1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-08 02:33:12 +02:00

core: optimize xxx_valid() functions: return immediately if pointer is NULL

This commit is contained in:
Sebastien Helleu
2014-01-09 19:28:51 +01:00
parent 73eb2564f3
commit 02868b4dc0
5 changed files with 9 additions and 3 deletions
+3
View File
@@ -344,6 +344,9 @@ hook_valid (struct t_hook *hook)
int type;
struct t_hook *ptr_hook;
if (!hook)
return 0;
for (type = 0; type < HOOK_NUM_TYPES; type++)
{
for (ptr_hook = weechat_hooks[type]; ptr_hook;
+3
View File
@@ -287,6 +287,9 @@ infolist_valid (struct t_infolist *infolist)
{
struct t_infolist *ptr_infolist;
if (!infolist)
return 0;
for (ptr_infolist = weechat_infolists; ptr_infolist;
ptr_infolist = ptr_infolist->next_infolist)
{
+1 -1
View File
@@ -51,7 +51,7 @@ irc_channel_valid (struct t_irc_server *server, struct t_irc_channel *channel)
{
struct t_irc_channel *ptr_channel;
if (!server)
if (!server || !channel)
return 0;
for (ptr_channel = server->channels; ptr_channel;
+1 -1
View File
@@ -48,7 +48,7 @@ irc_nick_valid (struct t_irc_channel *channel, struct t_irc_nick *nick)
{
struct t_irc_nick *ptr_nick;
if (!channel)
if (!channel || !nick)
return 0;
for (ptr_nick = channel->nicks; ptr_nick; ptr_nick = ptr_nick->next_nick)
+1 -1
View File
@@ -256,7 +256,7 @@ plugin_script_valid (struct t_plugin_script *scripts,
{
struct t_plugin_script *ptr_script;
if (!script)
if (!scripts || !script)
return 0;
for (ptr_script = scripts; ptr_script;