Source file src/vendor/golang.org/x/net/internal/http3/varint.go

     1  // Copyright 2026 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package http3
     6  
     7  // sizeVarint returns the size of the variable-length integer encoding of f.
     8  // Copied from internal/quic/quicwire to break dependency that makes bundling
     9  // into std more complicated.
    10  func sizeVarint(v uint64) int {
    11  	switch {
    12  	case v <= 63:
    13  		return 1
    14  	case v <= 16383:
    15  		return 2
    16  	case v <= 1073741823:
    17  		return 4
    18  	case v <= 4611686018427387903:
    19  		return 8
    20  	default:
    21  		panic("varint too large")
    22  	}
    23  }
    24  

View as plain text