ModernUO/Projects/Server/Text
Kamron Batman 872de8d095
fix: Optimizes GetString to eliminate allocations (#2154)
### Summary

* Optimized GetString by eliminating the intermediate string allocation.

** Note **: Encoding.GetChars() is still really inefficient, especially when strings are not aligned or have regular ascii/unicode characters. Thankfully we generally don't have to worry about these odd edge cases, but if they happen then GetChars can allocate hundreds of bytes.


This is a benchmark for just the related changes. NonSpecial are just ascii characters, while the other tests include control codes.
```cs
| Method                         | Mean     | Error   | StdDev  | Gen0   | Allocated |
|------------------------------- |---------:|--------:|--------:|-------:|----------:|
| GetString                      | 306.7 ns | 5.96 ns | 6.86 ns | 0.0124 |     200 B |
| GetStringNotSpecial            | 257.0 ns | 4.83 ns | 4.52 ns | 0.0114 |     184 B |
| GetStringSpanHelpers           | 166.4 ns | 3.26 ns | 3.48 ns |      - |         - |
| GetStringSpanHelpersNotSpecial | 137.3 ns | 1.57 ns | 1.22 ns |      - |         - |
```
2025-04-12 12:42:15 -07:00
..
HexStringConverter.cs chore: Updates copyright (#1448) 2023-08-09 09:09:26 -07:00
InsensitiveStringHelpers.cs fix: Adds required changes for Advanced Search feature (#1650) 2023-12-28 18:16:58 -08:00
ISelfInterpolatedStringHandler.cs chore: Updates copyright (#1448) 2023-08-09 09:09:26 -07:00
OrdinalStringHelpers.cs feat: Updates to .NET 8. (#1542) 2023-11-14 17:08:09 -08:00
StringHelpers.cs feat: Adds Pre-UOTD single click support for weapons, armor, wands, and clothing (#2053) 2025-01-13 17:04:24 -08:00
TextDefinition.cs chore: Updates copyright (#1448) 2023-08-09 09:09:26 -07:00
TextEncoding.cs fix: Optimizes GetString to eliminate allocations (#2154) 2025-04-12 12:42:15 -07:00