Skip to content

Commit

Permalink
Clippy + fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurenzV committed Feb 25, 2024
1 parent 635cdd5 commit b81e13a
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 23 deletions.
4 changes: 1 addition & 3 deletions src/cmap/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ pub(crate) fn subset(ctx: &mut Context) -> Result<()> {
Ok(())
}

fn subset_subtables(
ctx: &mut Context,
) -> Result<Vec<(EncodingRecord, Vec<u8>)>> {
fn subset_subtables(ctx: &mut Context) -> Result<Vec<(EncodingRecord, Vec<u8>)>> {
let cmap = ctx.expect_table(Tag::CMAP)?;
let mut reader = Reader::new(cmap);

Expand Down
14 changes: 7 additions & 7 deletions src/cmap/subtable12.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ pub(crate) fn subset_subtable12(ctx: &Context, data: &[u8]) -> crate::Result<Vec
}
}

return None;
None
})
.collect::<Vec<_>>();

Expand All @@ -128,12 +128,12 @@ pub(crate) fn subset_subtable12(ctx: &Context, data: &[u8]) -> crate::Result<Vec
let mut cur_gid = first.1;
let mut cur_range = 0;

while let Some(next) = map_iter.next() {
if next.0 == cur_start + cur_range + 1 {
if next.1 as u32 == cur_gid as u32 + cur_range + 1 {
cur_range += 1;
continue;
}
for next in map_iter {
if next.0 == cur_start + cur_range + 1
&& next.1 as u32 == cur_gid as u32 + cur_range + 1
{
cur_range += 1;
continue;
}

new_groups.push(SequentialMapGroupRecord {
Expand Down
12 changes: 5 additions & 7 deletions src/cmap/subtable4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ pub(crate) fn subset_subtable4(ctx: &Context, data: &[u8]) -> crate::Result<Vec<
}
}

return None;
None
})
.collect::<Vec<_>>();

Expand All @@ -181,12 +181,10 @@ pub(crate) fn subset_subtable4(ctx: &Context, data: &[u8]) -> crate::Result<Vec<
let mut cur_delta = delta(first);
let mut cur_range = 0;

while let Some(next) = map_iter.next() {
if next.0 == cur_start + cur_range + 1 {
if delta(next) == cur_delta {
cur_range += 1;
continue;
}
for next in map_iter {
if next.0 == cur_start + cur_range + 1 && delta(next) == cur_delta {
cur_range += 1;
continue;
}

segments.push((cur_start, cur_start + cur_range, cur_delta));
Expand Down
2 changes: 1 addition & 1 deletion src/glyf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ pub(crate) fn subset(ctx: &mut Context) -> Result<()> {
let data = table.glyph_data(*old_gid)?;

// Not contours
if data.len() == 0 {
if data.is_empty() {
continue;
}

Expand Down
6 changes: 2 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,11 +331,9 @@ impl<'a> Context<'a> {
let mut original_gids = self.subset.iter().collect::<Vec<_>>();
original_gids.sort();

let mut counter = 0;
for gid in original_gids {
self.gid_map.insert(*gid, counter);
for (counter, gid) in original_gids.into_iter().enumerate() {
self.gid_map.insert(*gid, counter as u16);
self.reverse_gid_map.push(*gid);
counter += 1;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ pub(crate) fn subset(ctx: &mut Context) -> Result<()> {

let mut pruned = prune_name_records(name_records);

if pruned.len() == 0 && count != 0 {
if pruned.is_empty() && count != 0 {
// Only contains non-Unicode records, so we don't subset.
ctx.push(Tag::NAME, name);
return Ok(());
Expand Down

0 comments on commit b81e13a

Please sign in to comment.