-
Notifications
You must be signed in to change notification settings - Fork 116
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
Perf #3
Conversation
YingboMa
commented
Feb 12, 2020
•
edited
Loading
edited
src/util.jl
Outdated
end | ||
@inline cdr(v) = isempty(v) ? empty(l) : LL(v, 2) | ||
|
||
@inline take_n(ll::LL, n) = isempty(ll) || n == 0 ? empty(ll) : @view ll.v[ll.i:min(end, n+ll.i-1)] |
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 LL{<:AbstractVector}
? it can be anything.
src/util.jl
Outdated
@inline cdr(v) = isempty(v) ? empty(l) : LL(v, 2) | ||
|
||
@inline take_n(ll::LL, n) = isempty(ll) || n == 0 ? empty(ll) : @view ll.v[ll.i:min(end, n+ll.i-1)] | ||
@inline take_n(ll, n) = @view ll[1:min(end, n)] |
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.
This should probably fail if it can't take. The only place it is used shouldn't need it to fail silently.
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.
I think we actually need this.
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.
I'm saying @view ll[1:min(end, n)]
should be @view ll[1:n]
@@ -6,27 +6,27 @@ end | |||
islist(::Any) = false | |||
islist(l::Union{LL, Term, AbstractArray, Tuple}) = true | |||
|
|||
Base.empty(l::LL) = empty(l.v) |
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.
I didn't know about this function, so type stable, wow.
Oh, don't merge this. It is wrong. |
src/util.jl
Outdated
|
||
@inline drop_n(ll::Term, n) = drop_n(arguments(ll), n) | ||
@inline drop_n(ll::AbstractArray, n) = drop_n(LL(ll, 1), n) | ||
@inline drop_n(ll::LL, n) = LL(ll.v, max(1, ll.i-n)) |
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.
I think it needs to handle ll.i-n=0, otherwise segment recognition is wrong.
src/util.jl
Outdated
|
||
@inline drop_n(ll::Term, n) = drop_n(arguments(ll), n) |
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.
should be drop_n(arguments(ll), n-1)
f
is considered car
of a term
Co-authored-by: "Shashi Gowda" <[email protected]> Co-authored-by: "Yingbo Ma" <[email protected]>