39
}
40
}
42
>
function toLittleEndianBuffer(arr: Uint32Array): VSBuffer {
43
>
const uint8Arr = new Uint8Array(arr.buffer, arr.byteOffset, arr.length * 4);
44
>
if (!platform.isLittleEndian()) {
45
// the byte order must be changed
46
reverseEndianness(uint8Arr);
47
}
49
>
}
50
>
51
>
function fromLittleEndianBuffer(buff: VSBuffer): Uint32Array {
52
>
const uint8Arr = buff.buffer;
53
>
if (!platform.isLittleEndian()) {
54
// the byte order must be changed
55
reverseEndianness(uint8Arr);
56
}
58
>
return new Uint32Array(uint8Arr.buffer, uint8Arr.byteOffset, uint8Arr.length / 4);
59
>
} else {
60
// unaligned memory access doesn't work on all platforms
61
const data = new Uint8Array(uint8Arr.byteLength);