From 53c9fbf247994f1801bc7c27feddc1feb3d95ff8 Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Sat, 5 Sep 2020 16:40:17 -0600 Subject: [PATCH] autodoc: Avoid a loop iteration Initializing everything with the first elements values allows us to not look at that element again. Previously, only somethings were so initialized. --- autodoc.pl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/autodoc.pl b/autodoc.pl index 4a0c26d7c9..40e1fd4c42 100644 --- a/autodoc.pl +++ b/autodoc.pl @@ -1121,13 +1121,14 @@ sub docout ($$$) { # output the docs for one function # return type and arguments, only the main entry is displayed. # Also, find the longest return type and longest name so that if # multiple ones are shown, they can be vertically aligned nicely - my $longest_ret = 0; - my $longest_name_length = 0; my $need_individual_usage = 0; + my $longest_name_length = length $items[0]->{name}; my $base_ret_type = $items[0]->{ret_type}; + my $longest_ret = length $base_ret_type; my @base_args = $items[0]->{args}->@*; - for my $item (@items) { + for (my $i = 1; $i < @items; $i++) { no warnings 'experimental::smartmatch'; + my $item = $items[$i]; $need_individual_usage = 1 if $item->{ret_type} ne $base_ret_type || ! ($item->{args}->@* ~~ @base_args);