mirror of
https://github.com/Tonejs/Tone.js
synced 2024-11-16 00:27:58 +00:00
small optimization reducing the number of cancelScheduledValues calls
first check if there are any more values which are scheduled
This commit is contained in:
parent
b4b924f2e0
commit
37a62137fa
1 changed files with 7 additions and 4 deletions
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue