1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 16:18:12 +00:00

Ladybird/Qt: Replace the QString-from-AK helpers with a single method

There's no need for 2 overloads for String and DeprecatedString, we can
just use a StringView. This also avoids some cases of needlessly
allocating a DeprecatedString from a StringView when calling this
method.
This commit is contained in:
Timothy Flynn 2023-12-04 09:55:47 -05:00 committed by Andrew Kaster
parent 4d5d282e6a
commit 1aedb0ae5a
8 changed files with 21 additions and 27 deletions

View file

@ -16,13 +16,7 @@ ErrorOr<String> ak_string_from_qstring(QString const& qstring)
return String::from_utf8(StringView(qstring.toUtf8().data(), qstring.size()));
}
QString qstring_from_ak_deprecated_string(AK::DeprecatedString const& ak_deprecated_string)
QString qstring_from_ak_string(StringView ak_string)
{
return QString::fromUtf8(ak_deprecated_string.characters(), ak_deprecated_string.length());
}
QString qstring_from_ak_string(String const& ak_string)
{
auto view = ak_string.bytes_as_string_view();
return QString::fromUtf8(view.characters_without_null_termination(), view.length());
return QString::fromUtf8(ak_string.characters_without_null_termination(), static_cast<qsizetype>(ak_string.length()));
}