Skip to content

Commit a3a0f07

Browse files
authored
Merge pull request #296 from albertziegenhagel/improve-pp-def-performance
Skip trying to substitute macros into lines that do not contain them
2 parents 1f54125 + 325b821 commit a3a0f07

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

fortls/parse_fortran.py

+4
Original file line numberDiff line numberDiff line change
@@ -2234,6 +2234,10 @@ def replace_vars(line: str):
22342234

22352235
# Substitute (if any) read in preprocessor macros
22362236
for def_tmp, value in defs_tmp.items():
2237+
# Skip if the line does not contain the macro at all. This is supposed to
2238+
# spare the expensive regex-substitution in case we do not need it at all
2239+
if def_tmp not in line:
2240+
continue
22372241
def_regex = def_regexes.get(def_tmp)
22382242
if def_regex is None:
22392243
def_regex = re.compile(rf"\b{def_tmp}\b")

0 commit comments

Comments
 (0)