Opened 11 years ago
Closed 11 years ago
#10152 closed task (wontfix)
_Widget: _applyAttributes() and getSettertAttributes() optimization
Reported by: | bill | Owned by: | bill |
---|---|---|---|
Priority: | high | Milestone: | 1.5 |
Component: | Dijit | Version: | 1.4.0b |
Keywords: | Cc: | Les | |
Blocked By: | Blocking: |
Description
_applyAttributes() calls this.attr(name, value) on every widget attribute that occurs in either attributeMap or has a custom setter (or both, which happens due to subclassing).
getSetterAttributes() computes the list of attributes with custom setters.
Two possible optimizations are:
1) modify getSetterAttributes() to make the entire list of attributes that occur either in (a) attributeMap or (b) have a custom setter.
2) optimizations on how to find which attributes have custom setters. There are a lot of ways to do that which I was playing with last night, many of which don't use isFunction() or regexp's at all.
I'm attaching a patch that needs more benchmarking and testing.
Attachments (1)
Change History (3)
Changed 11 years ago by
Attachment: | applyAttributes.patch added |
---|
comment:1 Changed 11 years ago by
Cc: | Les added |
---|---|
Owner: | set to bill |
comment:2 Changed 11 years ago by
Resolution: | → wontfix |
---|---|
Status: | new → closed |
I worked on this for a few days and I think it's better to drop it, at least until it occurs as part of a bigger refactor for 2.0.
The optimization was supposed to speed up widget instantiation, so it was to be useful when creating a lot of the same widget (like the 100 buttons that benchTool.html creates). But I'm not seeing any measurable effect.
More than that though, this code is very fragile. I tried to simplify things by calling attr() for every constructor parameter plus for attributes with non-blank default values:
where getDefaultParams() returned a subset of the prototype, for example for dijit.form.Button:
The (cached) result of getDefaultParams() didn't have attributes like title, style, class, etc. since they don't need attr() calls on widget instantiation unless they have a value specified in the constructor params.
getDefaultParams() was efficient because it's only computed once per widget class, no matter how many instances of the widget were created.
This didn't work for a number of reasons:
new Date("")
, but then in [12165] and [14404] there's some hackish code to convert the prototype'snew Date("")
into null in the instance.<input>
is different than<input name="">
. The former doesn't submit the value with the form at all, but the latter causes submission w/a "" name, ex:foo.php?=bar