QXcbXSettings: don't construct a QByteArray just to append it

... use QByteArray::append(char*,int) instead.

Also cache the return value of the out-of-line function
xcb_get_property_value_length().

Saves ~120b in text size, and a heap allocation.

Change-Id: I4d1deafdcd3345f2b7dfbf8c45702cfee733a269
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
This commit is contained in:
Marc Mutz 2016-01-11 14:46:20 +01:00
parent a836b4735c
commit ed45af5f3c

View File

@ -117,8 +117,9 @@ public:
if (!reply)
return settings;
settings += QByteArray((const char *)xcb_get_property_value(reply), xcb_get_property_value_length(reply));
offset += xcb_get_property_value_length(reply);
const auto property_value_length = xcb_get_property_value_length(reply);
settings.append(static_cast<const char *>(xcb_get_property_value(reply)), property_value_length);
offset += property_value_length;
more = reply->bytes_after != 0;
free(reply);