summaryrefslogtreecommitdiff
path: root/src/ldump.js
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-12-13 14:55:33 +1100
committerdaurnimator <quae@daurnimator.com>2017-12-13 15:31:04 +1100
commit11a2421acaf2b39d19ee99933102c35e28fd13f8 (patch)
tree4abd1fa6ee063f75c634349a02702de7bc145a8b /src/ldump.js
parent3e7c102eefbaae9e6bc839b11bba79aee1c5e040 (diff)
downloadfengari-11a2421acaf2b39d19ee99933102c35e28fd13f8.tar.gz
fengari-11a2421acaf2b39d19ee99933102c35e28fd13f8.tar.bz2
fengari-11a2421acaf2b39d19ee99933102c35e28fd13f8.zip
Use Uint8Array to back strings
Diffstat (limited to 'src/ldump.js')
-rw-r--r--src/ldump.js23
1 files changed, 9 insertions, 14 deletions
diff --git a/src/ldump.js b/src/ldump.js
index 964d6ff..7e62da3 100644
--- a/src/ldump.js
+++ b/src/ldump.js
@@ -34,31 +34,26 @@ const DumpByte = function(y, D) {
};
const DumpInt = function(x, D) {
- let dv = new DataView(new ArrayBuffer(4));
+ let ab = new ArrayBuffer(4);
+ let dv = new DataView(ab);
dv.setInt32(0, x, true);
- let t = [];
- for (let i = 0; i < 4; i++)
- t.push(dv.getUint8(i, true));
-
+ let t = new Uint8Array(ab);
DumpBlock(t, 4, D);
};
const DumpInteger = function(x, D) {
- let dv = new DataView(new ArrayBuffer(4));
+ let ab = new ArrayBuffer(4);
+ let dv = new DataView(ab);
dv.setInt32(0, x, true);
- let t = [];
- for (let i = 0; i < 4; i++)
- t.push(dv.getUint8(i, true));
+ let t = new Uint8Array(ab);
DumpBlock(t, 4, D);
};
const DumpNumber = function(x, D) {
- let dv = new DataView(new ArrayBuffer(8));
+ let ab = new ArrayBuffer(8);
+ let dv = new DataView(ab);
dv.setFloat64(0, x, true);
- let t = [];
- for (let i = 0; i < 8; i++)
- t.push(dv.getUint8(i, true));
-
+ let t = new Uint8Array(ab);
DumpBlock(t, 8, D);
};