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>
|
/// </summary>
|
||||||
public Part CloneAtOffset(Vector offset)
|
public Part CloneAtOffset(Vector offset)
|
||||||
{
|
{
|
||||||
var clonedProgram = Program.Clone() as Program;
|
// Share the Program instance — offset-only copies don't modify the program codes.
|
||||||
var part = new Part(BaseDrawing, clonedProgram,
|
// This is a major performance win for tiling large patterns.
|
||||||
|
var part = new Part(BaseDrawing, Program,
|
||||||
location + offset,
|
location + offset,
|
||||||
new Box(BoundingBox.X + offset.X, BoundingBox.Y + offset.Y,
|
new Box(BoundingBox.X + offset.X, BoundingBox.Y + offset.Y,
|
||||||
BoundingBox.Width, BoundingBox.Length));
|
BoundingBox.Width, BoundingBox.Length));
|
||||||
|
|||||||
Reference in New Issue
Block a user