mirror of
https://github.com/irssi/irssi.git
synced 2025-01-03 14:56:47 -05:00
Simplify the code
Early exit, simpler code.
This commit is contained in:
parent
9160ddaffd
commit
c00132ac4c
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user