-
Notifications
You must be signed in to change notification settings - Fork 249
usage of cargo clippy --fix --lib -p usvg
with rust 1.83.0
#876
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -331,7 +331,7 @@ fn convert_stops(grad: SvgNode) -> Vec<Stop> { | |
if stops.len() >= 3 { | ||
let mut i = 0; | ||
while i < stops.len() - 2 { | ||
let offset1 = stops[i + 0].offset.get(); | ||
let offset1 = stops[i].offset.get(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again... I can see the rationale, but I think the previous version was probably better. |
||
let offset2 = stops[i + 1].offset.get(); | ||
let offset3 = stops[i + 2].offset.get(); | ||
|
||
|
@@ -358,7 +358,7 @@ fn convert_stops(grad: SvgNode) -> Vec<Stop> { | |
if stops.len() >= 2 { | ||
let mut i = 0; | ||
while i < stops.len() - 1 { | ||
let offset1 = stops[i + 0].offset.get(); | ||
let offset1 = stops[i].offset.get(); | ||
let offset2 = stops[i + 1].offset.get(); | ||
|
||
if offset1.approx_eq_ulps(&0.0, 4) && offset2.approx_eq_ulps(&0.0, 4) { | ||
|
@@ -384,14 +384,14 @@ fn convert_stops(grad: SvgNode) -> Vec<Stop> { | |
let mut i = 1; | ||
while i < stops.len() { | ||
let offset1 = stops[i - 1].offset.get(); | ||
let offset2 = stops[i - 0].offset.get(); | ||
let offset2 = stops[i].offset.get(); | ||
|
||
// Next offset must be smaller then previous. | ||
if offset1 > offset2 || offset1.approx_eq_ulps(&offset2, 4) { | ||
// Make previous offset a bit smaller. | ||
let new_offset = offset1 - f32::EPSILON; | ||
stops[i - 1].offset = StopOffset::new_clamped(new_offset); | ||
stops[i - 0].offset = StopOffset::new_clamped(offset1); | ||
stops[i].offset = StopOffset::new_clamped(offset1); | ||
} | ||
|
||
i += 1; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1418,7 +1418,7 @@ fn shape_text_with_font( | |
|
||
glyphs.push(Glyph { | ||
byte_idx: ByteIndex::new(idx), | ||
cluster_len: end.checked_sub(start).unwrap_or(0), // TODO: can fail? | ||
cluster_len: end.saturating_sub(start), // TODO: can fail? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The semantics are the same, but the meaning this suggests to the reader is different There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know the history of this line, but seems like a runtime panic was too risky. Maybe a It doesn't trigger in usvg's test cases. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So to be clear, I agree. What I mean by "the meaning this suggests to the reader is different" is that ".unwrap_or" makes it really clear what There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Exactly, that's my reading as well. |
||
text: sub_text[start..end].to_string(), | ||
id: GlyphId(info.glyph_id as u16), | ||
dx: pos.x_offset, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is better. If you do want to change this, I'd say:
But I think the original code is fine...