Use std::string_view to avoid redundant std::string construction

post_malone
elsid 2 years ago
parent caf971b979
commit ba69146ced
No known key found for this signature in database
GPG Key ID: 4DE04C198CBA7625

@ -12,7 +12,7 @@ CSMWorld::Scope CSMWorld::getScopeFromId (const std::string& id)
std::string::size_type i = id.find ("::");
if (i!=std::string::npos)
namespace_ = Misc::StringUtils::lowerCase (id.substr (0, i));
namespace_ = Misc::StringUtils::lowerCase(std::string_view(id).substr(0, i));
if (namespace_=="project")
return Scope_Project;

@ -293,5 +293,5 @@ bool MWDialogue::SelectWrapper::selectCompare (bool value) const
std::string MWDialogue::SelectWrapper::getName() const
{
return Misc::StringUtils::lowerCase (mSelect.mSelectRule.substr (5));
return Misc::StringUtils::lowerCase(std::string_view(mSelect.mSelectRule).substr(5));
}

@ -36,7 +36,7 @@ namespace Interpreter{
if(eschar == '%' || eschar == '^')
{
retval << text.substr(start, i - start);
std::string temp = Misc::StringUtils::lowerCase(text.substr(i+1, 100));
std::string temp = Misc::StringUtils::lowerCase(std::string_view(text).substr(i + 1, 100));
bool found = false;
try
@ -170,10 +170,10 @@ namespace Interpreter{
sort(globals.begin(), globals.end(), longerStr);
}
for(unsigned int j = 0; j < globals.size(); j++){
if(globals[j].length() > temp.length()){ // Just in case there's a global with a huuuge name
temp = Misc::StringUtils::lowerCase(text.substr(i+1, globals[j].length()));
}
for(unsigned int j = 0; j < globals.size(); j++)
{
if (globals[j].length() > temp.length()) // Just in case there's a global with a huuuge name
temp = Misc::StringUtils::lowerCase(std::string_view(text).substr(i + 1, globals[j].length()));
found = check(temp, globals[j], &i, &start);
if(found){

@ -27,7 +27,8 @@ namespace Resource
void RetrieveAnimationsVisitor::apply(osg::Node& node)
{
if (node.libraryName() == std::string("osgAnimation") && node.className() == std::string("Bone") && Misc::StringUtils::lowerCase(node.getName()) == std::string("bip01"))
if (node.libraryName() == std::string_view("osgAnimation") && node.className() == std::string_view("Bone")
&& Misc::StringUtils::lowerCase(node.getName()) == std::string_view("bip01"))
{
osg::ref_ptr<SceneUtil::OsgAnimationController> callback = new SceneUtil::OsgAnimationController();

Loading…
Cancel
Save