Skip to content

Change a byte[] in KnownColorTable to be ReadOnlySpan<byte> - #51719

Merged
stephentoub merged 1 commit into
dotnet:mainfrom
stephentoub:colortablespan
Apr 23, 2021
Merged

Change a byte[] in KnownColorTable to be ReadOnlySpan<byte>#51719
stephentoub merged 1 commit into
dotnet:mainfrom
stephentoub:colortablespan

Conversation

@stephentoub

Copy link
Copy Markdown
Member

cc: @safern

@ghost ghost added the area-System.Drawing label Apr 23, 2021
@ghost

ghost commented Apr 23, 2021

Copy link
Copy Markdown

Tagging subscribers to this area: @safern, @tarekgh
See info in area-owners.md if you want to be subscribed.

Issue Details

cc: @safern

Author: stephentoub
Assignees: -
Labels:

area-System.Drawing

Milestone: -

@safern safern left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious did you find this in auditing memory on some app or anything?

Should we also update s_colorValueTable to ReadOnlySpan<uint> or that doesn't help?

Comment thread src/libraries/Common/src/System/Drawing/KnownColorTable.cs
@gfoidl

gfoidl commented Apr 23, 2021

Copy link
Copy Markdown
Member

Should we also update s_colorValueTable to ReadOnlySpan<uint> or that doesn't help?

This doesn't help. The C# compiler's optimization to refer to the data-segment of the assembly directly only works for (primitive) types with one byte size (due to endianess concerns). See e.g. this sharplab.

@stephentoub

Copy link
Copy Markdown
Member Author

We'll need #24961 and Roslyn support for it before we can start using this with types other than byte, sbyte, and bool.

@stephentoub
stephentoub merged commit 23d16da into dotnet:main Apr 23, 2021
@stephentoub
stephentoub deleted the colortablespan branch April 23, 2021 10:59
@stephentoub

Copy link
Copy Markdown
Member Author

Curious did you find this in auditing memory on some app or anything?

I was going back through some PRs I hadn't reviewed and saw the array rather than span being introduced in #50489.

@karelz karelz modified the milestones: 5.0.x, 6.0.0 May 20, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Jun 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants