Skip to content

Commit

Permalink
Use MemoryExtensions.Contains
Browse files Browse the repository at this point in the history
  • Loading branch information
paulirwin committed Jan 18, 2025
1 parent 7da9624 commit 8b47769
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
using System.Linq;
using Assert = Lucene.Net.TestFramework.Assert;

#if !FEATURE_STRING_CONTAINS_STRINGCOMPARISON
using Lucene.Net.Support.Text;
#endif

namespace Lucene.Net.Support.ExceptionHandling
{
/*
Expand Down Expand Up @@ -409,7 +405,7 @@ public void TestPrintStackTrace()
e.PrintStackTrace(sw);
}

var str = sw.ToString();
var str = sw.ToString().AsSpan();

Assert.IsTrue(str.Contains(typeof(MyException).FullName!, StringComparison.Ordinal));

Check failure on line 410 in src/Lucene.Net.Tests.AllProjects/Support/ExceptionHandling/TestExceptionExtensions.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net472, x64, Release)

Argument 2: cannot convert from 'string' to 'System.ReadOnlySpan<char>'

Check failure on line 410 in src/Lucene.Net.Tests.AllProjects/Support/ExceptionHandling/TestExceptionExtensions.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net472, x64, Release)

Argument 2: cannot convert from 'string' to 'System.ReadOnlySpan<char>'

Check failure on line 410 in src/Lucene.Net.Tests.AllProjects/Support/ExceptionHandling/TestExceptionExtensions.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net48, x64, Release)

Argument 2: cannot convert from 'string' to 'System.ReadOnlySpan<char>'

Check failure on line 410 in src/Lucene.Net.Tests.AllProjects/Support/ExceptionHandling/TestExceptionExtensions.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net48, x64, Release)

Argument 2: cannot convert from 'string' to 'System.ReadOnlySpan<char>'
Assert.IsTrue(str.Contains("Test exception", StringComparison.Ordinal));

Check failure on line 411 in src/Lucene.Net.Tests.AllProjects/Support/ExceptionHandling/TestExceptionExtensions.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net472, x64, Release)

Argument 2: cannot convert from 'string' to 'System.ReadOnlySpan<char>'

Check failure on line 411 in src/Lucene.Net.Tests.AllProjects/Support/ExceptionHandling/TestExceptionExtensions.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net472, x64, Release)

Argument 2: cannot convert from 'string' to 'System.ReadOnlySpan<char>'

Check failure on line 411 in src/Lucene.Net.Tests.AllProjects/Support/ExceptionHandling/TestExceptionExtensions.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net48, x64, Release)

Argument 2: cannot convert from 'string' to 'System.ReadOnlySpan<char>'

Check failure on line 411 in src/Lucene.Net.Tests.AllProjects/Support/ExceptionHandling/TestExceptionExtensions.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net48, x64, Release)

Argument 2: cannot convert from 'string' to 'System.ReadOnlySpan<char>'
Expand Down Expand Up @@ -439,7 +435,7 @@ public void TestPrintStackTrace_WithSuppressed()
e.PrintStackTrace(sw);
}

var str = sw.ToString();
var str = sw.ToString().AsSpan();

Assert.IsTrue(str.Contains(typeof(MyException).FullName!, StringComparison.Ordinal));

Check failure on line 440 in src/Lucene.Net.Tests.AllProjects/Support/ExceptionHandling/TestExceptionExtensions.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net472, x64, Release)

Argument 2: cannot convert from 'string' to 'System.ReadOnlySpan<char>'

Check failure on line 440 in src/Lucene.Net.Tests.AllProjects/Support/ExceptionHandling/TestExceptionExtensions.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net48, x64, Release)

Argument 2: cannot convert from 'string' to 'System.ReadOnlySpan<char>'
Assert.IsTrue(str.Contains("Test exception", StringComparison.Ordinal));

Check failure on line 441 in src/Lucene.Net.Tests.AllProjects/Support/ExceptionHandling/TestExceptionExtensions.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net472, x64, Release)

Argument 2: cannot convert from 'string' to 'System.ReadOnlySpan<char>'

Check failure on line 441 in src/Lucene.Net.Tests.AllProjects/Support/ExceptionHandling/TestExceptionExtensions.cs

View workflow job for this annotation

GitHub Actions / Test (windows-latest, net48, x64, Release)

Argument 2: cannot convert from 'string' to 'System.ReadOnlySpan<char>'
Expand Down
2 changes: 1 addition & 1 deletion src/Lucene.Net/Support/Text/StringExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public static bool Contains(this string input, string value, StringComparison co
if (value is null)
throw new ArgumentNullException(nameof(value));

return input.IndexOf(value, comparison) >= 0;
return input.AsSpan().Contains(value.AsSpan(), comparison);
}
#endif
}
Expand Down

0 comments on commit 8b47769

Please sign in to comment.