Received: from eggs.gnu.org ([2001:4830:134:3::10]:40654) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a0uci-0007b9-9c for qemu-devel@nongnu.org; Mon, 23 Nov 2015 12:09:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a0uch-0008RH-9C for qemu-devel@nongnu.org; Mon, 23 Nov 2015 12:09:52 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52575) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a0uch-0008R5-4X for qemu-devel@nongnu.org; Mon, 23 Nov 2015 12:09:51 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id B998BC057EC8 for ; Mon, 23 Nov 2015 17:09:50 +0000 (UTC) From: Markus Armbruster References: <1447946948-12489-1-git-send-email-armbru@redhat.com> <1447946948-12489-5-git-send-email-armbru@redhat.com> <564E46AD.4030901@redhat.com> <87egflqjty.fsf@blackfin.pond.sub.org> <564EDEE3.80000@redhat.com> <564F592D.4080305@redhat.com> <56532242.9040508@redhat.com> <565338EE.5070309@redhat.com> Date: Mon, 23 Nov 2015 18:09:48 +0100 In-Reply-To: <565338EE.5070309@redhat.com> (Eric Blake's message of "Mon, 23 Nov 2015 09:03:58 -0700") Message-ID: <877fl8lk0z.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v2 4/4] json-streamer: Limit number of tokens in addition to total size List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: Paolo Bonzini , qemu-devel@nongnu.org, lcapitulino@redhat.com Eric Blake writes: > On 11/23/2015 07:27 AM, Paolo Bonzini wrote: >> >> >> On 20/11/2015 18:32, Eric Blake wrote: >>>> static void qlist_size_iter(QObject *obj, void *opaque) >>>> { >>>> size_t *count = opaque; >>>> (*count)++; >>>> } >>> >>> Yuck - we don't track size independently? Seems like it might make a >>> worthwhile addition, >> >> Would you change your mind, if I told you that qlist_size is unused? :) > > Deleting dead code is a perfectly acceptable alternative to advertising > what should normally be an O(1) operation with an O(n) implementation. :) Well, "length of list" certainly isn't O(1) everywhere. The Common Lisp Hyperspec, for instance, gives an O(n) example implementation[*]. Generally just fine as long as callers are aware. [*] http://www.lispworks.com/documentation/HyperSpec/Body/f_list_l.htm#list-length