@@ -72,7 +72,6 @@ pub use progress::WorkInfo;
7272use source_query:: QueryResult ;
7373pub use source_ref:: { CallSite , SourceRef } ;
7474
75-
7675#[ derive( Error , Debug , Diagnostic , Clone , Default ) ]
7776pub enum LogError {
7877 #[ default]
@@ -184,7 +183,7 @@ pub(crate) enum Revision {
184183
185184#[ derive( Serialize , Deserialize , Debug ) ]
186185pub ( crate ) enum CacheEntryFormat {
187- Bincode ,
186+ Postcard ,
188187}
189188
190189/// Header for an entry in the cache. Currently, this is more of interest to humans than machines.
@@ -325,12 +324,12 @@ impl LogMatcher {
325324 }
326325 } ) ?;
327326 // XXX check that the path matches?
328- let mut decoded_root : SourceTree =
329- bincode :: serde :: decode_from_std_read ( & mut reader, bincode :: config :: standard ( ) )
330- . map_err ( |err| LogError :: FailedToReadCache {
331- path : path. to_owned ( ) ,
332- source : Arc :: new ( err) ,
333- } ) ?;
327+ let mut scratch = [ 0u8 ; 1024 ] ;
328+ let ( mut decoded_root , _ ) = postcard :: from_io :: < SourceTree , _ > ( ( & mut reader, & mut scratch ) )
329+ . map_err ( |err| LogError :: FailedToReadCache {
330+ path : path. to_owned ( ) ,
331+ source : Arc :: new ( err) ,
332+ } ) ?;
334333 for sif in decoded_root. files_with_statements . values_mut ( ) {
335334 sif. try_creating_matcher ( ) ;
336335 sif. to_lookup_pair ( ) . into_iter ( ) . for_each ( |( name, sid) | {
@@ -413,7 +412,7 @@ impl LogMatcher {
413412 let header = CacheEntryHeader {
414413 schema : CacheEntrySchema :: V1 ,
415414 revision : Revision :: Current ,
416- format : CacheEntryFormat :: Bincode ,
415+ format : CacheEntryFormat :: Postcard ,
417416 path : root_path. to_string_lossy ( ) . to_string ( ) ,
418417 timestamp : SystemTime :: now ( )
419418 . duration_since ( UNIX_EPOCH )
@@ -423,8 +422,7 @@ impl LogMatcher {
423422 serde_json:: to_writer ( & file, & header) . map_err ( to_write_cache_error) ?;
424423 file. write_all ( "\n " . as_bytes ( ) )
425424 . map_err ( to_write_cache_error) ?;
426- bincode:: serde:: encode_into_std_write ( root, & mut file, bincode:: config:: standard ( ) )
427- . map_err ( to_write_cache_error) ?;
425+ postcard:: to_io ( root, & mut file) . map_err ( to_write_cache_error) ?;
428426 total_size = total_size. saturating_add ( file. stream_position ( ) . unwrap_or ( 0 ) ) ;
429427 file. into_temp_path ( )
430428 } ;
@@ -584,8 +582,7 @@ impl LogMatcher {
584582 . iter ( )
585583 . flat_map ( |path| coll. files_with_statements . get ( path) )
586584 . flat_map ( |stmts| {
587- let file_matches =
588- stmts. matcher . as_ref ( ) ?. matches ( body) ;
585+ let file_matches = stmts. matcher . as_ref ( ) ?. matches ( body) ;
589586 match file_matches. iter ( ) . next ( ) {
590587 None => None ,
591588 Some ( index) => stmts. log_statements . get ( index) ,
@@ -598,8 +595,7 @@ impl LogMatcher {
598595 . values ( )
599596 . filter ( |stmts| stmts. path . contains ( filename) )
600597 . flat_map ( |stmts| {
601- let file_matches =
602- stmts. matcher . as_ref ( ) ?. matches ( body) ;
598+ let file_matches = stmts. matcher . as_ref ( ) ?. matches ( body) ;
603599 match file_matches. iter ( ) . next ( ) {
604600 None => None ,
605601 Some ( index) => stmts. log_statements . get ( index) ,
@@ -611,11 +607,7 @@ impl LogMatcher {
611607 coll. files_with_statements
612608 . par_iter ( )
613609 . flat_map ( |src_ref_coll| {
614- let file_matches = src_ref_coll
615- . 1
616- . matcher
617- . as_ref ( ) ?
618- . matches ( log_ref. body ( ) ) ;
610+ let file_matches = src_ref_coll. 1 . matcher . as_ref ( ) ?. matches ( log_ref. body ( ) ) ;
619611 match file_matches. iter ( ) . next ( ) {
620612 None => None ,
621613 Some ( index) => src_ref_coll. 1 . log_statements . get ( index) ,
0 commit comments