diff options
author | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2012-03-02 20:43:10 +0100 |
---|---|---|
committer | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2012-03-18 19:58:55 +0100 |
commit | bce577e663e28e1942fda371235eba091a6ea8e2 (patch) | |
tree | a54ce0b47eae92b760ddd763036ff3609d1415ef /src/utils/stringutils.cpp | |
parent | 20afba1adc84dd0e859605250c5a44a111045c2b (diff) | |
download | mana-bce577e663e28e1942fda371235eba091a6ea8e2.tar.gz mana-bce577e663e28e1942fda371235eba091a6ea8e2.tar.bz2 mana-bce577e663e28e1942fda371235eba091a6ea8e2.tar.xz mana-bce577e663e28e1942fda371235eba091a6ea8e2.zip |
Removed some 'const' keywords from value returns
It makes no sense to mark a return value as const when it is returned by
value. This only makes sense if the return value is passed by reference, in
order to prevent the receiver from modifying the value.
Also made some other small adjustments. A std::string does not need to be
initialized to "" explicitly and getSafeUtf8String could take its parameter by
reference.
Reviewed-by: Yohann Ferreira
Diffstat (limited to 'src/utils/stringutils.cpp')
-rw-r--r-- | src/utils/stringutils.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp index 5a51ef66..4f27d41b 100644 --- a/src/utils/stringutils.cpp +++ b/src/utils/stringutils.cpp @@ -157,8 +157,8 @@ bool isWordSeparator(char chr) return (chr == ' ' || chr == ',' || chr == '.' || chr == '"'); } -const std::string findSameSubstring(const std::string &str1, - const std::string &str2) +std::string findSameSubstring(const std::string &str1, + const std::string &str2) { int minLength = str1.length() > str2.length() ? str2.length() : str1.length(); for (int f = 0; f < minLength; f ++) @@ -171,9 +171,9 @@ const std::string findSameSubstring(const std::string &str1, return str1.substr(0, minLength); } -const char* getSafeUtf8String(std::string text) +const char *getSafeUtf8String(const std::string &text) { - char* buf = new char[text.size() + UTF8_MAX_SIZE]; + char *buf = new char[text.size() + UTF8_MAX_SIZE]; memcpy(buf, text.c_str(), text.size()); memset(buf + text.size(), 0, UTF8_MAX_SIZE); return buf; |