Commit graph

6 commits

Author SHA1 Message Date
Paul Stemmet da15105e1d lib: prune dead module reader
The code here was from earlier experiments and is not relevant or useful
anymore.
2021-09-07 18:32:26 +01:00
Paul Stemmet 7e567aa8a9 lib/queue: add Queue, a stable min binary heap
The structure will be how tokens are returned via the Scanner, over the
current Vec. This change is occurring because:

The genesis of this structure is a need in the Scanner for fast pops,
and fast inserts. A binary heap gives me both, namely O(1) inserts and
O(log(n)) pops -- with allocations amortized.

This is because of how YAML handles implicit keys... in that you don't
know whether you have one until you hit a value (': '). The easiest
solution is just to save these potential implicit keys and then insert
them into the token list at the correct position, but this would require
memcopy'ing everything >key.pos and potentially cause many more
reallocations than required.

Enter the Queue. I couldn't just use std::BinaryHeap for two reasons:

1. Its a max heap
2. Its not stable, the order of equal elements is unspecified

The Queue fixes both of these problems, first by innately using std::Reverse,
and second by guaranteeing that equal elements are returned in the order
added.

These two attributes allow me to use Scanner.stats.read (number of
bytes consumed so far) and a bit of elbow grease to get my tokens out in
the right order.
2021-08-01 08:12:47 +01:00
Paul Stemmet 0de27e1092 ci/clippy: fix error, allow styles
- On suspicious else, this is simply part of how I format this repo,
  so this style lint will be ignored
- On the manual range impl, inclusive ranges in Rust are slower than
  writing them out by hand by a significant amount
2021-06-23 21:51:33 +01:00
Paul Stemmet 7c8b0cdc43 lib/reader: first go at a reader impl
We need to track our column and mark how far through we've read at the
very least.
2021-06-03 17:52:32 +01:00
Paul Stemmet dee8a69b71
lib/mod: add scanner + token 2021-06-01 19:10:44 +00:00
Paul Stemmet 847cf54400
Genesis 2021-06-01 13:31:00 +00:00