X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;ds=sidebyside;f=helm%2Fsoftware%2Fcomponents%2Fng_kernel%2FnCicLibrary.ml;h=4e91334170555f6f5c75638e00ced633c4321e4a;hb=e085135177f7b3b74b410d47a4f3bca1784b60b1;hp=fa2816773cbc9d3107f62a789e2fcf9b07ee44e4;hpb=738ff6e752f9e5facba4e92bdb64453062f52c7d;p=helm.git diff --git a/helm/software/components/ng_kernel/nCicLibrary.ml b/helm/software/components/ng_kernel/nCicLibrary.ml index fa2816773..4e9133417 100644 --- a/helm/software/components/ng_kernel/nCicLibrary.ml +++ b/helm/software/components/ng_kernel/nCicLibrary.ml @@ -13,17 +13,28 @@ exception ObjectNotFound of string Lazy.t +let storage = ref [];; +let add_obj u obj = storage := (u,obj)::!storage;; + let cache = NUri.UriHash.create 313;; let get_obj u = + try List.assq u !storage + with Not_found -> try NUri.UriHash.find cache u with Not_found -> (* in the final implementation should get it from disk *) let ouri = NCic2OCic.ouri_of_nuri u in - let o,_ = CicEnvironment.get_obj CicUniv.oblivion_ugraph ouri in - let l = OCic2NCic.convert_obj ouri o in - List.iter (fun (u,_,_,_,_ as o) -> -(* prerr_endline ("+"^NUri.string_of_uri u); *) - NUri.UriHash.add cache u o) l; - HExtlib.list_last l + try + let o,_ = CicEnvironment.get_obj CicUniv.oblivion_ugraph ouri in + let l = OCic2NCic.convert_obj ouri o in + List.iter (fun (u,_,_,_,_ as o) -> + (* prerr_endline ("+"^NUri.string_of_uri u); *) + NUri.UriHash.add cache u o) l; + HExtlib.list_last l + with CicEnvironment.Object_not_found u -> + raise (ObjectNotFound + (lazy (NUri.string_of_uri (OCic2NCic.nuri_of_ouri u)))) ;; + +let clear_cache () = NUri.UriHash.clear cache;;