mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-25 18:58:56 +00:00
Ladybird/QT: Avoid constructing AK String types from char* without size
While QByteArray::data does return a null-terminated char* it's nicer to avoid strlen() when we already know the size
This commit is contained in:
parent
d18f7145ad
commit
cac23820c5
Notes:
sideshowbarker
2024-07-17 08:35:21 +09:00
Author: https://github.com/skyrising
Commit: cac23820c5
Pull-request: https://github.com/SerenityOS/serenity/pull/23288
Reviewed-by: https://github.com/trflynn89
1 changed files with 5 additions and 3 deletions
|
@ -8,7 +8,8 @@
|
||||||
|
|
||||||
AK::ByteString ak_byte_string_from_qstring(QString const& qstring)
|
AK::ByteString ak_byte_string_from_qstring(QString const& qstring)
|
||||||
{
|
{
|
||||||
return AK::ByteString(qstring.toUtf8().data());
|
auto utf8_data = qstring.toUtf8();
|
||||||
|
return AK::ByteString(utf8_data.data(), utf8_data.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
String ak_string_from_qstring(QString const& qstring)
|
String ak_string_from_qstring(QString const& qstring)
|
||||||
|
@ -24,10 +25,11 @@ QString qstring_from_ak_string(StringView ak_string)
|
||||||
|
|
||||||
AK::URL ak_url_from_qstring(QString const& qstring)
|
AK::URL ak_url_from_qstring(QString const& qstring)
|
||||||
{
|
{
|
||||||
return AK::URL(qstring.toUtf8().data());
|
auto utf8_data = qstring.toUtf8();
|
||||||
|
return AK::URL(StringView(utf8_data.data(), utf8_data.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
AK::URL ak_url_from_qurl(QUrl const& qurl)
|
AK::URL ak_url_from_qurl(QUrl const& qurl)
|
||||||
{
|
{
|
||||||
return AK::URL(qurl.toString().toUtf8().data());
|
return ak_url_from_qstring(qurl.toString());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue