perf: reduce parse node allocations when deserializing primitive types#128
perf: reduce parse node allocations when deserializing primitive types#128Copilot wants to merge 3 commits into
Conversation
Co-authored-by: baywet <7905502+baywet@users.noreply.github.com>
|
@copilot here is the pull request I want you to use as an example and I forgot to include earlier microsoft/kiota-dotnet#678 |
Co-authored-by: baywet <7905502+baywet@users.noreply.github.com>
Applied the same pattern from that PR in commit |
|


Several
TextParseNodemethods caused unnecessary intermediate heap allocations. This PR eliminates those allocations across both numeric and string-based value getters.Changes
Numeric getters — eliminate intermediate
*float64allocationsGetFloat32Value: parses directly viastrconv.ParseFloat(n.value, 32)— eliminates intermediate*float64GetFloat64Value: corrects bitSize from0→64; returns&valdirectlyGetInt32Value: parses directly viastrconv.ParseInt(n.value, 10, 32)— eliminates intermediate*float64GetInt64Value: parses directly viastrconv.ParseInt(n.value, 10, 64)— eliminates intermediate*float64String-based getters — eliminate intermediate
*stringallocationsGetTimeValue,GetISODurationValue,GetTimeOnlyValue,GetDateOnlyValue,GetUUIDValue,GetEnumValue,GetByteArrayValue: previously calledGetStringValue()which allocated a*stringon the heap before passing the value to the underlying parser. Each now works withstrings.Trim(n.value, "\"")directly — eliminating that pointer allocation.Before / After
Also adds unit tests for each modified numeric method.
Original prompt
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.