Skip to content

Commit 8ad3881

Browse files
committed
Exclude empty spans from MultiSpan
1 parent f9f0681 commit 8ad3881

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

DataFormats/Common/interface/MultiSpan.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ namespace edm {
3030
MultiSpan() = default;
3131

3232
void add(std::span<const T> sp) {
33+
// Empty spans are not added to reduce the number of spans and speed up the binary search
34+
if (sp.empty()) {
35+
return;
36+
}
37+
3338
spans_.emplace_back(sp);
3439
offsets_.push_back(totalSize_);
3540
totalSize_ += sp.size();

DataFormats/Common/test/test_catch2_MultiSpan.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ TEST_CASE("MultiSpan basic indexing", "[MultiSpan]") {
130130
REQUIRE(ms1[3] == a[1]);
131131
REQUIRE(ms1[4] == a[2]);
132132

133-
REQUIRE(ms1.globalIndex(1, 0) == 0);
134-
REQUIRE(ms1.globalIndex(2, 1) == 3);
133+
REQUIRE(ms1.globalIndex(0, 0) == 0);
134+
REQUIRE(ms1.globalIndex(1, 1) == 3);
135135

136136
std::vector<int> collected;
137137
for (auto val : ms1) {
@@ -152,8 +152,8 @@ TEST_CASE("MultiSpan basic indexing", "[MultiSpan]") {
152152
REQUIRE(ms2[6] == a[2]);
153153

154154
REQUIRE(ms2.globalIndex(0, 0) == 0);
155-
REQUIRE(ms2.globalIndex(4, 1) == 3);
156-
REQUIRE(ms2.globalIndex(5, 1) == 5);
155+
REQUIRE(ms2.globalIndex(1, 1) == 3);
156+
REQUIRE(ms2.globalIndex(2, 1) == 5);
157157

158158
std::vector<int> collected;
159159
for (auto val : ms2) {

0 commit comments

Comments
 (0)