docs(code-runtime-python): correct ownValues allocation claim

ownValues' JSDoc claimed the generator avoids a "second full-breadth
allocation before a single value is examined", but for...in still materializes
the key-name enumeration when the loop starts — the same JS limitation the
checkDoneValue rewrite now acknowledges. What the generator genuinely saves is
the extra VALUE array Object.values/Object.entries would copy; state that
precisely rather than implying sublinear startup.
This commit is contained in:
Chinesezjc
2026-08-07 13:27:54 +08:00
parent ae8070d799
commit b4487485c2
@@ -318,9 +318,12 @@ export function hasUnsafeIntegerToken(line: string): boolean {
/**
* Lazily yield one plain object's own enumerable property values. A generator
* (not `Object.values`/`Object.entries`) because {@link hasNonLosslessNumber}
* traverses breadth it cannot bound: those helpers copy the whole member list
* up front, so a wide forged object would cost a second full-breadth
* allocation before a single value is examined.
* walks breadth it cannot bound: those helpers copy the whole VALUE (or
* key/value pair) list into a fresh array up front, so a wide object would cost
* that second full-breadth allocation before a single value is examined. The
* `for...in` here does not make the walk sublinear — V8 still materializes the
* key-name enumeration when the loop starts — but it avoids the extra value
* array, yielding each value straight off the already-parsed object.
* @param record - a JSON-parse-produced object.
* @yields each own enumerable property value, in key order.
*/