• Is there any performance gain when using Uint8Arrays over normal arrays?

    Yes, there's quite a bit - also memory usage is miles lower :)

    However it depends how many array items you have - if it's ~32 then it probably doesn't matter - if it's more than that then Uint8Array will noticeably better.

    The thing is, normal arrays have operations like concat that are much faster than implementing the same for Uint8Array

    In that case you'd have to do something like:

    var result = new Uint8Array(a.length+b.length);
    result.set(a,0);
    result.set(b,a.length);
    

    It's slightly more long-winded but is far faster than a FOR-loop copy :)

About

Avatar for Gordon @Gordon started