Skip to content

Commit 4c951b4

Browse files
committed
Minor fixes from clippy and Claude.
1 parent 5a13654 commit 4c951b4

File tree

17 files changed

+27
-39
lines changed

17 files changed

+27
-39
lines changed

src/binary.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub mod write;
1717
/// assert_eq!(padded_length, 124);
1818
/// ```
1919
pub const fn long_align(len: usize) -> usize {
20-
(len + 3) / 4 * 4
20+
len.div_ceil(4) * 4
2121
}
2222

2323
/// Calculate the length required to 16-bit (word) align data of length `len`
@@ -32,7 +32,7 @@ pub const fn long_align(len: usize) -> usize {
3232
/// assert_eq!(padded_length, 124);
3333
/// ```
3434
pub const fn word_align(len: usize) -> usize {
35-
(len + 1) / 2 * 2
35+
len.div_ceil(2) * 2
3636
}
3737

3838
/// Unsigned 8-bit binary type.

src/binary/read.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,13 +166,13 @@ pub struct ReadArray<'a, T: ReadFixedSizeDep> {
166166
args: T::Args<'a>,
167167
}
168168

169-
impl<'a, T: ReadFixedSizeDep> Clone for ReadArray<'a, T> {
169+
impl<T: ReadFixedSizeDep> Clone for ReadArray<'_, T> {
170170
fn clone(&self) -> Self {
171171
*self
172172
}
173173
}
174174

175-
impl<'a, T: ReadFixedSizeDep> Copy for ReadArray<'a, T> {}
175+
impl<T: ReadFixedSizeDep> Copy for ReadArray<'_, T> {}
176176

177177
pub struct ReadArrayIter<'a, T: ReadUnchecked> {
178178
scope: ReadScope<'a>,

src/binary/write.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
//! Write binary data
44
5-
use std::iter;
65
use std::marker::PhantomData;
76

87
use crate::binary::read::{ReadArray, ReadArrayCow, ReadScope, ReadUnchecked};
@@ -313,7 +312,7 @@ impl WriteContext for WriteBuffer {
313312
}
314313

315314
fn write_zeros(&mut self, count: usize) -> Result<(), WriteError> {
316-
let zeros = iter::repeat(0).take(count);
315+
let zeros = std::iter::repeat_n(0, count);
317316
self.data.extend(zeros);
318317
Ok(())
319318
}

src/cff.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2053,7 +2053,7 @@ impl TryFrom<&Operand> for f32 {
20532053
.contains(int)
20542054
.then_some(*int as f32)
20552055
.ok_or(ParseError::LimitExceeded),
2056-
Operand::Real(r) => f64::try_from(r).map_err(ParseError::from).and_then(|val| {
2056+
Operand::Real(r) => f64::try_from(r).and_then(|val| {
20572057
(f32::MIN as f64..=f32::MAX as f64)
20582058
.contains(&val)
20592059
.then_some(val as f32)

src/cff/charstring.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -896,7 +896,7 @@ impl<'a, 'data> CharStringVisitorContext<'a, 'data> {
896896
return Err(CFFError::MissingVariationStore.into());
897897
};
898898

899-
if stack.len() > 0 {
899+
if !stack.is_empty() {
900900
visitor.visit(op.try_into().unwrap(), stack)?;
901901

902902
// Lookup the ItemVariationStore data to get the variation regions

src/cff/subset.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ fn copy_used_subrs(
294294
if dst_subr_index
295295
.data
296296
.get(subr_index)
297-
.map_or(false, |subr| !subr.is_empty())
297+
.is_some_and(|subr| !subr.is_empty())
298298
{
299299
continue;
300300
}

src/gdef.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,5 @@ pub fn glyph_is_mark_in_set(opt_gdef_table: Option<&GDEFTable>, glyph: u16, inde
3333
&& opt_gdef_table
3434
.and_then(|gdef| gdef.opt_mark_glyph_sets.as_ref())
3535
.and_then(|mark_glyph_sets| mark_glyph_sets.get(index))
36-
.map_or(false, |mark_set| {
37-
mark_set.glyph_coverage_value(glyph).is_some()
38-
})
36+
.is_some_and(|mark_set| mark_set.glyph_coverage_value(glyph).is_some())
3937
}

src/glyph_position.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ fn is_upright_glyph(info: &Info) -> bool {
350350
.glyph
351351
.unicodes
352352
.first()
353-
.map_or(false, |&ch| is_upright_char(ch))
353+
.is_some_and(|&ch| is_upright_char(ch))
354354
}
355355

356356
#[cfg(test)]

src/gsub.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,7 @@ fn apply_subst_context<T: GlyphData>(
748748
None => return Ok(None), // FIXME actually an error/impossible?
749749
};
750750
for (subst_index, subst_lookup_index) in subst.lookup_array {
751-
match apply_subst(
751+
if let Some(changes0) = apply_subst(
752752
recursion_limit,
753753
gsub_cache,
754754
lookup_list,
@@ -761,8 +761,7 @@ fn apply_subst_context<T: GlyphData>(
761761
max_glyphs,
762762
i,
763763
)? {
764-
Some(changes0) => changes += changes0,
765-
None => {}
764+
changes += changes0
766765
}
767766
}
768767
match checked_add(len, changes) {

src/scripts/myanmar.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -854,7 +854,7 @@ fn tag_syllable(
854854
// with POS_BEFORE_SUBJOINED
855855
else if glyph.is(a)
856856
&& prev_glyph_skip(before_i, a)
857-
.map_or(false, |prev| prev.pos() == Some(Pos::BelowbaseConsonant))
857+
.is_some_and(|prev| prev.pos() == Some(Pos::BelowbaseConsonant))
858858
{
859859
glyph.set_pos(Some(Pos::BeforeSubjoined))
860860
}

0 commit comments

Comments
 (0)