Eric Blake <ebl...@redhat.com> writes: > From: Markus Armbruster <arm...@redhat.com> > > Avoid the 'if seen' conditional by doing just the essential work > here, namely setting self.tag_member for flat unions. > Move the rest to callers. > > Signed-off-by: Markus Armbruster <arm...@redhat.com> > Message-Id: <1446559499-26984-7-git-send-email-arm...@redhat.com> > [reword commit, rebase to earlier AlternateType.check() changes] > Signed-off-by: Eric Blake <ebl...@redhat.com> > > --- > v9: new patch > --- > scripts/qapi.py | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-) > > diff --git a/scripts/qapi.py b/scripts/qapi.py > index 3054628..6653c70 100644 > --- a/scripts/qapi.py > +++ b/scripts/qapi.py > @@ -988,9 +988,10 @@ class QAPISchemaObjectType(QAPISchemaType): > for m in self.local_members: > m.check(schema) > m.check_clash(seen) > + self.members = seen.values() > if self.variants: > self.variants.check(schema, seen) > - self.members = seen.values() > + assert self.variants.tag_member in self.members > > def is_implicit(self): > # See QAPISchema._make_implicit_object_type() > @@ -1053,8 +1054,6 @@ class QAPISchemaObjectTypeVariants(object): > # seen is non-empty for unions, empty for alternates
You added this comment in PATCH 10 to explain the conditional I'm dropping here. Let's drop the comment, too. > if self.tag_name: # flat union > self.tag_member = seen[self.tag_name] > - if seen: > - assert self.tag_member in seen.itervalues() > assert isinstance(self.tag_member.type, QAPISchemaEnumType) > for v in self.variants: > # Reset seen array for each variant, since qapi names from one