mdzk-rs / mdzk

General-purpose interface to connected notes

Home Page:https://mdzk.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Further parallelization of `VaultBuilder::build` πŸš€πŸš€πŸš€

kmaasrud opened this issue Β· comments

Gotta go fast! Using something like Rayon, we should be able to parallelize the second notes pass:

mdzk/src/vault/builder.rs

Lines 168 to 191 in b056069

notes.iter_mut().try_for_each(|(_, note)| {
note.adjacencies = adjacencies.clone();
for_each_internal_link(&note.content.clone(), |link_string| {
match create_link(link_string, &path_lookup, &id_lookup) {
Ok(link) => {
note.adjacencies
.entry(link.dest_id)
.and_modify(|adj| *adj = Edge::Connected);
note.content = note.content.replacen(
&format!("[[{}]]", link_string),
&link.cmark(note.path.as_ref().unwrap().parent().unwrap()),
1,
);
}
// NOTE: This error is currently ignored, but could be useful as a toggleable
// error, since that would allow users of mdzk to ensure all links have a valid
// destination on vault creation.
Err(Error::InvalidInternalLinkDestination(_)) => {}
Err(e) => return Err(e),
}
Ok(())
})
})?;