From e918686911df9fd8600dee6ee142dee4d86d4ab4 Mon Sep 17 00:00:00 2001 From: Mike Marynowski Date: Thu, 7 Mar 2024 22:19:02 -0500 Subject: [PATCH] Add missing mutable ctors + optimizations --- .../MoneySet.cs | 22 +++++++++------ .../SortedMoneySet.cs | 28 ++++++++++--------- 2 files changed, 29 insertions(+), 21 deletions(-) diff --git a/Source/Singulink.Globalization.Currency/MoneySet.cs b/Source/Singulink.Globalization.Currency/MoneySet.cs index 22dd5e4..d2fec59 100644 --- a/Source/Singulink.Globalization.Currency/MoneySet.cs +++ b/Source/Singulink.Globalization.Currency/MoneySet.cs @@ -36,6 +36,19 @@ public MoneySet(CurrencyRegistry registry) _registry = registry; } + /// + public MoneySet(IEnumerable values) : this(CurrencyRegistry.Default, values) { } + + /// + public MoneySet(CurrencyRegistry registry, IEnumerable values) + : this(registry, values, values is not IReadOnlyMoneySet s || s.Registry != registry) { } + + /// + public MoneySet(params Money[] values) : this(CurrencyRegistry.Default, values) { } + + /// + public MoneySet(CurrencyRegistry registry, params Money[] values) : this(registry, values.AsSpan()) { } + /// /// Initializes a new instance of the class with the currency registry and adds all /// the specified values. @@ -43,7 +56,7 @@ public MoneySet(CurrencyRegistry registry) /// /// Attempted to add a value with a currency that is not available in the currency registry. /// - public MoneySet(IEnumerable values) : this(CurrencyRegistry.Default, values) { } + public MoneySet(ReadOnlySpan values) : this(CurrencyRegistry.Default, values) { } /// /// Initializes a new instance of the class with the specified currency registry and adds all the specified values. @@ -51,13 +64,6 @@ public MoneySet(IEnumerable values) : this(CurrencyRegistry.Default, valu /// /// Attempted to add a value with a currency that is not available in the currency registry. /// - public MoneySet(CurrencyRegistry registry, IEnumerable values) - : this(registry, values, values is not IReadOnlyMoneySet s || s.Registry != registry) { } - - /// - public MoneySet(ReadOnlySpan values) : this(CurrencyRegistry.Default, values) { } - - /// public MoneySet(CurrencyRegistry registry, ReadOnlySpan values) { _registry = registry; diff --git a/Source/Singulink.Globalization.Currency/SortedMoneySet.cs b/Source/Singulink.Globalization.Currency/SortedMoneySet.cs index 3cc33f5..8bbac45 100644 --- a/Source/Singulink.Globalization.Currency/SortedMoneySet.cs +++ b/Source/Singulink.Globalization.Currency/SortedMoneySet.cs @@ -23,9 +23,7 @@ public sealed partial class SortedMoneySet : IMoneySet /// /// Initializes a new instance of the class with the currency registry. /// - public SortedMoneySet() : this(CurrencyRegistry.Default) - { - } + public SortedMoneySet() : this(CurrencyRegistry.Default) { } /// /// Initializes a new instance of the class with the specified currency registry. @@ -38,6 +36,19 @@ public SortedMoneySet(CurrencyRegistry registry) _registry = registry; } + /// + public SortedMoneySet(IEnumerable values) : this(CurrencyRegistry.Default, values) { } + + /// + public SortedMoneySet(CurrencyRegistry registry, IEnumerable values) + : this(registry, values, values is not IReadOnlyMoneySet s || s.Registry != registry) { } + + /// + public SortedMoneySet(params Money[] values) : this(CurrencyRegistry.Default, values) { } + + /// + public SortedMoneySet(CurrencyRegistry registry, params Money[] values) : this(registry, values.AsSpan()) { } + /// /// Initializes a new instance of the class with the currency registry and adds all /// the specified values. @@ -45,9 +56,7 @@ public SortedMoneySet(CurrencyRegistry registry) /// /// Attempted to add a value with a currency that is not available in the currency registry. /// - public SortedMoneySet(IEnumerable values) : this(CurrencyRegistry.Default, values) - { - } + public SortedMoneySet(ReadOnlySpan values) : this(CurrencyRegistry.Default, values) { } /// /// Initializes a new instance of the class with the specified currency registry and adds all the specified values. @@ -55,13 +64,6 @@ public SortedMoneySet(IEnumerable values) : this(CurrencyRegistry.Default /// /// Attempted to add a value with a currency that is not available in the currency registry. /// - public SortedMoneySet(CurrencyRegistry registry, IEnumerable values) - : this(registry, values, values is not IReadOnlyMoneySet s || s.Registry != registry) { } - - /// - public SortedMoneySet(ReadOnlySpan values) : this(CurrencyRegistry.Default, values) { } - - /// public SortedMoneySet(CurrencyRegistry registry, ReadOnlySpan values) { _registry = registry;