Game Events: removed an unnecessary getter
Bad design to return mutable reference to static object. This method has the possibility of creating a new default entry in the by_name map, but the remove call will be a no-op in that case (as it was before), so no harm done.
This commit is contained in:
parent
20e61d67ff
commit
a25d28e637
2 changed files with 1 additions and 17 deletions
|
@ -81,19 +81,6 @@ bool event_handlers::cmp(const handler_ptr lhs, const handler_ptr rhs)
|
|||
return lhs->priority() < rhs->priority();
|
||||
}
|
||||
|
||||
/**
|
||||
* Read-only access to the handlers with fixed event names, by event name.
|
||||
*/
|
||||
handler_list& event_handlers::get(const std::string& name)
|
||||
{
|
||||
// Empty list for the "not found" case.
|
||||
static handler_list empty_list;
|
||||
|
||||
// Look for the name in the name map.
|
||||
auto find_it = by_name_.find(standardize_name(name));
|
||||
return find_it == by_name_.end() ? empty_list : find_it->second;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an event handler.
|
||||
* An event with a nonempty ID will not be added if an event with that
|
||||
|
@ -210,7 +197,7 @@ void event_handlers::clean_up_expired_handlers(const std::string& event_name)
|
|||
// Then remove any now-unlockable weak_ptrs from the by-name list.
|
||||
// Might be more than one so we split.
|
||||
for(const std::string& name : utils::split(event_name)) {
|
||||
get(name).remove_if(
|
||||
by_name_[standardize_name(name)].remove_if(
|
||||
[](weak_handler_ptr ptr) { return ptr.expired(); }
|
||||
);
|
||||
}
|
||||
|
|
|
@ -112,9 +112,6 @@ public:
|
|||
return active_;
|
||||
}
|
||||
|
||||
/** Access to the handlers with fixed event names, by event name. */
|
||||
handler_list& get(const std::string& name);
|
||||
|
||||
/** Adds an event handler. */
|
||||
pending_event_handler add_event_handler(const std::string& name, const std::string& id, bool repeat, double priority = 0., bool is_menu_item = false);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue