Skip to content

Commit 21571e8

Browse files
committed
[skera] move plan creation out of iterating loop
This will macth harfbuzz and make binary runtime comparison fairer
1 parent 739ee69 commit 21571e8

2 files changed

Lines changed: 11 additions & 25 deletions

File tree

skera/benches/skera-benchmarks.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,6 @@ fn read_test_font(file_name: &str) -> Vec<u8> {
1313
std::fs::read(&path).expect("failed to read test font file")
1414
}
1515

16-
// comment out for now, may be used later
17-
//fn set_from_ranges<I>(ranges: I) -> IntSet<u32>
18-
//where
19-
// I: IntoIterator<Item = std::ops::RangeInclusive<u32>>,
20-
//{
21-
// let mut set = IntSet::empty();
22-
// for range in ranges {
23-
// set.insert_range(range);
24-
// }
25-
// set
26-
//}
27-
2816
/// Creates a subsetting plan using the same default options as running the src/main.rs with
2917
/// --unicodes.
3018
fn create_plan(font: &FontRef, unicodes: &IntSet<u32>) -> Plan {
@@ -44,8 +32,6 @@ fn create_plan(font: &FontRef, unicodes: &IntSet<u32>) -> Plan {
4432
}
4533

4634
fn benchmark_subset(c: &mut Criterion) {
47-
// comment out for now, may be used later
48-
// let latin_codepoints = set_from_ranges([0x20..=0x7E, 0xA0..=0xFF, 0x100..=0x24F]);
4935
c.benchmark_group("subset")
5036
.bench_function("Amiri-Regular-all", |b| {
5137
let font_bytes = read_test_font("Amiri-Regular.ttf");

skera/src/main.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -233,18 +233,18 @@ fn main() {
233233
};
234234

235235
let mut output_bytes = Vec::new();
236+
let plan = Plan::new(
237+
&gids,
238+
&unicodes,
239+
&font,
240+
subset_flags,
241+
&drop_tables,
242+
&layout_scripts,
243+
&layout_features,
244+
&name_ids,
245+
&name_languages,
246+
);
236247
for _ in 0..args.num_iterations.unwrap_or(1) {
237-
let plan = Plan::new(
238-
&gids,
239-
&unicodes,
240-
&font,
241-
subset_flags,
242-
&drop_tables,
243-
&layout_scripts,
244-
&layout_features,
245-
&name_ids,
246-
&name_languages,
247-
);
248248
match subset_font(&font, &plan) {
249249
Ok(out) => {
250250
output_bytes = out;

0 commit comments

Comments
 (0)