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:
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user