refactor(opl): drop redundant Add(string) overload; OplTextBlock depends on IPropertyList

string converts implicitly to ReadOnlySpan<char>, so Add(ReadOnlySpan<char>) subsumes
Add(string); $"..." literals still bind to the interpolated-string-handler overload
(zero-alloc). OplTextBlock now holds an IPropertyList instead of the concrete
ObjectPropertyList.
This commit is contained in:
Kamron Batman 2026-06-22 10:01:39 -07:00
parent 88de585612
commit 42ae2a1146
4 changed files with 7 additions and 9 deletions

View file

@ -29,9 +29,6 @@ public interface IPropertyList : ISelfInterpolatedStringHandler
/** Convenience method for $"{argument}". */
public void Add(int number, string argument);
/** Convenience method for $"{text}". */
public void Add(string text);
/** Convenience method for span-based text without allocating a string. */
public void Add(ReadOnlySpan<char> argument);

View file

@ -148,7 +148,6 @@ public sealed class ObjectPropertyList : IPropertyList, IDisposable
}
public void Add(int number, string? arguments) => InternalAdd(number, $"{arguments}");
public void Add(string argument) => InternalAdd(GetStringNumber(), $"{argument}");
public void Add(int number, int value) => InternalAdd(number, $"{value}");
public void AddLocalized(int value) => InternalAdd(GetStringNumber(), $"{value:#}");
public void AddLocalized(int number, int value) => InternalAdd(number, $"{value:#}");

View file

@ -23,11 +23,11 @@ namespace Server;
// Use with `using var block = list.TextBlock();`. ref struct: single-threaded OPL build only.
public ref struct OplTextBlock
{
private readonly ObjectPropertyList _list;
private readonly IPropertyList _list;
internal ValueStringBuilder _builder;
private bool _any;
internal OplTextBlock(ObjectPropertyList list)
internal OplTextBlock(IPropertyList list)
{
_list = list;
_builder = ValueStringBuilder.Create();