@@ -85,8 +85,6 @@ pub struct EvalOutput {
8585 pub signature : Vec < ParameterInfo > ,
8686 /// Print output collected during evaluation
8787 pub print_output : Vec < String > ,
88- /// Resolution result from dependency resolution
89- pub resolution : Arc < ResolutionResult > ,
9088 /// Eval config (file provider, path specs, etc.)
9189 pub config : EvalContextConfig ,
9290 /// Session keeps the frozen heap alive for the lifetime of this output.
@@ -248,6 +246,19 @@ pub struct EvalContextConfig {
248246impl EvalContextConfig {
249247 /// Create a new root EvalContextConfig.
250248 pub fn new ( file_provider : Arc < dyn FileProvider > , resolution : ResolutionResult ) -> Self {
249+ use std:: sync:: OnceLock ;
250+ static BUILTIN_DOCS : OnceLock < Arc < HashMap < String , String > > > = OnceLock :: new ( ) ;
251+ let builtin_docs = BUILTIN_DOCS
252+ . get_or_init ( || {
253+ let globals = EvalContext :: build_globals ( ) ;
254+ let mut docs = HashMap :: new ( ) ;
255+ for ( name, item) in globals. documentation ( ) . members {
256+ docs. insert ( name. clone ( ) , item. render_as_code ( & name) ) ;
257+ }
258+ Arc :: new ( docs)
259+ } )
260+ . clone ( ) ;
261+
251262 // Canonicalize package_resolutions keys to match canonicalized file paths during lookup.
252263 let canon_resolutions = resolution
253264 . package_resolutions
@@ -264,7 +275,7 @@ impl EvalContextConfig {
264275 resolution. package_resolutions = canon_resolutions;
265276
266277 Self {
267- builtin_docs : Arc :: new ( Self :: build_builtin_docs ( ) ) ,
278+ builtin_docs,
268279 file_provider,
269280 resolution : Arc :: new ( resolution) ,
270281 path_to_spec : Arc :: new ( RwLock :: new ( HashMap :: new ( ) ) ) ,
@@ -278,16 +289,6 @@ impl EvalContextConfig {
278289 }
279290 }
280291
281- /// Build the builtin docs map from globals.
282- fn build_builtin_docs ( ) -> HashMap < String , String > {
283- let globals = EvalContext :: build_globals ( ) ;
284- let mut builtin_docs = HashMap :: new ( ) ;
285- for ( name, item) in globals. documentation ( ) . members {
286- builtin_docs. insert ( name. clone ( ) , item. render_as_code ( & name) ) ;
287- }
288- builtin_docs
289- }
290-
291292 /// Set the source path of the module we are evaluating.
292293 pub fn set_source_path ( mut self , path : PathBuf ) -> Self {
293294 self . source_path = Some ( path) ;
@@ -1320,7 +1321,6 @@ impl EvalContext {
13201321 sch_module : extra. module . clone ( ) ,
13211322 signature,
13221323 print_output,
1323- resolution : config_ref. resolution . clone ( ) ,
13241324 config : config_ref. clone ( ) ,
13251325 session : session_ref. clone ( ) ,
13261326 } ;
0 commit comments