TT#83651 Do not use the topic variable for nested loops

This makes the inner loops harder to read.

Change-Id: I692f3906bbf110b8f60b5e348dc699716dd979c0
changes/32/40932/2
Guillem Jover 6 years ago
parent 0f042e38b7
commit e7fd7fbb98

@ -15,8 +15,8 @@ sub apply_patch {
for my $op (@{ $patch }) {
my $coderef = JSON::Pointer->can($op->{op});
die "invalid op '".$op->{op}."' despite schema validation" unless $coderef;
for ($op->{op}) {
if ('add' eq $_ or 'replace' eq $_) {
for my $op_name ($op->{op}) {
if ('add' eq $op_name or 'replace' eq $op_name) {
try {
$entity = $coderef->('JSON::Pointer', $entity, $op->{path}, $op->{value});
} catch($pe) {
@ -29,7 +29,7 @@ sub apply_patch {
die($pe); #->rethrow;
}
}
} elsif ('remove' eq $_) {
} elsif ('remove' eq $op_name) {
try {
$entity = $coderef->('JSON::Pointer', $entity, $op->{path});
} catch($pe) {
@ -42,7 +42,7 @@ sub apply_patch {
die($pe); #->rethrow;
}
}
} elsif ('move' eq $_ or 'copy' eq $_) {
} elsif ('move' eq $op_name or 'copy' eq $op_name) {
try {
$entity = $coderef->('JSON::Pointer', $entity, $op->{from}, $op->{path});
} catch($pe) {
@ -55,7 +55,7 @@ sub apply_patch {
die($pe); #->rethrow;
}
}
} elsif ('test' eq $_) {
} elsif ('test' eq $op_name) {
try {
die "test failed - path: $op->{path} value: $op->{value}\n"
unless $coderef->('JSON::Pointer', $entity, $op->{path}, $op->{value});

@ -22,8 +22,8 @@ sub apply_patch {
for my $op (@{ $patch }) {
my $coderef = JSON::Pointer->can($op->{op});
die "invalid op '".$op->{op}."' despite schema validation" unless $coderef;
for ($op->{op}) {
if ('add' eq $_ or 'replace' eq $_) {
for my $op_name ($op->{op}) {
if ('add' eq $op_name or 'replace' eq $op_name) {
try {
$entity = $coderef->('JSON::Pointer', $entity, $op->{path}, $op->{value});
} catch($pe) {
@ -36,7 +36,7 @@ sub apply_patch {
die($pe); #->rethrow;
}
}
} elsif ('remove' eq $_) {
} elsif ('remove' eq $op_name) {
try {
$entity = $coderef->('JSON::Pointer', $entity, $op->{path});
} catch($pe) {
@ -49,7 +49,7 @@ sub apply_patch {
die($pe); #->rethrow;
}
}
} elsif ('move' eq $_ or 'copy' eq $_) {
} elsif ('move' eq $op_name or 'copy' eq $op_name) {
try {
$entity = $coderef->('JSON::Pointer', $entity, $op->{from}, $op->{path});
} catch($pe) {
@ -62,7 +62,7 @@ sub apply_patch {
die($pe); #->rethrow;
}
}
} elsif ('test' eq $_) {
} elsif ('test' eq $op_name) {
try {
die "test failed - path: $op->{path} value: $op->{value}\n"
unless $coderef->('JSON::Pointer', $entity, $op->{path}, $op->{value});
@ -82,4 +82,4 @@ sub apply_patch {
}
return $entity;
}
1;
1;

Loading…
Cancel
Save