MCPcopy Create free account
hub / github.com/apache/brpc / DoReplaceSubstringsAfterOffset

Function DoReplaceSubstringsAfterOffset

src/butil/strings/string_util.cc:513–530  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

511
512template<class StringType>
513void DoReplaceSubstringsAfterOffset(StringType* str,
514 size_t start_offset,
515 const StringType& find_this,
516 const StringType& replace_with,
517 bool replace_all) {
518 if ((start_offset == StringType::npos) || (start_offset >= str->length()))
519 return;
520
521 DCHECK(!find_this.empty());
522 for (size_t offs(str->find(find_this, start_offset));
523 offs != StringType::npos; offs = str->find(find_this, offs)) {
524 str->replace(offs, find_this.length(), replace_with);
525 offs += replace_with.length();
526
527 if (!replace_all)
528 break;
529 }
530}
531
532void ReplaceFirstSubstringAfterOffset(string16* str,
533 size_t start_offset,

Callers 2

Calls 3

lengthMethod · 0.45
emptyMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected