-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Conversation
I think that I can possibly implement this more efficiently but I wanted a proof of concept diff that wasn't totally insane. |
if (values) { | ||
var toDisplay = []; | ||
for (var i = 0, ii = values.length; i < ii; i++) { | ||
locals[valueName] = values[i]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sure I'm just not seeing it, but where is valueName
defined?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nevermind, apparently was searching for nameValue
--- so what are we doing, registering a $watchCollection in the middle of setup, for a single option?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What this is doing is saying, every digest loop, build a new array of all the display names, which are generated from expressions, which usually rely upon the valueName
. Then if this array changes then re-render.
It is rather heavy weight - if we could say that these expressions only ever depended upon the values
in the ng-option
expression then it could be much simpler.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't the goal here to update labels dynamically though? in which case the values wouldn't matter much.
I think we could do a better job by doing the work in a single watcher, but it would be hard to read/reason about (the select directive is already pretty hard to read and reason about)
The trouble with this is that we then also have to do the same for things like Really what I'd like to do is believe that all these functions are only affected by the scope.$watch(valuesFn, scheduleRendering, true); instead of the scope.$watchCollection(valuesFn, scheduleRendering); I tested this and it passes your test. It would of course fail if the |
we don't have a benchmark for <select> yet, afaik (it is possible that I'm wrong) --- the second watchCollection may be quicker than using object equality |
We're still better off than re-rendering on each digest, no? Is this worth implementing a benchmark for? |
02dc2aa
to
fd2d6c0
Compare
fd6f6f1
to
5e8d811
Compare
Closes #9025