From 3565bd357c11b7fa5c3c14ce407c765d44ad91f4 Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Mon, 24 Jul 2017 15:20:02 +0000 Subject: Avoid temporaries and move string construction outside lock. --- messagebus/src/vespa/messagebus/protocolrepository.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'messagebus/src') diff --git a/messagebus/src/vespa/messagebus/protocolrepository.cpp b/messagebus/src/vespa/messagebus/protocolrepository.cpp index 681af440a89..26f6b53361f 100644 --- a/messagebus/src/vespa/messagebus/protocolrepository.cpp +++ b/messagebus/src/vespa/messagebus/protocolrepository.cpp @@ -52,8 +52,9 @@ ProtocolRepository::getRoutingPolicy(const string &protocolName, const string &policyName, const string &policyParam) { + string cacheKey = protocolName; + cacheKey.append('.').append(policyName).append(".").append(policyParam); vespalib::LockGuard guard(_lock); - string cacheKey = protocolName + "." + policyName + "." + policyParam; RoutingPolicyCache::iterator cit = _routingPolicyCache.find(cacheKey); if (cit != _routingPolicyCache.end()) { return cit->second; @@ -67,12 +68,10 @@ ProtocolRepository::getRoutingPolicy(const string &protocolName, try { policy = pit->second->createPolicy(policyName, policyParam); } catch (const std::exception &e) { - LOG(error, "Protocol '%s' threw an exception; %s", - protocolName.c_str(), e.what()); + LOG(error, "Protocol '%s' threw an exception; %s", protocolName.c_str(), e.what()); } if (policy.get() == NULL) { - LOG(error, "Protocol '%s' failed to create routing policy '%s' " - "with parameter '%s'.", + LOG(error, "Protocol '%s' failed to create routing policy '%s' with parameter '%s'.", protocolName.c_str(), policyName.c_str(), policyParam.c_str()); return IRoutingPolicy::SP(); } -- cgit v1.2.3