From 489a5fa552297dac23fe2ff4b740249fcc9989a7 Mon Sep 17 00:00:00 2001 From: Přemysl Janouch Date: Fri, 15 May 2015 05:43:59 +0200 Subject: degesch: factor out irc_get_or_make_user() --- degesch.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/degesch.c b/degesch.c index fe9469b..c48d43a 100644 --- a/degesch.c +++ b/degesch.c @@ -2670,6 +2670,15 @@ irc_make_user (struct server *s, char *nickname) return user; } +struct user * +irc_get_or_make_user (struct server *s, const char *nickname) +{ + struct user *user = str_map_find (&s->irc_users, nickname); + if (user) + return user_ref (user); + return irc_make_user (s, xstrdup (nickname)); +} + static struct buffer * irc_get_or_make_user_buffer (struct server *s, const char *nickname) { @@ -2677,11 +2686,7 @@ irc_get_or_make_user_buffer (struct server *s, const char *nickname) if (buffer) return buffer; - struct user *user = str_map_find (&s->irc_users, nickname); - if (!user) - user = irc_make_user (s, xstrdup (nickname)); - else - user = user_ref (user); + struct user *user = irc_get_or_make_user (s, nickname); // Open a new buffer for the user buffer = buffer_new (); -- cgit v1.2.3-70-g09d2