From b54129f8bfcc499b3baecb4cd2db31b9c4362bf0 Mon Sep 17 00:00:00 2001 From: Andriy Yanko Date: Wed, 5 Jul 2017 11:46:51 +0300 Subject: 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. --- activesupport/lib/active_support/core_ext/name_error.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'activesupport') 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 -- cgit v1.2.3