« Previous | Next » 

Revision 01ee551e

ID01ee551e704776d8547250ac015a5463613afb45
Parent 202b5db4
Child b58efe77

Added by Ben Noordhuis over 11 years ago

typed arrays: only share ArrayBuffer backing store

Follow browser behavior, only share the backing store when it's a
ArrayBuffer. That is:

var abuf = new ArrayBuffer(32);
var a = new Int8Array(abuf);
var b = new Int8Array(abuf);
a[0] = 0;
b[0] = 1;
assert(a[0] === b[0]); // a and b share memory

But:

var a = new Int8Array(32);
var b = new Int8Array(a);
a[0] = 0;
b[0] = 1;
assert(a[0] !== b[0]); // a and b don't share memory

The typed arrays spec allows both `a0 === b0` and `a0 !=== b0`
but Chrome and Firefox implement the behavior where memory is not
shared.

Copying the memory is less efficient but let's do it anyway for the
sake of the Principle of Least Surprise.

Fixes #4714.

Files

  • added
  • modified
  • copied
  • renamed
  • deleted

View differences