From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33517) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZzqPu-0004qm-Es for qemu-devel@nongnu.org; Fri, 20 Nov 2015 13:28:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZzqPr-0007uv-6f for qemu-devel@nongnu.org; Fri, 20 Nov 2015 13:28:14 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40604) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZzqPr-0007ul-1b for qemu-devel@nongnu.org; Fri, 20 Nov 2015 13:28:11 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id C6EE1C100443 for ; Fri, 20 Nov 2015 18:28:10 +0000 (UTC) References: <1448010269-21694-1-git-send-email-pbonzini@redhat.com> <1448010269-21694-3-git-send-email-pbonzini@redhat.com> From: Eric Blake Message-ID: <564F6639.3080007@redhat.com> Date: Fri, 20 Nov 2015 11:28:09 -0700 MIME-Version: 1.0 In-Reply-To: <1448010269-21694-3-git-send-email-pbonzini@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="2xVGtgsMHRiSFmhuJAtLhggqCKIit5MIv" Subject: Re: [Qemu-devel] [PATCH 2/4] qjson: do not save/restore contexts List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini , qemu-devel@nongnu.org Cc: armbru@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --2xVGtgsMHRiSFmhuJAtLhggqCKIit5MIv Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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 is destroyed anyway > on errors. >=20 > The only interesting thing is that parse_keyword always eats > a TOKEN_KEYWORD, even if it is invalid, so it must come last in > parse_value (otherwise, NULL is returned, parse_literal is invoked > and it tries to peek beyond end of input). This is caught by > /errors/unterminated/literal, which actually checks for an unterminated= > keyword. =E0=B2=A0_=E0=B2=A0 >=20 > Signed-off-by: Paolo Bonzini > --- > qobject/json-parser.c | 59 ++++++++++++++++++-------------------------= -------- > 1 file changed, 21 insertions(+), 38 deletions(-) >=20 > @@ -578,17 +556,21 @@ out: > static QObject *parse_escape(JSONParserContext *ctxt, va_list *ap) > { > QObject *token =3D NULL, *obj; > - JSONParserContext saved_ctxt =3D parser_context_save(ctxt); > =20 > if (ap =3D=3D NULL) { > goto out; > } > =20 > - token =3D parser_context_pop_token(ctxt); > + token =3D parser_context_peek_token(ctxt); > if (token =3D=3D NULL) { > goto out; > } > =20 > + if (token_get_type(token) !=3D JSON_ESCAPE) { > + goto out; > + } Could merge these two conditionals. Otherwise, makes sense to me, and a lot less complicated. Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --2xVGtgsMHRiSFmhuJAtLhggqCKIit5MIv Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJWT2Y5AAoJEKeha0olJ0NqfYcH/AxwuEpQMag5wOVQf1JYHnYQ v3ix5DsqETTiI9ogIRojIeV9Bf8/1Q5FgWX/mjVrz6KnhzQLOU+oEL1H3q3oUd39 D3p9ON7x8rCVPDrC2xAXtzVepDvW1Oq6Jp1yjgh2kAg7QidMqCdD10d0h8aoG8Qt Tfv1BdLAlt2X55Ss7TPScKFE/18sSgIzEjAE1C0nPlcOtOITtja5YnDlE392q9it P4V1Wlo1B562oLxjGOVsCB/LU4p9D60/VE1LlUHKS+fdL2YeMv0j2vdwZIWHTh4e QWtlyR6KldpMUzl3RJgXBJDsvTQhGzV56pe3BaDQVk4MeJ8hKYX7sYSRd/8klSw= =GOCq -----END PGP SIGNATURE----- --2xVGtgsMHRiSFmhuJAtLhggqCKIit5MIv--