From: Dmitry Volyntsev Date: Wed, 22 May 2024 06:41:10 +0000 (-0700) Subject: Aligned StringIndexOf() implementation with the spec. X-Git-Tag: 0.8.5~25 X-Git-Url: http://www.kaiwu.me/postgresql/commit/static/gitweb.js?a=commitdiff_plain;h=4bb4c5eaebe29732edd84db44f9aefa666d9081b;p=njs.git Aligned StringIndexOf() implementation with the spec. When searchValue is empty the function should return early when fromIndex <= len is also true. --- diff --git a/src/njs_string.c b/src/njs_string.c index 4ef162df..95514274 100644 --- a/src/njs_string.c +++ b/src/njs_string.c @@ -1710,8 +1710,8 @@ njs_string_index_of(njs_string_prop_t *string, njs_string_prop_t *search, length = string->length; - if (njs_slow_path(search->length == 0)) { - return (from < length) ? from : length; + if (search->length == 0 && from <= length) { + return from; } index = from;