summaryrefslogtreecommitdiffstats
path: root/vespalib
diff options
context:
space:
mode:
authorTor Brede Vekterli <vekterli@vespa.ai>2023-10-31 16:37:25 +0000
committerTor Brede Vekterli <vekterli@vespa.ai>2023-11-01 10:01:38 +0000
commitfaf60027d1073321cd99635ef9a683f72d9fa32d (patch)
treeb5d745e1e9967bafbbc9b1ecabb47ddd10517b84 /vespalib
parentfba51caeea9e670dc0ba3fba93d6452105ce4c36 (diff)
Add `noexcept` and minor cleanups
Diffstat (limited to 'vespalib')
-rw-r--r--vespalib/src/vespa/vespalib/util/hw_info.h44
1 files changed, 22 insertions, 22 deletions
diff --git a/vespalib/src/vespa/vespalib/util/hw_info.h b/vespalib/src/vespa/vespalib/util/hw_info.h
index 2632aa70654..cebf65196ed 100644
--- a/vespalib/src/vespa/vespalib/util/hw_info.h
+++ b/vespalib/src/vespa/vespalib/util/hw_info.h
@@ -2,8 +2,8 @@
#pragma once
-#include <cstdint>
#include <algorithm>
+#include <cstdint>
namespace vespalib {
@@ -16,15 +16,15 @@ public:
class Disk {
private:
uint64_t _sizeBytes;
- bool _slow;
- bool _shared;
+ bool _slow;
+ bool _shared;
public:
- Disk(uint64_t sizeBytes_, bool slow_, bool shared_)
+ Disk(uint64_t sizeBytes_, bool slow_, bool shared_) noexcept
: _sizeBytes(sizeBytes_), _slow(slow_), _shared(shared_) {}
- uint64_t sizeBytes() const { return _sizeBytes; }
- bool slow() const { return _slow; }
- bool shared() const { return _shared; }
- bool operator == (const Disk & rhs) const {
+ uint64_t sizeBytes() const noexcept { return _sizeBytes; }
+ [[nodiscard]] bool slow() const noexcept { return _slow; }
+ [[nodiscard]] bool shared() const noexcept { return _shared; }
+ bool operator == (const Disk & rhs) const noexcept {
return (_sizeBytes == rhs._sizeBytes) && (_slow == rhs._slow) && (_shared == rhs._shared);
}
};
@@ -33,27 +33,27 @@ public:
private:
uint64_t _sizeBytes;
public:
- Memory(uint64_t sizeBytes_) : _sizeBytes(sizeBytes_) {}
- uint64_t sizeBytes() const { return _sizeBytes; }
- bool operator == (const Memory & rhs) const { return _sizeBytes == rhs._sizeBytes; }
+ Memory(uint64_t sizeBytes_) noexcept : _sizeBytes(sizeBytes_) {}
+ uint64_t sizeBytes() const noexcept { return _sizeBytes; }
+ bool operator == (const Memory & rhs) const noexcept { return _sizeBytes == rhs._sizeBytes; }
};
class Cpu {
private:
uint32_t _cores;
public:
- Cpu(uint32_t cores_) : _cores(std::max(1u, cores_)) { }
- uint32_t cores() const { return _cores; }
- bool operator == (const Cpu & rhs) const { return _cores == rhs._cores; }
+ Cpu(uint32_t cores_) noexcept : _cores(std::max(1u, cores_)) { }
+ uint32_t cores() const noexcept { return _cores; }
+ bool operator == (const Cpu & rhs) const noexcept { return _cores == rhs._cores; }
};
private:
- Disk _disk;
+ Disk _disk;
Memory _memory;
- Cpu _cpu;
+ Cpu _cpu;
public:
- HwInfo()
+ HwInfo() noexcept
: _disk(0, false, false),
_memory(0),
_cpu(1)
@@ -62,17 +62,17 @@ public:
HwInfo(const Disk &disk_,
const Memory &memory_,
- const Cpu &cpu_)
+ const Cpu &cpu_) noexcept
: _disk(disk_),
_memory(memory_),
_cpu(cpu_)
{
}
- const Disk &disk() const { return _disk; }
- const Memory &memory() const { return _memory; }
- const Cpu &cpu() const { return _cpu; }
- bool operator == (const HwInfo & rhs) const {
+ const Disk &disk() const noexcept { return _disk; }
+ const Memory &memory() const noexcept { return _memory; }
+ const Cpu &cpu() const noexcept { return _cpu; }
+ bool operator == (const HwInfo & rhs) const noexcept {
return (_cpu == rhs._cpu) && (_disk == rhs._disk) && (_memory == rhs._memory);
}
};