diff options
author | Jan Szumiec <jan.szumiec@gmail.com> | 2013-07-25 19:29:40 +0100 |
---|---|---|
committer | Jan Szumiec <jan.szumiec@gmail.com> | 2013-08-03 23:56:38 +0100 |
commit | 512603ee32910bc55b8094a40f6b2bf756f226f3 (patch) | |
tree | 41e6ec3c95379de0cff00b7fb87c404e4bf7f24d /actionview/lib/action_view | |
parent | c0635de4296f8b6f6cfa53e97282f73c6ae71b59 (diff) | |
download | rails-512603ee32910bc55b8094a40f6b2bf756f226f3.tar.gz rails-512603ee32910bc55b8094a40f6b2bf756f226f3.tar.bz2 rails-512603ee32910bc55b8094a40f6b2bf756f226f3.zip |
Removed an unnecessary loop - it kills performance on large texts.
Diffstat (limited to 'actionview/lib/action_view')
-rw-r--r-- | actionview/lib/action_view/helpers/text_helper.rb | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/actionview/lib/action_view/helpers/text_helper.rb b/actionview/lib/action_view/helpers/text_helper.rb index e3d4eb1d74..3fc64fa8a5 100644 --- a/actionview/lib/action_view/helpers/text_helper.rb +++ b/actionview/lib/action_view/helpers/text_helper.rb @@ -157,10 +157,12 @@ module ActionView 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 |