ruby-changes:36612
From: nobu <ko1@a...>
Date: Wed, 3 Dec 2014 12:25:24 +0900 (JST)
Subject: [ruby-changes:36612] nobu:r48693 (trunk): intern.h: SIZED_ENUMERATOR
nobu 2014-12-03 12:25:12 +0900 (Wed, 03 Dec 2014) New Revision: 48693 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=48693 Log: intern.h: SIZED_ENUMERATOR * include/ruby/intern.h (SIZED_ENUMERATOR): separate from RETURN_SIZED_ENUMERATOR. * string.c (rb_str_enumerate_chars): get rid of calling rb_block_given_p() twice. Modified files: trunk/include/ruby/intern.h trunk/string.c Index: include/ruby/intern.h =================================================================== --- include/ruby/intern.h (revision 48692) +++ include/ruby/intern.h (revision 48693) @@ -234,10 +234,12 @@ VALUE rb_enumeratorize_with_size(VALUE, https://github.com/ruby/ruby/blob/trunk/include/ruby/intern.h#L234 #define rb_enumeratorize_with_size(obj, id, argc, argv, size_fn) \ rb_enumeratorize_with_size(obj, id, argc, argv, (rb_enumerator_size_func *)(size_fn)) #endif +#define SIZED_ENUMERATOR(obj, argc, argv, size_fn) \ + rb_enumeratorize_with_size((obj), ID2SYM(rb_frame_this_func()), \ + (argc), (argv), (size_fn)) #define RETURN_SIZED_ENUMERATOR(obj, argc, argv, size_fn) do { \ if (!rb_block_given_p()) \ - return rb_enumeratorize_with_size((obj), ID2SYM(rb_frame_this_func()),\ - (argc), (argv), (size_fn)); \ + return SIZED_ENUMERATOR(obj, argc, argv, size_fn); \ } while (0) #define RETURN_ENUMERATOR(obj, argc, argv) RETURN_SIZED_ENUMERATOR(obj, argc, argv, 0) /* error.c */ Index: string.c =================================================================== --- string.c (revision 48692) +++ string.c (revision 48693) @@ -6810,7 +6810,7 @@ rb_str_enumerate_chars(VALUE str, int wa https://github.com/ruby/ruby/blob/trunk/string.c#L6810 if (wantarray) ary = rb_ary_new_capa(str_strlen(str, enc)); /* str's enc*/ else - RETURN_SIZED_ENUMERATOR(str, 0, 0, rb_str_each_char_size); + return SIZED_ENUMERATOR(str, 0, 0, rb_str_each_char_size); } switch (ENC_CODERANGE(str)) { -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/