You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • I'm not 100% sure what it's doing, but I'd say lookup tables are the way to go. Also allocating a new Uint16Array each time around the loop isn't great - it'd be faster as a normal array.

    Even something like:

    var gdimlookup = {
      15: function(i) {
                if (ma <390 && mi < 300) {
                    this.gdim[i]=3;
                    return 10.33;
                } else if (ma <700 && mi < 500) {
                    this.gdim[i]=7;
                    return 4.4;
                } else if (ma <1700 && mi < 1000) {
                    this.gdim[i]=15;
                    return 2.06;
                } 
            },
      ... 
    };
    // ...
            
            var f = gdimlookup[this.gdim[i]];
            var mult = f?f(i):1;
    
    

    would help, as it's not having to parse a whole bunch of stuff each time around the loop.

About

Avatar for Gordon @Gordon started