@@ -369,19 +369,20 @@ internal string RawString()
369369 return false ;
370370 }
371371
372- if ( xType == StorageType . Sequence &&
373- ( yType == StorageType . ByteArray || yType == StorageType . MemoryManager ) )
374- return x . RawSequence ( ) . SequenceEqual ( y . RawSpan ( ) ) ;
375-
376- if ( yType == StorageType . Sequence &&
377- ( xType == StorageType . ByteArray || xType == StorageType . MemoryManager ) )
378- return y . RawSequence ( ) . SequenceEqual ( x . RawSpan ( ) ) ;
379-
380- if ( ( xType == StorageType . ByteArray && yType == StorageType . MemoryManager ) ||
381- ( xType == StorageType . MemoryManager && yType == StorageType . ByteArray ) )
382- return x . RawSpan ( ) . SequenceEqual ( y . RawSpan ( ) ) ;
372+ // both are non-null, non-numeric, and of different kinds; the blob kinds (byte[] / memory /
373+ // sequence) compare by bytes in any combination - and we keep the span-vs-span path for the
374+ // case where neither side is a multi-segment sequence
375+ switch ( xType )
376+ {
377+ case StorageType . Sequence when yType is StorageType . ByteArray or StorageType . MemoryManager :
378+ return x . RawSequence ( ) . SequenceEqual ( y . RawSpan ( ) ) ;
379+ case StorageType . ByteArray or StorageType . MemoryManager when yType == StorageType . Sequence :
380+ return y . RawSequence ( ) . SequenceEqual ( x . RawSpan ( ) ) ;
381+ case StorageType . ByteArray or StorageType . MemoryManager when yType is StorageType . ByteArray or StorageType . MemoryManager :
382+ return x . RawSpan ( ) . SequenceEqual ( y . RawSpan ( ) ) ;
383+ }
383384
384- // otherwise, compare as strings
385+ // otherwise (anything involving a string) , compare as strings
385386 return ( string ? ) x == ( string ? ) y ;
386387 }
387388
@@ -870,6 +871,7 @@ public static explicit operator double(RedisValue value)
870871 // special values like NaN/Inf are deliberately not handled by Simplify, but need to be considered for casting
871872 StorageType . String when Format . TryParseDouble ( value . RawString ( ) , out var d ) => d ,
872873 StorageType . MemoryManager or StorageType . ByteArray when TryParseDouble ( value . RawSpan ( ) , out var d ) => d ,
874+ StorageType . Sequence when value . TryParse ( out double d ) => d , // linearizes + handles inf/nan, like the span case above
873875 // anything else: fail
874876 _ => throw new InvalidCastException ( $ "Unable to cast from { value . Type } to double: '{ value } '") ,
875877 } ;
0 commit comments