about summary refs log tree commit diff
path: root/compiler/rustc_query_system
diff options
context:
space:
mode:
authorBen Kimock <kimockb@gmail.com>2023-09-04 12:40:08 -0400
committerBen Kimock <kimockb@gmail.com>2023-09-10 23:37:51 -0400
commit01e97981488ddb0b8194b6f4e27c3592bcd2c8d1 (patch)
treed879056844cfe6152cd9ced43e0ed8b2d0f20596 /compiler/rustc_query_system
parent62ebe3a2b177d50ec664798d731b8a8d1a9120d1 (diff)
downloadrust-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.rs11
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
+            });
         }
     }
 }