Simplify and speed up GDSII diffs
Summarize added and removed cells, group references, and keep replacement pairs together at text display limits. Trim hierarchy labels and summarize long unmatched paths. Stream JSON object evidence and reduce parsing and comparison allocations. Parse large revisions concurrently and adaptively reuse matching cell bodies when most of the layout is shared.
This commit is contained in:
parent
15e8a3b7b5
commit
8efeb04aab
1 changed files with 1137 additions and 261 deletions
|
|
@ -28,6 +28,9 @@ fn group(object: &ObjectChange, bounds: bool) -> Group {
|
|||
/// Pair only unique candidates in the remaining multisets. Ambiguous groups
|
||||
/// remain additions/removals; no identity or geometric equivalence is inferred.
|
||||
pub(super) fn replacements(old: &[ObjectChange], new: &[ObjectChange]) -> Vec<Replacement> {
|
||||
if old.is_empty() || new.is_empty() {
|
||||
return Vec::new();
|
||||
}
|
||||
let (mut used_old, mut used_new) = (BTreeSet::new(), BTreeSet::new());
|
||||
let mut result = Vec::new();
|
||||
for bounds in [true, false] {
|
||||
|
|
@ -101,7 +104,7 @@ fn object_heading(object: &ObjectChange, kind: &str) -> String {
|
|||
}
|
||||
}
|
||||
|
||||
fn polygon_xy(object: &ObjectChange) -> &[u8] {
|
||||
fn object_xy(object: &ObjectChange) -> &[u8] {
|
||||
object
|
||||
.fields
|
||||
.iter()
|
||||
|
|
@ -109,6 +112,27 @@ fn polygon_xy(object: &ObjectChange) -> &[u8] {
|
|||
.map_or(&[], |field| field.data.as_slice())
|
||||
}
|
||||
|
||||
pub(super) fn write_unmatched(out: &mut String, sign: &str, object: &ObjectChange) {
|
||||
if object.kind == RTAG_PATH
|
||||
&& let Some([xmin, ymin, xmax, ymax]) = object.bounds
|
||||
{
|
||||
let vertices = XY::points(object_xy(object)).len();
|
||||
if vertices > POINTS_PER_LINE {
|
||||
let heading = object_heading(object, "path");
|
||||
let width = object
|
||||
.width
|
||||
.map_or_else(|| "absent".to_string(), |width| format!("{width} dbu"));
|
||||
writeln!(
|
||||
out,
|
||||
" {sign} {heading} · width {width} · {vertices} vertices · bounds ({xmin}, {ymin}) to ({xmax}, {ymax}) dbu"
|
||||
)
|
||||
.unwrap();
|
||||
return;
|
||||
}
|
||||
}
|
||||
writeln!(out, " {sign} {object}").unwrap();
|
||||
}
|
||||
|
||||
fn vertex_count(xy: &[u8]) -> usize {
|
||||
XY::points(xy).len().saturating_sub(1)
|
||||
}
|
||||
|
|
@ -147,7 +171,7 @@ struct ShapeCounts {
|
|||
impl ShapeCounts {
|
||||
fn add(&mut self, object: &ObjectChange, replacement: Option<&ObjectChange>) {
|
||||
let is_rectangle =
|
||||
|object: &ObjectChange| XY::closed_rectangle(polygon_xy(object)).is_some();
|
||||
|object: &ObjectChange| XY::closed_rectangle(object_xy(object)).is_some();
|
||||
match object.kind {
|
||||
RTAG_BOX => self.boxes += 1,
|
||||
_ if is_rectangle(object) && replacement.is_none_or(is_rectangle) => {
|
||||
|
|
@ -173,7 +197,7 @@ impl PolygonChanges {
|
|||
pub fn replacement(&mut self, old: &ObjectChange, new: &ObjectChange) {
|
||||
let counts = self.0.entry(old.layer).or_default();
|
||||
let moved = old.properties == new.properties
|
||||
&& translation(polygon_xy(old), polygon_xy(new)).is_some()
|
||||
&& translation(object_xy(old), object_xy(new)).is_some()
|
||||
&& field_changes(old, new).all(|(tag, _, _)| tag == RTAG_XY);
|
||||
let shapes = if moved {
|
||||
&mut counts.moved
|
||||
|
|
@ -237,6 +261,10 @@ pub(super) struct ReferenceCounts {
|
|||
}
|
||||
|
||||
impl ReferenceCounts {
|
||||
pub fn len(&self) -> usize {
|
||||
self.singles + self.arrays
|
||||
}
|
||||
|
||||
pub fn add(&mut self, object: &ObjectChange) {
|
||||
if object.kind == RTAG_AREF {
|
||||
self.arrays += 1;
|
||||
|
|
@ -272,8 +300,8 @@ impl ReferenceCounts {
|
|||
}
|
||||
|
||||
fn polygon_replacement(old: &ObjectChange, new: &ObjectChange) -> String {
|
||||
let before = polygon_xy(old);
|
||||
let after = polygon_xy(new);
|
||||
let before = object_xy(old);
|
||||
let after = object_xy(new);
|
||||
let old_size = rectangle_size(before);
|
||||
let new_size = rectangle_size(after);
|
||||
let mut out = polygon_heading(old, old_size.is_some() && new_size.is_some());
|
||||
|
|
|
|||
Loading…
Reference in a new issue