mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-12-25 11:54:25 +08:00
27 lines
361 B
Go
27 lines
361 B
Go
package gun
|
|
|
|
func UVarintLen(x uint64) int {
|
|
switch {
|
|
case x < 1<<(7*1):
|
|
return 1
|
|
case x < 1<<(7*2):
|
|
return 2
|
|
case x < 1<<(7*3):
|
|
return 3
|
|
case x < 1<<(7*4):
|
|
return 4
|
|
case x < 1<<(7*5):
|
|
return 5
|
|
case x < 1<<(7*6):
|
|
return 6
|
|
case x < 1<<(7*7):
|
|
return 7
|
|
case x < 1<<(7*8):
|
|
return 8
|
|
case x < 1<<(7*9):
|
|
return 9
|
|
default:
|
|
return 10
|
|
}
|
|
}
|