Commit 191d15da authored by Andrei Paskevich's avatar Andrei Paskevich
Browse files

Termcode: do not reallocate buffers

parent dfd11796
...@@ -412,35 +412,39 @@ module Checksum = struct ...@@ -412,35 +412,39 @@ module Checksum = struct
char b 'C'; ident b th.Theory.th_name; list string b th.Theory.th_path char b 'C'; ident b th.Theory.th_name; list string b th.Theory.th_path
| Theory.Meta (m, mal) -> char b 'M'; meta b m; list meta_arg b mal | Theory.Meta (m, mal) -> char b 'M'; meta b m; list meta_arg b mal
let task_v1 t = let task_v1 =
let c = ref 0 in let c = ref 0 in
let m = ref Ident.Mid.empty in let m = ref Ident.Mid.empty in
let b = Buffer.create 8192 in let b = Buffer.create 8192 in
Task.task_iter (tdecl (CV1,c,m,b)) t; fun t ->
clear_ident_v1 (); Task.task_iter (tdecl (CV1,c,m,b)) t;
let s = Buffer.contents b in clear_ident_v1 ();
Digest.to_hex (Digest.string s) let dnew = Digest.string (Buffer.contents b) in
Buffer.clear b;
let task_v2 t (c,mold,rest) = Digest.to_hex dnew
let c = ref c in
let m = ref mold in let task_v2 =
let c = ref 0 in
let m = ref Ident.Mid.empty in
let b = Buffer.create 8192 in let b = Buffer.create 8192 in
tdecl (CV2,c,m,b) t.Task.task_decl; let task_hd t (cold,mold,dold) =
Buffer.add_string b (Digest.to_hex rest); c := cold;
let s = Buffer.contents b in m := mold;
Buffer.clear b; tdecl (CV2,c,m,b) t.Task.task_decl;
let mnew = match t.Task.task_decl.Theory.td_node with Buffer.add_string b (Digest.to_hex dold);
| Theory.Decl d -> let dnew = Digest.string (Buffer.contents b) in
let m = Ident.Mid.set_inter !m d.Decl.d_news in Buffer.clear b;
Ident.Mid.set_union mold m let mnew = match t.Task.task_decl.Theory.td_node with
| _ -> !m in | Theory.Decl d ->
(!c, mnew, Digest.string s) let m = Ident.Mid.set_inter !m d.Decl.d_news in
Ident.Mid.set_union mold m
let task_v2 = Trans.fold task_v2 (0, Ident.Mid.empty, Digest.string "") | _ -> !m in
!c, mnew, dnew
let task_v2 t = in
let _,_,s = Trans.apply task_v2 t in let tr = Trans.fold task_hd (0, Ident.Mid.empty, Digest.string "") in
Digest.to_hex s fun t ->
let _,_,dnew = Trans.apply tr t in
Digest.to_hex dnew
let task ~version t = match version with let task ~version t = match version with
| CV1 -> task_v1 t | CV1 -> task_v1 t
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment