mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-03 07:07:23 +00:00
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.
23 lines
611 B
C++
23 lines
611 B
C++
/*
|
|
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include "StringUtils.h"
|
|
|
|
AK::DeprecatedString ak_deprecated_string_from_qstring(QString const& qstring)
|
|
{
|
|
return AK::DeprecatedString(qstring.toUtf8().data());
|
|
}
|
|
|
|
ErrorOr<String> ak_string_from_qstring(QString const& qstring)
|
|
{
|
|
return String::from_utf8(StringView(qstring.toUtf8().data(), qstring.size()));
|
|
}
|
|
|
|
QString qstring_from_ak_string(StringView ak_string)
|
|
{
|
|
return QString::fromUtf8(ak_string.characters_without_null_termination(), static_cast<qsizetype>(ak_string.length()));
|
|
}
|