Skip to content

Commit

Permalink
api: minor optimization for string comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
mertcandav committed Aug 25, 2024
1 parent 178165a commit 05f0dcc
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions api/str.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -480,11 +480,8 @@ namespace jule

jule::Bool operator==(const jule::Str &str) const noexcept
{
if (this->_len != str._len)
return false;
if (this->_len == 0)
return true;
return std::strncmp(
return this->_len == str._len &&
std::strncmp(
reinterpret_cast<const char *>(this->begin()),
reinterpret_cast<const char *>(str.begin()),
this->_len) == 0;
Expand Down

0 comments on commit 05f0dcc

Please sign in to comment.