Skip to content

Commit

Permalink
Remove unnecessary casts of function pointers through usize
Browse files Browse the repository at this point in the history
  • Loading branch information
sdroege committed Nov 29, 2023
1 parent 22c3351 commit c25e11e
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions src/codegen/function_body_chunk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -544,23 +544,12 @@ impl Builder {
if is_destroy || trampoline.scope.is_async() {
format!("Box_::from_raw({func} as *mut _)")
} else if trampoline.scope.is_call() {
format!(
"{} as *const _ as usize as *mut {}",
func, trampoline.bound_name
)
format!("{} as *mut {}", func, trampoline.bound_name)
} else {
format!("&*({func} as *mut _)")
},
)),
type_: Some(Box::new(Chunk::Custom(
if is_destroy || trampoline.scope.is_async() {
format!("Box_<{}>", trampoline.bound_name)
} else if trampoline.scope.is_call() {
format!("*mut {}", trampoline.bound_name)
} else {
format!("&{}", trampoline.bound_name)
},
))),
type_: None,
});
if !is_destroy && *trampoline.nullable {
if trampoline.scope.is_async() {
Expand Down Expand Up @@ -1016,7 +1005,7 @@ impl Builder {
Chunk::FfiCallParameter {
transformation_type: TransformationType::ToGlibDirect {
name: if all_call {
format!("super_callback{pos} as *const _ as usize as *mut _")
format!("super_callback{pos} as *const _ as *mut _")
} else {
format!("Box_::into_raw(super_callback{pos}) as *mut _")
},
Expand Down

0 comments on commit c25e11e

Please sign in to comment.