aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@qt.io>2016-11-09 10:49:24 +0100
committerErik Verbruggen <erik.verbruggen@qt.io>2016-11-09 11:44:38 +0000
commit94acdbfbdf8eef9e22d50d307be32cc3e21b9081 (patch)
tree0320240a32bd3675836d46ddaaabe441e723cdfc /src
parent05e3cdd8ab57686407d472722ab2e724c01de6b7 (diff)
V4: Replace memset by a for loop
GCC would often generate a call to a special "safe" version of memset, which would in turn prevent inlining in many cases. A simple for loop does not prevent inlining, and compilers can still decide to replace it with a memset. It also makes it easier for the compiler to do dead store elimination. Change-Id: I60fa3e321c2edb9225699bf57e8a31a3f8356ddc Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/qml/jsruntime/qv4engine_p.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/qml/jsruntime/qv4engine_p.h b/src/qml/jsruntime/qv4engine_p.h
index 843a6f4d94..a46066bde4 100644
--- a/src/qml/jsruntime/qv4engine_p.h
+++ b/src/qml/jsruntime/qv4engine_p.h
@@ -131,7 +131,8 @@ public:
Value *jsAlloca(int nValues) {
Value *ptr = jsStackTop;
jsStackTop = ptr + nValues;
- memset(ptr, 0, nValues*sizeof(Value));
+ for (int i = 0; i < nValues; ++i)
+ ptr[i] = Primitive::undefinedValue();
return ptr;
}