MCPcopy Index your code
hub / github.com/google/mangle / SortIndexInto

Function SortIndexInto

ast/ast.go:1456–1463  ·  view source on GitHub ↗

SortIndexInto sorts s and populates the index and hashes slice.

(keys []*Constant, index []int)

Source from the content-addressed store, hash-verified

1454
1455// SortIndexInto sorts s and populates the index and hashes slice.
1456func SortIndexInto(keys []*Constant, index []int) {
1457 hashes := make([]uint64, len(keys))
1458 for i := 0; i < len(keys); i++ {
1459 index[i] = i
1460 hashes[i] = keys[i].Hash()
1461 }
1462 sort.Stable(&keysorter{keys, hashes, index})
1463}
1464
1465// Helper to sort []*Constant by it's Hash().
1466type keysorter struct {

Callers 3

MapFunction · 0.85
StructFunction · 0.85
TestSortIndexIntoFunction · 0.85

Calls 1

HashMethod · 0.65

Tested by 1

TestSortIndexIntoFunction · 0.68