From 4edd2bf78a92e4e3313f52d5870c9532ece4bd0b Mon Sep 17 00:00:00 2001 From: harupy Date: Sun, 15 Jan 2023 16:10:51 +0900 Subject: [PATCH] Remove commented-out code --- parser/python.lalrpop | 43 +++++-------------------------------------- 1 file changed, 5 insertions(+), 38 deletions(-) diff --git a/parser/python.lalrpop b/parser/python.lalrpop index 7007905..df5057c 100644 --- a/parser/python.lalrpop +++ b/parser/python.lalrpop @@ -1136,44 +1136,11 @@ Atom: ast::Expr = { }.into()) }, "{" "}" => { - let pairs = e.unwrap_or_default(); - - // let (keys, values) = match pairs.iter().position(|(k,_)| k.is_none()) { - // Some(unpack_idx) => { - // let mut pairs = pairs; - // let (keys, mut values): (_, Vec<_>) = pairs.drain(..unpack_idx).map(|(k, v)| (*k.unwrap(), v)).unzip(); - // - // fn build_map(items: &mut Vec<(ast::Expr, ast::Expr)>) -> ast::Expr { - // let location = items[0].0.location; - // let end_location = items[0].0.end_location; - // let (keys, values) = items.drain(..).unzip(); - // ast::Expr { - // location, - // end_location, - // custom: (), - // node: ast::ExprKind::Dict { keys, values } - // } - // } - // - // let mut items = Vec::new(); - // for (key, value) in pairs.into_iter() { - // if let Some(key) = key { - // items.push((*key, value)); - // continue; - // } - // if !items.is_empty() { - // values.push(build_map(&mut items)); - // } - // values.push(value); - // } - // if !items.is_empty() { - // values.push(build_map(&mut items)); - // } - // (keys, values) - // }, - // None => pairs.into_iter().map(|(k, v)| (k, v)).unzip() - // }; - let (keys, values) = pairs.into_iter().map(|(k, v)| (k.map(|x| *x), v)).unzip(); + let (keys, values) = e + .unwrap_or_default() + .into_iter() + .map(|(k, v)| (k.map(|x| *x), v)) + .unzip(); ast::Expr { location, end_location: Some(end_location),