1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 12:07:45 +00: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:
Lenny Maiorani 2021-04-18 11:12:03 -06:00 committed by Andreas Kling
parent d462a56163
commit c1971df4c7
3 changed files with 50 additions and 50 deletions

View file

@ -42,12 +42,12 @@ Optional<ByteBuffer> decode_hex(const StringView& input)
auto output = ByteBuffer::create_zeroed(input.length() / 2); auto output = ByteBuffer::create_zeroed(input.length() / 2);
for (long unsigned int i = 0; i < input.length() / 2; i++) { for (size_t i = 0; i < input.length() / 2; ++i) {
auto c1 = decode_hex_digit(input[i * 2]); const auto c1 = decode_hex_digit(input[i * 2]);
if (c1 >= 16) if (c1 >= 16)
return {}; return {};
auto c2 = decode_hex_digit(input[i * 2 + 1]); const auto c2 = decode_hex_digit(input[i * 2 + 1]);
if (c2 >= 16) if (c2 >= 16)
return {}; return {};
@ -57,7 +57,7 @@ Optional<ByteBuffer> decode_hex(const StringView& input)
return output; return output;
} }
String encode_hex(ReadonlyBytes input) String encode_hex(const ReadonlyBytes input)
{ {
StringBuilder output(input.size() * 2); StringBuilder output(input.size() * 2);