Skip to content

Performance improvements to ValueHelper#31

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

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

Conversation

@guille-sage
Copy link
Contributor

@guille-sage guille-sage 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-sage guille-sage 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-sage guille-sage merged commit 1191542 into master Feb 16, 2026
1 check passed
@guille-sage guille-sage 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