MCPcopy Index your code
hub / github.com/google/codesearch / writeUvarint

Method writeUvarint

index/write.go:561–577  ·  view source on GitHub ↗
(x uint32)

Source from the content-addressed store, hash-verified

559}
560
561func (b *bufWriter) writeUvarint(x uint32) {
562 if cap(b.buf)-len(b.buf) < 5 {
563 b.flush()
564 }
565 switch {
566 case x < 1<<7:
567 b.buf = append(b.buf, byte(x))
568 case x < 1<<14:
569 b.buf = append(b.buf, byte(x|0x80), byte(x>>7))
570 case x < 1<<21:
571 b.buf = append(b.buf, byte(x|0x80), byte(x>>7|0x80), byte(x>>14))
572 case x < 1<<28:
573 b.buf = append(b.buf, byte(x|0x80), byte(x>>7|0x80), byte(x>>14|0x80), byte(x>>21))
574 default:
575 b.buf = append(b.buf, byte(x|0x80), byte(x>>7|0x80), byte(x>>14|0x80), byte(x>>21|0x80), byte(x>>28))
576 }
577}
578
579// validUTF8 reports whether the byte pair can appear in a
580// valid sequence of UTF-8-encoded code points.

Callers 3

fileidMethod · 0.80
endTrigramMethod · 0.80
mergePostMethod · 0.80

Calls 1

flushMethod · 0.95

Tested by

no test coverage detected