Skip to content

Commit

Permalink
fix: use emplace
Browse files Browse the repository at this point in the history
  • Loading branch information
zsokami committed Nov 18, 2024
1 parent 27d8267 commit 4043141
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/config/regmatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@ class RegexWrapper {
RegexWrapper(const std::string &pattern) : pattern(pattern) {}
const jp::Regex &reg() {
if (!_reg) {
_reg = jp::Regex();
_reg.emplace();
_reg->setPattern(pattern).addModifier("m").addPcre2Option(PCRE2_UTF|PCRE2_ALT_BSUX).compile();
}
return *_reg;
};
const jp::Regex &reg_non_multiline() {
if (!_reg_non_multiline) {
_reg_non_multiline = jp::Regex();
_reg_non_multiline.emplace();
_reg_non_multiline->setPattern(pattern).addPcre2Option(PCRE2_UTF|PCRE2_ALT_BSUX).compile();
}
return *_reg_non_multiline;
};
const jp::Regex &reg_full_match() {
if (!_reg_full_match) {
_reg_full_match = jp::Regex();
_reg_full_match.emplace();
_reg_full_match->setPattern(pattern).addModifier("m").addPcre2Option(PCRE2_ANCHORED|PCRE2_ENDANCHORED|PCRE2_UTF).compile();
}
return *_reg_full_match;
Expand All @@ -49,7 +49,7 @@ struct RegexMatchConfig
std::optional<RegexWrapper> real_rule;
RegexWrapper &reg_wrapper() {
if (!real_rule) {
real_rule = RegexWrapper(Match);
real_rule.emplace(Match);
}
return *real_rule;
}
Expand Down
4 changes: 2 additions & 2 deletions src/generator/config/subexport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ void extract_rule_once(RegexMatchConfig &config, const jp::Regex &regex) {
if (config.target) return;
std::string target, real_rule;
regGetMatch(config.Match, regex, 3, 0, &target, &real_rule);
config.target = RegexWrapper(target);
config.real_rule = RegexWrapper(real_rule);
config.target.emplace(target);
config.real_rule.emplace(real_rule);
}

bool applyMatcher(RegexMatchConfig &config, const Proxy &node) {
Expand Down

0 comments on commit 4043141

Please sign in to comment.