From d0d2ae91119dfaf68917061dea5080fcffabf339 Mon Sep 17 00:00:00 2001 From: malc Date: Sun, 24 Aug 2014 08:32:44 +0400 Subject: [PATCH] Simplify --- config.ml | 15 ++++++++++++++- main.ml | 22 +--------------------- 2 files changed, 15 insertions(+), 22 deletions(-) diff --git a/config.ml b/config.ml index d324088..2a9efb2 100644 --- a/config.ml +++ b/config.ml @@ -1500,8 +1500,21 @@ let load1 f = f (Hashtbl.create 0, defconf) ;; -let load () = +let load openlast = let f (h, dc) = + if openlast + then ( + let path, _ = + Hashtbl.fold + (fun path (conf, _, _, _) ((_, besttime) as best) -> + if conf.lastvisit > besttime + then (path, conf.lastvisit) + else best) + h + (state.path, -.infinity) + in + state.path <- path; + ); let pc, pb, px, pa = try let path = diff --git a/main.ml b/main.ml index a4599d5..e17cec7 100644 --- a/main.ml +++ b/main.ml @@ -6197,33 +6197,13 @@ let () = let histmode = emptystr state.path && not !openlast in - if not (Config.load ()) + if not (Config.load !openlast) then prerr_endline "failed to load configuration"; begin match !pageno with | Some pageno -> state.anchor <- (pageno, 0.0, 0.0) | None -> () end; - if !openlast - then ( - let list = ref [] in - if Config.gethist list - then ( - match !list with - | hd :: tl -> - let f ((_, c1, _, _, _) as h1) ((_, c2, _, _, _) as h2)= - if c1.lastvisit > c2.lastvisit - then h1 else h2 - in - let p1, _, _, _, _ = List.fold_left f hd tl in - state.path <- p1; - if not (Config.load ()) - then prerr_endline "failed to load last configuration" - | [] -> error "no idea what was last" - ) - else error "no idea what was last" - ); - if not (emptystr !gcconfig) then ( let c, s = -- 2.11.4.GIT