Cache ModelMetadata HashCode
This commit is contained in:
parent
a80d7d744a
commit
69b4b64fd5
|
|
@ -23,6 +23,8 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly int DefaultOrder = 10000;
|
public static readonly int DefaultOrder = 10000;
|
||||||
|
|
||||||
|
private int? _hashCode;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new <see cref="ModelMetadata"/>.
|
/// Creates a new <see cref="ModelMetadata"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -405,7 +407,13 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override int GetHashCode()
|
public override int GetHashCode()
|
||||||
{
|
{
|
||||||
return Identity.GetHashCode();
|
// Normaly caching the hashcode would be dangerous, but Identity is deeply immutable so this is safe.
|
||||||
|
if (_hashCode == null)
|
||||||
|
{
|
||||||
|
_hashCode = Identity.GetHashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
return _hashCode.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitializeTypeInformation()
|
private void InitializeTypeInformation()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue