mirror of https://github.com/pret/pokecrystal.git
better read_line performance in preprocessor
Jump out of read_line early if the line is an empty string or a newline.
This commit is contained in:
parent
7eaf5bf726
commit
473bd192d9
|
@ -427,12 +427,10 @@ def macro_test(asm, macro_table):
|
||||||
token = extract_token(asm)
|
token = extract_token(asm)
|
||||||
|
|
||||||
# skip db and dw since rgbasm handles those and they aren't macros
|
# skip db and dw since rgbasm handles those and they aren't macros
|
||||||
if token not in ["db", "dw"]:
|
if token is not None and token not in ["db", "dw"] and token in macro_table:
|
||||||
# check against all names
|
return (macro_table[token], token)
|
||||||
if token in macro_table:
|
else:
|
||||||
return (macro_table[token], token)
|
return (None, None)
|
||||||
|
|
||||||
return (None, None)
|
|
||||||
|
|
||||||
def is_based_on(something, base):
|
def is_based_on(something, base):
|
||||||
"""
|
"""
|
||||||
|
@ -611,6 +609,10 @@ def macro_translator(macro, token, line, show_original_lines=False, do_macro_san
|
||||||
def read_line(l, macro_table):
|
def read_line(l, macro_table):
|
||||||
"""Preprocesses a given line of asm."""
|
"""Preprocesses a given line of asm."""
|
||||||
|
|
||||||
|
if l in ["\n", ""]:
|
||||||
|
sys.stdout.write(l)
|
||||||
|
return # jump out early
|
||||||
|
|
||||||
# strip comments from asm
|
# strip comments from asm
|
||||||
asm, comment = separate_comment(l)
|
asm, comment = separate_comment(l)
|
||||||
|
|
||||||
|
@ -624,7 +626,7 @@ def read_line(l, macro_table):
|
||||||
sys.stdout.write(asm)
|
sys.stdout.write(asm)
|
||||||
|
|
||||||
# ascii string macro preserves the bytes as ascii (skip the translator)
|
# ascii string macro preserves the bytes as ascii (skip the translator)
|
||||||
elif len(asm) > 6 and "ascii " == asm[:6] or "\tascii " == asm[:7]:
|
elif len(asm) > 6 and ("ascii " == asm[:6] or "\tascii " == asm[:7]):
|
||||||
asm = asm.replace("ascii", "db", 1)
|
asm = asm.replace("ascii", "db", 1)
|
||||||
sys.stdout.write(asm)
|
sys.stdout.write(asm)
|
||||||
|
|
||||||
|
@ -640,7 +642,8 @@ def read_line(l, macro_table):
|
||||||
else:
|
else:
|
||||||
sys.stdout.write(asm)
|
sys.stdout.write(asm)
|
||||||
|
|
||||||
if comment: sys.stdout.write(comment)
|
if comment:
|
||||||
|
sys.stdout.write(comment)
|
||||||
|
|
||||||
def preprocess(macro_table, lines=None):
|
def preprocess(macro_table, lines=None):
|
||||||
"""Main entry point for the preprocessor."""
|
"""Main entry point for the preprocessor."""
|
||||||
|
|
Loading…
Reference in New Issue