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 2020/06/10 11:33:07 UTC

[GitHub] [rocketmq] lizhiboo commented on issue #2082: StringBuffer or StringBuilder

lizhiboo commented on issue #2082:
URL: https://github.com/apache/rocketmq/issues/2082#issuecomment-641942366


   > I have seen the source code
   > **NamespaceUtil#wrapNamespace**
   > 
   > ```java
   > public static String wrapNamespace(String namespace, String resourceWithOutNamespace) {
   > 	// ...
   > 	StringBuffer strBuffer = new StringBuffer();
   > 
   > 	if (isRetryTopic(resourceWithOutNamespace)) {
   > 		strBuffer.append(MixAll.RETRY_GROUP_TOPIC_PREFIX);
   > 	}
   > 
   > 	if (isDLQTopic(resourceWithOutNamespace)) {
   > 		strBuffer.append(MixAll.DLQ_GROUP_TOPIC_PREFIX);
   > 	}
   > 
   > 	return strBuffer.append(namespace).append(NAMESPACE_SEPARATOR).append(resourceWithoutRetryAndDLQ).toString();
   > 
   > }
   > ```
   > 
   > Maybe use `StringBuilder` is better because I think it is local variable level and obj doesn't "escape" from this method.
   > 
   > Feel free to reply for studying, thanks.
   
   yep, StringBuilder performs better in this case.


----------------------------------------------------------------
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:
users@infra.apache.org