-
Notifications
You must be signed in to change notification settings - Fork 863
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
Do not create strings just for comparison #3411
Comments
@paulomorgado Good morning. Thanks for opening the issue. Could you please point me to the exact location of code which you are referring to? I'm unable to find the code you are referring to here. Thanks, |
We refactored that code that was inspecting the HTTP verbs recently via #3338. Though there are likely other occurrences of creating strings for comparisons that we can take a look at, if you have others that are in a hot spot? |
According to @ashovlin, this code has been replaced. |
Comments on closed issues are hard for our team to see. |
Describe the feature
Amazon.Runtime.Internal.Marshaller.PreInvoke
has this code:method
is only used for comparison and can potentially be a newly allocated string.Use Case
Creating objects that do not need to be created, not only uses memory and CPU to create them, but also causes GC work.
Proposed Solution
Use
Equals(String, String, StringComparison)
withStringComparison.OrdinalIgnoreCase
, instead:Ordinal ignore-case comparison can also be used in dictionaries, avoiding creating creating new strings just for index lookup.
Other Information
No response
Acknowledgements
AWS .NET SDK and/or Package version used
AWSSDK.KeyManagementService 3.7.300.52
Targeted .NET Platform
.NET 8
Operating System and version
Windows and Linux
The text was updated successfully, but these errors were encountered: