[CSHARP-2736] Improve performance of CollectionElementNameValidator Created: 06/Sep/19  Updated: 06/Jun/23  Resolved: 06/Jun/23

Status: Closed
Project: C# Driver
Component/s: Performance
Affects Version/s: 2.9.1
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Wojciech Cibor Assignee: Unassigned
Resolution: Won't Do Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Documentation Changes Summary:

1. What would you like to communicate to the user about this feature?
2. Would you like the user to see examples of the syntax and/or executable code and its output?
3. Which versions of the driver/connector does this apply to?


 Description   

The current implementation of IsValidElementName method does the string lookup on the List while checking the exceptions. It is faster to use the Array instead. I also checked the performance of using the HashSet for that case, but it's generally worse for that number of elements.

 

Here is my benchmark: https://github.com/wojciechcibor/BenchmarkMongoElementNameValidator

 


Generated at Wed Feb 07 21:43:24 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.