mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-20 08:45:46 +00:00
Bug 1651732 - Part 8: Split ValueToId callers in js::Stringify. r=jandem
Only call `ValueToId` for primitive values in preparation for the next patch and instead call `ToAtom` for objects. Differential Revision: https://phabricator.services.mozilla.com/D83059
This commit is contained in:
parent
60f966c979
commit
616df230cc
@ -770,7 +770,12 @@ bool js::Stringify(JSContext* cx, MutableHandleValue vp, JSObject* replacer_,
|
||||
}
|
||||
|
||||
/* Step 4b(iii)(5)(c-g). */
|
||||
if (!item.isNumber() && !item.isString()) {
|
||||
RootedId id(cx);
|
||||
if (item.isNumber() || item.isString()) {
|
||||
if (!ValueToId<CanGC>(cx, item, &id)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
ESClass cls;
|
||||
if (!GetClassOfValue(cx, item, &cls)) {
|
||||
return false;
|
||||
@ -779,11 +784,13 @@ bool js::Stringify(JSContext* cx, MutableHandleValue vp, JSObject* replacer_,
|
||||
if (cls != ESClass::String && cls != ESClass::Number) {
|
||||
continue;
|
||||
}
|
||||
|
||||
JSAtom* atom = ToAtom<CanGC>(cx, item);
|
||||
if (!atom) {
|
||||
return false;
|
||||
}
|
||||
|
||||
RootedId id(cx);
|
||||
if (!ValueToId<CanGC>(cx, item, &id)) {
|
||||
return false;
|
||||
id.set(AtomToId(atom));
|
||||
}
|
||||
|
||||
/* Step 4b(iii)(5)(g). */
|
||||
|
Loading…
Reference in New Issue
Block a user