Conversation
| kphp::pcre2::match_context match_context; | ||
| kphp::pcre2::match_data match_data; | ||
|
|
||
| RegexInstanceState() |
| kphp::pcre2::match_data match_data; | ||
|
|
||
| RegexInstanceState() noexcept | ||
| RegexBaseState() noexcept |
There was a problem hiding this comment.
Let's hide it in kphp::regex::details namespace
| } | ||
|
|
||
| template<typename... Args> | ||
| void pattern_compilation_warning(const char* function, const char* file, std::format_string<kphp::log::impl::wrapped_arg_t<Args>...> fmt, |
There was a problem hiding this comment.
Do we really need separate logging utility for regexp?
| Args&&... args) const noexcept { | ||
| static constexpr size_t LOG_BUFFER_SIZE = 256UZ; | ||
| std::array<char, LOG_BUFFER_SIZE> log_buffer; // NOLINT | ||
| const size_t message_size{kphp::log::impl::format_log_message(log_buffer, fmt, std::forward<Args>(args)...)}; |
| namespace kphp::regex { | ||
| class regexp final { | ||
| private: | ||
| void compile_regex(RegexBaseState& regex_state, const string& pattern, const string& subject = {}, const char* function = nullptr, |
There was a problem hiding this comment.
- Shouldn't we take
patternandsubjectby copy? - Can we get rid of raw pointers?
| } | ||
| } | ||
|
|
||
| std::optional<std::reference_wrapper<const kphp::pcre2::regex>> _re{}; |
There was a problem hiding this comment.
- Maybe rename to
m_reto follow existing naming policies? - Redundant init for this member
| _re = regex_state.add_compiled_regex(pattern, this->compile_options, std::move(re))->get().regex_code; | ||
| } | ||
|
|
||
| std::optional<bool> find_compiled_regex(const RegexBaseState& regex_state, const string& pattern) noexcept { |
There was a problem hiding this comment.
Isn't bool as a return type enough here?
| return true; | ||
| } | ||
|
|
||
| inline Optional<int64_t> preg_match_base(const regexp& regex, const string& subject, |
There was a problem hiding this comment.
Common note: let's avoid generic names like *base*. Can we use some specific name that reflects what the function actually does instead?
|
|
||
| static constexpr size_t MAX_SUBPATTERNS_COUNT{512}; | ||
|
|
||
| kphp::stl::unordered_map<string, compiled_regex, kphp::memory::script_allocator, hasher_type> regex_pcre2_code_cache; |
There was a problem hiding this comment.
As now it's also used in *ImageState, we must ensure that all string objects in this map have their reference counter set to ExtraRefCnt::for_global_const
| auto group_names{kphp::regex::details::collect_group_names(re)}; | ||
| auto unsigned_limit{limit == kphp::regex::PREG_NOLIMIT ? std::numeric_limits<uint64_t>::max() : static_cast<uint64_t>(limit)}; | ||
| regex_info.replace_count = 0; | ||
| int64_t replace_count = 0; |
There was a problem hiding this comment.
Please, use braced init here
No description provided.