From 267a92adac852c671c4c0a4a048399c737637602 Mon Sep 17 00:00:00 2001 From: Phil Jones Date: Thu, 24 Nov 2022 17:55:58 +0000 Subject: Avoid some unnecessary copying in config parser. --- src/config.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/config.c') diff --git a/src/config.c b/src/config.c index daf6474..8a2b5c8 100644 --- a/src/config.c +++ b/src/config.c @@ -200,18 +200,19 @@ void config_load(struct tofi *tofi, const char *filename) copy_pos++; } { - char *line_stripped = strip(line); - if (!line_stripped) { - /* Skip blank lines */ - continue; + /* Grab first non-space character on the line. */ + char c; + for (char *tmp = line; *tmp != '\0'; tmp++) { + c = *tmp; + if (!isspace(c)) { + break; + } } - char first_char = line_stripped[0]; - free(line_stripped); /* * Comment characters. * N.B. treating section headers as comments for now. */ - switch (first_char) { + switch (c) { case '#': case ';': case '[': -- cgit v1.2.3