From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Warren Date: Mon, 03 Feb 2014 13:19:36 -0700 Subject: [U-Boot] [PATCH V3 04/12] cmd_test: use table lookup for parsing In-Reply-To: References: <1390855802-17504-1-git-send-email-swarren@wwwdotorg.org> <1390855802-17504-4-git-send-email-swarren@wwwdotorg.org> Message-ID: <52EFF9D8.1050902@wwwdotorg.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 01/31/2014 05:03 PM, Simon Glass wrote: > Hi Stephen, > > On 27 January 2014 13:49, Stephen Warren wrote: >> From: Stephen Warren >> >> do_test() currently uses strcmp() twice to determine which operator is >> present; once to determine how many arguments the operator needs, then >> a second time to actually decode the operator and implement it. >> >> Rewrite the code so that a table lookup is used to translate the operator >> string to an integer, and use a more efficient switch statement to decode >> and execute the operator. >> >> This approach also acts as enablement for the following patches. >> >> This patch should introduce no behavioural change. >> >> Signed-off-by: Stephen Warren >> --- >> v3: New patch. > > Wow that's some interesting code...it took me a while to understand > both the old and the new code. It looks correct to me but I wonder if > it is deserving of some tests? Something like test/command_ut.c might > show a simple way to run some tests. OK, I'll send V4 of this series with your minor issues addressed, and I'll send a separate follow-on series which adds the unit tests, just so it doesn't delay or cause revisions to the main series.