Merge pull request #169 from mdboom/use-bitwise-and

MAINT: Use bitwise and rather than mod, for performance
This commit is contained in:
Roman Yurchak 2018-09-18 18:40:44 +02:00 committed by GitHub
commit 3e459c8f4b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -7,11 +7,11 @@ EM_JS(void, hiwire_setup, (), {
{ {
var objects = hiwire.objects; var objects = hiwire.objects;
while (hiwire.counter in objects) { while (hiwire.counter in objects) {
hiwire.counter = (hiwire.counter + 1) % 0x8fffffff; hiwire.counter = (hiwire.counter + 1) & 0x7fffffff;
} }
var idval = hiwire.counter; var idval = hiwire.counter;
objects[idval] = jsval; objects[idval] = jsval;
hiwire.counter = (hiwire.counter + 1) % 0x8fffffff; hiwire.counter = (hiwire.counter + 1) & 0x7fffffff;
return idval; return idval;
}; };