Repository navigation
Parse numeric fields straight from the record bytes on .NET 8+ - #340
Merged
Merged
Conversation
AsciiFieldParser copied each numeric field into a stack-allocated char span before parsing. .NET 8 and later can parse the bytes directly, so skip the copy there. netstandard2.1 keeps the existing path. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



AsciiFieldParsercopied each numeric field into a stack-allocatedcharspan and then parsed that. .NET 8 and later haveTryParseoverloads that take UTF-8 bytes, so on thenet10.0target theint,long,decimalandfloatparsers now parse the record bytes directly.netstandard2.1keeps the existing copy-then-parse path behind#if, as the byte overloads do not exist there. Date parsing is unchanged.Behaviour
No change intended. Two checks:
DbfValueParsingTestspass, includingNumeric_bytes_above_ascii_fail_to_parse_like_ascii_decoding_did..,E, NUL, tab,*,,, letters and bytes above 0x7f) found no difference in either the success flag or the parsed value. The fuzz script is not part of this PR.Measurements
A modest win, proportional to how numeric the table is.
Per field (Release, Apple M3 Max, best of 7 runs of 5 million parses):
N(14,0)→longN(14,4)→decimalOn the cross-library benchmark fixture (
tl_2019_01_place.dbf), which has only 2 numeric columns out of 16, the read loop goes from about 272 µs to 266 µs — close to measurement noise. Tables dominated by integer columns benefit most.Testing
Full suite: 535 passed, 1 skipped (pre-existing).
🤖 Generated with Claude Code