fn reduce_identity_writes<R: StateReader<Key, Value>>(
        mut ops: HashMap<Key, Op>,
        mut transforms: HashMap<Key, Transform>,
        reader: &R,
        correlation_id: CorrelationId,
    ) -> ExecutionEffect {
        let kvs: Vec<(Key, Value)> = transforms
            .keys()
            .filter_map(|k| match transforms.get(k) {
                Some(Transform::Write(_)) => reader
                    .read(correlation_id, k)
                    .ok()
                    .and_then(|maybe_v| maybe_v.map(|v| (*k, v.clone()))),
                _ => None,
            })
            .collect();

        for (k, old_value) in kvs {
            if let Some(Transform::Write(new_value)) = transforms.remove(&k) {
                if new_value == old_value {
                    transforms.insert(k, Transform::Identity);
                    ops.insert(k, Op::Read);
                } else {
                    transforms.insert(k, Transform::Write(new_value));
                }
            }
        }

        ExecutionEffect::new(ops, transforms)
    }
/// In the case we are writing the same value as was there originally,
/// it is equivalent to having a `Transform::Identity` and `Op::Read`.
/// This function makes that reduction before returning the `ExecutionEffect`.
In the case we are writing the same value as was there originally,
it is equivalent to having a `Transform::Identity` and `Op::Read`.
This function makes that reduction before returning the `ExecutionEffect`.
In the case we are writing the same value as was there originally it is equivalent to having a ` Transform :: Identity ` and ` Op :: Read ` . This function makes that reduction before returning the ` ExecutionEffect ` .
fn reduce_identity_writes<R: StateReader<Key, Value>>(
        mut ops: HashMap<Key, Op>,
        mut transforms: HashMap<Key, Transform>,
        reader: &R,
        correlation_id: CorrelationId,
    ) -> ExecutionEffect {
        let kvs: Vec<(Key, Value)> = transforms
            .keys()
            .filter_map(|k| match transforms.get(k) {
                Some(Transform::Write(_)) => reader
                    .read(correlation_id, k)
                    .ok()
                    .and_then(|maybe_v| maybe_v.map(|v| (*k, v.clone()))),
                _ => None,
            })
            .collect();
        for (k, old_value) in kvs {
            if let Some(Transform::Write(new_value)) = transforms.remove(&k) {
                if new_value == old_value {
                    transforms.insert(k, Transform::Identity);
                    ops.insert(k, Op::Read);
                } else {
                    transforms.insert(k, Transform::Write(new_value));
                }
            }
        }
        ExecutionEffect::new(ops, transforms)
    }
fn reduce_identity_writes < R : StateReader < Key , Value > > ( mut ops : HashMap < Key , Op > , mut transforms : HashMap < Key , Transform > , reader : & R , correlation_id : CorrelationId , ) -> ExecutionEffect { let kvs : Vec < ( Key , Value ) > = transforms . keys ( ) . filter_map ( | k | match transforms . get ( k ) { Some ( Transform :: Write ( _ ) ) => reader . read ( correlation_id , k ) . ok ( ) . and_then ( | maybe_v | maybe_v . map ( | v | ( * k , v . clone ( ) ) ) ) , _ => None , } ) . collect ( ) ; for ( k , old_value ) in kvs { if let Some ( Transform :: Write ( new_value ) ) = transforms . remove ( & k ) { if new_value == old_value { transforms . insert ( k , Transform :: Identity ) ; ops . insert ( k , Op :: Read ) ; } else { transforms . insert ( k , Transform :: Write ( new_value ) ) ; } } } ExecutionEffect :: new ( ops , transforms ) }
In the case we are writing the same value as was there originally,
it is equivalent to having a `Transform::Identity` and `Op::Read`.
In the case we are writing the same value as was there originally it is equivalent to having a ` Transform :: Identity ` and ` Op :: Read ` .
ops
HashMap<Key, Op>
transforms
HashMap<Key, Transform>
reader
&R
correlation_id
CorrelationId
ops
HashMap<Key, Op>
transforms
HashMap<Key, Transform>
reader
&R
correlation_id
CorrelationId