Bug 1024132 - Add one slot cache for stripping leading and trailing .* from RegExps for test() calls, r=jandem.

This commit is contained in:
Brian Hackett
2014-07-16 08:34:30 -08:00
parent dbfff343eb
commit 71ae4344b8
9 changed files with 203 additions and 5 deletions

View File

@@ -472,6 +472,22 @@ js::AtomizeString(ExclusiveContext *cx, JSString *str,
: AtomizeAndCopyChars(cx, linear->twoByteChars(nogc), linear->length(), ib);
}
JSAtom *
js::AtomizeSubstring(ExclusiveContext *cx, JSString *str, size_t start, size_t length,
InternBehavior ib /* = DoNotInternAtom */)
{
JS_ASSERT(start + length <= str->length());
JSLinearString *linear = str->ensureLinear(cx);
if (!linear)
return nullptr;
JS::AutoCheckCannotGC nogc;
return linear->hasLatin1Chars()
? AtomizeAndCopyChars(cx, linear->latin1Chars(nogc) + start, length, ib)
: AtomizeAndCopyChars(cx, linear->twoByteChars(nogc) + start, length, ib);
}
JSAtom *
js::Atomize(ExclusiveContext *cx, const char *bytes, size_t length, InternBehavior ib)
{