Apply suggestions from code review

Co-authored-by: Daira Hopwood <daira@jacaranda.org>
This commit is contained in:
Greg Pfeil 2022-12-06 09:22:52 -07:00 committed by Greg Pfeil
parent 9c600a5582
commit 4cff6f80c6
1 changed files with 3 additions and 8 deletions

View File

@ -35,7 +35,7 @@ public:
// If ParseHex comes across a non-hex char, it will stop but still return results so far.
size_t slen = memoHex.length();
if (slen % 2 != 0 || (slen > 0 && rawMemo.size() != slen / 2)) {
if (slen != rawMemo.size() * 2) {
return MemoError::HexDecodeError;
}
@ -43,13 +43,8 @@ public:
return MemoError::MemoTooLong;
}
for (int i = 0; i < ZC_MEMO_SIZE; i++) {
if (i < rawMemo.size()) {
result.value[i] = rawMemo[i];
} else {
result.value[i] = 0x0;
}
}
auto rest = std::copy(rawMemo.begin(), rawMemo.end(), result.value.begin());
std::fill(rest, result.value.end(), 0);
return result;
}