[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Gavin D. Smith |
Date: |
Fri, 3 Jun 2022 20:08:13 -0400 (EDT) |
branch: master
commit 740ebd89dd65a017a56ebb98935b81335cace15a
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Fri Jun 3 22:45:12 2022 +0100
texi2any --html performance improvement
* tp/Texinfo/Convert/HTML.pm (_convert): Cache debug flag
as get_conf was being called many times. Profiled with
Devel::NYTProf.
---
ChangeLog | 8 ++++++++
tp/Texinfo/Convert/HTML.pm | 22 ++++++++++++----------
2 files changed, 20 insertions(+), 10 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 6a096556bd..70c0c57e5f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2022-06-03 Gavin Smith <gavinsmith0123@gmail.com>
+
+ texi2any --html performance improvement
+
+ * tp/Texinfo/Convert/HTML.pm (_convert): Cache debug flag
+ as get_conf was being called many times. Profiled with
+ Devel::NYTProf.
+
2022-06-03 Gavin Smith <gavinsmith0123@gmail.com>
* doc/texinfo.texi (HTML Translation): Edit and trim.
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index 5b9da4e75d..e6b7269c4f 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -9872,9 +9872,10 @@ sub _protect_class_name($$)
return &{$self->formatting_function('format_protect_text')}($self,
$class_name);
}
+my $debug; # whether to print debugging output
+
# Convert tree element $ELEMENT, and return HTML text for the output files.
sub _convert($$;$);
-
sub _convert($$;$)
{
my $self = shift;
@@ -9895,7 +9896,10 @@ sub _convert($$;$)
$command_type .= $element->{'type'};
}
- if ($self->get_conf('DEBUG')) {
+ $debug = $self->get_conf('DEBUG') if !defined($debug);
+ # cache return value of get_conf for speed
+
+ if ($debug) {
$explanation = 'NO EXPLANATION' if (!defined($explanation));
print STDERR "ELEMENT($explanation):$element
(".join('|',@{$self->{'document_context'}->[-1]->{'formatting_context'}})."),
->";
print STDERR " cmd: $element->{'cmdname'}," if ($element->{'cmdname'});
@@ -9919,7 +9923,7 @@ sub _convert($$;$)
or ($element->{'cmdname'}
and exists($self->{'commands_conversion'}->{$element->{'cmdname'}})
and
!defined($self->{'commands_conversion'}->{$element->{'cmdname'}}))) {
- if ($self->get_conf('DEBUG')) {
+ if ($debug) {
my $string = 'IGNORED';
$string .= " \@$element->{'cmdname'}" if ($element->{'cmdname'});
$string .= " $element->{'type'}" if ($element->{'type'});
@@ -9943,13 +9947,13 @@ sub _convert($$;$)
$element->{'type'},
$element,
$element->{'text'});
- print STDERR "DO TEXT => `$result'\n" if ($self->get_conf('DEBUG'));
+ print STDERR "DO TEXT => `$result'\n" if $debug;
return $result;
}
if ($element->{'extra'} and $element->{'extra'}->{'missing_argument'}
and (!$element->{'contents'} or !@{$element->{'contents'}})) {
- print STDERR "MISSING_ARGUMENT\n" if ($self->get_conf('DEBUG'));
+ print STDERR "MISSING_ARGUMENT\n" if $debug;
return '';
}
@@ -10200,8 +10204,7 @@ sub _convert($$;$)
pop @{$self->{'document_context'}->[-1]->{'preformatted_classes'}};
pop @{$self->{'document_context'}->[-1]->{'composition_context'}};
}
- print STDERR "DO type ($type_name) => `$result'\n"
- if ($self->get_conf('DEBUG'));
+ print STDERR "DO type ($type_name) => `$result'\n" if $debug;
return $result;
# no type, no cmdname, but contents.
} elsif ($element->{'contents'}) {
@@ -10212,11 +10215,10 @@ sub _convert($$;$)
$content_formatted .= $self->_convert($content, "$command_type C[$i]");
$i++;
}
- print STDERR "UNNAMED HOLDER => `$content_formatted'\n"
- if ($self->get_conf('DEBUG'));
+ print STDERR "UNNAMED HOLDER => `$content_formatted'\n" if $debug;
return $content_formatted;
} else {
- print STDERR "UNNAMED empty\n" if ($self->get_conf('DEBUG'));
+ print STDERR "UNNAMED empty\n" if $debug;
if ($self->{'types_conversion'}->{''}) {
return &{$self->{'types_conversion'}->{''}} ($self, $element);
} else {