Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SM64] Fix persistent block spam #434

Merged
merged 2 commits into from
Sep 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 12 additions & 14 deletions fast64_internal/sm64/sm64_level_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,24 +498,22 @@ def replaceScriptLoads(levelscript, obj):

STRING_TO_MACROS_PATTERN = re.compile(
r"""
.*?
(?P<macro_name>\w+)
\s*
\((?P<arguments>
[^()]*
.*? # match as few chars as possible before macro name
(?P<macro_name>\w+) #group macro name matches 1+ word chars
\s* # allows any number of spaces after macro name
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you make this lazy (was causing extra steps according to the debugger)

Suggested change
\s* # allows any number of spaces after macro name
\s*? # allows any number of spaces after macro name

\((?P<arguments> # group <arguments> is inside first parenthesis
[^()]* # anything but ()
(?: # Non-capturing group for 1 depth parentheses
\(
.*?
\)
\(.*?\) # captures parenthesis+any chars inside
[^()]*
)*
)* # allows any number of inner parenthesis ()
)\)
(\s*,\s*|\s*)
(?P<comment>
//.*$
(\s*?,)?[^\n]*? # capture a comma, including white space trailing except for new lines following the comma
(?P<comment> # comment group
([^\n]*?|\s*?\\\s*?\n)//.*$ # two // and any number of chars and str or line end
|
/\*.*\*/
)?
([^\n]*?|\s*?\\\s*?\n)/\*[\s\S]*?\*/ # a /*, any number of chars (including new line) and a */
)? # 0 or 1 repetition of comments
""",
re.VERBOSE | re.MULTILINE,
)
Expand Down
Loading