diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-07-15 21:29:44 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-07-15 21:29:44 +0000 |
commit | 5e476bab9c6db89dfadc94a8c4fbf3082339fecf (patch) | |
tree | 0bbe5d74b3d70f4ce019d23fc0e5afd65e0cff2d /libbb/get_line_from_file.c | |
parent | e559e0a75738044403e9a43f54ccb0ac3091cd9a (diff) | |
download | busybox-w32-5e476bab9c6db89dfadc94a8c4fbf3082339fecf.tar.gz busybox-w32-5e476bab9c6db89dfadc94a8c4fbf3082339fecf.tar.bz2 busybox-w32-5e476bab9c6db89dfadc94a8c4fbf3082339fecf.zip |
libbb: document plans to speed up line-based input
Diffstat (limited to 'libbb/get_line_from_file.c')
-rw-r--r-- | libbb/get_line_from_file.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/libbb/get_line_from_file.c b/libbb/get_line_from_file.c index 7b65ced8d..56761f941 100644 --- a/libbb/get_line_from_file.c +++ b/libbb/get_line_from_file.c | |||
@@ -68,12 +68,24 @@ char* FAST_FUNC xmalloc_fgetline(FILE *file) | |||
68 | return c; | 68 | return c; |
69 | } | 69 | } |
70 | 70 | ||
71 | #if 0 | ||
71 | /* Faster routines (~twice as fast). +170 bytes. Unused as of 2008-07. | 72 | /* Faster routines (~twice as fast). +170 bytes. Unused as of 2008-07. |
72 | * | 73 | * |
73 | * NB: they stop at NUL byte too. | 74 | * NB: they stop at NUL byte too. |
74 | * Performance is important here. Think "grep 50gigabyte_file"... | 75 | * Performance is important here. Think "grep 50gigabyte_file"... |
75 | * Iironically, grep can't use it because of NUL issue. | 76 | * Ironically, grep can't use it because of NUL issue. |
76 | * We sorely need C lib to provide fgets which reports size! | 77 | * We sorely need C lib to provide fgets which reports size! |
78 | * | ||
79 | * Update: | ||
80 | * Actually, uclibc and glibc have it. man getline. It's GNUism, | ||
81 | * but very useful one (if it's as fast as this code). | ||
82 | * TODO: | ||
83 | * - currently, sed and sort use bb_get_chunk_from_file and heavily | ||
84 | * depend on its "stop on \n or \0" behavior, and STILL they fail | ||
85 | * to handle all cases with embedded NULs correctly. So: | ||
86 | * - audit sed and sort; convert them to getline FIRST. | ||
87 | * - THEN ditch bb_get_chunk_from_file, replace it with getline. | ||
88 | * - provide getline implementation for non-GNU systems. | ||
77 | */ | 89 | */ |
78 | 90 | ||
79 | static char* xmalloc_fgets_internal(FILE *file, int *sizep) | 91 | static char* xmalloc_fgets_internal(FILE *file, int *sizep) |
@@ -118,7 +130,6 @@ char* FAST_FUNC xmalloc_fgetline_fast(FILE *file) | |||
118 | return r; /* not xrealloc(r, sz + 1)! */ | 130 | return r; /* not xrealloc(r, sz + 1)! */ |
119 | } | 131 | } |
120 | 132 | ||
121 | #if 0 | ||
122 | char* FAST_FUNC xmalloc_fgets(FILE *file) | 133 | char* FAST_FUNC xmalloc_fgets(FILE *file) |
123 | { | 134 | { |
124 | int sz; | 135 | int sz; |