Reuse settled TeX suffixes after physical line edits
This commit is contained in:
1 parent
5b86a7ac7e
commit
ac5f691a48
15 files changed
+518
-30
No files matched your search
@@ -193,6 +193,25 @@ impl EntryCheckpoint {
|
||||
None if self.frontier == prior.frontier => None,
|
||||
None => return None,
|
||||
};
|
||||
let observes_entry_line = completed.line_observations.as_ref().is_none_or(|observations| {
|
||||
observations.get(&self.entry) != old.line_observations.get(&self.entry)
|
||||
});
|
||||
if observes_entry_line
|
||||
&& relocation.as_ref().map_or_else(
|
||||
|| !SourceRelocation::same_line_breaks(previous_bytes, current_bytes),
|
||||
SourceRelocation::changes_line_numbers,
|
||||
)
|
||||
{
|
||||
// The old line number can be embedded in outputs. Equal byte
|
||||
// offsets can also mean different lines if a newline moved.
|
||||
return None;
|
||||
}
|
||||
let line_observations = match &completed.line_observations {
|
||||
Some(later) => Some(splice_line_observations(
|
||||
¤t.line_observations, &old.line_observations, later,
|
||||
)?),
|
||||
None => None,
|
||||
};
|
||||
// Comparison and publication visit some of the same original
|
||||
// allocations. Keep the checked relocations for this donor only.
|
||||
let mut moved = relocation.as_ref().map(EventRelocation::new);
|
||||
@@ -240,6 +259,7 @@ impl EntryCheckpoint {
|
||||
stream_sources: completed.stream_sources.clone(),
|
||||
generated_inputs: completed.generated_inputs.clone(),
|
||||
reads: completed.reads.clone(),
|
||||
line_observations,
|
||||
incoming_state: completed.incoming_state,
|
||||
outgoing_state: completed.outgoing_state,
|
||||
steps,
|
||||
@@ -344,6 +364,9 @@ impl EntryCheckpoint {
|
||||
}
|
||||
|
||||
let mut executor = next.clone();
|
||||
executor.line_observations = splice_line_observations(
|
||||
¤t.line_observations, &old.line_observations, &next.line_observations,
|
||||
)?;
|
||||
let mut events = prefix.clone();
|
||||
// Checkpoint capture seals the event log. Share the old suffix
|
||||
// chunks so all carried checkpoints keep the same allocation graph.
|
||||
@@ -400,6 +423,26 @@ fn measure<T>(elapsed: Option<&mut Duration>, action: impl FnOnce() -> T) -> T {
|
||||
value
|
||||
}
|
||||
|
||||
// Counts describe reads observed on a particular execution history.
|
||||
fn splice_line_observations(
|
||||
current: &BTreeMap<usize, usize>,
|
||||
prior: &BTreeMap<usize, usize>,
|
||||
later: &BTreeMap<usize, usize>,
|
||||
) -> Option<BTreeMap<usize, usize>> {
|
||||
if prior.keys().any(|source| !later.contains_key(source)) {
|
||||
return None;
|
||||
}
|
||||
let mut combined = current.clone();
|
||||
for (&source, &count) in later {
|
||||
let suffix = count.checked_sub(prior.get(&source).copied().unwrap_or_default())?;
|
||||
if suffix != 0 {
|
||||
let total = combined.entry(source).or_default();
|
||||
*total = total.checked_add(suffix)?;
|
||||
}
|
||||
}
|
||||
Some(combined)
|
||||
}
|
||||
|
||||
fn offset_event_steps(event: &Event, offset: StepOffset) -> Option<Event> {
|
||||
match event {
|
||||
Event::Statistics(report) => Some(Event::Statistics(Box::new(report.with_step_offset(offset)?))),
|
||||
@@ -469,7 +512,6 @@ fn same_kernel_continuation(
|
||||
restored_pdf_image_count,
|
||||
format_image_warnings,
|
||||
pdf_force_pagebox_warned,
|
||||
input_position,
|
||||
box_nodes_created,
|
||||
material_charge,
|
||||
mark_cells_created,
|
||||
@@ -492,6 +534,8 @@ fn same_kernel_continuation(
|
||||
generated_inputs,
|
||||
conditionals,
|
||||
current,
|
||||
input_position,
|
||||
line_observations,
|
||||
pdf_catalog_tokens,
|
||||
pdf_outlines,
|
||||
pdf_info_tokens,
|
||||
@@ -548,6 +592,7 @@ fn same_kernel_continuation(
|
||||
&& current.generated_inputs == prior.generated_inputs
|
||||
&& current.conditionals == prior.conditionals
|
||||
&& current.current == prior.current
|
||||
&& current.input_position == prior.input_position
|
||||
&& current.pdf_catalog_tokens == prior.pdf_catalog_tokens
|
||||
&& current.pdf_outlines == prior.pdf_outlines
|
||||
&& current.pdf_info_tokens == prior.pdf_info_tokens
|
||||
|
||||
Reference in new issue
Block a user