small optimization reducing the number of cancelScheduledValues calls

first check if there are any more values which are scheduled
This commit is contained in:
Yotam Mann 2019-07-24 19:50:49 -04:00
parent b4b924f2e0
commit 37a62137fa

View file

@ -342,10 +342,13 @@ implements AbstractParam<Type> {
cancelScheduledValues(time: Time): this {
const computedTime = this.toSeconds(time);
this._events.cancel(computedTime);
this.assert(isFinite(computedTime), `Invalid argument to cancelScheduledValues: ${JSON.stringify(time)}`);
this._param.cancelScheduledValues(computedTime);
this.log("cancel", computedTime);
// remove the events only if there is another event after
if (this._events.getFrom(computedTime)) {
this._events.cancel(computedTime);
this._param.cancelScheduledValues(computedTime);
this.log("cancel", computedTime);
}
return this;
}
@ -356,7 +359,7 @@ implements AbstractParam<Type> {
// remove the schedule events
this.assert(isFinite(computedTime), `Invalid argument to cancelAndHoldAtTime: ${JSON.stringify(time)}`);
this._param.cancelScheduledValues(computedTime);
this.cancelScheduledValues(computedTime);
// if there is an event at the given computedTime
// and that even is not a "set"