qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 6/7] migration: Fix arrays of pointers in JSON writer


From: Fabiano Rosas
Subject: Re: [PATCH v2 6/7] migration: Fix arrays of pointers in JSON writer
Date: Thu, 09 Jan 2025 13:25:51 -0300

Peter Xu <peterx@redhat.com> writes:

> On Thu, Jan 09, 2025 at 01:16:37PM -0300, Fabiano Rosas wrote:
>> > Btw, since the new code will process it correctly with non-array below,
>> > IIUC here we can make it simple:
>> >
>> >   if 'index' in field:
>> >       self.data[fname] = fdata
>> >
>> 
>> Sorry, I don't understand what you mean here. I changed it now to:
>> 
>>     if fname not in self.data:
>>         if 'index' in field:
>>             self.data[fname] = [fdata]
>>         else:
>>             self.data[fname] = fdata
>>     elif type(self.data[fname]) == list:
>>         self.data[fname].append(fdata)
>>     else:
>>         tmp = self.data[fname]
>>         self.data[fname] = [tmp, fdata]
>
> I meant we could avoid checking "index" completely now with the new code
> knowing how to expand, so IIUC it can be simplified to:
>
>   if fname not in self.data:
>       self.data[fname] = fdata
>   elif type(self.data[fname]) == list:
>       self.data[fname].append(fdata)
>   else:
>       tmp = self.data[fname]
>       self.data[fname] = [tmp, fdata]

Good point, I'll change that. Thanks



reply via email to

[Prev in Thread] Current Thread [Next in Thread]