[folks] core: Replace the linking step in IA.ensure_individual_property_writeable()
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [folks] core: Replace the linking step in IA.ensure_individual_property_writeable()
- Date: Sat, 7 Jul 2012 16:28:44 +0000 (UTC)
commit 2f442b4906a9c0f2c44a7d65e379f695e74cf701
Author: Philip Withnall <philip tecnocode co uk>
Date: Tue May 8 00:01:42 2012 +0100
core: Replace the linking step in IA.ensure_individual_property_writeable()
Itâs a waste of time to create a new Persona to ensure the property is
writeable, then create _another_ new Persona to link it to the Individual.
Why not just create the writeable Persona so that itâs automatically linked
to the Individual?
Helps: https://bugzilla.gnome.org/show_bug.cgi?id=629537
folks/individual-aggregator.vala | 31 ++++++++++++++-----------------
1 files changed, 14 insertions(+), 17 deletions(-)
---
diff --git a/folks/individual-aggregator.vala b/folks/individual-aggregator.vala
index f38dead..4bc1554 100644
--- a/folks/individual-aggregator.vala
+++ b/folks/individual-aggregator.vala
@@ -1989,8 +1989,17 @@ public class Folks.IndividualAggregator : Object
debug ("ensure_individual_property_writeable: %s, %s",
individual.id, property_name);
- /* See if the individual already contains the property we want. */
- foreach (var p1 in individual.personas)
+ var p = yield this._ensure_personas_property_writeable (
+ individual.personas, property_name);
+ return p;
+ }
+
+ private async Persona _ensure_personas_property_writeable (
+ Set<Persona> personas, string property_name)
+ throws IndividualAggregatorError
+ {
+ /* See if the persona set already contains the property we want. */
+ foreach (var p1 in personas)
{
if (property_name in p1.writeable_properties)
{
@@ -2002,7 +2011,7 @@ public class Folks.IndividualAggregator : Object
/* Otherwise, create a new persona in the writeable store. If the
* writeable store doesn't exist or doesn't support writing to the given
* property, we try the other persona stores. */
- var details = new HashTable<string, Value?> (str_hash, str_equal);
+ var details = this._build_linking_details (personas);
Persona? new_persona = null;
if (this._primary_store != null &&
@@ -2067,20 +2076,8 @@ public class Folks.IndividualAggregator : Object
property_name);
}
- /* Link the persona to the existing individual. We can guarantee
- * new_persona != null because we'd have bailed out above otherwise. */
- var linking_personas = new HashSet<Persona> ();
- linking_personas.add ((!) new_persona);
-
- foreach (var p2 in individual.personas)
- {
- linking_personas.add (p2);
- }
-
- debug (" Linking personas to ensure %s property is writeable.",
- property_name);
- yield this.link_personas (linking_personas);
-
+ /* We can guarantee new_persona != null because we'd have bailed out above
+ * otherwise. */
return (!) new_persona;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]