[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/Convert/Plaintext.pm (_convert) <nod
From: |
Gavin D. Smith |
Subject: |
branch master updated: * tp/Texinfo/Convert/Plaintext.pm (_convert) <node name quoting>: Optimise for the usual case where the node name is simple text, in which case avoid calling convert_line. |
Date: |
Thu, 27 Oct 2022 06:10:03 -0400 |
This is an automated email from the git hooks/post-receive script.
gavin pushed a commit to branch master
in repository texinfo.
The following commit(s) were added to refs/heads/master by this push:
new 4e22869cc8 * tp/Texinfo/Convert/Plaintext.pm (_convert) <node name
quoting>: Optimise for the usual case where the node name is simple text, in
which case avoid calling convert_line.
4e22869cc8 is described below
commit 4e22869cc856e842e616ad2e512388145f65ca21
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Thu Oct 27 11:09:54 2022 +0100
* tp/Texinfo/Convert/Plaintext.pm (_convert) <node name quoting>:
Optimise for the usual case where the node name is simple text,
in which case avoid calling convert_line.
---
ChangeLog | 6 ++++++
tp/Texinfo/Convert/Plaintext.pm | 35 ++++++++++++++++++++++++-----------
2 files changed, 30 insertions(+), 11 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 52528af6cb..7e09610e12 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2022-10-27 Gavin Smith <gavinsmith0123@gmail.com>
+
+ * tp/Texinfo/Convert/Plaintext.pm (_convert) <node name quoting>:
+ Optimise for the usual case where the node name is simple text,
+ in which case avoid calling convert_line.
+
2022-10-27 Gavin Smith <gavinsmith0123@gmail.com>
* tp/Texinfo/Convert/Plaintext.pm (new_formatter): Access 'conf'
diff --git a/tp/Texinfo/Convert/Plaintext.pm b/tp/Texinfo/Convert/Plaintext.pm
index 3f9e4d828e..ddd0e53f0d 100644
--- a/tp/Texinfo/Convert/Plaintext.pm
+++ b/tp/Texinfo/Convert/Plaintext.pm
@@ -2235,17 +2235,30 @@ sub _convert($$)
$result .= _convert($self, {'contents' => $file});
}
- # format ref node argument outside of the document context to determine
- # if it should be quoted
- $self->{'silent'} = 0 if (!defined($self->{'silent'}));
- $self->{'silent'}++;
- push @{$self->{'count_context'}}, {'lines' => 0, 'bytes' => 0};
- my $node_line_name = $self->convert_line({'type' => '_code',
- 'contents' => $node_content},
- {'suppress_styles' => 1,
- 'no_added_eol' => 1});
- pop @{$self->{'count_context'}};
- $self->{'silent'}--;
+ my $node_line_name;
+ # Get the node name to be output.
+ # Due to the way the paragraph formatter holds pending text, converting
+ # the node name with the current formatter does not yield all the
+ # converted text. To get the full node name (and no more), we
+ # can convert in a new context, using convert_line.
+ # However, it is slow to do this for every node. So in the most
+ # frequent case when the node name is a simple text element, use
+ # that text instead.
+ if (scalar(@{$node_content}) == 1
+ and defined($node_content->[0]->{'text'})) {
+ $node_line_name = $node_content->[0]->{'text'};
+ } else {
+ $self->{'silent'} = 0 if (!defined($self->{'silent'}));
+ $self->{'silent'}++;
+ push @{$self->{'count_context'}}, {'lines' => 0, 'bytes' => 0};
+
+ $node_line_name = $self->convert_line({'type' => '_code',
+ 'contents' => $node_content},
+ {'suppress_styles' => 1,
+ 'no_added_eol' => 1});
+ pop @{$self->{'count_context'}};
+ $self->{'silent'}--;
+ }
my $check_chars;
if ($name) {
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/Convert/Plaintext.pm (_convert) <node name quoting>: Optimise for the usual case where the node name is simple text, in which case avoid calling convert_line.,
Gavin D. Smith <=