We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7c0912f commit 5373108Copy full SHA for 5373108
include/scratchcpp/list.h
@@ -64,7 +64,15 @@ class LIBSCRATCHCPP_EXPORT List : public Entity
64
inline bool contains(const Value &value) const { return contains(value.data()); }
65
66
/*! Clears the list. */
67
- inline void clear() { m_size = 0; }
+ inline void clear()
68
+ {
69
+ // Keep at least 200,000 items allocated if the list has more
70
+ constexpr size_t limit = 200000;
71
+ m_size = 0;
72
+
73
+ if (m_dataPtr->size() > limit)
74
+ reserve(limit);
75
+ }
76
77
/*! Appends an empty item and returns the reference to it. Can be used for custom initialization. */
78
inline ValueData &appendEmpty()
0 commit comments