diff options
author | fiaxh <git@mx.ax.lt> | 2017-11-22 20:06:50 +0100 |
---|---|---|
committer | fiaxh <git@mx.ax.lt> | 2017-11-23 01:28:29 +0100 |
commit | 9165c4db278b2d3da636d53e89c3b80cff66977f (patch) | |
tree | 84f227a12389ec2b3c3c7a578f913bc763760b53 /xmpp-vala/src/module/util.vala | |
parent | de133218dab0ac1729dbfc32177979133c15f53b (diff) | |
download | dino-9165c4db278b2d3da636d53e89c3b80cff66977f.tar.gz dino-9165c4db278b2d3da636d53e89c3b80cff66977f.zip |
Async service lookup, connect and write
Diffstat (limited to 'xmpp-vala/src/module/util.vala')
-rw-r--r-- | xmpp-vala/src/module/util.vala | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/xmpp-vala/src/module/util.vala b/xmpp-vala/src/module/util.vala index 812b09ad..e42c4768 100644 --- a/xmpp-vala/src/module/util.vala +++ b/xmpp-vala/src/module/util.vala @@ -48,16 +48,6 @@ public class StanzaListenerHolder<T> : Object { } } - private Gee.List<StanzaListener<T>> set_minus(Gee.List<StanzaListener<T>> main_set, Gee.List<StanzaListener<T>> minus) { - Gee.List<StanzaListener<T>> res = new ArrayList<StanzaListener<T>>(); - foreach (StanzaListener<T> l in main_set) { - if (!minus.contains(l)) { - res.add(l); - } - } - return res; - } - private bool set_contains_action(Gee.List<StanzaListener<T>> s, string[] actions) { foreach(StanzaListener<T> l in s) { if (l.action_group in actions) { @@ -69,16 +59,23 @@ public class StanzaListenerHolder<T> : Object { private void resort_list() { ArrayList<StanzaListener<T>> new_list = new ArrayList<StanzaListener<T>>(); - while (listeners.size > new_list.size) { + ArrayList<StanzaListener<T>> remaining = new ArrayList<StanzaListener<T>>(); + remaining.add_all(listeners); + while (remaining.size > 0) { bool changed = false; - foreach (StanzaListener<T> l in listeners) { - Gee.List<StanzaListener<T>> remaining = set_minus(listeners, new_list); + Gee.Iterator<StanzaListener<T>> iter = remaining.iterator(); + while (iter.has_next()) { + if (!iter.valid) { + iter.next(); + } + StanzaListener<T> l = iter.get(); if (!set_contains_action(remaining, l.after_actions)) { new_list.add(l); + iter.remove(); changed = true; } } - if (!changed) warning("Can't sort listeners"); + if (!changed) error("Can't sort listeners"); } listeners = new_list; } |