texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

branch master updated: * tp/Texinfo/Convert/Plaintext.pm (process_printi


From: Gavin D. Smith
Subject: branch master updated: * tp/Texinfo/Convert/Plaintext.pm (process_printindex): Reuse line formatter for all index entries in an index.
Date: Thu, 27 Oct 2022 09:12:42 -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 be41535c7b * tp/Texinfo/Convert/Plaintext.pm (process_printindex): 
Reuse line formatter for all index entries in an index.
be41535c7b is described below

commit be41535c7b60e1b968d82d2389b8dab24d90c085
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Thu Oct 27 14:12:34 2022 +0100

    * tp/Texinfo/Convert/Plaintext.pm (process_printindex): Reuse
    line formatter for all index entries in an index.
---
 ChangeLog                       |  5 +++++
 tp/Texinfo/Convert/Plaintext.pm | 15 +++++++++------
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 7e09610e12..49359f57f8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2022-10-27  Gavin Smith  <gavinsmith0123@gmail.com>
+
+       * tp/Texinfo/Convert/Plaintext.pm (process_printindex): Reuse
+       line formatter for all index entries in an index.
+
 2022-10-27  Gavin Smith  <gavinsmith0123@gmail.com>
 
        * tp/Texinfo/Convert/Plaintext.pm (_convert) <node name quoting>:
diff --git a/tp/Texinfo/Convert/Plaintext.pm b/tp/Texinfo/Convert/Plaintext.pm
index ddd0e53f0d..9560d312e3 100644
--- a/tp/Texinfo/Convert/Plaintext.pm
+++ b/tp/Texinfo/Convert/Plaintext.pm
@@ -1380,6 +1380,13 @@ sub process_printindex($$;$)
   # this is used to count entries that are the same
   my %entry_counts = ();
 
+  # Use the same line formatter for all the index entries.  This is
+  # slightly faster than making a new one for each entry.
+  my $formatter = $self->new_formatter('line',
+                                 {'indent' => 0, 'suppress_styles' => 1,
+                                  'no_added_eol' => 1});
+  push @{$self->{'formatters'}}, $formatter;
+
   foreach my $entry (@{$self->{'index_entries'}->{$index_name}}) {
     next if ($ignored_entries{$entry});
     my $entry_tree = {'contents' => $entry->{'entry_content'}};
@@ -1395,18 +1402,12 @@ sub process_printindex($$;$)
     }
     my $entry_text = '';
 
-    my $formatter = $self->new_formatter('line',
-                                   {'indent' => 0, 'suppress_styles' => 1,
-                                    'no_added_eol' => 1});
-    push @{$self->{'formatters'}}, $formatter;
     $entry_text = $self->_convert($entry_tree);
     $entry_text .= $self->_convert($subentries_tree)
       if (defined($subentries_tree));
 
     $entry_text .= _count_added($self, $formatter->{'container'},
                   Texinfo::Convert::Paragraph::end($formatter->{'container'}));
-    pop @{$self->{'formatters'}};
-
     next if ($entry_text !~ /\S/);
 
     # No need for protection, the Info readers should find the last : on
@@ -1517,6 +1518,8 @@ sub process_printindex($$;$)
     add_text_to_count($self, $line_part);
     $result .= $line_part;
   }
+  pop @{$self->{'formatters'}};
+
 
   $result .= "\n"; 
   add_text_to_count($self, "\n");



reply via email to

[Prev in Thread] Current Thread [Next in Thread]