caigy opened a new issue #3593:
URL: https://github.com/apache/rocketmq/issues/3593


   There are several inefficient iterations of Map, in such code, `keySet()` is 
retrieved from Map firstly, and values are got in each iteration by key.  In my 
opinion, `entrySet()` should be used, so that keys and values can be fetched in 
one time.
   
   For example, in `org.apache.rocketmq.common.Configuration#merge`:
   >     private void merge(Properties from, Properties to) {
   >         for (Object key : from.keySet()) {
   >             Object fromObj = from.get(key), toObj = to.get(key);
   >             if (toObj != null && !toObj.equals(fromObj)) {
   >                 log.info("Replace, key: {}, value: {} -> {}", key, toObj, 
fromObj);
   >             }
   >             to.put(key, fromObj);
   >         }
   >     }
   
   
   Some other examples: 
   - `org.apache.rocketmq.broker.filter.ConsumerFilterManager#unRegister`
   - `org.apache.rocketmq.broker.filter.MessageEvaluationContext#keyValues`
   - `org.apache.rocketmq.common.Configuration#mergeIfExist`
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to