mirror of
https://github.com/Myriad-Dreamin/tinymist.git
synced 2025-08-03 17:58:17 +00:00
feat: remove do_reparse
flag (#1185)
This commit is contained in:
parent
1779209337
commit
a5cf15a701
3 changed files with 6 additions and 32 deletions
|
@ -144,9 +144,6 @@ pub trait WorldDeps {
|
|||
fn iter_dependencies(&self, f: &mut dyn FnMut(ImmutPath));
|
||||
}
|
||||
|
||||
type CodespanResult<T> = Result<T, CodespanError>;
|
||||
type CodespanError = codespan_reporting::files::Error;
|
||||
|
||||
/// type trait interface of [`CompilerWorld`].
|
||||
pub trait CompilerFeat {
|
||||
/// Specify the font resolver for typst compiler.
|
||||
|
|
|
@ -105,9 +105,6 @@ pub struct SourceDb {
|
|||
pub shared: Arc<RwLock<SharedState<SourceCache>>>,
|
||||
/// The slots for all the files during a single lifecycle.
|
||||
pub slots: Arc<Mutex<FxHashMap<TypstFileId, SourceCache>>>,
|
||||
/// Whether to reparse the file when it is changed.
|
||||
/// Default to `true`.
|
||||
pub do_reparse: bool,
|
||||
}
|
||||
|
||||
impl fmt::Debug for SourceDb {
|
||||
|
@ -124,16 +121,6 @@ impl SourceDb {
|
|||
}
|
||||
}
|
||||
|
||||
/// Set the `do_reparse` flag that indicates whether to reparsing the file
|
||||
/// instead of creating a new [`Source`] when the file is changed.
|
||||
/// Default to `true`.
|
||||
///
|
||||
/// You usually want to set this flag to `true` for better performance.
|
||||
/// However, one could disable this flag for debugging purpose.
|
||||
pub fn set_do_reparse(&mut self, do_reparse: bool) {
|
||||
self.do_reparse = do_reparse;
|
||||
}
|
||||
|
||||
/// Returns the overall memory usage for the stored files.
|
||||
pub fn memory_usage(&self) -> usize {
|
||||
let mut w = self.slots.lock().len() * core::mem::size_of::<SourceCache>();
|
||||
|
@ -192,7 +179,7 @@ impl SourceDb {
|
|||
|
||||
// otherwise reparse the source
|
||||
match prev {
|
||||
Some(mut source) if self.do_reparse => {
|
||||
Some(mut source) => {
|
||||
source.replace(&next);
|
||||
Ok(source)
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ use typst::{
|
|||
Library, World,
|
||||
};
|
||||
|
||||
use crate::source::{SharedState, SourceCache, SourceDb};
|
||||
use crate::{
|
||||
entry::{EntryManager, EntryReader, EntryState, DETACHED_ENTRY},
|
||||
font::FontResolver,
|
||||
|
@ -27,10 +28,12 @@ use crate::{
|
|||
get_semantic_tokens_full, get_semantic_tokens_legend, OffsetEncoding, SemanticToken,
|
||||
SemanticTokensLegend,
|
||||
},
|
||||
source::{SharedState, SourceCache, SourceDb},
|
||||
CodespanError, CodespanResult, CompilerFeat, ShadowApi, WorldDeps,
|
||||
CompilerFeat, ShadowApi, WorldDeps,
|
||||
};
|
||||
|
||||
type CodespanResult<T> = Result<T, CodespanError>;
|
||||
type CodespanError = codespan_reporting::files::Error;
|
||||
|
||||
pub struct Revising<'a, T> {
|
||||
pub revision: NonZeroUsize,
|
||||
pub inner: &'a mut T,
|
||||
|
@ -75,11 +78,6 @@ impl<F: CompilerFeat> Revising<'_, CompilerUniverse<F>> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Set the `do_reparse` flag.
|
||||
pub fn set_do_reparse(&mut self, do_reparse: bool) {
|
||||
self.inner.do_reparse = do_reparse;
|
||||
}
|
||||
|
||||
/// Set the inputs for the compiler.
|
||||
pub fn set_inputs(&mut self, inputs: Arc<LazyHash<Dict>>) {
|
||||
self.inner.inputs = inputs;
|
||||
|
@ -105,8 +103,6 @@ pub struct CompilerUniverse<F: CompilerFeat> {
|
|||
entry: EntryState,
|
||||
/// Additional input arguments to compile the entry file.
|
||||
inputs: Arc<LazyHash<Dict>>,
|
||||
/// Whether to reparse the source files.
|
||||
do_reparse: bool,
|
||||
|
||||
/// Provides font management for typst compiler.
|
||||
pub font_resolver: Arc<F::FontResolver>,
|
||||
|
@ -139,7 +135,6 @@ impl<F: CompilerFeat> CompilerUniverse<F> {
|
|||
Self {
|
||||
entry,
|
||||
inputs: inputs.unwrap_or_default(),
|
||||
do_reparse: true,
|
||||
|
||||
revision: RwLock::new(NonZeroUsize::new(1).expect("initial revision is 1")),
|
||||
shared: Arc::new(RwLock::new(SharedState::default())),
|
||||
|
@ -156,10 +151,6 @@ impl<F: CompilerFeat> CompilerUniverse<F> {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn do_reparse(&self) -> bool {
|
||||
self.do_reparse
|
||||
}
|
||||
|
||||
pub fn inputs(&self) -> Arc<LazyHash<Dict>> {
|
||||
self.inputs.clone()
|
||||
}
|
||||
|
@ -180,7 +171,6 @@ impl<F: CompilerFeat> CompilerUniverse<F> {
|
|||
vfs: self.vfs.snapshot(),
|
||||
source_db: SourceDb {
|
||||
revision: *rev_lock,
|
||||
do_reparse: self.do_reparse,
|
||||
shared: self.shared.clone(),
|
||||
slots: Default::default(),
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue