perf(RecordRange): optimize disable()
There could be no lastEnabledChildRecord when there is no firstEnabledChildRecord - saves time by skipping findLastEnabledRecord() when the result is know to be null, - saves a test as isPresent(lastEnabledChildRecord) == isPresent(firstEnabledChildRecord)
This commit is contained in:
parent
27e03591dd
commit
5c531f718e
|
@ -23,7 +23,7 @@ export class ChangeDetector {
|
||||||
var currentGroup = record.groupMemento();
|
var currentGroup = record.groupMemento();
|
||||||
|
|
||||||
if (record.check()) {
|
if (record.check()) {
|
||||||
count ++;
|
count++;
|
||||||
if (record.terminatesExpression()) {
|
if (record.terminatesExpression()) {
|
||||||
updatedRecords = this._addRecord(updatedRecords, record);
|
updatedRecords = this._addRecord(updatedRecords, record);
|
||||||
}
|
}
|
||||||
|
|
|
@ -149,14 +149,13 @@ export class RecordRange {
|
||||||
|
|
||||||
remove() {
|
remove() {
|
||||||
var firstEnabledChildRecord = this.findFirstEnabledRecord();
|
var firstEnabledChildRecord = this.findFirstEnabledRecord();
|
||||||
var lastEnabledChildRecord = this.findLastEnabledRecord();
|
|
||||||
|
|
||||||
var next = this.tailRecord.next;
|
var next = this.tailRecord.next;
|
||||||
var prev = this.headRecord.prev;
|
var prev = this.headRecord.prev;
|
||||||
|
|
||||||
_link(prev, next);
|
_link(prev, next);
|
||||||
|
|
||||||
if (isPresent(firstEnabledChildRecord)) {
|
if (isPresent(firstEnabledChildRecord)) {
|
||||||
|
var lastEnabledChildRecord = this.findLastEnabledRecord();
|
||||||
var nextEnabled = lastEnabledChildRecord.nextEnabled;
|
var nextEnabled = lastEnabledChildRecord.nextEnabled;
|
||||||
var prevEnabled = firstEnabledChildRecord.prevEnabled;
|
var prevEnabled = firstEnabledChildRecord.prevEnabled;
|
||||||
if (isPresent(nextEnabled)) nextEnabled.prevEnabled = prevEnabled;
|
if (isPresent(nextEnabled)) nextEnabled.prevEnabled = prevEnabled;
|
||||||
|
@ -191,16 +190,14 @@ export class RecordRange {
|
||||||
|
|
||||||
disable() {
|
disable() {
|
||||||
var firstEnabledChildRecord = this.findFirstEnabledRecord();
|
var firstEnabledChildRecord = this.findFirstEnabledRecord();
|
||||||
var lastEnabledChildRecord = this.findLastEnabledRecord();
|
if (isPresent(firstEnabledChildRecord)) {
|
||||||
|
// There could be a last enabled record only if first enabled exists
|
||||||
var nextEnabled = isPresent(lastEnabledChildRecord) ?
|
var lastEnabledChildRecord = this.findLastEnabledRecord();
|
||||||
lastEnabledChildRecord.nextEnabled : null;
|
var nextEnabled = lastEnabledChildRecord.nextEnabled;
|
||||||
|
var prevEnabled = firstEnabledChildRecord.prevEnabled;
|
||||||
var prevEnabled = isPresent(firstEnabledChildRecord) ?
|
if (isPresent(nextEnabled)) nextEnabled.prevEnabled = prevEnabled;
|
||||||
firstEnabledChildRecord.prevEnabled : null;
|
if (isPresent(prevEnabled)) prevEnabled.nextEnabled = nextEnabled;
|
||||||
|
}
|
||||||
if (isPresent(nextEnabled)) nextEnabled.prevEnabled = prevEnabled;
|
|
||||||
if (isPresent(prevEnabled)) prevEnabled.nextEnabled = nextEnabled;
|
|
||||||
|
|
||||||
this.disabled = true;
|
this.disabled = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue