[Scummvm-git-logs] scummvm master -> 6f8764b14cbe962fab44a6f830e2423a81dd560f

lolbot-iichan lolbot_iichan at mail.ru
Sun Jun 20 23:29:08 UTC 2021


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
b886c238fe COMMON: Fix BASESTRING::contains()
6f8764b14c COMMON: Rewrite BASESTRING::contains() with algorithm from BASESTRING::find()


Commit: b886c238fe08a67c7d049e541a8180718396770f
    https://github.com/scummvm/scummvm/commit/b886c238fe08a67c7d049e541a8180718396770f
Author: lb_ii (lolbot_iichan at mail.ru)
Date: 2021-06-21T02:29:05+03:00

Commit Message:
COMMON: Fix BASESTRING::contains()

Changed paths:
    common/base-str.cpp


diff --git a/common/base-str.cpp b/common/base-str.cpp
index f9b9873410..bc0a41e7e6 100644
--- a/common/base-str.cpp
+++ b/common/base-str.cpp
@@ -422,6 +422,7 @@ TEMPLATE bool BASESTRING::contains(const BaseString &otherString) const {
 			if (sizeMatch == otherString.size())
 				return true;
 		} else {
+			itr2 -= sizeMatch;
 			sizeMatch = 0;
 			itr = otherString.begin();
 		}


Commit: 6f8764b14cbe962fab44a6f830e2423a81dd560f
    https://github.com/scummvm/scummvm/commit/6f8764b14cbe962fab44a6f830e2423a81dd560f
Author: lb_ii (lolbot_iichan at mail.ru)
Date: 2021-06-21T02:29:05+03:00

Commit Message:
COMMON: Rewrite BASESTRING::contains() with algorithm from BASESTRING::find()

Changed paths:
    common/base-str.cpp


diff --git a/common/base-str.cpp b/common/base-str.cpp
index bc0a41e7e6..9aa166225a 100644
--- a/common/base-str.cpp
+++ b/common/base-str.cpp
@@ -412,19 +412,18 @@ TEMPLATE bool BASESTRING::contains(const BaseString &otherString) const {
 		return false;
 	}
 
-	uint32 sizeMatch = 0;
-	typename BASESTRING::const_iterator itr = otherString.begin();
-
-	for (typename BASESTRING::const_iterator itr2 = begin(); itr != otherString.end() && itr2 != end(); itr2++) {
-		if (*itr == *itr2) {
-			itr++;
-			sizeMatch++;
-			if (sizeMatch == otherString.size())
+	for (const_iterator cur = begin(); cur != end(); ++cur) {
+		uint i = 0;
+		while (true) {
+			if (i == otherString.size()) {
 				return true;
-		} else {
-			itr2 -= sizeMatch;
-			sizeMatch = 0;
-			itr = otherString.begin();
+			}
+
+			if (cur[i] != otherString[i]) {
+				break;
+			}
+
+			++i;
 		}
 	}
 




More information about the Scummvm-git-logs mailing list