Skip to content

Commit

Permalink
Use auto where possible for all = operators.
Browse files Browse the repository at this point in the history
  • Loading branch information
SharafMohamed committed Nov 7, 2024
1 parent 76ef76f commit 70362d1
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 16 deletions.
17 changes: 8 additions & 9 deletions src/log_surgeon/LALR1Parser.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,18 +88,17 @@ auto LALR1Parser<NfaStateType, DfaStateType>::add_token_chain(
std::string const& chain
) -> void {
assert(chain.size() > 1);
std::unique_ptr<finite_automata::RegexASTLiteral<NfaStateType>> first_char_rule
auto first_char_rule
= std::make_unique<finite_automata::RegexASTLiteral<NfaStateType>>(chain[0]);
std::unique_ptr<finite_automata::RegexASTLiteral<NfaStateType>> second_char_rule
auto second_char_rule
= std::make_unique<finite_automata::RegexASTLiteral<NfaStateType>>(chain[1]);
std::unique_ptr<finite_automata::RegexASTCat<NfaStateType>> rule_chain
= std::make_unique<finite_automata::RegexASTCat<NfaStateType>>(
std::move(first_char_rule),
std::move(second_char_rule)
);
auto rule_chain = std::make_unique<finite_automata::RegexASTCat<NfaStateType>>(
std::move(first_char_rule),
std::move(second_char_rule)
);
for (uint32_t i = 2; i < chain.size(); i++) {
char next_char = chain[i];
std::unique_ptr<finite_automata::RegexASTLiteral<NfaStateType>> next_char_rule
auto next_char = chain[i];
auto next_char_rule
= std::make_unique<finite_automata::RegexASTLiteral<NfaStateType>>(next_char);
rule_chain = std::make_unique<finite_automata::RegexASTCat<NfaStateType>>(
std::move(rule_chain),
Expand Down
8 changes: 4 additions & 4 deletions src/log_surgeon/Lexer.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ auto Lexer<NfaStateType, DfaStateType>::scan(ParserInputBuffer& input_buffer, To
m_type_ids = nullptr;
}
while (true) {
uint32_t prev_byte_buf_pos = input_buffer.storage().pos();
unsigned char next_char{utf8::cCharErr};
if (ErrorCode err = input_buffer.get_next_character(next_char); ErrorCode::Success != err) {
auto prev_byte_buf_pos = input_buffer.storage().pos();
auto next_char{utf8::cCharErr};
if (auto const err = input_buffer.get_next_character(next_char); ErrorCode::Success != err) {
m_asked_for_more_data = true;
m_prev_state = state;
return err;
Expand All @@ -80,7 +80,7 @@ auto Lexer<NfaStateType, DfaStateType>::scan(ParserInputBuffer& input_buffer, To
m_match_pos = prev_byte_buf_pos;
m_match_line = m_line;
}
DfaStateType* next = state->next(next_char);
auto* next = state->next(next_char);
if (next_char == '\n') {
m_line++;
if (m_has_delimiters && !m_match) {
Expand Down
4 changes: 2 additions & 2 deletions src/log_surgeon/LogEvent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ auto LogEventView::reset() -> void {
start = 1;
}
for (uint32_t i = start; i < m_log_output_buffer->pos(); i++) {
Token& token = m_log_output_buffer->get_mutable_token(i);
auto& token = m_log_output_buffer->get_mutable_token(i);
raw_log += token.to_string_view();
}
return raw_log;
Expand All @@ -51,7 +51,7 @@ auto LogEventView::reset() -> void {
auto LogEventView::get_logtype() const -> std::string {
std::string logtype;
for (uint32_t i = 1; i < m_log_output_buffer->pos(); i++) {
Token& token = m_log_output_buffer->get_mutable_token(i);
auto& token = m_log_output_buffer->get_mutable_token(i);
if (token.m_type_ids_ptr->at(0) == (uint32_t)SymbolId::TokenUncaughtString) {
logtype += token.to_string_view();
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/log_surgeon/Schema.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Schema::Schema(std::string const& schema_file_path)
: m_schema_ast{SchemaParser::try_schema_file(schema_file_path)} {}

auto Schema::add_variable(std::string_view const var_schema, int const priority) const -> void {
std::unique_ptr<SchemaAST> const schema_ast = SchemaParser::try_schema_string(var_schema);
auto const schema_ast = SchemaParser::try_schema_string(var_schema);
m_schema_ast->add_schema_var(std::move(schema_ast->m_schema_vars[0]), priority);
}
} // namespace log_surgeon

0 comments on commit 70362d1

Please sign in to comment.