Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/DynamoCore/Library/LibraryServices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -506,10 +506,12 @@ internal bool IsFunctionBuiltIn(string library, string name = "")
}
}

private static bool CanbeResolvedTo(ICollection<string> partialName, ICollection<string> fullName)
private static bool CanbeResolvedTo(string qualifiedName, string fullName)
{
return null != partialName && null != fullName && partialName.Count <= fullName.Count
&& fullName.Reverse().Take(partialName.Count).SequenceEqual(partialName.Reverse());
return null != qualifiedName && null != fullName
&& qualifiedName.Length <= fullName.Length
// compare the backing char spans of fullname[end - length..end] and qualifiedName without any allocations
&& fullName.AsSpan(fullName.Length - qualifiedName.Length, qualifiedName.Length).SequenceEqual(qualifiedName.AsSpan());
}

private static bool TryGetFunctionGroup(
Expand All @@ -518,8 +520,7 @@ private static bool TryGetFunctionGroup(
if (funcGroupMap.TryGetValue(qualifiedName, out funcGroup))
return true;

string[] partialName = qualifiedName.Split('.');
string key = funcGroupMap.Keys.FirstOrDefault(k => CanbeResolvedTo(partialName, k.Split('.')));
string key = funcGroupMap.Keys.FirstOrDefault(k => CanbeResolvedTo(qualifiedName, k));

if (key != null)
{
Expand Down
Loading