Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #34978

Re: Loop vs shift() closeby events

Newsgroups comp.lang.javascript
Date 2018-05-04 01:34 -0700
References <3666f183-fe87-4ba3-afbc-fcf71748b328@googlegroups.com>
Message-ID <edd8a6f4-6e27-488d-a8d6-2c39fbdbca1d@googlegroups.com> (permalink)
Subject Re: Loop vs shift() closeby events
From Julio Di Egidio <julio@diegidio.name>

Show all headers | View raw


On Friday, 4 May 2018 09:46:46 UTC+2, Jonas Thörnvall  wrote:
> 
> function doPlayup() {
>     if (copyEv.length) {
>        var waittime = copyEv.shift();
>        setTimeout(doPlayup, waittime); 
>     } 
> }
> 
> I am thinking that the shift() call maybe slow down the processing of
> closeby midievents?
> Would i gain tightness in performance by quantize lets say to 64 th notes,

Can't you just have an array and increment an index?

-------------------------------
var copyEv = ...
var copyEvIdx = 0;

function doPlayup() {
  if (copyEvIdx < copyEv.length) {
    var waittime = copyEv[copyEvIdx++];
    setTimeout(doPlayup, waittime);
  }
}
-------------------------------

Julio

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Loop vs shift() closeby events Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-05-04 00:46 -0700
  Re: Loop vs shift() closeby events Julio Di Egidio <julio@diegidio.name> - 2018-05-04 01:34 -0700
    Re: Loop vs shift() closeby events Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-05-23 21:23 -0700
      Re: Loop vs shift() closeby events Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-05-24 02:29 -0700
        Re: Loop vs shift() closeby events Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-05-24 23:58 -0700
          Re: Loop vs shift() closeby events Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-05-25 13:50 -0700

csiph-web