Repository navigation
craft-dxf: faster ASCII writing and parse_recovering (ports of open CADCraft PRs) - #924
Merged
Merged
Conversation
…achinery
write_ascii and its code page forms wrote every group code through
write!("{:>3}"), every real through a String of its own and every string
character by character. A large drawing writes millions of each. Codes 0 to
9999 and reals are now appended in place, and text with no line break or
backslash that is ASCII (or goes out as UTF-8) is copied as it is. Text for a
code page still takes the long path, since a code page may write an ASCII
character another way. The output is byte for byte what it was.
Ported from storytold/cadcraft#1938 (the crates/dxf part).
…he damage parse fails a file at the first line that is no group code, and at a last group code with no value. parse_recovering returns the tags before that point and the line where reading stopped, so a caller can open what the file still holds and say where it ends. Reading stops at the damage: lines after it are not paired up by guesswork. Damage before the first group, a truncated binary file and the group-code limit are still errors. section_slices ends a section at EOF as well as ENDSEC, so the EOF of a file cut inside a section is not one of that section's records. Ported from storytold/cadcraft#1565 (the crates/dxf part).
Contributor
|
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 29 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
|
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.



Two changes to the tag layer of
craft-dxf, ported from open CADCraft pull requests so they are not lost when CADCraft drops its own copy of the crate (storytold/cadcraft#3040). Part of #778.Writing: no formatting machinery for codes, reals and plain text
Ported from storytold/cadcraft#1938 by @francescoBV (the
crates/dxfpart; the rest of that PR is CADCraft's own writer).write_asciiand its code page forms wrote every group code throughwrite!("{:>3}"), every real through aStringof its own and every string one character at a time. Codes 0 to 9999 and reals are now appended in place, and text with no line break or backslash that is ASCII (or goes out as UTF-8) is copied as it is.Adapted to this crate as it is now: the writer produces bytes, reals keep the exponent form added in #847, and text written in a code page still takes the long path, because a code page may write an ASCII character another way. The output is byte for byte what it was;
fast_code_and_real_formatting_match_formatcompares codes, reals and strings with the old formatting, including a code page that shadows ASCII.Reading:
parse_recoveringPorted from storytold/cadcraft#1565 by @aljormon84 (the
crates/dxfpart; the clipping feature stays in CADCraft).parsefails a file at the first line that is no group code and at a last group code with no value.parse_recoveringreturns the tags before that point and the 1-based line where reading stopped (Nonefor an intact file).Two differences from the source PR:
parse.section_slicesnow ends a section at0 EOFas well as0 ENDSEC, so the EOF of a file cut inside a section is not one of its records.Ran
cargo fmt -p craft-dxf --check: cleancargo clippy -p craft-dxf --all-targets -- -D warnings: cleancargo test -p craft-dxf: 84 passed, 2 ignored (11 test binaries), including the 5 new tests intests/recovering.rsand the new unit testNot run: any app against this branch, and no timing was measured here (the source PR's figures are for CADCraft's whole save path).
Not ported
storytold/cadcraft#1835 (
TagStream, a streaming parser for the DWG bridge's output) is left for when the DWG bridge moves: it rewrites the binary reader this crate has since extended (R12 binary), and has no caller here yet.