summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Jones <philj56@gmail.com>2022-11-24 17:55:58 +0000
committerPhil Jones <philj56@gmail.com>2022-11-24 17:56:28 +0000
commit267a92adac852c671c4c0a4a048399c737637602 (patch)
treeb8061329263f33a522f699b8e4ac97aeb05430f5
parent1e863efba1c8d44b1f4faa8334a2c6ffb40e951c (diff)
Avoid some unnecessary copying in config parser.
-rw-r--r--src/config.c15
1 files changed, 8 insertions, 7 deletions
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 '[':