diff --git a/Foundation/include/Poco/ListMap.h b/Foundation/include/Poco/ListMap.h index ee2f5266f..932e6f6b0 100644 --- a/Foundation/include/Poco/ListMap.h +++ b/Foundation/include/Poco/ListMap.h @@ -37,7 +37,7 @@ class ListMap /// ordering of elements is not desirable. Naturally, this container will /// have inferior data retrieval performance and it is not recommended for /// use with large datasets. The main purpose within POCO is for Internet - /// messages (email message, http headers etc), to prevent autmomatic + /// messages (email message, http headers etc), to prevent automatic /// header entry reordering. { public: @@ -103,33 +103,33 @@ public: } ConstIterator find(const KeyType& key) const - /// Finds the first occurence of the key and + /// Finds the first occurrence of the key and /// returns iterator pointing to the found entry /// or iterator pointing to the end if entry is /// not found. { typename Container::const_iterator it = _list.begin(); - typename Container::const_iterator end = _list.end(); - for(; it != end; ++it) + typename Container::const_iterator itEnd = _list.end(); + for(; it != itEnd; ++it) { if (isEqual(it->first, key)) return it; } - return end; + return itEnd; } Iterator find(const KeyType& key) - /// Finds the first occurence of the key and + /// Finds the first occurrence of the key and /// returns iterator pointing to the found entry /// or iterator pointing to the end if entry is /// not found. { typename Container::iterator it = _list.begin(); - typename Container::iterator end = _list.end(); - for(; it != end; ++it) + typename Container::iterator itEnd = _list.end(); + for(; it != itEnd; ++it) { if (isEqual(it->first, key)) return it; } - return end; + return itEnd; } Iterator insert(const ValueType& val) @@ -140,24 +140,8 @@ public: /// Returns iterator pointing to the newly inserted value { Iterator it = find(val.first); - - while (it != _list.end() && isEqual(it->first, val.first)) - { - ++it; - } - - if (it == _list.end()) - { - _list.push_back(val); - it = _list.end(); - --it; - } - else - { - _list.insert(it, 1, val); - } - - return it; + while (it != _list.end() && isEqual(it->first, val.first)) ++it; + return _list.insert(it, val); } void erase(Iterator it) @@ -219,8 +203,8 @@ public: else { ValueType value(key, Mapped()); - Iterator it = insert(value); - return it->second; + Iterator itInsert = insert(value); + return itInsert->second; } }