Fix ilike cache

This commit is contained in:
alesapin 2020-10-02 17:27:47 +03:00
parent c0d1416bbd
commit 8c0581c503
2 changed files with 10 additions and 10 deletions

View File

@ -141,10 +141,7 @@ struct MatchImpl
{ {
size_t size = offsets.size(); size_t size = offsets.size();
constexpr int flags = case_insensitive ? auto regexp = Regexps::get<like, true, case_insensitive>(pattern);
Regexps::Regexp::RE_CASELESS : 0;
auto regexp = Regexps::get<like, true>(pattern, flags);
std::string required_substring; std::string required_substring;
bool is_trivial; bool is_trivial;

View File

@ -58,21 +58,24 @@ namespace Regexps
* You must hold the ownership while using the object. * You must hold the ownership while using the object.
* In destructor, it returns the object back to the Pool for further reuse. * In destructor, it returns the object back to the Pool for further reuse.
*/ */
template <bool like, bool no_capture> template <bool like, bool no_capture, bool case_insensitive = false>
inline Pool::Pointer get(const std::string & pattern, int flags = 0) inline Pool::Pointer get(const std::string & pattern)
{ {
/// C++11 has thread-safe function-local statics on most modern compilers. /// C++11 has thread-safe function-local statics on most modern compilers.
static Pool known_regexps; /// Different variables for different pattern parameters. static Pool known_regexps; /// Different variables for different pattern parameters.
return known_regexps.get(pattern, [flags, &pattern] return known_regexps.get(pattern, [&pattern]
{ {
int flags_final = flags | OptimizedRegularExpression::RE_DOT_NL; int flags = OptimizedRegularExpression::RE_DOT_NL;
if (no_capture) if (no_capture)
flags_final |= OptimizedRegularExpression::RE_NO_CAPTURE; flags |= OptimizedRegularExpression::RE_NO_CAPTURE;
if (case_insensitive)
flags |= Regexps::Regexp::RE_CASELESS;
ProfileEvents::increment(ProfileEvents::RegexpCreated); ProfileEvents::increment(ProfileEvents::RegexpCreated);
return new Regexp{createRegexp<like>(pattern, flags_final)}; return new Regexp{createRegexp<like>(pattern, flags)};
}); });
} }
} }