Skip to content

Performance improvements to ValueHelper#31

Merged
guille-work merged 3 commits intomasterfrom
performance-1
Feb 16, 2026
Merged

Performance improvements to ValueHelper#31
guille-work merged 3 commits intomasterfrom
performance-1

Conversation

@guille-work
Copy link
Contributor

@guille-work guille-work commented Feb 16, 2026

  • Put more common types higher up the if-else clause
  • Use a constant regex instead of creating a new one on every call
  • Use RegExp#match? instead of === (no MatchData allocation)
  • Avoid calling .to_s.downcase repeatedly:
    • Extract into single #to_s call
    • Let regex match in case-insensitive mode

Based on the new extended benchmarks (#30), it doesn't make much of an impact. Minor improvement, though.

@guille-work guille-work self-assigned this Feb 16, 2026
- Put more common types higher up the if-else clause
- Use a constant regex instead of creating a new one on every call
- Use RegExp#match? instead of `===` (no MatchData allocation)
- Avoid calling .to_s.downcase repeatedly:
    - Extract into single `#to_s` call
    - Let regex match in case-insensitive mode
@guille-work guille-work merged commit 1191542 into master Feb 16, 2026
1 check passed
@guille-work guille-work deleted the performance-1 branch February 16, 2026 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants