• Actually E.toUint8Array seems to make a copy, just tried in emulator

    >var h=E.toFlatString("Hello")
    ="Hello"
    >var hb=E.toArrayBuffer(h)
    =new Uint8Array([72, 101, 108, 108, 111]).buffer
    >var hu=Uint8Array(hb)
    =new Uint8Array([72, 101, 108, 108, 111])
    >var hu2=E.toUint8Array(h)
    =new Uint8Array([72, 101, 108, 108, 111])
    >E.getAddressOf(hu,true)
    =179852
    >E.getAddressOf(hb,true)
    =179852
    >E.getAddressOf(h,true)
    =179852
    >E.getAddressOf(hu2,true)
    =180006
    >var hu3=E.toUint8Array(hb)
    =new Uint8Array([72, 101, 108, 108, 111])
    >E.getAddressOf(hu3,true)
    =180300
    

    So hu2 and hu3 made by E.toUint8Array makes new array from same buffer. Others work as expected.

About

Avatar for fanoush @fanoush started