Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Stabzs
Copy link

@Stabzs Stabzs commented Aug 18, 2022

…perations.

/// <remarks>
/// <seealso href="https://redis.io/commands/mset"/>,
/// <seealso href="https://redis.io/commands/msetnx"/>
/// </remarks>
Copy link
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
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
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
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

Copy link
Author

@Stabzs Stabzs Aug 26, 2022

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
Copy link
Collaborator

mgravell commented Oct 11, 2022 via email

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