[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/ParserNonXS.pm (_process_remaining_o
From: |
Gavin D. Smith |
Subject: |
branch master updated: * tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line): Avoid use of goto statements to reduce program run time. |
Date: |
Sun, 12 Feb 2023 10:14:22 -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 325c71e8e5 * tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line):
Avoid use of goto statements to reduce program run time.
325c71e8e5 is described below
commit 325c71e8e55e8a4365f9b8baeb6a1af3db678a65
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Sun Feb 12 14:16:40 2023 +0000
* tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line):
Avoid use of goto statements to reduce program run time.
---
ChangeLog | 5 ++++
tp/Texinfo/ParserNonXS.pm | 67 ++++++++++++++++++++++++++---------------------
2 files changed, 42 insertions(+), 30 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 1869e50228..7cdff15d39 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2023-02-12 Gavin Smith <gavinsmith0123@gmail.com>
+
+ * tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line):
+ Avoid use of goto statements to reduce program run time.
+
2023-02-12 Patrice Dumas <pertusus@free.fr>
* tp/t/test_utils.pl (test): use the same expanded formats in the
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index 0bf6be60a1..cc2756d679 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -4832,8 +4832,8 @@ sub _process_remaining_on_line($$$$)
if (not $closed_nested_raw) {
push @{$current->{'contents'}},
{ 'text' => $line, 'type' => 'raw', 'parent' => $current };
- $retval = $GET_A_NEW_LINE;
- goto funexit;
+ return ($current, $line, $source_info, $GET_A_NEW_LINE);
+ # goto funexit; # used in XS code
}
# in ignored conditional block command
} elsif ($current->{'cmdname'}
@@ -4883,8 +4883,8 @@ sub _process_remaining_on_line($$$$)
}
}
# anything remaining on the line and any other line is ignored here
- $retval = $GET_A_NEW_LINE;
- goto funexit;
+ return ($current, $line, $source_info, $GET_A_NEW_LINE);
+ # goto funexit; # used in XS code
# in @verb. type should be 'brace_command_arg'
} elsif ($current->{'parent'} and $current->{'parent'}->{'cmdname'}
and $current->{'parent'}->{'cmdname'} eq 'verb') {
@@ -4910,8 +4910,8 @@ sub _process_remaining_on_line($$$$)
push @{$current->{'contents'}},
{ 'text' => $line, 'type' => 'raw', 'parent' => $current };
print STDERR "LINE VERB: $line" if ($self->{'DEBUG'});
- $retval = $GET_A_NEW_LINE;
- goto funexit;
+ return ($current, $line, $source_info, $GET_A_NEW_LINE);
+ # goto funexit; # used in XS code
}
} elsif ($current->{'cmdname'}
and $block_commands{$current->{'cmdname'}}
@@ -4953,8 +4953,8 @@ sub _process_remaining_on_line($$$$)
$current = _end_line($self, $current, $source_info);
# It may happen that there is an @include file on the line, it
# will be picked up at NEXT_LINE, beginning a new line
- $retval = $GET_A_NEW_LINE;
- goto funexit;
+ return ($current, $line, $source_info, $GET_A_NEW_LINE);
+ # goto funexit; # used in XS code
}
# this shows beginning of lines (right after 'empty_line') with
# _next_text obtained. This new text therefore does not
@@ -5003,7 +5003,8 @@ sub _process_remaining_on_line($$$$)
# results in test cases, avoiding useless text. But it is unclear why
# it is so and if it is not covering up some other bug.
($line, $source_info) = _next_text($self, $current);
- goto funexit;
+ return ($current, $line, $source_info, $retval);
+ # goto funexit; # used in XS code
}
# expand value if it can change the line. It considered again
# together with other commands below for all the other cases
@@ -5024,7 +5025,8 @@ sub _process_remaining_on_line($$$$)
"value call nested too deeply (set MAX_MACRO_CALL_NESTING to override;
current value %d)"),
$self->{'MAX_MACRO_CALL_NESTING'}),
$source_info);
$line = $remaining_line;
- goto funexit;
+ return ($current, $line, $source_info, $retval);
+ # goto funexit; # used in XS code
}
unshift @{$self->{'value_stack'}}, $value;
_input_push_text($self, $remaining_line, $source_info->{'line_nr'},
@@ -5040,7 +5042,8 @@ sub _process_remaining_on_line($$$$)
_register_source_mark($self, $current, $value_source_mark);
$self->{'input'}->[0]->{'input_source_mark'} = $value_source_mark;
$line = '';
- goto funexit;
+ return ($current, $line, $source_info, $retval);
+ # goto funexit; # used in XS code
}
}
}
@@ -5092,7 +5095,8 @@ sub _process_remaining_on_line($$$$)
_abort_empty_line($self, $current);
my $paragraph = _begin_paragraph($self, $current, $source_info);
$current = $paragraph if ($paragraph);
- goto funexit;
+ return ($current, $line, $source_info, $retval);
+ # goto funexit; # used in XS code
}
# this situation arises when after the $current->{'cmdname'}
@@ -5331,7 +5335,8 @@ sub _process_remaining_on_line($$$$)
$self->_line_error(sprintf(__("bad syntax for %c%s"), ord('@'),
$command), $source_info);
}
- goto funexit;
+ return ($current, $line, $source_info, $retval);
+ # goto funexit; # used in XS code
}
if (defined($deprecated_commands{$command})) {
@@ -5359,8 +5364,8 @@ sub _process_remaining_on_line($$$$)
my $line_continuation_source_mark
= { 'sourcemark_type' => 'defline_continuation' };
_register_source_mark($self, $current, $line_continuation_source_mark);
- $retval = $GET_A_NEW_LINE;
- goto funexit;
+ return ($current, $line, $source_info, $GET_A_NEW_LINE);
+ # goto funexit; # used in XS code
}
unless ($self->{'no_paragraph_commands'}->{$command}) {
@@ -5425,8 +5430,8 @@ sub _process_remaining_on_line($$$$)
}
if ($command eq "\n") {
$current = _end_line($self, $current, $source_info);
- $retval = $GET_A_NEW_LINE;
- goto funexit;
+ return ($current, $line, $source_info, $GET_A_NEW_LINE);
+ # goto funexit; # used in XS code
}
} else { # other
_register_global_command($self, $misc, $source_info);
@@ -5653,15 +5658,15 @@ sub _process_remaining_on_line($$$$)
}
if ($command eq 'bye') {
- $retval = $FINISHED_TOTALLY;
- goto funexit;
+ return ($current, $line, $source_info, $FINISHED_TOTALLY);
+ # goto funexit; # used in XS code
}
# Even if _end_line is called, it is not done since there is
# no line_arg
$current = _begin_preformatted($self, $current)
if ($close_preformatted_commands{$command});
- $retval = $GET_A_NEW_LINE;
- goto funexit;
+ return ($current, $line, $source_info, $GET_A_NEW_LINE);
+ # goto funexit; # used in XS code
} else {
# $arg_spec is text, line or a number
# @item or @itemx in @table
@@ -5817,8 +5822,8 @@ sub _process_remaining_on_line($$$$)
$current, $source_info);
push @{$current->{'contents'}}, $macro;
$current = $current->{'contents'}->[-1];
- $retval = $GET_A_NEW_LINE;
- goto funexit;
+ return ($current, $line, $source_info, $GET_A_NEW_LINE);
+ # goto funexit; # used in XS code
} elsif ($block_commands{$command} eq 'conditional') {
my $ifvalue_true = 0;
if ($command eq 'ifclear' or $command eq 'ifset') {
@@ -5891,8 +5896,8 @@ sub _process_remaining_on_line($$$$)
}
# FIXME(Karl) ignore what is remaining on the line, to eat
# the end of line?
- $retval = $GET_A_NEW_LINE;
- goto funexit;
+ return ($current, $line, $source_info, $GET_A_NEW_LINE);
+ # goto funexit; # used in XS code
} else {
my $block;
# a menu command closes a menu_comment, but not the other
@@ -6501,8 +6506,9 @@ sub _process_remaining_on_line($$$$)
# t/*macro.t macro_end_call_in_ignored_inlinefmtifelse.
= _next_text($self, $elided_arg_elt);
if (not defined($line)) {
- $retval = $GET_A_NEW_LINE; # error - unbalanced brace
- goto funexit;
+ # error - unbalanced brace
+ return ($current, $line, $source_info, $GET_A_NEW_LINE);
+ # goto funexit; # used in XS code
}
}
}
@@ -6559,7 +6565,8 @@ sub _process_remaining_on_line($$$$)
$current->{'remaining_args'}--;
$current = $current->{'args'}->[-1];
$line = '}' . $line;
- goto funexit;
+ return ($current, $line, $source_info, $retval);
+ # goto funexit; # used in XS code
}
}
$current->{'remaining_args'}--;
@@ -6623,8 +6630,8 @@ sub _process_remaining_on_line($$$$)
}
}
$current = _end_line($self, $current, $source_info);
- $retval = $GET_A_NEW_LINE;
- goto funexit;
+ return ($current, $line, $source_info, $GET_A_NEW_LINE);
+ # goto funexit; # used in XS code
}
funexit:
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line): Avoid use of goto statements to reduce program run time.,
Gavin D. Smith <=