MCPcopy Create free account
hub / github.com/PlatformLab/NanoLog / getSizeOfPackedValues

Function getSizeOfPackedValues

runtime/Packer.h:300–325  ·  view source on GitHub ↗

* Given a stream of nibbles, return the total number of bytes used to represent * the values encoded with the nibbles. * * \param nibbles * The start of the nibbles * \param numNibbles * Number of nibbles to process * * \return * The number of bytes encoded used to encode the values */

Source from the content-addressed store, hash-verified

298 * The number of bytes encoded used to encode the values
299 */
300inline static uint32_t
301getSizeOfPackedValues(const TwoNibbles *nibbles, uint32_t numNibbles)
302{
303 uint32_t size = 0;
304 for (uint32_t i = 0; i < numNibbles/2; ++i) {
305 size += nibbles[i].first + nibbles[i].second;
306 if (nibbles[i].first == 0)
307 size += 16;
308 if (nibbles[i].first > 0x8)
309 size -= 8;
310 if (nibbles[i].second == 0)
311 size += 16;
312 if (nibbles[i].second > 0x8)
313 size -= 8;
314 }
315
316 if (numNibbles & 0x1) {
317 size += nibbles[numNibbles / 2].first;
318 if (nibbles[numNibbles/2].first == 0)
319 size += 16;
320 if (nibbles[numNibbles/2].first > 0x8)
321 size -= 8;
322 }
323
324 return size;
325}
326
327/**
328 * This class takes in a data stream of pack() Nibbles followed by pack()'ed

Callers 2

TEST_FFunction · 0.85
NibblerMethod · 0.85

Calls

no outgoing calls

Tested by 1

TEST_FFunction · 0.68