diff options
author | Andriy Yanko <andriy.yanko@gmail.com> | 2017-07-05 11:46:51 +0300 |
---|---|---|
committer | Andriy Yanko <andriy.yanko@gmail.com> | 2017-07-10 19:27:14 +0300 |
commit | b54129f8bfcc499b3baecb4cd2db31b9c4362bf0 (patch) | |
tree | 34d83bcecfa114e3dca1ab7fb43b2bd598bf65fa | |
parent | 990a4dbbca5b7a8cf3d01861cb66deae456d370e (diff) | |
download | rails-b54129f8bfcc499b3baecb4cd2db31b9c4362bf0.tar.gz rails-b54129f8bfcc499b3baecb4cd2db31b9c4362bf0.tar.bz2 rails-b54129f8bfcc499b3baecb4cd2db31b9c4362bf0.zip |
Fix performance issue with NameError#missing_name on ruby >= v2.3.0.
Since ruby v2.3.0 `did_you_mean` gem shipped and ENABLED by default.
It patches NameError#message with spell corrections which are SLOW.
-rw-r--r-- | activesupport/lib/active_support/core_ext/name_error.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/name_error.rb b/activesupport/lib/active_support/core_ext/name_error.rb index 6b447d772b..97a38efde2 100644 --- a/activesupport/lib/active_support/core_ext/name_error.rb +++ b/activesupport/lib/active_support/core_ext/name_error.rb @@ -8,6 +8,11 @@ class NameError # end # # => "HelloWorld" def missing_name + # Since ruby v2.3.0 `did_you_mean` gem is loaded by default. + # It extends NameError#message with spell corrections which are SLOW. + # We should use original_message message instead. + message = respond_to?(:original_message) ? original_message : self.message + if /undefined local variable or method/ !~ message $1 if /((::)?([A-Z]\w*)(::[A-Z]\w*)*)$/ =~ message end |