File tree Expand file tree Collapse file tree 1 file changed +3
-18
lines changed Expand file tree Collapse file tree 1 file changed +3
-18
lines changed Original file line number Diff line number Diff line change @@ -171,24 +171,9 @@ uint64_t vdi::littleEndianToInt(const char *buffer, uint8_t size) {
171
171
throw std::invalid_argument (" 'size' should never be greater than 8" );
172
172
}
173
173
174
- // save existing stringstream settings (to restore later)
175
- std::ios_base::fmtflags oldFlags (std::stringstream ().flags ());
176
-
177
- // stringstream to store buffer in reverse order
178
- std::stringstream ss;
179
-
180
- // loop through buffer in reverse
181
- for (int8_t i = size - 1 ; i != -1 ; --i) {
182
- // concatenate each character in buffer as hex to the stringstream
183
- ss << std::hex << std::setw (2 ) << std::setfill (' 0' ) << (int )(uint8_t )buffer[i];
184
- }
185
-
186
- // store resulting stringstream as int
187
- int result;
188
- ss >> result;
189
-
190
- // restore stringstream settings
191
- std::stringstream ().flags (oldFlags);
174
+ // copy the buffer memory into a 64-bit int
175
+ uint64_t result;
176
+ memcpy (&result, buffer, size);
192
177
193
178
return result;
194
179
}
You can’t perform that action at this time.
0 commit comments