Mercurial > ~mikael > mcabber > hg
comparison mcabber/src/roster.c @ 669:2b87065270f3
roster_add_group(): do not call roster_find() twice
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Sat, 14 Jan 2006 13:40:07 +0100 |
parents | 4111ff4cdd15 |
children | 2cd0805515a4 |
comparison
equal
deleted
inserted
replaced
668:d0928694c81b | 669:2b87065270f3 |
---|---|
253 | 253 |
254 // Returns pointer to new group, or existing group with that name | 254 // Returns pointer to new group, or existing group with that name |
255 GSList *roster_add_group(const char *name) | 255 GSList *roster_add_group(const char *name) |
256 { | 256 { |
257 roster *roster_grp; | 257 roster *roster_grp; |
258 GSList *p_group; | |
259 | |
258 // #1 Check name doesn't already exist | 260 // #1 Check name doesn't already exist |
259 if (!roster_find(name, namesearch, ROSTER_TYPE_GROUP)) { | 261 p_group = roster_find(name, namesearch, ROSTER_TYPE_GROUP); |
262 if (!p_group) { | |
260 // #2 Create the group node | 263 // #2 Create the group node |
261 roster_grp = g_new0(roster, 1); | 264 roster_grp = g_new0(roster, 1); |
262 roster_grp->name = g_strdup(name); | 265 roster_grp->name = g_strdup(name); |
263 roster_grp->type = ROSTER_TYPE_GROUP; | 266 roster_grp->type = ROSTER_TYPE_GROUP; |
264 // #3 Insert (sorted) | 267 // #3 Insert (sorted) |
265 groups = g_slist_insert_sorted(groups, roster_grp, | 268 groups = g_slist_insert_sorted(groups, roster_grp, |
266 (GCompareFunc)&roster_compare_name); | 269 (GCompareFunc)&roster_compare_name); |
267 } | 270 p_group = roster_find(name, namesearch, ROSTER_TYPE_GROUP); |
268 return roster_find(name, namesearch, ROSTER_TYPE_GROUP); | 271 } |
272 return p_group; | |
273 | |
269 } | 274 } |
270 | 275 |
271 // Returns a pointer to the new user, or existing user with that name | 276 // Returns a pointer to the new user, or existing user with that name |
272 GSList *roster_add_user(const char *jid, const char *name, const char *group, | 277 GSList *roster_add_user(const char *jid, const char *name, const char *group, |
273 guint type, enum subscr esub) | 278 guint type, enum subscr esub) |