diff --git a/OpenMcdf.Perf/Program.cs b/OpenMcdf.Perf/Program.cs index c49534f..f1f54a9 100644 --- a/OpenMcdf.Perf/Program.cs +++ b/OpenMcdf.Perf/Program.cs @@ -39,7 +39,7 @@ public static void MultiStorageAndStreamWrite() int writeCount = 1024; byte[] buffer = new byte[32 * 512]; - Microsoft.IO.RecyclableMemoryStreamManager manager = new (); + Microsoft.IO.RecyclableMemoryStreamManager manager = new(); Microsoft.IO.RecyclableMemoryStream baseStream = new(manager); baseStream.Capacity = 2 * (storageCount * buffer.Length * writeCount + storageCount * (streamCount - 1) * buffer.Length); diff --git a/OpenMcdf/DirectoryTree.cs b/OpenMcdf/DirectoryTree.cs index 26620cc..cf2d605 100644 --- a/OpenMcdf/DirectoryTree.cs +++ b/OpenMcdf/DirectoryTree.cs @@ -107,15 +107,15 @@ public void Add(DirectoryEntry entry) return; } - uint previous = currentEntry!.LeftSiblingId; - uint next = currentEntry.RightSiblingId; - while (true) { - int compare = DirectoryEntryComparer.Compare(entry.NameCharSpan, currentEntry!.NameCharSpan); + uint leftId = currentEntry!.LeftSiblingId; + uint rightId = currentEntry.RightSiblingId; + + int compare = DirectoryEntryComparer.Compare(entry.NameCharSpan, currentEntry.NameCharSpan); if (compare < 0) { - if (previous == StreamId.NoStream) + if (leftId == StreamId.NoStream) { currentEntry.LeftSiblingId = entry.Id; directories.Write(currentEntry); @@ -123,11 +123,11 @@ public void Add(DirectoryEntry entry) return; } - currentEntry = directories.GetDictionaryEntry(previous); + currentEntry = directories.GetDictionaryEntry(leftId); } else if (compare > 0) { - if (next == StreamId.NoStream) + if (rightId == StreamId.NoStream) { currentEntry.RightSiblingId = entry.Id; directories.Write(currentEntry); @@ -135,15 +135,12 @@ public void Add(DirectoryEntry entry) return; } - currentEntry = directories.GetDictionaryEntry(next); + currentEntry = directories.GetDictionaryEntry(rightId); } else { throw new IOException($"{entry.Type} \"{entry.NameString}\" already exists."); } - - previous = currentEntry!.LeftSiblingId; - next = currentEntry!.RightSiblingId; } } @@ -209,6 +206,7 @@ internal void WriteTrace(TextWriter writer) WriteTrace(writer, current, 0); } + [ExcludeFromCodeCoverage] void WriteTrace(TextWriter writer, DirectoryEntry entry, int indent) { directories.TryGetDictionaryEntry(entry.RightSiblingId, out DirectoryEntry? rightSibling); diff --git a/OpenMcdf/Storage.cs b/OpenMcdf/Storage.cs index eb1ebb9..a512b89 100644 --- a/OpenMcdf/Storage.cs +++ b/OpenMcdf/Storage.cs @@ -125,7 +125,7 @@ public bool TryOpenStorage(string name, [MaybeNullWhen(false)] out Storage? stor this.ThrowIfDisposed(Context.IsDisposed); - directoryTree.TryGetDirectoryEntry(name, out DirectoryEntry? entry); + directoryTree.TryGetDirectoryEntry(name, out DirectoryEntry? entry); if (entry is null || entry.Type is not StorageType.Storage) { storage = null; diff --git a/StructuredStorageExplorer/MainForm.cs b/StructuredStorageExplorer/MainForm.cs index 20c6541..5ba64e8 100644 --- a/StructuredStorageExplorer/MainForm.cs +++ b/StructuredStorageExplorer/MainForm.cs @@ -1,7 +1,7 @@ #define OLE_PROPERTY -using OpenMcdf.Ole; using OpenMcdf; +using OpenMcdf.Ole; using StructuredStorageExplorer.Properties; using System.Collections; using System.ComponentModel;