diff options
author | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2011-10-19 22:56:32 +0200 |
---|---|---|
committer | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2011-10-20 23:10:40 +0200 |
commit | 4e49081ca1f0d658308582ef3084837bb58c33ec (patch) | |
tree | 85ab83e760a3bd017a1ef1ab2054eef049aa0f8e /src/game-server/map.h | |
parent | 03ff7c110e536de1f8b239817e50cb07c492da6f (diff) | |
download | manaserv-4e49081ca1f0d658308582ef3084837bb58c33ec.tar.gz manaserv-4e49081ca1f0d658308582ef3084837bb58c33ec.tar.bz2 manaserv-4e49081ca1f0d658308582ef3084837bb58c33ec.tar.xz manaserv-4e49081ca1f0d658308582ef3084837bb58c33ec.zip |
Return a const & from NameMap to avoid potential deep copies
When I introduced NameMap it was only used with pointers, but now it is
also used with std::string so it probably makes sense to keep a default-
constructed value around so that a reference can be returned rather than
a copy.
NameMap::find was renamed to NameMap::value to make it more clear that
it doesn't return an iterator, like std::map::find.
Reviewed-by: Yohann Ferreira
Reviewed-by: Ben Longbons
Diffstat (limited to 'src/game-server/map.h')
-rw-r--r-- | src/game-server/map.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/game-server/map.h b/src/game-server/map.h index eca36863..28faed7f 100644 --- a/src/game-server/map.h +++ b/src/game-server/map.h @@ -80,8 +80,8 @@ class MapObject mProperties.insert(key, value); } - std::string getProperty(const std::string &key) const - { return mProperties.find(key); } + const std::string &getProperty(const std::string &key) const + { return mProperties.value(key); } const std::string &getName() const { return mName; } |