From 29f0a7808ff470bd20c76b089881c98b3b59e6fc Mon Sep 17 00:00:00 2001
From: andreykproductengine <andreykproductengine@lindenlab.com>
Date: Tue, 16 Apr 2019 21:58:22 +0300
Subject: [PATCH] SL-10930 LLStringUtil pointlessly scan the string

---
 indra/llcommon/llstring.h | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/indra/llcommon/llstring.h b/indra/llcommon/llstring.h
index 30bec3a6f89..b619a9e48c5 100644
--- a/indra/llcommon/llstring.h
+++ b/indra/llcommon/llstring.h
@@ -1735,7 +1735,8 @@ bool LLStringUtilBase<T>::startsWith(
 	const string_type& substr)
 {
 	if(string.empty() || (substr.empty())) return false;
-	if(0 == string.find(substr)) return true;
+	if (substr.length() > string.length()) return false;
+	if (0 == string.compare(0, substr.length(), substr)) return true;
 	return false;
 }
 
@@ -1746,9 +1747,11 @@ bool LLStringUtilBase<T>::endsWith(
 	const string_type& substr)
 {
 	if(string.empty() || (substr.empty())) return false;
-	std::string::size_type idx = string.rfind(substr);
-	if(std::string::npos == idx) return false;
-	return (idx == (string.size() - substr.size()));
+	size_t sub_len = substr.length();
+	size_t str_len = string.length();
+	if (sub_len > str_len) return false;
+	if (0 == string.compare(str_len - sub_len, sub_len, substr)) return true;
+	return false;
 }
 
 // static
-- 
GitLab