Skip to content

Commit ad8a61a

Browse files
committed
Merge branch 'master' into stable
2 parents f24d983 + d6f7f15 commit ad8a61a

30 files changed

+388
-82
lines changed

.merlin

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ PKG threads
1818
PKG threads.posix
1919
PKG lwt
2020
PKG qcheck
21-
FLG -w +a -w -4 -w -44
21+
FLG -w +a-4-44-48-60

.ocp-indent

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
match_clause=2
2+
with=2

AUTHORS.adoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@
2121
- Glenn Slotte (glennsl)
2222
- @LemonBoy
2323
- Leonid Rozenberg (@rleonid)
24-
- Bikal Gurung (@bikalgurung)
24+
- Bikal Gurung (@bikalgurung)
25+
- Fabian Hemmer (copy)

CHANGELOG.adoc

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,25 @@
11
= Changelog
22

3+
== 1.4
4+
5+
- add `CCMap.union`
6+
- add `CCRef.swap`
7+
- add `CCArray.swap`
8+
- change signature of `CCWBTree.get_rank`
9+
- add `CCWBTree.get_rank{,_exn}`
10+
11+
- more efficient `List.map` Using efficient chunking algorithm
12+
- Fix `CCVector.append_array` (empty vector case)
13+
- `CCFQueue.take_back_exn` raised InvalidArg instead of Empty on an empty queue
14+
- faster `CCString.{prefix,suffix}`
15+
- speed improvements and benchmarks for `CCString.{prefix,suffix}`
16+
17+
- add ocp-indent file
18+
- fix `CCFun.tap` example in doc
19+
- specify behavior of `CCFQueue.take_{front,back}_l` in some corner cases
20+
- More tests for CCVector.append and CCVector.append_array
21+
- assertions and cleanup in `CCPool`
22+
323
== 1.3
424

525
- deprecate `CCBool.negate`

HOWTO.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ can be removed.
1010
. `make update_next_tag` (to update `@since` comments; be careful not to change symlinks)
1111
. check status of modules (`{b status: foo}`) and update if required;
1212
removed deprecated functions, etc.
13-
. update `CHANGELOG.md` (see its end to find the right git command)
13+
. update `CHANGELOG.adoc` (see its end to find the right git command)
1414
. commit the changes
1515
. `git checkout stable`
1616
. `git merge master`

README.adoc

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,8 @@ and <<tutorial,the tutorial below>> for a gentle introduction.
9696
In general, see http://c-cube.github.io/ocaml-containers/last/ or
9797
http://cedeela.fr/~simon/software/containers for the **API documentation**.
9898

99-
Some examples can be found link:doc/containers.adoc[there].
100-
101-
API documentation by version:
102-
103-
- http://c-cube.github.io/ocaml-containers/dev/[dev branch]
104-
- http://c-cube.github.io/ocaml-containers/1.0/[1.0]
105-
- http://c-cube.github.io/ocaml-containers/0.19/[0.19]
106-
- http://c-cube.github.io/ocaml-containers/0.17/[0.17]
99+
Some examples can be found link:doc/containers.adoc[there],
100+
per-version doc http://c-cube.github.io/ocaml-containers/[there].
107101

108102
[[build]]
109103
== Build

_oasis

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
OASISFormat: 0.4
22
Name: containers
3-
Version: 1.3
3+
Version: 1.4
44
Homepage: https://github.com/c-cube/ocaml-containers
55
Authors: Simon Cruanes
66
License: BSD-2-clause

benchs/run_benchs.ml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,6 +1177,99 @@ module Str = struct
11771177
let bench_find = bench_find_ ~dir:`Direct
11781178
let bench_rfind = bench_find_ ~dir:`Reverse
11791179

