Conversation
|
@copilot Is there a reason we still clone the path when it is not modified? From what I can see we can skip cloning all together. |
You're absolutely right! Since we don't modify the paths in |
|
@copilot Please add a test that verifies the speedup (approximately). |
Added a performance test that verifies at least 2x speedup when using |
cf48339 to
776b5cd
Compare
fe827c0 to
be14857
Compare
jarekdanielak
left a comment
There was a problem hiding this comment.
I ran diagram-js's test suites relying on path intersection against the old and the new versions of the library, and the performance change is marginal, so indeed getting rid of the internal caching doesn't affect the performance in the "real" use-cases that much.
I think it's a viable strategy for this library:
- Works reasonably fast OOTB.
- Doesn't do hidden magic under the hood.
- Can be fine-tuned for your individual, performance-critical use case.
Ensure we use exported types for main export.
Ensure it matches our nested format.
* remove internal caching of hot paths * create robust solution that allows external path caching Closes #25
be14857 to
4a3c777
Compare
4a3c777 to
2c7541e
Compare



Updated and fixed by @nikku. Ready for review.
Addresses #25. The library was mutating path objects with a complex internal cache using timeouts. Users wanted control over caching for performance-critical scenarios with repeated path intersections.
Changes
paths()function and all mutation-based caching fromparsePathString(),pathToAbsolute(), andpathToCurve()isPathCurve()) or absolute format (isPathAbsolute()) skip unnecessary processing and are returned as-is without cloningparsePath()utility: Users can pre-parse paths once and cache them for ~5x performance improvementpathClone()function: Not generic anymore, only called when actually neededparsePathfunctionality and validate at least 2x performance improvement with pre-parsed pathsUsage
Testing
parsePathexport and usage withintersectFully backward compatible. String and array paths continue to work unchanged.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.