Skip to content

Commit 89ace47

Browse files
committed
formatted
1 parent d481963 commit 89ace47

File tree

3 files changed

+20
-34
lines changed

3 files changed

+20
-34
lines changed

src/tools/unicode-table-generator/src/cascading_map.rs

+19-32
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,24 @@ use std::collections::HashMap;
44
use std::fmt::Write as _;
55
use std::ops::Range;
66

7-
87
impl RawEmitter {
98
pub fn emit_cascading_map(&mut self, ranges: &[Range<u32>]) -> bool {
10-
119
let mut map: [u8; 256] = [
12-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
13-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
14-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
15-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
16-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
17-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
18-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
19-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
20-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
21-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
22-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
23-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
24-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
25-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
26-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
27-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
10+
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,
11+
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,
12+
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,
13+
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,
14+
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,
15+
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,
16+
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,
17+
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,
18+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2819
];
2920

30-
let points = ranges.iter().flat_map(
31-
|r| (r.start..r.end).into_iter().collect::<Vec<u32>>()
32-
).collect::<Vec<u32>>();
21+
let points = ranges
22+
.iter()
23+
.flat_map(|r| (r.start..r.end).into_iter().collect::<Vec<u32>>())
24+
.collect::<Vec<u32>>();
3325

3426
println!("there are {} points", points.len());
3527

@@ -46,7 +38,8 @@ impl RawEmitter {
4638
let mut bit_for_high_byte = 1u8;
4739
let mut arms = Vec::<String>::new();
4840

49-
let mut high_bytes: Vec<usize> = codepoints_by_high_bytes.keys().map(|k| k.clone()).collect();
41+
let mut high_bytes: Vec<usize> =
42+
codepoints_by_high_bytes.keys().map(|k| k.clone()).collect();
5043
high_bytes.sort();
5144
for high_byte in high_bytes {
5245
let codepoints = codepoints_by_high_bytes.get_mut(&high_byte).unwrap();
@@ -61,21 +54,15 @@ impl RawEmitter {
6154
}
6255
arms.push(format!(
6356
"{} => WHITESPACE_MAP[c as usize & 0xff] & {} != 0",
64-
high_byte,
65-
bit_for_high_byte)
66-
);
57+
high_byte, bit_for_high_byte
58+
));
6759
bit_for_high_byte <<= 1;
6860
}
6961

70-
writeln!(
71-
&mut self.file,
72-
"static WHITESPACE_MAP: [u8; 256] = [{}];",
73-
fmt_list(map.iter())
74-
)
75-
.unwrap();
62+
writeln!(&mut self.file, "static WHITESPACE_MAP: [u8; 256] = [{}];", fmt_list(map.iter()))
63+
.unwrap();
7664
self.bytes_used += 256;
7765

78-
7966
writeln!(&mut self.file, "pub fn lookup(c: char) -> bool {{").unwrap();
8067
writeln!(&mut self.file, " match c as u32 >> 8 {{").unwrap();
8168
for arm in arms {

src/tools/unicode-table-generator/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ use std::collections::{BTreeMap, HashMap};
7575
use std::ops::Range;
7676
use ucd_parse::Codepoints;
7777

78+
mod cascading_map;
7879
mod case_mapping;
7980
mod raw_emitter;
8081
mod skiplist;
81-
mod cascading_map;
8282
mod unicode_download;
8383

8484
use raw_emitter::{emit_codepoints, emit_whitespace, RawEmitter};

src/tools/unicode-table-generator/src/raw_emitter.rs

-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,6 @@ pub fn emit_whitespace(emitter: &mut RawEmitter, ranges: &[Range<u32>]) {
177177
cascading.emit_cascading_map(&ranges);
178178
*emitter = cascading;
179179
emitter.desc = String::from("cascading");
180-
181180
}
182181

183182
struct Canonicalized {

0 commit comments

Comments
 (0)