summaryrefslogtreecommitdiffstats
path: root/eval
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2017-12-30 12:24:20 +0100
committerHenning Baldersheim <balder@yahoo-inc.com>2018-01-09 15:59:04 +0100
commit2bb57f5b124fbbf6ef54847889d816598d86c0b5 (patch)
tree6f38db1cfe07cbf7102c74b39db05c77b5fc9068 /eval
parent3aaa5053d289fec6fc5bfec6fa352a55100bfa72 (diff)
Cache the size in a 32 bit variable
Diffstat (limited to 'eval')
-rw-r--r--eval/src/vespa/eval/tensor/dense/dense_tensor_cells_iterator.cpp9
-rw-r--r--eval/src/vespa/eval/tensor/dense/dense_tensor_cells_iterator.h9
2 files changed, 10 insertions, 8 deletions
diff --git a/eval/src/vespa/eval/tensor/dense/dense_tensor_cells_iterator.cpp b/eval/src/vespa/eval/tensor/dense/dense_tensor_cells_iterator.cpp
index d20c5124330..15c09db44b3 100644
--- a/eval/src/vespa/eval/tensor/dense/dense_tensor_cells_iterator.cpp
+++ b/eval/src/vespa/eval/tensor/dense/dense_tensor_cells_iterator.cpp
@@ -5,10 +5,11 @@
namespace vespalib::tensor {
DenseTensorCellsIterator::DenseTensorCellsIterator(const eval::ValueType &type_in, CellsRef cells)
- : _type(type_in),
- _cells(cells),
- _cellIdx(0),
- _address(type_in.dimensions().size(), 0)
+ : _type(type_in),
+ _cells(cells),
+ _cellIdx(0),
+ _lastDimension(type_in.dimensions().size() - 1),
+ _address(type_in.dimensions().size(), 0)
{}
DenseTensorCellsIterator::~DenseTensorCellsIterator() = default;
diff --git a/eval/src/vespa/eval/tensor/dense/dense_tensor_cells_iterator.h b/eval/src/vespa/eval/tensor/dense/dense_tensor_cells_iterator.h
index fcffecef764..447d8a4f805 100644
--- a/eval/src/vespa/eval/tensor/dense/dense_tensor_cells_iterator.h
+++ b/eval/src/vespa/eval/tensor/dense/dense_tensor_cells_iterator.h
@@ -21,15 +21,16 @@ public:
private:
using CellsRef = vespalib::ConstArrayRef<double>;
const eval::ValueType &_type;
- CellsRef _cells;
- size_t _cellIdx;
- Address _address;
+ CellsRef _cells;
+ size_t _cellIdx;
+ const int32_t _lastDimension;
+ Address _address;
public:
DenseTensorCellsIterator(const eval::ValueType &type_in, CellsRef cells);
~DenseTensorCellsIterator();
void next() {
++_cellIdx;
- for (int64_t i = (_address.size() - 1); i >= 0; --i) {
+ for (int32_t i = _lastDimension; i >= 0; --i) {
_address[i]++;
if (__builtin_expect((_address[i] != _type.dimensions()[i].size), true)) {
// Outer dimension labels can only be increased when this label wraps around.