mozilla/shumway — pull request #1701 by mbebenita (2014-09-11 09:51:51+00:00)
Title: Bug 1063050 - Don't use DataView in DataBuffers.

Main change here is that we no longer use DataViews to read unaligned values, instead we just read byte by byte do a little bit of bit shifting. The second change, is that we no longer try to be clever about when to use different kinds of views. For instance, if you look at the current implementation of readInt(), you would think that optimizing it to check for 4 byte alignment and using a i32View would be more efficient. In reality it doesn't really make a difference and can actually be slower because of more branches and possibly making the function less inline worthy. I've experimented with this a bit, and I've concluded that the best thing to do here is to keep things as simple as possible.

```
readInt(): number /*int*/ {
var u8 = this._u8;
var position = this._position;
if (position + 4 > this._length) {
throwEOFError();
}
var a = u8[position + 0];
var b = u8[position + 1];
var c = u8[position + 2];
var d = u8[position + 3];
this._position = position + 4;
return this._littleEndian ?
(d << 24) | (c << 16) | (b << 8) | a :
(a << 24) | (b << 16) | (c << 8) | d;
}```