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

Function EncodeFixed32

src/leveldb/util/coding.h:62–78  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

60// REQUIRES: dst has enough space for the value being written
61
62inline void EncodeFixed32(char* dst, uint32_t value) {
63 uint8_t* const buffer = reinterpret_cast<uint8_t*>(dst);
64
65 if (port::kLittleEndian) {
66 // Fast path for little-endian CPUs. All major compilers optimize this to a
67 // single mov (x86_64) / str (ARM) instruction.
68 std::memcpy(buffer, &value, sizeof(uint32_t));
69 return;
70 }
71
72 // Platform-independent code.
73 // Currently, only gcc optimizes this to a single mov / str instruction.
74 buffer[0] = static_cast<uint8_t>(value);
75 buffer[1] = static_cast<uint8_t>(value >> 8);
76 buffer[2] = static_cast<uint8_t>(value >> 16);
77 buffer[3] = static_cast<uint8_t>(value >> 24);
78}
79
80inline void EncodeFixed64(char* dst, uint64_t value) {
81 uint8_t* const buffer = reinterpret_cast<uint8_t*>(dst);

Callers 6

WriteRawBlockMethod · 0.85
KeyFunction · 0.85
PutFixed32Function · 0.85
SetCountMethod · 0.85
FixChecksumMethod · 0.85
EmitPhysicalRecordMethod · 0.85

Calls

no outgoing calls

Tested by 2

KeyFunction · 0.68
FixChecksumMethod · 0.68