[PATCH 3/3] jshn.c: write_key_string(): extract var

Sergey Ponomarev stokito at gmail.com
Mon Feb 22 17:47:55 EST 2021


This makes code cleaner and helps compiler to optimize

Signed-off-by: Sergey Ponomarev <stokito at gmail.com>
---
 jshn.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/jshn.c b/jshn.c
index 8fdd290..7a2f935 100644
--- a/jshn.c
+++ b/jshn.c
@@ -96,8 +96,10 @@ static void add_json_string(const char *str)
 
 static void write_key_string(const char *key)
 {
-	while (*key) {
-		putc(isalnum(*key) ? *key : '_', stdout);
+	char k;
+	while ((k = *key)) {
+		k = isalnum(k) ? k : '_';
+		putc(k, stdout);
 		key++;
 	}
 }
-- 
2.27.0




More information about the openwrt-devel mailing list