Closed
Bug 927034
Opened 11 years ago
Closed 4 years ago
Use defineLazyPrototypeGetter where possible
Categories
(DevTools :: General, defect)
DevTools
General
Tracking
(Not tracked)
RESOLVED
INVALID
People
(Reporter: bbenvie, Unassigned)
References
Details
It is pretty common to the find the pattern of a getter on a prototype that does something like:
> get property() {
> if (this._property === null) {
> this._property = someCreatorFunction();
> }
> return this._property;
> }
Bug 926725 introduces "defineLazyPrototypeGetter" which encapsulates this pattern and does it in a more optimized way (rough testing shows ~140x speed improvements on subsequent property accesses). We should replace the these existing manualy lazy getters with this new function.
Victor mentions Item class and WidgetMethods widget setter method in ViewHelpers.jsm as a start and I'm sure we use this elsewhere.
Reporter | ||
Comment 1•11 years ago
|
||
This is also useful in places where we're calling `XPCOMUtils.defineLazyGetter` in a constructor. Using defineLazyPrototypeGetter in these cases is both more memory efficient and results in faster property accesses.
Updated•6 years ago
|
Product: Firefox → DevTools
Comment 2•4 years ago
|
||
We are already doing it in DevTools code base.
Honza
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → INVALID
You need to log in
before you can comment on or make changes to this bug.
Description
•