From a1c7c47cc0b7072ba6ee18798ea8ab62d23c885d Mon Sep 17 00:00:00 2001
From: hjk <hjk121@nokiamail.com>
Date: Mon, 15 Apr 2013 17:33:52 +0200
Subject: [PATCH] C++: Simplify Lexer::yyinp()

... by assuming we operate on NUL-terminated data, which is
(in theory) guaranteed by (non-raw) QByteArray which we have.

Change-Id: I855d01ea0dee5328ec737fbabee1086d7a28aa5a
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
---
 src/libs/3rdparty/cplusplus/Lexer.h | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/src/libs/3rdparty/cplusplus/Lexer.h b/src/libs/3rdparty/cplusplus/Lexer.h
index 0d527f1d828..e2e39ed4807 100644
--- a/src/libs/3rdparty/cplusplus/Lexer.h
+++ b/src/libs/3rdparty/cplusplus/Lexer.h
@@ -99,13 +99,9 @@ private:
 
     inline void yyinp()
     {
-        if (++_currentChar == _lastChar)
-            _yychar = 0;
-        else {
-            _yychar = *_currentChar;
-            if (_yychar == '\n')
-                pushLineStartOffset();
-        }
+        _yychar = *++_currentChar;
+        if (Q_UNLIKELY(_yychar == '\n'))
+            pushLineStartOffset();
     }
 
     void pushLineStartOffset();
-- 
GitLab