Skip to content

Commit

Permalink
internal/core/export: use cue/token.Pos.Compare
Browse files Browse the repository at this point in the history
A pretty straightforward code reuse, given that both sort by
filename and then offset.

Signed-off-by: Daniel Martí <[email protected]>
Change-Id: I48878f9fc2c645134e2b1d4d7bd68c9ef2af9359
Dispatch-Trailer: {"type":"trybot","CL":1206369,"patchset":2,"ref":"refs/changes/69/1206369/2","targetBranch":"master"}
  • Loading branch information
mvdan authored and cueckoo committed Dec 27, 2024
1 parent 31b4380 commit 4e6c35a
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions internal/core/export/adt.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,18 +365,7 @@ func cmpLeafNodes[T adt.Node](a, b T) int {
return 0
}

posA := srcA.Pos()
posB := srcB.Pos()

if c := cmp.Compare(posA.Filename(), posB.Filename()); c != 0 {
return c
}

if c := cmp.Compare(posA.Offset(), posB.Offset()); c != 0 {
return c
}

return 0
return srcA.Pos().Compare(srcB.Pos())
}

func typeOrder(x adt.Node) int {
Expand Down

0 comments on commit 4e6c35a

Please sign in to comment.