Age | Commit message (Collapse) | Author |
|
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65041 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64874 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64873 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
[Feature #14697] [ruby-core:86588]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64869 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
[ci-skip]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64697 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
* range.c (range_cover): add code for range argument.
If the argument is a Range, check it is or is not
covered by the reciver. If it can be treated as a
sequence, this method treats it that way.
* test/ruby/test_range.rb (class TestRange): add tests
for this feature.
This patch is written by Owen Stephens. thank you!
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64640 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64480 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
This commit introduces new core class Enumerator::ArithmeticSequence.
Enumerator::ArithmeticSequence is a subclass of Enumerator, and
represents a number generator of an arithmetic sequence.
After this commit, Numeric#step and Range#step without blocks
returned an ArithmeticSequence object instead of an Enumerator.
This class introduces the following incompatibilities:
- You can create a zero-step ArithmeticSequence,
and its size is not ArgumentError, but Infinity.
- You can create a negative-step ArithmeticSequence from a range.
[ruby-core:82816] [Feature #13904]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64205 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63907 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
Also, Range#min raises an error if it is endless and a comparison method
is specified.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63716 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
Fixes [Bug #14699]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63715 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
Fixes [Bug #14845]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63714 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
This reverts commit a44c010764a16ae09aaed49d76eec055ca0057c8.
Refs #14845.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63649 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
Now endless range can be created by either a literal `(1..)` or explicit
range creation `Range.new(1, nil)`. [Bug #14845]
This change is intended for "early failure"; for example,
`(1..var).to_a` causes out of memory if `var` is inadvertently nil.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63646 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
* range.c (range_eqq): switch `Range#===` to use `cover?` instead
of `include?`. [Feature #14575]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63453 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63299 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
* range.c (range_each): shortcirtuit endless symbol range too, as
well as `#step`.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63297 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
* range.c (range_each_func): adjust the signature of the callback
function to rb_str_upto_each, and exit the loop if the callback
returned non-zero.
* string.c (rb_str_upto_endless_each): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63290 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
* range.c (range_each): endless range begins with string-like
object should iterate from the converted result string, as well
as `#each` on a string-end range or `#step` method on an endless
range, i.e., `begin.succ` should not be called.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63283 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
* range.c (range_step): honor step in bignum addition.
[Feature #12912]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63208 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
* range.c (range_step): FIXABLE + FIXABLE never overflow, but may
not be FIXABLE. [Feature #12912]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63207 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
range.c: cast the function type to meet the declaration
This change is for fixing build error on AppVeyor:
https://ci.appveyor.com/project/ruby/ruby/build/1.0.8177
string.c
../string.c(4330) : error C4028: formal parameter 2 different from declaration
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63198 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
Just refactoring.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63196 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63194 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
Typical usages:
```
p ary[1..] # drop the first element; identical to ary[1..-1]
(1..).each {|n|...} # iterate forever from 1; identical to 1.step{...}
```
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63192 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
For checking whether an object is an Integer, because a subclass of
Integer is meaningless in Ruby, RB_INTEGER_TYPE_P is better than
rb_obj_is_kind_of for speed.
* object.c (rb_to_integer): Use RB_INTEGER_TYPE_P instead of rb_obj_is_kind_of.
* object.c (rb_check_to_integer): ditto.
* range.c (range_max): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62582 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
* range.c (rb_range_values): use rb_check_funcall instead of
calling rb_respond_to then rb_funcall, and allow `begin` and
`end` to be private as well as other internal conversions.
[ruby-core:83541] [Bug #14048]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60416 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
* range.c (rb_range_values): should raise TypeError if necessary
method is not defined, not NoMethodError, when trying to tell if
the object is a Range and extract info.
[ruby-core:83541] [Bug #14048]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60411 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
range.c (range_min): use OPTIMIZED_CMP() to compare the objects instead of
`<=>' method dispatching for Fixnum/Float/String object inside Range object.
range.c (range_max): ditto.
Range#min -> 34 % up
Range#max -> 44 % up
[ruby-core:80713] [Bug #13443] [Fix GH-1585]
### Before
Range#min 8.428M (± 1.3%) i/s - 42.141M in 5.000952s
Range#max 8.157M (± 1.3%) i/s - 40.852M in 5.009297s
### After
Range#min 11.269M (± 1.2%) i/s - 56.388M in 5.004611s
Range#max 11.764M (± 1.3%) i/s - 58.856M in 5.003820s
### Test code
require 'benchmark/ips'
Benchmark.ips do |x|
x.report "Range#min" do |i|
i.times { (1..100).min }
end
x.report "Range#max" do |i|
i.times { (1..100).max }
end
end
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58964 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58486 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
* range.c (range_init): no longer hide the user exception
with a ArgumentError, just let the user exception go through.
* test/ruby/test_range.rb (test_new): add tests.
[Feature #7688]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58476 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
* range.c (range_loader): check loading values if the data came
from an initialized range object. [ruby-core:78067] [Bug #12915]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
* range.c (range_modify): frozen object cannot be modified.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56693 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
* range.c (range_alloc): adjust indent of comments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56683 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
[fix GH-1433][ci skip] Patch by @BM5k
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56347 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56102 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
* range.c (check_step_domain): check step argument domain by <=>
method, instead of < and >.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55745 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
called in range_include() and thus r11113 doesn't work when the
receiver Range object consists of non linear objects such as Date
objects.
[ruby-core:72908] [Bug #12003]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53635 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
* range.c (range_to_s): should be infected by the receiver.
str2 infects by appending. [ruby-core:71811] [Bug #11767]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52868 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
* error.c (name_err_mesg_to_str): quote the name if unprintable.
* object.c (check_setter_id): use rb_check_id to convert names.
* variable.c (uninitialized_constant): use NameError::message to
keep the receiver of uninitialized constant. [Feature #10881]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52321 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
* range.c (range_eqq): trivial optimization to jump to
range_include directly if the method is not redefined.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51585 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
* range.c (range_include): call rb_str_include_range_p on String.
* string.c (str_upto_each): extract from rb_str_upto.
* string.c (rb_str_include_range_p): move String specific code
from Range#include? in range.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50502 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
* range.c (r_less): merge r_le() and r_lt() and make code shorter
with less branches.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50499 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
* range.c (r_cover_p): extract from range_cover and share with
range_include.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50498 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
* range.c (linear_object_p, range_include): test if covered for
linear objects. [ruby-core:69052] [Bug #11113]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50421 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
* range.c (id_cmp, id_succ): use predefined IDs in id.def.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50417 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
* range.c (range_step, range_each): String#upto should never
modifies the receiver, use frozen strings to enumerate symbols.
* re.c (reg_operand): matching target is not modified.
* ext/socket/constants.c (constant_arg): str_to_int never modifies
argument strings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50306 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
* use rb_funcallv() for no arguments call instead of variadic
rb_funcall().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49612 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
* range.c (range_bsearch): trivial optimizations, for Fixnum, and
by keeping the last satisfied element.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49230 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|