A tiny improvement of the MetadataParser._repair method

We can just insert the initial greater-than sign at the start of the buffer, rather than doing that manually at the end.
This commit is contained in:
Jonas Jenwald 2023-02-04 12:31:53 +01:00
parent 851c394e64
commit 3a7fce49a3

View File

@ -57,7 +57,7 @@ class MetadataParser {
throw new Error(`_repair: ${name} isn't defined.`); throw new Error(`_repair: ${name} isn't defined.`);
}); });
const charBuf = []; const charBuf = [">"];
for (let i = 0, ii = bytes.length; i < ii; i += 2) { for (let i = 0, ii = bytes.length; i < ii; i += 2) {
const code = bytes.charCodeAt(i) * 256 + bytes.charCodeAt(i + 1); const code = bytes.charCodeAt(i) * 256 + bytes.charCodeAt(i + 1);
if ( if (
@ -74,7 +74,7 @@ class MetadataParser {
); );
} }
} }
return ">" + charBuf.join(""); return charBuf.join("");
}); });
} }