From 4e6c35af703ca57ae972c97a09ffce5e47a5c1e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Fri, 27 Dec 2024 09:05:03 +0000 Subject: [PATCH] internal/core/export: use cue/token.Pos.Compare MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A pretty straightforward code reuse, given that both sort by filename and then offset. Signed-off-by: Daniel Martí Change-Id: I48878f9fc2c645134e2b1d4d7bd68c9ef2af9359 Dispatch-Trailer: {"type":"trybot","CL":1206369,"patchset":2,"ref":"refs/changes/69/1206369/2","targetBranch":"master"} --- internal/core/export/adt.go | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/internal/core/export/adt.go b/internal/core/export/adt.go index f623cccf1..c7b8b7085 100644 --- a/internal/core/export/adt.go +++ b/internal/core/export/adt.go @@ -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 {