You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@zookeeper.apache.org by "tom.long (JIRA)" <ji...@apache.org> on 2019/07/08 06:29:00 UTC
[jira] [Created] (ZOOKEEPER-3457) Code optimization in
QuorumCnxManager
tom.long created ZOOKEEPER-3457:
-----------------------------------
Summary: Code optimization in QuorumCnxManager
Key: ZOOKEEPER-3457
URL: https://issues.apache.org/jira/browse/ZOOKEEPER-3457
Project: ZooKeeper
Issue Type: Improvement
Components: quorum
Affects Versions: 3.5.5
Reporter: tom.long
Fix For: 3.5.5
Dear developer:
I think the following code in line 623 of the QuorumCnxManager class can be optimized:
{code:java}
ArrayBlockingQueue<ByteBuffer> bq = new ArrayBlockingQueue<ByteBuffer>(
SEND_CAPACITY);
ArrayBlockingQueue<ByteBuffer> oldq = queueSendMap.putIfAbsent(sid, bq);
if (oldq != null) {
addToSendQueue(oldq, b);
} else {
addToSendQueue(bq, b);
}
{code}
The optimization is as follows:
{code:java}
ArrayBlockingQueue<ByteBuffer> bq = queueSendMap.computeIfAbsent(sid, serverId
-> new ArrayBlockingQueue<>(SEND_CAPACITY));
addToSendQueue(bq, b);
{code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)