diff --git a/array.c b/array.c index e07e91bc3c..8e24da2ce6 100644 --- a/array.c +++ b/array.c @@ -2396,9 +2396,12 @@ sort_1(const void *ap, const void *bp, void *dummy) struct ary_sort_data *data = dummy; VALUE retval = sort_reentered(data->ary); VALUE a = *(const VALUE *)ap, b = *(const VALUE *)bp; + VALUE args[2]; int n; - retval = rb_yield_values(2, a, b); + args[0] = a; + args[1] = b; + retval = rb_yield_values2(2, args); n = rb_cmpint(retval, a, b); sort_reentered(data->ary); return n; diff --git a/benchmark/bm_array_sort_block.rb b/benchmark/bm_array_sort_block.rb new file mode 100644 index 0000000000..3579786056 --- /dev/null +++ b/benchmark/bm_array_sort_block.rb @@ -0,0 +1,2 @@ +ary = Array.new(1000) { rand(1000) } +10000.times { ary.sort { |a, b| a <=> b } }