diff options
author | Lars Knoll <lars.knoll@qt.io> | 2019-12-03 15:22:00 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2020-07-06 21:30:40 +0200 |
commit | c129362b4d9512bd33004d430bc3b817546cb1b7 (patch) | |
tree | ebad2fd99227d4413831abcfad42fd985ac47682 /src/corelib/tools/qarraydata.h | |
parent | fbce2e58e6f29dc8dde5618597d53e1b1007b503 (diff) |
Add a couple of noexcept
Change-Id: I993da2094482092540388ee72be3262bac94fad7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools/qarraydata.h')
-rw-r--r-- | src/corelib/tools/qarraydata.h | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/corelib/tools/qarraydata.h b/src/corelib/tools/qarraydata.h index fe8827afb8..b66a5add04 100644 --- a/src/corelib/tools/qarraydata.h +++ b/src/corelib/tools/qarraydata.h @@ -64,30 +64,30 @@ struct Q_CORE_EXPORT QArrayData uint flags; uint alloc; - inline size_t allocatedCapacity() + inline size_t allocatedCapacity() noexcept { return alloc; } - inline size_t constAllocatedCapacity() const + inline size_t constAllocatedCapacity() const noexcept { return alloc; } /// Returns true if sharing took place - bool ref() + bool ref() noexcept { ref_.ref(); return true; } /// Returns false if deallocation is necessary - bool deref() + bool deref() noexcept { return ref_.deref(); } - bool isShared() const + bool isShared() const noexcept { return ref_.loadRelaxed() != 1; } @@ -95,19 +95,19 @@ struct Q_CORE_EXPORT QArrayData // Returns true if a detach is necessary before modifying the data // This method is intentionally not const: if you want to know whether // detaching is necessary, you should be in a non-const function already - bool needsDetach() + bool needsDetach() const noexcept { return ref_.loadRelaxed() > 1; } - size_t detachCapacity(size_t newSize) const + size_t detachCapacity(size_t newSize) const noexcept { if (flags & CapacityReserved && newSize < constAllocatedCapacity()) return constAllocatedCapacity(); return newSize; } - ArrayOptions detachFlags() const + ArrayOptions detachFlags() const noexcept { ArrayOptions result = DefaultAllocationFlags; if (flags & CapacityReserved) @@ -160,7 +160,7 @@ struct QTypedArrayData return qMakePair(static_cast<QTypedArrayData *>(pair.first), static_cast<T *>(pair.second)); } - static void deallocate(QArrayData *data) + static void deallocate(QArrayData *data) noexcept { static_assert(sizeof(QTypedArrayData) == sizeof(QArrayData)); QArrayData::deallocate(data, sizeof(T), alignof(AlignmentDummy)); |