d1ac752de6
This is a big commit, but it breaks into two conceptual pieces. The first is to "parse without copying". We replace a stream of an owned collection of edn::ValueAndSpan and instead have a stream of a borrowed collection of &edn::ValueAndSpan references. (Generally, this is represented as an iterator over a slice, but it can be over other things too.) Cloning such iterators is constant time, which improves on cloning an owned collection of edn::ValueAndSpan, which is linear time in the length of the collection and additional time depending on the complexity of the EDN values. The second conceptual piece is to parse keyword maps using a special parser and a macro to build the parser implementations. Before, we created a new edn::ValueAndSpan::Map to represent a keyword map in vector form; since we're working with &edn::ValueAndSpan references now, we can't create an &edn::ValueAndSpan reference with an appropriate lifetime. Therefore we generalize the concept of iteration slightly and turn keyword maps in map form into linear iterators by flattening the value maps. This is a potentially obscuring transformation, so we have to take care to protect against some failure cases. (See the comments and the tests in the code.) After these changes, parsing using `combine` is linear time (and reasonably fast). |
||
---|---|---|
.. | ||
benches | ||
src | ||
tests | ||
Cargo.toml |