Skip to content

Commit 24f948a

Browse files
PR #402 Only convert entry.Name once when accessing updateIndex
* don't convert entry.Name twice when accessing updateIndex * Update src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs Accepted suggestion Co-Authored-By: nils måsén <[email protected]> * Update src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs Co-Authored-By: nils måsén <[email protected]> * Update src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs Co-Authored-By: nils måsén <[email protected]> * Update src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs Co-Authored-By: nils måsén <[email protected]> Co-authored-by: nils måsén <[email protected]>
1 parent bf4372a commit 24f948a

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1626,7 +1626,7 @@ private void AddUpdate(ZipUpdate update)
16261626
{
16271627
contentsEdited_ = true;
16281628

1629-
int index = FindExistingUpdate(update.Entry.Name);
1629+
int index = FindExistingUpdate(update.Entry.Name, isEntryName: true);
16301630

16311631
if (index >= 0)
16321632
{
@@ -2555,13 +2555,9 @@ private void CopyEntryDataDirect(ZipUpdate update, Stream stream, bool updateCrc
25552555
private int FindExistingUpdate(ZipEntry entry)
25562556
{
25572557
int result = -1;
2558-
string convertedName = entry.IsDirectory
2559-
? GetTransformedDirectoryName(entry.Name)
2560-
: GetTransformedFileName(entry.Name);
2561-
2562-
if (updateIndex_.ContainsKey(convertedName))
2558+
if (updateIndex_.ContainsKey(entry.Name))
25632559
{
2564-
result = (int)updateIndex_[convertedName];
2560+
result = (int)updateIndex_[entry.Name];
25652561
}
25662562
/*
25672563
// This is slow like the coming of the next ice age but takes less storage and may be useful
@@ -2579,11 +2575,11 @@ private int FindExistingUpdate(ZipEntry entry)
25792575
return result;
25802576
}
25812577

2582-
private int FindExistingUpdate(string fileName)
2578+
private int FindExistingUpdate(string fileName, bool isEntryName = false)
25832579
{
25842580
int result = -1;
25852581

2586-
string convertedName = GetTransformedFileName(fileName);
2582+
string convertedName = !isEntryName ? GetTransformedFileName(fileName) : fileName;
25872583

25882584
if (updateIndex_.ContainsKey(convertedName))
25892585
{

0 commit comments

Comments
 (0)