[Pkg-ocaml-maint-commits] [cudf] 01/03: Imported Upstream version 0.8
Stefano Zacchiroli
zack at upsilon.cc
Mon Mar 30 17:57:46 UTC 2015
This is an automated email from the git hooks/post-receive script.
zack pushed a commit to branch master
in repository cudf.
commit 6289681d8a273d1c477d7814ac707af2e648fa8b
Author: Stefano Zacchiroli <zack at upsilon.cc>
Date: Mon Mar 30 19:44:16 2015 +0200
Imported Upstream version 0.8
---
ChangeLog | 8 ++++++++
Makefile | 1 +
Makefile.config | 2 +-
cudf.ml | 15 ++++++++-------
cudf.mli | 5 +++++
cudf_parser.ml | 17 ++++++++++++++---
6 files changed, 37 insertions(+), 11 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index d01e8a1..31c5d3a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2015-03-31 Stefano Zacchiroli <zack at upsilon.cc>
+ * ALL release 0.8
+ * Cudf: performance improvement by allocating larger hashtbl
+ * Cudf: expose empty_universe
+ (Thanks to Pietro Abate for the above 2 patches)
+ * Makefile: inhibit parallel build (thanks to Roberto Di Cosmo)
+ * Cudf_parser: prevent in_channel leaks when using from_file
+
2014-04-29 Stefano Zacchiroli <zack at upsilon.cc>
* ALL release 0.7
* Cudf_checker: do not report as multi-upgrade error a package
diff --git a/Makefile b/Makefile
index b03c6c8..f503631 100644
--- a/Makefile
+++ b/Makefile
@@ -130,3 +130,4 @@ world: all opt c-lib c-lib-opt doc
.PHONY: all opt world clean top-level headers test tags install uninstall
.PHONY: dep rpm c-lib c-lib-opt dist doc
+.NOTPARALLEL:
diff --git a/Makefile.config b/Makefile.config
index 7c4b9ed..6f69c17 100644
--- a/Makefile.config
+++ b/Makefile.config
@@ -1,4 +1,4 @@
-VERSION = 0.7
+VERSION = 0.8
export DESTDIR =
diff --git a/cudf.ml b/cudf.ml
index 3ab7cdd..d82359d 100644
--- a/cudf.ml
+++ b/cudf.ml
@@ -106,12 +106,12 @@ let default_request = {
req_extra = [] ;
}
-let empty_universe () =
- { id2pkg = Hashtbl.create 1023 ;
- uid2pkgs = Hashtbl.create 1023;
- id2uid = Hashtbl.create 1023;
- name2pkgs = Hashtbl.create 1023 ;
- features = Hashtbl.create 1023 ;
+let empty_universe ?(size=1023) () =
+ { id2pkg = Hashtbl.create size ;
+ uid2pkgs = Hashtbl.create size;
+ id2uid = Hashtbl.create size;
+ name2pkgs = Hashtbl.create size;
+ features = Hashtbl.create size;
univ_size = 0 ; inst_size = 0 ;
}
@@ -184,7 +184,8 @@ let remove_package univ id =
end
let load_universe pkgs =
- let univ = empty_universe () in
+ let size = List.length pkgs in
+ let univ = empty_universe ~size () in
let uid = ref 0 in
List.iter
(fun pkg ->
diff --git a/cudf.mli b/cudf.mli
index 9bddf66..93fee10 100644
--- a/cudf.mli
+++ b/cudf.mli
@@ -98,6 +98,11 @@ type cudf = preamble * universe * request
status *)
type solution = preamble * universe
+(** return an empty universe.
+
+ @param size represents the initial size of the universe (default: 1023) *)
+val empty_universe : ?size:int -> unit -> universe
+
(** @raise Constraint_violation when a global CUDF constraint is violated in
the given package list *)
val load_universe : package list -> universe
diff --git a/cudf_parser.ml b/cudf_parser.ml
index 48d7ecd..5b4e966 100644
--- a/cudf_parser.ml
+++ b/cudf_parser.ml
@@ -1,6 +1,6 @@
(*****************************************************************************)
(* libCUDF - CUDF (Common Upgrade Description Format) manipulation library *)
-(* Copyright (C) 2009-2012 Stefano Zacchiroli <zack at upsilon.cc> *)
+(* Copyright (C) 2009-2015 Stefano Zacchiroli <zack at upsilon.cc> *)
(* *)
(* This library is free software: you can redistribute it and/or modify *)
(* it under the terms of the GNU Lesser General Public License as *)
@@ -20,6 +20,10 @@ type cudf_parser = {
lexbuf: Lexing.lexbuf ;
fname: string ;
mutable typedecl: Cudf_conf.stanza_typedecl ;
+ priv_in_chan: in_channel option;
+ (* in_channel to be closed upon close() invocation, to avoid leaving up to
+ OCaml GC when to close it. Will be set only if it is Cudf_parser itself
+ who has created the in_channel, e.g., upon Cudf_parser.from_file *)
}
type loc_map = (string * loc) list
@@ -31,6 +35,7 @@ let from_in_channel ?(typedecl=Cudf_conf.stanza_typedecl) ic =
{ lexbuf = Lexing.from_channel ic ;
typedecl = typedecl ;
fname = "" ;
+ priv_in_chan = None ;
}
let from_IO_in_channel ?(typedecl=Cudf_conf.stanza_typedecl) ic =
@@ -38,18 +43,24 @@ let from_IO_in_channel ?(typedecl=Cudf_conf.stanza_typedecl) ic =
{ lexbuf = Lexing.from_function f;
typedecl = typedecl ;
fname = "" ;
+ priv_in_chan = None ;
}
let from_file ?(typedecl=Cudf_conf.stanza_typedecl) fname =
(* Syntax error with OCaml 3.10.2:
* { from_in_channel ?typedecl (open_in fname)
* with fname = fname } *)
- { lexbuf = Lexing.from_channel (open_in fname) ;
+ let ic = open_in fname in
+ { lexbuf = Lexing.from_channel ic ;
typedecl = typedecl ;
fname = fname ;
+ priv_in_chan = Some ic ;
}
-let close p = ()
+let close p =
+ match p.priv_in_chan with
+ | None -> ()
+ | Some ic -> close_in ic
let parse_stanza p =
try
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ocaml-maint/packages/cudf.git
More information about the Pkg-ocaml-maint-commits
mailing list