From 36f39aec2277db917b66bc81aa640d2b5d099ac9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Wed, 24 Dec 2008 07:55:12 +0000 Subject: [PATCH] tokenize : optimising "simplifyConditions" --- tokenize.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tokenize.cpp b/tokenize.cpp index 98f90b1d8..de9fc450e 100644 --- a/tokenize.cpp +++ b/tokenize.cpp @@ -1333,9 +1333,12 @@ bool Tokenizer::simplifyConditions() } // Reduce "(%num% == %num%)" => "(true)"/"(false)" + const TOKEN *tok4 = tok->tokAt(4); + if ( ! tok4 ) + break; if ( (tok->str()=="&&" || tok->str()=="||" || tok->str()=="(") && TOKEN::Match(tok->tokAt(1), "%num% %any% %num%") && - (TOKEN::simpleMatch(tok->tokAt(4), "&&") || TOKEN::simpleMatch(tok->tokAt(4), "||") || TOKEN::simpleMatch(tok->tokAt(4), ")")) ) + (tok4->str()=="&&" || tok4->str()=="||" || tok4->str()==")") ) { double op1 = (strstr(tok->strAt(1), "0x")) ? strtol(tok->strAt(1),0,16) : atof( tok->strAt(1) ); double op2 = (strstr(tok->strAt(3), "0x")) ? strtol(tok->strAt(3),0,16) : atof( tok->strAt(3) );