diff options
author | Přemysl Janouch <p.janouch@gmail.com> | 2015-05-15 05:43:59 +0200 |
---|---|---|
committer | Přemysl Janouch <p.janouch@gmail.com> | 2015-05-15 05:43:59 +0200 |
commit | 489a5fa552297dac23fe2ff4b740249fcc9989a7 (patch) | |
tree | 847dbed5bfd646f5deca25a52a6d904fd1123de2 | |
parent | d41e3499c9d77aacc54f0fd3cc42ed85ec008f8a (diff) | |
download | xK-489a5fa552297dac23fe2ff4b740249fcc9989a7.tar.gz xK-489a5fa552297dac23fe2ff4b740249fcc9989a7.tar.xz xK-489a5fa552297dac23fe2ff4b740249fcc9989a7.zip |
degesch: factor out irc_get_or_make_user()
-rw-r--r-- | degesch.c | 15 |
1 files changed, 10 insertions, 5 deletions
@@ -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 (); |