From 59654d9c3a8fdc14ec33ef0f1a1547c6ec956de8 Mon Sep 17 00:00:00 2001 From: cuiweixie Date: Mon, 20 Oct 2025 21:46:49 +0800 Subject: [PATCH] trie: simplify code --- trie/encoding.go | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/trie/encoding.go b/trie/encoding.go index 4cd29f531a..cd5ac5f611 100644 --- a/trie/encoding.go +++ b/trie/encoding.go @@ -138,16 +138,13 @@ func decodeNibbles(nibbles []byte, bytes []byte) { // prefixLen returns the length of the common prefix of a and b. func prefixLen(a, b []byte) int { - var i, length = 0, len(a) - if len(b) < length { - length = len(b) - } - for ; i < length; i++ { + n := min(len(a), len(b)) + for i := range n { if a[i] != b[i] { - break + return i } } - return i + return n } // hasTerm returns whether a hex key has the terminator flag.