mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-27 11:48:59 +00:00
LibSQL: Avoid signed arithmetic in IntegerImpl::compare
This commit is contained in:
parent
a962ee020a
commit
cd4dba87fa
Notes:
sideshowbarker
2024-07-17 19:47:17 +09:00
Author: https://github.com/i3abghany 🔰
Commit: cd4dba87fa
Pull-request: https://github.com/SerenityOS/serenity/pull/10371
Reviewed-by: https://github.com/trflynn89 ✅
1 changed files with 6 additions and 3 deletions
|
@ -704,10 +704,13 @@ bool IntegerImpl::can_cast(Value const& other_value)
|
||||||
int IntegerImpl::compare(Value const& other) const
|
int IntegerImpl::compare(Value const& other) const
|
||||||
{
|
{
|
||||||
auto casted = other.to_int();
|
auto casted = other.to_int();
|
||||||
if (!casted.has_value()) {
|
if (!casted.has_value())
|
||||||
return 1;
|
return 1;
|
||||||
}
|
|
||||||
return value() - casted.value();
|
if (value() == casted.value())
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return value() < casted.value() ? -1 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 IntegerImpl::hash() const
|
u32 IntegerImpl::hash() const
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue