Skip to content

Cache RegEx in ValueMatchFilter #4056

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 16, 2022
Merged

Conversation

manfred-brands
Copy link
Member

Fixes #4055

Copy link
Member

@stevenaw stevenaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nicely done, thanks @manfred-brands !
Very minor nitpick suggestion related to pre-initializing the and/or filters, but it's also fine to merge as-is too. Thanks!

@@ -156,15 +156,15 @@ public static TestFilter FromXml(TNode node)
{
case "filter":
case "and":
List<TestFilter> childFilters = new List<TestFilter>();
var childFilters = new List<TestFilter>(node.ChildNodes.Count);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice touch to pre-initialize this. Thanks!

nitpick: Since we have to convert it to an array a few lines below, would it make sense to make this an array here instead of a list to save an array copy operation? Similar suggest for the "or" below.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with your nitpick, I should have looked how the list was used after.
Changed code to create array, extracted to a function so I only needed one copy.

@manfred-brands
Copy link
Member Author

@stevenaw Can you look at TestFilter.TopLevel property. I can't find any real usages.
There is code commented out in NotFilter and a test that checks the "TopLevel" property.
Can all of that be deleted as part of this PR?

@stevenaw
Copy link
Member

@stevenaw Can you look at TestFilter.TopLevel property. I can't find any real usages. There is code commented out in NotFilter and a test that checks the "TopLevel" property. Can all of that be deleted as part of this PR?

Thanks for noticing this 😊 I agree, it looks unused and appears to have been that way since a beta of nunit 3. That predates my involvement in the project, however, so I'd appreciate a second opinion. @CharliePoole any concerns with removing the code?

@CharliePoole
Copy link
Member

@stevenaw The commenting out was part of a fairly large change I made back in 2015. The idea was that we were going to re-visit the question of how we wanted top-level selected tests (those actually selected by the user) and ExplicitAttribute to interact. I don't think we ever resolved it and, of course, I eventually left the project so was no longer pushing to resolve it.

My 2 cents: If you find that Explicit is now working the way you want it to work (and/or as it's documented to work) I'd remove the property and all the commented out code that references it, possibly in a separate PR (but that's up to you guys).

@manfred-brands
Copy link
Member Author

@stevenaw I will create a new issue and PR once this one is in to remove the TopLevel property.

@stevenaw
Copy link
Member

Sounds good, thanks @CharliePoole and @manfred-brands 👍

Copy link
Member

@rprouse rprouse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stevenaw
Copy link
Member

LGTM. Thanks @manfred-brands !

@stevenaw stevenaw merged commit f3bd46c into nunit:master Mar 16, 2022
@manfred-brands manfred-brands deleted the 4055-ValueFilter branch June 11, 2022 01:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use static Regex.IsMatch in ValueMatchFilter to take advantage of caching
4 participants