Browse Source

Optimize string comparison

Kajetan Johannes Hammerle 3 weeks ago
parent
commit
8f50ca109d
1 changed files with 5 additions and 5 deletions
  1. 5 5
      include/core/utils/ArrayString.hpp

+ 5 - 5
include/core/utils/ArrayString.hpp

@@ -29,12 +29,12 @@ namespace Core {
         }
 
         bool operator==(const CharType* s) const {
-            for(int i = 0; i < length; i++, s++) {
-                if(*s == '\0') {
-                    return *s == data[i];
-                }
+            const CharType* p = data;
+            while(*s == *p && *s != '\0') {
+                s++;
+                p++;
             }
-            return *s == '\0';
+            return *s == *p;
         }
 
         template<int L>