ui.gadgets: faster max-dims and sum-dims.

db4
John Benediktsson 2012-07-31 20:23:32 -07:00
parent 74cdcba2cd
commit c36adbd749
1 changed files with 4 additions and 2 deletions

View File

@ -87,9 +87,11 @@ M: gadget contains-point? ( loc gadget -- ? )
[ contains-point? ] with find-last nip
[ [ loc>> v- ] [ pick-up ] bi ] [ nip ] ?if ;
: max-dims ( dims -- dim ) { 0 0 } [ vmax ] reduce ;
: max-dims ( seq -- dim )
[ 0 0 ] dip [ first2 swapd [ max ] 2bi@ ] each 2array ;
: sum-dims ( seq -- dim ) { 0 0 } [ v+ ] reduce ;
: sum-dims ( seq -- dim )
[ 0 0 ] dip [ first2 swapd [ + ] 2bi@ ] each 2array ;
: each-child ( gadget quot -- )
[ children>> ] dip each ; inline