Use nth rather than enumerating in cef_string_map_{key,value}.

This commit is contained in:
Ms2ger 2015-06-20 14:03:17 +02:00
parent 01df802fb2
commit 26964ff087

View file

@ -60,17 +60,17 @@ pub extern "C" fn cef_string_map_key(sm: *mut cef_string_map_t, index: c_int, va
if index < 0 || sm.is_null() { return 0; }
if index as usize > (*sm).len() - 1 { return 0; }
for (i, k) in (*sm).keys().enumerate() {
if i == index as usize {
match (*sm).keys().nth(index as usize) {
Some(k) => {
cef_string_utf16_set(k.as_bytes().as_ptr() as *const u16,
k.len() as u64,
value,
1);
return 1;
}
1
},
None => 0,
}
}
0
}
#[no_mangle]
@ -79,14 +79,14 @@ pub extern "C" fn cef_string_map_value(sm: *mut cef_string_map_t, index: c_int,
if index < 0 || sm.is_null() { return 0; }
if index as usize > (*sm).len() - 1 { return 0; }
for (i, val) in (*sm).values().enumerate() {
if i == index as usize {
match (*sm).values().nth(index as usize) {
Some(val) => {
cef_string_utf16_set((**val).str as *const u16, (**val).length, value, 1);
return 1;
}
1
},
None => 0,
}
}
0
}
#[no_mangle]