[seahorse] Replace usage of HashTable with GenericSet if possible as vala suggests
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [seahorse] Replace usage of HashTable with GenericSet if possible as vala suggests
- Date: Mon, 13 Mar 2017 08:51:49 +0000 (UTC)
commit d3a8a3a00e0461c63232806442d8ab48e086f636
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Sun Mar 12 18:58:33 2017 +0100
Replace usage of HashTable with GenericSet if possible as vala suggests
https://bugzilla.gnome.org/show_bug.cgi?id=779948
common/catalog.vala | 6 +++---
common/deletable.vala | 6 +++---
common/exportable.vala | 6 +++---
gkr/gkr-backend.vala | 4 ++--
gkr/gkr-keyring.vala | 4 ++--
5 files changed, 13 insertions(+), 13 deletions(-)
---
diff --git a/common/catalog.vala b/common/catalog.vala
index ddfb6df..938d2a4 100644
--- a/common/catalog.vala
+++ b/common/catalog.vala
@@ -33,7 +33,7 @@ public abstract class Catalog : Gtk.Window {
private Gtk.Builder _builder;
private Gtk.UIManager _ui_manager;
- private GLib.HashTable<Gtk.ActionGroup, weak Gtk.ActionGroup> _actions;
+ private GLib.GenericSet<Gtk.ActionGroup> _actions;
private Gtk.Action _edit_delete;
private Gtk.Action _properties_object;
private Gtk.Action _file_export;
@@ -49,7 +49,7 @@ public abstract class Catalog : Gtk.Window {
construct {
this._builder = Util.load_built_contents(this, this.ui_name);
- this._actions = new GLib.HashTable<Gtk.ActionGroup, weak Gtk.ActionGroup>(GLib.direct_hash,
GLib.direct_equal);
+ this._actions = new GLib.GenericSet<Gtk.ActionGroup>(GLib.direct_hash, GLib.direct_equal);
this._ui_manager = new Gtk.UIManager();
this._ui_manager.add_widget.connect((widget) => {
@@ -227,7 +227,7 @@ public abstract class Catalog : Gtk.Window {
object.get("actions", out actions, null);
if (actions == null)
continue;
- if (this._actions.lookup(actions) == null)
+ if (!this._actions.contains(actions))
this.include_actions(actions);
this._actions.add(actions);
}
diff --git a/common/deletable.vala b/common/deletable.vala
index 48fef93..58b78e6 100644
--- a/common/deletable.vala
+++ b/common/deletable.vala
@@ -38,12 +38,12 @@ public interface Deletable : GLib.Object {
int count = 0;
/* A table for monitoring which objects are still pending */
- var pending = new GLib.HashTable<weak GLib.Object, weak GLib.Object>(GLib.direct_hash,
GLib.direct_equal);
+ var pending = new GLib.GenericSet<weak GLib.Object>(GLib.direct_hash, GLib.direct_equal);
foreach (var obj in objects)
pending.add(obj);
foreach (var obj in objects) {
- if (pending.lookup(obj) == null)
+ if (!pending.contains(obj))
continue;
if (!Deletable.can_delete (obj)) {
@@ -57,7 +57,7 @@ public interface Deletable : GLib.Object {
foreach (var x in objects) {
if (x == obj)
continue;
- if (pending.lookup(x) != null)
+ if (pending.contains(x))
deleter.add_object(x);
}
diff --git a/common/exportable.vala b/common/exportable.vala
index 2561623..5000c4b 100644
--- a/common/exportable.vala
+++ b/common/exportable.vala
@@ -117,12 +117,12 @@ public interface Exportable : GLib.Object {
Gtk.Window? parent) throws GLib.Error {
int count = 0;
- var pending = new GLib.HashTable<weak GLib.Object, weak GLib.Object>(GLib.direct_hash,
GLib.direct_equal);
+ var pending = new GLib.GenericSet<weak GLib.Object>(GLib.direct_hash, GLib.direct_equal);
foreach (var object in objects)
pending.add(object);
foreach (var object in objects) {
- if (pending.lookup(object) == null)
+ if (!pending.contains(object))
continue;
if (!Exportable.can_export(object)) {
@@ -137,7 +137,7 @@ public interface Exportable : GLib.Object {
foreach (var x in objects) {
if (x == object)
continue;
- if (pending.lookup(x) != null) {
+ if (pending.contains(x)) {
foreach (var exporter in exporters)
exporter.add_object(x);
}
diff --git a/gkr/gkr-backend.vala b/gkr/gkr-backend.vala
index 722d402..b88d35e 100644
--- a/gkr/gkr-backend.vala
+++ b/gkr/gkr-backend.vala
@@ -101,7 +101,7 @@ public class Backend: GLib.Object , Gcr.Collection, Seahorse.Backend {
}
public void refresh_collections() {
- var seen = new GLib.HashTable<string, weak string>(GLib.str_hash, GLib.str_equal);
+ var seen = new GLib.GenericSet<string>(GLib.str_hash, GLib.str_equal);
var keyrings = this._service.get_collections();
string object_path;
@@ -122,7 +122,7 @@ public class Backend: GLib.Object , Gcr.Collection, Seahorse.Backend {
/* Remove any that we didn't find */
var iter = GLib.HashTableIter<string, Keyring>(this._keyrings);
while (iter.next(out object_path, null)) {
- if (seen.lookup(object_path) == null) {
+ if (!seen.contains(object_path)) {
var keyring = this._keyrings.lookup(object_path);
iter.remove();
emit_removed(keyring);
diff --git a/gkr/gkr-keyring.vala b/gkr/gkr-keyring.vala
index c82dbbf..717354a 100644
--- a/gkr/gkr-keyring.vala
+++ b/gkr/gkr-keyring.vala
@@ -131,7 +131,7 @@ public class Keyring : Secret.Collection, Gcr.Collection, Place, Deletable, Lock
}
private void refresh_collection() {
- var seen = new GLib.HashTable<string, weak string>(GLib.str_hash, GLib.str_equal);
+ var seen = new GLib.GenericSet<string>(GLib.str_hash, GLib.str_equal);
GLib.List<Secret.Item> items = null;
if (!get_locked())
@@ -152,7 +152,7 @@ public class Keyring : Secret.Collection, Gcr.Collection, Place, Deletable, Lock
var iter = GLib.HashTableIter<string, Item>(_items);
string object_path;
while (iter.next (out object_path, null)) {
- if (seen.lookup(object_path) == null) {
+ if (!seen.contains(object_path)) {
var item = _items.lookup(object_path);
item.set("place", null);
iter.remove();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]