MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / StringReplace

Function StringReplace

tensorflow/core/framework/op_gen_lib.cc:252–271  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

250}
251
252static void StringReplace(const string& from, const string& to, string* s) {
253 // Split *s into pieces delimited by `from`.
254 std::vector<string> split;
255 string::size_type pos = 0;
256 while (pos < s->size()) {
257 auto found = s->find(from, pos);
258 if (found == string::npos) {
259 split.push_back(s->substr(pos));
260 break;
261 } else {
262 split.push_back(s->substr(pos, found - pos));
263 pos = found + from.size();
264 if (pos == s->size()) { // handle case where `from` is at the very end.
265 split.push_back("");
266 }
267 }
268 }
269 // Join the pieces back together with a new delimiter.
270 *s = absl::StrJoin(split, to);
271}
272
273static void RenameInDocs(const string& from, const string& to,
274 ApiDef* api_def) {

Callers 1

RenameInDocsFunction · 0.70

Calls 3

sizeMethod · 0.45
findMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected