From c659ae06812a59ef9ebdbe3a8a93ae6737a8465e Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Thu, 2 Aug 2018 11:45:30 +0800 Subject: [PATCH] firmware: actually compact in config::compact(). --- artiq/firmware/libboard/config.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/artiq/firmware/libboard/config.rs b/artiq/firmware/libboard/config.rs index 92f228415..840a6806d 100644 --- a/artiq/firmware/libboard/config.rs +++ b/artiq/firmware/libboard/config.rs @@ -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)? };