Hax Map vs toString 16

Edit on GitHub

Setup

var x = new Uint8Array(256)
var map = { }
for (var i = 0; i < 256; ++i) {
  map[x[i] = i] = i.toString(16)
}

Tests

  • Hax Map

    result = ""
    for (var j = 0, l = x.length; j < l; ++j) {
      result += map[j]
    }
    return result
  • toString 16

    result = ""
    for (var j = 0, l = x.length; j < l; ++j) {
      result += j.toString(16)
    }
    return result