diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2021-07-01 10:39:35 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2021-07-01 11:27:51 +0000 |
commit | a27dedb61be36844466f7a56710d7600ba224622 (patch) | |
tree | cbd5105854536f41e375b2171df39f538516fa07 /vespalib | |
parent | c474c687512c5100c3a7aafdc72d813544904020 (diff) |
Add final and noexcept
Diffstat (limited to 'vespalib')
8 files changed, 35 insertions, 37 deletions
diff --git a/vespalib/src/vespa/vespalib/data/slime/array_value.h b/vespalib/src/vespa/vespalib/data/slime/array_value.h index 02bd730275b..0509c8e7414 100644 --- a/vespalib/src/vespa/vespalib/data/slime/array_value.h +++ b/vespalib/src/vespa/vespalib/data/slime/array_value.h @@ -13,7 +13,7 @@ namespace vespalib::slime { * Class representing a collection of ordered values that can be * looked up by index. **/ -class ArrayValue : public Value +class ArrayValue final : public Value { private: SymbolTable &_symbolTable; diff --git a/vespalib/src/vespa/vespalib/data/slime/basic_value.h b/vespalib/src/vespa/vespalib/data/slime/basic_value.h index 3768523ada0..20183999d8f 100644 --- a/vespalib/src/vespa/vespalib/data/slime/basic_value.h +++ b/vespalib/src/vespa/vespalib/data/slime/basic_value.h @@ -13,33 +13,33 @@ namespace vespalib::slime { /** * Classes representing a single basic value. **/ -class BasicBoolValue : public Value { +class BasicBoolValue final : public Value { bool _value; public: - BasicBoolValue(bool bit) : _value(bit) {} + BasicBoolValue(bool bit) noexcept : _value(bit) {} bool asBool() const override { return _value; } Type type() const override { return BOOL::instance; } }; -class BasicLongValue : public Value { +class BasicLongValue final : public Value { int64_t _value; public: - BasicLongValue(int64_t l) : _value(l) {} + BasicLongValue(int64_t l) noexcept : _value(l) {} int64_t asLong() const override { return _value; } double asDouble() const override { return _value; } Type type() const override { return LONG::instance; } }; -class BasicDoubleValue : public Value { +class BasicDoubleValue final : public Value { double _value; public: - BasicDoubleValue(double d) : _value(d) {} + BasicDoubleValue(double d) noexcept : _value(d) {} double asDouble() const override { return _value; } int64_t asLong() const override { return _value; } Type type() const override { return DOUBLE::instance; } }; -class BasicStringValue : public Value { +class BasicStringValue final : public Value { Memory _value; public: BasicStringValue(Memory str, Stash & stash); @@ -49,7 +49,7 @@ public: Type type() const override { return STRING::instance; } }; -class BasicDataValue : public Value { +class BasicDataValue final : public Value { Memory _value; public: BasicDataValue(Memory data, Stash & stash); diff --git a/vespalib/src/vespa/vespalib/data/slime/basic_value_factory.h b/vespalib/src/vespa/vespalib/data/slime/basic_value_factory.h index 5562415e33e..e7b2a9dd806 100644 --- a/vespalib/src/vespa/vespalib/data/slime/basic_value_factory.h +++ b/vespalib/src/vespa/vespalib/data/slime/basic_value_factory.h @@ -8,33 +8,33 @@ namespace vespalib::slime { -struct BoolValueFactory : public ValueFactory { +struct BoolValueFactory final : public ValueFactory { bool input; - BoolValueFactory(bool in) : input(in) {} + BoolValueFactory(bool in) noexcept : input(in) {} Value *create(Stash & stash) const override { return & stash.create<BasicBoolValue>(input); } }; -struct LongValueFactory : public ValueFactory { +struct LongValueFactory final : public ValueFactory { int64_t input; - LongValueFactory(int64_t in) : input(in) {} + LongValueFactory(int64_t in) noexcept : input(in) {} Value *create(Stash & stash) const override { return & stash.create<BasicLongValue>(input); } }; -struct DoubleValueFactory : public ValueFactory { +struct DoubleValueFactory final : public ValueFactory { double input; - DoubleValueFactory(double in) : input(in) {} + DoubleValueFactory(double in) noexcept : input(in) {} Value *create(Stash & stash) const override { return & stash.create<BasicDoubleValue>(input); } }; -struct StringValueFactory : public ValueFactory { +struct StringValueFactory final : public ValueFactory { Memory input; - StringValueFactory(Memory in) : input(in) {} + StringValueFactory(Memory in) noexcept : input(in) {} Value *create(Stash & stash) const override { return & stash.create<BasicStringValue>(input, stash); } }; -struct DataValueFactory : public ValueFactory { +struct DataValueFactory final : public ValueFactory { Memory input; - DataValueFactory(Memory in) : input(in) {} + DataValueFactory(Memory in) noexcept : input(in) {} Value *create(Stash & stash) const override { return & stash.create<BasicDataValue>(input, stash); } }; diff --git a/vespalib/src/vespa/vespalib/data/slime/empty_value_factory.h b/vespalib/src/vespa/vespalib/data/slime/empty_value_factory.h index ab50aad0709..c92b7ed1c68 100644 --- a/vespalib/src/vespa/vespalib/data/slime/empty_value_factory.h +++ b/vespalib/src/vespa/vespalib/data/slime/empty_value_factory.h @@ -7,20 +7,20 @@ namespace vespalib::slime { -struct NixValueFactory : public ValueFactory { +struct NixValueFactory final : public ValueFactory { Value *create(Stash &) const override { return NixValue::instance(); } }; -struct ArrayValueFactory : public ValueFactory { +struct ArrayValueFactory final : public ValueFactory { SymbolTable &symbolTable; size_t _reserve; - ArrayValueFactory(SymbolTable &table, size_t reserve) : symbolTable(table), _reserve(reserve) {} + ArrayValueFactory(SymbolTable &table, size_t reserve) noexcept : symbolTable(table), _reserve(reserve) {} Value *create(Stash & stash) const override; }; -struct ObjectValueFactory : public ValueFactory { +struct ObjectValueFactory final : public ValueFactory { SymbolTable &symbolTable; - ObjectValueFactory(SymbolTable &table) : symbolTable(table) {} + ObjectValueFactory(SymbolTable &table) noexcept : symbolTable(table) {} Value *create(Stash & stash) const override; }; diff --git a/vespalib/src/vespa/vespalib/data/slime/named_symbol_inserter.h b/vespalib/src/vespa/vespalib/data/slime/named_symbol_inserter.h index aac35b2e386..9752040d3e8 100644 --- a/vespalib/src/vespa/vespalib/data/slime/named_symbol_inserter.h +++ b/vespalib/src/vespa/vespalib/data/slime/named_symbol_inserter.h @@ -10,14 +10,14 @@ namespace vespalib::slime { /** * Class used to insert the name of a field into a symbol table. **/ -class NamedSymbolInserter : public SymbolInserter +class NamedSymbolInserter final : public SymbolInserter { private: SymbolTable &_table; const Memory &_name; public: - NamedSymbolInserter(SymbolTable &table, const Memory &name) + NamedSymbolInserter(SymbolTable &table, const Memory &name) noexcept : _table(table), _name(name) {} Symbol insert() override { return _table.insert(_name); diff --git a/vespalib/src/vespa/vespalib/data/slime/object_value.cpp b/vespalib/src/vespa/vespalib/data/slime/object_value.cpp index 094869f36ad..25a5d762825 100644 --- a/vespalib/src/vespa/vespalib/data/slime/object_value.cpp +++ b/vespalib/src/vespa/vespalib/data/slime/object_value.cpp @@ -24,18 +24,16 @@ ObjectValue::setLeaf(Memory name, const ValueFactory &input) { void ObjectValue::traverse(ObjectSymbolTraverser &ot) const { - typedef SymbolValueMap::const_iterator ITR; - for (ITR pos = _fields.begin(); pos != _fields.end(); ++pos) { - ot.field(pos->first, *pos->second); + for (const auto & field : _fields) { + ot.field(field.first, *field.second); } } void ObjectValue::traverse(ObjectTraverser &ot) const { - typedef SymbolValueMap::const_iterator ITR; - for (ITR pos = _fields.begin(); pos != _fields.end(); ++pos) { - Memory symbol = _symbolTable.inspect(pos->first); - ot.field(symbol, *pos->second); + for (const auto & field : _fields) { + Memory symbol = _symbolTable.inspect(field.first); + ot.field(symbol, *field.second); } } diff --git a/vespalib/src/vespa/vespalib/data/slime/object_value.h b/vespalib/src/vespa/vespalib/data/slime/object_value.h index 159a1431d29..4e9bc92c646 100644 --- a/vespalib/src/vespa/vespalib/data/slime/object_value.h +++ b/vespalib/src/vespa/vespalib/data/slime/object_value.h @@ -17,7 +17,7 @@ namespace vespalib::slime { * Class representing a collection of unordered values that can be * looked up by symbol. **/ -class ObjectValue : public Value +class ObjectValue final : public Value { private: struct hasher { diff --git a/vespalib/src/vespa/vespalib/data/slime/resolved_symbol.h b/vespalib/src/vespa/vespalib/data/slime/resolved_symbol.h index 2b8c39708c9..714230bdf94 100644 --- a/vespalib/src/vespa/vespalib/data/slime/resolved_symbol.h +++ b/vespalib/src/vespa/vespalib/data/slime/resolved_symbol.h @@ -13,14 +13,14 @@ namespace vespalib::slime { * appropriate symbol table. Thus, this class can satisfy both the * symbol lookup and inserter interfaces. **/ -class ResolvedSymbol : public SymbolLookup, - public SymbolInserter +class ResolvedSymbol final : public SymbolLookup, + public SymbolInserter { private: Symbol _symbol; public: - ResolvedSymbol(const Symbol &symbol) : _symbol(symbol) {} + ResolvedSymbol(const Symbol &symbol) noexcept : _symbol(symbol) {} Symbol lookup() const override { return _symbol; } |