From mboxrd@z Thu Jan 1 00:00:00 1970 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) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga102.jf.intel.com with ESMTP; 17 Dec 2015 18:17:29 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,443,1444719600"; d="scan'208";a="619903303" Received: from yliu-dev.sh.intel.com (HELO yliu-dev) ([10.239.66.49]) by FMSMGA003.fm.intel.com with ESMTP; 17 Dec 2015 18:17:18 -0800 Date: Fri, 18 Dec 2015 10:17:48 +0800 From: Yuanhan Liu To: "Ananyev, Konstantin" 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 Content-Disposition: inline In-Reply-To: <2601191342CEEE43887BDE71AB97725836AD484A@irsmsx105.ger.corp.intel.com> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: "dev@dpdk.org" Subject: Re: [dpdk-dev] [PATCH v2 1/2] mbuf: provide rte_pktmbuf_alloc_bulk API X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Dec 2015 02:17:30 -0000 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