From fee08a87e9d656d967d1d8612b2ddc3d63749c32 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Fri, 13 Mar 2020 13:59:10 -0700 Subject: [PATCH] [cppcheck] add const in several places Found with constParameter, functionConst, constVariable, constArgument Signed-off-by: Rosen Penev --- src/builtin.cpp | 2 +- src/builtin.h | 2 +- src/builtin_argparse.cpp | 2 +- src/builtin_bind.cpp | 2 +- src/builtin_bind.h | 2 +- src/builtin_complete.cpp | 4 ++-- src/builtin_math.cpp | 6 +++--- src/builtin_set.cpp | 16 ++++++++-------- src/builtin_string.cpp | 28 ++++++++++++++-------------- src/color.cpp | 2 +- src/env_dispatch.cpp | 14 +++++++------- src/fd_monitor.cpp | 2 +- src/input.cpp | 4 ++-- src/input.h | 2 +- src/input_common.h | 2 +- src/iothread.cpp | 6 +++--- src/parse_tree.cpp | 6 +++--- src/reader.h | 2 +- src/trace.cpp | 2 +- 19 files changed, 53 insertions(+), 53 deletions(-) diff --git a/src/builtin.cpp b/src/builtin.cpp index 0af4cc9f0..832bedcff 100644 --- a/src/builtin.cpp +++ b/src/builtin.cpp @@ -152,7 +152,7 @@ int parse_help_only_cmd_opts(struct help_only_cmd_opts_t &opts, int *optind, int /// builtin or function name to get up help for /// /// Process and print help for the specified builtin or function. -void builtin_print_help(parser_t &parser, io_streams_t &streams, const wchar_t *name, +void builtin_print_help(parser_t &parser, const io_streams_t &streams, const wchar_t *name, wcstring *error_message) { UNUSED(streams); // This won't ever work if no_exec is set. diff --git a/src/builtin.h b/src/builtin.h index 7f10b505e..1629c4a79 100644 --- a/src/builtin.h +++ b/src/builtin.h @@ -89,7 +89,7 @@ const wchar_t *builtin_get_desc(const wcstring &name); wcstring builtin_help_get(parser_t &parser, const wchar_t *cmd); -void builtin_print_help(parser_t &parser, io_streams_t &streams, const wchar_t *name, +void builtin_print_help(parser_t &parser, const io_streams_t &streams, const wchar_t *name, wcstring *error_message = nullptr); int builtin_count_args(const wchar_t *const *argv); diff --git a/src/builtin_argparse.cpp b/src/builtin_argparse.cpp index 4677d2076..cf7be380a 100644 --- a/src/builtin_argparse.cpp +++ b/src/builtin_argparse.cpp @@ -643,7 +643,7 @@ static int argparse_parse_args(argparse_cmd_opts_t &opts, const wcstring_list_t return STATUS_CMD_OK; } -static int check_min_max_args_constraints(const argparse_cmd_opts_t &opts, parser_t &parser, +static int check_min_max_args_constraints(const argparse_cmd_opts_t &opts, const parser_t &parser, io_streams_t &streams) { UNUSED(parser); const wchar_t *cmd = opts.name.c_str(); diff --git a/src/builtin_bind.cpp b/src/builtin_bind.cpp index 419688229..78522a4cc 100644 --- a/src/builtin_bind.cpp +++ b/src/builtin_bind.cpp @@ -150,7 +150,7 @@ void builtin_bind_t::function_names(io_streams_t &streams) { /// Wraps input_terminfo_get_sequence(), appending the correct error messages as needed. bool builtin_bind_t::get_terminfo_sequence(const wcstring &seq, wcstring *out_seq, - io_streams_t &streams) { + io_streams_t &streams) const { if (input_terminfo_get_sequence(seq, out_seq)) { return true; } diff --git a/src/builtin_bind.h b/src/builtin_bind.h index d522f6383..769fea782 100644 --- a/src/builtin_bind.h +++ b/src/builtin_bind.h @@ -30,7 +30,7 @@ class builtin_bind_t { const wchar_t *sets_mode, bool terminfo, bool user, io_streams_t &streams); bool erase(wchar_t **seq, bool all, const wchar_t *mode, bool use_terminfo, bool user, io_streams_t &streams); - bool get_terminfo_sequence(const wcstring &seq, wcstring *out_seq, io_streams_t &streams); + bool get_terminfo_sequence(const wcstring &seq, wcstring *out_seq, io_streams_t &streams) const; bool insert(int optind, int argc, wchar_t **argv, io_streams_t &streams); void list_modes(io_streams_t &streams); bool list_one(const wcstring &seq, const wcstring &bind_mode, bool user, io_streams_t &streams); diff --git a/src/builtin_complete.cpp b/src/builtin_complete.cpp index 831c3fa51..6bdc11592 100644 --- a/src/builtin_complete.cpp +++ b/src/builtin_complete.cpp @@ -56,8 +56,8 @@ static void builtin_complete_add2(const wchar_t *cmd, bool cmd_is_path, const wc /// Silly function. static void builtin_complete_add(const wcstring_list_t &cmds, const wcstring_list_t &paths, - const wchar_t *short_opt, wcstring_list_t &gnu_opt, - wcstring_list_t &old_opt, completion_mode_t result_mode, + const wchar_t *short_opt, const wcstring_list_t &gnu_opt, + const wcstring_list_t &old_opt, completion_mode_t result_mode, const wchar_t *condition, const wchar_t *comp, const wchar_t *desc, int flags) { for (const wcstring &cmd : cmds) { diff --git a/src/builtin_math.cpp b/src/builtin_math.cpp index e6142f703..be998b1e1 100644 --- a/src/builtin_math.cpp +++ b/src/builtin_math.cpp @@ -128,7 +128,7 @@ static const wchar_t *math_get_arg(int *argidx, wchar_t **argv, wcstring *storag return math_get_arg_argv(argidx, argv); } -static const wchar_t *math_describe_error(te_error_t &error) { +static const wchar_t *math_describe_error(const te_error_t &error) { if (error.position == 0) return L"NO ERROR?!?"; switch (error.type) { @@ -186,8 +186,8 @@ static wcstring format_double(double v, const math_cmd_opts_t &opts) { } /// Evaluate math expressions. -static int evaluate_expression(const wchar_t *cmd, parser_t &parser, io_streams_t &streams, - math_cmd_opts_t &opts, wcstring &expression) { +static int evaluate_expression(const wchar_t *cmd, const parser_t &parser, io_streams_t &streams, + const math_cmd_opts_t &opts, wcstring &expression) { UNUSED(parser); int retval = STATUS_CMD_OK; diff --git a/src/builtin_set.cpp b/src/builtin_set.cpp index d6082ef2b..c22685df9 100644 --- a/src/builtin_set.cpp +++ b/src/builtin_set.cpp @@ -172,7 +172,7 @@ static int parse_cmd_opts(set_cmd_opts_t &opts, int *optind, //!OCLINT(high ncs return STATUS_CMD_OK; } -static int validate_cmd_opts(const wchar_t *cmd, set_cmd_opts_t &opts, //!OCLINT(npath complexity) +static int validate_cmd_opts(const wchar_t *cmd, const set_cmd_opts_t &opts, //!OCLINT(npath complexity) int argc, parser_t &parser, io_streams_t &streams) { // Can't query and erase or list. if (opts.query && (opts.erase || opts.list)) { @@ -235,7 +235,7 @@ static int validate_cmd_opts(const wchar_t *cmd, set_cmd_opts_t &opts, //!OCLIN // Check if we are setting a uvar and a global of the same name exists. See // https://github.com/fish-shell/fish-shell/issues/806 -static int check_global_scope_exists(const wchar_t *cmd, set_cmd_opts_t &opts, const wchar_t *dest, +static int check_global_scope_exists(const wchar_t *cmd, const set_cmd_opts_t &opts, const wchar_t *dest, io_streams_t &streams, const parser_t &parser) { if (opts.universal) { auto global_dest = parser.vars().get(dest, ENV_GLOBAL); @@ -414,7 +414,7 @@ static int parse_index(std::vector &indexes, wchar_t *src, int scope, io_s } static int update_values(wcstring_list_t &list, std::vector &indexes, - wcstring_list_t &values) { + const wcstring_list_t &values) { // Replace values where needed. for (size_t i = 0; i < indexes.size(); i++) { // The '- 1' below is because the indices in fish are one-based, but the vector uses @@ -452,7 +452,7 @@ static void erase_values(wcstring_list_t &list, const std::vector &indexes } } -static env_mode_flags_t compute_scope(set_cmd_opts_t &opts) { +static env_mode_flags_t compute_scope(const set_cmd_opts_t &opts) { int scope = ENV_USER; if (opts.local) scope |= ENV_LOCAL; if (opts.global) scope |= ENV_GLOBAL; @@ -602,10 +602,10 @@ static void show_scope(const wchar_t *var_name, int scope, io_streams_t &streams } /// Show mode. Show information about the named variable(s). -static int builtin_set_show(const wchar_t *cmd, set_cmd_opts_t &opts, int argc, wchar_t **argv, +static int builtin_set_show(const wchar_t *cmd, const set_cmd_opts_t &opts, int argc, wchar_t **argv, parser_t &parser, io_streams_t &streams) { UNUSED(opts); - auto &vars = parser.vars(); + const auto &vars = parser.vars(); if (argc == 0) { // show all vars wcstring_list_t names = parser.vars().get_names(ENV_USER); sort(names.begin(), names.end()); @@ -696,9 +696,9 @@ static int builtin_set_erase(const wchar_t *cmd, set_cmd_opts_t &opts, int argc, } /// This handles the common case of setting the entire var to a set of values. -static int set_var_array(const wchar_t *cmd, set_cmd_opts_t &opts, const wchar_t *varname, +static int set_var_array(const wchar_t *cmd, const set_cmd_opts_t &opts, const wchar_t *varname, wcstring_list_t &new_values, int argc, wchar_t **argv, parser_t &parser, - io_streams_t &streams) { + const io_streams_t &streams) { UNUSED(cmd); UNUSED(streams); diff --git a/src/builtin_string.cpp b/src/builtin_string.cpp index 35230a3b0..ce9173be5 100644 --- a/src/builtin_string.cpp +++ b/src/builtin_string.cpp @@ -183,7 +183,7 @@ typedef struct { //!OCLINT(too many fields) } options_t; /// This handles the `--style=xxx` flag. -static int handle_flag_1(wchar_t **argv, parser_t &parser, io_streams_t &streams, wgetopter_t &w, +static int handle_flag_1(wchar_t **argv, parser_t &parser, io_streams_t &streams, const wgetopter_t &w, options_t *opts) { const wchar_t *cmd = argv[0]; @@ -207,7 +207,7 @@ static int handle_flag_1(wchar_t **argv, parser_t &parser, io_streams_t &streams return STATUS_INVALID_ARGS; } -static int handle_flag_N(wchar_t **argv, parser_t &parser, io_streams_t &streams, wgetopter_t &w, +static int handle_flag_N(wchar_t **argv, parser_t &parser, io_streams_t &streams, const wgetopter_t &w, options_t *opts) { if (opts->no_newline_valid) { opts->no_newline = true; @@ -220,7 +220,7 @@ static int handle_flag_N(wchar_t **argv, parser_t &parser, io_streams_t &streams return STATUS_INVALID_ARGS; } -static int handle_flag_a(wchar_t **argv, parser_t &parser, io_streams_t &streams, wgetopter_t &w, +static int handle_flag_a(wchar_t **argv, parser_t &parser, io_streams_t &streams, const wgetopter_t &w, options_t *opts) { if (opts->all_valid) { opts->all = true; @@ -230,7 +230,7 @@ static int handle_flag_a(wchar_t **argv, parser_t &parser, io_streams_t &streams return STATUS_INVALID_ARGS; } -static int handle_flag_c(wchar_t **argv, parser_t &parser, io_streams_t &streams, wgetopter_t &w, +static int handle_flag_c(wchar_t **argv, parser_t &parser, io_streams_t &streams, const wgetopter_t &w, options_t *opts) { if (opts->chars_valid) { opts->chars_to_trim = w.woptarg; @@ -240,7 +240,7 @@ static int handle_flag_c(wchar_t **argv, parser_t &parser, io_streams_t &streams return STATUS_INVALID_ARGS; } -static int handle_flag_e(wchar_t **argv, parser_t &parser, io_streams_t &streams, wgetopter_t &w, +static int handle_flag_e(wchar_t **argv, parser_t &parser, io_streams_t &streams, const wgetopter_t &w, options_t *opts) { if (opts->entire_valid) { opts->entire = true; @@ -250,7 +250,7 @@ static int handle_flag_e(wchar_t **argv, parser_t &parser, io_streams_t &streams return STATUS_INVALID_ARGS; } -static int handle_flag_f(wchar_t **argv, parser_t &parser, io_streams_t &streams, wgetopter_t &w, +static int handle_flag_f(wchar_t **argv, parser_t &parser, io_streams_t &streams, const wgetopter_t &w, options_t *opts) { if (opts->filter_valid) { opts->filter = true; @@ -260,7 +260,7 @@ static int handle_flag_f(wchar_t **argv, parser_t &parser, io_streams_t &streams return STATUS_INVALID_ARGS; } -static int handle_flag_i(wchar_t **argv, parser_t &parser, io_streams_t &streams, wgetopter_t &w, +static int handle_flag_i(wchar_t **argv, parser_t &parser, io_streams_t &streams, const wgetopter_t &w, options_t *opts) { if (opts->ignore_case_valid) { opts->ignore_case = true; @@ -273,7 +273,7 @@ static int handle_flag_i(wchar_t **argv, parser_t &parser, io_streams_t &streams return STATUS_INVALID_ARGS; } -static int handle_flag_l(wchar_t **argv, parser_t &parser, io_streams_t &streams, wgetopter_t &w, +static int handle_flag_l(wchar_t **argv, parser_t &parser, io_streams_t &streams, const wgetopter_t &w, options_t *opts) { if (opts->length_valid) { opts->length = fish_wcstol(w.woptarg); @@ -293,7 +293,7 @@ static int handle_flag_l(wchar_t **argv, parser_t &parser, io_streams_t &streams return STATUS_INVALID_ARGS; } -static int handle_flag_m(wchar_t **argv, parser_t &parser, io_streams_t &streams, wgetopter_t &w, +static int handle_flag_m(wchar_t **argv, parser_t &parser, io_streams_t &streams, const wgetopter_t &w, options_t *opts) { if (opts->max_valid) { opts->max = fish_wcstol(w.woptarg); @@ -310,7 +310,7 @@ static int handle_flag_m(wchar_t **argv, parser_t &parser, io_streams_t &streams return STATUS_INVALID_ARGS; } -static int handle_flag_n(wchar_t **argv, parser_t &parser, io_streams_t &streams, wgetopter_t &w, +static int handle_flag_n(wchar_t **argv, parser_t &parser, io_streams_t &streams, const wgetopter_t &w, options_t *opts) { if (opts->count_valid) { opts->count = fish_wcstol(w.woptarg); @@ -336,7 +336,7 @@ static int handle_flag_n(wchar_t **argv, parser_t &parser, io_streams_t &streams return STATUS_INVALID_ARGS; } -static int handle_flag_q(wchar_t **argv, parser_t &parser, io_streams_t &streams, wgetopter_t &w, +static int handle_flag_q(wchar_t **argv, parser_t &parser, io_streams_t &streams, const wgetopter_t &w, options_t *opts) { if (opts->quiet_valid) { opts->quiet = true; @@ -346,7 +346,7 @@ static int handle_flag_q(wchar_t **argv, parser_t &parser, io_streams_t &streams return STATUS_INVALID_ARGS; } -static int handle_flag_r(wchar_t **argv, parser_t &parser, io_streams_t &streams, wgetopter_t &w, +static int handle_flag_r(wchar_t **argv, parser_t &parser, io_streams_t &streams, const wgetopter_t &w, options_t *opts) { if (opts->regex_valid) { opts->regex = true; @@ -359,7 +359,7 @@ static int handle_flag_r(wchar_t **argv, parser_t &parser, io_streams_t &streams return STATUS_INVALID_ARGS; } -static int handle_flag_s(wchar_t **argv, parser_t &parser, io_streams_t &streams, wgetopter_t &w, +static int handle_flag_s(wchar_t **argv, parser_t &parser, io_streams_t &streams, const wgetopter_t &w, options_t *opts) { if (opts->start_valid) { opts->start = fish_wcstol(w.woptarg); @@ -376,7 +376,7 @@ static int handle_flag_s(wchar_t **argv, parser_t &parser, io_streams_t &streams return STATUS_INVALID_ARGS; } -static int handle_flag_v(wchar_t **argv, parser_t &parser, io_streams_t &streams, wgetopter_t &w, +static int handle_flag_v(wchar_t **argv, parser_t &parser, io_streams_t &streams, const wgetopter_t &w, options_t *opts) { if (opts->invert_valid) { opts->invert_match = true; diff --git a/src/color.cpp b/src/color.cpp index 990997a33..bfb2a52c8 100644 --- a/src/color.cpp +++ b/src/color.cpp @@ -170,7 +170,7 @@ static const named_color_t named_colors[] = { }; wcstring_list_t rgb_color_t::named_color_names() { - size_t count = sizeof named_colors / sizeof *named_colors; + const size_t count = sizeof named_colors / sizeof *named_colors; wcstring_list_t result; result.reserve(1 + count); for (size_t i = 0; i < count; i++) { diff --git a/src/env_dispatch.cpp b/src/env_dispatch.cpp index 1b23fe81a..f278d2738 100644 --- a/src/env_dispatch.cpp +++ b/src/env_dispatch.cpp @@ -217,12 +217,12 @@ void env_universal_callbacks(env_stack_t *stack, const callback_data_list_t &cal } } -static void handle_fish_term_change(env_stack_t &vars) { +static void handle_fish_term_change(const env_stack_t &vars) { update_fish_color_support(vars); reader_react_to_color_change(); } -static void handle_change_ambiguous_width(env_stack_t &vars) { +static void handle_change_ambiguous_width(const env_stack_t &vars) { int new_width = 1; if (auto width_str = vars.get(L"fish_ambiguous_width")) { new_width = fish_wcstol(width_str->as_string().c_str()); @@ -230,26 +230,26 @@ static void handle_change_ambiguous_width(env_stack_t &vars) { g_fish_ambiguous_width = std::max(0, new_width); } -static void handle_term_size_change(env_stack_t &vars) { +static void handle_term_size_change(const env_stack_t &vars) { UNUSED(vars); invalidate_termsize(true); // force fish to update its idea of the terminal size plus vars } -static void handle_fish_history_change(env_stack_t &vars) { +static void handle_fish_history_change(const env_stack_t &vars) { reader_change_history(history_session_id(vars)); } -static void handle_function_path_change(env_stack_t &vars) { +static void handle_function_path_change(const env_stack_t &vars) { UNUSED(vars); function_invalidate_path(); } -static void handle_complete_path_change(env_stack_t &vars) { +static void handle_complete_path_change(const env_stack_t &vars) { UNUSED(vars); complete_invalidate_path(); } -static void handle_tz_change(const wcstring &var_name, env_stack_t &vars) { +static void handle_tz_change(const wcstring &var_name, const env_stack_t &vars) { handle_timezone(var_name.c_str(), vars); } diff --git a/src/fd_monitor.cpp b/src/fd_monitor.cpp index d02ebad1b..00b7a717d 100644 --- a/src/fd_monitor.cpp +++ b/src/fd_monitor.cpp @@ -26,7 +26,7 @@ fd_monitor_t::fd_monitor_t() { // Add an item for ourselves. // We don't need to go through 'pending' because we have not yet launched the thread, and don't // want to yet. - auto callback = [this](autoclose_fd_t &fd, bool timed_out) { + auto callback = [this](const autoclose_fd_t &fd, bool timed_out) { ASSERT_IS_BACKGROUND_THREAD(); assert(!timed_out && "Should not time out with kNoTimeout"); (void)timed_out; diff --git a/src/input.cpp b/src/input.cpp index a316dee5e..53da3e7af 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -582,9 +582,9 @@ bool input_mapping_set_t::erase(const wcstring &sequence, const wcstring &mode, } bool input_mapping_set_t::get(const wcstring &sequence, const wcstring &mode, - wcstring_list_t *out_cmds, bool user, wcstring *out_sets_mode) { + wcstring_list_t *out_cmds, bool user, wcstring *out_sets_mode) const { bool result = false; - mapping_list_t &ml = user ? mapping_list_ : preset_mapping_list_; + const auto &ml = user ? mapping_list_ : preset_mapping_list_; for (const input_mapping_t &m : ml) { if (sequence == m.seq && mode == m.mode) { *out_cmds = m.commands; diff --git a/src/input.h b/src/input.h index 45b714a12..35ed33290 100644 --- a/src/input.h +++ b/src/input.h @@ -100,7 +100,7 @@ class input_mapping_set_t { /// Gets the command bound to the specified key sequence in the specified mode. Returns true if /// it exists, false if not. bool get(const wcstring &sequence, const wcstring &mode, wcstring_list_t *out_cmds, bool user, - wcstring *out_sets_mode); + wcstring *out_sets_mode) const; /// Returns all mapping names and modes. std::vector get_names(bool user = true) const; diff --git a/src/input_common.h b/src/input_common.h index e4248d9c6..746b4f6d6 100644 --- a/src/input_common.h +++ b/src/input_common.h @@ -178,7 +178,7 @@ class input_event_queue_t { std::deque queue_; /// \return if we have any lookahead. - bool has_lookahead() { return !queue_.empty(); } + bool has_lookahead() const { return !queue_.empty(); } /// \return the next event in the queue. char_event_t pop(); diff --git a/src/iothread.cpp b/src/iothread.cpp index a4b55e793..b4a8ea651 100644 --- a/src/iothread.cpp +++ b/src/iothread.cpp @@ -120,7 +120,7 @@ struct thread_pool_t { static void *run_trampoline(void *vpool); /// Attempt to spawn a new pthread. - bool spawn(); + bool spawn() const; /// No copying or moving. thread_pool_t(const thread_pool_t &) = delete; @@ -229,8 +229,8 @@ void *thread_pool_t::run_trampoline(void *pool) { } /// Spawn another thread. No lock is held when this is called. -bool thread_pool_t::spawn() { - return make_detached_pthread(&run_trampoline, static_cast(this)); +bool thread_pool_t::spawn() const { + return make_detached_pthread(&run_trampoline, const_cast(this)); } int thread_pool_t::perform(void_function_t &&func, void_function_t &&completion, bool cant_wait) { diff --git a/src/parse_tree.cpp b/src/parse_tree.cpp index a98971602..27cc963a0 100644 --- a/src/parse_tree.cpp +++ b/src/parse_tree.cpp @@ -406,7 +406,7 @@ class parse_ll_t { void parse_error(parse_token_t token, parse_error_code_t code, const wchar_t *fmt, ...); void parse_error_at_location(size_t source_start, size_t source_length, size_t error_location, parse_error_code_t code, const wchar_t *fmt, ...); - void parse_error_failed_production(struct parse_stack_element_t &elem, parse_token_t token); + void parse_error_failed_production(const struct parse_stack_element_t &elem, parse_token_t token); void parse_error_unbalancing_token(parse_token_t token); // Reports an error for an unclosed block, e.g. 'begin;'. Returns true on success, false on @@ -701,7 +701,7 @@ void parse_ll_t::parse_error_unbalancing_token(parse_token_t token) { } /// This is a 'generic' parse error when we can't match the top of the stack element. -void parse_ll_t::parse_error_failed_production(struct parse_stack_element_t &stack_elem, +void parse_ll_t::parse_error_failed_production(const struct parse_stack_element_t &stack_elem, parse_token_t token) { fatal_errored = true; if (this->should_generate_error_messages) { @@ -806,7 +806,7 @@ bool parse_ll_t::report_error_for_unclosed_block() { bool parse_ll_t::top_node_handle_terminal_types(const parse_token_t &token) { PARSE_ASSERT(!symbol_stack.empty()); //!OCLINT(multiple unary operator) PARSE_ASSERT(token.type >= FIRST_PARSE_TOKEN_TYPE); - parse_stack_element_t &stack_top = symbol_stack.back(); + const auto &stack_top = symbol_stack.back(); if (!type_is_terminal_type(stack_top.type)) { return false; // was not handled diff --git a/src/reader.h b/src/reader.h index 0ba6bb175..5c411d821 100644 --- a/src/reader.h +++ b/src/reader.h @@ -87,7 +87,7 @@ class editable_line_t { bool empty() const { return text().empty(); } - wchar_t at(size_t idx) { return text().at(idx); } + wchar_t at(size_t idx) const { return text().at(idx); } void clear() { undo_history.clear(); diff --git a/src/trace.cpp b/src/trace.cpp index f247ac5f8..d3c134aa0 100644 --- a/src/trace.cpp +++ b/src/trace.cpp @@ -9,7 +9,7 @@ static const wcstring VAR_fish_trace = L"fish_trace"; bool trace_enabled(const parser_t &parser) { - auto &ld = parser.libdata(); + const auto &ld = parser.libdata(); if (ld.suppress_fish_trace) return false; // TODO: this variable lookup is somewhat expensive, consider how to make this cheaper. return !parser.vars().get(VAR_fish_trace).missing_or_empty();