From 8ef8fb3d94c1abe39c100d1e583d95f65c5ee59f Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Sat, 10 Oct 2020 12:50:07 +0200 Subject: [PATCH] Refactor: omit parens in lambdas with no parameters TIL []{} is a thing. We already do that in some places, so this improves consistency, although it may be less obvious. --- src/common.cpp | 4 ++-- src/parser_keywords.cpp | 4 ++-- src/timer.cpp | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/common.cpp b/src/common.cpp index 58076658d..1bfdced5d 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -151,7 +151,7 @@ bool is_windows_subsystem_for_linux() { // routine simultaneously the first time around, we just end up needlessly querying uname(2) one // more time. - static bool wsl_state = []() { + static bool wsl_state = [] { utsname info; uname(&info); @@ -2130,7 +2130,7 @@ std::string get_path_to_tmp_dir() { // session. We err on the side of assuming it's not a console session. This approach isn't // bullet-proof and that's OK. bool is_console_session() { - static const bool console_session = []() { + static const bool console_session = [] { ASSERT_IS_MAIN_THREAD(); const char *tty_name = ttyname(0); diff --git a/src/parser_keywords.cpp b/src/parser_keywords.cpp index 49b375127..982286ae2 100644 --- a/src/parser_keywords.cpp +++ b/src/parser_keywords.cpp @@ -45,7 +45,7 @@ bool parser_keywords_skip_arguments(const wcstring &cmd) { } bool parser_keywords_is_subcommand(const wcstring &cmd) { - const static string_set_t search_list = ([]() { + const static string_set_t search_list = ([] { string_set_t results; results.insert(std::begin(subcommand_keywords), std::end(subcommand_keywords)); results.insert(std::begin(skip_keywords), std::end(skip_keywords)); @@ -68,7 +68,7 @@ bool parser_keywords_is_block(const wcstring &word) { } bool parser_keywords_is_reserved(const wcstring &word) { - const static string_set_t search_list = ([]() { + const static string_set_t search_list = ([] { string_set_t results; results.insert(std::begin(subcommand_keywords), std::end(subcommand_keywords)); results.insert(std::begin(skip_keywords), std::end(skip_keywords)); diff --git a/src/timer.cpp b/src/timer.cpp index 248b9144b..0291311f2 100644 --- a/src/timer.cpp +++ b/src/timer.cpp @@ -212,7 +212,7 @@ static void pop_timer() { } cleanup_t push_timer(bool enabled) { - if (!enabled) return {[]() {}}; + if (!enabled) return {[] {}}; active_timers.emplace_back(timer_snapshot_t::take()); - return {[]() { pop_timer(); }}; + return {[] { pop_timer(); }}; }