diff options
author | Lars Knoll <lars.knoll@theqtcompany.com> | 2015-04-30 23:50:50 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@theqtcompany.com> | 2015-06-17 09:03:46 +0000 |
commit | 81d8e36c1732854a0c6b0312c0bf42804d30192e (patch) | |
tree | 0ab2458bdeaa03e81bd29107547e7cc714fd233c /src/qml/jsruntime/qv4stringobject.cpp | |
parent | a4aa358acf763469bf46244c7f5a3a358c038a81 (diff) |
Get rid of the tmpProperty in StringObject
This was a bad hack. The new code is cleaner, and should
also perform faster in a couple of cases (avoiding the creation
of a temporary String that is then only thrown away).
Change-Id: Ia6f978e037506484adbc01a61606307d4645b343
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'src/qml/jsruntime/qv4stringobject.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4stringobject.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/qml/jsruntime/qv4stringobject.cpp b/src/qml/jsruntime/qv4stringobject.cpp index 319768746b..08b078f8c5 100644 --- a/src/qml/jsruntime/qv4stringobject.cpp +++ b/src/qml/jsruntime/qv4stringobject.cpp @@ -72,7 +72,6 @@ Heap::StringObject::StringObject(InternalClass *ic, QV4::Object *prototype) { Q_ASSERT(vtable == QV4::StringObject::staticVTable()); value = ic->engine->newString()->asReturnedValue(); - tmpProperty.value = Primitive::undefinedValue(); Scope scope(ic->engine); ScopedObject s(scope, this); @@ -84,20 +83,23 @@ Heap::StringObject::StringObject(ExecutionEngine *engine, const Value &val) { value = val; Q_ASSERT(value.isString()); - tmpProperty.value = Primitive::undefinedValue(); Scope scope(engine); ScopedObject s(scope, this); s->defineReadonlyProperty(engine->id_length(), Primitive::fromUInt32(value.stringValue()->toQString().length())); } -Property *Heap::StringObject::getIndex(uint index) const +Heap::String *Heap::StringObject::getIndex(uint index) const { QString str = value.stringValue()->toQString(); if (index >= (uint)str.length()) return 0; - tmpProperty.value = Encode(internalClass->engine->newString(str.mid(index, 1))); - return &tmpProperty; + return internalClass->engine->newString(str.mid(index, 1)); +} + +uint Heap::StringObject::length() const +{ + return value.stringValue()->toQString().length(); } bool StringObject::deleteIndexedProperty(Managed *m, uint index) @@ -148,7 +150,6 @@ void StringObject::markObjects(Heap::Base *that, ExecutionEngine *e) { StringObject::Data *o = static_cast<StringObject::Data *>(that); o->value.stringValue()->mark(e); - o->tmpProperty.value.mark(e); Object::markObjects(that, e); } |