forked from M-Labs/artiq
1
0
Fork 0

firmware: actually compact in config::compact().

This commit is contained in:
Sebastien Bourdeauducq 2018-08-02 11:45:30 +08:00
parent a6b61f0c1d
commit c659ae0681
1 changed files with 8 additions and 3 deletions

View File

@ -149,14 +149,19 @@ mod imp {
// This is worst-case quadratic, but we're limited by a small SPI flash sector size,
// so it does not really matter.
let mut iter = Iter::new(old_data);
while let Some(result) = iter.next() {
'iter: while let Some(result) = iter.next() {
let (key, mut value) = result?;
if value.is_empty() {
// This is a removed entry, ignore it.
continue
}
let mut next_iter = iter.clone();
while let Some(next_result) = next_iter.next() {
let (next_key, next_value) = next_result?;
let (next_key, _) = next_result?;
if key == next_key {
value = next_value
// There's another entry that overwrites this one, ignore this one.
continue 'iter
}
}
data = unsafe { append_at(data, key, value)? };