From 028f2b83e0a45b853760285e3d2f5409f755b2c4 Mon Sep 17 00:00:00 2001 From: Khan Winter <35942988+thecoolwinter@users.noreply.github.com> Date: Thu, 12 Jun 2025 11:11:35 -0500 Subject: [PATCH] Use Faster `NSTextStorage` Substring Updates the `NSTextStorage` `TextStoring` internals to use the much faster `NSString.substring` instead of finding the attributed substring. This avoids any unnecessary attribute fixing, attribute allocation, etc. --- Sources/TextStory/NSTextStorage+TextStoring.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/TextStory/NSTextStorage+TextStoring.swift b/Sources/TextStory/NSTextStorage+TextStoring.swift index c72a9cf..1401a83 100644 --- a/Sources/TextStory/NSTextStorage+TextStoring.swift +++ b/Sources/TextStory/NSTextStorage+TextStoring.swift @@ -23,6 +23,6 @@ extension NSTextStorage: TextStoring { return nil } - return attributedSubstring(from: range).string + return (string as NSString).substring(with: range) } }