diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 18:31:44 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 18:31:44 +0000 |
commit | c23a457e72abe608715ac76f076f47dc42af07a5 (patch) | |
tree | 2772049aaf84b5c9d0ed12ec8d86812f7a7904b6 /vendor/windows-metadata/src/writer/imp/blobs.rs | |
parent | Releasing progress-linux version 1.73.0+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-c23a457e72abe608715ac76f076f47dc42af07a5.tar.xz rustc-c23a457e72abe608715ac76f076f47dc42af07a5.zip |
Merging upstream version 1.74.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/windows-metadata/src/writer/imp/blobs.rs')
-rw-r--r-- | vendor/windows-metadata/src/writer/imp/blobs.rs | 60 |
1 files changed, 0 insertions, 60 deletions
diff --git a/vendor/windows-metadata/src/writer/imp/blobs.rs b/vendor/windows-metadata/src/writer/imp/blobs.rs deleted file mode 100644 index 08bad113d..000000000 --- a/vendor/windows-metadata/src/writer/imp/blobs.rs +++ /dev/null @@ -1,60 +0,0 @@ -use super::*; - -#[derive(Default)] -pub struct Blobs { - // Blobs 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<Vec<u8>, u32>, - stream: Vec<u8>, -} - -pub struct StagedBlobs(Blobs); - -impl Blobs { - pub fn insert(&mut self, value: Vec<u8>) { - if !value.is_empty() { - self.map.entry(value).or_default(); - } - } - - pub fn stage(mut self) -> StagedBlobs { - self.stream = vec![0]; - - for (value, index) in self.map.iter_mut() { - *index = self.stream.len() as _; - - match value.len() { - 0..=0x7F => self.stream.push(value.len() as _), - 0x80..=0x3FFF => { - self.stream.push((0x80 | value.len() >> 8) as _); - self.stream.push((0xFF & value.len()) as _); - } - _ => { - self.stream.push((0xC0 | value.len() >> 24) as _); - self.stream.push((0xFF & value.len() >> 16) as _); - self.stream.push((0xFF & value.len() >> 8) as _); - self.stream.push((0xFF & value.len()) as _); - } - } - - self.stream.extend_from_slice(value); - } - - self.stream.resize(round(self.stream.len(), 4), 0); - StagedBlobs(self) - } -} - -impl StagedBlobs { - pub fn stream(self) -> Vec<u8> { - self.0.stream - } - - #[track_caller] - pub fn index(&self, value: &[u8]) -> u32 { - if value.is_empty() { - 0 - } else { - self.0.map[value] - } - } -} |