@@ -745,35 +745,10 @@ pub trait FromLua: Sized {
745745 }
746746}
747747
748- // Per-thread size of the VecDeque pool for MultiValue container.
749- const MULTIVALUE_POOL_SIZE : usize = 32 ;
750-
751- thread_local ! {
752- static MULTIVALUE_POOL : RefCell <Vec <VecDeque <Value >>> = const { RefCell :: new( Vec :: new( ) ) } ;
753- }
754-
755748/// Multiple Lua values used for both argument passing and also for multiple return values.
756- #[ derive( Debug , Clone ) ]
749+ #[ derive( Default , Debug , Clone ) ]
757750pub struct MultiValue ( VecDeque < Value > ) ;
758751
759- impl Drop for MultiValue {
760- fn drop ( & mut self ) {
761- MULTIVALUE_POOL . with_borrow_mut ( |pool| {
762- if pool. len ( ) < MULTIVALUE_POOL_SIZE {
763- self . 0 . clear ( ) ;
764- pool. push ( mem:: take ( & mut self . 0 ) ) ;
765- }
766- } ) ;
767- }
768- }
769-
770- impl Default for MultiValue {
771- #[ inline]
772- fn default ( ) -> MultiValue {
773- MultiValue :: new ( )
774- }
775- }
776-
777752impl Deref for MultiValue {
778753 type Target = VecDeque < Value > ;
779754
@@ -793,24 +768,13 @@ impl DerefMut for MultiValue {
793768impl MultiValue {
794769 /// Creates an empty `MultiValue` containing no values.
795770 #[ inline]
796- pub fn new ( ) -> MultiValue {
797- Self :: with_capacity ( 0 )
771+ pub const fn new ( ) -> MultiValue {
772+ MultiValue ( VecDeque :: new ( ) )
798773 }
799774
800775 /// Creates an empty `MultiValue` container with space for at least `capacity` elements.
801776 pub fn with_capacity ( capacity : usize ) -> MultiValue {
802- let deque = MULTIVALUE_POOL . with_borrow_mut ( |pool| {
803- pool. pop ( ) . map_or_else (
804- || VecDeque :: with_capacity ( capacity) ,
805- |mut deque| {
806- if capacity > 0 {
807- deque. reserve ( capacity) ;
808- }
809- deque
810- } ,
811- )
812- } ) ;
813- MultiValue ( deque)
777+ MultiValue ( VecDeque :: with_capacity ( capacity) )
814778 }
815779
816780 #[ inline]
0 commit comments