diff options
author | Xavier Noria <fxn@hashref.com> | 2015-09-12 10:45:18 +0200 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2015-09-12 10:45:18 +0200 |
commit | 59ec70dcbeb2fb6d1d5ef63bd807ec0e915f7b3a (patch) | |
tree | 8b178443d95c4debb48c3ebb49ba1eef40227eb1 /activesupport/lib/active_support/core_ext/string/strip.rb | |
parent | bbf0d35bf6148752911c1da4b7449450faea8755 (diff) | |
parent | 503d334599a315e956928bb82febf1e226fb6100 (diff) | |
download | rails-59ec70dcbeb2fb6d1d5ef63bd807ec0e915f7b3a.tar.gz rails-59ec70dcbeb2fb6d1d5ef63bd807ec0e915f7b3a.tar.bz2 rails-59ec70dcbeb2fb6d1d5ef63bd807ec0e915f7b3a.zip |
Merge pull request #21596 from JuanitoFatas/perf/strip-heredoc
Improve String#strip_heredoc
Diffstat (limited to 'activesupport/lib/active_support/core_ext/string/strip.rb')
-rw-r--r-- | activesupport/lib/active_support/core_ext/string/strip.rb | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/activesupport/lib/active_support/core_ext/string/strip.rb b/activesupport/lib/active_support/core_ext/string/strip.rb index 9fdd9d8d2e..a523e76b69 100644 --- a/activesupport/lib/active_support/core_ext/string/strip.rb +++ b/activesupport/lib/active_support/core_ext/string/strip.rb @@ -20,7 +20,6 @@ class String # Technically, it looks for the least indented non-empty line # in the whole string, and removes that amount of leading whitespace. def strip_heredoc - indent = scan(/^[ \t]*(?=\S)/).min.try(:size) || 0 - gsub(/^[ \t]{#{indent}}/, '') + gsub(/^#{scan(/^[ \t]*(?=\S)/).min}/, ''.freeze) end end |