-
Notifications
You must be signed in to change notification settings - Fork 27
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
perf: Cleanup allocations + missing ConfigureAwait's #124
Conversation
a25cca3
to
57e3066
Compare
Had inadvertently dropped a |
@@ -519,7 +521,7 @@ private static Value ConvertToPrimitiveValue(ProtoValue value) | |||
|
|||
private Service.ServiceClient BuildClientForPlatform(Uri url) | |||
{ | |||
var useUnixSocket = url.ToString().StartsWith("unix://"); | |||
var useUnixSocket = url.Scheme is "unix"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Above, you use string.Equals(url.Scheme, "unix", StringComparison.OrdinalIgnoreCase)
. Is there a reason to do it differently here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not necessarily. I'm starting to see the is {const string}
pattern more often in the wild for exact/ordinal matching, so since StartsWith(string)
implies StartsWith(string, StringComparison.Ordinal)
, I converted it to a constant ordinal pattern out of habit.
But I can certainly convert it to string.Equals(url.Scheme, "unix", StringComparison.Ordinal)
for consistency if you prefer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a weak preference for the consistency in this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough! Updated:
diff --git a/src/OpenFeature.Contrib.Providers.Flagd/FlagdProvider.cs b/src/OpenFeature.Contrib.Providers.Flagd/FlagdProvider.cs
index 6496ebc..cdb5f26 100644
--- a/src/OpenFeature.Contrib.Providers.Flagd/FlagdProvider.cs
+++ b/src/OpenFeature.Contrib.Providers.Flagd/FlagdProvider.cs
@@ -516,7 +516,7 @@ namespace OpenFeature.Contrib.Providers.Flagd
private Service.ServiceClient BuildClientForPlatform(Uri url)
{
- var useUnixSocket = url.Scheme is "unix";
+ var useUnixSocket = string.Equals(url.Scheme, "unix", StringComparison.Ordinal);
if (!useUnixSocket)
{
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving with a question. Thanks again!
Additionally, do you think it's worth adding something like this as we have in the SDK?
I'm definitely in the |
Confused on the test re-failures, given they passed locally last week. I'll re-re-run them locally and see what's going on... |
@austindrenski I guess this is a side-effect of adding |
Locally it seemed to be from that erroneously dropped |
57e3066
to
670698e
Compare
doh! mis-converted the original updated the pr, but interesting bit is here: diff --git a/src/OpenFeature.Contrib.Providers.Flagd/FlagdProvider.cs b/src/OpenFeature.Contrib.Providers.Flagd/FlagdProvider.cs
index 65e5c03..481a724 100644
--- a/src/OpenFeature.Contrib.Providers.Flagd/FlagdProvider.cs
+++ b/src/OpenFeature.Contrib.Providers.Flagd/FlagdProvider.cs
@@ -325,18 +325,10 @@ namespace OpenFeature.Contrib.Providers.Flagd
var response = call.ResponseStream.Current;
if (string.Equals(response.Type, "configuration_change", StringComparison.OrdinalIgnoreCase))
{
HandleConfigurationChangeEvent(response.Data);
- break;
}
-
- if (string.Equals(response.Type, "provider_ready", StringComparison.OrdinalIgnoreCase))
+ else if (string.Equals(response.Type, "provider_ready", StringComparison.OrdinalIgnoreCase))
{
HandleProviderReadyEvent();
- break;
}
-
- break;
}
}
catch (RpcException ex) when (ex.StatusCode == StatusCode.Unavailable) |
670698e
to
319e350
Compare
Minor stuff, but noticed these while reviewing/evaluating the source for an upcoming project and figured they're most likely oversights, so opening a quick PR to help out. Signed-off-by: Austin Drenski <[email protected]>
319e350
to
5e14b85
Compare
I noticed this about the same time you force pushed the fix. Understandable mistake 😅 |
Signed-off-by: Austin Drenski <[email protected]> Signed-off-by: Eric Pattison <[email protected]>
Signed-off-by: Austin Drenski <[email protected]> Signed-off-by: Eric Pattison <[email protected]>
Signed-off-by: Austin Drenski <[email protected]> Signed-off-by: Eric Pattison <[email protected]>
Minor stuff, but noticed these while reviewing/evaluating the source for an upcoming project and figured they're most likely oversights, so opening a quick PR to help out.