improve span

master v1.0.2
Avril 4 years ago
parent 3aaf09031e
commit 96795c0f91
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -19,12 +19,16 @@ namespace hv
inline T& operator[](std::size_t index) inline T& operator[](std::size_t index)
{ {
#ifdef DEBUG
if (index>=len) throw "tried to index out of bounds of array"; if (index>=len) throw "tried to index out of bounds of array";
#endif
return ptr[index]; return ptr[index];
} }
inline const T& operator[](std::size_t index) const inline const T& operator[](std::size_t index) const
{ {
#ifdef DEBUG
if (index>=len) throw "tried to index out of bounds of array"; if (index>=len) throw "tried to index out of bounds of array";
#endif
return ptr[index]; return ptr[index];
} }

@ -69,19 +69,21 @@ namespace hv {
#define S #define S
#endif #endif
fmt::print("0x{:016x} ", offset); fmt::print("0x{:016x} ", offset);
char hxbuf[3];
std::size_t i=0;
char ascii[1 + ROW_SZ]; char ascii[1 + ROW_SZ];
ascii[ROW_SZ] = 0; ascii[ROW_SZ] = 0;
std::size_t i=0;
char hxbuf[3];
hxbuf[2] = 0; hxbuf[2] = 0;
for(;i<memory.size();i++) { for(;i<memory.size();i++) {
if (i && i % ROW_SZ == 0) { if (i && i % ROW_SZ == 0) {
prints(" ", S ascii); prints(" ", S ascii);
fmt::print("\n0x{:016x} ", i+offset); fmt::print("\n0x{:016x} ", i+offset);
} }
hex02(memory[i], hxbuf); unsigned char idx = memory[i];
hex02(idx, hxbuf);
prints(hxbuf, " "); prints(hxbuf, " ");
ascii[i%ROW_SZ] = ascii_map[memory[i]]; ascii[i%ROW_SZ] = ascii_map[idx];
} }
if (memory.size() % ROW_SZ != 0) if (memory.size() % ROW_SZ != 0)
{ {

Loading…
Cancel
Save