aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@yahooinc.com>2022-04-08 18:02:10 +0200
committerTor Egge <Tor.Egge@yahooinc.com>2022-04-08 18:02:10 +0200
commit7757b76a328736913c4bb6e319199764fd289741 (patch)
treed9d11aebddad8992a6c1b2cc9ff0a7afadf5856f
parent0e31957a72309321bfcb23ede796f0ad10b936e7 (diff)
Use data() member function to get pointer to the underlying array.
-rw-r--r--searchlib/src/vespa/searchlib/features/dotproductfeature.cpp8
-rw-r--r--vespalib/src/vespa/vespalib/util/arrayref.h1
2 files changed, 5 insertions, 4 deletions
diff --git a/searchlib/src/vespa/searchlib/features/dotproductfeature.cpp b/searchlib/src/vespa/searchlib/features/dotproductfeature.cpp
index 6bbfed60ecb..06e6e9157ae 100644
--- a/searchlib/src/vespa/searchlib/features/dotproductfeature.cpp
+++ b/searchlib/src/vespa/searchlib/features/dotproductfeature.cpp
@@ -276,7 +276,7 @@ void DotProductExecutorBase<BaseType>::execute(uint32_t docId) {
size_t commonRange = std::min(values.size(), _queryVector.size());
static_assert(std::is_same<typename AT::ValueType, BaseType>::value);
outputs().set_number(0, _multiplier.dotProduct(
- &_queryVector[0], reinterpret_cast<const typename AT::ValueType *>(&values[0]), commonRange));
+ &_queryVector[0], reinterpret_cast<const typename AT::ValueType *>(values.data()), commonRange));
}
template <typename A>
@@ -319,7 +319,7 @@ SparseDotProductExecutor<A>::getAttributeValues(uint32_t docId)
for (; (i < _queryIndexes.size()) && (_queryIndexes[i] < count); i++) {
_scratch[i] = allValues[_queryIndexes[i]];
}
- return vespalib::ConstArrayRef(&_scratch[0], i);
+ return vespalib::ConstArrayRef(_scratch.data(), i);
}
template <typename A>
@@ -341,7 +341,7 @@ DotProductByCopyExecutor<A>::getAttributeValues(uint32_t docId)
_copy.resize(count);
count = this->_attribute->getAll(docId, &_copy[0], _copy.size());
}
- return vespalib::ConstArrayRef(reinterpret_cast<const AT *>(&_copy[0]), count);
+ return vespalib::ConstArrayRef(reinterpret_cast<const AT *>(_copy.data()), count);
}
template <typename A>
@@ -367,7 +367,7 @@ SparseDotProductByCopyExecutor<A>::getAttributeValues(uint32_t docId)
for (const IV & iv(this->_queryIndexes); (i < iv.size()) && (iv[i] < count); i++) {
_copy[i] = _copy[iv[i]];
}
- return vespalib::ConstArrayRef(reinterpret_cast<const AT *>(&_copy[0]), i);
+ return vespalib::ConstArrayRef(reinterpret_cast<const AT *>(_copy.data()), i);
}
template <typename BaseType>
diff --git a/vespalib/src/vespa/vespalib/util/arrayref.h b/vespalib/src/vespa/vespalib/util/arrayref.h
index bc1fc540a6c..337833d2457 100644
--- a/vespalib/src/vespa/vespalib/util/arrayref.h
+++ b/vespalib/src/vespa/vespalib/util/arrayref.h
@@ -50,6 +50,7 @@ public:
const T *cend() const { return _v + _sz; }
const T *begin() const { return _v; }
const T *end() const { return _v + _sz; }
+ const T *data() const noexcept { return _v; }
private:
const T *_v;
size_t _sz;