Skip to content

Commit

Permalink
perf: don't check twice if this.textNode is set
Browse files Browse the repository at this point in the history
The current flow would check the variable twice. Just check it before calling
`closeText`, everywhere.
  • Loading branch information
lddubeau committed Sep 3, 2018
1 parent e981a25 commit 00536cc
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/saxes.js
Original file line number Diff line number Diff line change
Expand Up @@ -1569,7 +1569,9 @@ class SaxesParser {
(this.state !== S_TEXT)) {
this.fail("unexpected end.");
}
this.closeText();
if (this.textNode) {
this.closeText();
}
this.closed = true;
this.onend();
this._init(this.opt);
Expand All @@ -1582,9 +1584,7 @@ class SaxesParser {
* @private
*/
closeText() {
if (this.textNode) {
this.ontext(this.textNode);
}
this.ontext(this.textNode);
this.textNode = "";
this.textNodeCheckedBefore = 0;
}
Expand Down

0 comments on commit 00536cc

Please sign in to comment.