From 76daa2b1c9ff4c40b858812c030ceb7c185cceb5 Mon Sep 17 00:00:00 2001 From: konard Date: Thu, 11 Sep 2025 14:56:27 +0300 Subject: [PATCH 1/3] Initial commit with task details for issue #120 Adding CLAUDE.md with task information for AI processing. This file will be removed when the task is complete. Issue: https://github.com/linksplatform/Data/issues/120 --- CLAUDE.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 CLAUDE.md diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..05866cb --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,5 @@ +Issue to solve: https://github.com/linksplatform/Data/issues/120 +Your prepared branch: issue-120-931c65ea +Your prepared working directory: /tmp/gh-issue-solver-1757591781076 + +Proceed. \ No newline at end of file From 13a292dd093c8bbed52581f977f751fc267ce85a Mon Sep 17 00:00:00 2001 From: konard Date: Thu, 11 Sep 2025 14:56:45 +0300 Subject: [PATCH 2/3] Remove CLAUDE.md - PR created successfully --- CLAUDE.md | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 CLAUDE.md diff --git a/CLAUDE.md b/CLAUDE.md deleted file mode 100644 index 05866cb..0000000 --- a/CLAUDE.md +++ /dev/null @@ -1,5 +0,0 @@ -Issue to solve: https://github.com/linksplatform/Data/issues/120 -Your prepared branch: issue-120-931c65ea -Your prepared working directory: /tmp/gh-issue-solver-1757591781076 - -Proceed. \ No newline at end of file From 367246ca5358b8535b4db672e87c3ba410185b12 Mon Sep 17 00:00:00 2001 From: konard Date: Thu, 11 Sep 2025 15:08:27 +0300 Subject: [PATCH 3/3] Remove ExternalZero concept and use regular zero as external MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Removed ExternalZero constant from both C# and C++ Hybrid classes - Updated IsNothing, IsExternal, and AbsoluteValue properties to use default/zero - Modified constructors to assign default value instead of ExternalZero - Updated LinksConstants to use zero as minimum external reference range - Updated corresponding unit tests This change makes regular (internal) zero become external, improving bitwise operations safety and performance with raw number conversions. Fixes #120 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- cpp/Platform.Data.Tests/LinksConstantsTests.cpp | 2 +- cpp/Platform.Data/Hybrid.h | 9 ++++----- cpp/Platform.Data/LinksConstants.h | 2 +- .../Platform.Data.Tests/LinksConstantsTests.cs | 2 +- csharp/Platform.Data/Hybrid.cs | 17 +++++------------ csharp/Platform.Data/LinksConstants.cs | 2 +- 6 files changed, 13 insertions(+), 21 deletions(-) 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 {