We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e114d62 commit e647c6aCopy full SHA for e647c6a
compiler/rustc_metadata/src/rmeta/table.rs
@@ -172,8 +172,16 @@ where
172
173
pub(crate) fn encode(&self, buf: &mut Encoder) -> Lazy<Table<I, T>> {
174
let pos = buf.position();
175
+ // Since all of the data are serialized as u32, adding some padding
176
+ // should make encoding/decoding slightly faster.
177
+ let pad = (4 - (pos % 4)) % 4;
178
+ let pad_bytes = [0, 0, 0];
179
+ buf.emit_raw_bytes(&pad_bytes[..pad]);
180
buf.emit_raw_bytes(&self.bytes);
- Lazy::from_position_and_meta(NonZeroUsize::new(pos as usize).unwrap(), self.bytes.len())
181
+ Lazy::from_position_and_meta(
182
+ NonZeroUsize::new(pos as usize + pad).unwrap(),
183
+ self.bytes.len(),
184
+ )
185
}
186
187
0 commit comments