diff options
author | normal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-06-25 23:06:48 +0000 |
---|---|---|
committer | normal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-06-25 23:06:48 +0000 |
commit | 7b58113bbd23d23009d209a672ec4892facecfd1 (patch) | |
tree | 585cbb72c39af6cf202074b53a9c43b04531a19d /enum.c | |
parent | dfc1a3b26f36ad23903e6bf7db5b9a214acad882 (diff) | |
download | ruby-7b58113bbd23d23009d209a672ec4892facecfd1.tar.gz |
enum.c (enum_minmax): simplify return value creation
No need to call three functions on success when one will do.
This results in less LoC and smaller object code, too:
text data bss dec hex filename
33860 0 296 34156 856c gcc/enum.o-before
33852 0 296 34148 8564 gcc/enum.o
* enum.c (enum_minmax): simplify return value creation
* test/ruby/test_enum.rb: test behavior on empty
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51036 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'enum.c')
-rw-r--r-- | enum.c | 6 |
1 files changed, 2 insertions, 4 deletions
@@ -1715,7 +1715,6 @@ enum_minmax(VALUE obj) { struct MEMO *memo = MEMO_NEW(Qundef, Qundef, Qundef); struct minmax_t *m = (struct minmax_t *)&memo->v1; - VALUE ary = rb_ary_new3(2, Qnil, Qnil); m->min = Qundef; m->last = Qundef; @@ -1730,10 +1729,9 @@ enum_minmax(VALUE obj) minmax_i_update(m->last, m->last, m); } if (m->min != Qundef) { - rb_ary_store(ary, 0, m->min); - rb_ary_store(ary, 1, m->max); + return rb_assoc_new(m->min, m->max); } - return ary; + return rb_assoc_new(Qnil, Qnil); } static VALUE |