From bad1b845136bce0fbb59204c806715d3cf3bb0a7 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Thu, 15 Jul 2021 11:04:06 -0700 Subject: [PATCH] Remove the index parameter from parser_t::is_function It was always 0 in practice. --- src/parser.cpp | 5 ++--- src/parser.h | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/parser.cpp b/src/parser.cpp index a8e69db35..3b25bb173 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -416,9 +416,8 @@ wcstring parser_t::stack_trace() const { /// NULL otherwise. This is tested by moving down the block-scope-stack, checking every block if it /// is of type FUNCTION_CALL. If the caller doesn't specify a starting position in the stack we /// begin with the current block. -const wchar_t *parser_t::is_function(size_t idx) const { - for (size_t block_idx = idx; block_idx < block_list.size(); block_idx++) { - const block_t &b = block_list[block_idx]; +const wchar_t *parser_t::is_function() const { + for (const auto &b : block_list) { if (b.is_function_call()) { return b.function_name.c_str(); } else if (b.type() == block_type_t::source) { diff --git a/src/parser.h b/src/parser.h index f7822e751..19fa21110 100644 --- a/src/parser.h +++ b/src/parser.h @@ -285,7 +285,7 @@ class parser_t : public std::enable_shared_from_this { /// Returns the name of the currently evaluated function if we are currently evaluating a /// function, null otherwise. This is tested by moving down the block-scope-stack, checking /// every block if it is of type FUNCTION_CALL. - const wchar_t *is_function(size_t idx = 0) const; + const wchar_t *is_function() const; /// Create a parser. parser_t();