Benchmarking overhead of bytes bounds checks

If the upfront bounds check is too expensive, it could instead be put in the try catch. This may get the best of both worlds.

I am thinking something like:


try {
    window.y = view.getInt32(offest);
} catch (e) {
    if (offset + 4 <= buffer.byteLength) {
        // Access is valid and error comes from another source.
        throw e;
    }
}
2 Likes