Closed Bug 550799 Opened 15 years ago Closed 15 years ago

Template root for fixed-sized arrays

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED WONTFIX

People

(Reporter: igor, Assigned: igor)

References

Details

+++ This bug was initially created as a clone of Bug #548702 +++ Not to grow the patch out of control the refactoring in the bug 548702 keeps the following code pattern: jsval roots[2]; memset(roots, 0, sizeof roots); JSAutoArrayRooter tvr(cx, roots, JS_ARRAY_LENGTH(roots)); ... root[0] = foo; root[1] = bar; We should replace it with template class like: template<size_t N> class JSAutoRoots { jsval data[N]; public: JSAutoRoots(JSContext *cx) ... { memset(data, 0, sizeof data); } jsval& operator[](size_t i) { JS_ASSERT(i < N); return data[i]; } ... }; With this class the above becomes: JSAutoRoots roots(cx); ... root[0] = foo; root[1] = bar;
This is no longer relevant in view of the conservative stack scanner.
Status: NEW → RESOLVED
Closed: 15 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.