Skip to content

Commit 8ac526e

Browse files
committed
Avoid std::string copy in ssplit argument
- Other minor changes reported by sonarcloud
1 parent cc0f893 commit 8ac526e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/utils/string.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,15 @@ const char HEX2DEC[256] = {
5959
};
6060

6161

62-
inline std::string ascTime(time_t *t) {
62+
inline std::string ascTime(const time_t *t) {
6363
std::string ts = std::ctime(t);
6464
ts.pop_back();
6565
return ts;
6666
}
6767

6868

6969
inline std::string dash_if_empty(const std::string *str) {
70-
if (str == NULL || str->empty()) {
70+
if (str == nullptr || str->empty()) {
7171
return "-";
7272
}
7373

@@ -107,7 +107,7 @@ inline std::string toHexIfNeeded(const std::string &str, bool escape_spec = fals
107107
}
108108

109109

110-
inline std::vector<std::string> ssplit(std::string str, char delimiter) {
110+
inline std::vector<std::string> ssplit(const std::string &str, char delimiter) {
111111
std::vector<std::string> internal;
112112
std::stringstream ss(str); // Turn the string into a stream.
113113
std::string tok;
@@ -134,10 +134,10 @@ inline std::pair<std::string, std::string> ssplit_pair(const std::string& str, c
134134
}
135135

136136

137-
inline std::vector<std::string> split(std::string str, char delimiter) {
137+
inline std::vector<std::string> split(const std::string &str, char delimiter) {
138138
std::vector<std::string> internal = ssplit(str, delimiter);
139139

140-
if (internal.size() == 0) {
140+
if (internal.empty()) {
141141
internal.push_back(str);
142142
}
143143

0 commit comments

Comments
 (0)