MCPcopy Create free account
hub / github.com/Tencent/MMKV / readRawVarint32

Method readRawVarint32

Core/CodedInputData.cpp:179–211  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

177}
178
179int32_t CodedInputData::readRawVarint32() {
180 int8_t tmp = this->readRawByte();
181 if (tmp >= 0) {
182 return tmp;
183 }
184 int32_t result = tmp & 0x7f;
185 if ((tmp = this->readRawByte()) >= 0) {
186 result |= tmp << 7;
187 } else {
188 result |= (tmp & 0x7f) << 7;
189 if ((tmp = this->readRawByte()) >= 0) {
190 result |= tmp << 14;
191 } else {
192 result |= (tmp & 0x7f) << 14;
193 if ((tmp = this->readRawByte()) >= 0) {
194 result |= tmp << 21;
195 } else {
196 result |= (tmp & 0x7f) << 21;
197 result |= (tmp = this->readRawByte()) << 28;
198 if (tmp < 0) {
199 // discard upper 32 bits
200 for (int i = 0; i < 5; i++) {
201 if (this->readRawByte() >= 0) {
202 return result;
203 }
204 }
205 throw invalid_argument("InvalidProtocolBuffer malformed varint32");
206 }
207 }
208 }
209 }
210 return result;
211}
212
213int32_t CodedInputData::readRawLittleEndian32() {
214 int8_t b1 = this->readRawByte();

Callers 6

readInt32Method · 0.95
readBoolMethod · 0.95
readStringMethod · 0.95
readDataMethod · 0.95
readNSStringMethod · 0.95
readNSDataMethod · 0.95

Calls 1

readRawByteMethod · 0.95

Tested by

no test coverage detected