Skip to content

Commit

Permalink
Rework OLEProperties.GetDescription to avoid allocating temporary dic…
Browse files Browse the repository at this point in the history
…tionaries
  • Loading branch information
Numpsy committed Aug 26, 2024
1 parent 273bb26 commit 7c8438f
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions sources/OpenMcdf.Extensions/OLEProperties/ProperyIdentifiers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,28 +64,24 @@ public static class CommonIdentifiers

public static class Extensions
{
public static String GetDescription(this uint identifier, ContainerType map, Dictionary<uint, string> customDict = null)
public static string GetDescription(this uint identifier, ContainerType map, Dictionary<uint, string> customDict = null)
{
Dictionary<uint, string> NameDictionary = new Dictionary<uint, string>();
Dictionary<uint, string> nameDictionary = customDict;

if (customDict == null)
if (nameDictionary is null)
{
switch (map)
{
case ContainerType.SummaryInfo:
NameDictionary = CommonIdentifiers.PropertyIdentifiersSummaryInfo;
nameDictionary = CommonIdentifiers.PropertyIdentifiersSummaryInfo;
break;
case ContainerType.DocumentSummaryInfo:
NameDictionary = CommonIdentifiers.PropertyIdentifiersDocumentSummaryInfo;
nameDictionary = CommonIdentifiers.PropertyIdentifiersDocumentSummaryInfo;
break;
}
}
else
{
NameDictionary = customDict;
}

if (NameDictionary.TryGetValue(identifier, out string value))
if (nameDictionary?.TryGetValue(identifier, out string value) == true)
{
return value;
}
Expand Down

0 comments on commit 7c8438f

Please sign in to comment.