Permalink
Browse files

Removed an unnecessary loop - it kills performance on large texts.

  • Loading branch information...
1 parent c0635de commit 512603ee32910bc55b8094a40f6b2bf756f226f3 @jasiek jasiek committed Jul 25, 2013
Showing with 6 additions and 4 deletions.
  1. +6 −4 actionview/lib/action_view/helpers/text_helper.rb
@@ -157,10 +157,12 @@ def excerpt(text, phrase, options = {})
return unless matches = text.match(regex)
phrase = matches[0]
- text.split(separator).each do |value|
- if value.match(regex)
- regex = phrase = value
- break
+ unless separator.empty?
+ text.split(separator).each do |value|
+ if value.match(regex)
+ regex = phrase = value
+ break
+ end
end
end

0 comments on commit 512603e

Please sign in to comment.