zookeeper-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Justin Ling Mao" <maoling199210...@sina.com>
Subject Re: Zookeeper code optimization
Date Fri, 05 Jul 2019 08:26:34 GMT
A good code optimizationCould you plz help us improve this issue?The contributor guideline
is [here](https://cwiki.apache.org/confluence/display/ZOOKEEPER/HowToContribute])

----- Original Message -----
From: 18779116352 <18779116352@163.com>
To: dev <dev@zookeeper.apache.org>
Subject: Zookeeper code optimization
Date: 2019-06-25 01:21

Dear developer:
    I think the following code in line 623 of the QuorumCnxManager class can be optimized:
    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);
}
    The optimization is as follows:
        ArrayBlockingQueue<ByteBuffer> bq = queueSendMap.computeIfAbsent(sid, serverId
-> new ArrayBlockingQueue<>(SEND_CAPACITY));
addToSendQueue(bq, b);
Thanks
    
| |
18779116352
邮箱:18779116352@163.com
|
Signature is customized by Netease Mail Master
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message