diff options
author | Lars Knoll <[email protected]> | 2017-08-22 18:24:56 +0200 |
---|---|---|
committer | Erik Verbruggen <[email protected]> | 2017-08-25 12:10:57 +0000 |
commit | acaa28e916b0d89e3c243cc3f8a46fcf74d8be63 (patch) | |
tree | 55332cb9d1e387fd34d56e978710983950375084 /src/qml/jsruntime/qv4arraydata_p.h | |
parent | 4e0174a88e66b9d9471c98eeb7d8be6209ba5c98 (diff) |
Optimize array access
Avoid the expensive modulo operation when indexing into an array,
and do a simple conditional subtraction instead.
Change-Id: I57a78c0cf94b010e4bc226b9b2a5c2e3251498f8
Reviewed-by: Erik Verbruggen <[email protected]>
Diffstat (limited to 'src/qml/jsruntime/qv4arraydata_p.h')
-rw-r--r-- | src/qml/jsruntime/qv4arraydata_p.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/qml/jsruntime/qv4arraydata_p.h b/src/qml/jsruntime/qv4arraydata_p.h index e1de2e82e6..5028778877 100644 --- a/src/qml/jsruntime/qv4arraydata_p.h +++ b/src/qml/jsruntime/qv4arraydata_p.h @@ -144,7 +144,7 @@ DECLARE_HEAP_OBJECT(ArrayData, Base) { V4_ASSERT_IS_TRIVIAL(ArrayData) struct SimpleArrayData : public ArrayData { - uint mappedIndex(uint index) const { return (index + offset) % values.alloc; } + uint mappedIndex(uint index) const { index += offset; if (index > values.alloc) index -= values.alloc; return index; } const Value &data(uint index) const { return values[mappedIndex(index)]; } void setData(EngineBase *e, uint index, Value newVal) { values.set(e, mappedIndex(index), newVal); |