@@ -78,18 +78,9 @@ static void rvalue_cache_insert_at(rvalue_cache *cache, int index, VALUE rstring
7878 cache -> entries [index ] = rstring ;
7979}
8080
81- static ALWAYS_INLINE () int rstring_cache_cmp (const char * str , const long length , VALUE rstring )
82- {
8381#if defined(__BYTE_ORDER__ ) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ ) && defined(__has_builtin ) && __has_builtin (__builtin_bswap64 )
84- const char * rptr ;
85- long rstring_length ;
86-
87- RSTRING_GETMEM (rstring , rptr , rstring_length );
88-
89- if (length != rstring_length ) {
90- return (int )(length - rstring_length );
91- }
92-
82+ static ALWAYS_INLINE () int rstring_memcmp (const char * str , const char * rptr , const long length )
83+ {
9384 long i = 0 ;
9485
9586 for (; i + 8 <= length ; i += 8 ) {
@@ -112,14 +103,23 @@ static ALWAYS_INLINE() int rstring_cache_cmp(const char *str, const long length,
112103 }
113104
114105 return 0 ;
106+ }
115107#else
116- long rstring_length = RSTRING_LEN (rstring );
117- if (length == rstring_length ) {
118- return memcmp (str , RSTRING_PTR (rstring ), length );
119- } else {
108+ #define rstring_memcmp memcmp
109+ #endif
110+
111+ static ALWAYS_INLINE () int rstring_cache_cmp (const char * str , const long length , VALUE rstring )
112+ {
113+ const char * rptr ;
114+ long rstring_length ;
115+
116+ RSTRING_GETMEM (rstring , rptr , rstring_length );
117+
118+ if (length != rstring_length ) {
120119 return (int )(length - rstring_length );
121120 }
122- #endif
121+
122+ return rstring_memcmp (str , rptr , length );
123123}
124124
125125static ALWAYS_INLINE () VALUE rstring_cache_fetch (rvalue_cache * cache , const char * str , const long length )
0 commit comments