All of our call sites to it pass in a const StringComparison; GetHashCode will then turn around and decide which property on StringComparer to use, and then call GetHashCode on the relevant instance... we may as well just pick the instance directly, which not only saves the lookup and enables devirtualization, it also enables better trimming, as string.GetHashCode(StringComparison) ends up rooting all of the StringComparer properties in case you pass in the appropriate StringComparison.
public override int GetHashCode()
{
- return ToString().GetHashCode(StringComparison.InvariantCultureIgnoreCase);
+ return StringComparer.InvariantCultureIgnoreCase.GetHashCode(ToString());
}
private static readonly EncodedStreamFactory s_encoderFactory = new EncodedStreamFactory();
if (IsUncOrDosPath)
{
- return remoteUrl.GetHashCode(StringComparison.OrdinalIgnoreCase);
+ return StringComparer.OrdinalIgnoreCase.GetHashCode(remoteUrl);
}
else
{
public override int GetHashCode()
{
- return Name == null ? 0 : Name.GetHashCode(StringComparison.OrdinalIgnoreCase);
+ return Name == null ? 0 : StringComparer.OrdinalIgnoreCase.GetHashCode(Name);
}
public override string ToString()