Skip to content

Commit

Permalink
Speed-up FASTA parsing in kseq.h with memchr (#756)
Browse files Browse the repository at this point in the history
Co-authored-by: Valentyn Bezshapkin <walentyn.bzsz@gmail.com>
Co-authored-by: Fabian Klötzl <fabian@kloetzl.info>
  • Loading branch information
3 people authored Oct 31, 2023
1 parent dd6c017 commit 98406dd
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/ksw2/kseq.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,10 @@ 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') { ks->newline+=(append == 1); break; } \
if (delimiter == KS_SEP_LINE) { \
unsigned char *sep = (unsigned char*)memchr(ks->buf + ks->begin, '\n', ks->end - ks->begin); \
i = sep != NULL ? sep - (unsigned char*)ks->buf : ks->end; \
ks->newline += (sep != NULL && append == 1); \
} else if (delimiter > KS_SEP_MAX) { \
for (i = ks->begin; i < ks->end; ++i) \
if (ks->buf[i] == delimiter) break; \
Expand Down

0 comments on commit 98406dd

Please sign in to comment.