github.com/kelleygo/clashcore@v1.0.2/transport/gun/utils.go (about)

     1  package gun
     2  
     3  func UVarintLen(x uint64) int {
     4  	switch {
     5  	case x < 1<<(7*1):
     6  		return 1
     7  	case x < 1<<(7*2):
     8  		return 2
     9  	case x < 1<<(7*3):
    10  		return 3
    11  	case x < 1<<(7*4):
    12  		return 4
    13  	case x < 1<<(7*5):
    14  		return 5
    15  	case x < 1<<(7*6):
    16  		return 6
    17  	case x < 1<<(7*7):
    18  		return 7
    19  	case x < 1<<(7*8):
    20  		return 8
    21  	case x < 1<<(7*9):
    22  		return 9
    23  	default:
    24  		return 10
    25  	}
    26  }