Skip to content

Initial POC commit for adding ReadOnlyMemory overloads to StringSet o…#2221

Draft
Stabzs wants to merge 1 commit into
StackExchange:mainfrom
Stabzs:pooled_overloads
Draft

Initial POC commit for adding ReadOnlyMemory overloads to StringSet o…#2221
Stabzs wants to merge 1 commit into
StackExchange:mainfrom
Stabzs:pooled_overloads

Conversation

@Stabzs

@Stabzs Stabzs commented Aug 18, 2022

Copy link
Copy Markdown

…perations.

/// <remarks>
/// <seealso href="https://redis.io/commands/mset"/>,
/// <seealso href="https://redis.io/commands/msetnx"/>
/// </remarks>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

possibly worth a warning about FireAndForget being dangerous here if the ReadOnlyMemory is going to be recycled/reused?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Definitely seems wise, thank you. I'll add warnings for all of the new methods taking ReadOnlyMemory. If the approach looks good overall, I'll continue expanding the surface area.


for (int i = 0; i < outer.Length; ++i)
{
inner[i] = ToInner(outer.Span[i]);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Accessing .Span is relatively expensive; this should be done outside the loop and resused.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The ++i is very unusual for C#, note

@Stabzs Stabzs Aug 26, 2022

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Makes sense, thanks! I'll make the changes to cache all call sites for .Span.

The ++i was copied from line 801 of the diff. I assumed that was intentional and copied it here. Is that an incorrect usage?

@mgravell

mgravell commented Oct 11, 2022 via email

Copy link
Copy Markdown
Collaborator

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants