Skip to content

Commit e174168

Browse files
committed
improve performance of attributes reading
1 parent 79a8dde commit e174168

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

src/xmlparser/OrderedObjParser.js

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ function isItStopNode() {
656656
*/
657657
function tagExpWithClosingIndex(xmlData, i, closingChar = ">") {
658658
let attrBoundary = 0;
659-
const chars = [];
659+
// const chars = [];
660660
const len = xmlData.length;
661661
const closeCode0 = closingChar.charCodeAt(0);
662662
const closeCode1 = closingChar.length > 1 ? closingChar.charCodeAt(1) : -1;
@@ -669,19 +669,11 @@ function tagExpWithClosingIndex(xmlData, i, closingChar = ">") {
669669
} else if (code === 34 || code === 39) { // " or '
670670
attrBoundary = code;
671671
} else if (code === closeCode0) {
672-
if (closeCode1 !== -1) {
673-
if (xmlData.charCodeAt(index + 1) === closeCode1) {
674-
return { data: String.fromCharCode(...chars), index };
675-
}
676-
} else {
677-
return { data: String.fromCharCode(...chars), index };
672+
if (closeCode1 === -1 || xmlData.charCodeAt(index + 1) === closeCode1) {
673+
const data = xmlData.substring(i, index);
674+
return { data: data.replace(/\t/g, " "), index };
678675
}
679-
} else if (code === 9) { // \t
680-
chars.push(32); // space
681-
continue;
682676
}
683-
684-
chars.push(code);
685677
}
686678
}
687679

0 commit comments

Comments
 (0)