Skip to content

Cache currency symbol regex to improve parse performance #193

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

Merged
merged 4 commits into from
Jul 23, 2025

Conversation

pranavbabu
Copy link
Contributor

Cached the currency symbol regex in Parser to avoid recompiling it on every parse call, improving performance during repeated monetary parsing operations.

Benchmarking currency_symbol_regex creation...
                                user     system      total        real
Dynamic regex generation:   0.551297   0.001920   0.553217 (  0.553221)
Cached regex reuse:         0.003189   0.000083   0.003272 (  0.003271)

Copy link
Member

@yukideluxe yukideluxe left a comment

Choose a reason for hiding this comment

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

Could we just remove the method and just use the constant here?

match = input.match(currency_symbol_regex)
😊

@yukideluxe
Copy link
Member

also, I think the test failure is related 🙏🏻

Copy link
Member

@yukideluxe yukideluxe left a comment

Choose a reason for hiding this comment

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

thanks!

@yukideluxe yukideluxe merged commit 549ace4 into RubyMoney:main Jul 23, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants