refactor(config): use LazyLock for static regex initialization#67
Closed
echobt wants to merge 5 commits intodocs/standardize-timeout-documentationfrom
Closed
refactor(config): use LazyLock for static regex initialization#67echobt wants to merge 5 commits intodocs/standardize-timeout-documentationfrom
echobt wants to merge 5 commits intodocs/standardize-timeout-documentationfrom
Conversation
echobt
added a commit
that referenced
this pull request
Feb 4, 2026
…it, and documentation This PR consolidates the following refactoring changes: - #27: Centralize timeout constants - #43: Replace magic numbers with documented named constants - #67: Use LazyLock for static regex initialization - #68: Extract subagent timeout values as named constants Key changes: - Created centralized timeout module with documented constants - Replaced scattered magic numbers with well-documented constants - Improved static initialization using LazyLock for regexes - Added comprehensive documentation for timeout hierarchy
Contributor
Author
|
Consolidated into #77 - refactor: consolidated code quality improvements - constants, lazy init, and documentation |
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.
Summary
This PR refactors the regex initialization in
config_substitution.rsto usestd::sync::LazyLockfor static regex patterns instead of creating them within struct instances.Problem
The previous implementation compiled regex patterns in the
ConfigSubstitution::new()constructor usingunwrap_or_elsewith panic:While the regex patterns are valid, using panic as error handling is not ideal for the following reasons:
Solution
Replaced the instance-level regex compilation with static
LazyLockconstants at module level:Benefits
ConfigSubstitutioninstancesTesting
All 23 existing tests pass without modification, confirming backward compatibility.