summaryrefslogtreecommitdiff
path: root/src/event_manager.h
diff options
context:
space:
mode:
authorLoïc Blot <nerzhul@users.noreply.github.com>2017-08-20 13:30:50 +0200
committerGitHub <noreply@github.com>2017-08-20 13:30:50 +0200
commit1c1c97cbd1d7913ac12bf550ec02c97f843a0fd3 (patch)
tree03dd0c39e323c7f0b1f06014ff30e74f429bfa01 /src/event_manager.h
parent50669cd2822a11570ae462972194eeb2d585a8c1 (diff)
downloadminetest-1c1c97cbd1d7913ac12bf550ec02c97f843a0fd3.tar.gz
minetest-1c1c97cbd1d7913ac12bf550ec02c97f843a0fd3.tar.bz2
minetest-1c1c97cbd1d7913ac12bf550ec02c97f843a0fd3.zip
Modernize source code: last part (#6285)
* Modernize source code: last par * Use empty when needed * Use emplace_back instead of push_back when needed * For range-based loops * Initializers fixes * constructors, destructors default * c++ C stl includes
Diffstat (limited to 'src/event_manager.h')
-rw-r--r--src/event_manager.h19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/event_manager.h b/src/event_manager.h
index 54cd728bd..f64d05869 100644
--- a/src/event_manager.h
+++ b/src/event_manager.h
@@ -43,17 +43,15 @@ class EventManager: public MtEventManager
std::map<std::string, Dest> m_dest;
public:
- ~EventManager()
- {
- }
+ ~EventManager() = default;
+
void put(MtEvent *e)
{
std::map<std::string, Dest>::iterator i = m_dest.find(e->getType());
if(i != m_dest.end()){
std::list<FuncSpec> &funcs = i->second.funcs;
- for(std::list<FuncSpec>::iterator i = funcs.begin();
- i != funcs.end(); ++i){
- (*(i->f))(e, i->d);
+ for (FuncSpec &func : funcs) {
+ (*(func.f))(e, func.d);
}
}
delete e;
@@ -62,11 +60,11 @@ public:
{
std::map<std::string, Dest>::iterator i = m_dest.find(type);
if(i != m_dest.end()){
- i->second.funcs.push_back(FuncSpec(f, data));
+ i->second.funcs.emplace_back(f, data);
} else{
std::list<FuncSpec> funcs;
Dest dest;
- dest.funcs.push_back(FuncSpec(f, data));
+ dest.funcs.emplace_back(f, data);
m_dest[type] = dest;
}
}
@@ -86,9 +84,8 @@ public:
}
}
} else{
- for(std::map<std::string, Dest>::iterator
- i = m_dest.begin(); i != m_dest.end(); ++i){
- std::list<FuncSpec> &funcs = i->second.funcs;
+ for (auto &dest : m_dest) {
+ std::list<FuncSpec> &funcs = dest.second.funcs;
std::list<FuncSpec>::iterator j = funcs.begin();
while(j != funcs.end()){
bool remove = (j->f == f && (!data || j->d == data));