Repository navigation
Cheaper xsi:nil checks and value reads on decode - #85
Conversation
Hoist per property type meta out of the object loops
Xmlns::xsi() builds a new object on every call. OptionalElementEncoder now resolves it once per iso, and DocumentToLookupArrayReader compares against a class constant.
Locator\Node\value() reads substitutedNodeValue and coerces it to a string, which it already is on a Dom\Element. Reading the property skips the function call and the Psl coercion.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
…per-decode-reads # Conflicts: # src/Xml/Reader/DocumentToLookupArrayReader.php
Stacked on #80.
Summary
Decoding called
Xmlns::xsi()for every element it checked forxsi:nil, which builds a new object on every call, and read every element value throughLocator\Node\value($element, string()). That function readssubstitutedNodeValueand coerces it with Psl, but on aDom\Elementthat property is already a non-nullable string.OptionalElementEncoder::iso()now resolves the xsi namespace once per iso, andElementValueReaderreadssubstitutedNodeValuedirectly. Each change is its own commit.Same output
The namespace string and the value read are the same as before, so decoded values and exceptions cannot change. The removed coercion could not fail, because the property is typed
string. The decoded results of the 3MB workloads have the same sha1 before and after.Stacked on #80
This branch is based on #80, which deletes
DocumentToLookupArrayReader, so the diff only touchesOptionalElementEncoderandElementValueReader. I leftElementLookup::text()alone because it only runs for the_text value. I leftXsiTypeDetectoralone because #82 rewrites that line.Speed
Median of 3 interleaved rounds on the same machine, with ext-soap as the noise reference.
The gain is small and only on decode. Encode stays within 3% either way.
Summary by CodeRabbit