@@ -59,15 +59,15 @@ const char HEX2DEC[256] = {
59
59
};
60
60
61
61
62
- inline std::string ascTime (time_t *t) {
62
+ inline std::string ascTime (const time_t *t) {
63
63
std::string ts = std::ctime (t);
64
64
ts.pop_back ();
65
65
return ts;
66
66
}
67
67
68
68
69
69
inline std::string dash_if_empty (const std::string *str) {
70
- if (str == NULL || str->empty ()) {
70
+ if (str == nullptr || str->empty ()) {
71
71
return " -" ;
72
72
}
73
73
@@ -107,7 +107,7 @@ inline std::string toHexIfNeeded(const std::string &str, bool escape_spec = fals
107
107
}
108
108
109
109
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) {
111
111
std::vector<std::string> internal;
112
112
std::stringstream ss (str); // Turn the string into a stream.
113
113
std::string tok;
@@ -134,21 +134,21 @@ inline std::pair<std::string, std::string> ssplit_pair(const std::string& str, c
134
134
}
135
135
136
136
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) {
138
138
std::vector<std::string> internal = ssplit (str, delimiter);
139
139
140
- if (internal.size () == 0 ) {
140
+ if (internal.empty () ) {
141
141
internal.push_back (str);
142
142
}
143
143
144
144
return internal;
145
145
}
146
146
147
147
148
- inline void chomp (std::string * str) {
149
- std::string::size_type pos = str-> find_last_not_of (" \n\r " );
148
+ inline void chomp (std::string & str) {
149
+ std::string::size_type pos = str. find_last_not_of (" \n\r " );
150
150
if (pos != std::string::npos) {
151
- str-> erase (pos+1 , str-> length ()-pos-1 );
151
+ str. erase (pos+1 , str. length ()-pos-1 );
152
152
}
153
153
}
154
154
@@ -194,24 +194,24 @@ inline std::string parserSanitizer(std::string a) {
194
194
}
195
195
196
196
197
- inline unsigned char x2c (const unsigned char *what) {
197
+ /* *
198
+ * Converts a single hexadecimal digit into a decimal value.
199
+ */
200
+ inline unsigned char xsingle2c (const unsigned char *what) {
198
201
unsigned char digit;
199
202
200
203
digit = (what[0 ] >= ' A' ? ((what[0 ] & 0xdf ) - ' A' ) + 10 : (what[0 ] - ' 0' ));
201
- digit *= 16 ;
202
- digit += (what[1 ] >= ' A' ? ((what[1 ] & 0xdf ) - ' A' ) + 10 : (what[1 ] - ' 0' ));
203
204
204
205
return digit;
205
206
}
206
207
207
208
208
- /* *
209
- * Converts a single hexadecimal digit into a decimal value.
210
- */
211
- inline unsigned char xsingle2c (const unsigned char *what) {
209
+ inline unsigned char x2c (const unsigned char *what) {
212
210
unsigned char digit;
213
211
214
- digit = (what[0 ] >= ' A' ? ((what[0 ] & 0xdf ) - ' A' ) + 10 : (what[0 ] - ' 0' ));
212
+ digit = xsingle2c (what);
213
+ digit *= 16 ;
214
+ digit += xsingle2c (what+1 );
215
215
216
216
return digit;
217
217
}
0 commit comments