Use ascii_case_insensitive_phf_map! in PropertyId::parse

This commit is contained in:
Simon Sapin 2017-02-25 19:00:29 +01:00
parent 33ef6f78e5
commit 2f996e34f5
7 changed files with 21 additions and 69 deletions

View file

@ -10,11 +10,8 @@ extern crate bindgen;
#[cfg(feature = "bindgen")]
extern crate regex;
extern crate walkdir;
extern crate phf_codegen;
use std::env;
use std::fs::File;
use std::io::{BufWriter, BufReader, BufRead, Write};
use std::path::Path;
use std::process::{Command, exit};
use walkdir::WalkDir;
@ -78,23 +75,6 @@ fn generate_properties() {
if !status.success() {
exit(1)
}
let path = Path::new(&env::var("OUT_DIR").unwrap()).join("static_ids.rs");
let static_ids = Path::new(&env::var("OUT_DIR").unwrap()).join("static_ids.txt");
let mut file = BufWriter::new(File::create(&path).unwrap());
let static_ids = BufReader::new(File::open(&static_ids).unwrap());
write!(&mut file, "static STATIC_IDS: ::phf::Map<&'static str, StaticId> = ").unwrap();
let mut map = phf_codegen::Map::new();
for result in static_ids.lines() {
let line = result.unwrap();
let mut split = line.split('\t');
let key = split.next().unwrap().to_owned();
let value = split.next().unwrap();
map.entry(key, value);
}
map.build(&mut file).unwrap();
write!(&mut file, ";\n").unwrap();
}
fn main() {