1180+
module Pre = struct
1181+
let prefix_rec ~pre s =
1182+
let rec same s1 s2 i =
1183+
if i = String.length s1 then true
1184+
else (
1185+
String.unsafe_get s1 i = String.unsafe_get s2 i && same s1 s2 (i+1)
1186+
)
1187+
in
1188+
String.length pre <= String.length s &&
1189+
same pre s 0
1190+
1191+
let prefix_while ~pre s =
1192+
String.length pre <= String.length s &&
1193+
begin
1194+
let i = ref 0 in
1195+
while !i < String.length pre &&
1196+
String.unsafe_get s !i = String.unsafe_get pre !i
1197+
do incr i done;
1198+
!i = String.length pre
1199+
end
1200+
1201+
exception Exit_false
1202+
1203+
let prefix_for_exn ~pre s =
1204+
String.length pre <= String.length s &&
1205+
try
1206+
for i=0 to String.length pre-1 do
1207+
if String.unsafe_get s i != String.unsafe_get pre i
1208+
then raise Exit_false
1209+
done;
1210+
true
1211+
with Exit_false -> false
1212+
1213+
let prefix_sub ~pre:prfx s =
1214+
let len_s = String.length s in
1215+
let len_p = String.length prfx in
1216+
if len_s < len_p then
1217+
false
1218+
else
1219+
let sub = String.sub s 0 len_p in
1220+
CCString.equal prfx sub
1221+
1222+
let bat_prefix ~pre:p str =
1223+
let len = String.length p in
1224+
if String.length str < len then false
1225+
else
1226+
let rec loop str p i =
1227+
if i = len then true
1228+
else if String.unsafe_get str i <> String.unsafe_get p i then false
1229+
else loop str p (i + 1)
1230+
in loop str p 0
1231+
1232+
let make ~max_len ~max_len_prefix n =
1233+
let rand = Random.State.make_self_init () in
1234+
let input =
1235+
Array.init n
1236+
(fun _ ->
1237+
let str =
1238+
QCheck.Gen.(string_size ~gen:printable (10 -- max_len))
1239+
|> QCheck.Gen.generate1 ~rand
1240+
in
1241+
let prfx_len = Random.State.int rand (min max_len_prefix (String.length str + 1)) in
1242+
let prfx =
1243+
if Random.State.bool rand then
1244+
String.sub str 0 prfx_len
1245+
else
1246+
String.sub str (String.length str - prfx_len) prfx_len
1247+
in
1248+
(prfx, str))
1249+
in
1250+
let output =
1251+
Array.map
1252+
(fun (pre, str) -> prefix_rec ~pre str)
1253+
input
1254+
in
1255+
let test f () =
1256+
Array.iteri
1257+
(fun i (pre, y) ->
1258+
let res = f ~pre y in
1259+
assert (res = output.(i)))
1260+
input
1261+
in
1262+
Benchmark.throughputN 3
1263+
[
1264+
"containers", test CCString.prefix, ();
1265+
"while_unsafe", test prefix_while, ();
1266+
"rec_unsafe", test prefix_rec, ();
1267+
"for_exn_unsafe", test prefix_for_exn, ();
1268+
"sub_eq", test prefix_sub, ();
1269+
"bat_prefix", test bat_prefix, ();
1270+
]
1271+
end
1272+
11801273
let () = B.Tree.register (
11811274
"string" @>>>
11821275
[ "find" @>>>
@@ -1205,6 +1298,11 @@ module Str = struct
12051298
; "50" @>> app_ints (bench_rfind ~size:50) [100; 100_000; 500_000]
12061299
; "500" @>> app_ints (bench_rfind ~size:500) [100_000; 500_000]
12071300
];
1301+
"prefix" @>>>
1302+
[ "max_len:1000,max_pre_len:15" @>> app_ints (Pre.make ~max_len:1000 ~max_len_prefix:15) [100; 1_000];
1303+
"max_len:1000,max_pre_len:100" @>> app_ints (Pre.make ~max_len:1000 ~max_len_prefix:100) [100; 1_000];
1304+
"max_len:1000,max_pre_len:300" @>> app_ints (Pre.make ~max_len:1000 ~max_len_prefix:300) [100; 1_000];
1305+
]
12081306
])
12091307

12101308
end

doc/intro.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ CCFlatHashtbl
8282
CCGraph
8383
CCHashSet
8484
CCHashTrie
85+
CCHet
8586
CCImmutArray
8687
CCIntMap
8788
CCMixmap

opam

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
opam-version: "1.2"
22
name: "containers"
3-
version: "1.2"
3+
version: "1.4"
44
author: "Simon Cruanes"
55
maintainer: "[email protected]"
66
build: [

0 commit comments

Comments
 (0)