Skip to contentSkip to conversation

Optimize tests and remove shadowed local variable.

PATCH New Leonardo Brás 1 participant 1 message Sep 12, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Optimize tests and remove shadowed local variable.

Removes an unnecessary shadowed local variable (start). Optimize test of isdigit:
- If isalpha returns true, isdigit will return false, so no need to test.

---
 scripts/asn1_compiler.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
scripts/asn1_compiler.c +4 -4
index c146020fc783..a0056df4e358 100644
@@ -413,7 +413,7 @@ static void tokenise(char *buffer, char *end)
 
 			/* Handle string tokens */
 			if (isalpha(*p)) {
-				const char **dir, *start = p;
+				const char **dir;
 
 				/* Can be a directive, type name or element
 				 * name.  Find the end of the name.
@@ -454,10 +454,10 @@ static void tokenise(char *buffer, char *end)
 
 				tokens[tix++].token_type = TOKEN_TYPE_NAME;
 				continue;
-			}
 
-			/* Handle numbers */
-			if (isdigit(*p)) {
+			} else if (isdigit(*p)) {
+				/* Handle numbers */
+
 				/* Find the end of the number */
 				q = p + 1;
 				while (q < nl && (isdigit(*q)))
Signature · 1 line
2.19.0