mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-08 04:27:37 +00:00
Bug 925949: Add fastpath to zeroLastIndex the normal RegExpObject, r=jwalden
This commit is contained in:
parent
427d30352c
commit
f0af93a292
@ -1788,8 +1788,14 @@ class MOZ_STACK_CLASS StringRegExpGuard
|
||||
if (!regExpIsObject())
|
||||
return true;
|
||||
|
||||
// Don't use RegExpObject::setLastIndex, because that ignores the
|
||||
// writability of "lastIndex" on this user-controlled RegExp object.
|
||||
// Use a fast path for same-global RegExp objects with writable
|
||||
// lastIndex.
|
||||
if (obj_->is<RegExpObject>() && obj_->nativeLookup(cx, cx->names().lastIndex)->writable()) {
|
||||
obj_->as<RegExpObject>().zeroLastIndex();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Handle everything else generically (including throwing if .lastIndex is non-writable).
|
||||
RootedValue zero(cx, Int32Value(0));
|
||||
return JSObject::setProperty(cx, obj_, obj_, cx->names().lastIndex, &zero, true);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user