aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4string.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2014-04-29 11:32:19 +0200
committerSimon Hausmann <simon.hausmann@digia.com>2014-07-22 13:49:05 +0200
commit541da479754e6da07463cd6f0dd0e24bc6746494 (patch)
treee4d949f1e1d8a71f8f868e02d01e0742fb8b55c2 /src/qml/jsruntime/qv4string.cpp
parent233b339c480e313bc49d16f9b85bc4318f4c3f48 (diff)
Convert String to the new storage layout
Change-Id: Ifa9aac63fdb270fb449f11832a1792caeb6c6724 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/jsruntime/qv4string.cpp')
-rw-r--r--src/qml/jsruntime/qv4string.cpp88
1 files changed, 44 insertions, 44 deletions
diff --git a/src/qml/jsruntime/qv4string.cpp b/src/qml/jsruntime/qv4string.cpp
index 5c21548173..f489699b2a 100644
--- a/src/qml/jsruntime/qv4string.cpp
+++ b/src/qml/jsruntime/qv4string.cpp
@@ -133,9 +133,9 @@ void String::destroy(Managed *that)
void String::markObjects(Managed *that, ExecutionEngine *e)
{
String *s = static_cast<String *>(that);
- if (s->stringData()->largestSubLength) {
- s->stringData()->left->mark(e);
- s->stringData()->right->mark(e);
+ if (s->d()->largestSubLength) {
+ s->d()->left->mark(e);
+ s->d()->right->mark(e);
}
}
@@ -148,7 +148,7 @@ ReturnedValue String::get(Managed *m, const StringRef name, bool *hasProperty)
if (name->equals(v4->id_length)) {
if (hasProperty)
*hasProperty = true;
- return Primitive::fromInt32(that->stringData()->text->size).asReturnedValue();
+ return Primitive::fromInt32(that->d()->text->size).asReturnedValue();
}
PropertyAttributes attrs;
Property *pd = v4->stringObjectClass->prototype->__getPropertyDescriptor__(name, &attrs);
@@ -168,7 +168,7 @@ ReturnedValue String::getIndexed(Managed *m, uint index, bool *hasProperty)
Scope scope(engine);
ScopedString that(scope, static_cast<String *>(m));
- if (index < static_cast<uint>(that->stringData()->text->size)) {
+ if (index < static_cast<uint>(that->d()->text->size)) {
if (hasProperty)
*hasProperty = true;
return Encode(engine->newString(that->toQString().mid(index, 1)));
@@ -217,7 +217,7 @@ PropertyAttributes String::query(const Managed *m, StringRef name)
PropertyAttributes String::queryIndexed(const Managed *m, uint index)
{
const String *that = static_cast<const String *>(m);
- return (index < static_cast<uint>(that->stringData()->text->size)) ? Attr_NotConfigurable|Attr_NotWritable : Attr_Invalid;
+ return (index < static_cast<uint>(that->d()->text->size)) ? Attr_NotConfigurable|Attr_NotWritable : Attr_Invalid;
}
bool String::deleteProperty(Managed *, const StringRef)
@@ -254,13 +254,13 @@ bool String::isEqualTo(Managed *t, Managed *o)
String::String(ExecutionEngine *engine, const QString &text)
: Managed(engine->stringClass)
{
- Data *d = stringData();
- d->text = const_cast<QString &>(text).data_ptr();
- d->text->ref.ref();
- d->identifier = 0;
- d->stringHash = UINT_MAX;
- d->largestSubLength = 0;
- d->len = stringData()->text->size;
+ Data *data = d();
+ data->text = const_cast<QString &>(text).data_ptr();
+ data->text->ref.ref();
+ data->identifier = 0;
+ data->stringHash = UINT_MAX;
+ data->largestSubLength = 0;
+ data->len = d()->text->size;
setSubtype(StringType_Unknown);
}
@@ -269,20 +269,20 @@ String::String(ExecutionEngine *engine, String *l, String *r)
{
setSubtype(StringType_Unknown);
- Data *d = stringData();
- d->left = l;
- d->right = r;
- d->stringHash = UINT_MAX;
- d->largestSubLength = qMax(l->stringData()->largestSubLength, r->stringData()->largestSubLength);
- d->len = l->stringData()->len + r->stringData()->len;
+ Data *data = d();
+ data->left = l;
+ data->right = r;
+ data->stringHash = UINT_MAX;
+ data->largestSubLength = qMax(l->d()->largestSubLength, r->d()->largestSubLength);
+ data->len = l->d()->len + r->d()->len;
- if (!l->stringData()->largestSubLength && l->stringData()->len > stringData()->largestSubLength)
- stringData()->largestSubLength = l->stringData()->len;
- if (!r->stringData()->largestSubLength && r->stringData()->len > stringData()->largestSubLength)
- stringData()->largestSubLength = r->stringData()->len;
+ if (!l->d()->largestSubLength && l->d()->len > d()->largestSubLength)
+ d()->largestSubLength = l->d()->len;
+ if (!r->d()->largestSubLength && r->d()->len > d()->largestSubLength)
+ d()->largestSubLength = r->d()->len;
// make sure we don't get excessive depth in our strings
- if (stringData()->len > 256 && stringData()->len >= 2*stringData()->largestSubLength)
+ if (d()->len > 256 && d()->len >= 2*d()->largestSubLength)
simplifyString();
}
@@ -293,7 +293,7 @@ uint String::toUInt(bool *ok) const
if (subtype() == StringType_Unknown)
createHashValue();
if (subtype() >= StringType_UInt)
- return stringData()->stringHash;
+ return d()->stringHash;
// ### this conversion shouldn't be required
double d = RuntimeHelpers::stringToNumber(toQString());
@@ -320,34 +320,34 @@ bool String::equals(const StringRef other) const
void String::makeIdentifierImpl() const
{
- if (stringData()->largestSubLength)
+ if (d()->largestSubLength)
simplifyString();
- Q_ASSERT(!stringData()->largestSubLength);
+ Q_ASSERT(!d()->largestSubLength);
engine()->identifierTable->identifier(this);
}
void String::simplifyString() const
{
- Q_ASSERT(stringData()->largestSubLength);
+ Q_ASSERT(d()->largestSubLength);
int l = length();
QString result(l, Qt::Uninitialized);
QChar *ch = const_cast<QChar *>(result.constData());
recursiveAppend(ch);
- stringData()->text = result.data_ptr();
- stringData()->text->ref.ref();
- stringData()->identifier = 0;
- stringData()->largestSubLength = 0;
+ d()->text = result.data_ptr();
+ d()->text->ref.ref();
+ d()->identifier = 0;
+ d()->largestSubLength = 0;
}
QChar *String::recursiveAppend(QChar *ch) const
{
- if (stringData()->largestSubLength) {
- ch = stringData()->left->recursiveAppend(ch);
- ch = stringData()->right->recursiveAppend(ch);
+ if (d()->largestSubLength) {
+ ch = d()->left->recursiveAppend(ch);
+ ch = d()->right->recursiveAppend(ch);
} else {
- memcpy(ch, stringData()->text->data(), stringData()->text->size*sizeof(QChar));
- ch += stringData()->text->size;
+ memcpy(ch, d()->text->data(), d()->text->size*sizeof(QChar));
+ ch += d()->text->size;
}
return ch;
}
@@ -355,17 +355,17 @@ QChar *String::recursiveAppend(QChar *ch) const
void String::createHashValue() const
{
- if (stringData()->largestSubLength)
+ if (d()->largestSubLength)
simplifyString();
- Q_ASSERT(!stringData()->largestSubLength);
- const QChar *ch = reinterpret_cast<const QChar *>(stringData()->text->data());
- const QChar *end = ch + stringData()->text->size;
+ Q_ASSERT(!d()->largestSubLength);
+ const QChar *ch = reinterpret_cast<const QChar *>(d()->text->data());
+ const QChar *end = ch + d()->text->size;
// array indices get their number as hash value
bool ok;
- stringData()->stringHash = ::toArrayIndex(ch, end, &ok);
+ d()->stringHash = ::toArrayIndex(ch, end, &ok);
if (ok) {
- setSubtype((stringData()->stringHash == UINT_MAX) ? StringType_UInt : StringType_ArrayIndex);
+ setSubtype((d()->stringHash == UINT_MAX) ? StringType_UInt : StringType_ArrayIndex);
return;
}
@@ -375,7 +375,7 @@ void String::createHashValue() const
++ch;
}
- stringData()->stringHash = h;
+ d()->stringHash = h;
setSubtype(StringType_Regular);
}