Skip to content

Commit 000137a

Browse files
committed
Fix CodeFactor issue
1 parent 2eab4db commit 000137a

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/NHibernate.Test/TestCase.cs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -515,17 +515,14 @@ protected static int GetTotalOccurrences(string content, string substring)
515515
throw new ArgumentNullException(nameof(substring));
516516
}
517517

518-
int occurrences = 0;
519-
for (var index = 0; ; index += substring.Length)
518+
int occurrences = 0, index = 0;
519+
while ((index = content.IndexOf(substring, index)) >= 0)
520520
{
521-
index = content.IndexOf(substring, index);
522-
if (index == -1)
523-
{
524-
return occurrences;
525-
}
526-
527521
occurrences++;
522+
index += substring.Length;
528523
}
524+
525+
return occurrences;
529526
}
530527

531528
protected struct Substitute<TType> : IDisposable

0 commit comments

Comments
 (0)