| // Strings don't need to be sorted. A map is used to collapse duplicates. A `BTreeMap` in particular is used to help with reproducible builds. |
| map: BTreeMap<&'a str, u32>, |
| pub struct StagedStrings<'a>(Strings<'a>); |
| pub fn insert(&mut self, value: &'a str) { |
| self.map.entry(value).or_default(); |
| pub fn stage(mut self) -> StagedStrings<'a> { |
| for (value, index) in self.map.iter_mut() { |
| *index = self.stream.len() as _; |
| self.stream.extend_from_slice(value.as_bytes()); |
| self.stream.push(0); // terminator |
| self.stream.resize(round(self.stream.len(), 4), 0); |
| impl<'a> StagedStrings<'a> { |
| pub fn stream(self) -> Vec<u8> { |
| pub fn index(&self, value: &str) -> u32 { |