Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
d52d836
Avoid unnecessary byte[] allocations
stephentoub Aug 19, 2022
1e5020e
Remove unnecessary use of FileStreamOptions
stephentoub Aug 19, 2022
6938c77
Clean up Dispose{Async} implementations
stephentoub Aug 19, 2022
5fa03e9
Clean up unnecessary consts
stephentoub Aug 19, 2022
8dd0ac1
Remove MemoryStream/Encoding.UTF8.GetBytes allocations, unnecessary a…
stephentoub Aug 19, 2022
5be57ad
Avoid string allocations in ReadMagicAttribute
stephentoub Aug 19, 2022
ab71e6c
Avoid allocation in WriteAsOctal
stephentoub Aug 19, 2022
df2d742
Improve handling of octal
stephentoub Aug 19, 2022
c6058bd
Avoid allocation for version string
stephentoub Aug 19, 2022
5756a8c
Removing boxing and char string allocation in GenerateExtendedAttribu…
stephentoub Aug 19, 2022
9539a4a
Fix a couple unnecessary dictionary lookups
stephentoub Aug 19, 2022
74bbc9c
Replace Enum.HasFlag usage
stephentoub Aug 19, 2022
46e0855
Remove allocations from Write{Posix}Name
stephentoub Aug 19, 2022
02ca7da
Replace ArrayPool use with string.Create
stephentoub Aug 19, 2022
f9eb99f
Replace more superfluous ArrayPool usage
stephentoub Aug 19, 2022
add6179
Remove ArrayPool use from System.IO.Compression.ZipFile
stephentoub Aug 20, 2022
6f8cb75
Fix inverted condition
stephentoub Aug 20, 2022
827a588
Use generic math to parse octal
stephentoub Aug 20, 2022
ae21478
Remove allocations from StringReader and string.Split
stephentoub Aug 20, 2022
d6b6727
Remove magic string allocation for Ustar when not V7
stephentoub Aug 20, 2022
480af5c
Remove file name and directory name allocation in GenerateExtendedAtt…
stephentoub Aug 20, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Avoid string allocations in ReadMagicAttribute
  • Loading branch information
stephentoub committed Aug 19, 2022
commit 5be57ad948a6a99d635c4d5d458d2d4606de59b8
Original file line number Diff line number Diff line change
Expand Up @@ -425,17 +425,21 @@ private void ReadMagicAttribute(Span<byte> buffer)
}

// When the magic field is set, the archive is newer than v7.
_magic = Encoding.ASCII.GetString(magic);

if (_magic == GnuMagic)
if (magic.SequenceEqual(GnuMagicBytes))
{
_magic = GnuMagic;
_format = TarEntryFormat.Gnu;
}
else if (_format == TarEntryFormat.V7 && _magic == UstarMagic)
else if (_format == TarEntryFormat.V7 && magic.SequenceEqual(PaxMagicBytes))
{
// Important: Only change to ustar if we had not changed the format to pax already
_magic = UstarMagic;
_format = TarEntryFormat.Ustar;
}
else
{
_magic = Encoding.ASCII.GetString(magic);
}
}

// Reads the version string and determines the format depending on its value.
Expand Down