parse_config: use getline. BIG speedup with glibc (~40%).
function old new delta
config_read 559 604 +45
getline - 23 +23
config_close 29 49 +20
find_pair 169 187 +18
showmode 330 338 +8
hash_find 233 234 +1
builtin_umask 133 132 -1
lzo1x_optimize 1434 1429 -5
test_main 253 247 -6
buffer_fill_and_print 196 179 -17
create_J 1849 1826 -23
config_free_data 37 - -37
------------------------------------------------------------------------------
(add/remove: 3/1 grow/shrink: 5/5 up/down: 138/-89) Total: 26 bytes
Signed-off-by: Timo Teras <timo.teras@iki.fi>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
diff --git a/include/libbb.h b/include/libbb.h
index 2cac7e6..953bec3 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -1184,8 +1184,9 @@
};
typedef struct parser_t {
FILE *fp;
- char *line;
char *data;
+ char *line, *nline;
+ size_t line_alloc, nline_alloc;
int lineno;
} parser_t;
parser_t* config_open(const char *filename) FAST_FUNC;