From d0629d4e5566faeb5976f8a43f06140ec312fded Mon Sep 17 00:00:00 2001 From: Michael Droettboom Date: Mon, 17 Sep 2018 13:19:03 -0400 Subject: [PATCH 1/2] Use bitwise and rather than mod, for performance --- src/hiwire.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hiwire.c b/src/hiwire.c index f6f411cc0..273f14003 100644 --- a/src/hiwire.c +++ b/src/hiwire.c @@ -7,11 +7,11 @@ EM_JS(void, hiwire_setup, (), { { var objects = hiwire.objects; while (hiwire.counter in objects) { - hiwire.counter = (hiwire.counter + 1) % 0x8fffffff; + hiwire.counter = (hiwire.counter + 1) & 0x8fffffff; } var idval = hiwire.counter; objects[idval] = jsval; - hiwire.counter = (hiwire.counter + 1) % 0x8fffffff; + hiwire.counter = (hiwire.counter + 1) & 0x8fffffff; return idval; }; From 609e1def40b9ecba46aee62d5561f292774fc28b Mon Sep 17 00:00:00 2001 From: Michael Droettboom Date: Tue, 18 Sep 2018 11:09:02 -0400 Subject: [PATCH 2/2] Fix constants --- src/hiwire.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hiwire.c b/src/hiwire.c index 273f14003..593362c81 100644 --- a/src/hiwire.c +++ b/src/hiwire.c @@ -7,11 +7,11 @@ EM_JS(void, hiwire_setup, (), { { var objects = hiwire.objects; while (hiwire.counter in objects) { - hiwire.counter = (hiwire.counter + 1) & 0x8fffffff; + hiwire.counter = (hiwire.counter + 1) & 0x7fffffff; } var idval = hiwire.counter; objects[idval] = jsval; - hiwire.counter = (hiwire.counter + 1) & 0x8fffffff; + hiwire.counter = (hiwire.counter + 1) & 0x7fffffff; return idval; };