Code view:

A painting is a person's account of this edit as text, recorded independently of the node mapping - a rendering often has several equally defensible answers where the mapping has one. Deletions and insertions carry no position on the opposite side in a painting, so that panel draws no caret for them.

Before

1use std::{
2 borrow::Borrow,
3 env,
4 path::PathBuf,
5 sync::{Arc, LazyLock, Mutex, PoisonError, Weak},
6};
7
8use anyhow::{Context, Result};
9use turbo_bincode::{
10 TurboBincodeBuffer, new_turbo_bincode_decoder, new_turbo_bincode_encoder, turbo_bincode_decode,
11 turbo_bincode_encode, turbo_bincode_encode_into,
12};
13use turbo_tasks::{
14 TaskId,
15 backend::CachedTaskType,
16 panic_hooks::{PanicHookGuard, register_panic_hook},
17 parallel,
…lines 18–246 unchanged (229 lines)
247 let operations = turbo_bincode_decode(operations.borrow())?;
248 Ok(operations)
249 }
250 get(&self.inner.database).context("Unable to read uncompleted operations from database")
251 }
252
253 fn serialize(
254 &self,
255 task: TaskId,
256 data: &TaskStorage,
257 category: SpecificTaskDataCategory,
258 ) -> Result<TurboBincodeBuffer> {
259 encode_task_data(task, data, category)
260 }
261
262 fn save_snapshot<I>(
263 &self,
264 operations: Vec<Arc<AnyOperation>>,
265 task_cache_updates: Vec<ChunkedVec<(Arc<CachedTaskType>, TaskId)>>,
266 snapshots: Vec<I>,
…lines 267–794 unchanged (528 lines)
795 }
796
797 Ok(result)
798 })
799}
800
801fn encode_task_data(
802 task: TaskId,
803 data: &TaskStorage,
804 category: SpecificTaskDataCategory,
805) -> Result<TurboBincodeBuffer> {
806 // TODO: see if the caller can pass us a buffer instead of us allocating a new one.
807 // This should be possible and save a lot of small allocations.
808 let mut buffer = TurboBincodeBuffer::new();
809 let mut encoder = new_turbo_bincode_encoder(&mut buffer);
810 data.encode(category, &mut encoder)?;
811
812 if !cfg!(feature = "verify_serialization") {
813 return Ok(buffer);
814 }
815
816 TaskStorage::new()
817 .decode(category, &mut new_turbo_bincode_decoder(buffer.borrow()))
818 .with_context(|| {
819 format!(
820 "expected to be able to decode serialized data for '{category:?}' information for \
821 {task}"
822 )
823 })?;
824
825 Ok(buffer)
826}
827

After

1use std::{
2 borrow::Borrow,
3 env,
4 path::PathBuf,
5 sync::{Arc, LazyLock, Mutex, PoisonError, Weak},
6};
7
8use anyhow::{Context, Result};
9use turbo_bincode::{
10 TurboBincodeBuffer, new_turbo_bincode_decoder, turbo_bincode_decode, turbo_bincode_encode,
11 turbo_bincode_encode_into,
12};
13use turbo_tasks::{
14 TaskId,
15 backend::CachedTaskType,
16 panic_hooks::{PanicHookGuard, register_panic_hook},
17 parallel,
…lines 18–245 unchanged (228 lines)
246 };
247 let operations = turbo_bincode_decode(operations.borrow())?;
248 Ok(operations)
249 }
250 get(&self.inner.database).context("Unable to read uncompleted operations from database")
251 }
252
253 fn save_snapshot<I>(
254 &self,
255 operations: Vec<Arc<AnyOperation>>,
256 task_cache_updates: Vec<ChunkedVec<(Arc<CachedTaskType>, TaskId)>>,
257 snapshots: Vec<I>,
258 ) -> Result<()>
…lines 259–784 unchanged (526 lines)
785 }
786 }
787
788 Ok(result)
789 })
790}
791

Before

