aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext
diff options
context:
space:
mode:
authorJeremy Daer <jeremydaer@gmail.com>2016-04-26 11:41:16 -0500
committerJeremy Daer <jeremydaer@gmail.com>2016-04-26 11:41:16 -0500
commitf03c27cad2d3b4a9751cccdc3834f719f1cfbaa2 (patch)
treee0e640cfe385b0b1ca5803d801a58c7f0cabc3b1 /activesupport/lib/active_support/core_ext
parent8d4ffc81fb9e1bdd2b4aa310d95d005022834b29 (diff)
parentffb1df52c1f8a8e1805e310448eb66665804b5fc (diff)
downloadrails-f03c27cad2d3b4a9751cccdc3834f719f1cfbaa2.tar.gz
rails-f03c27cad2d3b4a9751cccdc3834f719f1cfbaa2.tar.bz2
rails-f03c27cad2d3b4a9751cccdc3834f719f1cfbaa2.zip
Merge pull request #24723 from lvl0nax/array_split_fix
Little perfomance fix for Array#split.
Diffstat (limited to 'activesupport/lib/active_support/core_ext')
-rw-r--r--activesupport/lib/active_support/core_ext/array/grouping.rb16
1 files changed, 6 insertions, 10 deletions
diff --git a/activesupport/lib/active_support/core_ext/array/grouping.rb b/activesupport/lib/active_support/core_ext/array/grouping.rb
index 87ae052eb0..34af83d1ab 100644
--- a/activesupport/lib/active_support/core_ext/array/grouping.rb
+++ b/activesupport/lib/active_support/core_ext/array/grouping.rb
@@ -100,17 +100,13 @@ class Array
results
end
else
- results, arr = [[]], self.dup
- until arr.empty?
- if (idx = arr.index(value))
- results.last.concat(arr.shift(idx))
- arr.shift
- results << []
- else
- results.last.concat(arr.shift(arr.size))
- end
+ arr = self.dup
+ result = []
+ while (idx = arr.index(value))
+ result << arr.shift(idx)
+ arr.shift
end
- results
+ result << arr
end
end
end