From 7d203289bf3e796fcc01f1e877a4443fdf3c7a61 Mon Sep 17 00:00:00 2001 From: clemahieu Date: Thu, 21 Jul 2022 13:10:38 +0100 Subject: [PATCH] Simplifying bootstrap_attempt::mode_text and returning the direct char const * instead of converting it to std::string. (#3869) --- nano/node/bootstrap/bootstrap_attempt.cpp | 22 +++++++++------------- nano/node/bootstrap/bootstrap_attempt.hpp | 2 +- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/nano/node/bootstrap/bootstrap_attempt.cpp b/nano/node/bootstrap/bootstrap_attempt.cpp index fcac6b2b6..3743bce9a 100644 --- a/nano/node/bootstrap/bootstrap_attempt.cpp +++ b/nano/node/bootstrap/bootstrap_attempt.cpp @@ -95,22 +95,18 @@ void nano::bootstrap_attempt::stop () node->bootstrap_initiator.connections->clear_pulls (incremental_id); } -std::string nano::bootstrap_attempt::mode_text () +char const * nano::bootstrap_attempt::mode_text () { - std::string mode_text; - if (mode == nano::bootstrap_mode::legacy) + switch (mode) { - mode_text = "legacy"; + case nano::bootstrap_mode::legacy: + return "legacy"; + case nano::bootstrap_mode::lazy: + return "lazy"; + case nano::bootstrap_mode::wallet_lazy: + return "wallet_lazy"; } - else if (mode == nano::bootstrap_mode::lazy) - { - mode_text = "lazy"; - } - else if (mode == nano::bootstrap_mode::wallet_lazy) - { - mode_text = "wallet_lazy"; - } - return mode_text; + return "unknown"; } bool nano::bootstrap_attempt::process_block (std::shared_ptr const & block_a, nano::account const & known_account_a, uint64_t pull_blocks_processed, nano::bulk_pull::count_t max_blocks, bool block_expected, unsigned retry_limit) diff --git a/nano/node/bootstrap/bootstrap_attempt.hpp b/nano/node/bootstrap/bootstrap_attempt.hpp index 58f8b1e72..3fb63f3b2 100644 --- a/nano/node/bootstrap/bootstrap_attempt.hpp +++ b/nano/node/bootstrap/bootstrap_attempt.hpp @@ -26,7 +26,7 @@ public: void pull_started (); void pull_finished (); bool should_log (); - std::string mode_text (); + char const * mode_text (); virtual bool process_block (std::shared_ptr const &, nano::account const &, uint64_t, nano::bulk_pull::count_t, bool, unsigned); virtual void get_information (boost::property_tree::ptree &) = 0; virtual void block_processed (nano::transaction const & tx, nano::process_return const & result, nano::block const & block);