Changeset - r27321:bd1380ce5d71
[Not reviewed]
master
0 1 0
Peter Nelson - 16 months ago 2023-05-09 20:51:46
peter1138@openttd.org
Codechange: Use find_if when finding things.
1 file changed with 1 insertions and 5 deletions:
0 comments (0 inline, 0 general)
src/core/smallmap_type.hpp
Show inline comments
 
@@ -37,17 +37,13 @@ struct SmallMap : std::vector<std::pair<
 
	 * Finds given key in this map
 
	 * @param key key to find
 
	 * @return &Pair(key, data) if found, this->End() if not
 
	 */
 
	inline typename std::vector<Pair>::const_iterator Find(const T &key) const
 
	{
 
		typename std::vector<Pair>::const_iterator it;
 
		for (it = std::vector<Pair>::begin(); it != std::vector<Pair>::end(); it++) {
 
			if (key == it->first) return it;
 
		}
 
		return it;
 
		return std::find_if(std::vector<Pair>::begin(), std::vector<Pair>::end(), [&key](const Pair &pair) { return key == pair.first; });
 
	}
 

	
 
	/**
 
	 * Finds given key in this map
 
	 * @param key key to find
 
	 * @return &Pair(key, data) if found, this->End() if not
0 comments (0 inline, 0 general)