From c7e36bfd89634a9c4ffe1ad44b14fa410561f55c Mon Sep 17 00:00:00 2001 From: Louis-Dominique Dubeau Date: Tue, 14 Aug 2018 17:57:29 -0400 Subject: [PATCH] perf: minor optimizations --- lib/saxes.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/saxes.js b/lib/saxes.js index 3c91835f..e9cd7301 100644 --- a/lib/saxes.js +++ b/lib/saxes.js @@ -860,11 +860,9 @@ class SaxesParser { /** @private */ sDoctypeQuoted(chunkState) { - const c = this.captureWhile(chunkState, cx => cx !== this.q, "doctype"); - if (!c) { - return; - } - if (c !== this.q) { + const { q } = this; + const c = this.captureWhile(chunkState, cx => cx !== q, "doctype"); + if (!c || c !== q) { return; } @@ -894,13 +892,14 @@ class SaxesParser { /** @private */ sDoctypeDTDQuoted(chunkState) { - const c = this.captureWhile(chunkState, cx => cx !== this.q, "doctype"); + const { q } = this; + const c = this.captureWhile(chunkState, cx => cx !== q, "doctype"); if (!c) { return; } this.doctype += String.fromCodePoint(c); - if (c === this.q) { + if (c === q) { this.state = S_DOCTYPE_DTD; this.q = null; } @@ -1400,13 +1399,14 @@ class SaxesParser { /** @private */ sAttribValueQuoted(chunkState) { + const { q } = this; const c = this.captureWhile( chunkState, (cx) => { if (cx === LESS) { this.fail("disallowed character."); } - return cx !== this.q && cx !== AMP; + return cx !== q && cx !== AMP; }, "attribValue"); if (c === AMP) {