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 (_stream_encode


From: Gavin D. Smith
Subject: branch master updated: * tp/Texinfo/Convert/Plaintext.pm (_stream_encode): Set $self->{'encoding_disabled'} if no encoding is taking place. This avoids attempting to initialise $self->{'encoding_object'} each time this runs. Report from Patrice.
Date: Sun, 18 Feb 2024 16:12:06 -0500

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 83894bac53 * tp/Texinfo/Convert/Plaintext.pm (_stream_encode): Set 
$self->{'encoding_disabled'} if no encoding is taking place. This avoids 
attempting to initialise $self->{'encoding_object'} each time this runs.  
Report from Patrice.
83894bac53 is described below

commit 83894bac530a487dc6fe7191490144aa2155967d
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Sun Feb 18 21:11:49 2024 +0000

    * tp/Texinfo/Convert/Plaintext.pm (_stream_encode):
    Set $self->{'encoding_disabled'} if no encoding is taking place.
    This avoids attempting to initialise $self->{'encoding_object'}
    each time this runs.  Report from Patrice.
---
 ChangeLog                       |  7 +++++++
 tp/Texinfo/Convert/Plaintext.pm | 25 +++++++++++++------------
 2 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 80cb3e3336..5ff3f650a2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2024-02-18  Gavin Smith <gavinsmith0123@gmail.com>
+
+       * tp/Texinfo/Convert/Plaintext.pm (_stream_encode):
+       Set $self->{'encoding_disabled'} if no encoding is taking place.
+       This avoids attempting to initialise $self->{'encoding_object'}
+       each time this runs.  Report from Patrice.
+
 2024-02-18  Roland Clobus <rclobus@rclobus.nl> (tiny change)
 
        * install-info/install-info.c (compare_entries_text):
diff --git a/tp/Texinfo/Convert/Plaintext.pm b/tp/Texinfo/Convert/Plaintext.pm
index 70a3136c8b..19df4a8912 100644
--- a/tp/Texinfo/Convert/Plaintext.pm
+++ b/tp/Texinfo/Convert/Plaintext.pm
@@ -956,23 +956,24 @@ sub _stream_encode($$)
   my $self = shift;
   my $string = shift;
 
+  if ($self->{'encoding_disabled'}) {
+    return $string;
+  }
+
   if (!defined($self->{'encoding_object'})) {
     my $encoding = $self->{'output_perl_encoding'};
-    if ($encoding and $encoding ne 'ascii') {
-      my $Encode_encoding_object = Encode::find_encoding($encoding);
-      if (!defined($Encode_encoding_object)) {
-        Carp::croak "Unknown encoding '$encoding'";
-      }
-      $self->{'encoding_object'} = $Encode_encoding_object;
+    if (!$encoding or $encoding eq 'ascii') {
+      $self->{'encoding_disabled'} = 1;
+      return $string;
     }
+    my $Encode_encoding_object = Encode::find_encoding($encoding);
+    if (!defined($Encode_encoding_object)) {
+      Carp::croak "Unknown encoding '$encoding'";
+    }
+    $self->{'encoding_object'} = $Encode_encoding_object;
   }
 
-  if ($self->{'encoding_object'}) {
-    my $encoded = $self->{'encoding_object'}->encode($string);
-    return $encoded;
-  } else {
-    return $string;
-  }
+  return $self->{'encoding_object'}->encode($string);
 }
 
 



reply via email to

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