vulncheck: remove additional meaningless string sorting for stacks

String ordering on stacks was employed for deterministic output which
cannot happen anyhow since the initial slice of stacks is not
determinstic. The string comparison is expensive, especially for large
vulnerability graphs.

This shaves off approx. 15-20 seconds for k8s and vault projects.

Change-Id: I3c4502b948eb32ebf2c4705097c70e3928bbf3de
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/410897
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
Reviewed-by: Julie Qiu <julieqiu@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
diff --git a/vulncheck/witness.go b/vulncheck/witness.go
index d642308..c46a8fd 100644
--- a/vulncheck/witness.go
+++ b/vulncheck/witness.go
@@ -6,7 +6,6 @@
 
 import (
 	"container/list"
-	"fmt"
 	"sort"
 	"strings"
 	"sync"
@@ -280,26 +279,10 @@
 	if w1, w2 := weight(s1), weight(s2); w1 != w2 {
 		return w1 < w2
 	}
-	// At this point we just need to make sure the ordering is deterministic.
-	// TODO(zpavlinovic): is there a more meaningful additional ordering?
-	return stackStrLess(s1, s2)
-}
 
-// stackStrLess compares string representation of stacks.
-func stackStrLess(s1, s2 CallStack) bool {
-	// Creates a unique string representation of a call stack
-	// for comparison purposes only.
-	stackStr := func(stack CallStack) string {
-		var stackStr []string
-		for _, cs := range stack {
-			s := cs.Function.String()
-			if cs.Call != nil && cs.Call.Pos != nil {
-				p := cs.Call.Pos
-				s = fmt.Sprintf("%s[%s:%d:%d:%d]", s, p.Filename, p.Line, p.Column, p.Offset)
-			}
-			stackStr = append(stackStr, s)
-		}
-		return strings.Join(stackStr, "->")
-	}
-	return strings.Compare(stackStr(s1), stackStr(s2)) <= 0
+	// At this point, the stableness/determinism of
+	// sorting is guaranteed by the determinism of
+	// the underlying call graph and the call stack
+	// search algorithm.
+	return true
 }