MCPcopy Create free account
hub / github.com/PaddlePaddle/Paddle / trim_spaces

Function trim_spaces

paddle/utils/string/string_helper.cc:26–40  ·  view source on GitHub ↗

remove leading and tailing spaces

Source from the content-addressed store, hash-verified

24
25// remove leading and tailing spaces
26std::string trim_spaces(const std::string& str) {
27 const char* p = str.c_str();
28
29 while (*p != 0 && isspace(*p)) {
30 p++;
31 }
32
33 size_t len = strlen(p);
34
35 while (len > 0 && isspace(p[len - 1])) {
36 len--;
37 }
38
39 return std::string(p, len);
40}
41
42std::string erase_spaces(const std::string& str) {
43 std::string result;

Callers

nothing calls this directly

Calls 2

strlenFunction · 0.85
c_strMethod · 0.80

Tested by

no test coverage detected