diff --git a/ports/cef/string_list.rs b/ports/cef/string_list.rs index 2c1d4be17be..e10df59bc56 100644 --- a/ports/cef/string_list.rs +++ b/ports/cef/string_list.rs @@ -11,10 +11,6 @@ use types::{cef_string_list_t,cef_string_t}; use rustc_unicode::str::Utf16Encoder; -fn string_list_to_vec(lt: *mut cef_string_list_t) -> *mut Vec { - lt as *mut Vec -} - //cef_string_list #[no_mangle] @@ -26,8 +22,7 @@ pub extern "C" fn cef_string_list_alloc() -> *mut cef_string_list_t { pub extern "C" fn cef_string_list_size(lt: *mut cef_string_list_t) -> c_int { unsafe { if lt.is_null() { return 0; } - let v = string_list_to_vec(lt); - (*v).len() as c_int + (*lt).len() as c_int } } @@ -35,8 +30,7 @@ pub extern "C" fn cef_string_list_size(lt: *mut cef_string_list_t) -> c_int { pub extern "C" fn cef_string_list_append(lt: *mut cef_string_list_t, value: *const cef_string_t) { unsafe { if lt.is_null() { return; } - let v = string_list_to_vec(lt); - (*v).push(String::from_utf16(slice::from_raw_parts((*value).str, (*value).length as usize)).unwrap()); + (*lt).push(String::from_utf16(slice::from_raw_parts((*value).str, (*value).length as usize)).unwrap()); } } @@ -44,9 +38,8 @@ pub extern "C" fn cef_string_list_append(lt: *mut cef_string_list_t, value: *con pub extern "C" fn cef_string_list_value(lt: *mut cef_string_list_t, index: c_int, value: *mut cef_string_t) -> c_int { unsafe { if index < 0 || lt.is_null() { return 0; } - let v = string_list_to_vec(lt); - if index as usize > (*v).len() - 1 { return 0; } - let ref string = (*v)[index as usize]; + if index as usize > (*lt).len() - 1 { return 0; } + let ref string = (*lt)[index as usize]; let utf16_chars: Vec = Utf16Encoder::new(string.chars()).collect(); cef_string_utf16_set(mem::transmute(utf16_chars.as_ptr()), utf16_chars.len() as u64, value, 1) } @@ -56,8 +49,7 @@ pub extern "C" fn cef_string_list_value(lt: *mut cef_string_list_t, index: c_int pub extern "C" fn cef_string_list_clear(lt: *mut cef_string_list_t) { unsafe { if lt.is_null() { return; } - let v = string_list_to_vec(lt); - (*v).clear(); + (*lt).clear(); } } @@ -74,8 +66,7 @@ pub extern "C" fn cef_string_list_free(lt: *mut cef_string_list_t) { pub extern "C" fn cef_string_list_copy(lt: *mut cef_string_list_t) -> *mut cef_string_list_t { unsafe { if lt.is_null() { return 0 as *mut cef_string_list_t; } - let v = string_list_to_vec(lt); - let copy = (*v).clone(); + let copy = (*lt).clone(); boxed::into_raw(box copy) } }