Re: [Qemu-devel] [PATCH 2/4] qjson: do not save/restore contexts

2015-11-20 Thread Paolo Bonzini
On 20/11/2015 19:28, Eric Blake wrote: >> > +token = parser_context_peek_token(ctxt); >> > if (token == NULL) { >> > goto out; >> > } >> > >> > +if (token_get_type(token) != JSON_ESCAPE) { >> > +goto out; >> > +} > Could merge these two conditionals. Foll

Re: [Qemu-devel] [PATCH 2/4] qjson: do not save/restore contexts

2015-11-20 Thread Eric Blake
On 11/20/2015 02:04 AM, Paolo Bonzini wrote: > JSON is LL(1) and our parser indeed needs only 1 token lookahead. > Saving the parser context is mostly unnecessary; we can replace it > with peeking at the next token, or remove it altogether when the > restore only happens on errors. The token list

[Qemu-devel] [PATCH 2/4] qjson: do not save/restore contexts

2015-11-20 Thread Paolo Bonzini
JSON is LL(1) and our parser indeed needs only 1 token lookahead. Saving the parser context is mostly unnecessary; we can replace it with peeking at the next token, or remove it altogether when the restore only happens on errors. The token list is destroyed anyway on errors. The only interesting