Skip to content

Cache sub-encoder isos in ScalarTypeEncoder#54

Closed
veewee wants to merge 1 commit intophp-soap:mainfrom
veewee:feature/scalar-type-encoder-iso-cache
Closed

Cache sub-encoder isos in ScalarTypeEncoder#54
veewee wants to merge 1 commit intophp-soap:mainfrom
veewee:feature/scalar-type-encoder-iso-cache

Conversation

@veewee
Copy link
Copy Markdown
Member

@veewee veewee commented Mar 26, 2026

Summary

Captures the int/float/string/bool isos once in iso() instead of creating new IntTypeEncoder() etc. and calling ->iso($context) on every encode invocation.

Impact

<1% (negligible). Each sub-encoder's iso() is trivially cheap. The value is consistency: iso() should capture its dependencies eagerly, not rebuild them per call.

Test plan

  • Full test suite passes (549 tests)
  • Psalm clean
  • CS fixer clean

Builds the int/float/string/bool isos once in iso() instead of
creating new encoder instances and calling iso() on every encode.
@veewee
Copy link
Copy Markdown
Member Author

veewee commented Mar 26, 2026

Closing: the 4 sub-encoder isos are only used in the to() direction, while decode (the hot path) doesn't use them at all. This means we eagerly allocate 4 unused isos on every decode call. No measurable benefit, slight waste on decode.

@veewee veewee closed this Mar 26, 2026
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