ruby-changes:36061
From: duerst <ko1@a...>
Date: Sun, 26 Oct 2014 11:24:38 +0900 (JST)
Subject: [ruby-changes:36061] duerst:r48142 (trunk): string.c: improved comment.
duerst 2014-10-26 11:24:28 +0900 (Sun, 26 Oct 2014) New Revision: 48142 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=48142 Log: string.c: improved comment. Modified files: trunk/ChangeLog trunk/string.c Index: ChangeLog =================================================================== --- ChangeLog (revision 48141) +++ ChangeLog (revision 48142) @@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Sun Oct 25 11:24:24 2014 Martin Duerst <duerst@i...> + + * string.c: improved comment. + Sun Oct 26 07:40:11 2014 Masaki Suketa <masaki.suketa@n...> * ext/win32ole/win32ole.c (ole_val2variant, ole_invoke): refactoring. @@ -12,6 +16,7 @@ Sat Oct 25 22:28:17 2014 Tanaka Akira https://github.com/ruby/ruby/blob/trunk/ChangeLog#L16 * io.c (io_binwrite_string): Test writev() failure. +>>>>>>> .r48141 Sat Oct 25 20:19:19 2014 Martin Duerst <duerst@i...> * test/test-unicode_normalize.rb: added test_us_ascii. Index: string.c =================================================================== --- string.c (revision 48141) +++ string.c (revision 48142) @@ -1187,26 +1187,27 @@ rb_str_init(int argc, VALUE *argv, VALUE https://github.com/ruby/ruby/blob/trunk/string.c#L1187 /* * UTF-8 leading bytes have either 0xxxxxxx or 11xxxxxx * bit representation. (see http://en.wikipedia.org/wiki/UTF-8) - * Therefore, following pseudo code can detect UTF-8 leading byte. + * Therefore, the following pseudocode can detect UTF-8 leading bytes. * * if (!(byte & 0x80)) * byte |= 0x40; // turn on bit6 - * return ((byte>>6) & 1); // bit6 represent it's leading byte or not. + * return ((byte>>6) & 1); // bit6 represent whether this byte is leading or not. * - * This function calculate every bytes in the argument word `s' - * using the above logic concurrently. and gather every bytes result. + * This function calculates whether a byte is leading or not for all bytes + * in the argument word by concurrently using the above logic, and then + * adds up the number of leading bytes in the word. */ static inline uintptr_t count_utf8_lead_bytes_with_word(const uintptr_t *s) { uintptr_t d = *s; - /* Transform into bit0 represent UTF-8 leading or not. */ + /* Transform so that bit0 indicates whether we have a UTF-8 leading byte or not. */ d |= ~(d>>1); d >>= 6; d &= NONASCII_MASK >> 7; - /* Gather every bytes. */ + /* Gather all bytes. */ d += (d>>8); d += (d>>16); #if SIZEOF_VOIDP == 8 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/