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 (_convert): Ass


From: Gavin D. Smith
Subject: branch master updated: * tp/Texinfo/Convert/Plaintext.pm (_convert): Assign variables $type and $command earlier so we can use them in a condition. Swap two blocks of code dealing with spaces to put the more frequently used one first, which may have a minor reduction in runtime.
Date: Fri, 07 Apr 2023 17:41:49 -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 0d5b1c33d3 * tp/Texinfo/Convert/Plaintext.pm (_convert): Assign 
variables $type and $command earlier so we can use them in a condition.  Swap 
two blocks of code dealing with spaces to put the more frequently used one 
first, which may have a minor reduction in runtime.
0d5b1c33d3 is described below

commit 0d5b1c33d366ef7bca804b040f81c9b9ee77da69
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Fri Apr 7 22:41:37 2023 +0100

    * tp/Texinfo/Convert/Plaintext.pm (_convert): Assign
    variables $type and $command earlier so we can use them in
    a condition.  Swap two blocks of code dealing with spaces to
    put the more frequently used one first, which may have a
    minor reduction in runtime.
---
 ChangeLog                       |  8 +++++++
 tp/Texinfo/Convert/Plaintext.pm | 51 +++++++++++++++++++++--------------------
 2 files changed, 34 insertions(+), 25 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 080d0fcec4..80e2abf3b1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2023-04-07  Gavin Smith <gavinsmith0123@gmail.com>
+
+       * tp/Texinfo/Convert/Plaintext.pm (_convert): Assign
+       variables $type and $command earlier so we can use them in
+       a condition.  Swap two blocks of code dealing with spaces to
+       put the more frequently used one first, which may have a
+       minor reduction in runtime.
+
 2023-04-06  Gavin Smith <gavinsmith0123@gmail.com>
 
        * doc/texinfo.tex (\startxreflink): Use \ifpdforxetex conditional
diff --git a/tp/Texinfo/Convert/Plaintext.pm b/tp/Texinfo/Convert/Plaintext.pm
index cb24875476..66a57a314c 100644
--- a/tp/Texinfo/Convert/Plaintext.pm
+++ b/tp/Texinfo/Convert/Plaintext.pm
@@ -1717,39 +1717,25 @@ sub _convert($$)
 
   my $formatter = $self->{'formatters'}->[-1];
 
-  if (($element->{'type'} and $self->{'ignored_types'}->{$element->{'type'}})
-       or ($element->{'cmdname'}
-            and ($self->{'ignored_commands'}->{$element->{'cmdname'}}
-                 or ($brace_commands{$element->{'cmdname'}}
-                     and $brace_commands{$element->{'cmdname'}} eq 'inline'
-                     and $element->{'cmdname'} ne 'inlinefmtifelse'
-                     and (($inline_format_commands{$element->{'cmdname'}}
+  my $type = $element->{'type'};
+  my $command = $element->{'cmdname'};
+
+  if (($type and $self->{'ignored_types'}->{$type})
+       or ($command
+            and ($self->{'ignored_commands'}->{$command}
+                 or ($brace_commands{$command}
+                     and $brace_commands{$command} eq 'inline'
+                     and $command ne 'inlinefmtifelse'
+                     and (($inline_format_commands{$command}
                           and (!$element->{'extra'}->{'format'}
                                or !$self->{'expanded_formats_hash'}
                                            
->{$element->{'extra'}->{'format'}}))
-                         or (!$inline_format_commands{$element->{'cmdname'}}
+                         or (!$inline_format_commands{$command}
                              and 
!defined($element->{'extra'}->{'expand_index'}))))))) {
     return '';
   }
   my $result = '';
 
-  my $type = $element->{'type'};
-  my $command = $element->{'cmdname'};
-
-  # in ignorable spaces, keep only form feeds.
-  if ($type and $self->{'ignorable_space_types'}->{$type}
-      and ($type ne 'spaces_before_paragraph'
-           or $self->get_conf('paragraphindent') ne 'asis')) {
-    if ($type eq 'spaces_after_close_brace'
-        and $element->{'text'} =~ /\f/) {
-      # FIXME also in spaces_before_paragraph?  Does not seems to be
-      # relevant to keep form feeds in other ignorable spaces.
-      $result = _get_form_feeds($element->{'text'});
-    }
-    add_text_to_count($self, $result);
-    return $result;
-  }
-
   # First handle empty lines. This has to be done before the handling
   # of text below to be sure that an empty line is always processed
   # especially
@@ -1772,6 +1758,21 @@ sub _convert($$)
     }
   }
 
+  # in ignorable spaces, keep only form feeds.
+  if ($type and $self->{'ignorable_space_types'}->{$type}
+      and ($type ne 'spaces_before_paragraph'
+           or $self->get_conf('paragraphindent') ne 'asis')) {
+    if ($type eq 'spaces_after_close_brace'
+        and $element->{'text'} =~ /\f/) {
+      # FIXME also in spaces_before_paragraph?  Does not seems to be
+      # relevant to keep form feeds in other ignorable spaces.
+      $result = _get_form_feeds($element->{'text'});
+    }
+    add_text_to_count($self, $result);
+    return $result;
+  }
+
+
   # process text
   if (defined($element->{'text'})) {
     if (!$type or $type ne 'untranslated') {



reply via email to

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