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.
This commit is contained in:
Johannes Altmanninger 2020-10-10 12:50:07 +02:00
parent c325603d73
commit 8ef8fb3d94
3 changed files with 6 additions and 6 deletions

View file

@ -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 // routine simultaneously the first time around, we just end up needlessly querying uname(2) one
// more time. // more time.
static bool wsl_state = []() { static bool wsl_state = [] {
utsname info; utsname info;
uname(&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 // session. We err on the side of assuming it's not a console session. This approach isn't
// bullet-proof and that's OK. // bullet-proof and that's OK.
bool is_console_session() { bool is_console_session() {
static const bool console_session = []() { static const bool console_session = [] {
ASSERT_IS_MAIN_THREAD(); ASSERT_IS_MAIN_THREAD();
const char *tty_name = ttyname(0); const char *tty_name = ttyname(0);

View file

@ -45,7 +45,7 @@ bool parser_keywords_skip_arguments(const wcstring &cmd) {
} }
bool parser_keywords_is_subcommand(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; string_set_t results;
results.insert(std::begin(subcommand_keywords), std::end(subcommand_keywords)); results.insert(std::begin(subcommand_keywords), std::end(subcommand_keywords));
results.insert(std::begin(skip_keywords), std::end(skip_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) { 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; string_set_t results;
results.insert(std::begin(subcommand_keywords), std::end(subcommand_keywords)); results.insert(std::begin(subcommand_keywords), std::end(subcommand_keywords));
results.insert(std::begin(skip_keywords), std::end(skip_keywords)); results.insert(std::begin(skip_keywords), std::end(skip_keywords));

View file

@ -212,7 +212,7 @@ static void pop_timer() {
} }
cleanup_t push_timer(bool enabled) { cleanup_t push_timer(bool enabled) {
if (!enabled) return {[]() {}}; if (!enabled) return {[] {}};
active_timers.emplace_back(timer_snapshot_t::take()); active_timers.emplace_back(timer_snapshot_t::take());
return {[]() { pop_timer(); }}; return {[] { pop_timer(); }};
} }