Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

diff: reduce code noise #458

Merged
merged 1 commit into from
Feb 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 3 additions & 11 deletions bin/diff
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,8 @@ sub output_diff {
"REVERSE_ED" => \&output_ed_diff,
"UNIFIED" => \&output_unified_diff,
);
if (exists $funchash{$diff_type}) {
&{$funchash{$diff_type}}(@_); # pass in all args
} else {die "unknown diff type $diff_type"}
my $func = $funchash{$diff_type} or die "unknown diff type '$diff_type'\n";
$func->(@_);
}

sub output_old_diff {
Expand Down Expand Up @@ -538,15 +537,8 @@ sub new {
# We don't bother storing the text of the item
#
my ($class,$chunk) = @_;
my @changes = ();

# This just turns each change into a hash.
foreach my $item (@$chunk) {
my ($sign, $item_no, $text) = @$item;
my $hashref = {"sign" => $sign, "item_no" => $item_no};
push @changes, $hashref;
}

my @changes = map { {'sign' => $_->[0], 'item_no' => $_->[1]} } @$chunk;
my $block = { "changes" => \@changes };
bless $block, $class;

Expand Down
Loading