From 4dcc9926cbb37546b80a05f59c9af4104f59c2b8 Mon Sep 17 00:00:00 2001 From: Shargon Date: Fri, 18 Jan 2019 15:26:14 +0100 Subject: [PATCH] ToArray Optimization --- neo/UInt160.cs | 4 ++-- neo/UInt256.cs | 4 ++-- neo/UIntBase.cs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/neo/UInt160.cs b/neo/UInt160.cs index ad70573eb0b..39951ab3e2b 100644 --- a/neo/UInt160.cs +++ b/neo/UInt160.cs @@ -33,7 +33,7 @@ public UInt160(byte[] value) /// public unsafe int CompareTo(UInt160 other) { - fixed (byte* px = ToArray(), py = other.ToArray()) + fixed (byte* px = data_bytes, py = other.data_bytes) { uint* lpx = (uint*)px; uint* lpy = (uint*)py; @@ -54,7 +54,7 @@ public unsafe int CompareTo(UInt160 other) /// public unsafe bool Equals(UInt160 other) { - fixed (byte* px = ToArray(), py = other.ToArray()) + fixed (byte* px = data_bytes, py = other.data_bytes) { uint* lpx = (uint*)px; uint* lpy = (uint*)py; diff --git a/neo/UInt256.cs b/neo/UInt256.cs index 37045b9b94b..9633148e82f 100644 --- a/neo/UInt256.cs +++ b/neo/UInt256.cs @@ -34,7 +34,7 @@ public UInt256(byte[] value) /// public unsafe int CompareTo(UInt256 other) { - fixed (byte* px = ToArray(), py = other.ToArray()) + fixed (byte* px = data_bytes, py = other.data_bytes) { ulong* lpx = (ulong*)px; ulong* lpy = (ulong*)py; @@ -55,7 +55,7 @@ public unsafe int CompareTo(UInt256 other) /// public unsafe bool Equals(UInt256 other) { - fixed (byte* px = ToArray(), py = other.ToArray()) + fixed (byte* px = data_bytes, py = other.data_bytes) { ulong* lpx = (ulong*)px; ulong* lpy = (ulong*)py; diff --git a/neo/UIntBase.cs b/neo/UIntBase.cs index 4ab43c83f9a..5ddf8b87be1 100644 --- a/neo/UIntBase.cs +++ b/neo/UIntBase.cs @@ -15,7 +15,7 @@ public abstract class UIntBase : IEquatable, ISerializable /// /// Storing unsigned int in a little-endian byte array. /// - private byte[] data_bytes; + protected readonly byte[] data_bytes; /// /// Number of bytes of the unsigned int.