MCPcopy Create free account
hub / github.com/chen3feng/toft / RemoveContinuousBlank

Function RemoveContinuousBlank

base/string/algorithm.cpp:182–208  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

180}
181
182void RemoveContinuousBlank(std::string* str)
183{
184 bool first_blank = true;
185 std::string::size_type end_pos = 0;
186 std::string::size_type start_pos = 0;
187 size_t len = str->length();
188
189 for (start_pos = 0; start_pos != len; start_pos++)
190 {
191 if (str->at(start_pos) != ' ')
192 {
193 str->at(end_pos) = str->at(start_pos);
194 end_pos++;
195 first_blank = true;
196 }
197 else
198 {
199 if (first_blank)
200 {
201 str->at(end_pos) = str->at(start_pos);
202 end_pos++;
203 first_blank = false;
204 }
205 }
206 }
207 str->resize(end_pos);
208}
209
210std::string RemoveContinuousBlank(const StringPiece& str)
211{

Callers 1

TESTFunction · 0.85

Calls 3

resizeMethod · 0.80
as_stringMethod · 0.80
lengthMethod · 0.45

Tested by 1

TESTFunction · 0.68