summaryrefslogtreecommitdiffhomepage
path: root/src/string.c
diff options
context:
space:
mode:
authorRyan Lopopolo <[email protected]>2019-07-08 19:23:24 -0700
committerRyan Lopopolo <[email protected]>2019-07-08 22:36:24 -0700
commit4085709ae1736fb755955d3d52b6b73c15853506 (patch)
treeaaf0f788d879f009a2ba681319b45d75b76b9e2d /src/string.c
parent469c6261c69999aab9e0d19cea6ac8e03f7847e3 (diff)
downloadmruby-4085709ae1736fb755955d3d52b6b73c15853506.tar.gz
mruby-4085709ae1736fb755955d3d52b6b73c15853506.zip
Specialize Enumerable#max and Enumerable#min for Range
This patch prevents a hang for pathalogical (large) Ranges when computing max and min. Range inherits its implementation of max and min from Enumerable. Enumerable implements max and min by calling each. For Range objects, this is unnecessary since we know the max and the min by the end and begin attributes. It is also very slow. This code hangs unnecessarily: (0..2**32).max # ... hang (0..2**32).min # ... hang This patch overrides max and min after including enumerable to yield based on the begin and end methods.
Diffstat (limited to 'src/string.c')
0 files changed, 0 insertions, 0 deletions