diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-11-04 20:10:20 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-11-04 20:10:20 +0000 |
commit | d2858a7fef3b79075ee59b68b3d4c2ebcd4900c4 (patch) | |
tree | 4d02c821d71051b343d5f622a1ad44e3dd9a2d58 /include/modules.h | |
parent | 051aa21ed3c4583d19862055e2128b418adea633 (diff) |
Remove some now redundant if (!empty) checks in FOREACH_MOD
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8520 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'include/modules.h')
-rw-r--r-- | include/modules.h | 48 |
1 files changed, 22 insertions, 26 deletions
diff --git a/include/modules.h b/include/modules.h index c0e2adada..a8bc9f507 100644 --- a/include/modules.h +++ b/include/modules.h @@ -123,18 +123,16 @@ typedef std::map<std::string, std::pair<int, modulelist> > interfacelist; * loaded modules in a readable simple way, e.g.: * 'FOREACH_MOD(I_OnConnect,OnConnect(user));' */ -#define FOREACH_MOD(y,x) if (!ServerInstance->Modules->EventHandlers[y].empty()) \ +#define FOREACH_MOD(y,x) \ +for (EventHandlerIter _i = ServerInstance->Modules->EventHandlers[y].begin(); _i != ServerInstance->Modules->EventHandlers[y].end(); ++_i) \ { \ - for (EventHandlerIter _i = ServerInstance->Modules->EventHandlers[y].begin(); _i != ServerInstance->Modules->EventHandlers[y].end(); ++_i) \ + try \ { \ - try \ - { \ - (*_i)->x ; \ - } \ - catch (CoreException& modexcept) \ - { \ - ServerInstance->Log(DEFAULT,"Exception caught: %s",modexcept.GetReason()); \ - } \ + (*_i)->x ; \ + } \ + catch (CoreException& modexcept) \ + { \ + ServerInstance->Log(DEFAULT,"Exception caught: %s",modexcept.GetReason()); \ } \ } @@ -144,18 +142,16 @@ typedef std::map<std::string, std::pair<int, modulelist> > interfacelist; * an instance pointer to the macro. e.g.: * 'FOREACH_MOD_I(Instance, OnConnect, OnConnect(user));' */ -#define FOREACH_MOD_I(z,y,x) if (!z->Modules->EventHandlers[y].empty()) \ +#define FOREACH_MOD_I(z,y,x) \ +for (EventHandlerIter _i = z->Modules->EventHandlers[y].begin(); _i != z->Modules->EventHandlers[y].end(); ++_i) \ { \ - for (EventHandlerIter _i = z->Modules->EventHandlers[y].begin(); _i != z->Modules->EventHandlers[y].end(); ++_i) \ + try \ { \ - try \ - { \ - (*_i)->x ; \ - } \ - catch (CoreException& modexcept) \ - { \ - z->Log(DEFAULT,"Exception caught: %s",modexcept.GetReason()); \ - } \ + (*_i)->x ; \ + } \ + catch (CoreException& modexcept) \ + { \ + z->Log(DEFAULT,"Exception caught: %s",modexcept.GetReason()); \ } \ } @@ -164,8 +160,8 @@ typedef std::map<std::string, std::pair<int, modulelist> > interfacelist; * The first module to return a nonzero result is the value to be accepted, * and any modules after are ignored. */ -#define FOREACH_RESULT(y,x) if (!ServerInstance->Modules->EventHandlers[y].empty()) \ -{ \ +#define FOREACH_RESULT(y,x) \ +do { \ MOD_RESULT = 0; \ for (EventHandlerIter _i = ServerInstance->Modules->EventHandlers[y].begin(); _i != ServerInstance->Modules->EventHandlers[y].end(); ++_i) \ { \ @@ -182,7 +178,7 @@ typedef std::map<std::string, std::pair<int, modulelist> > interfacelist; ServerInstance->Log(DEFAULT,"Exception caught: %s",modexcept.GetReason()); \ } \ } \ -} +} while(0); /** @@ -190,8 +186,8 @@ typedef std::map<std::string, std::pair<int, modulelist> > interfacelist; * The first module to return a nonzero result is the value to be accepted, * and any modules after are ignored. */ -#define FOREACH_RESULT_I(z,y,x) if (!z->Modules->EventHandlers[y].empty()) \ -{ \ +#define FOREACH_RESULT_I(z,y,x) \ +do { \ MOD_RESULT = 0; \ for (EventHandlerIter _i = z->Modules->EventHandlers[y].begin(); _i != z->Modules->EventHandlers[y].end(); ++_i) \ { \ @@ -208,7 +204,7 @@ typedef std::map<std::string, std::pair<int, modulelist> > interfacelist; z->Log(DEBUG,"Exception caught: %s",modexcept.GetReason()); \ } \ } \ -} +} while (0); /** Represents a non-local user. * (in fact, any FD less than -1 does) |