1
0
mirror of https://github.com/janet-lang/janet synced 2025-01-10 23:50:26 +00:00

Merge pull request #1519 from ianthehenry/fix-string-equal-with-byteview

fix janet_string_equalconst
This commit is contained in:
Calvin Rose 2024-11-17 07:33:47 -08:00 committed by GitHub
commit bafa6bfff0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -71,10 +71,10 @@ int janet_string_compare(const uint8_t *lhs, const uint8_t *rhs) {
int janet_string_equalconst(const uint8_t *lhs, const uint8_t *rhs, int32_t rlen, int32_t rhash) {
int32_t lhash = janet_string_hash(lhs);
int32_t llen = janet_string_length(lhs);
if (lhs == rhs)
return 1;
if (lhash != rhash || llen != rlen)
return 0;
if (lhs == rhs)
return 1;
return !memcmp(lhs, rhs, rlen);
}