Commit 11c0ebc7 authored by John van Groningen's avatar John van Groningen

Merge branch 'optimise-sort' into 'master'

Optimize memory behaviour of sort and sortBy (create less temporary Cons nodes)

See merge request clean-compiler-and-rts/stdenv!4
parents 6f4fe0c0 8923e12b
......@@ -19,7 +19,7 @@ where
= [[x1,x2]:pair xs];
pair x = [x];
msort [x1,x2:xs] = msort (merge_stage [x1,x2:xs]);
msort xs=:[_,_:_] = msort (merge_stage xs);
msort x = x;
merge_stage [xs1,xs2:xxs] = [merge xs1 xs2 : merge_stage xxs];
......@@ -34,7 +34,7 @@ where
= [[x1,x2]:pair xs];
pair x = [x];
msort [x1,x2:xs] = msort (merge_stage [x1,x2:xs]);
msort xs=:[_,_:_] = msort (merge_stage xs);
msort x = x;
merge_stage [xs1,xs2:xxs] = [mergeBy less_f xs1 xs2 : merge_stage xxs];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment