wu-sheng commented on a change in pull request #2776: Added minor performance 
improvements
URL: https://github.com/apache/skywalking/pull/2776#discussion_r288356183
 
 

 ##########
 File path: 
oap-server/server-library/library-util/src/main/java/org/apache/skywalking/oap/server/library/util/CollectionUtils.java
 ##########
 @@ -26,15 +26,15 @@
 public class CollectionUtils {
 
     public static boolean isEmpty(Map map) {
-        return map == null || map.size() == 0;
+        return map == null || map.isEmpty();
 
 Review comment:
   For making codes more clear, I would say YES for this PR. But I need to 
point out, even from your post(stackoverflow), there is not clear about 
`isEmpty` has better performance.
   In list(we only use ArrayList and LinkedList), there is no performance 
difference. Also, in `HashMap`/`HashSet`, it is the same too. Even more, when 
`isEmpty` call `size() == 0`, this change causes a more level in method stack. 
I don't know whether this could trigger side effect, but at least, it may not 
be better.
   
   So, right now, I would say this PR is only code style related, rather than 
performance improvement.
   
   If you have more clear test results, which could show I am wrong, please 
point out. Or do I miss anything in your StackOverflow post?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to