From ffd562351b8d55cb8ff6c613d6ac601cead4341c Mon Sep 17 00:00:00 2001 From: yenatch Date: Wed, 15 May 2013 01:51:58 -0400 Subject: [PATCH] preprocessor: minor optimization in separate_comment --- preprocessor.py | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/preprocessor.py b/preprocessor.py index 67e4cdb9f..18e96dff0 100644 --- a/preprocessor.py +++ b/preprocessor.py @@ -314,26 +314,19 @@ def separate_comment(l): asm = "" comment = None in_quotes = False - in_comment = False # token either belongs to the line or to the comment for token in l: - if in_comment: + if comment: comment += token - elif in_quotes and token != "\"": + else: + if not in_quotes: + if token == ";": + comment = ";" + continue + if token == "\"": + in_quotes = not in_quotes asm += token - elif in_quotes and token == "\"": - in_quotes = False - asm += token - elif not in_quotes and token == "\"": - in_quotes = True - asm += token - elif not in_quotes and token != "\"": - if token == ";": - in_comment = True - comment = ";" - else: - asm += token return asm, comment def quote_translator(asm):