-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
remove subtypes
search for concrete types
#19964
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
Conversation
This prevents an unnecessary/expensive call to `_subtypes` when `subtypes` is called on a concrete type.
@@ -301,7 +301,7 @@ function _subtypes(m::Module, x::DataType, sts=Set{DataType}(), visited=Set{Modu | |||
end | |||
return sts | |||
end | |||
subtypes(m::Module, x::DataType) = sort(collect(_subtypes(m, x)), by=string) | |||
subtypes(m::Module, x::DataType) = x.abstract ? sort(collect(_subtypes(m, x)), by=string) : DataType[] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can use the opportunity to also improve this by changing it to sort!(collect(...))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, good point
Bump, is there any chance this could go into 0.6? We kind of need it for our LanguageServer.jl project, which is the VS Code julia extension. @JeffBezanson, it looks like you might have to review this? |
Perhaps add a few tests for |
Do you mean a simple:
|
Yeah, just to hit that code path. |
Cool, done |
Can this be merged? |
I plan to merge this in a day or so unless I hear anything else. |
LGTM. This will conflict with #20307 but it should be easy to resolve. |
This prevents an unnecessary/expensive call to
_subtypes
whensubtypes
is called on a concrete type.