Skip to content

Commit 93239b6

Browse files
committed
use span instead of a pointer
1 parent 7bfaf51 commit 93239b6

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

Framework/Core/include/Framework/ArrowTableSlicingCache.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ namespace o2::framework
2121
using ListVector = std::vector<std::vector<int64_t>>;
2222

2323
struct SliceInfoPtr {
24-
std::vector<int64_t> const* offsets;
25-
std::vector<int64_t> const* sizes;
24+
gsl::span<int64_t const> offsets;
25+
gsl::span<int64_t const> sizes;
2626

2727
std::pair<int64_t, int64_t> getSliceFor(int value) const;
2828
};

Framework/Core/src/ArrowTableSlicingCache.cxx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ void updatePairList(Cache& list, std::string const& binding, std::string const&
3232
std::pair<int64_t, int64_t> SliceInfoPtr::getSliceFor(int value) const
3333
{
3434
int64_t offset = 0;
35-
if ((*offsets).empty()) {
35+
if (offsets.empty()) {
3636
return {offset, 0};
3737
}
38-
if ((size_t)value > (*offsets).size()) {
38+
if ((size_t)value >= offsets.size()) {
3939
return {offset, 0};
4040
}
4141

42-
return {(*offsets)[value], (*sizes)[value]};
42+
return {offsets[value], sizes[value]};
4343
}
4444

4545
gsl::span<const int64_t> SliceInfoUnsortedPtr::getSliceFor(int value) const
@@ -240,14 +240,14 @@ SliceInfoPtr ArrowTableSlicingCache::getCacheForPos(int pos) const
240240
{
241241
if (values[pos] == nullptr && counts[pos] == nullptr) {
242242
return {
243-
nullptr, //
244-
nullptr //
243+
{}, //
244+
{} //
245245
};
246246
}
247247

248248
return {
249-
&(offsets[pos]), //
250-
&(sizes[pos]) //
249+
gsl::span{offsets[pos].data(), offsets[pos].size()}, //
250+
gsl::span(sizes[pos].data(), sizes[pos].size()) //
251251
};
252252
}
253253

Framework/Core/test/test_GroupSlicer.cxx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,8 @@ TEST_CASE("GroupSlicerMismatchedGroups")
245245
if (i == 3 || i == 10 || i == 12 || i == 16 || i == 19) {
246246
continue;
247247
}
248-
for (auto j = 0.f; j < 5; j += 0.5f) {
249-
trksWriter(0, i, 0.5f * j);
248+
for (auto j = 0; j < 10; ++j) {
249+
trksWriter(0, i, 0.5f * (j / 2.));
250250
}
251251
}
252252
auto trkTable = builderT.finalize();
@@ -297,8 +297,8 @@ TEST_CASE("GroupSlicerMismatchedUnassignedGroups")
297297
++skip;
298298
continue;
299299
}
300-
for (auto j = 0.f; j < 5; j += 0.5f) {
301-
trksWriter(0, i, 0.5f * j);
300+
for (auto j = 0; j < 10; ++j) {
301+
trksWriter(0, i, 0.5f * (j / 2.));
302302
}
303303
}
304304
for (auto i = 0; i < 5; ++i) {

0 commit comments

Comments
 (0)