diff options
author | Marc Mutz <marc.mutz@qt.io> | 2022-07-08 09:30:37 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2022-07-08 20:14:52 +0000 |
commit | 3f32e4a73a95d287cf427bf0b16a99068a2b4daf (patch) | |
tree | 923e2ad8e7f965800e4a484f2e9189a662927cc8 /src/gui/painting | |
parent | 04ab0905e3cff6371b21731aa7f26d2f7f32ce7b (diff) |
Port QDataBuffer to qsizetype
Reduces the impedance mismatch with "normal" Qt containers.
Remove useless inline keywords as a drive-by. Functions defined in the
class body are implicitly inline since C++98. C++ declarations are
long-winded enough as they are, no need to add more cruft.
Also make the ctor explicit, we surely didn't intend to allow implicit
conversion from qsizetype to QDataBuffer
Pick-to: 6.4
Task-number: QTBUG-104825
Change-Id: I563dcd825afd63937b87e87fbbd324daaeb49d08
Reviewed-by: Lars Knoll <lars.knoll@gmail.com>
Diffstat (limited to 'src/gui/painting')
-rw-r--r-- | src/gui/painting/qdatabuffer_p.h | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/gui/painting/qdatabuffer_p.h b/src/gui/painting/qdatabuffer_p.h index b8bb44de6c..1e62c8d924 100644 --- a/src/gui/painting/qdatabuffer_p.h +++ b/src/gui/painting/qdatabuffer_p.h @@ -26,7 +26,7 @@ template <typename Type> class QDataBuffer { Q_DISABLE_COPY_MOVE(QDataBuffer) public: - QDataBuffer(int res) + explicit QDataBuffer(qsizetype res) { capacity = res; if (res) { @@ -51,11 +51,11 @@ public: inline bool isEmpty() const { return siz==0; } - inline int size() const { return siz; } + qsizetype size() const { return siz; } inline Type *data() const { return buffer; } - inline Type &at(int i) { Q_ASSERT(i >= 0 && i < siz); return buffer[i]; } - inline const Type &at(int i) const { Q_ASSERT(i >= 0 && i < siz); return buffer[i]; } + Type &at(qsizetype i) { Q_ASSERT(i >= 0 && i < siz); return buffer[i]; } + const Type &at(qsizetype i) const { Q_ASSERT(i >= 0 && i < siz); return buffer[i]; } inline Type &last() { Q_ASSERT(!isEmpty()); return buffer[siz-1]; } inline const Type &last() const { Q_ASSERT(!isEmpty()); return buffer[siz-1]; } inline Type &first() { Q_ASSERT(!isEmpty()); return buffer[0]; } @@ -72,12 +72,12 @@ public: --siz; } - inline void resize(int size) { + void resize(qsizetype size) { reserve(size); siz = size; } - inline void reserve(int size) { + void reserve(qsizetype size) { if (size > capacity) { if (capacity == 0) capacity = 1; @@ -88,7 +88,7 @@ public: } } - inline void shrink(int size) { + void shrink(qsizetype size) { capacity = size; if (size) { buffer = (Type*) realloc(static_cast<void*>(buffer), capacity * sizeof(Type)); @@ -108,8 +108,8 @@ public: inline QDataBuffer &operator<<(const Type &t) { add(t); return *this; } private: - int capacity; - int siz; + qsizetype capacity; + qsizetype siz; Type *buffer; }; |