(x uint32)
| 559 | } |
| 560 | |
| 561 | func (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. |
no test coverage detected