From: Philip Withnall Date: Mon, 7 May 2012 23:01:42 +0000 (+0100) Subject: core: Replace the linking step in IA.ensure_individual_property_writeable() X-Git-Tag: FOLKS_0_7_3~54 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2f442b4906a9c0f2c44a7d65e379f695e74cf701;p=platform%2Fupstream%2Ffolks.git 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 --- 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 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 (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 (); - 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; }