Skip to content

Compare plain types without per-node bookkeeping - #416

Open
mvdan wants to merge 1 commit into
google:masterfrom
mvdan:fast-equal
Open

mvdan wants to merge 1 commit into
google:masterfrom
mvdan:fast-equal

Conversation

@mvdan

@mvdan mvdan commented Oct 21, 2026

Copy link
Copy Markdown

(see commit message)

When no options or reporters are used, values whose types cannot reach
an Equal method, an interface, an unexported struct field, a map key
which may be NaN, or a recursive type are now compared directly,
following the same rules as compareAny but without path steps, cycle
detection, option filtering, or the slice difference algorithm.
Diff still builds its report with the full machinery.

As suggested in google#353, this applies only when no option could apply.
Comparing equal slices of 1000 small structs drops from 2051
allocations to none, and a 4KiB byte slice from 67 to none.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant