From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yuanhan Liu Subject: Re: [PATCH v2 1/2] mbuf: provide rte_pktmbuf_alloc_bulk API Date: Fri, 18 Dec 2015 10:17:48 +0800 Message-ID: <20151218021748.GH29571@yliu-dev.sh.intel.com> References: <1450049754-33635-1-git-send-email-huawei.xie@intel.com> <1450055682-51953-1-git-send-email-huawei.xie@intel.com> <1450055682-51953-2-git-send-email-huawei.xie@intel.com> <20151217064106.GY29571@yliu-dev.sh.intel.com> <2601191342CEEE43887BDE71AB97725836AD484A@irsmsx105.ger.corp.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: "dev@dpdk.org" To: "Ananyev, Konstantin" Return-path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 4901ACE7 for ; Fri, 18 Dec 2015 03:17:30 +0100 (CET) Content-Disposition: inline In-Reply-To: <2601191342CEEE43887BDE71AB97725836AD484A@irsmsx105.ger.corp.intel.com> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Thu, Dec 17, 2015 at 03:42:19PM +0000, Ananyev, Konstantin wrote: > > > > -----Original Message----- > > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Yuanhan Liu > > Sent: Thursday, December 17, 2015 6:41 AM > > To: Xie, Huawei > > Cc: dev@dpdk.org > > Subject: Re: [dpdk-dev] [PATCH v2 1/2] mbuf: provide rte_pktmbuf_alloc_bulk API > > > > > +{ > > > + unsigned idx = 0; > > > + int rc; > > > + > > > + rc = rte_mempool_get_bulk(pool, (void **)mbufs, count); > > > + if (unlikely(rc)) > > > + return rc; > > > + > > > + switch (count % 4) { > > > + while (idx != count) { > > > > Well, that's an awkward trick, putting while between switch and case. > > > > How about moving the whole switch block ahead, and use goto? > > > > switch (count % 4) { > > case 3: > > goto __3; > > break; > > case 2: > > goto __2; > > break; > > ... > > > > } > > > > It basically generates same instructions, yet it improves the > > readability a bit. > > I am personally not a big fun of gotos, unless it is totally unavoidable. > I think switch/while construction is pretty obvious these days. To me, it's not. (well, maybe I have been out for a while :( > For me the original variant looks cleaner, I agree with you on that. But it sacrifices code readability a bit. If two pieces of code generates same instructions, but one is cleaner (shorter), another one is more readable, I'd prefer the later. > so my vote would be to stick with it. Okay. And anyway, above is just a suggestion, and I'm open to other suggestions. --yliu