Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Refactor code to better implement C++11 best practices #49

Description

@aarontay

Per feedback from @tomaszkapela on PR#46, recommended C++11 updates that fall out of scope of PR#46 can be implemented as follows:

src/snap/config.cc:

74    std::string Config::get_string(const std::string& key) const {
75        auto str_map = rpc_map.stringmap();
76        return str_map.at(key);
77    }

--Oneline this method as well as all the others

src/snap/config.h:

24    /**
25    * A Rule of type std::string
26    */
27    typedef Rule<rpc::StringPolicy, rpc::StringRule, std::string> StringRule;

--Since C++11, it's preferred to write using StringRule = Rule<...

53    template<class P, class R, typename T>
54    class Rule final : public P {
55    private:
56        class rule final : public R {

--Consider new naming choice for Rule -> rule. Maybe internal_rule or rule_impl

90    Rule(const std::string& key, bool req) {
91        rule rl(req);
92       auto rule_ptr = this->mutable_rules();
93       (*rule_ptr)[key] = rl;

--(*rule_ptr)[key] = rule(req); to avoid triggering a move assignment

Please consider providing additional refactor requests in comments

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions