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

Method readRawVarint32

Core/CodedInputDataCrypt.cpp:180–214  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 4

readInt32Method · 0.95
readStringMethod · 0.95
readDataMethod · 0.95
readNSStringMethod · 0.95

Calls 1

readRawByteMethod · 0.95

Tested by

no test coverage detected