Skip to content

Conversation

@CodewithEvilxd
Copy link

Summary

This PR optimizes regex generation in compileBooleanMatcher by using character ranges for better performance.

Changes:

  • Convert consecutive single characters to ranges: [1-4a] instead of [1234a]
  • Improves regex performance and reduces size
  • Resolves TODO comment for further regex optimization

What kind of change does this PR introduce?

  • Feature
  • Performance

Did you add tests for your changes?

  • Yes
  • No (changes are internal optimizations that don't require new tests - existing test suite covers the functionality)

Does this PR introduce a breaking change?

  • No

If relevant, what needs to be documented once your changes are merged or what have you already documented?

  • Nothing - these are internal improvements that don't affect public APIs

Copy link
Member

@alexander-akait alexander-akait left a comment

Choose a reason for hiding this comment

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

Please add a test case

// optimize by using character ranges: e.g., [1-4a] instead of [1234a]
if (countOfSingleCharItems === itemsArr.length) {
return `[${quoteMeta(itemsArr.sort().join(""))}]`;
const sorted = itemsArr.sort();
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for contributing! Could you abstract this logic and add tests to your pr?

@evenstensberg
Copy link
Member

@CodewithEvilxd nice work. Could you rebase and add tests?

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