FWIW, I would expect that to be faster than creating new Typed Arrays on each 
read.  The Garbage Collection implications of an instantiation on each read 
made me cringe.

My 2 cents,
-Alex

On 6/20/18, 1:31 AM, "Harbs" <[email protected]> wrote:

    I ended up rewriting the read methods to use simple math and shift 
operators. It reads bytes directly from the existing Uint8Array and uses shift 
operators to convert unsigned ints to signed ones. Over-all the new methods 
should be more robust and more efficient.
    
    There is likely still issues with the float read methods and all multi-byte 
write methods.
    
    Harbs
    
    > On Jun 19, 2018, at 9:28 PM, Harbs <[email protected]> wrote:
    > 
    > DataView works in IE10+. The problem with DataView as that it’s slow.
    > 
    >> On Jun 19, 2018, at 9:24 PM, Carlos Rovira <[email protected]> 
wrote:
    >> 
    >> Hi Harbs,
    >> 
    >> for me any improvement seems ok, just ensure it works in all browsers
    >> (specially IE11)
    >> 
    >> thanks
    >> 
    >> 2018-06-19 19:25 GMT+02:00 Alex Harui <[email protected]>:
    >> 
    >>> Isn't ByteArray mapped to UInt8Array?
    >>> 
    >>> On 6/19/18, 10:07 AM, "Harbs" <[email protected]> wrote:
    >>> 
    >>>   BinaryData uses TypedArrays to read data. It seems that if the
    >>> ArrayBuffer does not divide evenly into the target TypedArray, you get a
    >>> runtime error.
    >>> 
    >>>   For example:
    >>> 
    >>>   readShort() works like this:
    >>>   var ret:int = new Int16Array(ba, _position, 1)[0];
    >>> 
    >>>   If _position is not divisible by 2 (i.e. an odd number), this causes a
    >>> RTE.
    >>> 
    >>>   readInt() has a similar problem that _position needs to be divisible
    >>> by 4, etc.
    >>> 
    >>>   Am I correct that Flash’s ByteArray works correctly in this situation?
    >>> We can use DataViews to solve the problem or we can read the bytes 
directly.
    >>> 
    >>>   Thanks,
    >>>   Harbs
    >>> 
    >>> 
    >> 
    >> 
    >> -- 
    >> Carlos Rovira
    >> 
https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fabout.me%2Fcarlosrovira&data=02%7C01%7Caharui%40adobe.com%7C0a39e02d45a94743801a08d5d688429c%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C1%7C636650803077295693&sdata=po2u0k2cYHf2yvcfuYaN8VzEoF9pAzcV6YEPaS%2Be8G0%3D&reserved=0
    > 
    
    

Reply via email to