Skip to content

fix: cache compiled regex in parse_ipc_regex#361

Open
Koan-Bot wants to merge 1 commit intoTest-More:2.0from
Koan-Bot:koan.atoomic/fix-issue-335
Open

fix: cache compiled regex in parse_ipc_regex#361
Koan-Bot wants to merge 1 commit intoTest-More:2.0from
Koan-Bot:koan.atoomic/fix-issue-335

Conversation

@Koan-Bot
Copy link
Copy Markdown
Contributor

@Koan-Bot Koan-Bot commented Mar 30, 2026

Summary

parse_ipc_regex() was called separately in both _find_ipcs and parse_ipc_file, creating a new regex object on every call. Since the regex only depends on $settings->ipc->prefix which is constant during a run, the result is now cached in $self->{+IPC_REGEX} and reused on subsequent calls.

Fixes #335

Changes

  • Added +ipc_regex to the HashBase attribute list in App::Yath::IPC
  • Modified parse_ipc_regex() to cache and return $self->{+IPC_REGEX} after the first compilation
  • Added a test asserting that repeated calls to parse_ipc_regex() return the same cached object

Test plan

  • New subtest parse_ipc_regex() caches the compiled regex in t/unit/App/Yath/IPC.t verifies the returned regex is the same object on repeated calls
  • All existing tests in the file continue to pass

Generated by Kōan /fix


Quality Report

Changes: 1364 files changed, 102466 insertions(+), 24695 deletions(-)

Code scan: 224 issue(s) found

  • .gitignore:40 — TODO comment
  • README:607 — TODO comment
  • README:611 — TODO comment
  • README:615 — TODO comment
  • README.md:565 — TODO comment
  • README.md:569 — TODO comment
  • README.md:573 — TODO comment
  • demo/tiny/tiny.t:4 — XXX marker
  • deplib/App/Yath/Option.pm:21 — FIXME comment
  • deplib/App/Yath/Options.pm:22 — FIXME comment

Tests: failed (timeout (120s))

Branch hygiene: clean

Generated by Kōan post-mission quality pipeline

…pilation

`parse_ipc_regex()` was called independently in both `_find_ipcs` and
`parse_ipc_file`, creating a new regex object on each call. Since the
regex only depends on `$settings->ipc->prefix` which is constant during
a run, cache the result in `$self->{+IPC_REGEX}` so it is compiled once
and reused.

Fixes Test-More#335

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@atoomic atoomic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@atoomic atoomic marked this pull request as ready for review March 31, 2026 01:17
@atoomic
Copy link
Copy Markdown
Collaborator

atoomic commented Mar 31, 2026

@exodist ready to review

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.

Optimization: Redundant regex recompilation in parse_ipc_file and _find_ipcs

3 participants