chaindb: optimize key parsing.
This commit is contained in:
parent
485029a241
commit
676563125d
@ -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);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user