Repository navigation
Skip xsi:type detection for elements without attributes - #81
Conversation
An xsi:type can only live on the element itself, so an element without attributes always decodes through the inner encoder. Checking hasAttributes() first avoids the two attribute lookups and the Option wrapping for every such element on decode.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 14 minutes. View limit details
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
…tion-without-attributes # Conflicts: # src/Encoder/XsiTypeEncoder.php # tests/Unit/Encoder/XsiTypeEncoderTest.php
Summary
On decode,
XsiTypeEncoderasksXsiTypeDetectorfor an xsi:type on every element it sees. Most elements in a literal response carry no attributes at all, yet each one still pays for two attribute lookups and theOptionwrapping around them. I now checkhasAttributes()first and go straight to the inner encoder when it is false.The detector only reads the
xsi:typeattribute of the element itself. It does not look at parents, children or the context type, so an element without attributes always ended up on the inner encoder before this change too.Dom\Elementcounts namespace declarations as attributes, which means an element that only declaresxmlns:...still goes through the detector as before. TheDisregardXsiInformationarm still runs first, so encoders that ignore xsi information do not get an extra parse.3MB synthetic workloads, seconds, median of 3 interleaved rounds:
Encode does not pass through this code, so those rows show the noise level of the runs. In phpbench, literal decode is 9% to 12% faster and literal sparse decode 3% to 5%. Encoded decode stays flat because every element there carries an xsi:type. The other subjects move between -4% and +4%, which matches how much the ext-soap subjects move without any change.
Summary by CodeRabbit
xsi:typeare now decoded by the underlying encoder, preserving the expected value type.