From d0249fb7c099d30015f22e49cc5421f3c80e05b7 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Sat, 17 Sep 2016 20:54:50 -0400 Subject: MAINT-5232: Eliminate pointless string search for "class " prefix. The Visual C++ runtime produces typeid(MyClass).name() as "class MyClass". It's prudent to check for the presence of that prefix before stripping off the first six characters, but if the first comparison should ever fail, find() would continue searching the rest of the string for "class " -- a search guaranteed to fail. Use compare() instead. --- indra/llcommon/llerror.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'indra') diff --git a/indra/llcommon/llerror.cpp b/indra/llcommon/llerror.cpp index 2ef748e3e4..245118b00f 100644 --- a/indra/llcommon/llerror.cpp +++ b/indra/llcommon/llerror.cpp @@ -270,15 +270,15 @@ namespace LLError // DevStudio: type_info::name() includes the text "class " at the start static const std::string class_prefix = "class "; - std::string name = mangled; - std::string::size_type p = name.find(class_prefix); - if (p == std::string::npos) + if (0 != name.compare(0, class_prefix.length(), class_prefix)) { + LL_DEBUGS() << "Did not see '" << class_prefix << "' prefix on '" + << name << "'" << LL_ENDL; return name; } - return name.substr(p + class_prefix.size()); + return name.substr(class_prefix.length()); #else return mangled; -- cgit v1.2.3