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:
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user