diff options
author | Erik Verbruggen <erik.verbruggen@qt.io> | 2016-10-14 12:01:51 +0200 |
---|---|---|
committer | Erik Verbruggen <erik.verbruggen@qt.io> | 2016-10-21 07:50:23 +0000 |
commit | c82d5241addb3d1e2182d0428ac4e818f4c8afd4 (patch) | |
tree | ecc3bc4589ae221e119eed0819db00be5bec49dd /src/qml/jsruntime/qv4persistent_p.h | |
parent | f5da1a9261d64fdac3b4e12082932cb473098c73 (diff) |
QML: Create a fast-path for QV4::WeakValue::set
And hint the compiler (with LTO) to never inline the slow path.
Change-Id: Idad15498bca457d3f1f063031ad1a08415e9b3db
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4persistent_p.h')
-rw-r--r-- | src/qml/jsruntime/qv4persistent_p.h | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/src/qml/jsruntime/qv4persistent_p.h b/src/qml/jsruntime/qv4persistent_p.h index a0ade2068f..c1cd1f34df 100644 --- a/src/qml/jsruntime/qv4persistent_p.h +++ b/src/qml/jsruntime/qv4persistent_p.h @@ -154,9 +154,26 @@ public: WeakValue &operator=(const WeakValue &other); ~WeakValue(); - void set(ExecutionEngine *engine, const Value &value); - void set(ExecutionEngine *engine, ReturnedValue value); - void set(ExecutionEngine *engine, Heap::Base *obj); + void set(ExecutionEngine *engine, const Value &value) + { + if (!val) + allocVal(engine); + *val = value; + } + + void set(ExecutionEngine *engine, ReturnedValue value) + { + if (!val) + allocVal(engine); + *val = value; + } + + void set(ExecutionEngine *engine, Heap::Base *obj) + { + if (!val) + allocVal(engine); + *val = obj; + } ReturnedValue value() const { return (val ? val->asReturnedValue() : Encode::undefined()); @@ -192,6 +209,8 @@ private: Value *val; private: + Q_NEVER_INLINE void allocVal(ExecutionEngine *engine); + void free(); }; |