forked from M-Labs/artiq
1
0
Fork 0

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

Fixes #1116.
This commit is contained in:
whitequark 2018-08-01 16:27:48 +00:00
parent 829fca6112
commit 5871d13da8
1 changed files with 8 additions and 3 deletions

View File

@ -212,14 +212,19 @@ mod imp {
// so it does not really matter.
let mut offset = 0;
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
}
}
offset = unsafe { append_at(data, offset, key, value)? };