From fe869aca3823f2b5e0ff8b69b2ab07857cb02a11 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Wed, 21 Jun 2023 14:47:29 +0200 Subject: [PATCH] Simplify the `sign` handling in the `Lexer.getNumber` method After the changes in PR 15606, we can (slightly) simplify the `sign` handling. --- src/core/parser.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/core/parser.js b/src/core/parser.js index 8a0c92e58..f7efc4d2d 100644 --- a/src/core/parser.js +++ b/src/core/parser.js @@ -893,7 +893,7 @@ class Lexer { let ch = this.currentChar; let eNotation = false; let divideBy = 0; // Different from 0 if it's a floating point value. - let sign = 0; + let sign = 1; if (ch === /* '-' = */ 0x2d) { sign = -1; @@ -904,7 +904,6 @@ class Lexer { ch = this.nextChar(); } } else if (ch === /* '+' = */ 0x2b) { - sign = 1; ch = this.nextChar(); } if (ch === /* LF = */ 0x0a || ch === /* CR = */ 0x0d) { @@ -929,7 +928,6 @@ class Lexer { throw new FormatError(msg); } - sign ||= 1; let baseValue = ch - 0x30; // '0' let powerValue = 0; let powerValueSign = 1;