Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试编写自己的 Protobuf 帧解码器,并以此为基础:
https://github.com/netty/netty/blob/master/codec/src/main/java/io/netty/handler/codec/protobuf/ProtobufVarint32FrameDecoder.java
我只是想知道为什么它会创建new byte[5];
new byte[5];
它不只需要读取第一个字节即可获得长度。为什么需要for循环?
因为长度表示为可变长度字段,如此处所述。