|
| 1 | +@inline function _ancestors_values_no_filter_ignore!(node, key::Symbol, val, recursivity_level, ignore_nothing::Bool) |
| 2 | + current = node |
| 3 | + remaining = recursivity_level |
| 4 | + |
| 5 | + while !isroot(current) && remaining != 0 |
| 6 | + parent_ = parent(current) |
| 7 | + v = unsafe_getindex(parent_, key) |
| 8 | + ignore_nothing && v === nothing || push!(val, v) |
| 9 | + remaining -= 1 |
| 10 | + current = parent_ |
| 11 | + end |
| 12 | + return val |
| 13 | +end |
| 14 | + |
| 15 | +@inline function _ancestors_values_no_filter_collect(node, key::Symbol, recursivity_level, ignore_nothing::Bool) |
| 16 | + vals = Any[] |
| 17 | + current = node |
| 18 | + remaining = recursivity_level |
| 19 | + |
| 20 | + while !isroot(current) && remaining != 0 |
| 21 | + parent_ = parent(current) |
| 22 | + v = unsafe_getindex(parent_, key) |
| 23 | + ignore_nothing && v === nothing || push!(vals, v) |
| 24 | + remaining -= 1 |
| 25 | + current = parent_ |
| 26 | + end |
| 27 | + return vals |
| 28 | +end |
| 29 | + |
| 30 | +@inline function _typed_from_any(vals::Vector{Any}, fallback_type=Any) |
| 31 | + if isempty(vals) |
| 32 | + return Array{fallback_type,1}() |
| 33 | + end |
| 34 | + T = typeof(vals[1]) |
| 35 | + @inbounds for i in 2:length(vals) |
| 36 | + T = Union{T,typeof(vals[i])} |
| 37 | + end |
| 38 | + out = Vector{T}(undef, length(vals)) |
| 39 | + @inbounds for i in eachindex(vals) |
| 40 | + out[i] = vals[i] |
| 41 | + end |
| 42 | + return out |
| 43 | +end |
| 44 | + |
| 45 | + |
1 | 46 | """ |
2 | 47 | ancestors(node::Node,key,<keyword arguments>) |
3 | 48 | ancestors(node::Node,<keyword arguments>) |
@@ -49,50 +94,6 @@ ancestors(leaf_node, :Length, symbol = :Internode) |
49 | 94 | ancestors(leaf_node, :Length, symbol = (:Axis,:Internode)) |
50 | 95 | ``` |
51 | 96 | """ |
52 | | -@inline function _ancestors_values_no_filter_ignore!(node, key::Symbol, val, recursivity_level, ignore_nothing::Bool) |
53 | | - current = node |
54 | | - remaining = recursivity_level |
55 | | - |
56 | | - while !isroot(current) && remaining != 0 |
57 | | - parent_ = parent(current) |
58 | | - v = unsafe_getindex(parent_, key) |
59 | | - ignore_nothing && v === nothing || push!(val, v) |
60 | | - remaining -= 1 |
61 | | - current = parent_ |
62 | | - end |
63 | | - return val |
64 | | -end |
65 | | - |
66 | | -@inline function _ancestors_values_no_filter_collect(node, key::Symbol, recursivity_level, ignore_nothing::Bool) |
67 | | - vals = Any[] |
68 | | - current = node |
69 | | - remaining = recursivity_level |
70 | | - |
71 | | - while !isroot(current) && remaining != 0 |
72 | | - parent_ = parent(current) |
73 | | - v = unsafe_getindex(parent_, key) |
74 | | - ignore_nothing && v === nothing || push!(vals, v) |
75 | | - remaining -= 1 |
76 | | - current = parent_ |
77 | | - end |
78 | | - return vals |
79 | | -end |
80 | | - |
81 | | -@inline function _typed_from_any(vals::Vector{Any}, fallback_type=Any) |
82 | | - if isempty(vals) |
83 | | - return Array{fallback_type,1}() |
84 | | - end |
85 | | - T = typeof(vals[1]) |
86 | | - @inbounds for i in 2:length(vals) |
87 | | - T = Union{T,typeof(vals[i])} |
88 | | - end |
89 | | - out = Vector{T}(undef, length(vals)) |
90 | | - @inbounds for i in eachindex(vals) |
91 | | - out[i] = vals[i] |
92 | | - end |
93 | | - return out |
94 | | -end |
95 | | - |
96 | 97 | function ancestors( |
97 | 98 | node, key; |
98 | 99 | scale=nothing, |
|
0 commit comments