namespace cleanup for workers

This commit is contained in:
Stewart Allen 2020-06-16 11:08:50 -04:00
commit 4cae0b945a
4 changed files with 35 additions and 23 deletions

View file

@ -8,12 +8,17 @@
const BASE = self.base, KIRI = self.kiri, handlers = {};
KIRI.codec = {
const codec = KIRI.codec = {
encode: encode,
decode: decode,
registerDecoder: registerDecoder
registerDecoder: registerDecoder,
allocFloat32Array: allocFloat32Array
};
function allocFloat32Array(len) {
return new Float32Array(len);
}
function encode(o, state) {
state = state || {};
if (o === null) return null;
@ -140,7 +145,7 @@
function encodePointArray(points, state) {
if (!points) return null;
let array = new Float32Array(points.length * 3),
let array = codec.allocFloat32Array(points.length * 3),
pos = 0;
points.forEach(function(point) {