RDoc::Parser::C: Integrate do_classes and do_modules by one regexp match
The full scan of the C source code (@content.scan) is very slow.
The old code invokes the scan six times in do_classes and do_modules.
This change integrates the six scans into one by merging the regexps.
The integrated regexp is a bit hard to maintain, but the speed up is
significant: approx. 30 sec -> 20 sec in Ruby's make rdoc.
In addition, this change omits do_boot_defclass unless the file name
is class.c. boot_defclass is too specific to Ruby's source code, so
RDoc should handle it as a special case.
RDoc::Parser::C: Integrate do_classes and do_modules by one regexp match
The full scan of the C source code (
@content.scan
) is very slow.The old code invokes the scan six times in
do_classes
anddo_modules
.This change integrates the six scans into one by merging the regexps.
The integrated regexp is a bit hard to maintain, but the speed up is
significant: approx. 30 sec -> 20 sec in Ruby's
make rdoc
.In addition, this change omits
do_boot_defclass
unless the file nameis
class.c
.boot_defclass
is too specific to Ruby's source code, soRDoc should handle it as a special case.
Before this change:
The six methods take approx. 22.2%.
do_define_class
(4.2%) +do_define_class_under
(3.8%) +do_define_module
(3,9$) +do_define_module_under
(3.7%) +do_struct_define_without_accessor
(3.4%) +do_singleton_class
(3.2%)After this change, the methods are integrated to
do_classes_and_modules
which takes only 5.8%.