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

Re-use regular expressions when parsing IEV termlinks #147

Open
skalee opened this issue Mar 15, 2021 · 1 comment
Open

Re-use regular expressions when parsing IEV termlinks #147

skalee opened this issue Mar 15, 2021 · 1 comment

Comments

@skalee
Copy link
Contributor

skalee commented Mar 15, 2021

Initializing regular expressions over and over again takes almost 20% of concept generation time, not mentioning additional work for the garbage collector. Some easy improvement to do here, I guess.

Zrzut ekranu 2021-03-15 o 11 39 35

@skalee
Copy link
Contributor Author

skalee commented Mar 15, 2021

Regular expressions in Ruby are generally immutable. I bet these two are root of all evil:

gsub(Regexp.new([SIMG_PATH_REGEX, "\\s*", FIGURE_TWO_REGEX].join('')), "image::/assets/images/parts/#{part_number}/\\1[Figure \\2 - \\3; \\6]").
gsub(Regexp.new([SIMG_PATH_REGEX, "\\s*", FIGURE_ONE_REGEX].join('')), "image::/assets/images/parts/#{part_number}/\\1[Figure \\2 - \\3]").

I suppose they can be generalized so that they don't include any particular IEV domain, and so that they don't need to be reinstantiated over and over again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant