diff options
| author | Ben Kimock <kimockb@gmail.com> | 2023-09-04 12:40:08 -0400 |
|---|---|---|
| committer | Ben Kimock <kimockb@gmail.com> | 2023-09-10 23:37:51 -0400 |
| commit | 01e97981488ddb0b8194b6f4e27c3592bcd2c8d1 (patch) | |
| tree | d879056844cfe6152cd9ced43e0ed8b2d0f20596 /compiler/rustc_query_system | |
| parent | 62ebe3a2b177d50ec664798d731b8a8d1a9120d1 (diff) | |
| download | rust-01e97981488ddb0b8194b6f4e27c3592bcd2c8d1.tar.gz rust-01e97981488ddb0b8194b6f4e27c3592bcd2c8d1.zip | |
Reimplement FileEncoder with a small-write optimization
Diffstat (limited to 'compiler/rustc_query_system')
| -rw-r--r-- | compiler/rustc_query_system/src/dep_graph/serialized.rs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/compiler/rustc_query_system/src/dep_graph/serialized.rs b/compiler/rustc_query_system/src/dep_graph/serialized.rs index 4ba0cb31d0b..3fd83f79a48 100644 --- a/compiler/rustc_query_system/src/dep_graph/serialized.rs +++ b/compiler/rustc_query_system/src/dep_graph/serialized.rs @@ -394,7 +394,10 @@ struct NodeInfo<K: DepKind> { impl<K: DepKind> Encodable<FileEncoder> for NodeInfo<K> { fn encode(&self, e: &mut FileEncoder) { let header = SerializedNodeHeader::new(self); - e.emit_raw_bytes(&header.bytes); + e.write_with(|dest| { + *dest = header.bytes; + header.bytes.len() + }); if header.len().is_none() { e.emit_usize(self.edges.len()); @@ -402,8 +405,10 @@ impl<K: DepKind> Encodable<FileEncoder> for NodeInfo<K> { let bytes_per_index = header.bytes_per_index(); for node_index in self.edges.iter() { - let bytes = node_index.as_u32().to_le_bytes(); - e.emit_raw_bytes(&bytes[..bytes_per_index]); + e.write_with(|dest| { + *dest = node_index.as_u32().to_le_bytes(); + bytes_per_index + }); } } } |
