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

Reduce some allocations with the magic of spans etc. #5938

Merged
merged 7 commits into from May 5, 2021
Merged
Changes from 1 commit
Commits
File filter
Filter file types
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.

Always

Just for now

remove span based setproviderid
  • Loading branch information
cvium committed Apr 30, 2021
commit 716cbb06958da987ab917c1f6408396d4ace7a0c
@@ -1012,7 +1012,7 @@ private static void DeserializeProviderIds(string value, BaseItem item)
var providerDelimiterIndex = part.IndexOf('=');
if (providerDelimiterIndex != -1 && providerDelimiterIndex == part.LastIndexOf('='))
{
item.SetProviderId(part.Slice(0, providerDelimiterIndex), part.Slice(providerDelimiterIndex + 1));
item.SetProviderId(part.Slice(0, providerDelimiterIndex).ToString(), part.Slice(providerDelimiterIndex + 1).ToString());
}
}
}
@@ -132,36 +132,6 @@ public static void SetProviderId(this IHasProviderIds instance, string name, str
}
}

/// <summary>
/// Sets a provider id.
/// </summary>
/// <param name="instance">The instance.</param>
/// <param name="name">The name.</param>
/// <param name="value">The value.</param>
public static void SetProviderId(this IHasProviderIds instance, ReadOnlySpan<char> name, ReadOnlySpan<char> value)
{
if (instance == null)
{
throw new ArgumentNullException(nameof(instance));
}

// If it's null remove the key from the dictionary
if (value.IsEmpty)
{
instance.ProviderIds?.Remove(name.ToString());
}
else
{
// Ensure it exists
if (instance.ProviderIds == null)
{
instance.ProviderIds = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
}

instance.ProviderIds[name.ToString()] = value.ToString();
}
}

/// <summary>
/// Sets a provider id.
/// </summary>
ProTip! Use n and p to navigate between commits in a pull request.