Repository navigation
Conversation
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.
Keep each TIFF directory entry and its value in their own heap blocks, as C++ does
Problem
TiffDirectory(C++, Rust) holds the entries the TIFF parser reads. C++ keeps them in astd::map, so each entry is its own heap node, and each value is astd::vectorwith its own heap buffer, even when it is 1 byte. The port keeps the entries in oneVecand stores a value of 8 bytes or less inside the entry, so only a longer value gets a heap buffer.For example, heap blocks for the entries and their values in
GetPreviewImageData,GetDngInformationandGetOrientation:What each call returns is the same on both sides.
Question
Which behaviour do we want: C++'s or the Rust port's? Specifically, should each directory entry be its own heap block, with its value in its own heap buffer (like the C++ library), or a slot in one
Vecwith a value of 8 bytes or less stored inside it (like the Rust port)?This PR implements C++'s behaviour.
Fix
newandnew_slicealways buildEntryValue::Heap, so every value has its own heap buffer, as C++'sstd::vectordoes.add_directory_entryboxes each entry, one heap block per entry, as C++'s map node is.The examples above then match C++ (C++ in blue, the port in red, this PR in green):
What each call returns does not change, on these files and on a file of each other format piex reads, and the port's tests pass (44 + 174).
A note for review: