diff options
author | Daniel Boles <dboles@src.gnome.org> | 2017-02-05 23:50:25 +0000 |
---|---|---|
committer | Daniel Boles <dboles@src.gnome.org> | 2017-02-13 15:46:10 +0000 |
commit | 134bb7c0b2448003dd7601cfffb3de14bf22ca51 (patch) | |
tree | 4911c29079cb5dab3f7a326407e47f5228e3d4ca | |
parent | 8d30a13529f80b59e41ea7dab84f7a3a63212e78 (diff) | |
download | glibmm-134bb7c0b2448003dd7601cfffb3de14bf22ca51.tar.gz |
Glib::Variant—Cosmetically tweak braces & newlines
Donʼt use braces for single-line blocks, and do if the other side of an
if/else already did. Also, get rid of a couple of extraneous newlines.
https://bugzilla.gnome.org/show_bug.cgi?id=778219
-rw-r--r-- | glib/src/variant.ccg | 20 |
1 files changed, 4 insertions, 16 deletions
diff --git a/glib/src/variant.ccg b/glib/src/variant.ccg index d70af542..06923a74 100644 --- a/glib/src/variant.ccg +++ b/glib/src/variant.ccg @@ -28,13 +28,10 @@ VariantBase::VariantBase(GVariant* castitem, bool make_a_copy /* = false */) if (castitem) { if (g_variant_is_floating(castitem)) - { g_variant_ref_sink(castitem); - } + if (make_a_copy) - { g_variant_ref(castitem); - } } gobject_ = castitem; @@ -158,9 +155,7 @@ VariantContainerBase::create_tuple(const std::vector<VariantBase>& children) var_ptr* const var_array = new var_ptr[children.size()]; for (std::vector<VariantBase>::size_type i = 0; i < children.size(); i++) - { var_array[i] = const_cast<GVariant*>(children[i].gobj()); - } VariantContainerBase result = VariantContainerBase(g_variant_new_tuple(var_array, children.size())); @@ -202,9 +197,8 @@ VariantContainerBase VariantBase::cast_dynamic<VariantContainerBase>(const VariantBase& v) throw(std::bad_cast) { if (!v.gobj()) - { return VariantContainerBase(); - } + if (v.get_type().is_container()) { return VariantContainerBase(const_cast<GVariant*>(v.gobj()), true); @@ -227,7 +221,9 @@ VariantContainerBase::get_maybe(VariantBase& maybe) const return true; } else + { return false; + } } VariantIter @@ -456,9 +452,7 @@ Variant<type_vec_ustring>::create(const type_vec_ustring& data) // Add the elements of the vector into the builder. for (const auto& str : data) - { g_variant_builder_add(builder, element_variant_type.get_string().c_str(), str.c_str()); - } // Create the variant using the builder. auto result = @@ -493,7 +487,6 @@ Variant<type_vec_ustring>::get() const for (gsize i = 0; i < n_children; i++) { GVariant* gvariant = g_variant_get_child_value(const_cast<GVariant*>(gobj()), i); - result.emplace_back(Glib::Variant<Glib::ustring>(gvariant).get()); } @@ -534,9 +527,7 @@ Variant<type_vec_string>::create(const type_vec_string& data) // Add the elements of the vector into the string array. for (type_vec_string::size_type i = 0; i < data.size(); i++) - { str_array[i] = g_strdup(data[i].c_str()); - } // Terminate the string array. str_array[data.size()] = nullptr; @@ -557,9 +548,7 @@ Variant<type_vec_string>::create_from_object_paths(const type_vec_string& data) // Add the elements of the vector into the string array. for (type_vec_string::size_type i = 0; i < data.size(); i++) - { str_array[i] = g_strdup(data[i].c_str()); - } // Terminate the string array. str_array[data.size()] = nullptr; @@ -597,7 +586,6 @@ Variant<type_vec_string>::get() const for (gsize i = 0; i < n_children; i++) { GVariant* gvariant = g_variant_get_child_value(const_cast<GVariant*>(gobj()), i); - result.emplace_back(Glib::Variant<std::string>(gvariant).get()); } |