PR#4079: Queue.copy is now tail-recursive (patch from "Cristophe" on the bugtracker)

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@13784 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
master
Gabriel Scherer 2013-06-16 16:19:30 +00:00
parent b23b2e0bde
commit 54a131a262
2 changed files with 8 additions and 6 deletions

View File

@ -56,6 +56,7 @@ Runtime system:
Bug fixes:
- PR#3679: Warning display problems
- PR#3963: Graphics.wait_next_event in Win32 hangs if window closed
- PR#4079: Queue.copy is now tail-recursive
- PR#4762: ?? is not used at all, but registered as a lexer token
- PR#4887: input_char after close_in crashes ocaml (msvc runtime)
- PR#4994: ocaml-mode doesn't work with xemacs21

View File

@ -107,14 +107,15 @@ let copy q =
next = tail'
} in
let rec copy cell =
if cell == tail then tail'
else {
let rec copy prev cell =
if cell != tail
then let res = {
content = cell.content;
next = copy cell.next
} in
next = tail'
} in prev.next <- res;
copy res cell.next in
tail'.next <- copy tail.next;
copy tail' tail.next;
{
length = q.length;
tail = tail'