LibRegex: Searching for anchored patterns like /^b/ should fail early if possible
awesomekling opened this issue · comments
If we're looking for /^b/
in the string aaaaaa
(and multi-line mode is not enabled), we should be smarter than to scan through every single a
before bailing.
Reduction from https://fragrantica.com/
const mb = 100;
console.log("Create " + mb + "MB string");
let s = "a".repeat(mb * 1048576);
let re = /^b/
console.log("Search for " + re + " in string");
for (let i = 0; i < 10_000; ++i) {
console.log(re.test(s));
}