Aligh u8aToHex optimization (#1184)

* Aligh u8aToHex optimization

* Adjust

* Fix failing tests, empty value

* Adjust

* numberToHex fix

* Fix hexFixLength tests
This commit is contained in:
Jaco
2021-11-14 21:03:41 +02:00
committed by GitHub
parent 8a6fd0812a
commit cf990dd4ec
12 changed files with 70 additions and 54 deletions
+5 -3
View File
@@ -22,14 +22,16 @@ export function arrayFlatten <T> (arrays: T[][]): T[] {
// pre-allocate based on the combined size
let size = 0;
for (const a of arrays) {
size += a.length;
for (let i = 0; i < arrays.length; i++) {
size += arrays[i].length;
}
const output = new Array<T>(size);
let i = -1;
for (const a of arrays) {
for (let j = 0; j < arrays.length; j++) {
const a = arrays[j];
// instead of pushing, we just set the entries
for (let e = 0; e < a.length; e++) {
output[++i] = a[e];