Files
test2/source
Laurynas Duburas a806f1c866 Curves: Optimization of ed::curves::duplicate_points
Adds new function `foreach_content_slice_by_offsets` that gathers mask's
indices into `IndexRange` lists grouped by given offsets. New approach
doesn't need temporary `points_to_duplicate` array of size
`curves.points_num()`. Traversal is more effective as only selected
indices get visited. Also point data is copied by point ranges instead
of point by point.

Performance was tested with following code:
```cpp
TEST(curves_geometry, DuplicatePoints)
{
  CurvesGeometry curves = create_basic_curves(100000, 100);

  IndexMaskMemory memory;
  IndexMask every_second = IndexMask::from_predicate(
      curves.points_range(), GrainSize(100), memory, [](const int i) {
        return bool(i % 2);
      });

  for (const int i : IndexRange(1000)) {
    CurvesGeometry copy = curves;
    const int expected_point_count = copy.points_num() + every_second.size();
    ed::curves::duplicate_points(copy, every_second);
    EXPECT_EQ(copy.points_num(), expected_point_count);
  }
}
```
|          |   main   | mask slices | slices & copy by ranges |
| -------- | -------- | ----------- | ----------------------- |
| full copy|  3346 ms | 2270 ms | 1614 ms |
| `i % 2`  |  8084 ms | 5918 ms | 5112 ms |
| `!((i % 10 == 0) or` <br/>`(i % 10 == 1) or` <br/>`(i % 10 == 2))` | 4522 ms | 2860 ms | 2343 ms|
| `(i % 10 == 0) or` <br/> `(i % 10 == 1) or` <br/> `(i % 10 == 2)`| 4088 ms | 1961 ms | 1639 ms|
| `IndexRange(50020, 70)` <br/> <sub>(one small range in the middle)</sub>| 1966 ms | 100 ms | ~75 ms |

Pull Request: https://projects.blender.org/blender/blender/pulls/133101
2025-01-30 17:19:16 +01:00
..