mlange-42 / yarner

Literate Programming command line tool for Markdown
https://mlange-42.github.io/yarner
MIT License
32 stars 1 forks source link

[Design] Zero-copy document model #96

Open adamreichold opened 3 years ago

adamreichold commented 3 years ago

The current document model around the Node type contains a large number of separately allocated String instances which however are often (or possibly even always?) substrings into the text of the source file. Hence, it would be much more efficient to store string slices &'a str within the document that borrow from the source file which is read into memory via fs::read_to_string anyway. (Of course, this implies that the source file contents must outlive the parsed document.)

mlange-42 commented 3 years ago

This is how it was originally implemented in outline. However, with my still limited Rust experience I was facing a lot of problems when starting to implement to multi-file features (IIRC), so I switched to copying. But we may give it a try.