mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 1388354 - Optimize ToPropertyKey a bit. r=anba
This commit is contained in:
parent
11d57944d7
commit
9f891645fa
@ -3176,6 +3176,20 @@ js::ToPrimitiveSlow(JSContext* cx, JSType preferredType, MutableHandleValue vp)
|
||||
return OrdinaryToPrimitive(cx, obj, preferredType, vp);
|
||||
}
|
||||
|
||||
/* ES6 draft rev 28 (2014 Oct 14) 7.1.14 */
|
||||
bool
|
||||
js::ToPropertyKeySlow(JSContext* cx, HandleValue argument, MutableHandleId result)
|
||||
{
|
||||
MOZ_ASSERT(argument.isObject());
|
||||
|
||||
// Steps 1-2.
|
||||
RootedValue key(cx, argument);
|
||||
if (!ToPrimitiveSlow(cx, JSTYPE_STRING, &key))
|
||||
return false;
|
||||
|
||||
// Steps 3-4.
|
||||
return ValueToId<CanGC>(cx, key, result);
|
||||
}
|
||||
|
||||
/* * */
|
||||
|
||||
|
@ -583,17 +583,17 @@ HasNoToPrimitiveMethodPure(JSObject* obj, JSContext* cx)
|
||||
return !prop;
|
||||
}
|
||||
|
||||
extern bool
|
||||
ToPropertyKeySlow(JSContext* cx, HandleValue argument, MutableHandleId result);
|
||||
|
||||
/* ES6 draft rev 28 (2014 Oct 14) 7.1.14 */
|
||||
inline bool
|
||||
MOZ_ALWAYS_INLINE bool
|
||||
ToPropertyKey(JSContext* cx, HandleValue argument, MutableHandleId result)
|
||||
{
|
||||
// Steps 1-2.
|
||||
RootedValue key(cx, argument);
|
||||
if (!ToPrimitive(cx, JSTYPE_STRING, &key))
|
||||
return false;
|
||||
if (MOZ_LIKELY(argument.isPrimitive()))
|
||||
return ValueToId<CanGC>(cx, argument, result);
|
||||
|
||||
// Steps 3-4.
|
||||
return ValueToId<CanGC>(cx, key, result);
|
||||
return ToPropertyKeySlow(cx, argument, result);
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user