MCPcopy Create free account
hub / github.com/appdevforall/CodeOnTheGo / string_replace_all

Function string_replace_all

subprojects/llama.cpp/common/common.cpp:442–457  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

440}
441
442void string_replace_all(std::string & s, const std::string & search, const std::string & replace) {
443 if (search.empty()) {
444 return;
445 }
446 std::string builder;
447 builder.reserve(s.length());
448 size_t pos = 0;
449 size_t last_pos = 0;
450 while ((pos = s.find(search, last_pos)) != std::string::npos) {
451 builder.append(s, last_pos, pos - last_pos);
452 builder.append(replace);
453 last_pos = pos + search.length();
454 }
455 builder.append(s, last_pos, std::string::npos);
456 s = std::move(builder);
457}
458
459bool string_ends_with(const std::string_view & str, const std::string_view & suffix) {
460 return str.size() >= suffix.size() && str.compare(str.size()-suffix.size(), suffix.size(), suffix) == 0;

Callers 9

to_iniMethod · 0.70
load_from_models_dirMethod · 0.70
get_value_from_envMethod · 0.70
has_value_from_envMethod · 0.70
get_envMethod · 0.70
clean_file_nameFunction · 0.70
get_manifest_pathFunction · 0.70

Calls 4

emptyMethod · 0.65
lengthMethod · 0.65
findMethod · 0.65
appendMethod · 0.65

Tested by

no test coverage detected