aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2015-05-15 05:43:59 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2015-05-15 05:43:59 +0200
commit489a5fa552297dac23fe2ff4b740249fcc9989a7 (patch)
tree847dbed5bfd646f5deca25a52a6d904fd1123de2
parentd41e3499c9d77aacc54f0fd3cc42ed85ec008f8a (diff)
downloadxK-489a5fa552297dac23fe2ff4b740249fcc9989a7.tar.gz
xK-489a5fa552297dac23fe2ff4b740249fcc9989a7.tar.xz
xK-489a5fa552297dac23fe2ff4b740249fcc9989a7.zip
degesch: factor out irc_get_or_make_user()
-rw-r--r--degesch.c15
1 files 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 ();