Skip to content

Commit 23c60e1

Browse files
authored
YJIT: Tiny refactors (ruby#14505)
Addressed some suggestions from clippy that made sense to me.
1 parent 399e2ab commit 23c60e1

4 files changed

Lines changed: 5 additions & 8 deletions

File tree

yjit/src/asm/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,12 +441,12 @@ impl CodeBlock {
441441

442442
// Ignore empty code ranges
443443
if start_addr == end_addr {
444-
return (0..0).into_iter();
444+
return 0..0;
445445
}
446446

447447
let start_page = (start_addr.raw_addr(self) - mem_start) / self.page_size;
448448
let end_page = (end_addr.raw_addr(self) - mem_start - 1) / self.page_size;
449-
(start_page..end_page + 1).into_iter()
449+
start_page..end_page + 1
450450
}
451451

452452
/// Get a (possibly dangling) direct pointer to the current write position

yjit/src/backend/ir.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1602,7 +1602,7 @@ impl Assembler
16021602
if c_args.len() > 0 {
16031603
// Resolve C argument dependencies
16041604
let c_args_len = c_args.len() as isize;
1605-
let moves = Self::reorder_reg_moves(&c_args.drain(..).into_iter().collect());
1605+
let moves = Self::reorder_reg_moves(&c_args.drain(..).collect());
16061606
shift_live_ranges(&mut shifted_live_ranges, asm.insns.len(), moves.len() as isize - c_args_len);
16071607

16081608
// Push batched C arguments

yjit/src/core.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1099,7 +1099,7 @@ impl Context {
10991099
MapToLocal(local_idx) => {
11001100
bits.push_op(CtxOp::MapTempLocal);
11011101
bits.push_u3(stack_idx as u8);
1102-
bits.push_u3(local_idx as u8);
1102+
bits.push_u3(local_idx);
11031103
}
11041104

11051105
MapToSelf => {

yjit/src/utils.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,7 @@ pub fn ruby_str_to_rust(v: VALUE) -> String {
9292
let str_ptr = unsafe { rb_RSTRING_PTR(v) } as *mut u8;
9393
let str_len: usize = unsafe { rb_RSTRING_LEN(v) }.try_into().unwrap();
9494
let str_slice: &[u8] = unsafe { slice::from_raw_parts(str_ptr, str_len) };
95-
match String::from_utf8(str_slice.to_vec()) {
96-
Ok(utf8) => utf8,
97-
Err(_) => String::new(),
98-
}
95+
String::from_utf8(str_slice.to_vec()).unwrap_or_default()
9996
}
10097

10198
// Location is the file defining the method, colon, method name.

0 commit comments

Comments
 (0)