ruby-changes:67702
From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Fri, 10 Sep 2021 20:00:43 +0900 (JST)
Subject: [ruby-changes:67702] ef74483594 (master): tool/strip-rdoc.rb: optimize
https://git.ruby-lang.org/ruby.git/commit/?id=ef74483594 From ef7448359478a04d67a4a406cca1c8442b5e2f94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?= <shyouhei@r...> Date: Sat, 26 Dec 2020 14:45:57 +0900 Subject: tool/strip-rdoc.rb: optimize This script is called from Doxygen many times. Worth optimising. [ci skip] --- tool/strip-rdoc.rb | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/tool/strip-rdoc.rb b/tool/strip-rdoc.rb index 0ac9c39..d8e311c 100755 --- a/tool/strip-rdoc.rb +++ b/tool/strip-rdoc.rb @@ -1,26 +1,14 @@ https://github.com/ruby/ruby/blob/trunk/tool/strip-rdoc.rb#L1 #!ruby +# frozen_string_literal: true # Filter for preventing Doxygen from processing RDoc comments. # Used by the Doxygen template. -ARGF.binmode -source = ARGF.read -source = source.gsub(%r{/\*([!*])((?!\*/).+?)\*/}m) do |comment| - marker, comment = $1, $2 - next "/**#{comment}*/" unless /^\s*\*\s?\-\-\s*$/ =~ comment - doxybody = nil - comment.each_line do |line| - if doxybody - if /^\s*\*\s?\+\+\s*$/ =~ line - break - end - doxybody << line - else - if /^\s*\*\s?--\s*$/ =~ line - doxybody = "\n" - end - end - end - "/*#{marker}#{doxybody}*/" -end -print source +print ARGF.binmode.read.tap {|src| + src.gsub!(%r|(/\*[!*])(?:(?!\*/).)+?^\s*\*\s?\-\-\s*$(.+?\*/)|m) { + marker = $1 + comment = $2 + comment.sub!(%r|^\s*\*\s?\+\+\s*$.+?(\s*\*/)\z|m, '\\1') + marker + comment + } +} -- cgit v1.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/