Skip to content
This repository was archived by the owner on Feb 12, 2025. It is now read-only.

Commit cc325b1

Browse files
committed
Added a private 'equalsCompareValue', so the GetHashCode and Equals function do not have to compute the value of ProjectName + Label + StartTime.Ticks on each call
1 parent ef2dfcc commit cc325b1

File tree

1 file changed

+42
-11
lines changed

1 file changed

+42
-11
lines changed

project/core/IntegrationResult.cs

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ public class IntegrationResult : IIntegrationResult
5555
private Exception sourceControlError;
5656

5757

58+
59+
5860
/// <summary>
5961
/// Gets the build progress information.
6062
/// </summary>
@@ -99,7 +101,7 @@ public IntegrationResult(string projectName, string workingDirectory, string art
99101

100102
CustomIntegrationProperties = lastIntegration.CustomIntegrationProperties;
101103

102-
this.label = this.LastIntegration.Label;
104+
this.Label = this.LastIntegration.Label;
103105
}
104106

105107
/// <summary>
@@ -110,7 +112,11 @@ public IntegrationResult(string projectName, string workingDirectory, string art
110112
public string ProjectName
111113
{
112114
get { return projectName; }
113-
set { projectName = value; }
115+
set
116+
{
117+
projectName = value;
118+
UpdateEqualsCompareValue();
119+
}
114120
}
115121

116122
/// <summary>
@@ -143,7 +149,11 @@ public BuildCondition BuildCondition
143149
public string Label
144150
{
145151
get { return label; }
146-
set { label = value; }
152+
set
153+
{
154+
label = value;
155+
UpdateEqualsCompareValue();
156+
}
147157
}
148158

149159
/// <summary>
@@ -256,7 +266,11 @@ public IntegrationStatus Status
256266
public DateTime StartTime
257267
{
258268
get { return startTime; }
259-
set { startTime = value; }
269+
set
270+
{
271+
startTime = value;
272+
UpdateEqualsCompareValue();
273+
}
260274
}
261275

262276
/// <summary>
@@ -660,7 +674,7 @@ public IDictionary IntegrationProperties
660674
fullProps[nv.Name] = nv.Value;
661675
}
662676
}
663-
677+
664678
return fullProps;
665679
}
666680
}
@@ -677,10 +691,7 @@ public override bool Equals(object obj)
677691
if (other == null)
678692
return false;
679693

680-
return ProjectName == other.ProjectName &&
681-
Status == other.Status &&
682-
Label == other.Label &&
683-
StartTime == other.StartTime;
694+
return string.Equals(EqualsCompareValue, other.EqualsCompareValue);
684695
}
685696

686697
/// <summary>
@@ -690,9 +701,29 @@ public override bool Equals(object obj)
690701
/// <remarks></remarks>
691702
public override int GetHashCode()
692703
{
693-
return (ProjectName + Label + StartTime.Ticks).GetHashCode();
704+
return EqualsCompareValue.GetHashCode();
694705
}
695706

707+
708+
709+
string equalsCompareValue;
710+
711+
/// <summary>
712+
/// Updates equalsCompareValue so the GetHashCode and Equals function do not have to compute the value on each call
713+
/// Value consists of : ProjectName + Label + StartTime.Ticks
714+
/// </summary>
715+
private void UpdateEqualsCompareValue()
716+
{
717+
equalsCompareValue = ProjectName + Label + StartTime.Ticks;
718+
}
719+
720+
721+
internal string EqualsCompareValue
722+
{
723+
get { return equalsCompareValue; }
724+
}
725+
726+
696727
/// <summary>
697728
/// Toes the string.
698729
/// </summary>
@@ -761,7 +792,7 @@ public virtual IIntegrationResult Clone()
761792
clone.projectUrl = projectUrl;
762793
clone.buildLogDirectory = buildLogDirectory;
763794
clone.parameters = new List<NameValuePair>(parameters);
764-
clone.label = label;
795+
clone.Label = label;
765796
clone.modifications = (Modification[])modifications.Clone();
766797
clone.status = status;
767798
return clone;

0 commit comments

Comments
 (0)