! Copyright (C) 2005, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
-IN: growable
-MIXIN: growable ! for bootstrap
-USING: accessors kernel layouts math math.private sequences
+USING: accessors kernel math math.private sequences
sequences.private ;
+IN: growable
+
+MIXIN: growable
SLOT: length
SLOT: underlying
] if
length<< ;
-: new-size ( old -- new )
- integer>fixnum-strict 1 fixnum+fast 2 fixnum*fast
- dup 0 < [ drop most-positive-fixnum ] when ; inline
+: new-size ( old -- new ) 1 + 2 * ; inline
: ensure ( n seq -- n seq )
bounds-check-head
: most-negative-fixnum ( -- n )
first-bignum neg >fixnum ; inline
-ALIAS: max-array-capacity most-positive-fixnum
+: (max-array-capacity) ( b -- n )
+ 2 - 2^ 1 - ; inline
+
+: max-array-capacity ( -- n )
+ fixnum-bits (max-array-capacity) ; inline
: bootstrap-first-bignum ( -- n )
bootstrap-cell-bits (first-bignum) ;
: bootstrap-most-negative-fixnum ( -- n )
bootstrap-first-bignum neg ;
-ALIAS: bootstrap-max-array-capacity bootstrap-most-positive-fixnum
+: bootstrap-max-array-capacity ( -- n )
+ bootstrap-fixnum-bits (max-array-capacity) ;
M: bignum >integer
dup most-negative-fixnum most-positive-fixnum between?