mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-13 16:45:20 +02:00
Code modernization: src/m* (part 3)
* empty function * default constructor/destructor * for range-based loops * use emplace_back instead of push_back * remove some unused headers in some cpp variable
This commit is contained in:
@@ -18,12 +18,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
*/
|
||||
|
||||
#include "metadata.h"
|
||||
#include "exceptions.h"
|
||||
#include "gamedef.h"
|
||||
#include "log.h"
|
||||
#include <sstream>
|
||||
#include "constants.h" // MAP_BLOCKSIZE
|
||||
#include <sstream>
|
||||
|
||||
/*
|
||||
Metadata
|
||||
@@ -36,7 +31,7 @@ void Metadata::clear()
|
||||
|
||||
bool Metadata::empty() const
|
||||
{
|
||||
return m_stringvars.size() == 0;
|
||||
return m_stringvars.empty();
|
||||
}
|
||||
|
||||
size_t Metadata::size() const
|
||||
@@ -54,10 +49,9 @@ bool Metadata::operator==(const Metadata &other) const
|
||||
if (size() != other.size())
|
||||
return false;
|
||||
|
||||
for (StringMap::const_iterator it = m_stringvars.begin();
|
||||
it != m_stringvars.end(); ++it) {
|
||||
if (!other.contains(it->first) ||
|
||||
other.getString(it->first) != it->second)
|
||||
for (const auto &sv : m_stringvars) {
|
||||
if (!other.contains(sv.first) ||
|
||||
other.getString(sv.first) != sv.second)
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -102,7 +96,7 @@ const std::string &Metadata::resolveString(const std::string &str, u16 recursion
|
||||
{
|
||||
if (recursion <= 1 && str.substr(0, 2) == "${" && str[str.length() - 1] == '}') {
|
||||
return getString(str.substr(2, str.length() - 3), recursion + 1);
|
||||
} else {
|
||||
return str;
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
Reference in New Issue
Block a user