Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
8c07524
Avoid unnecessary byte[] allocations
stephentoub Aug 19, 2022
53d24d0
Remove unnecessary use of FileStreamOptions
stephentoub Aug 19, 2022
c9dc0be
Clean up Dispose{Async} implementations
stephentoub Aug 19, 2022
4e1af20
Clean up unnecessary consts
stephentoub Aug 19, 2022
13f011b
Remove MemoryStream/Encoding.UTF8.GetBytes allocations, unnecessary a…
stephentoub Aug 19, 2022
8735a67
Avoid string allocations in ReadMagicAttribute
stephentoub Aug 19, 2022
f50edcf
Avoid allocation in WriteAsOctal
stephentoub Aug 19, 2022
29a90d3
Improve handling of octal
stephentoub Aug 19, 2022
e211457
Avoid allocation for version string
stephentoub Aug 19, 2022
868a20c
Removing boxing and char string allocation in GenerateExtendedAttribu…
stephentoub Aug 19, 2022
c83e97c
Fix a couple unnecessary dictionary lookups
stephentoub Aug 19, 2022
82b8909
Replace Enum.HasFlag usage
stephentoub Aug 19, 2022
60145e9
Remove allocations from Write{Posix}Name
stephentoub Aug 19, 2022
e9a32ec
Replace ArrayPool use with string.Create
stephentoub Aug 19, 2022
d632a95
Replace more superfluous ArrayPool usage
stephentoub Aug 19, 2022
fbf22b3
Remove ArrayPool use from System.IO.Compression.ZipFile
stephentoub Aug 20, 2022
60d9352
Fix inverted condition
stephentoub Aug 20, 2022
24aa3a2
Use generic math to parse octal
stephentoub Aug 20, 2022
25b32ff
Remove allocations from StringReader and string.Split
stephentoub Aug 20, 2022
9649015
Remove magic string allocation for Ustar when not V7
stephentoub Aug 20, 2022
c5a8bfe
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
Replace Enum.HasFlag usage
  • Loading branch information
stephentoub authored and github-actions committed Aug 21, 2022
commit 82b890927434dfda45948209b0f68ca6b7336d62
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ private static string GetEntryNameForFileSystemInfo(FileSystemInfo file, int bas
int entryNameLength = file.FullName.Length - basePathLength;
Debug.Assert(entryNameLength > 0);

bool isDirectory = file.Attributes.HasFlag(FileAttributes.Directory);
bool isDirectory = (file.Attributes & FileAttributes.Directory) != 0;
return ArchivingUtils.EntryFromPath(file.FullName, basePathLength, entryNameLength, ref entryNameBuffer, appendPathSeparator: isDirectory);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ private TarEntry ConstructEntryForWriting(string fullPath, string entryName, Fil
FileAttributes attributes = File.GetAttributes(fullPath);

TarEntryType entryType;
if (attributes.HasFlag(FileAttributes.ReparsePoint))
if ((attributes & FileAttributes.ReparsePoint) != 0)
{
entryType = TarEntryType.SymbolicLink;
}
else if (attributes.HasFlag(FileAttributes.Directory))
else if ((attributes & FileAttributes.Directory) != 0)
{
entryType = TarEntryType.Directory;
}
else if (attributes.HasFlag(FileAttributes.Normal) || attributes.HasFlag(FileAttributes.Archive))
else if ((attributes & (FileAttributes.Normal | FileAttributes.Archive)) != 0)
{
entryType = Format is TarEntryFormat.V7 ? TarEntryType.V7RegularFile : TarEntryType.RegularFile;
}
Expand All @@ -48,7 +48,7 @@ private TarEntry ConstructEntryForWriting(string fullPath, string entryName, Fil
_ => throw new FormatException(string.Format(SR.TarInvalidFormat, Format)),
};

FileSystemInfo info = attributes.HasFlag(FileAttributes.Directory) ? new DirectoryInfo(fullPath) : new FileInfo(fullPath);
FileSystemInfo info = (attributes & FileAttributes.Directory) != 0 ? new DirectoryInfo(fullPath) : new FileInfo(fullPath);

entry._header._mTime = info.LastWriteTimeUtc;
entry._header._aTime = info.LastAccessTimeUtc;
Expand Down