bipf
bipf copied to clipboard
Optimize JS code with V8 tricks
Continuing from https://github.com/jerive/bipf-napi/issues/1#issuecomment-985868777
@jerive I noticed that in test/perf.js, sometimes seekKey(buffer, start, target) is called with buffer = 0 and that's what causes a deopt. We could do two things: (1) check why is buffer = 0 being passed to this function in the perf.js, and not pass that (invalid) arg, (2) put a if (Buffer.isBuffer(buffer)) check in the implementation, although this will likely impact performance a tiny bit.
at seekKey (/home/jerome/dev/bipf/index.js:235:11)
at Array.eval (eval at createSeekPath (/home/jerome/dev/bipf/index.js:336:10), <anonymous>:6:11)
at /home/jerome/dev/bipf/index.js:452:27
at Object.<anonymous> (/home/jerome/dev/bipf/test/perf.js:166:3)
Something wrong with createCompareAt: the function produced is indeed not called the proper way in perf.js (with 4 args instead of 2, probably a confusion with bipf.compare)