summaryrefslogtreecommitdiffstats
path: root/eval
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2017-12-18 00:51:08 +0100
committerHenning Baldersheim <balder@yahoo-inc.com>2017-12-18 00:51:08 +0100
commit3b6064d84a18d327abc7f203434555c744ab1e0a (patch)
treea2da72a65f56789d944aa8e96578c8accfd9c22b /eval
parent0362a35182855568e7efd71c95b12f216a0d1ccf (diff)
Reserve space up front.
Diffstat (limited to 'eval')
-rw-r--r--eval/src/vespa/eval/tensor/sparse/sparse_tensor_match.cpp20
1 files changed, 7 insertions, 13 deletions
diff --git a/eval/src/vespa/eval/tensor/sparse/sparse_tensor_match.cpp b/eval/src/vespa/eval/tensor/sparse/sparse_tensor_match.cpp
index b4c9d511d09..e89b37ab442 100644
--- a/eval/src/vespa/eval/tensor/sparse/sparse_tensor_match.cpp
+++ b/eval/src/vespa/eval/tensor/sparse/sparse_tensor_match.cpp
@@ -2,8 +2,7 @@
#include "sparse_tensor_match.h"
-namespace vespalib {
-namespace tensor {
+namespace vespalib::tensor {
namespace {
@@ -73,9 +72,9 @@ transformAddress(SparseTensorAddressBuilder &builder,
void
-SparseTensorMatch::fastMatch(const TensorImplType &lhs,
- const TensorImplType &rhs)
+SparseTensorMatch::fastMatch(const TensorImplType &lhs, const TensorImplType &rhs)
{
+ _builder.reserve(lhs.cells().size());
for (const auto &lhsCell : lhs.cells()) {
auto rhsItr = rhs.cells().find(lhsCell.first);
if (rhsItr != rhs.cells().end()) {
@@ -85,13 +84,11 @@ SparseTensorMatch::fastMatch(const TensorImplType &lhs,
}
void
-SparseTensorMatch::slowMatch(const TensorImplType &lhs,
- const TensorImplType &rhs)
+SparseTensorMatch::slowMatch(const TensorImplType &lhs, const TensorImplType &rhs)
{
std::vector<AddressOp> ops;
SparseTensorAddressBuilder addressBuilder;
- SparseTensorAddressPadder addressPadder(_builder.fast_type(),
- lhs.fast_type());
+ SparseTensorAddressPadder addressPadder(_builder.fast_type(), lhs.fast_type());
buildTransformOps(ops, lhs.fast_type(), rhs.fast_type());
for (const auto &lhsCell : lhs.cells()) {
if (!transformAddress(addressBuilder, lhsCell.first, ops)) {
@@ -106,8 +103,7 @@ SparseTensorMatch::slowMatch(const TensorImplType &lhs,
}
}
-SparseTensorMatch::SparseTensorMatch(const TensorImplType &lhs,
- const TensorImplType &rhs)
+SparseTensorMatch::SparseTensorMatch(const TensorImplType &lhs, const TensorImplType &rhs)
: Parent(lhs.combineDimensionsWith(rhs))
{
if ((lhs.fast_type().dimensions().size() == rhs.fast_type().dimensions().size()) &&
@@ -123,6 +119,4 @@ SparseTensorMatch::SparseTensorMatch(const TensorImplType &lhs,
}
}
-
-} // namespace vespalib::tensor
-} // namespace vespalib
+}