Skip to content

Commit

Permalink
push_valtypes/pop_valtypes: simplify a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
yamt committed May 7, 2024
1 parent 4689a8e commit ec41fd3
Showing 1 changed file with 5 additions and 18 deletions.
23 changes: 5 additions & 18 deletions lib/validation.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,8 @@ int
push_valtypes(const struct resulttype *types, struct validation_context *ctx)
{
uint32_t i;

for (i = 0; i < types->ntypes; i++) {
int ret;

ret = push_valtype(types->types[i], ctx);
int ret = push_valtype(types->types[i], ctx);
if (ret != 0) {
return ret;
}
Expand All @@ -103,24 +100,14 @@ push_valtypes(const struct resulttype *types, struct validation_context *ctx)
int
pop_valtypes(const struct resulttype *types, struct validation_context *ctx)
{
uint32_t i;

if (types->ntypes == 0) {
return 0;
}

for (i = types->ntypes - 1;;) {
uint32_t left = types->ntypes;
while (left > 0) {
left--;
enum valtype t;
int ret;

ret = pop_valtype(types->types[i], &t, ctx);
int ret = pop_valtype(types->types[left], &t, ctx);
if (ret != 0) {
return ret;
}
if (i == 0) {
break;
}
i--;
}
return 0;
}
Expand Down

0 comments on commit ec41fd3

Please sign in to comment.