zookeeper-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From 18779116352 <18779116...@163.com>
Subject Zookeeper code optimization
Date Mon, 24 Jun 2019 09:13:23 GMT
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