Handbook
Glossary
fold-only-branch ( #branch -- node/nodes )
Vocabulary
compiler
.
tree
.
cleanup
Inputs
#branch
a
#branch
Outputs
node/nodes
a
node
or a sequence of nodes
Word description
If only one branch is live we don't need to branch at all; just drop the condition value.
Definition
USING:
accessors
combinators
compiler.tree
compiler.tree.propagation.branches
kernel
sequences
;
IN:
compiler.tree.cleanup
:
fold-only-branch
( #branch -- node/nodes )
dup
live-children
sift
dup
length
{
{
0
[
drop
in-d>>
<#drop>
]
}
{
1
[
first
swap
in-d>>
<#drop>
prefix
]
}
[
2drop
]
}
case
;