From 9852feaf0862a199a28ee131a863a0d65bd9a6cc Mon Sep 17 00:00:00 2001 From: Haselnussbomber Date: Wed, 8 Oct 2025 03:41:31 +0200 Subject: [PATCH 1/2] Add RentedSeStringBuilder Co-authored-by: Soreepeong <3614868+Soreepeong@users.noreply.github.com> --- Dalamud/Utility/RentedSeStringBuilder.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 Dalamud/Utility/RentedSeStringBuilder.cs diff --git a/Dalamud/Utility/RentedSeStringBuilder.cs b/Dalamud/Utility/RentedSeStringBuilder.cs new file mode 100644 index 000000000..93a45d967 --- /dev/null +++ b/Dalamud/Utility/RentedSeStringBuilder.cs @@ -0,0 +1,19 @@ +using Lumina.Text; + +namespace Dalamud.Utility; + +/// +/// Provides a temporarily rented from a shared pool. +/// +public readonly struct RentedSeStringBuilder() : IDisposable +{ + /// + /// Gets the rented value from the shared pool. + /// + public SeStringBuilder Builder { get; } = SeStringBuilder.SharedPool.Get(); + + /// + /// Returns the rented to the shared pool. + /// + public void Dispose() => SeStringBuilder.SharedPool.Return(this.Builder); +} From 4a869bad3f4a2ff5f2a8c739c71234c40fa0cf55 Mon Sep 17 00:00:00 2001 From: Haselnussbomber Date: Wed, 8 Oct 2025 03:41:34 +0200 Subject: [PATCH 2/2] Use Luminas SeStringBuilder in DalamudAtkTweaks --- Dalamud/Game/Internal/DalamudAtkTweaks.cs | 30 ++++++++++++++--------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/Dalamud/Game/Internal/DalamudAtkTweaks.cs b/Dalamud/Game/Internal/DalamudAtkTweaks.cs index 83a2f3525..486af463c 100644 --- a/Dalamud/Game/Internal/DalamudAtkTweaks.cs +++ b/Dalamud/Game/Internal/DalamudAtkTweaks.cs @@ -1,12 +1,12 @@ using CheapLoc; + using Dalamud.Configuration.Internal; using Dalamud.Game.Text; -using Dalamud.Game.Text.SeStringHandling; -using Dalamud.Game.Text.SeStringHandling.Payloads; using Dalamud.Hooking; using Dalamud.Interface.Internal; using Dalamud.Interface.Windowing; using Dalamud.Logging.Internal; +using Dalamud.Utility; using FFXIVClientStructs.FFXIV.Client.UI; using FFXIVClientStructs.FFXIV.Client.UI.Agent; @@ -185,17 +185,23 @@ internal sealed unsafe class DalamudAtkTweaks : IInternalDisposableService secondStringEntry->ChangeType(ValueType.String); const int color = 539; - var strPlugins = new SeString().Append(new UIForegroundPayload(color)) - .Append($"{SeIconChar.BoxedLetterD.ToIconString()} ") - .Append(new UIForegroundPayload(0)) - .Append(this.locDalamudPlugins).Encode(); - var strSettings = new SeString().Append(new UIForegroundPayload(color)) - .Append($"{SeIconChar.BoxedLetterD.ToIconString()} ") - .Append(new UIForegroundPayload(0)) - .Append(this.locDalamudSettings).Encode(); - firstStringEntry->SetManagedString(strPlugins); - secondStringEntry->SetManagedString(strSettings); + using var rssb = new RentedSeStringBuilder(); + + firstStringEntry->SetManagedString(rssb.Builder + .PushColorType(color) + .Append($"{SeIconChar.BoxedLetterD.ToIconString()} ") + .PopColorType() + .Append(this.locDalamudPlugins) + .GetViewAsSpan()); + + rssb.Builder.Clear(); + secondStringEntry->SetManagedString(rssb.Builder + .PushColorType(color) + .Append($"{SeIconChar.BoxedLetterD.ToIconString()} ") + .PopColorType() + .Append(this.locDalamudSettings) + .GetViewAsSpan()); // open menu with new size var sizeEntry = &atkValueArgs[4];