From 89ace470dcc0d4e08c1fd530e938893f87dcd436 Mon Sep 17 00:00:00 2001 From: "Bruce A. MacNaughton" Date: Tue, 19 Jul 2022 18:03:18 -0700 Subject: [PATCH] formatted --- .../src/cascading_map.rs | 51 +++++++------------ src/tools/unicode-table-generator/src/main.rs | 2 +- .../src/raw_emitter.rs | 1 - 3 files changed, 20 insertions(+), 34 deletions(-) diff --git a/src/tools/unicode-table-generator/src/cascading_map.rs b/src/tools/unicode-table-generator/src/cascading_map.rs index 780d32e969c6..d4efdef2e806 100644 --- a/src/tools/unicode-table-generator/src/cascading_map.rs +++ b/src/tools/unicode-table-generator/src/cascading_map.rs @@ -4,32 +4,24 @@ use std::collections::HashMap; use std::fmt::Write as _; use std::ops::Range; - impl RawEmitter { pub fn emit_cascading_map(&mut self, ranges: &[Range]) -> bool { - let mut map: [u8; 256] = [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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>(); + let points = ranges + .iter() + .flat_map(|r| (r.start..r.end).into_iter().collect::>()) + .collect::>(); println!("there are {} points", points.len()); @@ -46,7 +38,8 @@ impl RawEmitter { let mut bit_for_high_byte = 1u8; let mut arms = Vec::::new(); - let mut high_bytes: Vec = codepoints_by_high_bytes.keys().map(|k| k.clone()).collect(); + let mut high_bytes: Vec = + codepoints_by_high_bytes.keys().map(|k| k.clone()).collect(); high_bytes.sort(); for high_byte in high_bytes { let codepoints = codepoints_by_high_bytes.get_mut(&high_byte).unwrap(); @@ -61,21 +54,15 @@ impl RawEmitter { } arms.push(format!( "{} => WHITESPACE_MAP[c as usize & 0xff] & {} != 0", - high_byte, - bit_for_high_byte) - ); + high_byte, bit_for_high_byte + )); bit_for_high_byte <<= 1; } - writeln!( - &mut self.file, - "static WHITESPACE_MAP: [u8; 256] = [{}];", - fmt_list(map.iter()) - ) - .unwrap(); + writeln!(&mut self.file, "static WHITESPACE_MAP: [u8; 256] = [{}];", fmt_list(map.iter())) + .unwrap(); self.bytes_used += 256; - writeln!(&mut self.file, "pub fn lookup(c: char) -> bool {{").unwrap(); writeln!(&mut self.file, " match c as u32 >> 8 {{").unwrap(); for arm in arms { diff --git a/src/tools/unicode-table-generator/src/main.rs b/src/tools/unicode-table-generator/src/main.rs index b40afcf4bf2d..a3327a3c2ffd 100644 --- a/src/tools/unicode-table-generator/src/main.rs +++ b/src/tools/unicode-table-generator/src/main.rs @@ -75,10 +75,10 @@ use std::collections::{BTreeMap, HashMap}; use std::ops::Range; use ucd_parse::Codepoints; +mod cascading_map; mod case_mapping; mod raw_emitter; mod skiplist; -mod cascading_map; mod unicode_download; use raw_emitter::{emit_codepoints, emit_whitespace, RawEmitter}; diff --git a/src/tools/unicode-table-generator/src/raw_emitter.rs b/src/tools/unicode-table-generator/src/raw_emitter.rs index f5960c459200..5aca86ba089d 100644 --- a/src/tools/unicode-table-generator/src/raw_emitter.rs +++ b/src/tools/unicode-table-generator/src/raw_emitter.rs @@ -177,7 +177,6 @@ pub fn emit_whitespace(emitter: &mut RawEmitter, ranges: &[Range]) { cascading.emit_cascading_map(&ranges); *emitter = cascading; emitter.desc = String::from("cascading"); - } struct Canonicalized {