source_file
use_declaration (+37 nodes collapsed)
use_declaration
use "use"
scoped_use_list
identifier "anyhow"
:: "::"
use_list
{ "{"
identifier "Context"
, ","
identifier "Result"
} "}"
; ";"
use_declaration
use "use"
scoped_use_list
identifier "turbo_bincode"
:: "::"
use_list
{ "{"
identifier "TurboBincodeBuffer"
, ","
identifier "new_turbo_bincode_decoder"
, ","
identifier "new_turbo_bincode_encoder"
, ","
identifier "turbo_bincode_decode"
, ","
identifier "turbo_bincode_encode"
, ","
identifier "turbo_bincode_encode_into"
, ","
} "}"
; ";"
use_declaration (+28 nodes collapsed)
use_declaration (+102 nodes collapsed)
const_item
const "const"
identifier "META_KEY_OPERATIONS"
: ":"
primitive_type "u32"
= "="
integer_literal "0"
; ";"
const_item
const "const"
identifier "META_KEY_NEXT_FREE_TASK_ID"
: ":"
primitive_type "u32"
= "="
integer_literal "1"
; ";"
struct_item
struct "struct"
type_identifier "IntKey"
ordered_field_declaration_list
( "("
array_type
[ "["
primitive_type "u8"
; ";"
integer_literal "4"
] "]"
) ")"
; ";"
impl_item (+34 nodes collapsed)
impl_item (+41 nodes collapsed)
function_item (+66 nodes collapsed)
line_comment
// "//"
line_comment
// "//"
line_comment
// "//"
line_comment
// "//"
line_comment
// "//"
line_comment
// "//"
line_comment
// "//"
line_comment
// "//"
function_item (+150 nodes collapsed)
struct_item (+76 nodes collapsed)
struct_item (+33 nodes collapsed)
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " A wrapper type used by [`crate::turbo_backing_storage`] and"...
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment "\n"
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " Wraps a low-level key-value database into a higher-level [`"...
impl_item (+508 nodes collapsed)
impl_item (+428 nodes collapsed)
impl_item (+69 nodes collapsed)
impl_item
impl "impl"
type_parameters
< "<"
type_parameter
type_identifier "T"
trait_bounds
: ":"
type_identifier "KeyValueDatabase"
+ "+"
type_identifier "Send"
+ "+"
type_identifier "Sync"
+ "+"
lifetime
' "'"
identifier "static"
> ">"
type_identifier "BackingStorageSealed"
for "for"
generic_type
type_identifier "KeyValueDatabaseBackingStorage"
type_arguments
< "<"
type_identifier "T"
> ">"
declaration_list
{ "{"
type_item (+23 nodes collapsed)
function_item (+72 nodes collapsed)
function_item (+185 nodes collapsed)
function_item
fn "fn"
identifier "serialize"
parameters
( "("
self_parameter
& "&"
self "self"
, ","
parameter
identifier "task"
: ":"
type_identifier "TaskId"
, ","
parameter
identifier "data"
: ":"
reference_type
& "&"
type_identifier "TaskStorage"
, ","
parameter
identifier "category"
: ":"
type_identifier "SpecificTaskDataCategory"
, ","
) ")"
-> "->"
generic_type
type_identifier "Result"
type_arguments
< "<"
type_identifier "TurboBincodeBuffer"
> ">"
block
{ "{"
call_expression
identifier "encode_task_data"
arguments
( "("
identifier "task"
, ","
identifier "data"
, ","
identifier "category"
) ")"
} "}"
function_item (+1764 nodes collapsed)
function_item (+50 nodes collapsed)
function_item (+350 nodes collapsed)
function_item (+325 nodes collapsed)
function_item (+483 nodes collapsed)
function_item (+35 nodes collapsed)
} "}"
function_item (+180 nodes collapsed)
function_item (+334 nodes collapsed)
function_item (+452 nodes collapsed)
type_item (+49 nodes collapsed)
attribute_item
# "#"
[ "["
attribute
identifier "cfg"
token_tree
( "("
identifier "feature"
= "="
string_literal
" "\""
string_content "print_cache_item_size"
" "\""
) ")"
] "]"
attribute_item
# "#"
[ "["
attribute
identifier "derive"
token_tree
( "("
identifier "Default"
) ")"
] "]"
struct_item (+21 nodes collapsed)
attribute_item
# "#"
[ "["
attribute
identifier "cfg"
token_tree
( "("
identifier "feature"
= "="
string_literal
" "\""
string_content "print_cache_item_size"
" "\""
) ")"
] "]"
impl_item (+156 nodes collapsed)
attribute_item
# "#"
[ "["
attribute
identifier "cfg"
token_tree
( "("
identifier "feature"
= "="
string_literal
" "\""
string_content "print_cache_item_size"
" "\""
) ")"
] "]"
function_item (+323 nodes collapsed)
function_item (+374 nodes collapsed)
function_item
fn "fn"
identifier "encode_task_data"
parameters
( "("
parameter
identifier "task"
: ":"
type_identifier "TaskId"
, ","
parameter
identifier "data"
: ":"
reference_type
& "&"
type_identifier "TaskStorage"
, ","
parameter
identifier "category"
: ":"
type_identifier "SpecificTaskDataCategory"
, ","
) ")"
-> "->"
generic_type
type_identifier "Result"
type_arguments
< "<"
type_identifier "TurboBincodeBuffer"
> ">"
block
{ "{"
line_comment
// "//"
line_comment
// "//"
let_declaration
let "let"
mutable_specifier "mut"
identifier "buffer"
= "="
call_expression
scoped_identifier
identifier "TurboBincodeBuffer"
:: "::"
identifier "new"
arguments
( "("
) ")"
; ";"
let_declaration
let "let"
mutable_specifier "mut"
identifier "encoder"
= "="
call_expression
identifier "new_turbo_bincode_encoder"
arguments
( "("
reference_expression
& "&"
mutable_specifier "mut"
identifier "buffer"
) ")"
; ";"
expression_statement
try_expression
call_expression
field_expression
identifier "data"
. "."
field_identifier "encode"
arguments
( "("
identifier "category"
, ","
reference_expression
& "&"
mutable_specifier "mut"
identifier "encoder"
) ")"
? "?"
; ";"
expression_statement
if_expression
if "if"
unary_expression
! "!"
macro_invocation
identifier "cfg"
! "!"
token_tree
( "("
identifier "feature"
= "="
string_literal
" "\""
string_content "verify_serialization"
" "\""
) ")"
block
{ "{"
expression_statement
return_expression
return "return"
call_expression
identifier "Ok"
arguments
( "("
identifier "buffer"
) ")"
; ";"
} "}"
expression_statement
try_expression
call_expression
field_expression
call_expression
field_expression
call_expression
scoped_identifier
identifier "TaskStorage"
:: "::"
identifier "new"
arguments
( "("
) ")"
. "."
field_identifier "decode"
arguments
( "("
identifier "category"
, ","
reference_expression
& "&"
mutable_specifier "mut"
call_expression
identifier "new_turbo_bincode_decoder"
arguments
( "("
call_expression
field_expression
identifier "buffer"
. "."
field_identifier "borrow"
arguments
( "("
) ")"
) ")"
) ")"
. "."
field_identifier "with_context"
arguments
( "("
closure_expression
closure_parameters
| "|"
| "|"
block
{ "{"
macro_invocation
identifier "format"
! "!"
token_tree
( "("
string_literal
" "\""
string_content "expected to be able to decode serialized data for '{category"...
escape_sequence "\\\n"
string_content " {task}"
" "\""
) ")"
} "}"
) ")"
? "?"
; ";"
call_expression
identifier "Ok"
arguments
( "("
identifier "buffer"
) ")"
} "}"

