ethtrie.NewTrie => ethtrie.New

This commit is contained in:
obscuren
2014-08-04 10:38:18 +02:00
parent 2e7cf83522
commit 3debeb7236
8 changed files with 52 additions and 82 deletions

View File

@ -1,6 +1,6 @@
package ethtrie
import ()
import "math"
// Helper function for comparing slices
func CompareIntSlice(a, b []int) bool {
@ -17,9 +17,13 @@ func CompareIntSlice(a, b []int) bool {
// Returns the amount of nibbles that match each other from 0 ...
func MatchingNibbleLength(a, b []int) int {
i := 0
for CompareIntSlice(a[:i+1], b[:i+1]) && i < len(b) {
i += 1
var i, length = 0, int(math.Min(float64(len(a)), float64(len(b))))
for i < length {
if a[i] != b[i] {
break
}
i++
}
return i