LibRegex: Add some implied auto qualifiers

This commit is contained in:
Hendiadyoin1 2021-12-21 17:38:51 +01:00 committed by Brian Gianforcaro
parent 1fdd1915c2
commit b674de6957
Notes: sideshowbarker 2024-07-17 22:25:11 +09:00
4 changed files with 10 additions and 10 deletions

View File

@ -52,7 +52,7 @@ int regcomp(regex_t* reg, const char* pattern, int cflags)
// This could've been prevented if libc provided a reginit() or similar, but it does not.
reg->__data = new internal_regex_t { 0, 0, {}, 0, ReError::REG_NOERR, {} };
auto preg = impl_from(reg);
auto* preg = impl_from(reg);
bool is_extended = cflags & REG_EXTENDED;
preg->cflags = cflags;
@ -82,7 +82,7 @@ int regcomp(regex_t* reg, const char* pattern, int cflags)
int regexec(const regex_t* reg, const char* string, size_t nmatch, regmatch_t pmatch[], int eflags)
{
auto preg = impl_from(reg);
auto const* preg = impl_from(reg);
if (!preg->re.has_value() || preg->re_pat_err) {
if (preg->re_pat_err)
@ -213,7 +213,7 @@ inline static String get_error(ReError errcode)
size_t regerror(int errcode, const regex_t* reg, char* errbuf, size_t errbuf_size)
{
String error;
auto preg = impl_from(reg);
auto const* preg = impl_from(reg);
if (!preg)
error = get_error((ReError)errcode);
@ -231,7 +231,7 @@ size_t regerror(int errcode, const regex_t* reg, char* errbuf, size_t errbuf_siz
void regfree(regex_t* reg)
{
auto preg = impl_from(reg);
auto* preg = impl_from(reg);
if (preg) {
delete preg;
reg->__data = nullptr;

View File

@ -502,7 +502,7 @@ ALWAYS_INLINE ExecutionResult OpCode_Compare::execute(MatchInput const& input, M
auto ch = input.view.substring_view(state.string_position, 1)[0];
auto matching_range = binary_search(range_data, ch, nullptr, [insensitive = input.regex_options & AllFlags::Insensitive](auto needle, CharRange range) {
auto const* matching_range = binary_search(range_data, ch, nullptr, [insensitive = input.regex_options & AllFlags::Insensitive](auto needle, CharRange range) {
auto from = range.from;
auto to = range.to;
if (insensitive) {

View File

@ -130,13 +130,13 @@ RegexResult Matcher<Parser>::match(Vector<RegexStringView> const& views, Optiona
size_t lines_to_skip = 0;
bool unicode = input.regex_options.has_flag_set(AllFlags::Unicode);
for (auto& view : views)
for (auto const& view : views)
const_cast<RegexStringView&>(view).set_unicode(unicode);
if (input.regex_options.has_flag_set(AllFlags::Internal_Stateful)) {
if (views.size() > 1 && input.start_offset > views.first().length()) {
dbgln_if(REGEX_DEBUG, "Started with start={}, goff={}, skip={}", input.start_offset, input.global_offset, lines_to_skip);
for (auto& view : views) {
for (auto const& view : views) {
if (input.start_offset < view.length() + 1)
break;
++lines_to_skip;
@ -181,7 +181,7 @@ RegexResult Matcher<Parser>::match(Vector<RegexStringView> const& views, Optiona
if (input.regex_options.has_flag_set(AllFlags::Internal_Stateful))
continue_search = false;
for (auto& view : views) {
for (auto const& view : views) {
if (lines_to_skip != 0) {
++input.line;
--lines_to_skip;

View File

@ -213,7 +213,7 @@ void Regex<Parser>::attempt_rewrite_loops_as_atomic_groups(BasicBlockList const&
if constexpr (REGEX_DEBUG) {
RegexDebug dbg;
dbg.print_bytecode(*this);
for (auto& block : basic_blocks)
for (auto const& block : basic_blocks)
dbgln("block from {} to {}", block.start, block.end);
}
@ -264,7 +264,7 @@ void Regex<Parser>::attempt_rewrite_loops_as_atomic_groups(BasicBlockList const&
auto is_an_eligible_jump = [](OpCode const& opcode, size_t ip, size_t block_start, AlternateForm alternate_form) {
switch (opcode.opcode_id()) {
case OpCodeId::JumpNonEmpty: {
auto& op = static_cast<OpCode_JumpNonEmpty const&>(opcode);
auto const& op = static_cast<OpCode_JumpNonEmpty const&>(opcode);
auto form = op.form();
if (form != OpCodeId::Jump && alternate_form == AlternateForm::DirectLoopWithHeader)
return false;