1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 19:47:45 +00:00

tr: use BitvSet instead of HashSet

This commit is contained in:
Michael Gehring 2014-05-18 21:47:53 +02:00
parent 91b9b4b441
commit 1669c76442

View file

@ -12,7 +12,7 @@
extern crate collections; extern crate collections;
extern crate getopts; extern crate getopts;
use collections::hashmap::HashSet; use collections::bitv::BitvSet;
use collections::smallintmap::SmallIntMap; use collections::smallintmap::SmallIntMap;
use getopts::OptGroup; use getopts::OptGroup;
use std::char::from_u32; use std::char::from_u32;
@ -83,16 +83,16 @@ fn expand_set(s: &str) -> Vec<char> {
} }
fn delete(set: Vec<char>) { fn delete(set: Vec<char>) {
let mut hset = HashSet::new(); let mut bset = BitvSet::new();
let mut out = stdout(); let mut out = stdout();
for &c in set.iter() { for &c in set.iter() {
hset.insert(c); bset.insert(c as uint);
} }
for c in stdin().chars() { for c in stdin().chars() {
match c { match c {
Ok(c) if !hset.contains(&c) => out.write_char(c).unwrap(), Ok(c) if !bset.contains(&(c as uint)) => out.write_char(c).unwrap(),
Ok(_) => (), Ok(_) => (),
Err(err) => fail!("{}", err), Err(err) => fail!("{}", err),
}; };