Remove additional premature uses of C#7 features
This commit is contained in:
@@ -10,7 +10,7 @@ namespace Umbraco.Core.Collections
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="CompositeTypeTypeKey"/> struct.
|
||||
/// </summary>
|
||||
public CompositeTypeTypeKey(Type type1, Type type2)
|
||||
public CompositeTypeTypeKey(Type type1, Type type2) : this()
|
||||
{
|
||||
Type1 = type1;
|
||||
Type2 = type2;
|
||||
@@ -19,26 +19,35 @@ namespace Umbraco.Core.Collections
|
||||
/// <summary>
|
||||
/// Gets the first type.
|
||||
/// </summary>
|
||||
public Type Type1 { get; }
|
||||
public Type Type1 { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the second type.
|
||||
/// </summary>
|
||||
public Type Type2 { get; }
|
||||
public Type Type2 { get; private set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool Equals(CompositeTypeTypeKey other)
|
||||
=> Type1 == other.Type1 && Type2 == other.Type2;
|
||||
{
|
||||
return Type1 == other.Type1 && Type2 == other.Type2;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool Equals(object obj)
|
||||
=> obj is CompositeTypeTypeKey other && Type1 == other.Type1 && Type2 == other.Type2;
|
||||
{
|
||||
var other = obj is CompositeTypeTypeKey ? (CompositeTypeTypeKey)obj : default(CompositeTypeTypeKey);
|
||||
return Type1 == other.Type1 && Type2 == other.Type2;
|
||||
}
|
||||
|
||||
public static bool operator ==(CompositeTypeTypeKey key1, CompositeTypeTypeKey key2)
|
||||
=> key1.Type1 == key2.Type1 && key1.Type2 == key2.Type2;
|
||||
{
|
||||
return key1.Type1 == key2.Type1 && key1.Type2 == key2.Type2;
|
||||
}
|
||||
|
||||
public static bool operator !=(CompositeTypeTypeKey key1, CompositeTypeTypeKey key2)
|
||||
=> key1.Type1 != key2.Type1 || key1.Type2 != key2.Type2;
|
||||
{
|
||||
return key1.Type1 != key2.Type1 || key1.Type2 != key2.Type2;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override int GetHashCode()
|
||||
|
||||
@@ -37,7 +37,8 @@ namespace Umbraco.Tests.Benchmarks
|
||||
{
|
||||
// This method is 10% faster
|
||||
var key = new CompositeTypeTypeKey(source, target);
|
||||
if (AssignableTypeCache.TryGetValue(key, out bool canConvert))
|
||||
bool canConvert;
|
||||
if (AssignableTypeCache.TryGetValue(key, out canConvert))
|
||||
{
|
||||
return canConvert;
|
||||
}
|
||||
|
||||
@@ -241,8 +241,10 @@ namespace Umbraco.Web
|
||||
var tmpNodes = cache.GetXPathNavigator().Select("//*[@nodeTypeAlias]");
|
||||
foreach (XPathNavigator tmpNode in tmpNodes)
|
||||
{
|
||||
if (int.TryParse(tmpNode.GetAttribute("id", string.Empty), out int tmpNodeId)
|
||||
&& Guid.TryParse(tmpNode.GetAttribute("key", string.Empty), out Guid tmpNodeKey))
|
||||
int tmpNodeId;
|
||||
Guid tmpNodeKey;
|
||||
if (int.TryParse(tmpNode.GetAttribute("id", string.Empty), out tmpNodeId)
|
||||
&& Guid.TryParse(tmpNode.GetAttribute("key", string.Empty), out tmpNodeKey))
|
||||
{
|
||||
_guidToIntLoopkup[tmpNodeKey] = tmpNodeId;
|
||||
}
|
||||
@@ -252,8 +254,9 @@ namespace Umbraco.Web
|
||||
|
||||
IPublishedContent doc;
|
||||
|
||||
// Check if the lookup contains the GUID/INT value
|
||||
if (_guidToIntLoopkup.TryGetValue(id, out int nodeId) == false)
|
||||
// Check if the lookup contains the GUID/INT value
|
||||
int nodeId;
|
||||
if (_guidToIntLoopkup.TryGetValue(id, out nodeId) == false)
|
||||
{
|
||||
// If not, then we perform an inefficient XPath for the GUID
|
||||
|
||||
@@ -460,4 +463,4 @@ namespace Umbraco.Web
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user