[API Proposal] System.Drawing.Drawing2D.GraphicsPathIterator.CopyData spanify
See original GitHub issueBackground and motivation
When converting graphicsPaths I’m iterating over a lot of subpaths.
for (int i = ...
{
// ...
var subPathPoints = new GDIP.PointF[cnt];
var subPathTypes = new byte[cnt];
pathIterator.CopyData(ref subPathPoints, ref subPathTypes, startIndexSubPath, endIndexSubPath);
}
I’d like rent the subPathPoints and subPathTypes from an ArrayPool. Because the arraypool would give me larger arrays, I should need to use Spans and slice them to the actual size.
original question: Can a CopyData overload using Spans be added?
API Proposal
Something like this, I’ll let the experts decide the best method parameters/overloads and datatypes
namespace System.Drawing.Drawing2D {
public class GraphicsPathIterator
{
public int CopyData (Span<System.Drawing.PointF> points, Span<byte types, int startIndex, int endIndex);
}
}
API Usage
for (int i = ...
{
// ...
pathIterator.CopyData(Span<PointF> subPathPoints, Span<byte> subPathTypes, startIndexSubPath, endIndexSubPath);
}
Alternative Designs
I’ll let the experts decide the best method parameters/overloads and datatypes
Risks
None
Will this feature affect UI controls
- No, not that I’m aware of.
Only impact is performanceboost and less allocations! 😄
Issue Analytics
- State:
- Created 5 months ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
[API Proposal] System.Drawing.Drawing2D. ...
I'd like rent the subPathPoints and subPathTypes from an ArrayPool. Because the arraypool would give me larger arrays, I should need to use ......
Read more >GraphicsPathIterator.CopyData(PointF[], Byte[], Int32 ...
Copies the PathPoints property and PathTypes property arrays of the associated GraphicsPath into the two specified arrays.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

System.Drawing now lives in the dotnet/winforms repo. Transferring this issue there.
Updated the template. Thanks for pointing out.