Skip to content

Commit e1bebf1

Browse files
sapicscodebytere
authored andcommitted
src: fix FastStringKey equal operator
PR-URL: #33748 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]>
1 parent e0b0ddd commit e1bebf1

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/util-inl.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ bool StringEqualNoCase(const char* a, const char* b) {
300300
if (*a == '\0')
301301
return *b == '\0';
302302
if (*b == '\0')
303-
return *a == '\0';
303+
return false;
304304
} while (ToLower(*a++) == ToLower(*b++));
305305
return false;
306306
}
@@ -533,9 +533,9 @@ inline bool IsSafeJsInt(v8::Local<v8::Value> v) {
533533
constexpr size_t FastStringKey::HashImpl(const char* str) {
534534
// Low-quality hash (djb2), but just fine for current use cases.
535535
size_t h = 5381;
536-
do {
537-
h = h * 33 + *str; // NOLINT(readability/pointer_notation)
538-
} while (*(str++) != '\0');
536+
while (*str != '\0') {
537+
h = h * 33 + *(str++); // NOLINT(readability/pointer_notation)
538+
}
539539
return h;
540540
}
541541

@@ -551,7 +551,7 @@ constexpr bool FastStringKey::operator==(const FastStringKey& other) const {
551551
do {
552552
if (*(p1++) != *(p2++)) return false;
553553
} while (*p1 != '\0');
554-
return true;
554+
return *p2 == '\0';
555555
}
556556

557557
constexpr FastStringKey::FastStringKey(const char* name)

0 commit comments

Comments
 (0)