aboutsummaryrefslogtreecommitdiffstats
path: root/user.c
diff options
context:
space:
mode:
Diffstat (limited to 'user.c')
-rw-r--r--user.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/user.c b/user.c
index 5f0952f5..ff65fe66 100644
--- a/user.c
+++ b/user.c
@@ -66,7 +66,7 @@ user_t *user_add( irc_t *irc, char *nick )
}
u->user = u->realname = u->host = u->nick = g_strdup( nick );
- u->is_private = set_getint( irc, "private" );
+ u->is_private = set_getbool( &irc->set, "private" );
key = g_strdup( nick );
nick_lc( key );
@@ -142,16 +142,22 @@ user_t *user_find( irc_t *irc, char *nick )
user_t *user_findhandle( struct gaim_connection *gc, char *handle )
{
- user_t *u = gc->irc->users;
-
- while( u )
- {
- if( u->gc == gc && u->handle && gc->prpl->cmp_buddynames ( u->handle, handle ) == 0 )
- break;
- u = u->next;
- }
-
- return( u );
+ user_t *u;
+ char *nick;
+
+ /* First, let's try a hash lookup. If it works, it's probably faster. */
+ if( ( nick = g_hash_table_lookup( gc->acc->nicks, handle ) ) &&
+ ( u = user_find( gc->irc, nick ) ) &&
+ ( gc->acc->prpl->handle_cmp( handle, u->handle ) == 0 ) )
+ return u;
+
+ /* However, it doesn't always work, so in that case we'll have to dig
+ through the whole userlist. :-( */
+ for( u = gc->irc->users; u; u = u->next )
+ if( u->gc == gc && u->handle && gc->acc->prpl->handle_cmp( u->handle, handle ) == 0 )
+ return u;
+
+ return NULL;
}
void user_rename( irc_t *irc, char *oldnick, char *newnick )