| summaryrefslogtreecommitdiff |
diff options
| author | nsensfel <SpamShield0@noot-noot.org> | 2019-04-25 14:27:08 +0200 |
|---|---|---|
| committer | nsensfel <SpamShield0@noot-noot.org> | 2019-04-25 14:27:08 +0200 |
| commit | 3b2c01735adc75f6d778916f21ac9cf40c008df4 (patch) | |
| tree | 8c6824e7bf08e486eb8883adac77caeabb3d3fbd /src | |
| parent | 24359b5b84c756d94b6ce2f56b75709fa5d7ad1a (diff) | |
Adds a flatten optimization for sequences.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ataxic.erl | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/ataxic.erl b/src/ataxic.erl index 83e687d..92c11b1 100644 --- a/src/ataxic.erl +++ b/src/ataxic.erl @@ -247,6 +247,20 @@ optimize_update_field_sequence (UnsortedOPs, CurrentResults) -> (CurrentResults ++ MergedFieldUpdates ++ ImportantOPs) ). +-spec flatten_sequence (list(basic())) -> basic(). +flatten_sequence (OPs) -> + lists:foldl + ( + fun (E, CurrentOPs) -> + case is_record(E, seq) of + true -> (E#seq.ops ++ CurrentOPs); + _ -> [E|CurrentOPs] + end + end, + [], + OPs + ). + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -313,7 +327,9 @@ update_write_permission (OP) -> #write_perm{ op = OP }. update_value (OP) -> #value{ op = OP }. -spec optimize (basic()) -> basic(). -optimize (#seq{ ops = OPs }) -> optimize_update_field_sequence(OPs, []); +optimize (#seq{ ops = OPs }) -> + S0OPs = flatten_sequence(OPs), + optimize_update_field_sequence(S0OPs, []); optimize (OP) -> OP. %%%%% APPLY TO %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |


