You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2017/12/09 00:15:34 UTC

[GitHub] rdhabalia commented on a change in pull request #952: Reduce duplicate string allocation for GC improvements

rdhabalia commented on a change in pull request #952: Reduce duplicate string allocation for GC improvements
URL: https://github.com/apache/incubator-pulsar/pull/952#discussion_r155903555
 
 

 ##########
 File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractReplicator.java
 ##########
 @@ -211,7 +211,7 @@ public static String getRemoteCluster(String remoteCursor) {
     }
 
     public static String getReplicatorName(String replicatorPrefix, String cluster) {
-        return String.format("%s.%s", replicatorPrefix, cluster);
+        return (replicatorPrefix + "." + cluster).intern();
 
 Review comment:
   actually I ran a test where I saw that `String.format("%s%s",x,y).intern()` allocates some more number of string objects than `(x+"."+y).intern()` when I checked with `jmap -histo <pid> | grep String`. However, `intern()` still reuses objects in both cases but somehow, `String.format()` adds some more instances compare to append. 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services