pub fn cached_parse(
path: &Path,
content: &str,
) -> (FileId, Result<(Arc<Vec<SourceUnit>>, Arc<Vec<CompileError>>), Arc<Vec<CompileError>>>)Expand description
The strict parse of path’s content — parser::parse_units_with_warnings_from,
cached by content equality and keyed on the durable FileId
file_id_for assigns path. On a cache hit, no new ExprIds are
consumed (the cached units already carry their own, fixed at whenever
they were last actually parsed); on a miss, [DECISION D]’s durable
counter advances by however many the fresh parse used.
The lock is held across the parse itself (not released and re-acquired
the way PROJECT_UNIT_CACHE did around its own parse) — [DECISION D]’s
counter must be threaded through the parse call, and releasing the lock
mid-parse would need a pre-reserved ExprId block of unknown size.
Serialises concurrent parses process-wide; each individual file’s parse
is fast enough (sub-millisecond, ordinarily) that this is a deliberate,
documented trade of a little concurrency for not having to invent a
block-reservation scheme — revisit only if profiling ever shows real
contention. See file_id_for’s own doc comment for why the lock’s
unwrap_or_else(PoisonError::into_inner) here is safe.