From de692c674a1fcf8bcbfdb16cde21df37a4fea25f Mon Sep 17 00:00:00 2001 From: John Kerl Date: Mon, 31 Aug 2015 18:46:11 -0400 Subject: [PATCH] read-performance iterate --- c/bld.sh | 3 +- c/experimental/getline_for_profile.c | 17 --------- c/experimental/getmulti_for_profile.c | 51 --------------------------- 3 files changed, 1 insertion(+), 70 deletions(-) delete mode 100644 c/experimental/getline_for_profile.c delete mode 100644 c/experimental/getmulti_for_profile.c diff --git a/c/bld.sh b/c/bld.sh index 7c765bc3a..3188d745b 100644 --- a/c/bld.sh +++ b/c/bld.sh @@ -1,6 +1,5 @@ #gcc -Wall -Werror -I. lib/mlrutil.c lib/string_builder.c lib/mlr_globals.c containers/slls.c input/peek_file_reader.c experimental/csv0.c -gcc -Wall -Werror -I. -O3 lib/mlrutil.c lib/mlr_globals.c experimental/getline_for_profile.c -o get1 gcc -Wall -Werror -I. -O3 lib/mlrutil.c lib/mlr_globals.c \ lib/string_builder.c \ input/peek_file_reader.c \ - experimental/getmulti_for_profile.c -o get2 + experimental/getlines.c -o getl diff --git a/c/experimental/getline_for_profile.c b/c/experimental/getline_for_profile.c deleted file mode 100644 index ce0282dc6..000000000 --- a/c/experimental/getline_for_profile.c +++ /dev/null @@ -1,17 +0,0 @@ -#include -#include -#include "lib/mlrutil.h" -#include "input/file_reader_stdio.h" -#include "input/lrec_readers.h" - -int main(void) { - while (1) { - char* line = mlr_get_line(stdin, '\n'); - if (line == NULL) - break; - fputs(line, stdout); - fputc('\n', stdout); - free(line); - } - return 0; -} diff --git a/c/experimental/getmulti_for_profile.c b/c/experimental/getmulti_for_profile.c deleted file mode 100644 index c32e45ebe..000000000 --- a/c/experimental/getmulti_for_profile.c +++ /dev/null @@ -1,51 +0,0 @@ -#include -#include -#include "lib/mlr_globals.h" -#include "lib/mlrutil.h" -#include "containers/slls.h" -#include "containers/lhmslv.h" -#include "input/file_reader_stdio.h" -#include "input/lrec_readers.h" -#include "lib/string_builder.h" -#include "input/peek_file_reader.h" - -#define PEEK_BUF_LEN 32 -#define STRING_BUILDER_INIT_SIZE 1024 - -static char* mlr_get_line2(FILE* input_stream, char* irs, int irs_len, - peek_file_reader_t* pfr, string_builder_t* psb) -{ - while (TRUE) { - if (pfr_at_eof(pfr)) { - if (sb_is_empty(psb)) - return NULL; - else - return sb_finish(psb); - } else if (pfr_next_is(pfr, irs, irs_len)) { - if (!pfr_advance_past(pfr, irs)) { - fprintf(stderr, "%s: Internal coding error: IRS found and lost.\n", MLR_GLOBALS.argv0); - exit(1); - } - return sb_finish(psb); - } else { - sb_append_char(psb, pfr_read_char(pfr)); - } - } -} - -int main(void) { - FILE* input_stream = stdin; - peek_file_reader_t* pfr = pfr_alloc(input_stream, PEEK_BUF_LEN); - string_builder_t sb; - string_builder_t* psb = &sb; - sb_init(&sb, STRING_BUILDER_INIT_SIZE); - - while (1) { - char* line = mlr_get_line2(stdin, "\r\n", 2, pfr, psb); - if (line == NULL) - break; - fputs(line, stdout); - free(line); - } - return 0; -}