Skip to content

Commit

Permalink
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 3 additions & 0 deletions core/src/main/java/org/jruby/RubyEnumerable.java
Original file line number Diff line number Diff line change
@@ -1288,6 +1288,9 @@ public static IRubyObject min_by(ThreadContext context, IRubyObject self, final
@JRubyMethod
public static IRubyObject min_by(ThreadContext context, IRubyObject self, IRubyObject arg, final Block block) {
if (arg == context.nil) return singleExtentBy(context, self, "min", SORT_MIN, block);

if (!block.isGiven()) return enumeratorizeWithSize(context, self, "min_by", enumSizeFn(context, self));

// TODO: Replace with an implementation (quickselect, etc) which requires O(k) memory rather than O(n) memory
RubyArray sorted = (RubyArray)sort_by(context, self, block);
return sorted.first(arg);
1 change: 0 additions & 1 deletion spec/tags/ruby/core/enumerable/min_by_tags.txt

This file was deleted.

0 comments on commit ff996fb

Please sign in to comment.