qapi: cleanup redundant variable
PATCH 1/1 qapi: cleanup redundant variable
No need to re-append an expr list, it's ok to return schema.exprs
--- scripts/qapi.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
scripts/qapi.py +1 -4
@@ -175,8 +175,6 @@ def parse_schema(fp): print >>sys.stderr, e exit(1) - exprs = [] - for expr in schema.exprs: if expr.has_key('enum'): add_enum(expr['enum'])
@@ -185,9 +183,8 @@ def parse_schema(fp): add_enum('%sKind' % expr['union']) elif expr.has_key('type'): add_struct(expr) - exprs.append(expr) - return exprs + return schema.exprs def parse_args(typeinfo): if isinstance(typeinfo, basestring):
Signature · 1 line
1.8.4.2
Quoted 21 lines · Amos Kong
No need to re-append an expr list, it's ok to return schema.exprs
Signed-off-by Amos Kong <[email protected]>--- scripts/qapi.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)scripts/qapi.py +0
-2@@ -175,8 +175,6 @@ def parse_schema(fp): print >>sys.stderr, e exit(1) - exprs = [] - for expr in schema.exprs: if expr.has_key('enum'): add_enum(expr['enum'])
scripts/qapi.py def parse_schema(fp): · line 187
Quoted 7 lines
scripts/qapi.py +1
-2@@ -185,9 +183,8 @@ def parse_schema(fp): add_enum('%sKind' % expr['union']) elif expr.has_key('type'): add_struct(expr) - exprs.append(expr) - return exprs + return schema.exprs
I don't really know python. Does it mean that previously, this function returned a copy of schema.exprs, but now it returns schema.exprs itself, so a caller can modify it?
Thanks,
/mjt
Quoted 14 lines · Michael Tokarev
Quoted 13 lines · Amos Kong
No need to re-append an expr list, it's ok to return schema.exprs
Signed-off-by Amos Kong <[email protected]>--- scripts/qapi.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)scripts/qapi.py +0
-1@@ -185,9 +183,8 @@ def parse_schema(fp): add_enum('%sKind' % expr['union']) elif expr.has_key('type'): add_struct(expr) - exprs.append(expr)
Quoted 6 lines
scripts/qapi.py def parse_schema(fp): · line 187
Quoted 2 lines
scripts/qapi.py +1
-1- return exprs + return schema.exprsI don't really know python. Does it mean that previously, this function returned a copy of schema.exprs, but now it returns schema.exprs itself, so a caller can modify it?
My python is also weak (hence my lack of R-b), but yes, I believe you are correct. On the other hand, parse_schema is only called up front, so I don't think callers are modifying the return value anyways, so does it matter?
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org