aboutsummaryrefslogtreecommitdiffstats
path: root/ethtrie/slice.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-08-04 16:38:18 +0800
committerobscuren <geffobscura@gmail.com>2014-08-04 16:38:18 +0800
commit3debeb7236d2c8474fa9049cc91dc26bf1040b3f (patch)
tree928b5ff8486ea485a3efae8cc69adaf54af9c87e /ethtrie/slice.go
parent2e7cf835222274a311302c33498cf83bb2593b7a (diff)
downloaddexon-3debeb7236d2c8474fa9049cc91dc26bf1040b3f.tar
dexon-3debeb7236d2c8474fa9049cc91dc26bf1040b3f.tar.gz
dexon-3debeb7236d2c8474fa9049cc91dc26bf1040b3f.tar.bz2
dexon-3debeb7236d2c8474fa9049cc91dc26bf1040b3f.tar.lz
dexon-3debeb7236d2c8474fa9049cc91dc26bf1040b3f.tar.xz
dexon-3debeb7236d2c8474fa9049cc91dc26bf1040b3f.tar.zst
dexon-3debeb7236d2c8474fa9049cc91dc26bf1040b3f.zip
ethtrie.NewTrie => ethtrie.New
Diffstat (limited to 'ethtrie/slice.go')
-rw-r--r--ethtrie/slice.go12
1 files changed, 8 insertions, 4 deletions
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