From 2f4793a55058c94eaddc3f4514d9c9cc1475722f Mon Sep 17 00:00:00 2001 From: Rudy Ges Date: Thu, 9 May 2024 10:24:41 +0200 Subject: [PATCH] [hxb] rename read_all to minimal_restore and invert logic --- src/compiler/hxb/hxbReader.ml | 12 ++++++------ src/compiler/server.ml | 4 ++-- src/context/display/displayJson.ml | 14 +++++++------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/compiler/hxb/hxbReader.ml b/src/compiler/hxb/hxbReader.ml index 8d860df9015..3d7b6a096e7 100644 --- a/src/compiler/hxb/hxbReader.ml +++ b/src/compiler/hxb/hxbReader.ml @@ -152,7 +152,7 @@ class hxb_reader (timers_enabled : bool) = object(self) val mutable api = Obj.magic "" - val mutable read_all = true + val mutable minimal_restore = false val mutable current_module = null_module val mutable ch = BytesWithPosition.create (Bytes.create 0) @@ -1944,7 +1944,7 @@ class hxb_reader current_module.m_types <- self#read_mtf; api#add_module current_module; | IMP -> - if read_all then self#read_imports; + if not minimal_restore then self#read_imports; | CLR -> self#read_clr; | ENR -> @@ -2012,11 +2012,11 @@ class hxb_reader close() method read_chunks (new_api : hxb_reader_api) (chunks : cached_chunks) = - fst (self#read_chunks_until new_api chunks EOM true) + fst (self#read_chunks_until new_api chunks EOM false) - method read_chunks_until (new_api : hxb_reader_api) (chunks : cached_chunks) end_chunk full_read = + method read_chunks_until (new_api : hxb_reader_api) (chunks : cached_chunks) end_chunk minimal_restore' = api <- new_api; - read_all <- full_read; + minimal_restore <- minimal_restore'; let rec loop = function | (kind,data) :: chunks -> ch <- BytesWithPosition.create data; @@ -2029,7 +2029,7 @@ class hxb_reader method read (new_api : hxb_reader_api) (bytes : bytes) = api <- new_api; - read_all <- true; + minimal_restore <- false; ch <- BytesWithPosition.create bytes; if (Bytes.to_string (read_bytes ch 3)) <> "hxb" then raise (HxbFailure "magic"); diff --git a/src/compiler/server.ml b/src/compiler/server.ml index fd191bde7b4..02e00cf770f 100644 --- a/src/compiler/server.ml +++ b/src/compiler/server.ml @@ -427,7 +427,7 @@ class hxb_reader_api_server let full_restore = com.is_macro_context || com.display.dms_full_typing || is_display_file in let f_next chunks until = let t_hxb = Timer.timer ["server";"module cache";"hxb read"] in - let r = reader#read_chunks_until (self :> HxbReaderApi.hxb_reader_api) chunks until full_restore in + let r = reader#read_chunks_until (self :> HxbReaderApi.hxb_reader_api) chunks until (not full_restore) in t_hxb(); r in @@ -591,7 +591,7 @@ and type_module sctx com delay mpath p = in let f_next chunks until = let t_hxb = Timer.timer ["server";"module cache";"hxb read"] in - let r = reader#read_chunks_until api chunks until full_restore in + let r = reader#read_chunks_until api chunks until (not full_restore) in t_hxb(); r in diff --git a/src/context/display/displayJson.ml b/src/context/display/displayJson.ml index 15f7339c893..fd18866c1d9 100644 --- a/src/context/display/displayJson.ml +++ b/src/context/display/displayJson.ml @@ -105,7 +105,7 @@ class display_handler (jsonrpc : jsonrpc_handler) com (cs : CompilationCache.t) end class hxb_reader_api_com - ~(headers_only : bool) + ~(minimal_restore : bool) (com : Common.context) (cc : CompilationCache.context_cache) = object(self) @@ -140,7 +140,7 @@ class hxb_reader_api_com with Not_found -> let mc = cc#get_hxb_module m_path in let reader = new HxbReader.hxb_reader mc.mc_path com.hxb_reader_stats (Some cc#get_string_pool_arr) (Common.defined com Define.HxbTimes) in - fst (reader#read_chunks_until (self :> HxbReaderApi.hxb_reader_api) mc.mc_chunks (if headers_only then MTF else EOM) (not headers_only)) + fst (reader#read_chunks_until (self :> HxbReaderApi.hxb_reader_api) mc.mc_chunks (if minimal_restore then MTF else EOM) minimal_restore) method basic_types = com.basic @@ -152,8 +152,8 @@ class hxb_reader_api_com false end -let find_module ~(headers_only : bool) com cc path = - (new hxb_reader_api_com ~headers_only com cc)#find_module path +let find_module ~(minimal_restore : bool) com cc path = + (new hxb_reader_api_com ~minimal_restore com cc)#find_module path type handler_context = { com : Common.context; @@ -352,11 +352,11 @@ let handler = let cs = hctx.display#get_cs in let cc = cs#get_context sign in let m = try - find_module ~headers_only:true hctx.com cc path + find_module ~minimal_restore:true hctx.com cc path with Not_found -> hctx.send_error [jstring "No such module"] in - hctx.send_result (generate_module (cc#get_hxb) (find_module ~headers_only:true hctx.com cc) m) + hctx.send_result (generate_module (cc#get_hxb) (find_module ~minimal_restore:true hctx.com cc) m) ); "server/type", (fun hctx -> let sign = Digest.from_hex (hctx.jsonrpc#get_string_param "signature") in @@ -364,7 +364,7 @@ let handler = let typeName = hctx.jsonrpc#get_string_param "typeName" in let cc = hctx.display#get_cs#get_context sign in let m = try - find_module ~headers_only:true hctx.com cc path + find_module ~minimal_restore:true hctx.com cc path with Not_found -> hctx.send_error [jstring "No such module"] in