diff --git a/cpp/Platform.Data.Tests/LinksConstantsTests.cpp b/cpp/Platform.Data.Tests/LinksConstantsTests.cpp index d2c0fb6..de3d2d0 100644 --- a/cpp/Platform.Data.Tests/LinksConstantsTests.cpp +++ b/cpp/Platform.Data.Tests/LinksConstantsTests.cpp @@ -5,7 +5,7 @@ using namespace Platform::Data; auto constants = LinksConstants(true); - ASSERT_EQ(Hybrid::ExternalZero, constants.ExternalReferencesRange.Minimum); + ASSERT_EQ(std::uint64_t{0}, constants.ExternalReferencesRange.Minimum); ASSERT_EQ(std::numeric_limits::max(), constants.ExternalReferencesRange.Maximum); } diff --git a/cpp/Platform.Data/Hybrid.h b/cpp/Platform.Data/Hybrid.h index 0c3fa9d..3f12dba 100644 --- a/cpp/Platform.Data/Hybrid.h +++ b/cpp/Platform.Data/Hybrid.h @@ -13,13 +13,12 @@ class Hybrid { public: static constexpr TLinkAddress HalfOfNumberValuesRange = std::numeric_limits::max() / 2; - public: static constexpr TLinkAddress ExternalZero = static_cast(HalfOfNumberValuesRange + 1); public: const TLinkAddress Value = 0; public: [[nodiscard]] bool IsNothing() const noexcept { - return (Value == ExternalZero) || (SignedValue() == 0); + return Value == 0; } public: [[nodiscard]] bool IsInternal() const noexcept @@ -29,7 +28,7 @@ public: [[nodiscard]] bool IsExternal() const noexcept { - return (Value == ExternalZero) || (SignedValue() < 0); + return (Value == 0) || (SignedValue() < 0); } public: [[nodiscard]] auto SignedValue() const noexcept -> decltype(Internal::smart_to_signed(Value)) @@ -39,7 +38,7 @@ public: [[nodiscard]] TLinkAddress AbsoluteValue() const noexcept { - return (Value == ExternalZero) ? 0 : std::abs(SignedValue()); + return (Value == 0) ? 0 : std::abs(SignedValue()); } public: explicit Hybrid(TLinkAddress value) noexcept : Value(value) { } @@ -58,7 +57,7 @@ { if (value == 0 && isExternal) { - return ExternalZero; + return 0; } else { diff --git a/cpp/Platform.Data/LinksConstants.h b/cpp/Platform.Data/LinksConstants.h index e55b4ed..5f3aee7 100644 --- a/cpp/Platform.Data/LinksConstants.h +++ b/cpp/Platform.Data/LinksConstants.h @@ -116,7 +116,7 @@ { if (enableExternalReferencesSupport) { - return Ranges::Range{Hybrid::ExternalZero, std::numeric_limits::max()}; + return Ranges::Range{TLinkAddress{0}, std::numeric_limits::max()}; } else { diff --git a/csharp/Platform.Data.Tests/LinksConstantsTests.cs b/csharp/Platform.Data.Tests/LinksConstantsTests.cs index 8cad565..7be3456 100644 --- a/csharp/Platform.Data.Tests/LinksConstantsTests.cs +++ b/csharp/Platform.Data.Tests/LinksConstantsTests.cs @@ -24,7 +24,7 @@ public static class LinksConstantsTests public static void ConstructorTest() { var constants = new LinksConstants(enableExternalReferencesSupport: true); - Assert.Equal(Hybrid.ExternalZero, constants.ExternalReferencesRange.Value.Minimum); + Assert.Equal((ulong)0, constants.ExternalReferencesRange.Value.Minimum); Assert.Equal(ulong.MaxValue, constants.ExternalReferencesRange.Value.Maximum); } diff --git a/csharp/Platform.Data/Hybrid.cs b/csharp/Platform.Data/Hybrid.cs index 93ce0a1..b8c877e 100644 --- a/csharp/Platform.Data/Hybrid.cs +++ b/csharp/Platform.Data/Hybrid.cs @@ -30,13 +30,6 @@ public struct Hybrid : IEquatable> where TLin /// /// public static readonly TLinkAddress HalfOfNumberValuesRange = (NumericType.MaxValue) / TLinkAddress.CreateTruncating(2); - /// - /// - /// The half of number values range. - /// - /// - /// - public static readonly TLinkAddress ExternalZero = (HalfOfNumberValuesRange + TLinkAddress.CreateTruncating(1)); /// /// @@ -55,7 +48,7 @@ public struct Hybrid : IEquatable> where TLin public bool IsNothing { [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => (Value == ExternalZero) || SignedValue == 0; + get => Value == default; } /// @@ -79,7 +72,7 @@ public bool IsInternal public bool IsExternal { [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => (Value == ExternalZero) || SignedValue < 0; + get => (Value == default) || SignedValue < 0; } /// @@ -103,7 +96,7 @@ public long SignedValue public long AbsoluteValue { [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => (Value == ExternalZero) ? 0 : System.Math.Abs(SignedValue); + get => (Value == default) ? 0 : System.Math.Abs(SignedValue); } /// @@ -142,7 +135,7 @@ public Hybrid(TLinkAddress value, bool isExternal) { if ((value == default) && isExternal) { - Value = ExternalZero; + Value = default; } else { @@ -190,7 +183,7 @@ public Hybrid(object value, bool isExternal) var signedValue = value == null ? 0 : _objectToInt64Converter.Convert(value); if (signedValue == 0 && isExternal) { - Value = ExternalZero; + Value = default; } else { diff --git a/csharp/Platform.Data/LinksConstants.cs b/csharp/Platform.Data/LinksConstants.cs index f2df4f9..47e7b56 100644 --- a/csharp/Platform.Data/LinksConstants.cs +++ b/csharp/Platform.Data/LinksConstants.cs @@ -287,7 +287,7 @@ public static Range GetDefaultInternalReferencesRange(bool enableE { if (enableExternalReferencesSupport) { - return (Hybrid.ExternalZero, NumericType.MaxValue); + return (TLinkAddress.CreateTruncating(0), NumericType.MaxValue); } else {