diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2020-09-07 09:04:14 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-07 09:04:14 +0200 |
commit | 35a22abcdd0a677212722ad494107831a23bcbd1 (patch) | |
tree | 6a42f9ada9b2ceb5bfa982d6d40a13fdb1dd0633 /eval | |
parent | 466bc196eee4571e2197624f17b8a7d8aee38cf0 (diff) | |
parent | cb68428feab8bb84d4c5fe5ef6800c3543ee67f4 (diff) |
Merge pull request #14290 from vespa-engine/arnej/optimize-copy-cells
Arnej/optimize copy cells
Diffstat (limited to 'eval')
-rw-r--r-- | eval/src/vespa/eval/tensor/sparse/sparse_tensor.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/eval/src/vespa/eval/tensor/sparse/sparse_tensor.cpp b/eval/src/vespa/eval/tensor/sparse/sparse_tensor.cpp index db35de6786d..b2bd9330160 100644 --- a/eval/src/vespa/eval/tensor/sparse/sparse_tensor.cpp +++ b/eval/src/vespa/eval/tensor/sparse/sparse_tensor.cpp @@ -29,10 +29,15 @@ using Cells = SparseTensor::Cells; void copyCells(Cells &cells, const Cells &cells_in, Stash &stash) { - for (const auto &cell : cells_in) { + // copy the exact hashtable structure: + cells = cells_in; + // copy the actual contents of the addresses, + // and update the pointers inside the hashtable + // keys so they point to our copy: + for (auto &cell : cells) { SparseTensorAddressRef oldRef = cell.first; SparseTensorAddressRef newRef(oldRef, stash); - cells[newRef] = cell.second; + cell.first = newRef; } } |