Use StringView in id_map

This commit is contained in:
Maxime Coste 2014-04-21 10:47:21 +01:00
parent 5ebd588e5f
commit a1ec45d91a

View File

@ -28,7 +28,7 @@ public:
m_content.push_back(std::move(value)); m_content.push_back(std::move(value));
} }
iterator find(const String& id) iterator find(StringView id)
{ {
for (auto it = begin(); it != end(); ++it) for (auto it = begin(); it != end(); ++it)
{ {
@ -38,7 +38,7 @@ public:
return end(); return end();
} }
const_iterator find(const String& id) const const_iterator find(StringView id) const
{ {
for (auto it = begin(); it != end(); ++it) for (auto it = begin(); it != end(); ++it)
{ {
@ -48,19 +48,19 @@ public:
return end(); return end();
} }
bool contains(const String& id) const bool contains(StringView id) const
{ {
return find(id) != end(); return find(id) != end();
} }
void remove(const String& id) void remove(StringView id)
{ {
auto it = find(id); auto it = find(id);
if (it != end()) if (it != end())
m_content.erase(it); m_content.erase(it);
} }
void remove_all(const String& id) void remove_all(StringView id)
{ {
for (auto it = find(id); it != end(); it = find(id)) for (auto it = find(id); it != end(); it = find(id))
m_content.erase(it); m_content.erase(it);