preprocess_* now uses const references to tokens

They copy and construct new token vectors and just read the token
inputs.
This commit is contained in:
2024-04-15 05:08:07 +06:30
parent 9ca93786af
commit 0e5c934072
2 changed files with 5 additions and 5 deletions

View File

@@ -22,7 +22,7 @@ using std::pair, std::vector, std::make_pair, std::string, std::string_view;
#define VAL(E) std::make_pair(E, pp_err_t{pp_err_type_t::OK})
pair<vector<token_t *>, pp_err_t>
preprocess_use_blocks(vector<token_t *> tokens)
preprocess_use_blocks(const vector<token_t *> &tokens)
{
vector<token_t *> new_tokens;
for (size_t i = 0; i < tokens.size(); ++i)
@@ -69,7 +69,7 @@ struct const_t
};
pair<vector<token_t *>, pp_err_t>
preprocess_const_blocks(vector<token_t *> &tokens)
preprocess_const_blocks(vector<token_t *> const &tokens)
{
std::unordered_map<string_view, const_t> blocks;
for (size_t i = 0; i < tokens.size(); ++i)

View File

@@ -45,13 +45,13 @@ std::pair<std::vector<token_t *>, pp_err_t>
preprocesser(std::vector<token_t *> &);
std::pair<std::vector<token_t *>, pp_err_t>
preprocess_const_blocks(std::vector<token_t *> &);
preprocess_const_blocks(const std::vector<token_t *> &);
std::pair<std::vector<token_t *>, pp_err_t>
preprocess_use_blocks(std::vector<token_t *> &);
preprocess_use_blocks(const std::vector<token_t *> &);
// TODO: Implement this
std::pair<std::vector<token_t *>, pp_err_t>
preprocess_macro_blocks(std::vector<token_t *> &);
preprocess_macro_blocks(const std::vector<token_t *> &);
#endif