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

Function ReplaceAllChars

base/string/algorithm.cpp:82–95  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

80}
81
82size_t ReplaceAllChars(std::string* s, const StringPiece& from, char to)
83{
84 size_t num_replaced = 0;
85 size_t length = s->length();
86 for (size_t i = 0; i < length; ++i)
87 {
88 if (from.find((*s)[i]) != std::string::npos)
89 {
90 (*s)[i] = to;
91 ++num_replaced;
92 }
93 }
94 return num_replaced;
95}
96
97std::string ReplaceAllChars(const StringPiece& s, const StringPiece& from, char to)
98{

Callers 1

TESTFunction · 0.85

Calls 3

findMethod · 0.80
as_stringMethod · 0.80
lengthMethod · 0.45

Tested by 1

TESTFunction · 0.68