summaryrefslogtreecommitdiff
path: root/src/irc
diff options
context:
space:
mode:
authorLemonBoy <thatlemon@gmail.com>2017-10-24 15:47:06 +0200
committerLemonBoy <thatlemon@gmail.com>2018-01-07 12:36:20 +0100
commitc00132ac4cf78702b4f72fc6a0085432bcef2fac (patch)
tree6155c17de228e5060c1a907f893f2a4e64d46571 /src/irc
parent9160ddaffd45b03c523320ef8f71bb3a8a9fb87a (diff)
downloadirssi-c00132ac4cf78702b4f72fc6a0085432bcef2fac.zip
Simplify the code
Early exit, simpler code.
Diffstat (limited to 'src/irc')
-rw-r--r--src/irc/core/irc-cap.c31
1 files changed, 13 insertions, 18 deletions
diff --git a/src/irc/core/irc-cap.c b/src/irc/core/irc-cap.c
index d93dfac4..5d033bbf 100644
--- a/src/irc/core/irc-cap.c
+++ b/src/irc/core/irc-cap.c
@@ -155,18 +155,16 @@ static void event_cap (IRC_SERVER_REC *server, char *args, char *nick, char *add
for (i = 0; i < caps_length; i++) {
char *key, *val;
- if (parse_cap_name(caps[i], &key, &val)) {
- if (!g_hash_table_insert(server->cap_supported,
- key, val)) {
- /* The specification doesn't say anything about
- * duplicated values, let's just warn the user */
- g_warning("Duplicate value %s", key);
- }
- }
- else {
+ if (!parse_cap_name(caps[i], &key, &val)) {
g_warning("Invalid CAP %s key/value pair", evt);
continue;
}
+
+ if (!g_hash_table_insert(server->cap_supported, key, val)) {
+ /* The specification doesn't say anything about
+ * duplicated values, let's just warn the user */
+ g_warning("Duplicate value %s", key);
+ }
}
/* A multiline response is always terminated by a normal one,
@@ -242,14 +240,12 @@ static void event_cap (IRC_SERVER_REC *server, char *args, char *nick, char *add
for (i = 0; i < caps_length; i++) {
char *key, *val;
- if (parse_cap_name(caps[i], &key, &val)) {
- g_hash_table_insert(server->cap_supported,
- key, val);
- }
- else {
+ if (!parse_cap_name(caps[i], &key, &val)) {
g_warning("Invalid CAP %s key/value pair", evt);
continue;
}
+
+ g_hash_table_insert(server->cap_supported, key, val);
cap_emit_signal(server, "new", key);
}
}
@@ -257,13 +253,12 @@ static void event_cap (IRC_SERVER_REC *server, char *args, char *nick, char *add
for (i = 0; i < caps_length; i++) {
char *key, *val;
- if (parse_cap_name(caps[i], &key, &val)) {
- g_hash_table_remove(server->cap_supported, key);
- }
- else {
+ if (!parse_cap_name(caps[i], &key, &val)) {
g_warning("Invalid CAP %s key/value pair", evt);
continue;
}
+
+ g_hash_table_remove(server->cap_supported, key);
cap_emit_signal(server, "delete", key);
/* The server removed this CAP, remove it from the list
* of the active ones if we had requested it */