Skip to content

Commit

Permalink
We never have both separator and char limit.
Browse files Browse the repository at this point in the history
So use an `else if` to save an extra check/branch. Gets 56 million
instructions off the Perl 6 million lines/60 chars per line benchmark.
  • Loading branch information
jnthn committed Jun 16, 2017
1 parent 8fa1857 commit 8972ab2
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/strings/ascii.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ MVMuint32 MVM_string_ascii_decodestream(MVMThreadContext *tc, MVMDecodeStream *d
last_accept_bytes = cur_bytes;
last_accept_pos = pos;
total++;
if (stopper_chars && *stopper_chars == total) {
if (MVM_string_decode_stream_maybe_sep(tc, seps, codepoint)) {
reached_stopper = 1;
goto done;
}
if (MVM_string_decode_stream_maybe_sep(tc, seps, codepoint)) {
else if (stopper_chars && *stopper_chars == total) {
reached_stopper = 1;
goto done;
}
Expand Down
4 changes: 2 additions & 2 deletions src/strings/latin1.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,11 @@ MVMuint32 MVM_string_latin1_decodestream(MVMThreadContext *tc, MVMDecodeStream *
last_accept_bytes = cur_bytes;
last_accept_pos = pos;
total++;
if (stopper_chars && *stopper_chars == total) {
if (MVM_string_decode_stream_maybe_sep(tc, seps, codepoint)) {
reached_stopper = 1;
goto done;
}
if (MVM_string_decode_stream_maybe_sep(tc, seps, codepoint)) {
else if (stopper_chars && *stopper_chars == total) {
reached_stopper = 1;
goto done;
}
Expand Down
4 changes: 2 additions & 2 deletions src/strings/utf8.c
Original file line number Diff line number Diff line change
Expand Up @@ -386,11 +386,11 @@ MVMuint32 MVM_string_utf8_decodestream(MVMThreadContext *tc, MVMDecodeStream *ds
}
buffer[count++] = g;
total++;
if (stopper_chars && *stopper_chars == total) {
if (MVM_string_decode_stream_maybe_sep(tc, seps, g)) {
reached_stopper = 1;
goto done;
}
if (MVM_string_decode_stream_maybe_sep(tc, seps, g)) {
else if (stopper_chars && *stopper_chars == total) {
reached_stopper = 1;
goto done;
}
Expand Down
4 changes: 2 additions & 2 deletions src/strings/windows1252.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,11 @@ MVMuint32 MVM_string_windows1252_decodestream(MVMThreadContext *tc, MVMDecodeStr
last_accept_bytes = cur_bytes;
last_accept_pos = pos;
total++;
if (stopper_chars && *stopper_chars == total) {
if (MVM_string_decode_stream_maybe_sep(tc, seps, codepoint)) {
reached_stopper = 1;
goto done;
}
if (MVM_string_decode_stream_maybe_sep(tc, seps, codepoint)) {
else if (stopper_chars && *stopper_chars == total) {
reached_stopper = 1;
goto done;
}
Expand Down

0 comments on commit 8972ab2

Please sign in to comment.