Cleanup: Simplify spline point attribute materialize functions

- Iterate over the mask directly instead of using an index.
- Use Span slice and copy_from instead of a lower level function.
This commit is contained in:
Hans Goudey 2021-05-26 22:22:09 -04:00
parent c97b6215a3
commit b132dd042e
1 changed files with 3 additions and 7 deletions

View File

@ -476,14 +476,12 @@ static void point_attribute_materialize(Span<Span<T>> data,
for (const int spline_index : data.index_range()) {
const int offset = offsets[spline_index];
const int next_offset = offsets[spline_index + 1];
initialized_copy_n(data[spline_index].data(), next_offset - offset, r_span.data() + offset);
r_span.slice(offset, next_offset - offset).copy_from(data[spline_index]);
}
}
else {
int spline_index = 0;
for (const int i : r_span.index_range()) {
const int dst_index = mask[i];
for (const int dst_index : mask) {
while (offsets[spline_index] < dst_index) {
spline_index++;
}
@ -511,9 +509,7 @@ static void point_attribute_materialize_to_uninitialized(Span<Span<T>> data,
}
else {
int spline_index = 0;
for (const int i : r_span.index_range()) {
const int dst_index = mask[i];
for (const int dst_index : mask) {
while (offsets[spline_index] < dst_index) {
spline_index++;
}