From edb2cdc06ac5ab808429c654c55de87c8c4bf450 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 11 Sep 2018 10:27:32 +0200 Subject: Micro optimization when initializing the Cpp frame Change-Id: I07db2df7eec2bdbeb84bd576d9e4f7912f79fc78 Reviewed-by: Erik Verbruggen --- src/qml/jsruntime/qv4stackframe_p.h | 5 ++--- src/qml/jsruntime/qv4value_p.h | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'src/qml') diff --git a/src/qml/jsruntime/qv4stackframe_p.h b/src/qml/jsruntime/qv4stackframe_p.h index 39e7c25a4e..6f21058e91 100644 --- a/src/qml/jsruntime/qv4stackframe_p.h +++ b/src/qml/jsruntime/qv4stackframe_p.h @@ -180,9 +180,8 @@ struct Q_QML_EXPORT CppStackFrame { jsFrame->setArgc(argc); memcpy(jsFrame->args, originalArguments, argc*sizeof(Value)); - const Value *end = jsFrame->args + nRegisters; - for (Value *v = jsFrame->args + argc; v < end; ++v) - *v = Encode::undefined(); + Q_STATIC_ASSERT(Encode::undefined() == 0); + memset(jsFrame->args + argc, 0, (nRegisters - argc)*sizeof(Value)); if (v4Function && v4Function->compiledFunction) { const int firstDeadZoneRegister = v4Function->compiledFunction->firstTemporalDeadZoneRegister; diff --git a/src/qml/jsruntime/qv4value_p.h b/src/qml/jsruntime/qv4value_p.h index e4be6b99dd..305b8c6bab 100644 --- a/src/qml/jsruntime/qv4value_p.h +++ b/src/qml/jsruntime/qv4value_p.h @@ -710,8 +710,8 @@ inline unsigned int Primitive::toUInt32(double d) } struct Encode { - static ReturnedValue undefined() { - return Primitive::undefinedValue().rawValue(); + static constexpr ReturnedValue undefined() { + return 0; } static ReturnedValue null() { return Primitive::nullValue().rawValue(); -- cgit v1.2.3