From 0190cf6ce1d2a460353709f389f28367a98d223b Mon Sep 17 00:00:00 2001 From: sapics Date: Fri, 5 Jun 2020 21:50:03 +0900 Subject: [PATCH] src: fix FastStringKey equal operator PR-URL: https://github.com/nodejs/node/pull/33748 Reviewed-By: Anna Henningsen Reviewed-By: James M Snell Reviewed-By: Colin Ihrig Reviewed-By: Benjamin Gruenbaum --- src/util-inl.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/util-inl.h b/src/util-inl.h index 1af87d492ade06..5276fbef07f244 100644 --- a/src/util-inl.h +++ b/src/util-inl.h @@ -300,7 +300,7 @@ bool StringEqualNoCase(const char* a, const char* b) { if (*a == '\0') return *b == '\0'; if (*b == '\0') - return *a == '\0'; + return false; } while (ToLower(*a++) == ToLower(*b++)); return false; } @@ -533,9 +533,9 @@ inline bool IsSafeJsInt(v8::Local v) { constexpr size_t FastStringKey::HashImpl(const char* str) { // Low-quality hash (djb2), but just fine for current use cases. size_t h = 5381; - do { - h = h * 33 + *str; // NOLINT(readability/pointer_notation) - } while (*(str++) != '\0'); + while (*str != '\0') { + h = h * 33 + *(str++); // NOLINT(readability/pointer_notation) + } return h; } @@ -551,7 +551,7 @@ constexpr bool FastStringKey::operator==(const FastStringKey& other) const { do { if (*(p1++) != *(p2++)) return false; } while (*p1 != '\0'); - return true; + return *p2 == '\0'; } constexpr FastStringKey::FastStringKey(const char* name)