Verified Commit 8923e12b authored by Camil Staps's avatar Camil Staps 🚀

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

parent 6f4fe0c0
......@@ -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