After

source_file
use_declaration (+37 nodes collapsed)
use_declaration
use "use"
scoped_use_list
identifier "anyhow"
:: "::"
use_list
{ "{"
identifier "Context"
, ","
identifier "Result"
} "}"
; ";"
use_declaration
use "use"
scoped_use_list
identifier "turbo_bincode"
:: "::"
use_list
{ "{"
identifier "TurboBincodeBuffer"
, ","
identifier "new_turbo_bincode_decoder"
, ","
identifier "turbo_bincode_decode"
, ","
identifier "turbo_bincode_encode"
, ","
identifier "turbo_bincode_encode_into"
, ","
} "}"
; ";"
use_declaration (+28 nodes collapsed)
use_declaration (+102 nodes collapsed)
const_item
const "const"
identifier "META_KEY_OPERATIONS"
: ":"
primitive_type "u32"
= "="
integer_literal "0"
; ";"
const_item
const "const"
identifier "META_KEY_NEXT_FREE_TASK_ID"
: ":"
primitive_type "u32"
= "="
integer_literal "1"
; ";"
struct_item
struct "struct"
type_identifier "IntKey"
ordered_field_declaration_list
( "("
array_type
[ "["
primitive_type "u8"
; ";"
integer_literal "4"
] "]"
) ")"
; ";"
impl_item (+34 nodes collapsed)
impl_item (+41 nodes collapsed)
function_item (+66 nodes collapsed)
line_comment
// "//"
line_comment
// "//"
line_comment
// "//"
line_comment
// "//"
line_comment
// "//"
line_comment
// "//"
line_comment
// "//"
line_comment
// "//"
function_item (+150 nodes collapsed)
struct_item (+76 nodes collapsed)
struct_item (+33 nodes collapsed)
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " A wrapper type used by [`crate::turbo_backing_storage`] and"...
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment "\n"
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " Wraps a low-level key-value database into a higher-level [`"...
impl_item (+508 nodes collapsed)
impl_item (+428 nodes collapsed)
impl_item (+69 nodes collapsed)
impl_item
impl "impl"
type_parameters
< "<"
type_parameter
type_identifier "T"
trait_bounds
: ":"
type_identifier "KeyValueDatabase"
+ "+"
type_identifier "Send"
+ "+"
type_identifier "Sync"
+ "+"
lifetime
' "'"
identifier "static"
> ">"
type_identifier "BackingStorageSealed"
for "for"
generic_type
type_identifier "KeyValueDatabaseBackingStorage"
type_arguments
< "<"
type_identifier "T"
> ">"
declaration_list
{ "{"
type_item (+23 nodes collapsed)
function_item (+72 nodes collapsed)
function_item (+185 nodes collapsed)
function_item (+1764 nodes collapsed)
function_item (+50 nodes collapsed)
function_item (+350 nodes collapsed)
function_item (+325 nodes collapsed)
function_item (+483 nodes collapsed)
function_item (+35 nodes collapsed)
} "}"
function_item (+180 nodes collapsed)
function_item (+334 nodes collapsed)
function_item (+452 nodes collapsed)
type_item (+49 nodes collapsed)
attribute_item
# "#"
[ "["
attribute
identifier "cfg"
token_tree
( "("
identifier "feature"
= "="
string_literal
" "\""
string_content "print_cache_item_size"
" "\""
) ")"
] "]"
attribute_item
# "#"
[ "["
attribute
identifier "derive"
token_tree
( "("
identifier "Default"
) ")"
] "]"
struct_item (+21 nodes collapsed)
attribute_item
# "#"
[ "["
attribute
identifier "cfg"
token_tree
( "("
identifier "feature"
= "="
string_literal
" "\""
string_content "print_cache_item_size"
" "\""
) ")"
] "]"
impl_item (+156 nodes collapsed)
attribute_item
# "#"
[ "["
attribute
identifier "cfg"
token_tree
( "("
identifier "feature"
= "="
string_literal
" "\""
string_content "print_cache_item_size"
" "\""
) ")"
] "]"
function_item (+323 nodes collapsed)
function_item (+374 nodes collapsed)