Optimize ActorContext a bit 24/14424/1
authorRobert Varga <rovarga@cisco.com>
Fri, 23 Jan 2015 10:14:26 +0000 (11:14 +0100)
committerRobert Varga <rovarga@cisco.com>
Fri, 23 Jan 2015 11:13:51 +0000 (12:13 +0100)
Do not perform .toString() on objects passed to loggers -- it will be
invoked automatically if the message is not filtered.

Use a simple character lookup instead of a string.

Change-Id: I262298c767a1363daf3c8f7e83f994e70e0cf6bf
Signed-off-by: Robert Varga <rovarga@cisco.com>
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/ActorContext.java

index f81c2a87cd8694dab4c5c194a3a3be05af6bc282..f217d05bb21a12e6f92add47da5536c6f6fe12d9 100644 (file)
@@ -279,7 +279,7 @@ public class ActorContext {
         Preconditions.checkArgument(actor != null, "actor must not be null");
         Preconditions.checkArgument(message != null, "message must not be null");
 
-        LOG.debug("Sending message {} to {}", message.getClass().toString(), actor.toString());
+        LOG.debug("Sending message {} to {}", message.getClass(), actor);
         return ask(actor, message, timeout);
     }
 
@@ -314,7 +314,7 @@ public class ActorContext {
         Preconditions.checkArgument(actor != null, "actor must not be null");
         Preconditions.checkArgument(message != null, "message must not be null");
 
-        LOG.debug("Sending message {} to {}", message.getClass().toString(), actor.toString());
+        LOG.debug("Sending message {} to {}", message.getClass(), actor);
 
         return ask(actor, message, timeout);
     }
@@ -341,7 +341,7 @@ public class ActorContext {
         Preconditions.checkArgument(actor != null, "actor must not be null");
         Preconditions.checkArgument(message != null, "message must not be null");
 
-        LOG.debug("Sending message {} to {}", message.getClass().toString(), actor.toString());
+        LOG.debug("Sending message {} to {}", message.getClass(), actor);
 
         actor.tell(message, ActorRef.noSender());
     }
@@ -386,14 +386,14 @@ public class ActorContext {
             return false;
         }
 
-        int pathAtIndex = path.indexOf("@");
+        int pathAtIndex = path.indexOf('@');
         if (pathAtIndex == -1) {
             //if the path is of local format, then its local and is co-located
             return true;
 
         } else if (selfAddressHostPort != null) {
             // self-address and tx actor path, both are of remote path format
-            int slashIndex = path.indexOf("/", pathAtIndex);
+            int slashIndex = path.indexOf('/', pathAtIndex);
 
             if (slashIndex == -1) {
                 return false;