Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremie Laval <jeremie.laval@gmail.com>2012-11-29 19:14:44 +0400
committerJeremie Laval <jeremie.laval@gmail.com>2012-11-29 19:21:05 +0400
commit1f6a2697fcd19f81a939d1b44adcf9ed79621a70 (patch)
tree1ec9d62527794adfd4622cc7f33f1d1031310d4f
parent43f36c19ba49214349eb745d6a5559a294e7b7bf (diff)
[monkeydoc] Use a map to quickly access zip archive content.
-rw-r--r--mcs/tools/monkeydoc/Monkeydoc/storage/ZipStorage.cs8
1 files changed, 7 insertions, 1 deletions
diff --git a/mcs/tools/monkeydoc/Monkeydoc/storage/ZipStorage.cs b/mcs/tools/monkeydoc/Monkeydoc/storage/ZipStorage.cs
index b04ee39556a..81ed1c5bd66 100644
--- a/mcs/tools/monkeydoc/Monkeydoc/storage/ZipStorage.cs
+++ b/mcs/tools/monkeydoc/Monkeydoc/storage/ZipStorage.cs
@@ -15,6 +15,8 @@ namespace MonkeyDoc.Storage
int code;
ZipOutputStream zipOutput;
ZipFile zipFile;
+ // SharpZipLib use linear search to map name to index, correct that a bit
+ Dictionary<string, int> entries = new Dictionary<string, int> ();
public ZipStorage (string zipFileName)
{
@@ -78,7 +80,10 @@ namespace MonkeyDoc.Storage
public Stream Retrieve (string id)
{
EnsureInput ();
- ZipEntry entry = zipFile.GetEntry (id);
+ int index;
+ ZipEntry entry;
+ if (!entries.TryGetValue (id, out index) || (entry = zipFile[index]) == null)
+ entry = zipFile.GetEntry (id);
if (entry != null)
return zipFile.GetInputStream (entry);
else
@@ -107,6 +112,7 @@ namespace MonkeyDoc.Storage
if (zipFile != null)
return;
zipFile = new ZipFile (zipFileName);
+ entries = Enumerable.Range (0, zipFile.Size).ToDictionary (i => zipFile[i].Name, i => i);
}
public void Dispose ()