Skip to content

Commit

Permalink
api: fix the < and > operators of the Str class
Browse files Browse the repository at this point in the history
  • Loading branch information
mertcandav committed Jan 24, 2024
1 parent d2fb870 commit 6b42c50
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions api/str.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,14 +254,10 @@ namespace jule
{
jule::Slice<jule::I32> thisr = this->operator jule::Slice<jule::I32>();
jule::Slice<jule::I32> strr = str.operator jule::Slice<jule::I32>();
jule::Int n = thisr.len() < strr.len() ? thisr.len() : strr.len();
if (n == 0)
return false;
if (thisr.__at(0) > strr.__at(0))
return false;
jule::Int n = thisr.len() > strr.len() ? strr.len() : thisr.len();
for (jule::Int i = 0; i < n; ++i)
if (thisr.__at(i) < strr.__at(i))
return true;
if (thisr.__at(i) > strr.__at(i))
return thisr.__at(i) < strr.__at(i);
return thisr.len() < strr.len();
}

Expand All @@ -274,14 +270,10 @@ namespace jule
{
jule::Slice<jule::I32> thisr = this->operator jule::Slice<jule::I32>();
jule::Slice<jule::I32> strr = str.operator jule::Slice<jule::I32>();
jule::Int n = thisr.len() < strr.len() ? thisr.len() : strr.len();
if (n == 0)
return false;
if (thisr.__at(0) < strr.__at(0))
return false;
jule::Int n = thisr.len() > strr.len() ? strr.len() : thisr.len();
for (jule::Int i = 0; i < n; ++i)
if (thisr.__at(i) > strr.__at(i))
return true;
if (thisr.__at(i) != strr.__at(i))
return thisr.__at(i) > strr.__at(i);
return thisr.len() > strr.len();
}

Expand Down

0 comments on commit 6b42c50

Please sign in to comment.