diff options
author | Lars Knoll <lars.knoll@qt.io> | 2016-12-09 14:46:49 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2016-12-10 11:07:02 +0000 |
commit | 8c322d89ee13f15141f3115dcb5ee9567270ba32 (patch) | |
tree | bdadf23e2b0c7b9e7b23d579ea8858de8b954d4d /src/qml/jsruntime/qv4value_p.h | |
parent | d3bff5843b14a4e0640fb7429b0d8685d5d25b46 (diff) |
Some smaller optimizations for indexed property access
Saves around 1% of instructions on crypto.js
Change-Id: Iccef08b204e6e752d827242baf156efd9a4d58a7
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4value_p.h')
-rw-r--r-- | src/qml/jsruntime/qv4value_p.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/qml/jsruntime/qv4value_p.h b/src/qml/jsruntime/qv4value_p.h index e59ab9af0b..816b8fb11b 100644 --- a/src/qml/jsruntime/qv4value_p.h +++ b/src/qml/jsruntime/qv4value_p.h @@ -453,6 +453,7 @@ public: } inline uint asArrayIndex() const; + inline bool asArrayIndex(uint &idx) const; #ifndef V4_BOOTSTRAP uint asArrayLength(bool *ok) const; #endif @@ -531,6 +532,20 @@ inline uint Value::asArrayIndex() const return UINT_MAX; return idx; } + +inline bool Value::asArrayIndex(uint &idx) const +{ + if (!isDouble()) { + if (isInteger() && int_32() >= 0) { + idx = (uint)int_32(); + return true; + } + return false; + } + double d = doubleValue(); + idx = (uint)d; + return (idx == d); +} #endif inline |