diff options
author | Lars Knoll <lars.knoll@qt.io> | 2017-01-03 11:38:00 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2017-01-22 11:50:36 +0000 |
commit | 94e6106d357ca5a1349a2b10a69dd84db34065c8 (patch) | |
tree | 30e139e2eca3d950c69efeb148dcc5a1be00ab4d /src/qml/jsruntime/qv4string.cpp | |
parent | 2f16dd7b1415995109bc44b925cf860236977776 (diff) |
Simplify handling of non GC managed heap data
Let the destroy() method in QV4::String clean up the
unmanaged heap size instead of having a special hook in
the code that sweeps the GC heap.
Change-Id: I989ee99604f0cc67b896d3acc94e200dd5e56a60
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4string.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4string.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/qml/jsruntime/qv4string.cpp b/src/qml/jsruntime/qv4string.cpp index 9494142fa5..cde2131aab 100644 --- a/src/qml/jsruntime/qv4string.cpp +++ b/src/qml/jsruntime/qv4string.cpp @@ -114,6 +114,15 @@ void Heap::String::init(MemoryManager *mm, String *l, String *r) simplifyString(); } +void Heap::String::destroy() { + if (!largestSubLength) { + mm->changeUnmanagedHeapSizeUsage(qptrdiff(-text->size) * (int)sizeof(QChar)); + if (!text->ref.deref()) + QStringData::deallocate(text); + } + Base::destroy(); +} + uint String::toUInt(bool *ok) const { *ok = true; @@ -152,7 +161,7 @@ void Heap::String::simplifyString() const text->ref.ref(); identifier = 0; largestSubLength = 0; - mm->growUnmanagedHeapSizeUsage(size_t(text->size) * sizeof(QChar)); + mm->changeUnmanagedHeapSizeUsage(qptrdiff(text->size) * (qptrdiff)sizeof(QChar)); } void Heap::String::append(const String *data, QChar *ch) |