1
0
mirror of https://github.com/SerenityOS/serenity synced 2024-07-09 06:00:45 +00:00

AK: Stop using DeprecatedString in UUID

This commit is contained in:
Jelle Raaijmakers 2022-12-18 23:24:02 +01:00 committed by Andreas Kling
parent f050a426f5
commit 99c1b634fc
2 changed files with 14 additions and 13 deletions

View File

@ -97,19 +97,20 @@ ErrorOr<NonnullOwnPtr<Kernel::KString>> UUID::to_string() const
return Kernel::KString::try_create(builder.string_view());
}
#else
DeprecatedString UUID::to_deprecated_string() const
ErrorOr<String> UUID::to_string() const
{
auto buffer_span = m_uuid_buffer.span();
StringBuilder builder(36);
builder.append(encode_hex(m_uuid_buffer.span().trim(4)).view());
builder.append('-');
builder.append(encode_hex(m_uuid_buffer.span().slice(4).trim(2)).view());
builder.append('-');
builder.append(encode_hex(m_uuid_buffer.span().slice(6).trim(2)).view());
builder.append('-');
builder.append(encode_hex(m_uuid_buffer.span().slice(8).trim(2)).view());
builder.append('-');
builder.append(encode_hex(m_uuid_buffer.span().slice(10).trim(6)).view());
return builder.to_deprecated_string();
TRY(builder.try_append(encode_hex(buffer_span.trim(4)).view()));
TRY(builder.try_append('-'));
TRY(builder.try_append(encode_hex(buffer_span.slice(4, 2)).view()));
TRY(builder.try_append('-'));
TRY(builder.try_append(encode_hex(buffer_span.slice(6, 2)).view()));
TRY(builder.try_append('-'));
TRY(builder.try_append(encode_hex(buffer_span.slice(8, 2)).view()));
TRY(builder.try_append('-'));
TRY(builder.try_append(encode_hex(buffer_span.slice(10, 6)).view()));
return builder.to_string();
}
#endif

View File

@ -14,7 +14,7 @@
#ifdef KERNEL
# include <Kernel/KString.h>
#else
# include <AK/DeprecatedString.h>
# include <AK/String.h>
#endif
namespace AK {
@ -36,7 +36,7 @@ public:
#ifdef KERNEL
ErrorOr<NonnullOwnPtr<Kernel::KString>> to_string() const;
#else
DeprecatedString to_deprecated_string() const;
ErrorOr<String> to_string() const;
#endif
bool is_zero() const;