Added mmap-based implementation for POSIX-compliant systems. #5
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.
Preamble
Tar is a very simple format, which makes it possible to very easily find a pointer to a packed file.
Using
mmap
, I added the ability to directly map a tar file into the computer's address space, andfind pointers to large pieces of memory.
This eliminates potentially unnecessary copies, and in my testing (getting the contents of a file many
thousands of times), the
mmap
-based implementation proved to be 60% faster, which is a great improvement.What was added
I added
mtar_open_mapped
,mtar_get_mapped
, andmtar_get_pointer
to open, query, and loop through a mapped file respectively.
What was lost
All features were added, no functionality was lost in the base API.
Example