chaindb: optimize key parsing.

This commit is contained in:
Christopher Jeffrey 2016-08-24 05:47:31 -07:00
parent 485029a241
commit 676563125d
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -180,10 +180,10 @@ var layout = {
var hash, index; var hash, index;
if (key.length === 69) { if (key.length === 69) {
hash = key.slice(33, 65).toString('hex'); hash = key.toString('hex', 33, 65);
index = key.readUInt32BE(65, 0); index = key.readUInt32BE(65, 0);
} else { } else {
hash = key.slice(21, 53).toString('hex'); hash = key.toString('hex', 21, 53);
index = key.readUInt32BE(53, 0); index = key.readUInt32BE(53, 0);
} }
@ -191,8 +191,8 @@ var layout = {
}, },
Tt: function Tt(key) { Tt: function Tt(key) {
return key.length === 65 return key.length === 65
? key.slice(33).toString('hex') ? key.toString('hex', 33, 65)
: key.slice(21).toString('hex'); : key.toString('hex', 21, 53);
} }
}; };