texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * tp/Texinfo/Convert/HTML.pm (_default_format_but


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/Convert/HTML.pm (_default_format_button) (_default_format_special_body_about): avoid calling get_conf multiple times.
Date: Thu, 04 Jan 2024 08:31:59 -0500

This is an automated email from the git hooks/post-receive script.

pertusus pushed a commit to branch master
in repository texinfo.

The following commit(s) were added to refs/heads/master by this push:
     new 694edb7c27 * tp/Texinfo/Convert/HTML.pm (_default_format_button) 
(_default_format_special_body_about): avoid calling get_conf multiple times.
694edb7c27 is described below

commit 694edb7c27b8c59562b5ae4502a14de1741951e8
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Thu Jan 4 14:31:57 2024 +0100

    * tp/Texinfo/Convert/HTML.pm (_default_format_button)
    (_default_format_special_body_about): avoid calling get_conf multiple
    times.
---
 ChangeLog                  |  6 ++++
 tp/Texinfo/Convert/HTML.pm | 79 ++++++++++++++++++++++++++--------------------
 2 files changed, 50 insertions(+), 35 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 1b3754313a..26fdf0ea2d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-01-04  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/Convert/HTML.pm (_default_format_button)
+       (_default_format_special_body_about): avoid calling get_conf multiple
+       times.
+
 2024-01-04  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/main/build_perl_info.c (html_build_direction_icons):
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index 1109cc1c1e..db74d2e5d5 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -4289,13 +4289,18 @@ sub _default_format_button($$;$)
     }
   } elsif ($button eq ' ') {
     # handle space button
-    if ($self->get_conf('ICONS') and $self->get_conf('ACTIVE_ICONS')
-        and defined($self->get_conf('ACTIVE_ICONS')->{$button})
-        and $self->get_conf('ACTIVE_ICONS')->{$button} ne '') {
+    my $direction_icon;
+    if ($self->get_conf('ICONS')) {
+      my $active_icons = $self->get_conf('ACTIVE_ICONS');
+      if ($active_icons) {
+        $direction_icon = $active_icons->{$button};
+      }
+    }
+    if (defined($direction_icon) and $direction_icon ne '') {
       my $button_name_string = $self->direction_string($button,
                                                        'button', 'string');
       $active = &{$self->formatting_function('format_button_icon_img')}($self,
-                   $button_name_string, $self->get_conf('ACTIVE_ICONS')->{' 
'});
+                                         $button_name_string, $direction_icon);
     } else {
       $active = $self->direction_string($button, 'text');
     }
@@ -4322,43 +4327,45 @@ sub _default_format_button($$;$)
           $btitle .= " rel=\"$button_rel\"";
         }
       }
-      my $use_icon;
-      if ($self->get_conf('ICONS') and $self->get_conf('ACTIVE_ICONS')) {
+      my $active_icon;
+      if ($self->get_conf('ICONS')) {
+        my $active_icons = $self->get_conf('ACTIVE_ICONS');
+        if ($active_icons) {
         # FIXME strip FirstInFile from $button to get $active_icon?
-        my $active_icon = $self->get_conf('ACTIVE_ICONS')->{$button};
-        my $button_name_string = $self->direction_string($button,
-                                                         'button', 'string');
-        if (defined($active_icon) and $active_icon ne '') {
-          # use icon
-          $active = "<a href=\"$href\"${btitle}>".
-             &{$self->formatting_function('format_button_icon_img')}($self,
-                      $button_name_string, $active_icon,
-                      $self->from_element_direction($button, 'string')) 
."</a>";
-          $use_icon = 1;
+          $active_icon = $active_icons->{$button};
         }
       }
-      if (!$use_icon) {
+      if (defined($active_icon) and $active_icon ne '') {
+        my $button_name_string = $self->direction_string($button,
+                                                         'button', 'string');
+        $active = "<a href=\"$href\"${btitle}>".
+           &{$self->formatting_function('format_button_icon_img')}($self,
+                    $button_name_string, $active_icon,
+                    $self->from_element_direction($button, 'string')) ."</a>";
+      } else {
         # use text
         $active = '[' . "<a href=\"$href\"${btitle}>".
           $self->direction_string($button, 'text')."</a>" . ']';
       }
     } else {
       # button is passive
-      my $use_icon;
-      if ($self->get_conf('ICONS') and $self->get_conf('PASSIVE_ICONS')) {
+      my $passive_icon;
+      if ($self->get_conf('ICONS')) {
+        my $passive_icons = $self->get_conf('PASSIVE_ICONS');
+        if ($passive_icons) {
         # FIXME strip FirstInFile from $button to get $passive_icon?
-        my $passive_icon = $self->get_conf('PASSIVE_ICONS')->{$button};
-        my $button_name_string = $self->direction_string($button,
-                                                         'button', 'string');
-        if ($passive_icon and $passive_icon ne '') {
-          $passive = &{$self->formatting_function('format_button_icon_img')}(
-                      $self, $button_name_string, $passive_icon,
-                      $self->from_element_direction($button, 'string'));
-          $use_icon = 1;
+          $passive_icon = $passive_icons->{$button};
         }
       }
-      if (!$use_icon) {
-        $passive =  '[' . $self->direction_string($button, 'text') . ']';
+      if (defined($passive_icon) and $passive_icon ne '') {
+        # FIXME strip FirstInFile from $button to get $passive_icon?
+        my $button_name_string = $self->direction_string($button,
+                                                         'button', 'string');
+        $passive = &{$self->formatting_function('format_button_icon_img')}(
+                    $self, $button_name_string, $passive_icon,
+                    $self->from_element_direction($button, 'string'));
+      } else {
+        $passive = '[' . $self->direction_string($button, 'text') . ']';
       }
     }
     $need_delimiter = 0;
@@ -11286,9 +11293,7 @@ sub _default_format_special_body_about($$$)
     $about .= '  
'.&{$self->formatting_function('format_program_string')}($self) ."\n";
     $about .= "</p>\n";
   }
-  $about .= <<EOT;
-<p>
-EOT
+  $about .= "<p>\n";
   $about .= $self->convert_tree(
     $self->gdt('  The buttons in the navigation panels have the following 
meaning:'))
             . "\n";
@@ -11307,6 +11312,11 @@ EOT
    '    <th> ' . $self->convert_tree($self->gdt('From 1.2.3 go to')) . 
"</th>\n"
  . "  </tr>\n";
 
+  my $active_icons;
+  if ($self->get_conf('ICONS')) {
+    $active_icons = $self->get_conf('ACTIVE_ICONS');
+  }
+
   foreach my $button_spec (@{$self->get_conf('SECTION_BUTTONS')}) {
     next if ($button_spec eq ' ' or ref($button_spec) eq 'CODE'
              or ref($button_spec) eq 'SCALAR'
@@ -11326,10 +11336,9 @@ EOT
           = $self->direction_string($direction, 'button', 'string');
       # FIXME strip FirstInFile from $button to get active icon file?
       $about .=
-        (($self->get_conf('ICONS') and $self->get_conf('ACTIVE_ICONS')
-          and $self->get_conf('ACTIVE_ICONS')->{$direction}) ?
+        (($active_icons and $active_icons->{$direction}) ?
             &{$self->formatting_function('format_button_icon_img')}($self,
-             $button_name_string, 
$self->get_conf('ACTIVE_ICONS')->{$direction})
+                         $button_name_string, $active_icons->{$direction})
         : ' [' . $self->direction_string($direction, 'text') . '] ');
     }
     $about .= "</td>\n";



reply via email to

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