Skip to content

Use spans to improve performance in StreamExts.#21186

Merged
PunkPun merged 1 commit intoOpenRA:bleedfrom
RoosterDragon:stream-spans
Nov 10, 2023
Merged

Use spans to improve performance in StreamExts.#21186
PunkPun merged 1 commit intoOpenRA:bleedfrom
RoosterDragon:stream-spans

Conversation

@RoosterDragon
Copy link
Copy Markdown
Member

Also avoid ReadBytes calls that allocate a buffer by either updating the stream position (if not interested in the bytes), by reusing an input buffer (if interested in the bytes), or using a stackalloc buffer to avoid the allocation (for small reads).


This isn't motivated by any specific performance benchmark, but rather just on the basis that moving towards using more span features in something that affects a large chunk of the codebase such as streams will provide some incremental gains.

Copy link
Copy Markdown
Member

@PunkPun PunkPun left a comment

Choose a reason for hiding this comment

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

otherwise LGTM

Comment thread OpenRA.Game/StreamExts.cs
Comment thread OpenRA.Mods.Common/AudioLoaders/OggLoader.cs Outdated
@RoosterDragon
Copy link
Copy Markdown
Member Author

Added some missing newlines.

Comment thread OpenRA.Game/StreamExts.cs
Also avoid ReadBytes calls that allocate a buffer by either updating the stream position (if not interested in the bytes), by reusing an input buffer (if interested in the bytes), or using a stackalloc buffer to avoid the allocation (for small reads).
Copy link
Copy Markdown
Member

@PunkPun PunkPun left a comment

Choose a reason for hiding this comment

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

LGTM

@PunkPun PunkPun merged commit 5d91b67 into OpenRA:bleed Nov 10, 2023
@PunkPun
Copy link
Copy Markdown
Member

PunkPun commented Nov 10, 2023

Changelog

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants