[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? |
| 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
|