From owner-svn-src-projects@freebsd.org Wed Aug 12 19:10:50 2015 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 86D7D9A04E4 for ; Wed, 12 Aug 2015 19:10:50 +0000 (UTC) (envelope-from davide.italiano@gmail.com) Received: from mail-lb0-x236.google.com (mail-lb0-x236.google.com [IPv6:2a00:1450:4010:c04::236]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 2B6A2184A; Wed, 12 Aug 2015 19:10:50 +0000 (UTC) (envelope-from davide.italiano@gmail.com) Received: by lbbsx3 with SMTP id sx3so15059298lbb.0; Wed, 12 Aug 2015 12:10:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=V806YX2WpEMyMoTjF/tCvd0zZv8mrRSNIp5imdKr28s=; b=wl1hpEfIsgwDC7tUffE3TBldkrzgYtxY7lF2wu8qTltlXExPP3uI2wdvYlo+/D8p/v ZCsDuOLzL6Ourro8aWWLFB/obV+Z7+3F6WwtYeFE2jXbpqmptGn9C5ZTO7fvHnB3/FYH BFwnxNjvtpWic2mJfVgCOUaXD5Z/YQ6/WV1YXLGTn7wqeXMDfrhg9LDBmQVyYZrVvCG6 wl0HxxBRjlZLa7GW4OoiyXHnM8nfVCj/vRRUO8u3ZGnhcDnKDgAPY+SXjdzquDN8cyx0 mucis6e38sFkfBw4mjO8G2gQCASIEj8ojI1vZ5ho5PuQjYHFjFn4YmzKJvJrvYBRHlFj 63Ww== MIME-Version: 1.0 X-Received: by 10.112.46.130 with SMTP id v2mr33014462lbm.119.1439406648254; Wed, 12 Aug 2015 12:10:48 -0700 (PDT) Sender: davide.italiano@gmail.com Received: by 10.25.216.232 with HTTP; Wed, 12 Aug 2015 12:10:48 -0700 (PDT) In-Reply-To: <55CB91FD.8000004@fastmail.net> References: <201508082257.t78MvIT1000841@repo.freebsd.org> <20150812182739.GB51754@ivaldir.etoilebsd.net> <55CB91FD.8000004@fastmail.net> Date: Wed, 12 Aug 2015 15:10:48 -0400 X-Google-Sender-Auth: 05F2cw6y0PUvTBw00cCwtSeCqcc Message-ID: Subject: Re: svn commit: r286484 - projects/collation/usr.bin/localedef From: Davide Italiano To: Bruce Simpson Cc: Baptiste Daroussin , "src-committers@freebsd.org" , svn-src-projects@freebsd.org Content-Type: text/plain; charset=UTF-8 X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Aug 2015 19:10:50 -0000 On Wed, Aug 12, 2015 at 2:35 PM, Bruce Simpson wrote: > On 12/08/15 19:27, Baptiste Daroussin wrote: >> >> On Wed, Aug 12, 2015 at 01:22:17PM -0400, Davide Italiano wrote: >>>> >>>> +#define RB_NUMNODES(type, name, head, cnt) do { \ >>>> + type *t; \ >>>> + cnt = 0; \ >>>> + RB_FOREACH(t, name, head) { \ >>>> + cnt++; \ >>>> + } \ >>>> +} while (0); >>>> + >>> >>> >>> Can you commit this one to HEAD && move it to the right header? >>> >> You mean adding to tree(3)? > > > Not sure why you'd want to pollute it by doing this. The macro is simple > enough that anyone can write it, and it is often best to count RB nodes > whilst doing something else (or lazy-update) to avoid unnecessary > traversals. I'm not sure which pollution are you referring to. The fact that a macro is easy enough doesn't necessarily imply it shouldn't be part of the API/KPI. Not only I think that having all the RB macro in a single place is better than having them scatter-gathered in the tree, using RB_NUMNODES to hide the details would save us a lot of headache in case we want to change internal node representation, e.g. if we want to store a field in the struct that keeps the number of nodes in the subtree rooted at a given node, to make count O(1 ) rather than O( N ) where N is the number of nodes in the tree. -- Davide "There are no solved problems; there are only problems that are more or less solved" -- Henri Poincare