this loop is too slow - but may be useful for future reference
This commit is contained in:
parent
915e956821
commit
da0bc62102
|
@ -17,7 +17,7 @@ a large VCD file from
|
||||||
|
|
||||||
The first build of the program may take some time.
|
The first build of the program may take some time.
|
||||||
|
|
||||||
``cargo run --release -- path/to/vcd/file``
|
``cargo run --release test-vcd-files/aldec/SPI_Write.vcd``
|
||||||
|
|
||||||
## TODO
|
## TODO
|
||||||
- [ ] We need a way to merge lines.
|
- [ ] We need a way to merge lines.
|
||||||
|
|
42
src/main.rs
42
src/main.rs
|
@ -18,6 +18,19 @@ struct Timestamp{
|
||||||
timestamp: BigInt
|
timestamp: BigInt
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct Cursor{
|
||||||
|
line: u64,
|
||||||
|
col : u64
|
||||||
|
}
|
||||||
|
|
||||||
|
enum Tokens {
|
||||||
|
Date,
|
||||||
|
End,
|
||||||
|
String,
|
||||||
|
Version,
|
||||||
|
Time,
|
||||||
|
}
|
||||||
|
|
||||||
struct Signal {
|
struct Signal {
|
||||||
name : String,
|
name : String,
|
||||||
timeline : BTreeMap<BigInt, BigInt>,
|
timeline : BTreeMap<BigInt, BigInt>,
|
||||||
|
@ -35,12 +48,33 @@ fn main() -> std::io::Result<()> {
|
||||||
let mut buffer = Vec::<u8>::new();
|
let mut buffer = Vec::<u8>::new();
|
||||||
let mut word_count = 0u64;
|
let mut word_count = 0u64;
|
||||||
|
|
||||||
while {
|
// while {
|
||||||
let bytes_read = reader.read_until(space, &mut buffer).unwrap();
|
// let bytes_read = reader.read_until(b' ', &mut buffer).unwrap();
|
||||||
bytes_read > 0
|
// bytes_read > 0
|
||||||
} {
|
// } {
|
||||||
|
// word_count += 1;
|
||||||
|
|
||||||
|
// if word_count < 5 {
|
||||||
|
// let string = std::str::from_utf8(&buffer).unwrap();
|
||||||
|
// dbg!(string);
|
||||||
|
// }
|
||||||
|
// buffer.clear();
|
||||||
|
// }
|
||||||
|
loop {
|
||||||
|
buffer.clear();
|
||||||
|
let t = reader
|
||||||
|
.by_ref()
|
||||||
|
.bytes()
|
||||||
|
.map(|c| c.unwrap())
|
||||||
|
.take_while(|c|
|
||||||
|
c != &b' ' &&
|
||||||
|
c != &b'\n');
|
||||||
|
buffer.extend(t);
|
||||||
word_count += 1;
|
word_count += 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
let string = std::str::from_utf8(&buffer).unwrap();
|
||||||
|
dbg!(string);
|
||||||
dbg!(word_count);
|
dbg!(word_count);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
Loading…
Reference in a new issue