1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[reline] Do not compile regexp for each line

This commit is contained in:
Nobuyoshi Nakada 2019-07-28 09:52:07 +09:00
parent a6e32855d0
commit b40589802b
No known key found for this signature in database
GPG key ID: 4BC7D6DF58D8DF60

View file

@ -126,20 +126,19 @@ class Reline::Config
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