remove String::replace, use boost::regex_replace directly
This commit is contained in:
parent
b6d21514e4
commit
385241d2c0
|
@ -201,7 +201,8 @@ TokenList parse(const String& line,
|
||||||
if (opt_token_pos_info)
|
if (opt_token_pos_info)
|
||||||
opt_token_pos_info->push_back({token_start, pos});
|
opt_token_pos_info->push_back({token_start, pos});
|
||||||
String token = line.substr(token_start, pos - token_start);
|
String token = line.substr(token_start, pos - token_start);
|
||||||
token = token.replace(R"(\\([ \t;\n]))", "\\1");
|
static const Regex regex{R"(\\([ \t;\n]))"};
|
||||||
|
token = boost::regex_replace(token, regex, "\\1");
|
||||||
result.push_back({type, token});
|
result.push_back({type, token});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,13 +50,6 @@ std::vector<String> split(const String& str, char separator)
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
String String::replace(const String& expression,
|
|
||||||
const String& replacement) const
|
|
||||||
{
|
|
||||||
boost::regex re(expression);
|
|
||||||
return String(boost::regex_replace(*this, re, replacement));
|
|
||||||
}
|
|
||||||
|
|
||||||
String option_to_string(const Regex& re)
|
String option_to_string(const Regex& re)
|
||||||
{
|
{
|
||||||
return String{re.str()};
|
return String{re.str()};
|
||||||
|
|
|
@ -56,7 +56,7 @@ public:
|
||||||
auto e = utf8::advance(b, end(), (int)length);
|
auto e = utf8::advance(b, end(), (int)length);
|
||||||
return String(b,e);
|
return String(b,e);
|
||||||
}
|
}
|
||||||
String replace(const String& expression, const String& replacement) const;
|
String replace(const Regex& expression, const String& replacement) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline String operator+(const char* lhs, const String& rhs)
|
inline String operator+(const char* lhs, const String& rhs)
|
||||||
|
|
|
@ -218,7 +218,8 @@ bool operator== (const std::unique_ptr<T>& lhs, T* rhs)
|
||||||
|
|
||||||
inline String escape(const String& name)
|
inline String escape(const String& name)
|
||||||
{
|
{
|
||||||
return name.replace("([ \\t;])", R"(\\\1)");
|
static Regex ex{"([ \\t;])"};
|
||||||
|
return boost::regex_replace(name, ex, R"(\\\1)");
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user