Skip to content

Cache RegEx in ValueMatchFilter - #4056

Merged
stevenaw merged 2 commits into
nunit:masterfrom
manfred-brands:4055-ValueFilter
Mar 16, 2022
Merged

stevenaw merged 2 commits into
nunit:masterfrom
manfred-brands:4055-ValueFilter

Conversation

@manfred-brands

Copy link
Copy Markdown
Member

Fixes #4055

Comment thread src/NUnitFramework/framework/Internal/Filters/IdFilter.cs

@stevenaw stevenaw left a comment

Copy link
Copy Markdown
Member

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!

case "filter":
case "and":
List<TestFilter> childFilters = new List<TestFilter>();
var childFilters = new List<TestFilter>(node.ChildNodes.Count);

Copy link
Copy Markdown
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
Copy Markdown
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.

Comment thread src/NUnitFramework/framework/Internal/TestFilter.cs
@manfred-brands

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member Author

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

@stevenaw

Copy link
Copy Markdown
Member

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

@rprouse rprouse left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@stevenaw

Copy link
Copy Markdown
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