@@ -67,40 +67,16 @@ impl Constant for PyConstant {
6767 borrow_obj_constant ( & self . 0 )
6868 }
6969 fn map_constant < Bag : ConstantBag > ( self , bag : & Bag ) -> Bag :: Constant {
70- bag. make_constant_borrowed ( self . borrow_constant ( ) )
70+ bag. make_constant ( self . borrow_constant ( ) )
7171 }
7272}
7373
7474pub ( crate ) struct PyObjBag < ' a > ( pub & ' a Context ) ;
7575
7676impl ConstantBag for PyObjBag < ' _ > {
7777 type Constant = PyConstant ;
78- fn make_constant ( & self , constant : bytecode:: ConstantData ) -> Self :: Constant {
79- let ctx = self . 0 ;
80- let obj = match constant {
81- bytecode:: ConstantData :: Integer { value } => ctx. new_int ( value) . into ( ) ,
82- bytecode:: ConstantData :: Float { value } => ctx. new_float ( value) . into ( ) ,
83- bytecode:: ConstantData :: Complex { value } => ctx. new_complex ( value) . into ( ) ,
84- bytecode:: ConstantData :: Str { value } if value. len ( ) <= 20 => {
85- ctx. intern_string ( value) . into_pyref ( ) . into ( )
86- }
87- bytecode:: ConstantData :: Str { value } => ctx. new_str ( value) . into ( ) ,
88- bytecode:: ConstantData :: Bytes { value } => ctx. new_bytes ( value. to_vec ( ) ) . into ( ) ,
89- bytecode:: ConstantData :: Boolean { value } => ctx. new_bool ( value) . into ( ) ,
90- bytecode:: ConstantData :: Code { code } => ctx. new_code ( code. map_bag ( self ) ) . into ( ) ,
91- bytecode:: ConstantData :: Tuple { elements } => {
92- let elements = elements
93- . into_iter ( )
94- . map ( |constant| self . make_constant ( constant) . 0 )
95- . collect ( ) ;
96- ctx. new_tuple ( elements) . into ( )
97- }
98- bytecode:: ConstantData :: None => ctx. none ( ) ,
99- bytecode:: ConstantData :: Ellipsis => ctx. ellipsis ( ) ,
100- } ;
101- PyConstant ( obj)
102- }
103- fn make_constant_borrowed < C : Constant > ( & self , constant : BorrowedConstant < C > ) -> Self :: Constant {
78+
79+ fn make_constant < C : Constant > ( & self , constant : BorrowedConstant < C > ) -> Self :: Constant {
10480 let ctx = self . 0 ;
10581 let obj = match constant {
10682 bytecode:: BorrowedConstant :: Integer { value } => ctx. new_bigint ( value) . into ( ) ,
@@ -118,7 +94,7 @@ impl ConstantBag for PyObjBag<'_> {
11894 bytecode:: BorrowedConstant :: Tuple { elements } => {
11995 let elements = elements
12096 . into_iter ( )
121- . map ( |constant| self . make_constant_borrowed ( constant) . 0 )
97+ . map ( |constant| self . make_constant ( constant) . 0 )
12298 . collect ( ) ;
12399 ctx. new_tuple ( elements) . into ( )
124100 }
0 commit comments