Update index.js

A little optimization trick: hex.length will not change, so we can avoid to evaluate it each time we loop.
This commit is contained in:
Simon DENEL 2015-04-11 15:42:28 +02:00
parent 10305efe0c
commit 14a4fdf7fd

View File

@ -214,7 +214,7 @@ var intToBytes = function(num) {
*/ */
var hexToBytes = function(hex) { var hexToBytes = function(hex) {
var bytes = []; var bytes = [];
for(var c = 0; c < hex.length; c += 2) { for(var c = 0, C = hex.length; c < C; c += 2) {
bytes.push(parseInt(hex.substr(c, 2), 16)); bytes.push(parseInt(hex.substr(c, 2), 16));
} }
return bytes; return bytes;