Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provides a more performant implementation of the `SanitizeKey` method for both `AzureTableStorage` and `CosmosDbStorage`. The new implementation is faster in all cases and, perhaps more importantly, the new implementation allocates zero bytes in the case that there are no illegal characters in the key and guarantees only a single allocation in the case when there are bad characters. Benchmarks: ``` ini BenchmarkDotNet=v0.10.14, OS=Windows 10.0.17134 Intel Core i7-8650U CPU 1.90GHz (Kaby Lake R), 1 CPU, 8 logical and 4 physical cores [Host] : .NET Framework 4.7.1 (CLR 4.0.30319.42000), 64bit RyuJIT-v4.7.3101.0 DefaultJob : .NET Framework 4.7.1 (CLR 4.0.30319.42000), 64bit RyuJIT-v4.7.3101.0 ``` | Method | key | Mean | Error | StdDev | Scaled | ScaledSD | Gen 0 | Allocated | |---------------------- |------------------------------------------------------------------------------------------- |------------:|-----------:|-----------:|-------:|---------:|-------:|----------:| | **SanitizeKey_OPTIMIZED** | **bad-key-!@#$%^&*()~/\><,.?';`~** | **379.31 ns** | **8.6554 ns** | **16.2569 ns** | **0.63** | **0.03** | **0.0873** | **368 B** | | SanitizeKey_ORIGINAL | bad-key-!@#$%^&*()~/\><,.?';`~ | 604.43 ns | 11.9625 ns | 11.7487 ns | 1.00 | 0.00 | 0.0887 | 376 B | | | | | | | | | | | | **SanitizeKey_OPTIMIZED** | **bad-this-is-a-realllllllll\y-long-key-that- you-probably-wouldn't-encounter//-in-the-wild#** | **1,040.62 ns** | **15.5311 ns** | **14.5278 ns** | **0.56** | **0.01** | **0.2079** | **880 B** | | SanitizeKey_ORIGINAL | bad-this-is-a-realllllllll\y-long-key-that- you-probably-wouldn't-encounter//-in-the-wild# | 1,851.81 ns | 7.5866 ns | 5.4856 ns | 1.00 | 0.00 | 0.1755 | 744 B | | | | | | | | | | | | **SanitizeKey_OPTIMIZED** | **good-key-123** | **26.44 ns** | **0.5314 ns** | **0.4437 ns** | **0.11** | **0.00** | **-** | **0 B** | | SanitizeKey_ORIGINAL | good-key-123 | 242.83 ns | 4.9347 ns | 10.5163 ns | 1.00 | 0.00 | 0.0358 | 152 B | | | | | | | | | | | | **SanitizeKey_OPTIMIZED** | **good-this-is-a-reallllllllly-long-key-that-you-probably-wouldnt-encounter-in-the-wild#** | **349.20 ns** | **6.5568 ns** | **5.8124 ns** | **0.20** | **0.01** | **0.1101** | **464 B** | | SanitizeKey_ORIGINAL | good-this-is-a-reallllllllly-long-key-that-you-probably-wouldnt-encounter-in-the-wild# | 1,778.14 ns | 37.4411 ns | 72.1362 ns | 1.00 | 0.00 | 0.1659 | 704 B |
- Loading branch information