Skip to content

Commit 6382ded

Browse files
committed
Cleanup move constructors in dr::Local (C++)
1 parent 1a6c8bc commit 6382ded

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

include/drjit/local.h

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,9 @@ struct Local {
3939

4040
~Local() = default;
4141
Local(const Local &) = delete;
42-
Local(Local &&l) {
43-
for (size_t i = 0; i < Size; ++i)
44-
m_data[i] = l.m_data[i];
45-
}
42+
Local(Local &&l) = default;
4643
Local &operator=(const Local &) = delete;
47-
Local &operator=(Local &&l) {
48-
for (size_t i = 0; i < Size; ++i)
49-
m_data[i] = l.m_data[i];
50-
}
44+
Local &operator=(Local &&l) = default;
5145

5246
Value read(const Index &offset, const Mask &active = true) const {
5347
if (active)
@@ -176,16 +170,16 @@ struct Local<Value_, Size_, Index_,
176170
jit_var_dec_ref(index);
177171
}
178172
Local(const Local &) = delete;
179-
Local(Local &&l) {
180-
m_arrays.swap(l.m_arrays);
181-
l.m_arrays.clear();
182-
}
173+
Local(Local &&l) = default;
174+
183175
Local &operator=(const Local &) = delete;
184176
Local &operator=(Local &&l) {
185177
for (uint32_t index : m_arrays)
186178
jit_var_dec_ref(index);
187-
m_arrays.swap(l.m_arrays);
188-
l.m_arrays.clear();
179+
m_size = std::move(l.m_size);
180+
m_value = std::move(l.m_value);
181+
m_arrays = std::move(l.m_arrays);
182+
return *this;
189183
}
190184

191185
Value read(const Index &offset, const Mask &active = true) const {

0 commit comments

Comments
 (0)