Conversation
…ow memoized in $self->{compiled_template_cache} keyed by template text, avoiding recompilation on every call.
2. Removed redundant clone — The second clone() in _render_template was removed since Text::Hogan::Template->render() doesn't mutate its context.
3. Pre-compiled replacement regexes — _precompile_rules() runs at config load time, compiling all replace and postformat_replace regex patterns into qr// objects. The hot-loop try/catch blocks in _apply_replacements and _postformat are eliminated. Legacy raw-array format is still supported for backward compatibility with direct callers.
4. Built reverse lookup hashes for state/county codes — _build_code_lookups() creates {state_codes_reverse} and {county_codes_reverse} hashes at config time, turning O(n) linear scans in _add_code into O(1) hash lookups.
5. Pre-compiled abbreviation regexes — _precompile_abbreviations() compiles qr/(^|\s)\Q$long\E\b/ patterns once at load time, stored in {compiled_abbreviations}. _abbreviate() uses these directly.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cached compiled Mustache templates — $THC->compile() results are now memoized in $self->{compiled_template_cache} keyed by template text, avoiding recompilation on every call.
Removed redundant clone — The second clone() in _render_template was removed since Text::Hogan::Template->render() doesn't mutate its context.
Pre-compiled replacement regexes — _precompile_rules() runs at config load time, compiling all replace and postformat_replace regex patterns into qr// objects. The hot-loop try/catch blocks in _apply_replacements and _postformat are eliminated. Legacy raw-array format is still supported for backward compatibility with direct callers.
Built reverse lookup hashes for state/county codes — _build_code_lookups() creates {state_codes_reverse} and {county_codes_reverse} hashes at config time, turning O(n) linear scans in _add_code into O(1) hash lookups.
Pre-compiled abbreviation regexes — _precompile_abbreviations() compiles qr/(^|\s)\Q$long\E\b/ patterns once at load time, stored in {compiled_abbreviations}. _abbreviate() uses these directly.