mirror of
https://github.com/servo/servo.git
synced 2025-08-09 23:45:35 +01:00
Use nth rather than enumerating in cef_string_map_{key,value}.
This commit is contained in:
parent
01df802fb2
commit
26964ff087
1 changed files with 10 additions and 10 deletions
|
@ -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 < 0 || sm.is_null() { return 0; }
|
||||||
if index as usize > (*sm).len() - 1 { return 0; }
|
if index as usize > (*sm).len() - 1 { return 0; }
|
||||||
|
|
||||||
for (i, k) in (*sm).keys().enumerate() {
|
match (*sm).keys().nth(index as usize) {
|
||||||
if i == index as usize {
|
Some(k) => {
|
||||||
cef_string_utf16_set(k.as_bytes().as_ptr() as *const u16,
|
cef_string_utf16_set(k.as_bytes().as_ptr() as *const u16,
|
||||||
k.len() as u64,
|
k.len() as u64,
|
||||||
value,
|
value,
|
||||||
1);
|
1);
|
||||||
return 1;
|
1
|
||||||
}
|
},
|
||||||
|
None => 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[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 < 0 || sm.is_null() { return 0; }
|
||||||
if index as usize > (*sm).len() - 1 { return 0; }
|
if index as usize > (*sm).len() - 1 { return 0; }
|
||||||
|
|
||||||
for (i, val) in (*sm).values().enumerate() {
|
match (*sm).values().nth(index as usize) {
|
||||||
if i == index as usize {
|
Some(val) => {
|
||||||
cef_string_utf16_set((**val).str as *const u16, (**val).length, value, 1);
|
cef_string_utf16_set((**val).str as *const u16, (**val).length, value, 1);
|
||||||
return 1;
|
1
|
||||||
}
|
},
|
||||||
|
None => 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue