This is an automated email from the ASF dual-hosted git repository.

penghui pushed a commit to branch branch-2.8
in repository https://gitbox.apache.org/repos/asf/pulsar.git

commit ab8e94deedd3e6f2df777849d577180d686c739d
Author: GuoJiwei <[email protected]>
AuthorDate: Sat Jul 24 04:53:36 2021 +0800

    swap getTopicReference(topic).isPresent() with 
serviceUnit.includes(topicName) to reduce calling getTopicReference (#11405)
    
    ### Motivation
    
    Swap getTopicReference(topic).isPresent() with serviceUnit.includes to 
avoid calling getTopicReference to many times.
    
    #### For contributor
    
    This is a small optimization and does not require documentation。
    
    
    (cherry picked from commit 8b1d93754e0d68d9deab6fb5274575fe91a8832b)
---
 .../src/main/java/org/apache/pulsar/broker/service/BrokerService.java   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java
 
b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java
index d9a9d73..df0204c 100644
--- 
a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java
+++ 
b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java
@@ -1728,7 +1728,7 @@ public class BrokerService implements Closeable, 
ZooKeeperCacheListener<Policies
     public void cleanUnloadedTopicFromCache(NamespaceBundle serviceUnit) {
         for (String topic : topics.keys()) {
             TopicName topicName = TopicName.get(topic);
-            if (getTopicReference(topic).isPresent() && 
serviceUnit.includes(topicName)) {
+            if (serviceUnit.includes(topicName) && 
getTopicReference(topic).isPresent()) {
                 log.info("[{}][{}] Clean unloaded topic from cache.", 
serviceUnit.toString(), topic);
                 
pulsar.getBrokerService().removeTopicFromCache(topicName.toString(), 
serviceUnit);
             }

Reply via email to