Skip to content

Commit

Permalink
QXcbXSettings: don't construct a QByteArray just to append it
Browse files Browse the repository at this point in the history
... 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) <[email protected]>
  • Loading branch information
marc-kdab committed Jan 14, 2016
1 parent a836b47 commit ed45af5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/plugins/platforms/xcb/qxcbxsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,9 @@ class QXcbXSettingsPrivate
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);
Expand Down

0 comments on commit ed45af5

Please sign in to comment.