@@ -2,6 +2,11 @@ use rustpython_bytecode::bytecode::{self, Instruction};
22
33use super :: { InstructionMetadata , OptimizationBuffer } ;
44
5+ macro_rules! metas {
6+ [ $( $metas: expr) ,* $( , ) ?] => {
7+ InstructionMetadata :: from( vec![ $( $metas) ,* ] )
8+ } ;
9+ }
510macro_rules! lc {
611 ( $name: ident { $( $field: tt) * } ) => {
712 Instruction :: LoadConst {
@@ -13,10 +18,10 @@ macro_rules! lc {
1318 } ;
1419}
1520macro_rules! emitconst {
16- ( $buf: expr, [ $( $metas: expr) ,* ] , $( $arg: tt) * ) => {
21+ ( $buf: expr, [ $( $metas: expr) ,* $ ( , ) ? ] , $( $arg: tt) * ) => {
1722 $buf. emit(
1823 lc!( $( $arg) * ) ,
19- InstructionMetadata :: from ( vec ![ $( $metas) ,* ] ) ,
24+ metas ![ $( $metas) ,* ] ,
2025 )
2126 } ;
2227}
@@ -91,20 +96,3 @@ pub fn unpack(buf: &mut impl OptimizationBuffer) {
9196 buf. emit ( instruction, meta)
9297 }
9398}
94-
95- pub fn useless_const ( buf : & mut impl OptimizationBuffer ) {
96- let ( instruction, meta) = buf. pop ( ) ;
97- if instruction == Instruction :: Pop {
98- let ( arg, arg_meta) = buf. pop ( ) ;
99- if let Instruction :: LoadConst { .. } = arg {
100- // just ignore it all
101- drop ( arg) ;
102- drop ( instruction) ;
103- } else {
104- buf. emit ( arg, arg_meta) ;
105- buf. emit ( instruction, meta) ;
106- }
107- } else {
108- buf. emit ( instruction, meta) ;
109- }
110- }
0 commit comments