Skip to content

Avoid allocating the comma tail twice - #14

Merged
iliaal merged 1 commit into
masterfrom
simplify/reuse-comma-tail-string
Oct 10, 2026
Merged

iliaal merged 1 commit into
masterfrom
simplify/reuse-comma-tail-string

Conversation

@iliaal

@iliaal iliaal commented Oct 9, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Join the comma-separated given-name tail once and share that string between the reentrant-tail stack and the protected split hook.
  • Remove a redundant string allocation without changing parsing decisions or public/protected signatures.
  • Add a regression proving that a subclass can mutate its by-value hook argument without corrupting the cached tail or original source.

Measured benefit

On PHP 8.4.24, an exactly 1 MiB valid three-segment input (Smith, + 1,048,565 lowercase a characters + , MD) uses 1,052,672 fewer live bytes at hook entry and 1,052,672 fewer peak allocated bytes during parsing. Five before/after samples were identical. This saves one joined-tail string when there are multiple tail segments; single-element tails already share their string. No broad throughput improvement is claimed.

Validation

  • PHP 8.4.24 / PHPUnit 12.5.29: 1,198 tests and 3,107 assertions passed with the 256 MiB test limit.
  • PHPStan level 9 and PHP 8.5 compatibility analysis passed (local analysis memory limit 512 MiB).
  • PHP CS Fixer dry run, 69 PHP syntax checks, Composer audit, baseline/README/deprecation guards, and diff checks passed.
  • Independent review: 273 complete corpus outputs matched master; copy-on-write, nested success/failure, mismatched direct-hook calls, exception cleanup, and parser reuse checks passed.
  • Verified all 84 remote file paths, modes, and blob hashes match the tested local tree before opening this PR; recursive tree was not truncated.
  • Exact-head CI passed all five jobs: PHP 8.3 / 8.4 / 8.5 tests (including Composer audit), static analysis (including the PHP 8.5 compatibility gate), and code style. No jobs or steps were skipped.

@iliaal
iliaal merged commit 86831c6 into master Oct 10, 2026
5 checks passed
@iliaal
iliaal deleted the simplify/reuse-comma-tail-string branch October 10, 2026 18:53
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