Skip to content

Commit 6bfad37

Browse files
authored
Apply a few suggestions from clang-tidy (#992)
1 parent 2d1cff6 commit 6bfad37

3 files changed

Lines changed: 19 additions & 11 deletions

File tree

python/templates/CollectionData.cc.jinja2

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,15 @@
4646
// https://github.com/AIDASoft/podio/pull/817#issuecomment-3266748609 and
4747
// https://github.com/AIDASoft/podio/pull/842
4848
volatile std::uint64_t s = m_data->size();
49-
if (s > 1e15) throw std::runtime_error("Bad data after reading: a collection is too big ({{ class.full_type }})");
50-
else
51-
if (s == 0)
52-
for ([[maybe_unused]] const auto& _ : *m_data.get())
49+
if (s > 1e15) {
50+
throw std::runtime_error("Bad data after reading: a collection is too big ({{ class.full_type }})");
51+
} else {
52+
if (s == 0) {
53+
for ([[maybe_unused]] const auto& _ : *m_data.get()) {
5354
throw std::runtime_error("Bad data after reading: zero-sized collection with data ({{ class.full_type }})");
55+
}
56+
}
57+
}
5458
// end of ugly
5559

5660

@@ -96,7 +100,9 @@ void {{ class_type }}::clear(bool isSubsetColl) {
96100
{{ macros.clear_relation(relation) }}
97101
{% endfor %}
98102
{% for member in VectorMembers %}
99-
if (m_vec_{{ member.name }}) m_vec_{{ member.name }}->clear();
103+
if (m_vec_{{ member.name }}) {
104+
m_vec_{{ member.name }}->clear();
105+
}
100106
m_vecs_{{ member.name }}.clear();
101107

102108
{% endfor %}

python/templates/Interface.h.jinja2

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ private:
6666

6767
template<typename ValueT>
6868
struct Model final : Concept {
69-
~Model() = default;
70-
Model(ValueT value) : m_value(value) {}
69+
~Model() override = default;
70+
Model(const ValueT& value) : m_value(value) {}
7171

7272
std::unique_ptr<Concept> clone() const final {
7373
return std::make_unique<Model<ValueT>>(m_value);
@@ -107,7 +107,7 @@ public:
107107
// {{ class.bare_type }} can only be initialized with one of the following types (and their Mutable counter parts): {{ Types | join(", ") }}
108108
template<typename ValueT>
109109
requires isInitializableFrom<ValueT>
110-
{{ class.bare_type }}(ValueT value) :
110+
{{ class.bare_type }}(const ValueT& value) :
111111
m_self(std::make_unique<Model<podio::detail::GetDefaultHandleType<ValueT>>>(value)) {
112112
}
113113

python/templates/Obj.cc.jinja2

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,19 @@
4343
}
4444

4545
{% if not is_trivial_type -%}
46-
{{ obj_type }}::~{{ obj_type }}() {
4746
{% with multi_relations = OneToManyRelations + VectorMembers %}
4847
{%- if multi_relations %}
48+
{{ obj_type }}::~{{ obj_type }}() {
4949
if (id.index == podio::ObjectID::untracked) {
5050
{% for relation in multi_relations %}
5151
delete m_{{ relation.name }};
5252
{% endfor %}
5353
}
54-
{% endif %}
55-
{%- endwith %}
5654
}
55+
{%- else %}
56+
{{ obj_type }}::~{{ obj_type }}() = default;
57+
{%- endif %}
58+
{%- endwith %}
5759
{%- endif %}
5860

5961
{% endwith %}

0 commit comments

Comments
 (0)