diff options
| author | Nick Barnes <nick@tarides.com> | 2023-01-27 08:57:45 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-01-27 09:57:45 +0100 |
| commit | eb251c9f7f2e5ff1ff53ff1f5e8232e976295bca (patch) | |
| tree | febed1f42a20db72acfa5ef944544192dc0ddc60 /stdlib | |
| parent | ada2ba81fd9bb39a764dc31cddc11fb024ea8ad3 (diff) | |
| download | ocaml-eb251c9f7f2e5ff1ff53ff1f5e8232e976295bca.tar.gz | |
Multicore cleanup: remove traces of Obj.truncate (#11967)
Diffstat (limited to 'stdlib')
| -rw-r--r-- | stdlib/list.ml | 37 |
1 files changed, 5 insertions, 32 deletions
diff --git a/stdlib/list.ml b/stdlib/list.ml index 55e0b9e6aa..0e83bb42e4 100644 --- a/stdlib/list.ml +++ b/stdlib/list.ml @@ -408,38 +408,11 @@ let stable_sort cmp l = let sort = stable_sort let fast_sort = stable_sort -(* Note: on a list of length between about 100000 (depending on the minor - heap size and the type of the list) and Sys.max_array_size, it is - actually faster to use the following, but it might also use more memory - because the argument list cannot be deallocated incrementally. - - Also, there seems to be a bug in this code or in the - implementation of obj_truncate. - -external obj_truncate : 'a array -> int -> unit = "caml_obj_truncate" - -let array_to_list_in_place a = - let l = Array.length a in - let rec loop accu n p = - if p <= 0 then accu else begin - if p = n then begin - obj_truncate a p; - loop (a.(p-1) :: accu) (n-1000) (p-1) - end else begin - loop (a.(p-1) :: accu) n (p-1) - end - end - in - loop [] (l-1000) l - - -let stable_sort cmp l = - let a = Array.of_list l in - Array.stable_sort cmp a; - array_to_list_in_place a - -*) - +(* Note: on a very long list (length over about 100000), it used to be + faster to convert the list to an array, sort the array, and convert + back, truncating the array object after prepending each thousand + entries to the resulting list. Impossible now that Obj.truncate has + been removed. *) (** sorting + removing duplicates *) |
