diff --git a/src/Benchmarks/Benchmarks.csproj b/src/Benchmarks/Benchmarks.csproj
index dfc4697f4..bcf7843ad 100644
--- a/src/Benchmarks/Benchmarks.csproj
+++ b/src/Benchmarks/Benchmarks.csproj
@@ -8,6 +8,7 @@
+
diff --git a/src/Benchmarks/EnglishArticleBenchmarks.cs b/src/Benchmarks/EnglishArticleBenchmarks.cs
new file mode 100644
index 000000000..219161cfd
--- /dev/null
+++ b/src/Benchmarks/EnglishArticleBenchmarks.cs
@@ -0,0 +1,7 @@
+[MemoryDiagnoser(false)]
+public class EnglishArticleBenchmarks
+{
+ [Benchmark]
+ public string[] AppendArticlePrefix() =>
+ EnglishArticle.AppendArticlePrefix([ "Ant", "The Theater", "The apple", "Fox", "Bear"]);
+}
\ No newline at end of file
diff --git a/src/Benchmarks/Program.cs b/src/Benchmarks/Program.cs
index 8765747d0..d2ced67d3 100644
--- a/src/Benchmarks/Program.cs
+++ b/src/Benchmarks/Program.cs
@@ -1 +1,2 @@
-BenchmarkRunner.Run();
\ No newline at end of file
+BenchmarkRunner.Run(
+ typeof(Program).Assembly);
\ No newline at end of file
diff --git a/src/Humanizer.Tests.Shared/ArticlePrefixSortTests.cs b/src/Humanizer.Tests.Shared/ArticlePrefixSortTests.cs
index a37fc8e3a..ffb973e4a 100644
--- a/src/Humanizer.Tests.Shared/ArticlePrefixSortTests.cs
+++ b/src/Humanizer.Tests.Shared/ArticlePrefixSortTests.cs
@@ -6,6 +6,7 @@ public class ArticlePrefixSortTests
[InlineData(new[] { "Ant", "The Theater", "The apple", "Fox", "Bear" }, new[] { "Ant", "The apple", "Bear", "Fox", "The Theater" })]
[InlineData(new[] { "An Ant", "The Theater", "the apple", "a Fox", "Bear" }, new[] { "An Ant", "the apple", "Bear", "a Fox", "The Theater" })]
[InlineData(new[] { "Ant", "A Theater", "an apple", "Fox", "Bear" }, new[] { "Ant", "an apple", "Bear", "Fox", "A Theater" })]
+ [InlineData(new[] { " Ant ", " A Theater ", " an apple ", " Fox", "Bear " }, new[] { "A Theater", "an apple", "Ant", "Bear", "Fox" })]
public void SortStringArrayIgnoringArticlePrefixes(string[] input, string[] expectedOutput) =>
Assert.Equal(expectedOutput, EnglishArticle.PrependArticleSuffix(EnglishArticle.AppendArticlePrefix(input)));
diff --git a/src/Humanizer/ArticlePrefixSort.cs b/src/Humanizer/ArticlePrefixSort.cs
index 5077e1e20..e92fd8e33 100644
--- a/src/Humanizer/ArticlePrefixSort.cs
+++ b/src/Humanizer/ArticlePrefixSort.cs
@@ -22,17 +22,17 @@ public static string[] AppendArticlePrefix(string[] items)
for (var i = 0; i < items.Length; i++)
{
- var item = items[i];
+ var item = items[i].AsSpan();
if (_regex.IsMatch(item))
{
- var article = item.Substring(0, item.IndexOf(" ", StringComparison.CurrentCulture));
- var removed = item.Remove(0, item.IndexOf(" ", StringComparison.CurrentCulture));
- var appended = $"{removed} {article}";
- transformed[i] = appended.Trim();
+ var indexOf = item.IndexOf(' ');
+ var removed = item[indexOf..].TrimStart();
+ var article = item[..indexOf].TrimEnd();
+ transformed[i] = $"{removed} {article}";
}
else
{
- transformed[i] = item.Trim();
+ transformed[i] = item.Trim().ToString();
}
}
Array.Sort(transformed);