* [Qemu-devel] [PATCH] qapi: cleanup redundant variable
@ 2014-01-23 8:54 Amos Kong
2014-02-01 9:49 ` [Qemu-devel] [Qemu-trivial] " Michael Tokarev
0 siblings, 1 reply; 3+ messages in thread
From: Amos Kong @ 2014-01-23 8:54 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, mdroth
No need to re-append an expr list, it's ok to return schema.exprs
Signed-off-by: Amos Kong <akong@redhat.com>
---
scripts/qapi.py | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/scripts/qapi.py b/scripts/qapi.py
index 7b92689..718f1ad 100644
--- a/scripts/qapi.py
+++ b/scripts/qapi.py
@@ -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):
--
1.8.4.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [Qemu-trivial] [PATCH] qapi: cleanup redundant variable
2014-01-23 8:54 [Qemu-devel] [PATCH] qapi: cleanup redundant variable Amos Kong
@ 2014-02-01 9:49 ` Michael Tokarev
2014-02-03 18:23 ` Eric Blake
0 siblings, 1 reply; 3+ messages in thread
From: Michael Tokarev @ 2014-02-01 9:49 UTC (permalink / raw)
To: Amos Kong; +Cc: qemu-trivial, qemu-devel
23.01.2014 12:54, Amos Kong wrote:
> No need to re-append an expr list, it's ok to return schema.exprs
>
> Signed-off-by: Amos Kong <akong@redhat.com>
> ---
> scripts/qapi.py | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/scripts/qapi.py b/scripts/qapi.py
> index 7b92689..718f1ad 100644
> --- a/scripts/qapi.py
> +++ b/scripts/qapi.py
> @@ -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
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [Qemu-trivial] [PATCH] qapi: cleanup redundant variable
2014-02-01 9:49 ` [Qemu-devel] [Qemu-trivial] " Michael Tokarev
@ 2014-02-03 18:23 ` Eric Blake
0 siblings, 0 replies; 3+ messages in thread
From: Eric Blake @ 2014-02-03 18:23 UTC (permalink / raw)
To: Michael Tokarev, Amos Kong; +Cc: qemu-trivial, qemu-devel
[-- Attachment #1: Type: text/plain, Size: 1090 bytes --]
On 02/01/2014 02:49 AM, Michael Tokarev wrote:
> 23.01.2014 12:54, Amos Kong wrote:
>> No need to re-append an expr list, it's ok to return schema.exprs
>>
>> Signed-off-by: Amos Kong <akong@redhat.com>
>> ---
>> scripts/qapi.py | 5 +----
>> 1 file changed, 1 insertion(+), 4 deletions(-)
>> @@ -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?
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?
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-02-03 18:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-23 8:54 [Qemu-devel] [PATCH] qapi: cleanup redundant variable Amos Kong
2014-02-01 9:49 ` [Qemu-devel] [Qemu-trivial] " Michael Tokarev
2014-02-03 18:23 ` Eric Blake
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).