[前][次][番号順一覧][スレッド一覧]

ruby-changes:56681

From: Nobuyoshi <ko1@a...>
Date: Sun, 28 Jul 2019 09:53:04 +0900 (JST)
Subject: [ruby-changes:56681] Nobuyoshi Nakada: b40589802b (master): [reline] Do not compile regexp for each line

https://git.ruby-lang.org/ruby.git/commit/?id=b40589802b

From b40589802b6fe6ba5cbb783a43f513cb2e597844 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Sun, 28 Jul 2019 09:52:07 +0900
Subject: [reline] Do not compile regexp for each line


diff --git a/lib/reline/config.rb b/lib/reline/config.rb
index bf77eca..315a3d1 100644
--- a/lib/reline/config.rb
+++ b/lib/reline/config.rb
@@ -126,20 +126,19 @@ class Reline::Config https://github.com/ruby/ruby/blob/trunk/lib/reline/config.rb#L126
       no += 1
 
       line = line.chomp.lstrip
-      if line[0, 1] == '$'
+      if line.start_with?('$')
         handle_directive(line[1..-1], file, no)
         next
       end
 
       next if @skip_section
 
-      if line.match(/^set +([^ ]+) +([^ ]+)/i)
+      case line
+      when /^set +([^ ]+) +([^ ]+)/i
         var, value = $1.downcase, $2.downcase
         bind_variable(var, value)
         next
-      end
-
-      if line =~ /\s*("#{KEYSEQ_PATTERN}+")\s*:\s*(.*)\s*$/
+      when /\s*("#{KEYSEQ_PATTERN}+")\s*:\s*(.*)\s*$/o
         key, func_name = $1, $2
         keystroke, func = bind_key(key, func_name)
         next unless keystroke
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]