Merge lp:~pitti/autopilot-gtk/fix-1254996 into lp:autopilot-gtk

Proposed by Martin Pitt
Status: Merged
Approved by: Thomi Richards
Approved revision: 62
Merged at revision: 62
Proposed branch: lp:~pitti/autopilot-gtk/fix-1254996
Merge into: lp:autopilot-gtk
Diff against target: 19 lines (+2/-3)
1 file modified
lib/GtkNode.cpp (+2/-3)
To merge this branch: bzr merge lp:~pitti/autopilot-gtk/fix-1254996
Reviewer Review Type Date Requested Status
Thomi Richards (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+196703@code.launchpad.net

Commit message

Avoid unnecessary string duplication when matching properties. This also fixes a rare crash when cleaning up the temporary string object.

Description of the change

Avoid unnecessary string duplication when matching properties

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Thomi Richards (thomir-deactivatedaccount) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/GtkNode.cpp'
2--- lib/GtkNode.cpp 2013-09-04 05:21:51 +0000
3+++ lib/GtkNode.cpp 2013-11-26 12:40:41 +0000
4@@ -284,13 +284,12 @@
5 g_value_init(&dest_value, G_PARAM_SPEC_VALUE_TYPE(pspec));
6 g_object_get_property(object_, name.c_str(), &dest_value);
7 convert_value(pspec, &dest_value);
8- std::string dest_string;
9
10 if (G_VALUE_TYPE(&dest_value) == G_TYPE_STRING) {
11 const gchar *str = g_value_get_string(&dest_value);
12- dest_string = (str != NULL) ? str : "";
13+ int result = g_strcmp0 (str, value.c_str());
14 g_value_unset(&dest_value);
15- return dest_string == value;
16+ return result == 0;
17 }
18 else {
19 g_debug("Property %s exists, but is not a string (is %s).",

Subscribers

People subscribed via source and target branches

to all changes: