From cbbbf84d375636f8b5517b0b87fbf075ed36c3a2 Mon Sep 17 00:00:00 2001 From: huyunhui Date: Mon, 6 Nov 2023 15:58:53 +0800 Subject: [PATCH] Codecheck fix, use guard clauses to avoid huge-depth Issue:https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/I8E6QZ Signed-off-by: huyunhui --- es2panda/lexer/lexer.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/es2panda/lexer/lexer.cpp b/es2panda/lexer/lexer.cpp index 5a3d0ebc24..3e240ceb5e 100644 --- a/es2panda/lexer/lexer.cpp +++ b/es2panda/lexer/lexer.cpp @@ -1245,22 +1245,22 @@ void Lexer::SkipWhiteSpaces() case LEX_CHAR_HASH_MARK: { Iterator().Forward(1); cp = Iterator().Peek(); - if (cp == LEX_CHAR_EXCLAMATION) { - if (Iterator().Index() != 1) { - /* - * according to ECMA-262 specification item 12.5 Hashbang Comments are location-sensitive. - * only allowed occurs at the beginning of files, other position is illegal. - */ - Iterator().Backward(1); - ThrowError("Invalid or unexpected token"); - } - Iterator().Forward(1); - SkipSingleLineComment(); - continue; + if (cp != LEX_CHAR_EXCLAMATION) { + Iterator().Backward(1); + return; + } + if (Iterator().Index() != 1) { + /* + * according to ECMA-262 specification item 12.5 Hashbang Comments are location-sensitive. + * only allowed occurs at the beginning of files, other position is illegal. + */ + Iterator().Backward(1); + ThrowError("Invalid or unexpected token"); } - Iterator().Backward(1); - return; + Iterator().Forward(1); + SkipSingleLineComment(); + continue; } case LEX_CHAR_CR: { Iterator().Forward(1); -- Gitee