mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48693 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
c95b3a16bd
commit
aaed10716a
2 changed files with 5 additions and 3 deletions
|
@ -234,10 +234,12 @@ VALUE rb_enumeratorize_with_size(VALUE, VALUE, int, const VALUE *, rb_enumerator
|
|||
#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 */
|
||||
|
|
2
string.c
2
string.c
|
@ -6810,7 +6810,7 @@ rb_str_enumerate_chars(VALUE str, int wantarray)
|
|||
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)) {
|
||||
|
|
Loading…
Reference in a new issue