Skip to content

Commit

Permalink
generic_string: handle empty strings correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
freshFruict committed May 13, 2024
1 parent ad3b014 commit 62bd0e7
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions include/cista/containers/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,11 @@ struct generic_string {
if (size_s > size()) {
return false;
}
if (size_s == 0) {
return true;
}
if (empty()) {
return size_s == 0;
return false;
}
return !std::memcmp(s, data(), size_s);
}
Expand All @@ -374,8 +377,11 @@ struct generic_string {
if (size_s > size()) {
return false;
}
if (size_s == 0) {
return true;
}
if (empty()) {
return size_s == 0;
return false;
}
return !std::memcmp(s, data() + size() - size_s, size_s);
}
Expand Down

0 comments on commit 62bd0e7

Please sign in to comment.