codelipenghui commented on code in PR #24457:
URL: https://github.com/apache/pulsar/pull/24457#discussion_r2167212606


##########
pulsar-common/src/main/java/org/apache/pulsar/common/naming/TopicName.java:
##########
@@ -152,18 +139,18 @@ private TopicName(String completeTopicName) {
             parts = Splitter.on("/").limit(4).splitToList(rest);
             if (parts.size() == 3) {
                 // New topic name without cluster name
-                this.tenant = parts.get(0);
+                this.tenant = StringInterner.intern(parts.get(0));
                 this.cluster = null;
-                this.namespacePortion = parts.get(1);
-                this.localName = parts.get(2);
+                this.namespacePortion = StringInterner.intern(parts.get(1));
+                this.localName = StringInterner.intern(parts.get(2));
                 this.partitionIndex = getPartitionIndex(completeTopicName);
                 this.namespaceName = NamespaceName.get(tenant, 
namespacePortion);
             } else if (parts.size() == 4) {
                 // Legacy topic name that includes cluster name
-                this.tenant = parts.get(0);
-                this.cluster = parts.get(1);
-                this.namespacePortion = parts.get(2);
-                this.localName = parts.get(3);
+                this.tenant = StringInterner.intern(parts.get(0));
+                this.cluster = StringInterner.intern(parts.get(1));
+                this.namespacePortion = StringInterner.intern(parts.get(2));
+                this.localName = StringInterner.intern(parts.get(3));

Review Comment:
   Is there any expected performance improvement from line 153? I see the 
benefit of deduplicating tenant and namespace, but I'm missing the context for 
the topic name. I'm wondering what cases would lead to a large number of 
duplicate topic names.



-- 
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: commits-unsubscr...@pulsar.apache.org

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

Reply via email to