Skip to content

fix(#174): compile currency/precision regexes once via lazy_static#323

Open
LeJamon wants to merge 1 commit into
XRPLF:mainfrom
LeJamon:fix/issue-174
Open

fix(#174): compile currency/precision regexes once via lazy_static#323
LeJamon wants to merge 1 commit into
XRPLF:mainfrom
LeJamon:fix/issue-174

Conversation

@LeJamon

@LeJamon LeJamon commented May 30, 2026

Copy link
Copy Markdown

Closes #174.

is_hex_address, is_iso_code, is_iso_hex and _calculate_precision called Regex::new(..) on every invocation, recompiling the pattern on the hot path.

Caches the compiled regexes in lazy_static statics, matching the existing pattern used in core/binarycodec/definitions.

Testing

  • cargo test --lib and cargo test --doc (existing is_hex_address / is_iso_code / is_iso_hex coverage)
  • cargo fmt --check; no_std feature set green

is_hex_address, is_iso_code, is_iso_hex and _calculate_precision rebuilt
their Regex on every call. Cache them in lazy_static statics (matching the
existing pattern in binarycodec definitions) to avoid recompiling on the
hot path.
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.

Regex compiled per call (is_hex_address, etc.)

1 participant