From 899968ed398fdec00903fab59f1ed36c55b4f20b Mon Sep 17 00:00:00 2001 From: makoto kuwata Date: Tue, 14 Jul 2009 10:05:11 +0900 Subject: [refactor] tiny.rb to use 'pos...m.begin(0)' instead of 'input[pos, match.begin(0) - pos]' --- lib/erubis/tiny.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/erubis/tiny.rb b/lib/erubis/tiny.rb index 8f925a1..3eb9547 100644 --- a/lib/erubis/tiny.rb +++ b/lib/erubis/tiny.rb @@ -27,10 +27,9 @@ module Erubis src = "_buf = '';" # preamble pos = 0 input.scan(EMBEDDED_PATTERN) do |indicator, code| - match = Regexp.last_match - len = match.begin(0) - pos - text = input[pos, len] - pos = match.end(0) + m = Regexp.last_match + text = input[pos...m.begin(0)] + pos = m.end(0) #src << " _buf << '" << escape_text(text) << "';" text.gsub!(/['\\]/, '\\\\\&') src << " _buf << '" << text << "';" unless text.empty? -- cgit v1.2.1