Project

General

Profile

Actions

Bug #15807

closed

Range#minmax is slow and never returns for endless ranges

Added by janosch-x (Janosch Müller) over 5 years ago. Updated over 5 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:92459]

Description

current situation:

  • (1..).minmax runs forever
  • (1..).max raises "cannot get the maximum of endless range"
  • (1..Float::INFINITY).minmax runs forever
  • (1..Float::INFINITY).max returns instantly
  • (1..1_000_000_000).minmax takes one minute
  • (1..1_000_000_000).max returns instantly

my suggestion:

  • implement minmax in range.c, return [range_min, range_max]
  • for endless ranges, this will trigger the same error as max does
  • delegate to enum (rb_call_super) only if called with a block (?)

i could perhaps provide a PR if you can point me to some information on how to contribute.

cheers!


Files

range-minmax.patch (2.89 KB) range-minmax.patch jeremyevans0 (Jeremy Evans), 06/08/2019 05:16 AM

Related issues 1 (0 open1 closed)

Related to Ruby master - Bug #15867: Enumerable#minmax inconsistent behavior with Time rangesClosedActions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0