Skip to content

Commit ee4df79

Browse files
committed
Revert change of how to count words
1 parent c536130 commit ee4df79

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/LinkDotNet.Blog.Web/Features/Services/ReadingTimeCalculator.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,16 @@ public static int CalculateReadingTime(string content)
2424
private static int GetWordCount(ReadOnlySpan<char> content)
2525
{
2626
var wordCount = 0;
27-
var index = 0;
28-
while ((index = content[index..].IndexOf(' ')) != -1)
27+
for (var i = 0; i < content.Length; i++)
2928
{
30-
wordCount++;
29+
if (content[i] == ' ')
30+
{
31+
wordCount++;
32+
}
3133
}
3234

3335
return wordCount;
36+
37+
return wordCount;
3438
}
3539
}

0 commit comments

Comments
 (0)