Skip to content

Compile the whitespace split pattern once - #6

Open
dionmcm wants to merge 1 commit into
masterfrom
perf/precompile-whitespace-split
Open

Compile the whitespace split pattern once#6
dionmcm wants to merge 1 commit into
masterfrom
perf/precompile-whitespace-split

Conversation

@dionmcm

@dionmcm dionmcm commented Aug 28, 2026

Copy link
Copy Markdown
Member

Branch: perf/precompile-whitespace-split · Module: snomed-drools-engine

What

DescriptionHelper split description terms on the literal "\\s+" in two places. String.split only bypasses the regex engine for a single literal character, so "\\s+" compiled a fresh Pattern on every call.

Change

Moved to a static final Pattern as a constant beside the three already there, removing the duplicated literal at the same time as precompiling.

Impact

In reality it is a very minor gain, more for tidiness than anything.

Also considered, but not implemented

TAG_PATTERN and FULL_TAG_PATTERN both lead with a greedy .* that backtracks across the whole term, and are hotter than this. Rewriting them as lastIndexOf arithmetic would be faster, but exact equivalence has awkward edges around terms containing newlines, and the gain was not enough to justify the risk.

CoderMChu added a commit that referenced this pull request Aug 28, 2026
Keep validation workers supplied with concepts instead of every 10
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.

1 participant