From 5aa1f0d0bbd59043acc8faf031ad9cdfcbaabe28 Mon Sep 17 00:00:00 2001 From: crc Date: Wed, 20 Nov 2019 21:03:07 +0000 Subject: [PATCH] nga-js: cache err:notfound, interpret addresses to improve performance a little FossilOrigin-Name: 9f29e09fbb02eb5b5b316693228b0c0a28dff2316be84c74f829cc6cc635620c --- nga-js/nga.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/nga-js/nga.js b/nga-js/nga.js index 569b88c..a162f31 100644 --- a/nga-js/nga.js +++ b/nga-js/nga.js @@ -89,6 +89,8 @@ var address = new Stack(ADDRESS_DEPTH); var image = new Array(IMAGE_SIZE); var vm = new Opcodes(); var instructions = new Array(vm.II + 1); +var notfound = 0; +var interpret = 0; function rxPrepareVM() { ip = 0; @@ -335,7 +337,6 @@ function execute(offset) { var opcode; address.sp = 1; ip = offset; - var notfound = d_xt_for("err:notfound"); while (ip < IMAGE_SIZE) { opcode = image[ip]; if (ip == notfound) { @@ -444,10 +445,9 @@ function d_class_for(name) { function evaluate(s) { if (s.length == 0) return; - var i = d_xt_for("interpret"); string_inject(s, 1471); data.push(1471); - execute(i); + execute(interpret); } function cls() { @@ -478,6 +478,8 @@ function unu(src) { function go() { rxPrepareVM(); loadInitialImage(); + notfound = d_xt_for("err:notfound"); + interpret = d_xt_for("interpret"); document.getElementById("console").innerHTML = ""; src = document.getElementById("input").value; tokens = unu(src).match(/\S+/g);