Skip to content

Commit

Permalink
imp - prf - Don't run through all types
Browse files Browse the repository at this point in the history
---

This brings little to no performance improvements, but reduces the number of calls to Get*() functions in both the vCard and the vCalendar instances.

---

Type: imp
Breaking: False
Doc Required: False
Backport Required: False
Part: 1/1
  • Loading branch information
AptiviCEO committed Oct 3, 2024
1 parent 2ebe7a6 commit 7cf7b12
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
9 changes: 3 additions & 6 deletions VisualCard.Calendar/Parts/Calendar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,7 @@ internal string SaveToString(Version version, Dictionary<CalendarPartsArrayEnum,
cardBuilder.AppendLine($"{VcardConstants._versionSpecifier}:{version}");

// Then, enumerate all the strings
CalendarStringsEnum[] stringEnums = (CalendarStringsEnum[])Enum.GetValues(typeof(CalendarStringsEnum));
foreach (CalendarStringsEnum stringEnum in stringEnums)
foreach (CalendarStringsEnum stringEnum in strings.Keys)
{
// Get the string values
var array = GetString(stringEnum, version, strings);
Expand Down Expand Up @@ -313,8 +312,7 @@ internal string SaveToString(Version version, Dictionary<CalendarPartsArrayEnum,
}

// Then, enumerate all the integers
CalendarIntegersEnum[] integerEnums = (CalendarIntegersEnum[])Enum.GetValues(typeof(CalendarIntegersEnum));
foreach (CalendarIntegersEnum integerEnum in integerEnums)
foreach (CalendarIntegersEnum integerEnum in integers.Keys)
{
// Get the string value
var array = GetInteger(integerEnum, version, integers);
Expand Down Expand Up @@ -344,8 +342,7 @@ internal string SaveToString(Version version, Dictionary<CalendarPartsArrayEnum,
}

// Then, enumerate all the arrays
CalendarPartsArrayEnum[] partsArrayEnums = (CalendarPartsArrayEnum[])Enum.GetValues(typeof(CalendarPartsArrayEnum));
foreach (CalendarPartsArrayEnum partsArrayEnum in partsArrayEnums)
foreach (CalendarPartsArrayEnum partsArrayEnum in partsArray.Keys)
{
// Get the array value
var array = GetPartsArray<BaseCalendarPartInfo>(partsArrayEnum, version, partsArray);
Expand Down
6 changes: 2 additions & 4 deletions VisualCard/Parts/Card.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,7 @@ public string SaveToString()
cardBuilder.AppendLine($"{VcardConstants._versionSpecifier}:{version}");

// Then, enumerate all the strings
StringsEnum[] stringEnums = (StringsEnum[])Enum.GetValues(typeof(StringsEnum));
foreach (StringsEnum stringEnum in stringEnums)
foreach (StringsEnum stringEnum in strings.Keys)
{
// Get the string values
var array = GetString(stringEnum);
Expand Down Expand Up @@ -231,8 +230,7 @@ public string SaveToString()
}

// Then, enumerate all the arrays
PartsArrayEnum[] partsArrayEnums = (PartsArrayEnum[])Enum.GetValues(typeof(PartsArrayEnum));
foreach (PartsArrayEnum partsArrayEnum in partsArrayEnums)
foreach (PartsArrayEnum partsArrayEnum in partsArray.Keys)
{
// Get the array value
var array = GetPartsArray<BaseCardPartInfo>(partsArrayEnum);
Expand Down

0 comments on commit 7cf7b12

Please sign in to comment.