From bf5886b790f8f386ed425f543506a4bebb48448c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20H=C3=B6gberg?= Date: Mon, 15 Oct 2018 18:17:12 +0200 Subject: Optimize operator '--' and yield on large inputs The removal set now uses a red-black tree instead of an array on large inputs, decreasing runtime complexity from `n*n` to `n*log(n)`. It will also exit early when there are no more items left in the removal set, drastically improving performance and memory use when the items to be removed are present near the head of the list. This got a lot more complicated than before as the overhead of always using a red-black tree was unacceptable when either of the inputs were small, but this compromise has okay-to-decent performance regardless of input size. Co-authored-by: Dmytro Lytovchenko --- lib/stdlib/doc/src/lists.xml | 8 -------- 1 file changed, 8 deletions(-) (limited to 'lib/stdlib/doc') diff --git a/lib/stdlib/doc/src/lists.xml b/lib/stdlib/doc/src/lists.xml index 7efafedc82..55227aaee5 100644 --- a/lib/stdlib/doc/src/lists.xml +++ b/lib/stdlib/doc/src/lists.xml @@ -838,14 +838,6 @@ splitwith(Pred, List) -> > lists:subtract("123212", "212"). "312".

lists:subtract(A, B) is equivalent to A -- B.

- -

The complexity of lists:subtract(A, B) is proportional to - length(A)*length(B), meaning that it is very slow if both - A and B are long lists. (If both lists are long, it - is a much better choice to use ordered lists and - - ordsets:subtract/2.

-
-- cgit v1.2.3 From f5313be396144700acff451279062dab9674e436 Mon Sep 17 00:00:00 2001 From: Erlang/OTP Date: Mon, 5 Nov 2018 10:48:29 +0100 Subject: Prepare release --- lib/stdlib/doc/src/notes.xml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'lib/stdlib/doc') diff --git a/lib/stdlib/doc/src/notes.xml b/lib/stdlib/doc/src/notes.xml index e26c4aba74..3c7c8bf400 100644 --- a/lib/stdlib/doc/src/notes.xml +++ b/lib/stdlib/doc/src/notes.xml @@ -31,6 +31,21 @@

This document describes the changes made to the STDLIB application.

+
STDLIB 3.4.5.1 + +
Improvements and New Features + + +

List subtraction (The -- operator) will now + yield properly on large inputs.

+

+ Own Id: OTP-15371

+
+
+
+ +
+
STDLIB 3.4.5
Fixed Bugs and Malfunctions -- cgit v1.2.3