MCPcopy
hub / github.com/google/mangle / hashTerm

Function hashTerm

ast/ast.go:1317–1335  ·  view source on GitHub ↗
(s string, args []BaseTerm)

Source from the content-addressed store, hash-verified

1315}
1316
1317func hashTerm(s string, args []BaseTerm) uint64 {
1318 h := fnv.New64()
1319 h.Write([]byte(s))
1320 for _, arg := range args {
1321 switch c := arg.(type) {
1322 case Constant:
1323 b := make([]byte, 8)
1324 binary.LittleEndian.PutUint64(b, c.Hash())
1325 h.Write(b)
1326 case Variable:
1327 h.Write([]byte(c.String()))
1328 case ApplyFn:
1329 b := make([]byte, 8)
1330 binary.LittleEndian.PutUint64(b, c.Hash())
1331 h.Write(b)
1332 }
1333 }
1334 return h.Sum64()
1335}
1336
1337// FreshVariable returns a variable different from the ones in used.
1338func FreshVariable(used map[Variable]bool) Variable {

Callers 3

HashMethod · 0.85
HashMethod · 0.85
HashMethod · 0.85

Calls 2

HashMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected