mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-09 09:34:57 +09:00
AK/Hex: Cleanup implementation
Problem: - Post-increment of loop index. - `const` variables are not marked `const`. - Incorrect type for loop index. Solution: - Pre-increment loop index. - Mark all possible variables `const`. - Corret type for loop index.
This commit is contained in:
parent
d462a56163
commit
c1971df4c7
Notes:
sideshowbarker
2024-07-18 19:25:37 +09:00
Author: https://github.com/ldm5180
Commit: c1971df4c7
Pull-request: https://github.com/SerenityOS/serenity/pull/6458
Reviewed-by: https://github.com/alimpfard
3 changed files with 50 additions and 50 deletions
|
@ -316,11 +316,11 @@ static constexpr bool approx_eq(const Complex<T>& a, const Complex<U>& b, const
|
|||
return x.magnitude() <= margin;
|
||||
}
|
||||
|
||||
//complex version of exp()
|
||||
// complex version of exp()
|
||||
template<AK::Concepts::Arithmetic T>
|
||||
static constexpr Complex<T> cexp(const Complex<T>& a)
|
||||
{
|
||||
//FIXME: this can probably be faster and not use so many expensive trigonometric functions
|
||||
// FIXME: this can probably be faster and not use so many expensive trigonometric functions
|
||||
if constexpr (sizeof(T) <= sizeof(float)) {
|
||||
return expf(a.real()) * Complex<T>(cosf(a.imag()), sinf(a.imag()));
|
||||
} else if constexpr (sizeof(T) <= sizeof(double)) {
|
||||
|
|
|
@ -42,12 +42,12 @@ Optional<ByteBuffer> decode_hex(const StringView& input)
|
|||
|
||||
auto output = ByteBuffer::create_zeroed(input.length() / 2);
|
||||
|
||||
for (long unsigned int i = 0; i < input.length() / 2; i++) {
|
||||
auto c1 = decode_hex_digit(input[i * 2]);
|
||||
for (size_t i = 0; i < input.length() / 2; ++i) {
|
||||
const auto c1 = decode_hex_digit(input[i * 2]);
|
||||
if (c1 >= 16)
|
||||
return {};
|
||||
|
||||
auto c2 = decode_hex_digit(input[i * 2 + 1]);
|
||||
const auto c2 = decode_hex_digit(input[i * 2 + 1]);
|
||||
if (c2 >= 16)
|
||||
return {};
|
||||
|
||||
|
@ -57,7 +57,7 @@ Optional<ByteBuffer> decode_hex(const StringView& input)
|
|||
return output;
|
||||
}
|
||||
|
||||
String encode_hex(ReadonlyBytes input)
|
||||
String encode_hex(const ReadonlyBytes input)
|
||||
{
|
||||
StringBuilder output(input.size() * 2);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue