perf(core): share Program instance in CloneAtOffset

Offset-only copies don't modify program codes, so sharing the instance
avoids expensive cloning during large pattern tiling.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-13 21:14:21 -04:00
parent 891bb49548
commit 1a9bd795a8

View File

@@ -216,8 +216,9 @@ namespace OpenNest
/// </summary>
public Part CloneAtOffset(Vector offset)
{
var clonedProgram = Program.Clone() as Program;
var part = new Part(BaseDrawing, clonedProgram,
// Share the Program instance — offset-only copies don't modify the program codes.
// This is a major performance win for tiling large patterns.
var part = new Part(BaseDrawing, Program,
location + offset,
new Box(BoundingBox.X + offset.X, BoundingBox.Y + offset.Y,
BoundingBox.Width, BoundingBox.Length));