Esempio n. 1
0
            private static bool Equals(BulkString a, BulkString b)
            {
                if (a.IsNull && b.IsNull)
                {
                    return(true);
                }

                if (a.IsNull || b.IsNull)
                {
                    return(false);
                }

                if (a.Length != b.Length)
                {
                    return(false);
                }

                var aBytes = a.ToBytes();
                var bBytes = b.ToBytes();

                for (var i = 0; i < aBytes.Length; i++)
                {
                    if (aBytes[i] != bBytes[i])
                    {
                        return(false);
                    }
                }

                return(true);
            }
Esempio n. 2
0
        public override int Visit(BulkString bulkString)
        {
            if (bulkString.IsNull)
            {
                return(-1);
            }

            var bytes = bulkString.ToBytes();

            if (bytes.Length == 0)
            {
                return(-2);
            }

            var hash = (int)bytes[0];

            for (var i = 1; i < bytes.Length; i++)
            {
                hash = (hash * 31) ^ bytes[i];
            }

            return(hash);
        }
Esempio n. 3
0
 public override string Visit(BulkString bulkString) => indentation + "$" + Encoding.UTF8.GetString(
     bulkString.ToBytes()
     );