mirror of
https://github.com/LostRuins/koboldcpp.git
synced 2025-09-09 16:44:35 +00:00
llama : better replace_all (cont) (#8926)
* llama : better replace_all (cont) ggml-ci * code : deduplicate replace_all ggml-ci
This commit is contained in:
parent
3071c0a5f2
commit
45a55b91aa
7 changed files with 35 additions and 49 deletions
|
@ -121,17 +121,6 @@ static std::string trim(const std::string & str) {
|
|||
return str.substr(start, end - start);
|
||||
}
|
||||
|
||||
static void replace_all(std::string & s, const std::string & search, const std::string & replace) {
|
||||
if (search.empty()) {
|
||||
return; // Avoid infinite loop if 'search' is an empty string
|
||||
}
|
||||
size_t pos = 0;
|
||||
while ((pos = s.find(search, pos)) != std::string::npos) {
|
||||
s.replace(pos, search.length(), replace);
|
||||
pos += replace.length();
|
||||
}
|
||||
}
|
||||
|
||||
static bool is_float_close(float a, float b, float abs_tol) {
|
||||
// Check for non-negative tolerance
|
||||
if (abs_tol < 0.0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue