MCPcopy Create free account
hub / github.com/ElementsProject/elements / DecodeFixed32

Function DecodeFixed32

src/leveldb/util/coding.h:105–122  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

103// without any bounds checking.
104
105inline uint32_t DecodeFixed32(const char* ptr) {
106 const uint8_t* const buffer = reinterpret_cast<const uint8_t*>(ptr);
107
108 if (port::kLittleEndian) {
109 // Fast path for little-endian CPUs. All major compilers optimize this to a
110 // single mov (x86_64) / ldr (ARM) instruction.
111 uint32_t result;
112 std::memcpy(&result, buffer, sizeof(uint32_t));
113 return result;
114 }
115
116 // Platform-independent code.
117 // Clang and gcc optimize this to a single mov / ldr instruction.
118 return (static_cast<uint32_t>(buffer[0])) |
119 (static_cast<uint32_t>(buffer[1]) << 8) |
120 (static_cast<uint32_t>(buffer[2]) << 16) |
121 (static_cast<uint32_t>(buffer[3]) << 24);
122}
123
124inline uint64_t DecodeFixed64(const char* ptr) {
125 const uint8_t* const buffer = reinterpret_cast<const uint8_t*>(ptr);

Callers 13

FilterBlockReaderMethod · 0.85
KeyMayMatchMethod · 0.85
KeyMayMatchMethod · 0.85
NumRestartsMethod · 0.85
GetRestartPointMethod · 0.85
DecodeFromMethod · 0.85
ReadBlockFunction · 0.85
TESTFunction · 0.85
ReadUint32LEFunction · 0.85
HashFunction · 0.85
DecodeKeyFunction · 0.85
CountMethod · 0.85

Calls

no outgoing calls

Tested by 3

KeyMayMatchMethod · 0.68
TESTFunction · 0.68
DecodeKeyFunction · 0.68