/src/qtbase/src/gui/painting/qdatabuffer_p.h
Line | Count | Source |
1 | | // Copyright (C) 2016 The Qt Company Ltd. |
2 | | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | | // Qt-Security score:significant reason:default |
4 | | |
5 | | #ifndef QDATABUFFER_P_H |
6 | | #define QDATABUFFER_P_H |
7 | | |
8 | | // |
9 | | // W A R N I N G |
10 | | // ------------- |
11 | | // |
12 | | // This file is not part of the Qt API. It exists for the convenience |
13 | | // of other Qt classes. This header file may change from version to |
14 | | // version without notice, or even be removed. |
15 | | // |
16 | | // We mean it. |
17 | | // |
18 | | |
19 | | #include <QtGui/private/qtguiglobal_p.h> |
20 | | |
21 | | #include "QtCore/qalloc.h" |
22 | | #include "QtCore/qbytearray.h" |
23 | | #include "QtCore/qtypeinfo.h" |
24 | | |
25 | | #include <stdlib.h> |
26 | | |
27 | | QT_BEGIN_NAMESPACE |
28 | | |
29 | | template <typename Type> class QDataBuffer |
30 | | { |
31 | | Q_DISABLE_COPY_MOVE(QDataBuffer) |
32 | | public: |
33 | | explicit QDataBuffer(qsizetype res) |
34 | 1.32M | { |
35 | 1.32M | capacity = res; |
36 | 1.32M | if (res) { |
37 | 1.68k | QT_WARNING_PUSH |
38 | 1.68k | QT_WARNING_DISABLE_GCC("-Walloc-size-larger-than=") |
39 | 1.68k | buffer = (Type*) QtPrivate::fittedMalloc(0, &capacity, sizeof(Type)); |
40 | 1.68k | QT_WARNING_POP |
41 | 1.68k | Q_CHECK_PTR(buffer); |
42 | 1.32M | } else { |
43 | 1.32M | buffer = nullptr; |
44 | 1.32M | } |
45 | 1.32M | siz = 0; |
46 | 1.32M | } QDataBuffer<QPainterPath::ElementType>::QDataBuffer(long long) Line | Count | Source | 34 | 119k | { | 35 | 119k | capacity = res; | 36 | 119k | if (res) { | 37 | 842 | QT_WARNING_PUSH | 38 | 842 | QT_WARNING_DISABLE_GCC("-Walloc-size-larger-than=") | 39 | 842 | buffer = (Type*) QtPrivate::fittedMalloc(0, &capacity, sizeof(Type)); | 40 | 842 | QT_WARNING_POP | 41 | 842 | Q_CHECK_PTR(buffer); | 42 | 118k | } else { | 43 | 118k | buffer = nullptr; | 44 | 118k | } | 45 | 119k | siz = 0; | 46 | 119k | } |
QDataBuffer<QPointF>::QDataBuffer(long long) Line | Count | Source | 34 | 118k | { | 35 | 118k | capacity = res; | 36 | 118k | if (res) { | 37 | 0 | QT_WARNING_PUSH | 38 | 0 | QT_WARNING_DISABLE_GCC("-Walloc-size-larger-than=") | 39 | 0 | buffer = (Type*) QtPrivate::fittedMalloc(0, &capacity, sizeof(Type)); | 40 | 0 | QT_WARNING_POP | 41 | 0 | Q_CHECK_PTR(buffer); | 42 | 118k | } else { | 43 | 118k | buffer = nullptr; | 44 | 118k | } | 45 | 118k | siz = 0; | 46 | 118k | } |
QDataBuffer<QT_FT_Vector_>::QDataBuffer(long long) Line | Count | Source | 34 | 118k | { | 35 | 118k | capacity = res; | 36 | 118k | if (res) { | 37 | 0 | QT_WARNING_PUSH | 38 | 0 | QT_WARNING_DISABLE_GCC("-Walloc-size-larger-than=") | 39 | 0 | buffer = (Type*) QtPrivate::fittedMalloc(0, &capacity, sizeof(Type)); | 40 | 0 | QT_WARNING_POP | 41 | 0 | Q_CHECK_PTR(buffer); | 42 | 118k | } else { | 43 | 118k | buffer = nullptr; | 44 | 118k | } | 45 | 118k | siz = 0; | 46 | 118k | } |
QDataBuffer<char>::QDataBuffer(long long) Line | Count | Source | 34 | 118k | { | 35 | 118k | capacity = res; | 36 | 118k | if (res) { | 37 | 0 | QT_WARNING_PUSH | 38 | 0 | QT_WARNING_DISABLE_GCC("-Walloc-size-larger-than=") | 39 | 0 | buffer = (Type*) QtPrivate::fittedMalloc(0, &capacity, sizeof(Type)); | 40 | 0 | QT_WARNING_POP | 41 | 0 | Q_CHECK_PTR(buffer); | 42 | 118k | } else { | 43 | 118k | buffer = nullptr; | 44 | 118k | } | 45 | 118k | siz = 0; | 46 | 118k | } |
QDataBuffer<int>::QDataBuffer(long long) Line | Count | Source | 34 | 118k | { | 35 | 118k | capacity = res; | 36 | 118k | if (res) { | 37 | 0 | QT_WARNING_PUSH | 38 | 0 | QT_WARNING_DISABLE_GCC("-Walloc-size-larger-than=") | 39 | 0 | buffer = (Type*) QtPrivate::fittedMalloc(0, &capacity, sizeof(Type)); | 40 | 0 | QT_WARNING_POP | 41 | 0 | Q_CHECK_PTR(buffer); | 42 | 118k | } else { | 43 | 118k | buffer = nullptr; | 44 | 118k | } | 45 | 118k | siz = 0; | 46 | 118k | } |
QDataBuffer<QLineF>::QDataBuffer(long long) Line | Count | Source | 34 | 118k | { | 35 | 118k | capacity = res; | 36 | 118k | if (res) { | 37 | 0 | QT_WARNING_PUSH | 38 | 0 | QT_WARNING_DISABLE_GCC("-Walloc-size-larger-than=") | 39 | 0 | buffer = (Type*) QtPrivate::fittedMalloc(0, &capacity, sizeof(Type)); | 40 | 0 | QT_WARNING_POP | 41 | 0 | Q_CHECK_PTR(buffer); | 42 | 118k | } else { | 43 | 118k | buffer = nullptr; | 44 | 118k | } | 45 | 118k | siz = 0; | 46 | 118k | } |
QDataBuffer<double>::QDataBuffer(long long) Line | Count | Source | 34 | 842 | { | 35 | 842 | capacity = res; | 36 | 842 | if (res) { | 37 | 842 | QT_WARNING_PUSH | 38 | 842 | QT_WARNING_DISABLE_GCC("-Walloc-size-larger-than=") | 39 | 842 | buffer = (Type*) QtPrivate::fittedMalloc(0, &capacity, sizeof(Type)); | 40 | 842 | QT_WARNING_POP | 41 | 842 | Q_CHECK_PTR(buffer); | 42 | 842 | } else { | 43 | 0 | buffer = nullptr; | 44 | 0 | } | 45 | 842 | siz = 0; | 46 | 842 | } |
Unexecuted instantiation: QDataBuffer<QIntersection>::QDataBuffer(long long) Unexecuted instantiation: QDataBuffer<QKdPointTree::Node>::QDataBuffer(long long) Unexecuted instantiation: QDataBuffer<QPathSegments::Segment>::QDataBuffer(long long) Unexecuted instantiation: QDataBuffer<QPathSegments::Intersection>::QDataBuffer(long long) Unexecuted instantiation: QDataBuffer<QPathEdge>::QDataBuffer(long long) Unexecuted instantiation: QDataBuffer<QPathVertex>::QDataBuffer(long long) QDataBuffer<QScanConverter::Line>::QDataBuffer(long long) Line | Count | Source | 34 | 118k | { | 35 | 118k | capacity = res; | 36 | 118k | if (res) { | 37 | 0 | QT_WARNING_PUSH | 38 | 0 | QT_WARNING_DISABLE_GCC("-Walloc-size-larger-than=") | 39 | 0 | buffer = (Type*) QtPrivate::fittedMalloc(0, &capacity, sizeof(Type)); | 40 | 0 | QT_WARNING_POP | 41 | 0 | Q_CHECK_PTR(buffer); | 42 | 118k | } else { | 43 | 118k | buffer = nullptr; | 44 | 118k | } | 45 | 118k | siz = 0; | 46 | 118k | } |
QDataBuffer<QScanConverter::Line*>::QDataBuffer(long long) Line | Count | Source | 34 | 118k | { | 35 | 118k | capacity = res; | 36 | 118k | if (res) { | 37 | 0 | QT_WARNING_PUSH | 38 | 0 | QT_WARNING_DISABLE_GCC("-Walloc-size-larger-than=") | 39 | 0 | buffer = (Type*) QtPrivate::fittedMalloc(0, &capacity, sizeof(Type)); | 40 | 0 | QT_WARNING_POP | 41 | 0 | Q_CHECK_PTR(buffer); | 42 | 118k | } else { | 43 | 118k | buffer = nullptr; | 44 | 118k | } | 45 | 118k | siz = 0; | 46 | 118k | } |
QDataBuffer<QStrokerOps::Element>::QDataBuffer(long long) Line | Count | Source | 34 | 380k | { | 35 | 380k | capacity = res; | 36 | 380k | if (res) { | 37 | 0 | QT_WARNING_PUSH | 38 | 0 | QT_WARNING_DISABLE_GCC("-Walloc-size-larger-than=") | 39 | 0 | buffer = (Type*) QtPrivate::fittedMalloc(0, &capacity, sizeof(Type)); | 40 | 0 | QT_WARNING_POP | 41 | 0 | Q_CHECK_PTR(buffer); | 42 | 380k | } else { | 43 | 380k | buffer = nullptr; | 44 | 380k | } | 45 | 380k | siz = 0; | 46 | 380k | } |
|
47 | | |
48 | | ~QDataBuffer() |
49 | 1.32M | { |
50 | 1.32M | static_assert(!QTypeInfo<Type>::isComplex); |
51 | 1.32M | if (buffer) |
52 | 27.0k | QtPrivate::sizedFree(buffer, capacity, sizeof(Type)); |
53 | 1.32M | } QDataBuffer<QLineF>::~QDataBuffer() Line | Count | Source | 49 | 118k | { | 50 | 118k | static_assert(!QTypeInfo<Type>::isComplex); | 51 | 118k | if (buffer) | 52 | 0 | QtPrivate::sizedFree(buffer, capacity, sizeof(Type)); | 53 | 118k | } |
QDataBuffer<int>::~QDataBuffer() Line | Count | Source | 49 | 118k | { | 50 | 118k | static_assert(!QTypeInfo<Type>::isComplex); | 51 | 118k | if (buffer) | 52 | 1.61k | QtPrivate::sizedFree(buffer, capacity, sizeof(Type)); | 53 | 118k | } |
QDataBuffer<char>::~QDataBuffer() Line | Count | Source | 49 | 118k | { | 50 | 118k | static_assert(!QTypeInfo<Type>::isComplex); | 51 | 118k | if (buffer) | 52 | 1.61k | QtPrivate::sizedFree(buffer, capacity, sizeof(Type)); | 53 | 118k | } |
QDataBuffer<QT_FT_Vector_>::~QDataBuffer() Line | Count | Source | 49 | 118k | { | 50 | 118k | static_assert(!QTypeInfo<Type>::isComplex); | 51 | 118k | if (buffer) | 52 | 1.61k | QtPrivate::sizedFree(buffer, capacity, sizeof(Type)); | 53 | 118k | } |
QDataBuffer<QPointF>::~QDataBuffer() Line | Count | Source | 49 | 118k | { | 50 | 118k | static_assert(!QTypeInfo<Type>::isComplex); | 51 | 118k | if (buffer) | 52 | 1.61k | QtPrivate::sizedFree(buffer, capacity, sizeof(Type)); | 53 | 118k | } |
QDataBuffer<QPainterPath::ElementType>::~QDataBuffer() Line | Count | Source | 49 | 119k | { | 50 | 119k | static_assert(!QTypeInfo<Type>::isComplex); | 51 | 119k | if (buffer) | 52 | 2.45k | QtPrivate::sizedFree(buffer, capacity, sizeof(Type)); | 53 | 119k | } |
QDataBuffer<double>::~QDataBuffer() Line | Count | Source | 49 | 842 | { | 50 | 842 | static_assert(!QTypeInfo<Type>::isComplex); | 51 | 842 | if (buffer) | 52 | 842 | QtPrivate::sizedFree(buffer, capacity, sizeof(Type)); | 53 | 842 | } |
Unexecuted instantiation: QDataBuffer<QIntersection>::~QDataBuffer() Unexecuted instantiation: QDataBuffer<QKdPointTree::Node>::~QDataBuffer() Unexecuted instantiation: QDataBuffer<QPathSegments::Segment>::~QDataBuffer() Unexecuted instantiation: QDataBuffer<QPathVertex>::~QDataBuffer() Unexecuted instantiation: QDataBuffer<QPathEdge>::~QDataBuffer() Unexecuted instantiation: QDataBuffer<QPathSegments::Intersection>::~QDataBuffer() QDataBuffer<QScanConverter::Line>::~QDataBuffer() Line | Count | Source | 49 | 118k | { | 50 | 118k | static_assert(!QTypeInfo<Type>::isComplex); | 51 | 118k | if (buffer) | 52 | 0 | QtPrivate::sizedFree(buffer, capacity, sizeof(Type)); | 53 | 118k | } |
QDataBuffer<QScanConverter::Line*>::~QDataBuffer() Line | Count | Source | 49 | 118k | { | 50 | 118k | static_assert(!QTypeInfo<Type>::isComplex); | 51 | 118k | if (buffer) | 52 | 0 | QtPrivate::sizedFree(buffer, capacity, sizeof(Type)); | 53 | 118k | } |
QDataBuffer<QStrokerOps::Element>::~QDataBuffer() Line | Count | Source | 49 | 380k | { | 50 | 380k | static_assert(!QTypeInfo<Type>::isComplex); | 51 | 380k | if (buffer) | 52 | 17.2k | QtPrivate::sizedFree(buffer, capacity, sizeof(Type)); | 53 | 380k | } |
|
54 | | |
55 | 491k | inline void reset() { siz = 0; }QDataBuffer<QStrokerOps::Element>::reset() Line | Count | Source | 55 | 133k | inline void reset() { siz = 0; } |
QDataBuffer<QPointF>::reset() Line | Count | Source | 55 | 64.5k | inline void reset() { siz = 0; } |
QDataBuffer<QPainterPath::ElementType>::reset() Line | Count | Source | 55 | 82.3k | inline void reset() { siz = 0; } |
QDataBuffer<QT_FT_Vector_>::reset() Line | Count | Source | 55 | 64.5k | inline void reset() { siz = 0; } |
QDataBuffer<char>::reset() Line | Count | Source | 55 | 64.5k | inline void reset() { siz = 0; } |
QDataBuffer<int>::reset() Line | Count | Source | 55 | 64.5k | inline void reset() { siz = 0; } |
QDataBuffer<double>::reset() Line | Count | Source | 55 | 17.7k | inline void reset() { siz = 0; } |
Unexecuted instantiation: QDataBuffer<QIntersection>::reset() Unexecuted instantiation: QDataBuffer<QPathSegments::Intersection>::reset() Unexecuted instantiation: QDataBuffer<QPathSegments::Segment>::reset() Unexecuted instantiation: QDataBuffer<QScanConverter::Line>::reset() Unexecuted instantiation: QDataBuffer<QScanConverter::Line*>::reset() |
56 | | |
57 | 1.59M | inline bool isEmpty() const { return siz==0; }Unexecuted instantiation: QDataBuffer<QPathVertex>::isEmpty() const Unexecuted instantiation: QDataBuffer<QScanConverter::Line>::isEmpty() const QDataBuffer<QStrokerOps::Element>::isEmpty() const Line | Count | Source | 57 | 182k | inline bool isEmpty() const { return siz==0; } |
QDataBuffer<QPointF>::isEmpty() const Line | Count | Source | 57 | 1.41M | inline bool isEmpty() const { return siz==0; } |
|
58 | | |
59 | 46.6M | qsizetype size() const { return siz; }QDataBuffer<QStrokerOps::Element>::size() const Line | Count | Source | 59 | 4.14M | qsizetype size() const { return siz; } |
QDataBuffer<QPointF>::size() const Line | Count | Source | 59 | 39.7M | qsizetype size() const { return siz; } |
QDataBuffer<QPainterPath::ElementType>::size() const Line | Count | Source | 59 | 2.46M | qsizetype size() const { return siz; } |
Unexecuted instantiation: QDataBuffer<QPathSegments::Segment>::size() const Unexecuted instantiation: QDataBuffer<QPathSegments::Intersection>::size() const Unexecuted instantiation: QDataBuffer<QPathEdge>::size() const Unexecuted instantiation: QDataBuffer<QPathVertex>::size() const Unexecuted instantiation: QDataBuffer<QIntersection>::size() const Unexecuted instantiation: QDataBuffer<QKdPointTree::Node>::size() const Unexecuted instantiation: QDataBuffer<QScanConverter::Line>::size() const Unexecuted instantiation: QDataBuffer<QScanConverter::Line*>::size() const QDataBuffer<QT_FT_Vector_>::size() const Line | Count | Source | 59 | 225k | qsizetype size() const { return siz; } |
QDataBuffer<int>::size() const Line | Count | Source | 59 | 52.3k | qsizetype size() const { return siz; } |
|
60 | 321k | inline Type *data() const { return buffer; }QDataBuffer<QPainterPath::ElementType>::data() const Line | Count | Source | 60 | 82.3k | inline Type *data() const { return buffer; } |
QDataBuffer<double>::data() const Line | Count | Source | 60 | 17.7k | inline Type *data() const { return buffer; } |
Unexecuted instantiation: QDataBuffer<QPathSegments::Intersection>::data() const Unexecuted instantiation: QDataBuffer<QScanConverter::Line>::data() const QDataBuffer<QPointF>::data() const Line | Count | Source | 60 | 64.5k | inline Type *data() const { return buffer; } |
QDataBuffer<QT_FT_Vector_>::data() const Line | Count | Source | 60 | 52.3k | inline Type *data() const { return buffer; } |
QDataBuffer<char>::data() const Line | Count | Source | 60 | 52.3k | inline Type *data() const { return buffer; } |
QDataBuffer<int>::data() const Line | Count | Source | 60 | 52.3k | inline Type *data() const { return buffer; } |
|
61 | | |
62 | 563k | Type &at(qsizetype i) { Q_ASSERT(i >= 0 && i < siz); return buffer[i]; }QDataBuffer<QPointF>::at(long long) Line | Count | Source | 62 | 491k | Type &at(qsizetype i) { Q_ASSERT(i >= 0 && i < siz); return buffer[i]; } |
Unexecuted instantiation: QDataBuffer<QPathSegments::Segment>::at(long long) Unexecuted instantiation: QDataBuffer<QPathSegments::Intersection>::at(long long) Unexecuted instantiation: QDataBuffer<QPathEdge>::at(long long) Unexecuted instantiation: QDataBuffer<QPathVertex>::at(long long) Unexecuted instantiation: QDataBuffer<QIntersection>::at(long long) Unexecuted instantiation: QDataBuffer<QKdPointTree::Node>::at(long long) Unexecuted instantiation: QDataBuffer<int>::at(long long) Unexecuted instantiation: QDataBuffer<QScanConverter::Line>::at(long long) Unexecuted instantiation: QDataBuffer<QScanConverter::Line*>::at(long long) QDataBuffer<QStrokerOps::Element>::at(long long) Line | Count | Source | 62 | 72.0k | Type &at(qsizetype i) { Q_ASSERT(i >= 0 && i < siz); return buffer[i]; } |
|
63 | 4.43M | const Type &at(qsizetype i) const { Q_ASSERT(i >= 0 && i < siz); return buffer[i]; }Unexecuted instantiation: QDataBuffer<QPointF>::at(long long) const Unexecuted instantiation: QDataBuffer<QPathSegments::Segment>::at(long long) const Unexecuted instantiation: QDataBuffer<QPathSegments::Intersection>::at(long long) const Unexecuted instantiation: QDataBuffer<QPathEdge>::at(long long) const Unexecuted instantiation: QDataBuffer<QPathVertex>::at(long long) const QDataBuffer<QStrokerOps::Element>::at(long long) const Line | Count | Source | 63 | 4.43M | const Type &at(qsizetype i) const { Q_ASSERT(i >= 0 && i < siz); return buffer[i]; } |
|
64 | 1.35M | inline Type &last() { Q_ASSERT(!isEmpty()); return buffer[siz-1]; }Unexecuted instantiation: QDataBuffer<QPathVertex>::last() QDataBuffer<QPointF>::last() Line | Count | Source | 64 | 1.35M | inline Type &last() { Q_ASSERT(!isEmpty()); return buffer[siz-1]; } |
|
65 | | inline const Type &last() const { Q_ASSERT(!isEmpty()); return buffer[siz-1]; } |
66 | 91.3k | inline Type &first() { Q_ASSERT(!isEmpty()); return buffer[0]; }Unexecuted instantiation: QDataBuffer<QScanConverter::Line>::first() QDataBuffer<QStrokerOps::Element>::first() Line | Count | Source | 66 | 91.3k | inline Type &first() { Q_ASSERT(!isEmpty()); return buffer[0]; } |
|
67 | | inline const Type &first() const { Q_ASSERT(!isEmpty()); return buffer[0]; } |
68 | | |
69 | 144M | inline void add(const Type &t) { |
70 | 144M | reserve(siz + 1); |
71 | 144M | buffer[siz] = t; |
72 | 144M | ++siz; |
73 | 144M | } QDataBuffer<QStrokerOps::Element>::add(QStrokerOps::Element const&) Line | Count | Source | 69 | 1.51M | inline void add(const Type &t) { | 70 | 1.51M | reserve(siz + 1); | 71 | 1.51M | buffer[siz] = t; | 72 | 1.51M | ++siz; | 73 | 1.51M | } |
QDataBuffer<QPainterPath::ElementType>::add(QPainterPath::ElementType const&) Line | Count | Source | 69 | 46.4M | inline void add(const Type &t) { | 70 | 46.4M | reserve(siz + 1); | 71 | 46.4M | buffer[siz] = t; | 72 | 46.4M | ++siz; | 73 | 46.4M | } |
QDataBuffer<QPointF>::add(QPointF const&) Line | Count | Source | 69 | 42.6M | inline void add(const Type &t) { | 70 | 42.6M | reserve(siz + 1); | 71 | 42.6M | buffer[siz] = t; | 72 | 42.6M | ++siz; | 73 | 42.6M | } |
QDataBuffer<double>::add(double const&) Line | Count | Source | 69 | 7.51M | inline void add(const Type &t) { | 70 | 7.51M | reserve(siz + 1); | 71 | 7.51M | buffer[siz] = t; | 72 | 7.51M | ++siz; | 73 | 7.51M | } |
Unexecuted instantiation: QDataBuffer<QPathSegments::Intersection>::add(QPathSegments::Intersection const&) Unexecuted instantiation: QDataBuffer<QPathVertex>::add(QPathVertex const&) Unexecuted instantiation: QDataBuffer<QIntersection>::add(QIntersection const&) QDataBuffer<int>::add(int const&) Line | Count | Source | 69 | 173k | inline void add(const Type &t) { | 70 | 173k | reserve(siz + 1); | 71 | 173k | buffer[siz] = t; | 72 | 173k | ++siz; | 73 | 173k | } |
Unexecuted instantiation: QDataBuffer<QPathSegments::Segment>::add(QPathSegments::Segment const&) Unexecuted instantiation: QDataBuffer<QPathEdge>::add(QPathEdge const&) Unexecuted instantiation: QDataBuffer<QScanConverter::Line*>::add(QScanConverter::Line* const&) Unexecuted instantiation: QDataBuffer<QScanConverter::Line>::add(QScanConverter::Line const&) QDataBuffer<QT_FT_Vector_>::add(QT_FT_Vector_ const&) Line | Count | Source | 69 | 22.8M | inline void add(const Type &t) { | 70 | 22.8M | reserve(siz + 1); | 71 | 22.8M | buffer[siz] = t; | 72 | 22.8M | ++siz; | 73 | 22.8M | } |
QDataBuffer<char>::add(char const&) Line | Count | Source | 69 | 22.8M | inline void add(const Type &t) { | 70 | 22.8M | reserve(siz + 1); | 71 | 22.8M | buffer[siz] = t; | 72 | 22.8M | ++siz; | 73 | 22.8M | } |
|
74 | | |
75 | | inline void pop_back() { |
76 | | Q_ASSERT(siz > 0); |
77 | | --siz; |
78 | | } |
79 | | |
80 | 0 | void resize(qsizetype size) { |
81 | 0 | reserve(size); |
82 | 0 | siz = size; |
83 | 0 | } Unexecuted instantiation: QDataBuffer<QKdPointTree::Node>::resize(long long) Unexecuted instantiation: QDataBuffer<QScanConverter::Line*>::resize(long long) Unexecuted instantiation: QDataBuffer<QPointF>::resize(long long) Unexecuted instantiation: QDataBuffer<QPainterPath::ElementType>::resize(long long) |
84 | | |
85 | 144M | void reserve(qsizetype size) { |
86 | 144M | if (size > capacity) { |
87 | 165k | if (capacity == 0) |
88 | 25.3k | capacity = 1; |
89 | 309k | while (capacity < size) |
90 | 143k | capacity *= 2; |
91 | 165k | auto ptr = QtPrivate::fittedRealloc(static_cast<void*>(buffer), 0, &capacity, sizeof(Type)); |
92 | 165k | Q_CHECK_PTR(ptr); |
93 | 165k | buffer = static_cast<Type*>(ptr); |
94 | 165k | } |
95 | 144M | } QDataBuffer<QStrokerOps::Element>::reserve(long long) Line | Count | Source | 85 | 1.51M | void reserve(qsizetype size) { | 86 | 1.51M | if (size > capacity) { | 87 | 98.2k | if (capacity == 0) | 88 | 17.2k | capacity = 1; | 89 | 179k | while (capacity < size) | 90 | 80.9k | capacity *= 2; | 91 | 98.2k | auto ptr = QtPrivate::fittedRealloc(static_cast<void*>(buffer), 0, &capacity, sizeof(Type)); | 92 | | Q_CHECK_PTR(ptr); | 93 | 98.2k | buffer = static_cast<Type*>(ptr); | 94 | 98.2k | } | 95 | 1.51M | } |
QDataBuffer<QPainterPath::ElementType>::reserve(long long) Line | Count | Source | 85 | 47.3M | void reserve(qsizetype size) { | 86 | 47.3M | if (size > capacity) { | 87 | 14.5k | if (capacity == 0) | 88 | 1.61k | capacity = 1; | 89 | 30.8k | while (capacity < size) | 90 | 16.2k | capacity *= 2; | 91 | 14.5k | auto ptr = QtPrivate::fittedRealloc(static_cast<void*>(buffer), 0, &capacity, sizeof(Type)); | 92 | | Q_CHECK_PTR(ptr); | 93 | 14.5k | buffer = static_cast<Type*>(ptr); | 94 | 14.5k | } | 95 | 47.3M | } |
QDataBuffer<QPointF>::reserve(long long) Line | Count | Source | 85 | 42.6M | void reserve(qsizetype size) { | 86 | 42.6M | if (size > capacity) { | 87 | 15.5k | if (capacity == 0) | 88 | 1.61k | capacity = 1; | 89 | 29.4k | while (capacity < size) | 90 | 13.9k | capacity *= 2; | 91 | 15.5k | auto ptr = QtPrivate::fittedRealloc(static_cast<void*>(buffer), 0, &capacity, sizeof(Type)); | 92 | | Q_CHECK_PTR(ptr); | 93 | 15.5k | buffer = static_cast<Type*>(ptr); | 94 | 15.5k | } | 95 | 42.6M | } |
QDataBuffer<double>::reserve(long long) Line | Count | Source | 85 | 7.51M | void reserve(qsizetype size) { | 86 | 7.51M | if (size > capacity) { | 87 | 3.21k | if (capacity == 0) | 88 | 0 | capacity = 1; | 89 | 6.43k | while (capacity < size) | 90 | 3.21k | capacity *= 2; | 91 | 3.21k | auto ptr = QtPrivate::fittedRealloc(static_cast<void*>(buffer), 0, &capacity, sizeof(Type)); | 92 | | Q_CHECK_PTR(ptr); | 93 | 3.21k | buffer = static_cast<Type*>(ptr); | 94 | 3.21k | } | 95 | 7.51M | } |
Unexecuted instantiation: QDataBuffer<QPathSegments::Intersection>::reserve(long long) Unexecuted instantiation: QDataBuffer<QPathVertex>::reserve(long long) Unexecuted instantiation: QDataBuffer<QIntersection>::reserve(long long) Unexecuted instantiation: QDataBuffer<QKdPointTree::Node>::reserve(long long) QDataBuffer<int>::reserve(long long) Line | Count | Source | 85 | 173k | void reserve(qsizetype size) { | 86 | 173k | if (size > capacity) { | 87 | 4.70k | if (capacity == 0) | 88 | 1.61k | capacity = 1; | 89 | 7.79k | while (capacity < size) | 90 | 3.09k | capacity *= 2; | 91 | 4.70k | auto ptr = QtPrivate::fittedRealloc(static_cast<void*>(buffer), 0, &capacity, sizeof(Type)); | 92 | | Q_CHECK_PTR(ptr); | 93 | 4.70k | buffer = static_cast<Type*>(ptr); | 94 | 4.70k | } | 95 | 173k | } |
Unexecuted instantiation: QDataBuffer<QPathSegments::Segment>::reserve(long long) Unexecuted instantiation: QDataBuffer<QPathEdge>::reserve(long long) Unexecuted instantiation: QDataBuffer<QScanConverter::Line*>::reserve(long long) Unexecuted instantiation: QDataBuffer<QScanConverter::Line>::reserve(long long) QDataBuffer<QT_FT_Vector_>::reserve(long long) Line | Count | Source | 85 | 22.8M | void reserve(qsizetype size) { | 86 | 22.8M | if (size > capacity) { | 87 | 14.8k | if (capacity == 0) | 88 | 1.61k | capacity = 1; | 89 | 28.0k | while (capacity < size) | 90 | 13.2k | capacity *= 2; | 91 | 14.8k | auto ptr = QtPrivate::fittedRealloc(static_cast<void*>(buffer), 0, &capacity, sizeof(Type)); | 92 | | Q_CHECK_PTR(ptr); | 93 | 14.8k | buffer = static_cast<Type*>(ptr); | 94 | 14.8k | } | 95 | 22.8M | } |
QDataBuffer<char>::reserve(long long) Line | Count | Source | 85 | 22.8M | void reserve(qsizetype size) { | 86 | 22.8M | if (size > capacity) { | 87 | 14.8k | if (capacity == 0) | 88 | 1.61k | capacity = 1; | 89 | 28.0k | while (capacity < size) | 90 | 13.2k | capacity *= 2; | 91 | 14.8k | auto ptr = QtPrivate::fittedRealloc(static_cast<void*>(buffer), 0, &capacity, sizeof(Type)); | 92 | | Q_CHECK_PTR(ptr); | 93 | 14.8k | buffer = static_cast<Type*>(ptr); | 94 | 14.8k | } | 95 | 22.8M | } |
|
96 | | |
97 | 0 | void shrink(qsizetype size) { |
98 | 0 | Q_ASSERT(capacity >= size); |
99 | 0 | if (size) { |
100 | 0 | capacity = size; |
101 | 0 | const auto ptr = QtPrivate::fittedRealloc(static_cast<void*>(buffer), 0, &capacity, sizeof(Type)); |
102 | 0 | Q_CHECK_PTR(ptr); |
103 | 0 | buffer = static_cast<Type*>(ptr); |
104 | 0 | siz = std::min(siz, size); |
105 | 0 | } else { |
106 | 0 | QtPrivate::sizedFree(buffer, capacity, sizeof(Type)); |
107 | 0 | capacity = size; |
108 | 0 | buffer = nullptr; |
109 | 0 | siz = 0; |
110 | 0 | } |
111 | 0 | } |
112 | | |
113 | 0 | inline void swap(QDataBuffer<Type> &other) { |
114 | 0 | qSwap(capacity, other.capacity); |
115 | 0 | qSwap(siz, other.siz); |
116 | 0 | qSwap(buffer, other.buffer); |
117 | 0 | } |
118 | | |
119 | 88.7M | inline QDataBuffer &operator<<(const Type &t) { add(t); return *this; }QDataBuffer<QPointF>::operator<<(QPointF const&) Line | Count | Source | 119 | 214k | inline QDataBuffer &operator<<(const Type &t) { add(t); return *this; } |
QDataBuffer<QPainterPath::ElementType>::operator<<(QPainterPath::ElementType const&) Line | Count | Source | 119 | 42.6M | inline QDataBuffer &operator<<(const Type &t) { add(t); return *this; } |
Unexecuted instantiation: QDataBuffer<QPathSegments::Intersection>::operator<<(QPathSegments::Intersection const&) Unexecuted instantiation: QDataBuffer<QPathVertex>::operator<<(QPathVertex const&) QDataBuffer<int>::operator<<(int const&) Line | Count | Source | 119 | 173k | inline QDataBuffer &operator<<(const Type &t) { add(t); return *this; } |
Unexecuted instantiation: QDataBuffer<QPathSegments::Segment>::operator<<(QPathSegments::Segment const&) Unexecuted instantiation: QDataBuffer<QPathEdge>::operator<<(QPathEdge const&) Unexecuted instantiation: QDataBuffer<QScanConverter::Line*>::operator<<(QScanConverter::Line* const&) QDataBuffer<QT_FT_Vector_>::operator<<(QT_FT_Vector_ const&) Line | Count | Source | 119 | 22.8M | inline QDataBuffer &operator<<(const Type &t) { add(t); return *this; } |
QDataBuffer<char>::operator<<(char const&) Line | Count | Source | 119 | 22.8M | inline QDataBuffer &operator<<(const Type &t) { add(t); return *this; } |
|
120 | | |
121 | | private: |
122 | | qsizetype capacity; |
123 | | qsizetype siz; |
124 | | Type *buffer; |
125 | | }; |
126 | | |
127 | | QT_END_NAMESPACE |
128 | | |
129 | | #endif // QDATABUFFER_P_H |