ruby-changes:56680
From: Nobuyoshi <ko1@a...>
Date: Sun, 28 Jul 2019 09:49:08 +0900 (JST)
Subject: [ruby-changes:56680] Nobuyoshi Nakada: a6e32855d0 (master): [reline] Do not escape and compile regexp for each byte
https://git.ruby-lang.org/ruby.git/commit/?id=a6e32855d0 From a6e32855d079e8f3806d8be8a5f5cf7b3a967133 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Sun, 28 Jul 2019 09:43:26 +0900 Subject: [reline] Do not escape and compile regexp for each byte diff --git a/lib/reline/line_editor.rb b/lib/reline/line_editor.rb index e9e693e..0de4234 100644 --- a/lib/reline/line_editor.rb +++ b/lib/reline/line_editor.rb @@ -808,6 +808,8 @@ class Reline::LineEditor https://github.com/ruby/ruby/blob/trunk/lib/reline/line_editor.rb#L808 rest = nil break_pointer = nil quote = nil + closing_quote = nil + escaped_quote = nil i = 0 while i < @byte_pointer do slice = @line.byteslice(i, @byte_pointer - i) @@ -815,14 +817,16 @@ class Reline::LineEditor https://github.com/ruby/ruby/blob/trunk/lib/reline/line_editor.rb#L817 i += 1 next end - if quote and slice.start_with?(/(?!\\)#{Regexp.escape(quote)}/) # closing " + if quote and slice.start_with?(closing_quote) quote = nil i += 1 - elsif quote and slice.start_with?(/\\#{Regexp.escape(quote)}/) # escaped \" + elsif quote and slice.start_with?(escaped_quote) # skip i += 2 elsif slice =~ quote_characters_regexp # find new " - quote = $& + quote = $~ + closing_quote = /(?!\\)#{Regexp.escape(quote)}/ + escaped_quote = /\\#{Regexp.escape(quote)}/ i += 1 elsif not quote and slice =~ word_break_regexp rest = $' -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/