From 52151e07aec9cfcfc916b03ec825d7a46872ed37 Mon Sep 17 00:00:00 2001 From: Louis-Dominique Dubeau Date: Wed, 4 Jul 2018 12:05:19 -0400 Subject: [PATCH] refactor: optimize --- lib/saxes.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/lib/saxes.js b/lib/saxes.js index a0db8c48..a8a7d06d 100644 --- a/lib/saxes.js +++ b/lib/saxes.js @@ -1015,13 +1015,14 @@ ${XML_NAMESPACE}.`); return; } + const { tags } = this; // first make sure that the closing tag actually exists. // will close everything, otherwise. - let t = this.tags.length; + let t = tags.length; const { tagName } = this; const closeTo = tagName; while (t--) { - const close = this.tags[t]; + const close = tags[t]; if (close.name !== closeTo) { this.fail("Unexpected close tag"); } @@ -1031,19 +1032,17 @@ ${XML_NAMESPACE}.`); } if (t < 0) { - this.fail(`Unmatched closing tag: ${this.tagName}`); - this.textNode += ``; + this.fail(`Unmatched closing tag: ${tagName}`); + this.textNode += ``; this.state = S_TEXT; return; } - this.tagName = tagName; let s = this.tags.length; while (s-- > t) { - const tag = this.tag = this.tags.pop(); - this.tagName = this.tag.name; - this.emitNode("onclosetag", this.tagName); + const tag = this.tag = tags.pop(); + this.emitNode("onclosetag", tag.name); - const parent = this.tags[this.tags.length - 1] || this; + const parent = tags[tags.length - 1] || this; if (this.opt.xmlns && tag.ns !== parent.ns) { // remove namespace bindings introduced by tag for (const p of Object.keys(tag.ns)) {