diff options
author | Loïc Blot <nerzhul@users.noreply.github.com> | 2017-08-20 13:30:50 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-20 13:30:50 +0200 |
commit | 1c1c97cbd1d7913ac12bf550ec02c97f843a0fd3 (patch) | |
tree | 03dd0c39e323c7f0b1f06014ff30e74f429bfa01 /src/util/string.h | |
parent | 50669cd2822a11570ae462972194eeb2d585a8c1 (diff) | |
download | minetest-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.h')
-rw-r--r-- | src/util/string.h | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/util/string.h b/src/util/string.h index 584ffb73a..122262af8 100644 --- a/src/util/string.h +++ b/src/util/string.h @@ -20,7 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #pragma once #include "irrlichttypes_bloated.h" -#include <stdlib.h> +#include <cstdlib> #include <string> #include <cstring> #include <vector> @@ -231,12 +231,12 @@ inline std::vector<std::basic_string<T> > str_split( */ inline std::string lowercase(const std::string &str) { - std::string s2 = ""; + std::string s2; s2.reserve(str.size()); - for (size_t i = 0; i < str.size(); i++) - s2 += tolower(str[i]); + for (char i : str) + s2 += tolower(i); return s2; } @@ -607,8 +607,8 @@ std::vector<std::basic_string<T> > split(const std::basic_string<T> &s, T delim) */ inline bool is_number(const std::string &to_check) { - for (size_t i = 0; i < to_check.size(); i++) - if (!std::isdigit(to_check[i])) + for (char i : to_check) + if (!std::isdigit(i)) return false; return !to_check.empty(); |