mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 13:49:16 +00:00
LibCrypto+LibJS: Remove {Signed,Unsigned}BigInteger to_base_deprecated
Use `to_base` instead.
This commit is contained in:
parent
ac16008d09
commit
a019efb24b
Notes:
github-actions[bot]
2025-04-28 10:07:28 +00:00
Author: https://github.com/devgianlu
Commit: a019efb24b
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4482
Reviewed-by: https://github.com/gmta ✅
8 changed files with 4 additions and 16 deletions
|
@ -258,7 +258,7 @@ String BigFraction::to_string(unsigned rounding_threshold) const
|
||||||
auto const rounded_fraction = rounded(rounding_threshold);
|
auto const rounded_fraction = rounded(rounding_threshold);
|
||||||
|
|
||||||
// We take the unsigned value as we already manage the '-'
|
// We take the unsigned value as we already manage the '-'
|
||||||
auto const full_value = rounded_fraction.m_numerator.unsigned_value().to_base_deprecated(10);
|
auto const full_value = MUST(rounded_fraction.m_numerator.unsigned_value().to_base(10)).to_byte_string();
|
||||||
int split = full_value.length() - (number_of_digits(rounded_fraction.m_denominator) - 1);
|
int split = full_value.length() - (number_of_digits(rounded_fraction.m_denominator) - 1);
|
||||||
|
|
||||||
if (split < 0)
|
if (split < 0)
|
||||||
|
|
|
@ -64,11 +64,6 @@ ErrorOr<String> SignedBigInteger::to_base(u16 N) const
|
||||||
return builder.to_string();
|
return builder.to_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
ByteString SignedBigInteger::to_base_deprecated(u16 N) const
|
|
||||||
{
|
|
||||||
return MUST(to_base(N)).to_byte_string();
|
|
||||||
}
|
|
||||||
|
|
||||||
u64 SignedBigInteger::to_u64() const
|
u64 SignedBigInteger::to_u64() const
|
||||||
{
|
{
|
||||||
u64 unsigned_value = m_unsigned_data.to_u64();
|
u64 unsigned_value = m_unsigned_data.to_u64();
|
||||||
|
|
|
@ -59,7 +59,6 @@ public:
|
||||||
|
|
||||||
[[nodiscard]] static ErrorOr<SignedBigInteger> from_base(u16 N, StringView str);
|
[[nodiscard]] static ErrorOr<SignedBigInteger> from_base(u16 N, StringView str);
|
||||||
[[nodiscard]] ErrorOr<String> to_base(u16 N) const;
|
[[nodiscard]] ErrorOr<String> to_base(u16 N) const;
|
||||||
[[nodiscard]] ByteString to_base_deprecated(u16 N) const;
|
|
||||||
|
|
||||||
[[nodiscard]] u64 to_u64() const;
|
[[nodiscard]] u64 to_u64() const;
|
||||||
[[nodiscard]] double to_double(UnsignedBigInteger::RoundingMode rounding_mode = UnsignedBigInteger::RoundingMode::IEEERoundAndTiesToEvenMantissa) const;
|
[[nodiscard]] double to_double(UnsignedBigInteger::RoundingMode rounding_mode = UnsignedBigInteger::RoundingMode::IEEERoundAndTiesToEvenMantissa) const;
|
||||||
|
|
|
@ -166,11 +166,6 @@ ErrorOr<String> UnsignedBigInteger::to_base(u16 N) const
|
||||||
return TRY(builder.to_string()).reverse();
|
return TRY(builder.to_string()).reverse();
|
||||||
}
|
}
|
||||||
|
|
||||||
ByteString UnsignedBigInteger::to_base_deprecated(u16 N) const
|
|
||||||
{
|
|
||||||
return MUST(to_base(N)).to_byte_string();
|
|
||||||
}
|
|
||||||
|
|
||||||
u64 UnsignedBigInteger::to_u64() const
|
u64 UnsignedBigInteger::to_u64() const
|
||||||
{
|
{
|
||||||
static_assert(sizeof(Word) == 4);
|
static_assert(sizeof(Word) == 4);
|
||||||
|
|
|
@ -65,7 +65,6 @@ public:
|
||||||
|
|
||||||
[[nodiscard]] static ErrorOr<UnsignedBigInteger> from_base(u16 N, StringView str);
|
[[nodiscard]] static ErrorOr<UnsignedBigInteger> from_base(u16 N, StringView str);
|
||||||
[[nodiscard]] ErrorOr<String> to_base(u16 N) const;
|
[[nodiscard]] ErrorOr<String> to_base(u16 N) const;
|
||||||
[[nodiscard]] ByteString to_base_deprecated(u16 N) const;
|
|
||||||
|
|
||||||
[[nodiscard]] u64 to_u64() const;
|
[[nodiscard]] u64 to_u64() const;
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ public:
|
||||||
Crypto::SignedBigInteger const& big_integer() const { return m_big_integer; }
|
Crypto::SignedBigInteger const& big_integer() const { return m_big_integer; }
|
||||||
|
|
||||||
ErrorOr<String> to_string() const;
|
ErrorOr<String> to_string() const;
|
||||||
ByteString to_byte_string() const { return ByteString::formatted("{}n", m_big_integer.to_base_deprecated(10)); }
|
ByteString to_byte_string() const { return ByteString::formatted("{}n", MUST(m_big_integer.to_base(10))); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit BigInt(Crypto::SignedBigInteger);
|
explicit BigInt(Crypto::SignedBigInteger);
|
||||||
|
|
|
@ -74,7 +74,7 @@ JS_DEFINE_NATIVE_FUNCTION(BigIntPrototype::to_string)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5. Return BigInt::toString(x, radixMV).
|
// 5. Return BigInt::toString(x, radixMV).
|
||||||
return PrimitiveString::create(vm, bigint->big_integer().to_base_deprecated(radix));
|
return PrimitiveString::create(vm, TRY_OR_THROW_OOM(vm, bigint->big_integer().to_base(radix)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 21.2.3.2 BigInt.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] ), https://tc39.es/ecma262/#sec-bigint.prototype.tolocalestring
|
// 21.2.3.2 BigInt.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] ), https://tc39.es/ecma262/#sec-bigint.prototype.tolocalestring
|
||||||
|
|
|
@ -377,7 +377,7 @@ static i64 clip_bigint_to_sane_time(Crypto::SignedBigInteger const& value)
|
||||||
return NumericLimits<i64>::max();
|
return NumericLimits<i64>::max();
|
||||||
|
|
||||||
// FIXME: Can we do this without string conversion?
|
// FIXME: Can we do this without string conversion?
|
||||||
return value.to_base_deprecated(10).to_number<i64>().value();
|
return MUST(value.to_base(10)).to_number<i64>().value();
|
||||||
}
|
}
|
||||||
|
|
||||||
static i64 clip_double_to_sane_time(double value)
|
static i64 clip_double_to_sane_time(double value)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue