diff options
author | Henning Baldersheim <balder@oath.com> | 2018-08-10 23:34:45 +0200 |
---|---|---|
committer | Henning Baldersheim <balder@oath.com> | 2018-08-10 23:34:45 +0200 |
commit | 6ecf0ff7e093eae86292c283bf586c405a557659 (patch) | |
tree | dc45738bead7ad07399324f255e2a0dbd38e5fcf /vdslib | |
parent | 86139ca05e67c56dfdee0399c4ebc157903f47ea (diff) |
Pass stringref by value
Diffstat (limited to 'vdslib')
-rw-r--r-- | vdslib/src/vespa/vdslib/container/parameters.cpp | 28 | ||||
-rw-r--r-- | vdslib/src/vespa/vdslib/container/parameters.h | 16 | ||||
-rw-r--r-- | vdslib/src/vespa/vdslib/container/parameters.hpp | 6 | ||||
-rw-r--r-- | vdslib/src/vespa/vdslib/state/clusterstate.h | 2 | ||||
-rw-r--r-- | vdslib/src/vespa/vdslib/state/diskstate.cpp | 2 | ||||
-rw-r--r-- | vdslib/src/vespa/vdslib/state/diskstate.h | 4 | ||||
-rw-r--r-- | vdslib/src/vespa/vdslib/state/nodestate.cpp | 2 | ||||
-rw-r--r-- | vdslib/src/vespa/vdslib/state/nodestate.h | 4 | ||||
-rw-r--r-- | vdslib/src/vespa/vdslib/state/nodetype.cpp | 4 | ||||
-rw-r--r-- | vdslib/src/vespa/vdslib/state/nodetype.h | 4 | ||||
-rw-r--r-- | vdslib/src/vespa/vdslib/state/state.cpp | 4 | ||||
-rw-r--r-- | vdslib/src/vespa/vdslib/state/state.h | 4 |
12 files changed, 40 insertions, 40 deletions
diff --git a/vdslib/src/vespa/vdslib/container/parameters.cpp b/vdslib/src/vespa/vdslib/container/parameters.cpp index 6294c35ca08..6747bee2bec 100644 --- a/vdslib/src/vespa/vdslib/container/parameters.cpp +++ b/vdslib/src/vespa/vdslib/container/parameters.cpp @@ -111,14 +111,14 @@ Parameters* Parameters::clone() const return new Parameters(*this); } -vespalib::stringref Parameters::get(const vespalib::stringref& id, const vespalib::stringref& def) const +vespalib::stringref Parameters::get(vespalib::stringref id, vespalib::stringref def) const { ParametersMap::const_iterator it = _parameters.find(id); if (it == _parameters.end()) return def; return it->second; } -bool Parameters::get(const KeyT & id, ValueRef & v ) const +bool Parameters::lookup(KeyT id, ValueRef & v ) const { ParametersMap::const_iterator it = _parameters.find(id); if (it == _parameters.end()) return false; @@ -160,17 +160,17 @@ std::string Parameters::toString() const return ret; } -template void vdslib::Parameters::set(const vespalib::stringref &, int32_t); -template void vdslib::Parameters::set(const vespalib::stringref &, int64_t); -template void vdslib::Parameters::set(const vespalib::stringref &, uint64_t); -template void vdslib::Parameters::set(const vespalib::stringref &, double); -template void vdslib::Parameters::set(const vespalib::stringref &, const char *); -template void vdslib::Parameters::set(const vespalib::stringref &, vespalib::string); -template void vdslib::Parameters::set(const vespalib::stringref &, std::string); -template int32_t vdslib::Parameters::get(const vespalib::stringref &, int32_t) const; -template int64_t vdslib::Parameters::get(const vespalib::stringref &, int64_t) const; -template uint64_t vdslib::Parameters::get(const vespalib::stringref &, uint64_t) const; -template double vdslib::Parameters::get(const vespalib::stringref &, double) const; -template std::string vdslib::Parameters::get(const vespalib::stringref &, std::string) const; +template void vdslib::Parameters::set(vespalib::stringref , int32_t); +template void vdslib::Parameters::set(vespalib::stringref , int64_t); +template void vdslib::Parameters::set(vespalib::stringref , uint64_t); +template void vdslib::Parameters::set(vespalib::stringref , double); +template void vdslib::Parameters::set(vespalib::stringref , const char *); +template void vdslib::Parameters::set(vespalib::stringref , vespalib::string); +template void vdslib::Parameters::set(vespalib::stringref , std::string); +template int32_t vdslib::Parameters::get(vespalib::stringref , int32_t) const; +template int64_t vdslib::Parameters::get(vespalib::stringref , int64_t) const; +template uint64_t vdslib::Parameters::get(vespalib::stringref , uint64_t) const; +template double vdslib::Parameters::get(vespalib::stringref , double) const; +template std::string vdslib::Parameters::get(vespalib::stringref , std::string) const; VESPALIB_HASH_MAP_INSTANTIATE(vespalib::string, vdslib::Parameters::Value); diff --git a/vdslib/src/vespa/vdslib/container/parameters.h b/vdslib/src/vespa/vdslib/container/parameters.h index ab65932496a..02d54643e18 100644 --- a/vdslib/src/vespa/vdslib/container/parameters.h +++ b/vdslib/src/vespa/vdslib/container/parameters.h @@ -32,7 +32,7 @@ public: { public: Value() { } - Value(const vespalib::stringref & s) : vespalib::string(s) { } + Value(vespalib::stringref s) : vespalib::string(s) { } Value(const vespalib::string & s) : vespalib::string(s) { } Value(const void *v, size_t sz) : vespalib::string(v, sz) { } size_t length() const { return size() - 1; } @@ -57,10 +57,10 @@ public: size_t getSerializedSize() const override; - bool hasValue(const KeyT & id) const { return (_parameters.find(id) != _parameters.end()); } + bool hasValue(KeyT id) const { return (_parameters.find(id) != _parameters.end()); } unsigned int size() const { return _parameters.size(); } - bool get(const KeyT & id, ValueRef & v ) const; - void set(const KeyT & id, const void * v, size_t sz) { _parameters[id] = Value(v, sz); } + bool lookup(KeyT id, ValueRef & v) const; + void set(KeyT id, const void * v, size_t sz) { _parameters[id] = Value(v, sz); } void print(std::ostream& out, bool verbose, const std::string& indent) const; @@ -68,8 +68,8 @@ public: ParametersMap::const_iterator begin() const { return _parameters.begin(); } ParametersMap::const_iterator end() const { return _parameters.end(); } /// Convenience from earlier use. - void set(const KeyT & id, const vespalib::stringref & value) { _parameters[id] = Value(value.data(), value.size()); } - vespalib::stringref get(const KeyT & id, const vespalib::stringref & def = "") const; + void set(KeyT id, vespalib::stringref value) { _parameters[id] = Value(value.data(), value.size()); } + vespalib::stringref get(KeyT id, vespalib::stringref def = "") const; /** * Set the value identified by the id given. This requires the type to be * convertible by stringstreams. @@ -78,7 +78,7 @@ public: * @param t The value to save. Will be converted to a string. */ template<typename T> - void set(const KeyT & id, T t); + void set(KeyT id, T t); /** * Get the value identified by the id given, as the same type as the default @@ -90,7 +90,7 @@ public: * the default itself if value did not exist. */ template<typename T> - T get(const KeyT & id, T def) const; + T get(KeyT id, T def) const; std::string toString() const; }; diff --git a/vdslib/src/vespa/vdslib/container/parameters.hpp b/vdslib/src/vespa/vdslib/container/parameters.hpp index 3647164961d..d7ad1d266cb 100644 --- a/vdslib/src/vespa/vdslib/container/parameters.hpp +++ b/vdslib/src/vespa/vdslib/container/parameters.hpp @@ -8,7 +8,7 @@ namespace vdslib { template<typename T> void -Parameters::set(const KeyT & id, T t) { +Parameters::set(KeyT id, T t) { vespalib::asciistream ost; ost << t; _parameters[id] = ost.str(); @@ -16,9 +16,9 @@ Parameters::set(const KeyT & id, T t) { template<typename T> T -Parameters::get(const KeyT & id, T def) const { +Parameters::get(KeyT id, T def) const { vespalib::stringref ref; - if (!get(id, ref)) return def; + if (!lookup(id, ref)) return def; vespalib::asciistream ist(ref); T t; ist >> t; diff --git a/vdslib/src/vespa/vdslib/state/clusterstate.h b/vdslib/src/vespa/vdslib/state/clusterstate.h index 26c6f1b95ef..35259ba672b 100644 --- a/vdslib/src/vespa/vdslib/state/clusterstate.h +++ b/vdslib/src/vespa/vdslib/state/clusterstate.h @@ -62,7 +62,7 @@ public: void setVersion(uint32_t version) { _version = version; } void setClusterState(const State& state); void setNodeState(const Node& node, const NodeState& state); - void setDescription(const vespalib::stringref & s) { _description = s; } + void setDescription(vespalib::stringref s) { _description = s; } void setDistributionBitCount(uint16_t count) { _distributionBits = count; } void print(std::ostream& out, bool verbose, const std::string& indent) const override; diff --git a/vdslib/src/vespa/vdslib/state/diskstate.cpp b/vdslib/src/vespa/vdslib/state/diskstate.cpp index c963dacff82..56e9f36b442 100644 --- a/vdslib/src/vespa/vdslib/state/diskstate.cpp +++ b/vdslib/src/vespa/vdslib/state/diskstate.cpp @@ -30,7 +30,7 @@ DiskState::DiskState(const State& state, const vespalib::stringref & description setCapacity(capacity); } -DiskState::DiskState(const vespalib::stringref & serialized) +DiskState::DiskState(vespalib::stringref serialized) : _state(&State::UP), _description(""), _capacity(1.0) diff --git a/vdslib/src/vespa/vdslib/state/diskstate.h b/vdslib/src/vespa/vdslib/state/diskstate.h index 0dcde1e7879..fb71f5c9733 100644 --- a/vdslib/src/vespa/vdslib/state/diskstate.h +++ b/vdslib/src/vespa/vdslib/state/diskstate.h @@ -23,7 +23,7 @@ public: DiskState(); DiskState(const State&, const vespalib::stringref & description = "", double capacity = 1.0); - explicit DiskState(const vespalib::stringref & serialized); + explicit DiskState(vespalib::stringref serialized); void serialize(vespalib::asciistream & out, const vespalib::stringref & prefix = "", bool includeReason = true, bool useOldFormat = false) const; @@ -34,7 +34,7 @@ public: void setState(const State& state); void setCapacity(double capacity); - void setDescription(const vespalib::stringref & desc) { _description = desc; } + void setDescription(vespalib::stringref desc) { _description = desc; } void print(std::ostream& out, bool verbose, const std::string& indent) const override; bool operator==(const DiskState& other) const; diff --git a/vdslib/src/vespa/vdslib/state/nodestate.cpp b/vdslib/src/vespa/vdslib/state/nodestate.cpp index d59686dcb1c..c6da5757de3 100644 --- a/vdslib/src/vespa/vdslib/state/nodestate.cpp +++ b/vdslib/src/vespa/vdslib/state/nodestate.cpp @@ -78,7 +78,7 @@ namespace { }; } -NodeState::NodeState(const vespalib::stringref & serialized, const NodeType* type) +NodeState::NodeState(vespalib::stringref serialized, const NodeType* type) : _type(type), _state(&State::UP), _description(), diff --git a/vdslib/src/vespa/vdslib/state/nodestate.h b/vdslib/src/vespa/vdslib/state/nodestate.h index edf2a308fa0..fef251bdaf1 100644 --- a/vdslib/src/vespa/vdslib/state/nodestate.h +++ b/vdslib/src/vespa/vdslib/state/nodestate.h @@ -46,7 +46,7 @@ public: const vespalib::stringref & description = "", double capacity = 1.0, uint16_t reliability = 1); /** Set type if you want to verify that content fit with the given type. */ - NodeState(const vespalib::stringref & serialized, const NodeType* nodeType = 0); + NodeState(vespalib::stringref serialized, const NodeType* nodeType = 0); ~NodeState(); /** @@ -77,7 +77,7 @@ public: void setReliability(uint16_t reliability); void setInitProgress(vespalib::Double initProgress); void setStartTimestamp(uint64_t startTimestamp); - void setDescription(const vespalib::stringref & desc) { _description = desc; } + void setDescription(vespalib::stringref desc) { _description = desc; } void setDiskCount(uint16_t count); void setDiskState(uint16_t index, const DiskState&); diff --git a/vdslib/src/vespa/vdslib/state/nodetype.cpp b/vdslib/src/vespa/vdslib/state/nodetype.cpp index c7676221e14..b5664bf691b 100644 --- a/vdslib/src/vespa/vdslib/state/nodetype.cpp +++ b/vdslib/src/vespa/vdslib/state/nodetype.cpp @@ -14,7 +14,7 @@ const NodeType NodeType::STORAGE("storage", 0); const NodeType NodeType::DISTRIBUTOR("distributor", 1); const NodeType& -NodeType::get(const vespalib::stringref & serialized) +NodeType::get(vespalib::stringref serialized) { if (serialized == STORAGE._name) { return STORAGE; @@ -26,7 +26,7 @@ NodeType::get(const vespalib::stringref & serialized) "Unknown node type " + serialized + " given.", VESPA_STRLOC); } -NodeType::NodeType(const vespalib::stringref & name, uint16_t enumValue) +NodeType::NodeType(vespalib::stringref name, uint16_t enumValue) : _enumValue(enumValue), _name(name) { } diff --git a/vdslib/src/vespa/vdslib/state/nodetype.h b/vdslib/src/vespa/vdslib/state/nodetype.h index 318cf59218e..4adf3e0d761 100644 --- a/vdslib/src/vespa/vdslib/state/nodetype.h +++ b/vdslib/src/vespa/vdslib/state/nodetype.h @@ -24,14 +24,14 @@ class NodeType { uint16_t _enumValue; vespalib::string _name; - NodeType(const vespalib::stringref & name, uint16_t enumValue); + NodeType(vespalib::stringref name, uint16_t enumValue); public: static const NodeType DISTRIBUTOR; static const NodeType STORAGE; /** Throws vespalib::IllegalArgumentException if invalid state given. */ - static const NodeType& get(const vespalib::stringref & serialized); + static const NodeType& get(vespalib::stringref serialized); const vespalib::string& serialize() const { return _name; } operator uint16_t() const { return _enumValue; } diff --git a/vdslib/src/vespa/vdslib/state/state.cpp b/vdslib/src/vespa/vdslib/state/state.cpp index 2c756aed7f5..b3109492c90 100644 --- a/vdslib/src/vespa/vdslib/state/state.cpp +++ b/vdslib/src/vespa/vdslib/state/state.cpp @@ -23,7 +23,7 @@ const State State::UP("Up", "u", 6, true, true, true, true, true, true); const State& -State::get(const vespalib::stringref & serialized) +State::get(vespalib::stringref serialized) { if (serialized.size() == 1) switch(serialized[0]) { case '-': return UNKNOWN; @@ -39,7 +39,7 @@ State::get(const vespalib::stringref & serialized) "Unknown state " + serialized + " given.", VESPA_STRLOC); } -State::State(const vespalib::stringref & name, const vespalib::stringref & serialized, +State::State(vespalib::stringref name, const vespalib::stringref & serialized, uint8_t rank, bool validDisk, bool validDistributorReported, bool validStorageReported, bool validDistributorWanted, bool validStorageWanted, diff --git a/vdslib/src/vespa/vdslib/state/state.h b/vdslib/src/vespa/vdslib/state/state.h index e0857fe8ccd..75f5e1cbb8e 100644 --- a/vdslib/src/vespa/vdslib/state/state.h +++ b/vdslib/src/vespa/vdslib/state/state.h @@ -26,7 +26,7 @@ class State : public vespalib::Printable { bool _validClusterState; State(const State&); - State(const vespalib::stringref & name, const vespalib::stringref & serialized, + State(vespalib::stringref name, const vespalib::stringref & serialized, uint8_t rank, bool validDisk, bool validDistributorReported, bool validStorageReported, bool validDistributorWanted, bool validStorageWanted, @@ -45,7 +45,7 @@ public: static const State UP; /** Throws vespalib::IllegalArgumentException if invalid state given. */ - static const State& get(const vespalib::stringref & serialized); + static const State& get(vespalib::stringref serialized); const vespalib::string& serialize() const { return _serialized; } bool validDiskState() const { return _validDiskState; } |