You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2021/12/07 01:58:20 UTC

[GitHub] [rocketmq] caigy opened a new issue #3593: Inefficient iteration of Map

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: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [rocketmq] Git-Yang commented on issue #3593: Inefficient iteration of Map

Posted by GitBox <gi...@apache.org>.
Git-Yang commented on issue #3593:
URL: https://github.com/apache/rocketmq/issues/3593#issuecomment-989578556


   Merged


-- 
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: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [rocketmq] zhaohai1299002788 commented on issue #3593: Inefficient iteration of Map

Posted by GitBox <gi...@apache.org>.
zhaohai1299002788 commented on issue #3593:
URL: https://github.com/apache/rocketmq/issues/3593#issuecomment-987529754


   #3595


-- 
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: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [rocketmq] Git-Yang closed issue #3593: Inefficient iteration of Map

Posted by GitBox <gi...@apache.org>.
Git-Yang closed issue #3593:
URL: https://github.com/apache/rocketmq/issues/3593


   


-- 
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: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org