<feed xmlns='http://www.w3.org/2005/Atom'>
<title>ruby.git/range.c, branch v3_2_11</title>
<subtitle>The Ruby Programming Language</subtitle>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/'/>
<entry>
<title>merge revision(s) da4464b824857d7610f9865ceb452ce0ead49164: [Backport #19426]</title>
<updated>2025-03-13T05:27:06+00:00</updated>
<author>
<name>Hiroshi SHIBATA</name>
<email>hsbt@ruby-lang.org</email>
</author>
<published>2025-03-13T04:34:24+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=469a0a4a08dc4b3d3b6387b1f569108cc0750f17'/>
<id>469a0a4a08dc4b3d3b6387b1f569108cc0750f17</id>
<content type='text'>
	[Bug #19426] Fix endless `Range#step` with `#succ` method
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
	[Bug #19426] Fix endless `Range#step` with `#succ` method
</pre>
</div>
</content>
</entry>
<entry>
<title>merge revision(s) 25711683e86271385e8abe09a9c03782000e48db: [Backport #19864]</title>
<updated>2023-09-24T04:48:08+00:00</updated>
<author>
<name>nagachika</name>
<email>nagachika@ruby-lang.org</email>
</author>
<published>2023-09-24T04:48:08+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=217ef2bf89b3861e83c2e2a3a633c019f0731de6'/>
<id>217ef2bf89b3861e83c2e2a3a633c019f0731de6</id>
<content type='text'>
	Fix regression when testing inclusion in unbounded ranges

	Caused by 04a92a6764bf678919cf4b68a27496a39d6b886a.  This treats
	unbounded ranges of arbitrary objects the same as how unbounded
	string ranges are treated:

	  (..x)  === y  # (y &lt;=&gt; x) &lt;= 0
	  (...x) === y  # (y &lt;=&gt; x) &lt;  0
	  (x..)  === y  # (x &lt;=&gt; y) &lt;= 0

	Fixes [Bug #19864]
	---
	 range.c                 |  9 +++++++++
	 test/ruby/test_range.rb | 23 +++++++++++++++++++++++
	 2 files changed, 32 insertions(+)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
	Fix regression when testing inclusion in unbounded ranges

	Caused by 04a92a6764bf678919cf4b68a27496a39d6b886a.  This treats
	unbounded ranges of arbitrary objects the same as how unbounded
	string ranges are treated:

	  (..x)  === y  # (y &lt;=&gt; x) &lt;= 0
	  (...x) === y  # (y &lt;=&gt; x) &lt;  0
	  (x..)  === y  # (x &lt;=&gt; y) &lt;= 0

	Fixes [Bug #19864]
	---
	 range.c                 |  9 +++++++++
	 test/ruby/test_range.rb | 23 +++++++++++++++++++++++
	 2 files changed, 32 insertions(+)
</pre>
</div>
</content>
</entry>
<entry>
<title>merge revision(s) 1a149aab776aa6741628eb35482eff1ded197fd2,fb17c833f542222afdf482924877d43aa577782d,60f22ebf86248388b41b4ec751d16700f2b4b621: [Backport #19533]</title>
<updated>2023-07-17T07:07:39+00:00</updated>
<author>
<name>nagachika</name>
<email>nagachika@ruby-lang.org</email>
</author>
<published>2023-07-17T07:07:39+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=5328c58c7d00540f4f56749aaeefb68761bd7eba'/>
<id>5328c58c7d00540f4f56749aaeefb68761bd7eba</id>
<content type='text'>
	Extract range type check functions

	---
	 range.c | 55 ++++++++++++++++++++++++++++++++++++-------------------
	 1 file changed, 36 insertions(+), 19 deletions(-)

	[Bug #19533] Fix infinite range inclusion with numeric value

	---
	 range.c                 | 10 +++++++---
	 test/ruby/test_range.rb |  2 ++
	 2 files changed, 9 insertions(+), 3 deletions(-)

	[Bug #19533] Add spec of infinite range inclusion

	---
	 spec/ruby/core/range/case_compare_spec.rb | 6 ++++++
	 1 file changed, 6 insertions(+)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
	Extract range type check functions

	---
	 range.c | 55 ++++++++++++++++++++++++++++++++++++-------------------
	 1 file changed, 36 insertions(+), 19 deletions(-)

	[Bug #19533] Fix infinite range inclusion with numeric value

	---
	 range.c                 | 10 +++++++---
	 test/ruby/test_range.rb |  2 ++
	 2 files changed, 9 insertions(+), 3 deletions(-)

	[Bug #19533] Add spec of infinite range inclusion

	---
	 spec/ruby/core/range/case_compare_spec.rb | 6 ++++++
	 1 file changed, 6 insertions(+)
</pre>
</div>
</content>
</entry>
<entry>
<title>[DOC] Fix most of Range#cover? marked as verbatim</title>
<updated>2022-12-23T02:12:16+00:00</updated>
<author>
<name>Marco Costa</name>
<email>mmarcottulio@gmail.com</email>
</author>
<published>2022-12-23T02:12:16+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=d2847009dbe1df52b3984ab994b1d5c2dadbb86e'/>
<id>d2847009dbe1df52b3984ab994b1d5c2dadbb86e</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Introduce BOP_CMP for optimized comparison</title>
<updated>2022-12-06T20:37:23+00:00</updated>
<author>
<name>Daniel Colson</name>
<email>danieljamescolson@gmail.com</email>
</author>
<published>2022-11-23T02:16:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=e69b91fae4602b69c5ef45fcf82932adde8b31d8'/>
<id>e69b91fae4602b69c5ef45fcf82932adde8b31d8</id>
<content type='text'>
Prior to this commit the `OPTIMIZED_CMP` macro relied on a method lookup
to determine whether `&lt;=&gt;` was overridden. The result of the lookup was
cached, but only for the duration of the specific method that
initialized the cmp_opt_data cache structure.

With this method lookup, `[x,y].max` is slower than doing `x &gt; y ?
x : y` even though there's an optimized instruction for "new array max".
(John noticed somebody a proposed micro-optimization based on this fact
in https://github.com/mastodon/mastodon/pull/19903.)

```rb
a, b = 1, 2
Benchmark.ips do |bm|
  bm.report('conditional') { a &gt; b ? a : b }
  bm.report('method') { [a, b].max }
  bm.compare!
end
```

Before:

```
Comparison:
         conditional: 22603733.2 i/s
              method: 19820412.7 i/s - 1.14x  (± 0.00) slower
```

This commit replaces the method lookup with a new CMP basic op, which
gives the examples above equivalent performance.

After:

```
Comparison:
              method: 24022466.5 i/s
         conditional: 23851094.2 i/s - same-ish: difference falls within
error
```

Relevant benchmarks show an improvement to Array#max and Array#min when
not using the optimized newarray_max instruction as well. They are
noticeably faster for small arrays with the relevant types, and the same
or maybe a touch faster on larger arrays.

```
$ make benchmark COMPARE_RUBY=&lt;master@5958c305&gt; ITEM=array_min
$ make benchmark COMPARE_RUBY=&lt;master@5958c305&gt; ITEM=array_max
```

The benchmarks added in this commit also look generally improved.

Co-authored-by: John Hawthorn &lt;jhawthorn@github.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Prior to this commit the `OPTIMIZED_CMP` macro relied on a method lookup
to determine whether `&lt;=&gt;` was overridden. The result of the lookup was
cached, but only for the duration of the specific method that
initialized the cmp_opt_data cache structure.

With this method lookup, `[x,y].max` is slower than doing `x &gt; y ?
x : y` even though there's an optimized instruction for "new array max".
(John noticed somebody a proposed micro-optimization based on this fact
in https://github.com/mastodon/mastodon/pull/19903.)

```rb
a, b = 1, 2
Benchmark.ips do |bm|
  bm.report('conditional') { a &gt; b ? a : b }
  bm.report('method') { [a, b].max }
  bm.compare!
end
```

Before:

```
Comparison:
         conditional: 22603733.2 i/s
              method: 19820412.7 i/s - 1.14x  (± 0.00) slower
```

This commit replaces the method lookup with a new CMP basic op, which
gives the examples above equivalent performance.

After:

```
Comparison:
              method: 24022466.5 i/s
         conditional: 23851094.2 i/s - same-ish: difference falls within
error
```

Relevant benchmarks show an improvement to Array#max and Array#min when
not using the optimized newarray_max instruction as well. They are
noticeably faster for small arrays with the relevant types, and the same
or maybe a touch faster on larger arrays.

```
$ make benchmark COMPARE_RUBY=&lt;master@5958c305&gt; ITEM=array_min
$ make benchmark COMPARE_RUBY=&lt;master@5958c305&gt; ITEM=array_max
```

The benchmarks added in this commit also look generally improved.

Co-authored-by: John Hawthorn &lt;jhawthorn@github.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Raise TypeError for endless non-numeric range include?</title>
<updated>2022-11-24T23:18:44+00:00</updated>
<author>
<name>Jeremy Evans</name>
<email>code@jeremyevans.net</email>
</author>
<published>2022-08-19T20:19:03+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=04a92a6764bf678919cf4b68a27496a39d6b886a'/>
<id>04a92a6764bf678919cf4b68a27496a39d6b886a</id>
<content type='text'>
Beginless ranges previously raised TypeError for this case,
except for string ranges, which had unexpected behavior:

  ('a'..'z').include?('ww') # false
  (..'z').include?('ww') # previously true, now TypeError

Use of include? with endless ranges could previously result
in an infinite loop.

This splits off a range_string_cover_internal function from
range_include_internal.

Fixes [Bug #18580]
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Beginless ranges previously raised TypeError for this case,
except for string ranges, which had unexpected behavior:

  ('a'..'z').include?('ww') # false
  (..'z').include?('ww') # previously true, now TypeError

Use of include? with endless ranges could previously result
in an infinite loop.

This splits off a range_string_cover_internal function from
range_include_internal.

Fixes [Bug #18580]
</pre>
</div>
</content>
</entry>
<entry>
<title>Using UNDEF_P macro</title>
<updated>2022-11-16T09:58:33+00:00</updated>
<author>
<name>S-H-GAMELINKS</name>
<email>gamelinks007@gmail.com</email>
</author>
<published>2022-11-15T04:24:08+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=1f4f6c9832d83e7ebd65ccf4e95cef358b3512c6'/>
<id>1f4f6c9832d83e7ebd65ccf4e95cef358b3512c6</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Range#size returns nil for (.."a") and (nil..)</title>
<updated>2022-10-21T07:35:46+00:00</updated>
<author>
<name>Yusuke Endoh</name>
<email>mame@ruby-lang.org</email>
</author>
<published>2022-10-21T04:39:15+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=e026368061c56bc925aff58910a4b02f18b78c70'/>
<id>e026368061c56bc925aff58910a4b02f18b78c70</id>
<content type='text'>
Fixes [Bug #18983]
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Fixes [Bug #18983]
</pre>
</div>
</content>
</entry>
<entry>
<title>rb_int_range_last: properly handle non-exclusive range</title>
<updated>2022-09-04T09:16:11+00:00</updated>
<author>
<name>Jean Boussier</name>
<email>jean.boussier@gmail.com</email>
</author>
<published>2022-09-04T07:44:59+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=bbe5ec78463f8d6ef2e1a3571f17357a3d9ec8e4'/>
<id>bbe5ec78463f8d6ef2e1a3571f17357a3d9ec8e4</id>
<content type='text'>
[Bug #18994]
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
[Bug #18994]
</pre>
</div>
</content>
</entry>
<entry>
<title>Expand tabs [ci skip]</title>
<updated>2022-07-21T16:42:04+00:00</updated>
<author>
<name>Takashi Kokubun</name>
<email>takashikkbn@gmail.com</email>
</author>
<published>2022-07-21T16:23:58+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=5b21e94bebed90180d8ff63dad03b8b948361089'/>
<id>5b21e94bebed90180d8ff63dad03b8b948361089</id>
<content type='text'>
[Misc #18891]
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
[Misc #18891]
</pre>
</div>
</content>
</entry>
</feed>
