aboutsummaryrefslogtreecommitdiffstats
path: root/vespalib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2024-04-24 10:04:23 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2024-04-24 10:04:23 +0000
commit48fcdefa6a6f2b4ee74cad0c67edbdd5e4612e6c (patch)
tree4b61bb7a87182676bc72bd4323c321ee3630c0d9 /vespalib
parent5a45898ac1dc3c512e3306d92a2c082f04f4f837 (diff)
Add noexcept
Diffstat (limited to 'vespalib')
-rw-r--r--vespalib/src/vespa/vespalib/util/alloc.h8
-rw-r--r--vespalib/src/vespa/vespalib/util/array.h2
-rw-r--r--vespalib/src/vespa/vespalib/util/array.hpp26
-rw-r--r--vespalib/src/vespa/vespalib/util/generation_hold_list.h8
-rw-r--r--vespalib/src/vespa/vespalib/util/generation_hold_list.hpp4
-rw-r--r--vespalib/src/vespa/vespalib/util/generationholder.cpp2
-rw-r--r--vespalib/src/vespa/vespalib/util/generationholder.h6
-rw-r--r--vespalib/src/vespa/vespalib/util/optimized.h42
8 files changed, 49 insertions, 49 deletions
diff --git a/vespalib/src/vespa/vespalib/util/alloc.h b/vespalib/src/vespa/vespalib/util/alloc.h
index e9ae8a0ed58..394deb486aa 100644
--- a/vespalib/src/vespa/vespalib/util/alloc.h
+++ b/vespalib/src/vespa/vespalib/util/alloc.h
@@ -84,7 +84,7 @@ private:
: _alloc(allocator->alloc(sz)),
_allocator(allocator)
{ }
- Alloc(const MemoryAllocator * allocator) noexcept
+ explicit Alloc(const MemoryAllocator * allocator) noexcept
: _alloc(),
_allocator(allocator)
{ }
@@ -102,19 +102,19 @@ namespace vespalib {
/// Rounds up to the closest number that is a power of 2
inline size_t
-roundUp2inN(size_t minimum) {
+roundUp2inN(size_t minimum) noexcept {
return 2ul << Optimized::msbIdx(minimum - 1);
}
/// Rounds minElems up to the closest number where minElems*elemSize is a power of 2
inline size_t
-roundUp2inN(size_t minElems, size_t elemSize) {
+roundUp2inN(size_t minElems, size_t elemSize) noexcept {
return roundUp2inN(minElems * elemSize)/elemSize;
}
template <typename T>
size_t
-roundUp2inN(size_t elems) {
+roundUp2inN(size_t elems) noexcept {
return roundUp2inN(elems, sizeof(T));
}
diff --git a/vespalib/src/vespa/vespalib/util/array.h b/vespalib/src/vespa/vespalib/util/array.h
index d0af62861f8..6cc22235361 100644
--- a/vespalib/src/vespa/vespalib/util/array.h
+++ b/vespalib/src/vespa/vespalib/util/array.h
@@ -83,7 +83,7 @@ public:
using value_type = T;
using size_type = size_t;
- Array(const Alloc & initial=Alloc::alloc());
+ Array(const Alloc & initial=Alloc::alloc()) noexcept;
Array(size_t sz, const Alloc & initial=Alloc::alloc());
Array(Alloc && buf, size_t sz) noexcept;
Array(Array &&rhs) noexcept;
diff --git a/vespalib/src/vespa/vespalib/util/array.hpp b/vespalib/src/vespa/vespalib/util/array.hpp
index 6ffbd63bd3a..33213df4cf6 100644
--- a/vespalib/src/vespa/vespalib/util/array.hpp
+++ b/vespalib/src/vespa/vespalib/util/array.hpp
@@ -148,15 +148,15 @@ void Array<T>::increase(size_t n)
}
template <typename T>
-Array<T>::Array(const Alloc & initial)
+Array<T>::Array(const Alloc & initial) noexcept
: _array(initial.create(0)),
_sz(0)
{ }
template <typename T>
-Array<T>::Array(Alloc && buf, size_t sz) noexcept :
- _array(std::move(buf)),
- _sz(sz)
+Array<T>::Array(Alloc && buf, size_t sz) noexcept
+ : _array(std::move(buf)),
+ _sz(sz)
{
}
@@ -170,25 +170,25 @@ Array<T>::Array(Array &&rhs) noexcept
}
template <typename T>
-Array<T>::Array(size_t sz, const Alloc & initial) :
- _array(initial.create(sz * sizeof(T))),
- _sz(sz)
+Array<T>::Array(size_t sz, const Alloc & initial)
+ : _array(initial.create(sz * sizeof(T))),
+ _sz(sz)
{
construct(array(0), _sz, std::is_trivially_default_constructible<T>());
}
template <typename T>
-Array<T>::Array(size_t sz, T value, const Alloc & initial) :
- _array(initial.create(sz * sizeof(T))),
- _sz(sz)
+Array<T>::Array(size_t sz, T value, const Alloc & initial)
+ : _array(initial.create(sz * sizeof(T))),
+ _sz(sz)
{
construct(array(0), _sz, value, std::is_trivially_copyable<T>());
}
template <typename T>
-Array<T>::Array(const_iterator begin_, const_iterator end_, const Alloc & initial) :
- _array(initial.create(begin_ != end_ ? sizeof(T) * (end_-begin_) : 0)),
- _sz(end_-begin_)
+Array<T>::Array(const_iterator begin_, const_iterator end_, const Alloc & initial)
+ : _array(initial.create(begin_ != end_ ? sizeof(T) * (end_-begin_) : 0)),
+ _sz(end_-begin_)
{
construct(array(0), begin_, _sz, std::is_trivially_copyable<T>());
}
diff --git a/vespalib/src/vespa/vespalib/util/generation_hold_list.h b/vespalib/src/vespa/vespalib/util/generation_hold_list.h
index 5d150c8a015..10ffb38816b 100644
--- a/vespalib/src/vespa/vespalib/util/generation_hold_list.h
+++ b/vespalib/src/vespa/vespalib/util/generation_hold_list.h
@@ -22,11 +22,11 @@ private:
struct ElemWithGen {
T elem;
generation_t gen;
- ElemWithGen(T elem_in, generation_t gen_in)
+ ElemWithGen(T elem_in, generation_t gen_in) noexcept
: elem(std::move(elem_in)),
gen(gen_in)
{}
- size_t byte_size() const {
+ size_t byte_size() const noexcept {
if constexpr (track_bytes_held) {
return elem->byte_size();
}
@@ -54,7 +54,7 @@ private:
void reclaim_internal(generation_t oldest_used_gen, Func callback);
public:
- GenerationHoldList();
+ GenerationHoldList() noexcept;
~GenerationHoldList();
/**
@@ -99,7 +99,7 @@ public:
template<typename Func>
void reclaim_all(Func callback);
- size_t get_held_bytes() const { return _held_bytes.load(std::memory_order_relaxed); }
+ size_t get_held_bytes() const noexcept { return _held_bytes.load(std::memory_order_relaxed); }
// Static size of _phase_2_list might depend on std::deque implementation
static constexpr size_t sizeof_phase_2_list = sizeof(ElemWithGenList);
diff --git a/vespalib/src/vespa/vespalib/util/generation_hold_list.hpp b/vespalib/src/vespa/vespalib/util/generation_hold_list.hpp
index 532aa9abe28..dfe84f9cfc0 100644
--- a/vespalib/src/vespa/vespalib/util/generation_hold_list.hpp
+++ b/vespalib/src/vespa/vespalib/util/generation_hold_list.hpp
@@ -12,7 +12,7 @@ void
GenerationHoldList<T, track_bytes_held, use_deque>::assign_generation_internal(generation_t current_gen)
{
for (auto& elem : _phase_1_list) {
- _phase_2_list.push_back(ElemWithGen(std::move(elem), current_gen));
+ _phase_2_list.emplace_back(std::move(elem), current_gen);
}
_phase_1_list.clear();
}
@@ -40,7 +40,7 @@ GenerationHoldList<T, track_bytes_held, use_deque>::reclaim_internal(generation_
}
template <typename T, bool track_bytes_held, bool use_deque>
-GenerationHoldList<T, track_bytes_held, use_deque>::GenerationHoldList()
+GenerationHoldList<T, track_bytes_held, use_deque>::GenerationHoldList() noexcept
: _phase_1_list(),
_phase_2_list(),
_held_bytes()
diff --git a/vespalib/src/vespa/vespalib/util/generationholder.cpp b/vespalib/src/vespa/vespalib/util/generationholder.cpp
index 9930cfedbe4..c172220bac2 100644
--- a/vespalib/src/vespa/vespalib/util/generationholder.cpp
+++ b/vespalib/src/vespa/vespalib/util/generationholder.cpp
@@ -12,7 +12,7 @@ template void GenerationHolderParent::reclaim_internal
GenerationHeldBase::~GenerationHeldBase() = default;
-GenerationHolder::GenerationHolder()
+GenerationHolder::GenerationHolder() noexcept
: GenerationHolderParent()
{
}
diff --git a/vespalib/src/vespa/vespalib/util/generationholder.h b/vespalib/src/vespa/vespalib/util/generationholder.h
index 00ce8182394..49ef038ad67 100644
--- a/vespalib/src/vespa/vespalib/util/generationholder.h
+++ b/vespalib/src/vespa/vespalib/util/generationholder.h
@@ -19,12 +19,12 @@ private:
size_t _byte_size;
public:
- GenerationHeldBase(size_t byte_size_in)
+ GenerationHeldBase(size_t byte_size_in) noexcept
: _byte_size(byte_size_in)
{ }
virtual ~GenerationHeldBase();
- size_t byte_size() const { return _byte_size; }
+ constexpr size_t byte_size() const noexcept { return _byte_size; }
};
using GenerationHolderParent = GenerationHoldList<GenerationHeldBase::UP, true, false>;
@@ -35,7 +35,7 @@ using GenerationHolderParent = GenerationHoldList<GenerationHeldBase::UP, true,
*/
class GenerationHolder : public GenerationHolderParent {
public:
- GenerationHolder();
+ GenerationHolder() noexcept;
};
}
diff --git a/vespalib/src/vespa/vespalib/util/optimized.h b/vespalib/src/vespa/vespalib/util/optimized.h
index 12d1b770904..f651a411367 100644
--- a/vespalib/src/vespa/vespalib/util/optimized.h
+++ b/vespalib/src/vespa/vespalib/util/optimized.h
@@ -16,15 +16,15 @@ namespace vespalib {
class Optimized
{
public:
- static int msbIdx(unsigned int v);
- static int msbIdx(unsigned long v);
- static int msbIdx(unsigned long long v);
- static int lsbIdx(unsigned int v);
- static int lsbIdx(unsigned long v);
- static int lsbIdx(unsigned long long v);
- static constexpr int popCount(unsigned int v) { return __builtin_popcount(v); }
- static constexpr int popCount(unsigned long v) { return __builtin_popcountl(v); }
- static constexpr int popCount(unsigned long long v) { return __builtin_popcountll(v); }
+ static int msbIdx(unsigned int v) noexcept;
+ static int msbIdx(unsigned long v) noexcept;
+ static int msbIdx(unsigned long long v) noexcept;
+ static int lsbIdx(unsigned int v) noexcept;
+ static int lsbIdx(unsigned long v) noexcept;
+ static int lsbIdx(unsigned long long v) noexcept;
+ static constexpr int popCount(unsigned int v) noexcept { return __builtin_popcount(v); }
+ static constexpr int popCount(unsigned long v) noexcept { return __builtin_popcountl(v); }
+ static constexpr int popCount(unsigned long long v) noexcept { return __builtin_popcountll(v); }
};
/**
@@ -64,43 +64,43 @@ public:
**/
#ifdef __x86_64__
-inline int Optimized::msbIdx(unsigned int v) {
+inline int Optimized::msbIdx(unsigned int v) noexcept {
unsigned int result;
__asm __volatile("bsrl %0,%0" : "=r" (result) : "0" (v));
return result;
}
-inline int Optimized::lsbIdx(unsigned int v) {
+inline int Optimized::lsbIdx(unsigned int v) noexcept {
unsigned int result;
__asm __volatile("bsfl %0,%0" : "=r" (result) : "0" (v));
return result;
}
-inline int Optimized::msbIdx(unsigned long v) {
+inline int Optimized::msbIdx(unsigned long v) noexcept {
unsigned long result;
__asm __volatile("bsrq %0,%0" : "=r" (result) : "0" (v));
return result;
}
-inline int Optimized::lsbIdx(unsigned long v) {
+inline int Optimized::lsbIdx(unsigned long v) noexcept {
unsigned long result;
__asm __volatile("bsfq %0,%0" : "=r" (result) : "0" (v));
return result;
}
-inline int Optimized::msbIdx(unsigned long long v) {
+inline int Optimized::msbIdx(unsigned long long v) noexcept {
unsigned long long result;
__asm __volatile("bsrq %0,%0" : "=r" (result) : "0" (v));
return result;
}
-inline int Optimized::lsbIdx(unsigned long long v) {
+inline int Optimized::lsbIdx(unsigned long long v) noexcept {
unsigned long long result;
__asm __volatile("bsfq %0,%0" : "=r" (result) : "0" (v));
return result;
}
#else
-inline int Optimized::msbIdx(unsigned int v) { return v ? sizeof(unsigned int) * 8 - 1 - __builtin_clz(v) : 0; }
-inline int Optimized::msbIdx(unsigned long v) { return v ? sizeof(unsigned long) * 8 - 1 - __builtin_clzl(v) : 0; }
-inline int Optimized::msbIdx(unsigned long long v) { return v ? sizeof(unsigned long long) * 8 - 1 - __builtin_clzll(v) : 0; }
-inline int Optimized::lsbIdx(unsigned int v) { return v ? __builtin_ctz(v) : 0; }
-inline int Optimized::lsbIdx(unsigned long v) { return v ? __builtin_ctzl(v) : 0; }
-inline int Optimized::lsbIdx(unsigned long long v) { return v ? __builtin_ctzll(v) : 0; }
+inline int Optimized::msbIdx(unsigned int v) noexcept { return v ? sizeof(unsigned int) * 8 - 1 - __builtin_clz(v) : 0; }
+inline int Optimized::msbIdx(unsigned long v) noexcept { return v ? sizeof(unsigned long) * 8 - 1 - __builtin_clzl(v) : 0; }
+inline int Optimized::msbIdx(unsigned long long v) noexcept { return v ? sizeof(unsigned long long) * 8 - 1 - __builtin_clzll(v) : 0; }
+inline int Optimized::lsbIdx(unsigned int v) noexcept { return v ? __builtin_ctz(v) : 0; }
+inline int Optimized::lsbIdx(unsigned long v) noexcept { return v ? __builtin_ctzl(v) : 0; }
+inline int Optimized::lsbIdx(unsigned long long v) noexcept { return v ? __builtin_ctzll(v) : 0; }
#endif
#define VESPA_DLL_LOCAL __attribute__ ((visibility("hidden")))