Repository navigation
remove duplicate dictionary lookups - #4000
Conversation
There was a problem hiding this comment.
Pull request overview
Refactors several internal dictionary access patterns to avoid redundant ContainsKey + indexer lookups, primarily by switching to TryGetValue (and, for the DNS cache, direct indexer assignment) while preserving existing behavior in SqlDependency-related infrastructure.
Changes:
- Replace double-lookups with
TryGetValueinSqlDependency*code paths. - Simplify DNS cache insertion to a single overwrite assignment.
- Update server enumerator parsing to use
TryGetValuefor instance detail extraction.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDependencyUtils.cs | Uses TryGetValue for dependency ID lookup under lock. |
| src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDependencyListener.cs | Replaces repeated dictionary lookups with TryGetValue in app-domain/container tracking paths. |
| src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDependency.cs | Uses TryGetValue to avoid multiple lookups in server/user hash management and default options composition. |
| src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SQLFallbackDNSCache.cs | Simplifies add/replace semantics to a single assignment into the ConcurrentDictionary. |
| src/Microsoft.Data.SqlClient/src/Microsoft/Data/Sql/SqlDataSourceEnumeratorManagedHelper.netcore.cs | Uses TryGetValue when populating DataRow fields from parsed instance details. |
|
/azp run |
|
Azure Pipelines successfully started running 2 pipeline(s). |
paulmedynski
left a comment
There was a problem hiding this comment.
A glorious set of changes! 🚀 Just a couple of comments.
|
/azp run |
|
Azure Pipelines successfully started running 2 pipeline(s). |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4000 +/- ##
==========================================
- Coverage 74.38% 65.49% -8.90%
==========================================
Files 287 275 -12
Lines 43982 65805 +21823
==========================================
+ Hits 32717 43097 +10380
- Misses 11265 22708 +11443
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
No description provided.