Commit d33114b3 authored by Kenton Varda's avatar Kenton Varda

Fix Vector::clear() for types with no default constructor.

parent 4a330282
...@@ -420,6 +420,16 @@ public: ...@@ -420,6 +420,16 @@ public:
} }
} }
void clear() {
if (__has_trivial_destructor(T)) {
pos = ptr;
} else {
while (pos > ptr) {
kj::dtor(*--pos);
}
}
}
void resize(size_t size) { void resize(size_t size) {
KJ_IREQUIRE(size <= capacity(), "can't resize past capacity"); KJ_IREQUIRE(size <= capacity(), "can't resize past capacity");
......
...@@ -115,7 +115,7 @@ public: ...@@ -115,7 +115,7 @@ public:
} }
inline void clear() { inline void clear() {
builder.resize(0); builder.clear();
} }
inline void truncate(size_t size) { inline void truncate(size_t size) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment