Skip to content

Commit 3ecbfee

Browse files
authored
Merge pull request #48138 from Dr15Jones/improveDetSetVectorNew
Simplified helpers for edmNew::DetSetVector
2 parents 15a04fc + 0b93aeb commit 3ecbfee

File tree

1 file changed

+22
-27
lines changed

1 file changed

+22
-27
lines changed

DataFormats/Common/interface/DetSetVectorNew.h

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ namespace edmNew {
4747
*/
4848
namespace dstvdetails {
4949

50-
void errorFilling();
51-
void notSafe();
52-
void errorIdExists(det_id_type iid);
53-
void throw_range(det_id_type iid);
50+
void errorFilling() noexcept(false);
51+
void notSafe() noexcept(false);
52+
void errorIdExists(det_id_type iid) noexcept(false);
53+
void throw_range(det_id_type iid) noexcept(false);
5454

5555
struct DetSetVectorTrans {
5656
typedef unsigned int size_type; // for persistency
@@ -130,15 +130,14 @@ namespace edmNew {
130130
operator id_type() const { return id; }
131131
};
132132

133-
bool ready() const {
133+
void startFilling() const noexcept(false) {
134134
bool expected = false;
135135
if (!m_filling.compare_exchange_strong(expected, true))
136136
errorFilling();
137-
return true;
138137
}
139138
};
140139

141-
inline void throwCapacityExausted() { throw CapacityExaustedException(); }
140+
inline void throwCapacityExausted() noexcept(false) { throw CapacityExaustedException(); }
142141
} // namespace dstvdetails
143142

144143
/** an optitimized container that linearized a "map of vector".
@@ -202,25 +201,15 @@ namespace edmNew {
202201
typedef typename DetSetVector<T>::id_type id_type;
203202
typedef typename DetSetVector<T>::size_type size_type;
204203

205-
// here just to make the compiler happy
206-
static DetSetVector<T>::Item& dummy() {
207-
assert(false);
208-
static DetSetVector<T>::Item d;
209-
return d;
210-
}
211-
212204
FastFiller(DetSetVector<T>& iv, id_type id, bool isaveEmpty = false)
213-
: m_v(iv), m_item(m_v.ready() ? m_v.push_back(id) : dummy()), m_saveEmpty(isaveEmpty) {
214-
if (m_v.onDemand())
215-
dstvdetails::notSafe();
216-
}
205+
: m_v(iv), m_item(getItem(m_v, id)), m_saveEmpty(isaveEmpty) {}
217206

218207
FastFiller(DetSetVector<T>& iv, typename DetSetVector<T>::Item& it, bool isaveEmpty = false)
219208
: m_v(iv), m_item(it), m_saveEmpty(isaveEmpty) {
220209
if (m_v.onDemand())
221210
dstvdetails::notSafe();
222-
if (m_v.ready())
223-
m_item.offset = int(m_v.m_data.size());
211+
m_v.startFilling();
212+
m_item.offset = int(m_v.m_data.size());
224213
}
225214
~FastFiller() {
226215
if (!m_saveEmpty && m_item.size == 0) {
@@ -296,6 +285,13 @@ namespace edmNew {
296285
//for testing
297286
friend class ::TestDetSet;
298287

288+
static DetSetVector<T>::Item& getItem(DetSetVector<T>& iv, id_type id) noexcept(false) {
289+
iv.startFilling();
290+
if (iv.onDemand())
291+
dstvdetails::notSafe();
292+
return iv.push_back(id);
293+
}
294+
299295
DetSetVector<T>& m_v;
300296
typename DetSetVector<T>::Item& m_item;
301297
bool m_saveEmpty;
@@ -310,14 +306,8 @@ namespace edmNew {
310306
typedef typename DetSetVector<T>::id_type id_type;
311307
typedef typename DetSetVector<T>::size_type size_type;
312308

313-
// here just to make the compiler happy
314-
static DetSetVector<T>::Item const& dummy() {
315-
assert(false);
316-
static DetSetVector<T>::Item const d;
317-
return d;
318-
}
319309
// this constructor is not supposed to be used in Concurrent mode
320-
TSFastFiller(DetSetVector<T>& iv, id_type id) : m_v(iv), m_item(m_v.ready() ? iv.push_back(id) : dummy()) {
310+
TSFastFiller(DetSetVector<T>& iv, id_type id) : m_v(iv), m_item(getItem(iv, id)) {
321311
assert(m_v.m_filling == true);
322312
m_v.m_filling = false;
323313
}
@@ -376,6 +366,11 @@ namespace edmNew {
376366
//for testing
377367
friend class ::TestDetSet;
378368

369+
static DetSetVector<T>::Item& getItem(DetSetVector<T>& iv, id_type id) noexcept(false) {
370+
iv.startFilling();
371+
return iv.push_back(id);
372+
}
373+
379374
std::vector<T> m_lv;
380375
DetSetVector<T> const& m_v;
381376
typename DetSetVector<T>::Item const& m_item;

0 commit comments

Comments
 (0)