Skip to content

Conversation

Dockerel
Copy link
Contributor

@Dockerel Dockerel commented Jul 9, 2025

Replace regex %.*% with startsWith / endsWith check for LIKE pattern detection

  • Removes regex overhead and Micro-performance gain
  • Explicit intent (startsWith/endsWith) is clearer than a regex.

Previously, each call to expression.matches("%.*%") incurred regex compilation and Matcher allocation overhead. Caching the pattern with

private static final Pattern CONTAINING = Pattern.compile("%.*%");

would avoid recompilation, but switching to startsWith("%") && endsWith("%") is even more efficient and more readable, so the implementation has been changed accordingly.

Let me know if you have any concerns or suggestions for further improvement.
Thank you for your time and consideration!

@Dockerel Dockerel force-pushed the optimize-like-parameter-binding-performance branch from f75fe97 to 95f0561 Compare July 9, 2025 11:55
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jul 9, 2025
@mp911de mp911de added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Jul 9, 2025
@mp911de mp911de self-assigned this Jul 9, 2025
@mp911de mp911de added this to the 3.5.2 (2025.0.2) milestone Jul 10, 2025
@mp911de mp911de closed this in 5aba123 Jul 10, 2025
mp911de added a commit that referenced this pull request Jul 10, 2025
Refine conditional flow.

See #3932
mp911de pushed a commit that referenced this pull request Jul 10, 2025
mp911de added a commit that referenced this pull request Jul 10, 2025
Refine conditional flow.

See #3932
@mp911de
Copy link
Member

mp911de commented Jul 10, 2025

Thank you for your contribution. That's merged, polished, and backported now.

@Dockerel Dockerel deleted the optimize-like-parameter-binding-performance branch July 10, 2025 11:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: enhancement A general enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants