hwcrypto / hwcrypto.js

Browser JavaScript library for working with hardware tokens
https://hwcrypto.github.io
MIT License
157 stars 47 forks source link

Use for loop instead of str.replace #10

Closed andris9 closed 9 years ago

andris9 commented 9 years ago

Currently _hex2array uses String.replace(/(..)/) to build an array out of a hex string. Even though convenient this is way much slower than a normal for loop with String.substr(). In my tests, the current solution is more than 80% slower than the proposed one, see the jsperf test case here.

martinpaljak commented 9 years ago

Great, thanks!