From 1be871be95118d674e32aa389822b35e8a66fd6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Fri, 1 Jun 2012 11:03:00 +0200 Subject: Particle : optimize update_link_value --- src/lib/eiotas_particle.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/lib/eiotas_particle.c b/src/lib/eiotas_particle.c index ea00b5c..5f302cf 100644 --- a/src/lib/eiotas_particle.c +++ b/src/lib/eiotas_particle.c @@ -229,7 +229,18 @@ static void update_link_value(Eiotas_Particle *particle, const char *field) } *dst='\0'; - if(particle->link_value) eina_stringshare_del(particle->link_value); - particle->link_value = ( (t==1) ? NULL : eina_stringshare_add(tmp) ); + if(particle->link_value) { + if(t==1) { + eina_stringshare_del(particle->link_value); + particle->link_value = NULL; + } else if(strcmp(particle->link_value,tmp)!=0) { + eina_stringshare_del(particle->link_value); + particle->link_value = eina_stringshare_add(tmp); + } + /* else : keep the same stringshare */ + } else if(t!=1) { + particle->link_value = eina_stringshare_add(tmp); + } + /* else : keep particle->link_value=NULL*/ } -- cgit v1.1-2-g2b99