Commit fb51d1f4 authored by Rye Mutt's avatar Rye Mutt 🍞
Browse files

Reduce string temporaries in capability lookups

parent d1cbb53a
...@@ -84,6 +84,10 @@ ...@@ -84,6 +84,10 @@
#include "llweb.h" #include "llweb.h"
#include "llcurrencywrapper.h" #include "llcurrencywrapper.h"
// Constants
static const std::string CAP_NAME_SEED("Seed");
static const std::string CAP_NAME_OBJECT_MEDIA("ObjectMedia");
// When we receive a base grant of capabilities that has a different number of // When we receive a base grant of capabilities that has a different number of
// capabilities than the original base grant received for the region, print // capabilities than the original base grant received for the region, print
// out the two lists of capabilities for analysis. // out the two lists of capabilities for analysis.
...@@ -255,7 +259,7 @@ void LLViewerRegionImpl::requestBaseCapabilitiesCoro(U64 regionHandle) ...@@ -255,7 +259,7 @@ void LLViewerRegionImpl::requestBaseCapabilitiesCoro(U64 regionHandle)
LL_DEBUGS("AppInit", "Capabilities") << "requesting seed caps for handle " << regionHandle LL_DEBUGS("AppInit", "Capabilities") << "requesting seed caps for handle " << regionHandle
<< " name " << regionp->getName() << LL_ENDL; << " name " << regionp->getName() << LL_ENDL;
std::string url = regionp->getCapability("Seed"); std::string url = regionp->getCapability(CAP_NAME_SEED);
if (url.empty()) if (url.empty())
{ {
LL_WARNS("AppInit", "Capabilities") << "Failed to get seed capabilities, and can not determine url!" << LL_ENDL; LL_WARNS("AppInit", "Capabilities") << "Failed to get seed capabilities, and can not determine url!" << LL_ENDL;
...@@ -378,7 +382,7 @@ void LLViewerRegionImpl::requestBaseCapabilitiesCompleteCoro(U64 regionHandle) ...@@ -378,7 +382,7 @@ void LLViewerRegionImpl::requestBaseCapabilitiesCompleteCoro(U64 regionHandle)
break; // this error condition is not recoverable. break; // this error condition is not recoverable.
} }
std::string url = regionp->getCapabilityDebug("Seed"); std::string url = regionp->getCapabilityDebug(CAP_NAME_SEED);
if (url.empty()) if (url.empty())
{ {
LL_WARNS("AppInit", "Capabilities") << "Failed to get seed capabilities, and can not determine url!" << LL_ENDL; LL_WARNS("AppInit", "Capabilities") << "Failed to get seed capabilities, and can not determine url!" << LL_ENDL;
...@@ -3039,7 +3043,7 @@ void LLViewerRegionImpl::buildCapabilityNames(LLSD& capabilityNames) ...@@ -3039,7 +3043,7 @@ void LLViewerRegionImpl::buildCapabilityNames(LLSD& capabilityNames)
capabilityNames.append("NavMeshGenerationStatus"); capabilityNames.append("NavMeshGenerationStatus");
capabilityNames.append("NewFileAgentInventory"); capabilityNames.append("NewFileAgentInventory");
capabilityNames.append("ObjectAnimation"); capabilityNames.append("ObjectAnimation");
capabilityNames.append("ObjectMedia"); capabilityNames.append(CAP_NAME_OBJECT_MEDIA);
capabilityNames.append("ObjectMediaNavigate"); capabilityNames.append("ObjectMediaNavigate");
capabilityNames.append("ObjectNavMeshProperties"); capabilityNames.append("ObjectNavMeshProperties");
capabilityNames.append("OpenSimExtras"); capabilityNames.append("OpenSimExtras");
...@@ -3088,9 +3092,9 @@ void LLViewerRegionImpl::buildCapabilityNames(LLSD& capabilityNames) ...@@ -3088,9 +3092,9 @@ void LLViewerRegionImpl::buildCapabilityNames(LLSD& capabilityNames)
void LLViewerRegion::setSeedCapability(const std::string& url) void LLViewerRegion::setSeedCapability(const std::string& url)
{ {
if (getCapability("Seed") == url) if (getCapability(CAP_NAME_SEED) == url)
{ {
setCapabilityDebug("Seed", url); setCapabilityDebug(CAP_NAME_SEED, url);
LL_WARNS("CrossingCaps") << "Received duplicate seed capability, posting to seed " << LL_WARNS("CrossingCaps") << "Received duplicate seed capability, posting to seed " <<
url << LL_ENDL; url << LL_ENDL;
...@@ -3105,7 +3109,7 @@ void LLViewerRegion::setSeedCapability(const std::string& url) ...@@ -3105,7 +3109,7 @@ void LLViewerRegion::setSeedCapability(const std::string& url)
mImpl->mEventPoll = nullptr; mImpl->mEventPoll = nullptr;
mImpl->mCapabilities.clear(); mImpl->mCapabilities.clear();
setCapability("Seed", url); setCapability(CAP_NAME_SEED, url);
std::string coroname = std::string coroname =
LLCoros::instance().launch("LLViewerRegionImpl::requestBaseCapabilitiesCoro", LLCoros::instance().launch("LLViewerRegionImpl::requestBaseCapabilitiesCoro",
...@@ -3222,7 +3226,7 @@ std::string LLViewerRegion::getCapabilityDebug(const std::string& name) const ...@@ -3222,7 +3226,7 @@ std::string LLViewerRegion::getCapabilityDebug(const std::string& name) const
CapabilityMap::const_iterator iter = mImpl->mSecondCapabilitiesTracker.find(name); CapabilityMap::const_iterator iter = mImpl->mSecondCapabilitiesTracker.find(name);
if (iter == mImpl->mSecondCapabilitiesTracker.end()) if (iter == mImpl->mSecondCapabilitiesTracker.end())
{ {
return ""; return std::string();
} }
return iter->second; return iter->second;
...@@ -3236,7 +3240,7 @@ bool LLViewerRegion::isSpecialCapabilityName(const std::string &name) ...@@ -3236,7 +3240,7 @@ bool LLViewerRegion::isSpecialCapabilityName(const std::string &name)
std::string LLViewerRegion::getCapability(const std::string& name) const std::string LLViewerRegion::getCapability(const std::string& name) const
{ {
if (!capabilitiesReceived() && (name!=std::string("Seed")) && (name!=std::string("ObjectMedia"))) if (!capabilitiesReceived() && (name != CAP_NAME_SEED) && (name != CAP_NAME_OBJECT_MEDIA))
{ {
LL_WARNS() << "getCapability called before caps received for " << name << LL_ENDL; LL_WARNS() << "getCapability called before caps received for " << name << LL_ENDL;
} }
...@@ -3244,7 +3248,7 @@ std::string LLViewerRegion::getCapability(const std::string& name) const ...@@ -3244,7 +3248,7 @@ std::string LLViewerRegion::getCapability(const std::string& name) const
CapabilityMap::const_iterator iter = mImpl->mCapabilities.find(name); CapabilityMap::const_iterator iter = mImpl->mCapabilities.find(name);
if(iter == mImpl->mCapabilities.end()) if(iter == mImpl->mCapabilities.end())
{ {
return ""; return std::string();
} }
return iter->second; return iter->second;
...@@ -3252,7 +3256,7 @@ std::string LLViewerRegion::getCapability(const std::string& name) const ...@@ -3252,7 +3256,7 @@ std::string LLViewerRegion::getCapability(const std::string& name) const
bool LLViewerRegion::isCapabilityAvailable(const std::string& name) const bool LLViewerRegion::isCapabilityAvailable(const std::string& name) const
{ {
if (!capabilitiesReceived() && (name!=std::string("Seed")) && (name!=std::string("ObjectMedia"))) if (!capabilitiesReceived() && (name!= CAP_NAME_SEED) && (name != CAP_NAME_OBJECT_MEDIA))
{ {
LL_WARNS() << "isCapabilityAvailable called before caps received for " << name << LL_ENDL; LL_WARNS() << "isCapabilityAvailable called before caps received for " << name << LL_ENDL;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment