Skip to content

Commit

Permalink
Merge pull request #46 from mgoodfellow/always-include-string-method
Browse files Browse the repository at this point in the history
Always include the string method into the output
  • Loading branch information
Turnerj committed May 22, 2021
2 parents 829b6f2 + 028ee63 commit 9d90093
Showing 1 changed file with 2 additions and 19 deletions.
21 changes: 2 additions & 19 deletions src/Quickenshtein/Levenshtein.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,15 @@ namespace Quickenshtein
/// </summary>
public static partial class Levenshtein
{
#if NETSTANDARD
public static int GetDistance(string source, string target)
{
return GetDistance(source, target, CalculationOptions.Default);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static unsafe int GetDistance(string source, string target, CalculationOptions calculationOptions)
public static int GetDistance(string source, string target, CalculationOptions calculationOptions)
{
//Shortcut any processing if either string is empty
if (source == null || source.Length == 0)
{
return target?.Length ?? 0;
}
if (target == null || target.Length == 0)
{
return source.Length;
}

fixed (char* sourcePtr = source)
fixed (char* targetPtr = target)
{
return CalculateDistance(sourcePtr, targetPtr, source.Length, target.Length, calculationOptions);
}
return GetDistance(source.AsSpan(), target.AsSpan(), calculationOptions);
}
#endif

public static unsafe int GetDistance(ReadOnlySpan<char> source, ReadOnlySpan<char> target)
{
Expand Down

0 comments on commit 9d90093

Please sign in to comment.