Skip to content

Commit

Permalink
Remove strip_comments workaround from example
Browse files Browse the repository at this point in the history
  • Loading branch information
pitdicker committed Apr 15, 2024
1 parent 8bbd50b commit 0d8f279
Showing 1 changed file with 3 additions and 18 deletions.
21 changes: 3 additions & 18 deletions parse-zoneinfo/examples/benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,13 @@ extern crate parse_zoneinfo;
use parse_zoneinfo::line::{Line, LineParser};
use parse_zoneinfo::table::TableBuilder;

// This function is needed until parse-zoneinfo handles comments correctly.
// Technically a '#' symbol could occur between double quotes and should be
// ignored in this case, however this never happens in the tz database as it
// stands.
fn strip_comments(mut line: String) -> String {
if let Some(pos) = line.find('#') {
line.truncate(pos)
}
line
}

fn main() {
let lines = std::fs::read_to_string("examples/asia")
.unwrap()
.lines()
.map(|line| strip_comments(line.to_string()))
.collect::<Vec<_>>();
let asia = std::fs::read_to_string("examples/asia").unwrap();

for _ in 0..100 {
let parser = LineParser::new();
let parser = LineParser::default();
let mut builder = TableBuilder::new();
for line in &lines {
for line in asia.lines() {
match parser.parse_str(line).unwrap() {
Line::Zone(zone) => builder.add_zone_line(zone).unwrap(),
Line::Continuation(cont) => builder.add_continuation_line(cont).unwrap(),
Expand Down

0 comments on commit 0d8f279

Please sign in to comment.