Skip to content

Commit 55420b1

Browse files
committed
refactor: Include table sizes in comment at top of unicode_data.rs
To make changes in table size obvious from git diffs
1 parent 7a03b28 commit 55420b1

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

library/core/src/unicode/unicode_data.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
11
///! This file is generated by `./x run src/tools/unicode-table-generator`; do not edit manually!
2+
// Alphabetic : 1727 bytes, 142759 codepoints in 757 ranges (U+000041 - U+0323B0) using skiplist
3+
// Case_Ignorable : 1053 bytes, 2749 codepoints in 452 ranges (U+000027 - U+0E01F0) using skiplist
4+
// Cased : 407 bytes, 4578 codepoints in 159 ranges (U+000041 - U+01F18A) using skiplist
5+
// Cc : 9 bytes, 65 codepoints in 2 ranges (U+000000 - U+0000A0) using skiplist
6+
// Grapheme_Extend : 887 bytes, 2193 codepoints in 375 ranges (U+000300 - U+0E01F0) using skiplist
7+
// Lowercase : 935 bytes, 2569 codepoints in 675 ranges (U+000061 - U+01E944) using bitset
8+
// N : 457 bytes, 1911 codepoints in 144 ranges (U+000030 - U+01FBFA) using skiplist
9+
// Uppercase : 799 bytes, 1978 codepoints in 656 ranges (U+000041 - U+01F18A) using bitset
10+
// White_Space : 256 bytes, 25 codepoints in 10 ranges (U+000009 - U+003001) using cascading
11+
// Total : 6530 bytes
212

313
#[inline(always)]
414
const fn bitset_search<

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

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,11 @@ fn main() {
239239
std::fs::write(&path, generate_tests(&write_location, ranges_by_property)).unwrap();
240240
}
241241

242+
let mut table_file = String::new();
243+
table_file.push_str(
244+
"///! This file is generated by `./x run src/tools/unicode-table-generator`; do not edit manually!\n",
245+
);
246+
242247
let mut total_bytes = 0;
243248
let mut modules = Vec::new();
244249
for (property, ranges) in ranges_by_property {
@@ -252,24 +257,19 @@ fn main() {
252257
}
253258

254259
modules.push((property.to_lowercase().to_string(), emitter.file));
255-
println!(
256-
"{:15}: {} bytes, {} codepoints in {} ranges ({} - {}) using {}",
260+
table_file.push_str(&format!(
261+
"// {:16}: {:5} bytes, {:6} codepoints in {:3} ranges (U+{:06X} - U+{:06X}) using {}\n",
257262
property,
258263
emitter.bytes_used,
259264
datapoints,
260265
ranges.len(),
261266
ranges.first().unwrap().start,
262267
ranges.last().unwrap().end,
263268
emitter.desc,
264-
);
269+
));
265270
total_bytes += emitter.bytes_used;
266271
}
267-
268-
let mut table_file = String::new();
269-
270-
table_file.push_str(
271-
"///! This file is generated by `./x run src/tools/unicode-table-generator`; do not edit manually!\n",
272-
);
272+
table_file.push_str(&format!("// {:16}: {:5} bytes\n", "Total", total_bytes));
273273

274274
// Include the range search function
275275
table_file.push('\n');
@@ -296,8 +296,6 @@ fn main() {
296296
}
297297

298298
std::fs::write(&write_location, format!("{}\n", table_file.trim_end())).unwrap();
299-
300-
println!("Total table sizes: {total_bytes} bytes");
301299
}
302300

303301
fn version() -> String {

0 commit comments

Comments
 (0)