aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2018-01-10 06:01:56 +0900
committerGitHub <noreply@github.com>2018-01-10 06:01:56 +0900
commitd749b5d0e8a659f2018a3acdd0061ec6b57b7f7e (patch)
tree40380d8ae5533d626d9789c35398f6ec8ea7782e /activesupport
parentd7d6921540d5cd45d5925db3b632f3a7e122ab5c (diff)
parentb54129f8bfcc499b3baecb4cd2db31b9c4362bf0 (diff)
downloadrails-d749b5d0e8a659f2018a3acdd0061ec6b57b7f7e.tar.gz
rails-d749b5d0e8a659f2018a3acdd0061ec6b57b7f7e.tar.bz2
rails-d749b5d0e8a659f2018a3acdd0061ec6b57b7f7e.zip
Merge pull request #29685 from ayanko/fix-slow-name-error-missing-name
Fix performance issue with NameError#missing_name on ruby >= v2.3.0.
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/core_ext/name_error.rb5
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 d4f1e01140..6d37cd9dfd 100644
--- a/activesupport/lib/active_support/core_ext/name_error.rb
+++ b/activesupport/lib/active_support/core_ext/name_error.rb
@@ -10,6 +10,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