File tree Expand file tree Collapse file tree 2 files changed +14
-13
lines changed
Expand file tree Collapse file tree 2 files changed +14
-13
lines changed Original file line number Diff line number Diff line change @@ -1992,18 +1992,18 @@ impl Compiler {
19921992 values : & [ ast:: Expr ] ,
19931993 ) -> CompileResult < ( ) > {
19941994 let mut size = 0 ;
1995-
1996- let ( packed_values , unpacked_values ) = values . split_at ( keys . len ( ) ) ;
1997- for ( key , value ) in keys . iter ( ) . zip ( packed_values ) {
1998- if let Some ( key ) = key {
1999- self . compile_expression ( key ) ? ;
2000- }
1995+ let ( packed , unpacked ) : ( Vec < _ > , Vec < _ > ) = keys
1996+ . iter ( )
1997+ . zip ( values . iter ( ) )
1998+ . partition ( | ( k , _ ) | k . is_some ( ) ) ;
1999+ for ( key , value ) in packed {
2000+ self . compile_expression ( & key . as_ref ( ) . unwrap ( ) ) ? ;
20012001 self . compile_expression ( value) ?;
20022002 size += 1 ;
20032003 }
20042004 emit ! ( self , Instruction :: BuildMap { size } ) ;
20052005
2006- for value in unpacked_values {
2006+ for ( _ , value) in unpacked {
20072007 self . compile_expression ( value) ?;
20082008 emit ! ( self , Instruction :: DictUpdate ) ;
20092009 }
Original file line number Diff line number Diff line change @@ -885,14 +885,15 @@ impl SymbolTableBuilder {
885885 self . scan_expression ( value, ExpressionContext :: Load ) ?;
886886 }
887887 Dict { keys, values } => {
888- let ( packed, unpacked) = values. split_at ( keys. len ( ) ) ;
889- for ( key, value) in keys. iter ( ) . zip ( packed) {
890- if let Some ( key) = key {
891- self . scan_expression ( key, context) ?;
892- }
888+ let ( packed, unpacked) : ( Vec < _ > , Vec < _ > ) = keys
889+ . iter ( )
890+ . zip ( values. iter ( ) )
891+ . partition ( |( key, _) | key. is_some ( ) ) ;
892+ for ( key, value) in packed {
893+ self . scan_expression ( & key. as_ref ( ) . unwrap ( ) , context) ?;
893894 self . scan_expression ( value, context) ?;
894895 }
895- for value in unpacked {
896+ for ( _ , value) in unpacked {
896897 // dict unpacking marker
897898 self . scan_expression ( value, context) ?;
898899 }
You can’t perform that action at this time.
0 commit comments