[ox/std] Fix code duplication
This commit is contained in:
parent
bb85e6ab6c
commit
20e5b7e617
25
deps/ox/src/ox/std/uuid.hpp
vendored
25
deps/ox/src/ox/std/uuid.hpp
vendored
@ -175,28 +175,9 @@ class UUID {
|
||||
[[nodiscard]]
|
||||
constexpr UUIDStr toString() const noexcept {
|
||||
UUIDStr out;
|
||||
auto valueI = 0u;
|
||||
constexpr auto printChars = [](
|
||||
UUIDStr *out,
|
||||
const Array<uint8_t, 16> &value,
|
||||
std::size_t cnt,
|
||||
unsigned &valueI) {
|
||||
for (auto i = 0u; i < cnt; ++i) {
|
||||
const auto v = value[valueI];
|
||||
const auto h = detail::toHex(v);
|
||||
oxIgnoreError(out->append(h.c_str(), h.len()));
|
||||
++valueI;
|
||||
}
|
||||
};
|
||||
printChars(&out, m_value, 4, valueI);
|
||||
out += "-";
|
||||
printChars(&out, m_value, 2, valueI);
|
||||
out += "-";
|
||||
printChars(&out, m_value, 2, valueI);
|
||||
out += "-";
|
||||
printChars(&out, m_value, 2, valueI);
|
||||
out += "-";
|
||||
printChars(&out, m_value, 6, valueI);
|
||||
ox::CharBuffWriter bw(out.data(), out.cap());
|
||||
oxIgnoreError(toString(bw));
|
||||
out[out.cap()] = 0;
|
||||
return out;
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user