Compare commits

..

No commits in common. "159b5c97d9fe4ab0d4e4bb5e1ce823b98b31ac49" and "91d69474eda5191f3782be52fc089254d3179b5a" have entirely different histories.

2 changed files with 2 additions and 30 deletions

View File

@ -1,4 +1,4 @@
#![no_std] //#![no_std]
use core::{mem::size_of, str}; use core::{mem::size_of, str};
use byteorder::{ByteOrder, BigEndian}; use byteorder::{ByteOrder, BigEndian};
@ -153,21 +153,7 @@ impl<B: StoreBackend> Store<B> {
} }
fn append(&mut self, key: &str, value: &[u8]) -> Result<(), Error<B::Error>> { fn append(&mut self, key: &str, value: &[u8]) -> Result<(), Error<B::Error>> {
let free_offset = { let free_offset = self.get_bytes_used()?;
let mut iter = Iter::new(self.backend.data().as_ref());
let mut not_modified = false;
while let Some(result) = iter.next() {
let (record_key, record_value) = result?;
if key.as_bytes() == record_key {
not_modified = value == record_value;
}
}
if not_modified {
return Ok(())
}
iter.offset
};
unsafe { self.append_at(free_offset, key.as_bytes(), value)? }; unsafe { self.append_at(free_offset, key.as_bytes(), value)? };
Ok(()) Ok(())
} }

View File

@ -130,20 +130,6 @@ fn write_many() {
assert_eq!(store.read("bar").unwrap().unwrap(), b"SPAM"); assert_eq!(store.read("bar").unwrap().unwrap(), b"SPAM");
} }
#[test]
#[cfg(feature = "postcard-values")]
fn write_value_many() {
let mut store = make_store();
store.write_value("quux", (false, 3u8, -42i16)).unwrap();
for i in 0..1000u32 {
store.write_value("bar", i).unwrap();
assert_eq!(store.read_value("bar"), Ok(Some(i)));
store.write_value("foo", i % 2 == 0).unwrap();
assert_eq!(store.read_value("foo"), Ok(Some(i % 2 == 0)));
}
assert_eq!(store.read_value("quux"), Ok(Some((false, 3u8, -42i16))));
}
#[test] #[test]
fn no_flash() { fn no_flash() {
let mut store = Store::new(no_flash::NoFlash); let mut store = Store::new(no_flash::NoFlash);