Bug 411285 - "js_BoyerMooreHorspool is sometimes called for very short texts" [p=Seno.Aiko@gmail.com r=crowder a1.9=schrep]

This commit is contained in:
reed@reedloden.com 2008-01-15 22:37:13 -08:00
parent c6629bec99
commit dbfc68a956

View File

@ -1015,7 +1015,7 @@ str_indexOf(JSContext *cx, uintN argc, jsval *vp)
}
/* XXX tune the BMH threshold (512) */
if ((jsuint)(patlen - 2) <= BMH_PATLEN_MAX - 2 && textlen >= 512) {
if (textlen - i >= 512 && (jsuint)(patlen - 2) <= BMH_PATLEN_MAX - 2) {
index = js_BoyerMooreHorspool(text, textlen, pat, patlen, i);
if (index != BMH_BAD_PATTERN)
goto out;