summaryrefslogtreecommitdiff
path: root/src/util/string.cpp
diff options
context:
space:
mode:
authorLoïc Blot <nerzhul@users.noreply.github.com>2017-08-20 13:30:50 +0200
committerGitHub <noreply@github.com>2017-08-20 13:30:50 +0200
commit1c1c97cbd1d7913ac12bf550ec02c97f843a0fd3 (patch)
tree03dd0c39e323c7f0b1f06014ff30e74f429bfa01 /src/util/string.cpp
parent50669cd2822a11570ae462972194eeb2d585a8c1 (diff)
downloadminetest-1c1c97cbd1d7913ac12bf550ec02c97f843a0fd3.tar.gz
minetest-1c1c97cbd1d7913ac12bf550ec02c97f843a0fd3.tar.bz2
minetest-1c1c97cbd1d7913ac12bf550ec02c97f843a0fd3.zip
Modernize source code: last part (#6285)
* Modernize source code: last par * Use empty when needed * Use emplace_back instead of push_back when needed * For range-based loops * Initializers fixes * constructors, destructors default * c++ C stl includes
Diffstat (limited to 'src/util/string.cpp')
-rw-r--r--src/util/string.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/util/string.cpp b/src/util/string.cpp
index d41b91f24..fc2a2057f 100644
--- a/src/util/string.cpp
+++ b/src/util/string.cpp
@@ -167,7 +167,7 @@ std::string wide_to_utf8(const std::wstring &input)
wchar_t *utf8_to_wide_c(const char *str)
{
- std::wstring ret = utf8_to_wide(std::string(str)).c_str();
+ std::wstring ret = utf8_to_wide(std::string(str));
size_t len = ret.length();
wchar_t *ret_c = new wchar_t[len + 1];
memset(ret_c, 0, (len + 1) * sizeof(wchar_t));
@@ -308,8 +308,8 @@ std::string wide_to_narrow(const std::wstring &wcs)
size_t len = wcstombs(*mbs, wcs.c_str(), mbl);
if (len == (size_t)(-1))
return "Character conversion failed!";
- else
- mbs[len] = 0;
+
+ mbs[len] = 0;
return *mbs;
}
@@ -321,8 +321,7 @@ std::string urlencode(const std::string &str)
// followed by two hex digits. See RFC 3986, section 2.3.
static const char url_hex_chars[] = "0123456789ABCDEF";
std::ostringstream oss(std::ios::binary);
- for (u32 i = 0; i < str.size(); i++) {
- unsigned char c = str[i];
+ for (unsigned char c : str) {
if (isalnum(c) || c == '-' || c == '.' || c == '_' || c == '~') {
oss << c;
} else {