ruby-changes:42785
From: naruse <ko1@a...>
Date: Sun, 1 May 2016 06:35:30 +0900 (JST)
Subject: [ruby-changes:42785] naruse:r54859 (trunk): * string.c (search_nonascii): use nlz on big endian environments.
naruse 2016-05-01 07:32:05 +0900 (Sun, 01 May 2016) New Revision: 54859 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=54859 Log: * string.c (search_nonascii): use nlz on big endian environments. * internal.h (nlz_intpr): defined. Modified files: trunk/ChangeLog trunk/internal.h trunk/string.c Index: internal.h =================================================================== --- internal.h (revision 54858) +++ internal.h (revision 54859) @@ -261,6 +261,15 @@ nlz_int128(uint128_t x) https://github.com/ruby/ruby/blob/trunk/internal.h#L261 #endif static inline int +nlz_intptr(uintptr_t x) { +#if SIZEOF_VOIDP == 8 + return nlz_long_long(x); +#elif SIZEOF_VOIDP == 4 + return nlz_int(x); +#endif +} + +static inline int rb_popcount32(uint32_t x) { x = (x & 0x55555555) + (x >> 1 & 0x55555555); x = (x & 0x33333333) + (x >> 2 & 0x33333333); Index: string.c =================================================================== --- string.c (revision 54858) +++ string.c (revision 54859) @@ -449,7 +449,11 @@ search_nonascii(const char *p, const cha https://github.com/ruby/ruby/blob/trunk/string.c#L449 const uintptr_t *t = (const uintptr_t *)(e - (SIZEOF_VOIDP-1)); for (;s < t; s++) { if (*s & NONASCII_MASK) { +#if BYTE_ORDER == LITTLE_ENDIAN return (const char *)s + (ntz_intptr(*s&NONASCII_MASK)>>3); +#else + return (const char *)s + (nlz_intptr(*s&NONASCII_MASK)>>3); +#endif } } p = (const char *)s; Index: ChangeLog =================================================================== --- ChangeLog (revision 54858) +++ ChangeLog (revision 54859) @@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Sun May 1 07:30:44 2016 NARUSE, Yui <naruse@r...> + + * string.c (search_nonascii): use nlz on big endian environments. + + * internal.h (nlz_intpr): defined. + Sun May 1 00:03:30 2016 NARUSE, Yui <naruse@r...> * configure.in (__builtin_ctz): check. -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/