D14060: Clean up string casts

Kai Uwe Broulik noreply at phabricator.kde.org
Wed Jul 11 23:05:05 BST 2018


broulik added a comment.




INLINE COMMENTS

> testkwaylandbackend.cpp:88
>      // and thus connect to our internal test server.
> -    setenv("WAYLAND_DISPLAY", s_socketName.toLocal8Bit(), 1);
> +    setenv("WAYLAND_DISPLAY", s_socketName.toLocal8Bit().constData(), true);
>      m_server->start();

Why `true`?

> testlog.cpp:52
>      QStandardPaths::setTestModeEnabled(true);
> -    m_defaultLogFile = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/kscreen/kscreen.log";
> +    m_defaultLogFile = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QStringLiteral("/kscreen/kscreen.log");
>  }

I thought when concatenating the advantage of `QStringLiteral` don't cut it since you already have a string so should be `QLatin1String` instead?

> testqscreenbackend.cpp:62
>  
> -    m_backend = qgetenv("KSCREEN_BACKEND").constData();
> +    m_backend = QString::fromUtf8(qgetenv("KSCREEN_BACKEND"));
>  

Not from local 8 bit?

> testqscreenbackend.cpp:174
>  
>          QVariantMap info;
> +        info[QStringLiteral("id")] = output->id();

Could use initializer list

> testscreenconfig.cpp:104
>  
> -    QCOMPARE(output->name(), QString("LVDS1"));
> +    QCOMPARE(output->name(), QStringLiteral("LVDS1"));
>      QCOMPARE(output->type(), Output::Panel);

`QLatin1String`?

> parser.cpp:187
>  
> -    if (map.contains("size")) {
> -        output->setSize(Parser::sizeFromJson(map["size"].toMap()));
> -        map.remove(QLatin1Literal("size"));
> +    if (map.contains(QStringLiteral("size"))) {
> +        output->setSize(Parser::sizeFromJson(map[QStringLiteral("size")].toMap()));

`QLatin1String`?

> xrandr11.cpp:174
>      xcb_generic_error_t *err;
> -    const int sizeId = mode->id().split("-").first().toInt();
> +    const int sizeId = mode->id().split(QStringLiteral("-")).first().toInt();
>      auto cookie = xcb_randr_set_screen_config(XCB::connection(), xcbScreen->root,

`QLatin1Char`?

REPOSITORY
  R110 KScreen Library

BRANCH
  master

REVISION DETAIL
  https://phabricator.kde.org/D14060

To: gladhorn, #plasma, davidedmundson
Cc: broulik, davidedmundson, plasma-devel, ragreen, Pitel, ZrenBot, lesliezhai, ali-mohamed, jensreuterberg, abetts, sebas, apol, mart
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/plasma-devel/attachments/20180711/0247dd75/attachment-0001.html>


More information about the Plasma-devel mailing list