mirror of https://github.com/pret/pokecrystal.git
don't call load_pokecrystal_macros 2000 times
Also, don't call make_macro_table 2000 times by only calling it once and passing the result.
This commit is contained in:
parent
ca0981eb36
commit
70be18427b
|
@ -642,9 +642,8 @@ def read_line(l, macro_table):
|
||||||
|
|
||||||
if comment: sys.stdout.write(comment)
|
if comment: sys.stdout.write(comment)
|
||||||
|
|
||||||
def preprocess(macros, lines=None):
|
def preprocess(macro_table, lines=None):
|
||||||
"""Main entry point for the preprocessor."""
|
"""Main entry point for the preprocessor."""
|
||||||
macro_table = make_macro_table(macros)
|
|
||||||
|
|
||||||
if not lines:
|
if not lines:
|
||||||
# read each line from stdin
|
# read each line from stdin
|
||||||
|
@ -658,4 +657,6 @@ def preprocess(macros, lines=None):
|
||||||
|
|
||||||
# only run against stdin when not included as a module
|
# only run against stdin when not included as a module
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
preprocess(load_pokecrystal_macros())
|
macros = load_pokecrystal_macros()
|
||||||
|
macro_table = make_macro_table(macros)
|
||||||
|
preprocess(macro_table)
|
||||||
|
|
10
prequeue.py
10
prequeue.py
|
@ -9,9 +9,15 @@ import os
|
||||||
import sys
|
import sys
|
||||||
import preprocessor
|
import preprocessor
|
||||||
|
|
||||||
if __name__ == '__main__':
|
def main():
|
||||||
|
macros = preprocessor.load_pokecrystal_macros()
|
||||||
|
macro_table = preprocessor.make_macro_table(macros)
|
||||||
|
|
||||||
for source in sys.argv[1:]:
|
for source in sys.argv[1:]:
|
||||||
dest = os.path.splitext(source)[0] + '.tx'
|
dest = os.path.splitext(source)[0] + '.tx'
|
||||||
sys.stdin = open(source, 'r')
|
sys.stdin = open(source, 'r')
|
||||||
sys.stdout = open(dest, 'w')
|
sys.stdout = open(dest, 'w')
|
||||||
preprocessor.preprocess(preprocessor.load_pokecrystal_macros())
|
preprocessor.preprocess(macro_table)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
|
|
Loading…
Reference in New Issue