Skip to content

Commit

Permalink
Merge pull request attractivechaos#173 from jmarshall/memchr
Browse files Browse the repository at this point in the history
Apply seqtk PR to improve kseq.h parsing performance
  • Loading branch information
attractivechaos authored Sep 21, 2023
2 parents 9a063b3 + 63c95f8 commit c588728
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
10 changes: 5 additions & 5 deletions kseq.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,12 @@ typedef struct __kstring_t {
if (ks->end == -1) { ks->is_eof = 1; return -3; } \
} else break; \
} \
if (delimiter == KS_SEP_LINE) { \
for (i = ks->begin; i < ks->end; ++i) \
if (ks->buf[i] == '\n') break; \
if (delimiter == KS_SEP_LINE) { \
unsigned char *sep = memchr(ks->buf + ks->begin, '\n', ks->end - ks->begin); \
i = sep != NULL ? sep - ks->buf : ks->end; \
} else if (delimiter > KS_SEP_MAX) { \
for (i = ks->begin; i < ks->end; ++i) \
if (ks->buf[i] == delimiter) break; \
unsigned char *sep = memchr(ks->buf + ks->begin, delimiter, ks->end - ks->begin); \
i = sep != NULL ? sep - ks->buf : ks->end; \
} else if (delimiter == KS_SEP_SPACE) { \
for (i = ks->begin; i < ks->end; ++i) \
if (isspace(ks->buf[i])) break; \
Expand Down
1 change: 1 addition & 0 deletions test/kseq_bench2.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <stdint.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include "kseq.h"
KSTREAM_INIT(int, read, 4096)

Expand Down

0 comments on commit c588728

Please sign in to comment.