diff options
| author | Valery Febvre <vfebvre at easter-eggs.com> | 2004-08-03 13:52:48 +0000 |
|---|---|---|
| committer | Valery Febvre <vfebvre at easter-eggs.com> | 2004-08-03 13:52:48 +0000 |
| commit | bbed9c0088c7526bbdc22dae77a261b31ff2e544 (patch) | |
| tree | 9086549fcb1a3ac7818254233f172f33b31d0b24 | |
| parent | e34f412d4781f9db24745b2490b2803f2b62ccb7 (diff) | |
| download | lasso-bbed9c0088c7526bbdc22dae77a261b31ff2e544.tar.gz lasso-bbed9c0088c7526bbdc22dae77a261b31ff2e544.tar.xz lasso-bbed9c0088c7526bbdc22dae77a261b31ff2e544.zip | |
Added some optimizations in lasso_identity_add_federation()
| -rw-r--r-- | lasso/id-ff/identity.c | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/lasso/id-ff/identity.c b/lasso/id-ff/identity.c index 6e7036d9..59789519 100644 --- a/lasso/id-ff/identity.c +++ b/lasso/id-ff/identity.c @@ -77,7 +77,7 @@ lasso_identity_add_federation(LassoIdentity *identity, LassoFederation *federation) { LassoFederation *old_federation; - gboolean found; + gboolean found = FALSE; int i; g_return_val_if_fail(identity != NULL, -1); @@ -85,23 +85,20 @@ lasso_identity_add_federation(LassoIdentity *identity, g_return_val_if_fail(federation != NULL, -3); /* add the remote provider id if not already saved */ - found = FALSE; for(i = 0; i<identity->providerIDs->len; i++) { if(xmlStrEqual(remote_providerID, g_ptr_array_index(identity->providerIDs, i))) { found = TRUE; + break; } } - if (found == FALSE) { + if(found == TRUE) { + message(G_LOG_LEVEL_CRITICAL, "A federation existed already for this providerID, it was replaced by the new one.\n"); + } + else { g_ptr_array_add(identity->providerIDs, g_strdup(remote_providerID)); - } + } /* add the federation, replace if one already exists */ - old_federation = lasso_identity_get_federation(identity, remote_providerID); - if (old_federation != NULL) { - lasso_identity_remove_federation(identity, remote_providerID); - /* BEWARE: Don't destroy old_federation here. - It's not a copy. But it must change */ - } g_hash_table_insert(identity->federations, g_strdup(remote_providerID), federation); identity->is_dirty = TRUE; @@ -230,7 +227,7 @@ lasso_identity_remove_federation(LassoIdentity *identity, } /* remove the federation remote provider id */ - for(i = 0; i<identity->providerIDs->len; i++){ + for(i = 0; i<identity->providerIDs->len; i++) { if(xmlStrEqual(remote_providerID, g_ptr_array_index(identity->providerIDs, i))) { debug("Remove federation of %s\n", remote_providerID); g_ptr_array_remove_index(identity->providerIDs, i); |
