aboutsummaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/v8/qv8bindings.cpp
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2012-02-14 10:47:03 +0000
committerQt by Nokia <qt-info@nokia.com>2012-02-20 08:34:28 +0100
commit330152354aed8496ac78d145e14b25ee2d7bf8fb (patch)
treed1aacb6ef10d695651a66138050c45cc34249e83 /src/declarative/qml/v8/qv8bindings.cpp
parentde431c5e6cc8d439ed039e24f050ad8020792ab8 (diff)
Use Utf8 for javascript source code
This saves a surprising amount of memory. Change-Id: I16f7bde8d11fe11703d4e441060fd52e9632248c Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
Diffstat (limited to 'src/declarative/qml/v8/qv8bindings.cpp')
-rw-r--r--src/declarative/qml/v8/qv8bindings.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/declarative/qml/v8/qv8bindings.cpp b/src/declarative/qml/v8/qv8bindings.cpp
index daadce442b..39203d35af 100644
--- a/src/declarative/qml/v8/qv8bindings.cpp
+++ b/src/declarative/qml/v8/qv8bindings.cpp
@@ -156,7 +156,7 @@ void QV8Bindings::Binding::destroy()
parent->release();
}
-QV8Bindings::QV8Bindings(const QString &program, int index, int line,
+QV8Bindings::QV8Bindings(int index, int line,
QDeclarativeCompiledData *compiled,
QDeclarativeContextData *context)
: bindingsCount(0), bindings(0)
@@ -171,7 +171,8 @@ QV8Bindings::QV8Bindings(const QString &program, int index, int line,
bool compileFailed = false;
{
v8::TryCatch try_catch;
- script = engine->qmlModeCompile(program, compiled->name, line);
+ const QByteArray &program = compiled->programs.at(index);
+ script = engine->qmlModeCompile(program.constData(), program.length(), compiled->name, line);
if (try_catch.HasCaught()) {
// The binding was not compiled. There are some exceptional cases which the
// expression rewriter does not rewrite properly (e.g., \r-terminated lines
@@ -192,6 +193,7 @@ QV8Bindings::QV8Bindings(const QString &program, int index, int line,
v8::Local<v8::Value> result = script->Run(engine->contextWrapper()->sharedContext());
if (result->IsArray()) {
compiled->v8bindings[index] = qPersistentNew(v8::Local<v8::Array>::Cast(result));
+ compiled->programs[index].clear(); // We don't need the source anymore
}
}
}