summaryrefslogtreecommitdiff
path: root/array.c
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-03-17 12:03:48 (GMT)
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-03-17 12:03:48 (GMT)
commita22455199bf5b3ce68a6bded62a5c184373d1adb (patch)
tree9462b6f69746074cadc0c099d76d7d0c18cdeddb /array.c
parent85473c481e3d07cf9856b1c73d7c8df1f0062bd8 (diff)
* internal.c: struct cmp_opt_data added for refactoring out a data
structure for CMP_OPTIMIZABLE * array.c (struct ary_sort_data): use struct cmp_opt_data. * enum.c (struct min_t, max_t, min_max_t): use struct cmp_opt_data. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54149 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'array.c')
-rw-r--r--array.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/array.c b/array.c
index 86cf09e..120c2f8 100644
--- a/array.c
+++ b/array.c
@@ -2364,8 +2364,7 @@ rb_ary_rotate_m(int argc, VALUE *argv, VALUE ary)
struct ary_sort_data {
VALUE ary;
- int opt_methods;
- int opt_inited;
+ struct cmp_opt_data cmp_opt;
};
static VALUE
@@ -2399,12 +2398,12 @@ sort_2(const void *ap, const void *bp, void *dummy)
VALUE a = *(const VALUE *)ap, b = *(const VALUE *)bp;
int n;
- if (FIXNUM_P(a) && FIXNUM_P(b) && CMP_OPTIMIZABLE(data, Fixnum)) {
+ if (FIXNUM_P(a) && FIXNUM_P(b) && CMP_OPTIMIZABLE(data->cmp_opt, Fixnum)) {
if ((long)a > (long)b) return 1;
if ((long)a < (long)b) return -1;
return 0;
}
- if (STRING_P(a) && STRING_P(b) && CMP_OPTIMIZABLE(data, String)) {
+ if (STRING_P(a) && STRING_P(b) && CMP_OPTIMIZABLE(data->cmp_opt, String)) {
return rb_str_cmp(a, b);
}
@@ -2448,8 +2447,8 @@ rb_ary_sort_bang(VALUE ary)
RBASIC_CLEAR_CLASS(tmp);
data.ary = tmp;
- data.opt_methods = 0;
- data.opt_inited = 0;
+ data.cmp_opt.opt_methods = 0;
+ data.cmp_opt.opt_inited = 0;
RARRAY_PTR_USE(tmp, ptr, {
ruby_qsort(ptr, len, sizeof(VALUE),
rb_block_given_p()?sort_1:sort_2, &data);