From 73f509a00beaed10ef288ece45b8ce0779009a25 Mon Sep 17 00:00:00 2001 From: Carlos Figueira Date: Mon, 5 Feb 2024 09:39:44 -0800 Subject: [PATCH] Don't create new DType instances for primitive FormulaType classes (#2188) Small perf improvement: we don't need to create new DType instances for primitive types. --- src/libraries/Microsoft.PowerFx.Core/Public/Types/BlankType.cs | 2 +- .../Microsoft.PowerFx.Core/Public/Types/BooleanType.cs | 2 +- .../Microsoft.PowerFx.Core/Public/Types/DecimalType.cs | 2 +- src/libraries/Microsoft.PowerFx.Core/Public/Types/NumberType.cs | 2 +- src/libraries/Microsoft.PowerFx.Core/Public/Types/StringType.cs | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/libraries/Microsoft.PowerFx.Core/Public/Types/BlankType.cs b/src/libraries/Microsoft.PowerFx.Core/Public/Types/BlankType.cs index 9bd5eb681..4667b2bd7 100644 --- a/src/libraries/Microsoft.PowerFx.Core/Public/Types/BlankType.cs +++ b/src/libraries/Microsoft.PowerFx.Core/Public/Types/BlankType.cs @@ -12,7 +12,7 @@ namespace Microsoft.PowerFx.Types public class BlankType : FormulaType { internal BlankType() - : base(new DType(DKind.ObjNull)) + : base(DType.ObjNull) { } diff --git a/src/libraries/Microsoft.PowerFx.Core/Public/Types/BooleanType.cs b/src/libraries/Microsoft.PowerFx.Core/Public/Types/BooleanType.cs index eaed3809b..31f64aa13 100644 --- a/src/libraries/Microsoft.PowerFx.Core/Public/Types/BooleanType.cs +++ b/src/libraries/Microsoft.PowerFx.Core/Public/Types/BooleanType.cs @@ -9,7 +9,7 @@ namespace Microsoft.PowerFx.Types public class BooleanType : FormulaType { internal BooleanType() - : base(new DType(DKind.Boolean)) + : base(DType.Boolean) { } diff --git a/src/libraries/Microsoft.PowerFx.Core/Public/Types/DecimalType.cs b/src/libraries/Microsoft.PowerFx.Core/Public/Types/DecimalType.cs index 1fc8808e0..dc3e9ea21 100644 --- a/src/libraries/Microsoft.PowerFx.Core/Public/Types/DecimalType.cs +++ b/src/libraries/Microsoft.PowerFx.Core/Public/Types/DecimalType.cs @@ -9,7 +9,7 @@ namespace Microsoft.PowerFx.Types public class DecimalType : FormulaType { internal DecimalType() - : base(new DType(DKind.Decimal)) + : base(DType.Decimal) { } diff --git a/src/libraries/Microsoft.PowerFx.Core/Public/Types/NumberType.cs b/src/libraries/Microsoft.PowerFx.Core/Public/Types/NumberType.cs index ff2c8819c..9f1f43570 100644 --- a/src/libraries/Microsoft.PowerFx.Core/Public/Types/NumberType.cs +++ b/src/libraries/Microsoft.PowerFx.Core/Public/Types/NumberType.cs @@ -9,7 +9,7 @@ namespace Microsoft.PowerFx.Types public class NumberType : FormulaType { internal NumberType() - : base(new DType(DKind.Number)) + : base(DType.Number) { } diff --git a/src/libraries/Microsoft.PowerFx.Core/Public/Types/StringType.cs b/src/libraries/Microsoft.PowerFx.Core/Public/Types/StringType.cs index 4bb2a39a8..66d38e070 100644 --- a/src/libraries/Microsoft.PowerFx.Core/Public/Types/StringType.cs +++ b/src/libraries/Microsoft.PowerFx.Core/Public/Types/StringType.cs @@ -10,7 +10,7 @@ namespace Microsoft.PowerFx.Types public class StringType : FormulaType { public StringType() - : base(new DType(DKind.String)) + : base(DType.String) { }