perf(Change Detection): Track the range & group on changes only
1.4x speed improvement with Firefox There is no need to track the range & group for all the records but only for the records that have changed.
This commit is contained in:
parent
ee36063fae
commit
2c4a2f5158
|
@ -17,24 +17,23 @@ export class ChangeDetector {
|
||||||
var count = 0;
|
var count = 0;
|
||||||
var updatedRecords = null;
|
var updatedRecords = null;
|
||||||
var record = this._rootRecordRange.findFirstEnabledRecord();
|
var record = this._rootRecordRange.findFirstEnabledRecord();
|
||||||
|
var currentRange, currentGroup;
|
||||||
|
|
||||||
while (isPresent(record)) {
|
while (isPresent(record)) {
|
||||||
var currentRange = record.recordRange;
|
|
||||||
var currentGroup = record.groupMemento();
|
|
||||||
|
|
||||||
if (record.check()) {
|
if (record.check()) {
|
||||||
count++;
|
count++;
|
||||||
if (record.terminatesExpression()) {
|
if (record.terminatesExpression()) {
|
||||||
|
currentRange = record.recordRange;
|
||||||
|
currentGroup = record.groupMemento();
|
||||||
updatedRecords = this._addRecord(updatedRecords, record);
|
updatedRecords = this._addRecord(updatedRecords, record);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isPresent(updatedRecords)) {
|
if (isPresent(updatedRecords)) {
|
||||||
var nextEnabled = record.nextEnabled;
|
var nextEnabled = record.nextEnabled;
|
||||||
var nextRange = isPresent(nextEnabled) ? nextEnabled.recordRange : null;
|
if (isBlank(nextEnabled) || // we have reached the last enabled record
|
||||||
var nextGroup = isPresent(nextEnabled) ? nextEnabled.groupMemento() : null;
|
currentRange != nextEnabled.recordRange || // the next record is in a different range
|
||||||
|
currentGroup != nextEnabled.groupMemento()) { // the next record is in a different group
|
||||||
if (currentRange != nextRange || currentGroup != nextGroup) {
|
|
||||||
currentRange.dispatcher.onRecordChange(currentGroup, updatedRecords);
|
currentRange.dispatcher.onRecordChange(currentGroup, updatedRecords);
|
||||||
updatedRecords = null;
|
updatedRecords = null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue