[geary/wip/713891-traversable: 6/12] Change around the null map/filter helpers
- From: Charles Lindsay <clindsay src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/713891-traversable: 6/12] Change around the null map/filter helpers
- Date: Thu, 12 Dec 2013 02:58:01 +0000 (UTC)
commit 5b9e276bc2c7661c3089459175ff04d44ac012fa
Author: Charles Lindsay <chaz yorba org>
Date: Wed Dec 11 17:23:01 2013 -0800
Change around the null map/filter helpers
This more accurately reflects how it seems to be used.
src/engine/api/geary-search-folder.vala | 3 +--
.../conversation-monitor/app-conversation-set.vala | 3 +--
src/engine/util/util-traversable.vala | 8 ++++----
3 files changed, 6 insertions(+), 8 deletions(-)
---
diff --git a/src/engine/api/geary-search-folder.vala b/src/engine/api/geary-search-folder.vala
index 2643eec..cdd7a47 100644
--- a/src/engine/api/geary-search-folder.vala
+++ b/src/engine/api/geary-search-folder.vala
@@ -152,9 +152,8 @@ public class Geary.SearchFolder : Geary.AbstractLocalFolder, Geary.FolderSupport
try {
Gee.ArrayList<ImapDB.SearchEmailIdentifier> relevant_ids
= Geary.traverse<Geary.EmailIdentifier>(ids)
- .map<ImapDB.SearchEmailIdentifier>(
+ .map_nonnull<ImapDB.SearchEmailIdentifier>(
id => ImapDB.SearchEmailIdentifier.collection_get_email_identifier(search_results, id))
- .filter_null()
.to_array_list();
if (relevant_ids.size > 0)
diff --git a/src/engine/app/conversation-monitor/app-conversation-set.vala
b/src/engine/app/conversation-monitor/app-conversation-set.vala
index 9e39cd2..06068d3 100644
--- a/src/engine/app/conversation-monitor/app-conversation-set.vala
+++ b/src/engine/app/conversation-monitor/app-conversation-set.vala
@@ -67,8 +67,7 @@ private class Geary.App.ConversationSet : BaseObject {
Gee.Set<Geary.RFC822.MessageID>? ancestors = email.get_ancestors();
if (ancestors != null) {
return Geary.traverse<Geary.RFC822.MessageID>(ancestors)
- .map<Conversation>(a => logical_message_id_map.get(a))
- .filter_null()
+ .map_nonnull<Conversation>(a => logical_message_id_map.get(a))
.to_hash_set();
}
diff --git a/src/engine/util/util-traversable.vala b/src/engine/util/util-traversable.vala
index 155eb9c..0dd65c4 100644
--- a/src/engine/util/util-traversable.vala
+++ b/src/engine/util/util-traversable.vala
@@ -48,16 +48,16 @@ public class Iterable<G> : BaseObject {
return new Iterable<G>(i.chop(offset, length));
}
- public Iterable<G> filter_null() {
- return new Iterable<G>(i.filter(x => x != null));
+ public Iterable<A> map_nonnull<A>(Gee.MapFunc<A, G> f) {
+ return new Iterable<A>(i.map<A>(f).filter(g => g != null));
}
public Iterable<A> cast<A>() {
return new Iterable<G>(
// This would be a lot simpler if valac didn't barf on the shorter,
// more obvious syntax for each of these delegates here.
- i.filter(x => ((Object) x).get_type().is_a(typeof(A)))
- .map<A>(x => { return (A) x; }));
+ i.filter(g => ((Object) g).get_type().is_a(typeof(A)))
+ .map<A>(g => { return (A) g; }));
}
public G? first() {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]