mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-03 14:23:07 +00:00
Merge pull request #1307 from topos-protocol/fmt
Apply rustfmt with latest nightly
This commit is contained in:
commit
ed5ec3ca9c
@ -114,7 +114,8 @@ fn no_op_jumps(code: &mut Vec<Item>) {
|
||||
fn remove_swapped_pushes(code: &mut Vec<Item>) {
|
||||
replace_windows(code, |window| {
|
||||
if let [Push(x), Push(y), StandardOp(swap1)] = window
|
||||
&& &swap1 == "SWAP1" {
|
||||
&& &swap1 == "SWAP1"
|
||||
{
|
||||
Some(vec![Push(y), Push(x)])
|
||||
} else {
|
||||
None
|
||||
@ -125,7 +126,9 @@ fn remove_swapped_pushes(code: &mut Vec<Item>) {
|
||||
/// Remove SWAP1 before a commutative function.
|
||||
fn remove_swaps_commutative(code: &mut Vec<Item>) {
|
||||
replace_windows(code, |window| {
|
||||
if let [StandardOp(swap1), StandardOp(f)] = window && &swap1 == "SWAP1" {
|
||||
if let [StandardOp(swap1), StandardOp(f)] = window
|
||||
&& &swap1 == "SWAP1"
|
||||
{
|
||||
let commutative = matches!(f.as_str(), "ADD" | "MUL" | "AND" | "OR" | "XOR" | "EQ");
|
||||
commutative.then_some(vec![StandardOp(f)])
|
||||
} else {
|
||||
@ -138,7 +141,9 @@ fn remove_swaps_commutative(code: &mut Vec<Item>) {
|
||||
// Could be extended to other non-side-effecting operations, e.g. [DUP1, ADD, POP] -> [POP].
|
||||
fn remove_ignored_values(code: &mut Vec<Item>) {
|
||||
replace_windows(code, |[a, b]| {
|
||||
if let StandardOp(pop) = b && &pop == "POP" {
|
||||
if let StandardOp(pop) = b
|
||||
&& &pop == "POP"
|
||||
{
|
||||
match a {
|
||||
Push(_) => Some(vec![]),
|
||||
StandardOp(dup) if dup.starts_with("DUP") => Some(vec![]),
|
||||
|
||||
@ -135,7 +135,9 @@ fn shortest_path(
|
||||
|
||||
let cost = node.cost + op.cost();
|
||||
let entry = node_info.entry(neighbor.clone());
|
||||
if let Occupied(e) = &entry && e.get().0 <= cost {
|
||||
if let Occupied(e) = &entry
|
||||
&& e.get().0 <= cost
|
||||
{
|
||||
// We already found a better or equal path.
|
||||
continue;
|
||||
}
|
||||
@ -202,9 +204,11 @@ fn next_ops(
|
||||
dst: &[StackItem],
|
||||
unique_push_targets: &[PushTarget],
|
||||
) -> Vec<StackOp> {
|
||||
if let Some(top) = src.last() && !dst.contains(top) {
|
||||
if let Some(top) = src.last()
|
||||
&& !dst.contains(top)
|
||||
{
|
||||
// If the top of src doesn't appear in dst, don't bother with anything other than a POP.
|
||||
return vec![StackOp::Pop]
|
||||
return vec![StackOp::Pop];
|
||||
}
|
||||
|
||||
if is_permutation(src, dst) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user