-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Group redraw performance #3409
Group redraw performance #3409
Changes from all commits
0b4dc73
845a01a
6b8e2b3
329d981
c00ebf2
3ed7477
d7b770c
6dba6bd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -681,13 +681,37 @@ ItemSet.prototype.redraw = function() { | |
// redraw the background group | ||
this.groups[BACKGROUND].redraw(range, nonFirstMargin, forceRestack); | ||
|
||
// redraw all regular groups | ||
util.forEach(this.groups, function (group) { | ||
var groupMargin = (group == firstGroup) ? firstMargin : nonFirstMargin; | ||
var groupResized = group.redraw(range, groupMargin, forceRestack); | ||
resized = groupResized || resized; | ||
height += group.height; | ||
var redrawQueue = {}; | ||
var redrawQueueLength = 0; | ||
|
||
// collect redraw functions | ||
util.forEach(this.groups, function (group, key) { | ||
if (key === BACKGROUND) return; | ||
var groupMargin = group == firstGroup ? firstMargin : nonFirstMargin; | ||
var returnQueue = true; | ||
redrawQueue[key] = group.redraw(range, groupMargin, forceRestack, returnQueue); | ||
redrawQueueLength = redrawQueue[key].length; | ||
}); | ||
|
||
if (redrawQueueLength) { | ||
var redrawResults = {}; | ||
|
||
for (var i = 0; i < redrawQueueLength; i++) { | ||
util.forEach(redrawQueue, function (fns, key) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oof this stuff is almost over the top of my head. But shouldn't this be:
If I got it wrong here, please explain. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Im sorry for bad naming :(
So redrawQueue is an queue, and every element in this queue is array of functions. And when we release this queue, we call all functions from every element of queue. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice to see you react to a question on the code. I was expecting @yotamberk, but I understand the original comes from you. Will try to wrap my brain around it again. Perhaps some commenting would be in order here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, I think I got it. The logic of this escapes me, but there must be a good reason for it. Perhaps I should not be reviewing. |
||
redrawResults[key] = fns[i](); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But then the |
||
}); | ||
} | ||
|
||
// redraw all regular groups | ||
util.forEach(this.groups, function (group, key) { | ||
if (key === BACKGROUND) return; | ||
var groupResized = redrawResults[key]; | ||
resized = groupResized || resized; | ||
height += group.height; | ||
}); | ||
height = Math.max(height, minHeight); | ||
} | ||
|
||
height = Math.max(height, minHeight); | ||
|
||
// update frame height | ||
|
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.
For my understanding: this is the last function in the queue and it returns something. The return value is collected here. Is this the intention?
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 suppose the assignment to
resize
isn't really necessary for the return, but it's kept in for completeness. I guess this is OK (I would probably do the same).