Skip to content

Commit

Permalink
chore: Address nightly clippy lints double_ended_iterator_last and …
Browse files Browse the repository at this point in the history
…`len_zero`
  • Loading branch information
torokati44 committed Jan 17, 2025
1 parent 20c1257 commit 8d94ef1
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion core/src/avm1/globals/file_reference.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ pub fn download<'gc>(
Some(file_name) => file_name.coerce_to_string(activation)?.to_string(),
None => {
// Try to get the end of the path as a file name, if we can't bail and return false
match url.path().split('/').last() {
match url.path().split('/').next_back() {
Some(path_end) => path_end.to_string(),
None => return Ok(false.into()),
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/avm1/globals/shared_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ fn new_lso<'gc>(activation: &mut Activation<'_, 'gc>, name: &str, data: Object<'
w.commit_lso(
&name
.split('/')
.last()
.next_back()
.map(|e| e.to_string())
.unwrap_or_else(|| "<unknown>".to_string()),
)
Expand Down
2 changes: 1 addition & 1 deletion core/src/avm2/globals/flash/net/shared_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fn new_lso<'gc>(
Ok(Lso::new(
elements,
name.split('/')
.last()
.next_back()
.map(|e| e.to_string())
.unwrap_or_else(|| "<unknown>".to_string()),
AMFVersion::AMF3,
Expand Down
2 changes: 1 addition & 1 deletion core/src/avm2/globals/xml_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ pub fn normalize<'gc>(
)?;
}

text.len() == 0
text.is_empty()
};

// ii. If list[i].[[Value]].length == 0
Expand Down
2 changes: 1 addition & 1 deletion core/src/debug_ui/movie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ pub fn open_character_button(ui: &mut Ui, character: &Character) {
fn save_swf(movie: &Arc<SwfMovie>, messages: &mut Vec<Message>) {
let suggested_name = if let Ok(url) = Url::parse(movie.url()) {
url.path_segments()
.and_then(|segments| segments.last())
.and_then(|mut segments| segments.next_back())
.map(|str| str.to_string())
} else {
None
Expand Down
4 changes: 2 additions & 2 deletions core/src/html/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1393,11 +1393,11 @@ impl<'gc> LayoutBox<'gc> {
LayoutContent::Text {
text_format: TextFormat { url: Some(url), .. },
..
} => url.len() > 0,
} => !url.is_empty(),
LayoutContent::Bullet {
text_format: TextFormat { url: Some(url), .. },
..
} => url.len() > 0,
} => !url.is_empty(),
_ => false,
}
}
Expand Down
4 changes: 2 additions & 2 deletions core/src/html/text_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -867,8 +867,8 @@ impl FormatSpans {
tag @ b"li" => {
format = apply_style(style_sheet, format, WStr::from_units(tag));

let is_last_nl = text.iter().last() == Some(HTML_NEWLINE);
if is_multiline && !is_last_nl && text.len() > 0 {
let is_last_nl = text.iter().next_back() == Some(HTML_NEWLINE);
if is_multiline && !is_last_nl && !text.is_empty() {
// If the last paragraph was not closed and
// there was some text since then,
// we need to close it here.
Expand Down
2 changes: 1 addition & 1 deletion frontend-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub static INVALID_URL: &str = "invalid:///";
pub fn url_to_readable_name(url: &Url) -> Cow<'_, str> {
let name = url
.path_segments()
.and_then(|segments| segments.last())
.and_then(|mut segments| segments.next_back())
.unwrap_or_else(|| url.as_str());

urlencoding::decode(name).unwrap_or(Cow::Borrowed(name))
Expand Down

0 comments on commit 8d94ef1

Please sign in to comment.