Skip to content

Commit

Permalink
Modified TypeHasMatchingTags to optimize performance
Browse files Browse the repository at this point in the history
  • Loading branch information
EProd-Rhansen committed Dec 7, 2016
1 parent fa94997 commit cb9961b
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/FluentMigrator/Infrastructure/DefaultMigrationConventions.cs
Expand Up @@ -148,10 +148,18 @@ public static bool TypeHasMatchingTags(Type type, IEnumerable<string> tagsToMatc
return false;

var tagNamesForAllBehavior = tags.Where(t => t.Behavior == TagBehavior.RequireAll).SelectMany(t => t.TagNames).ToArray();
if (tagNamesForAllBehavior.Any() && tagsToMatch.All(t => tagNamesForAllBehavior.Any(t.Equals)))
{
return true;
}

var tagNamesForAnyBehavior = tags.Where(t => t.Behavior == TagBehavior.RequireAny).SelectMany(t => t.TagNames).ToArray();

return (tagNamesForAllBehavior.Any() && tagsToMatch.All(t => tagNamesForAllBehavior.Any(t.Equals)))
|| (tagNamesForAnyBehavior.Any() && tagsToMatch.Any(t => tagNamesForAnyBehavior.Any(t.Equals)));
if (tagNamesForAnyBehavior.Any() && tagsToMatch.Any(t => tagNamesForAnyBehavior.Any(t.Equals)))
{
return true;
}

return false;
}

public static string GetAutoScriptUpName(Type type, string databaseType)
Expand Down

0 comments on commit cb9961b

Please sign in to comment.