Freedom-of-Form-Foundation / anatomy3d

A CAD tool for humanoid anatomy alterations. See the anatomy3d-blender repository for more recent work.
https://freedomofform.org/1856/3d-anatomy-project-scope-phase-1-focus-on-a-limb-joint/
GNU General Public License v2.0
7 stars 5 forks source link

Avoid a (potentially big) copy in capsule.GenerateIndexList. #51

Closed AdamNorberg closed 3 years ago

AdamNorberg commented 3 years ago

capsule.GenerateIndexList copies most of its cylinder's index list (GetRange is a shallow copy) to trim off the end rings that need to belong to the hemisphere endcaps instead. A Slice type, which is an offset view of a backing list, preserves the existing code without copying the list.

I believe the existing call into this function would cause the list being unnecessarily mostly copied to be about 65,000 elements long. Unnecessary copies are fine (and often optimal, for languages that aren't designed around slicing) for small lists but a bad idea for large ones, and the "small" threshhold is somewhere below a thousand.