Define RubyRange.min/max
------------------------

                 Key: JRUBY-3134
                 URL: http://jira.codehaus.org/browse/JRUBY-3134
             Project: JRuby
          Issue Type: Improvement
          Components: Core Classes/Modules
    Affects Versions: JRuby 1.1.5
            Reporter: Bernerd Schaefer
         Attachments: ruby_range_min_max.diff

Range gets its min/max methods by including Enumerable, which iterates through 
all the members using the spaceship operator.

This is unnecessary for a range, whose min and max values are by definition the 
first and last values. The attached patch defines min/max on Range, calling 
Enumberable.min/max if it is passed a block, and returning first/last if no 
block is passed.

This also fixes an issue (1.8.*, JRuby) where (0..Infinity).max would hang 
forever trying to calculate all of the possible values between 0 and Infinity.

Please let me know if the patch can be enhanced -- this is my first JRuby patch!

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to