Closed george-ka closed 9 years ago
Hi! Many thanks for your participation.
I've reviewed your pull request and there are some issues.
As jsperf.com has been broken I have to create a small benchmark at jsfiddle.
I slightly modifed your string_to_utf8bytes
to achieve at about x4 speedup and its performance becomes competitive w/ original string_to_bytes
. So I'm considering to replace original string_to_bytes
with UTF-8 capable one.
Unfortunately I'm out of spare time for now. I'll let your pull request in ASAP.
Wow, it looks like function inlining makes the code much faster, which is obvious, but I didn't take the efficiency into consideration, which is a shame. :) Let me fix it then.
Following your lead I've got rid of redundant function calls in the second method as well and managed to boost its performance too! Check this out https://jsfiddle.net/kct18qn8/3/ I've updated the pull request with the tweaks.
Ok, I'll break it into chunks. I wonder where did they take their magic number (8192 or 8 Kb) from...
I just couldn't resist the temptation to make batch size a little bigger :)
Hi Artem, I've created a pull request to add UTF8 support as the most widespread encoding nowadays. Not sure how to add proper tests to the solution, but tested locally. Used "🚀" rocket as an example of 4-byte UTF8 char. Used code samples: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint http://stackoverflow.com/questions/15181809/javascript-charcodeat0-stuck-at-55357 https://gist.github.com/volodymyr-mykhailyk/2923227
Additional info: https://en.wikipedia.org/wiki/UTF-8