Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions sv.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,19 +179,11 @@ SVDEF bool sv_try_chop_by_delim(String_View *sv, char delim, String_View *chunk)

SVDEF String_View sv_chop_by_delim(String_View *sv, char delim)
{
size_t i = 0;
while (i < sv->count && sv->data[i] != delim) {
i += 1;
}

String_View result = sv_from_parts(sv->data, i);
String_View result;

if (i < sv->count) {
sv->count -= i + 1;
sv->data += i + 1;
} else {
sv->count -= i;
sv->data += i;
if (!sv_try_chop_by_delim(sv, delim, &result)) {
result = *sv;
*sv = SV_NULL;
}

return result;
Expand Down