From 3debeb7236d2c8474fa9049cc91dc26bf1040b3f Mon Sep 17 00:00:00 2001 From: obscuren Date: Mon, 4 Aug 2014 10:38:18 +0200 Subject: ethtrie.NewTrie => ethtrie.New --- ethtrie/slice.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'ethtrie/slice.go') diff --git a/ethtrie/slice.go b/ethtrie/slice.go index b9d5d1285..cf4e8df7a 100644 --- a/ethtrie/slice.go +++ b/ethtrie/slice.go @@ -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 -- cgit