3 ms·
Basically what you can do is, e.g. Reading in a file. Now you have a string containing all your file. When you then write a parser you can write it so that it
by carlmr 8y ago
Basically what you can do is, e.g. Reading in a file. Now you have a string containing all your file.
When you then write a parser you can write it so that it uses string slices pointing into your file buffer whenever it references any text from your file, instead of creating new strings.
As long as you don't need to modify anything you don't need to create any copies and the borrow checking compiler will ensure that you don't invalidate any part of your buffer.
For a lot of parsers string allocation is a big part of runtime performance.