[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]]
|
[[nodiscard]]
|
||||||
constexpr UUIDStr toString() const noexcept {
|
constexpr UUIDStr toString() const noexcept {
|
||||||
UUIDStr out;
|
UUIDStr out;
|
||||||
auto valueI = 0u;
|
ox::CharBuffWriter bw(out.data(), out.cap());
|
||||||
constexpr auto printChars = [](
|
oxIgnoreError(toString(bw));
|
||||||
UUIDStr *out,
|
out[out.cap()] = 0;
|
||||||
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);
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user