mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-02 09:30:11 +01:00
Reduce heap pressure on getPacketContents
Reviewed-by: Aaron Ruby <aruby@blackberry.com> Acked-by: Yonggang Luo <luoyonggang@gmail.com> Acked-by: Adam Jackson <ajax@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27246>
This commit is contained in:
parent
092dbc32ab
commit
bb2e9be160
1 changed files with 8 additions and 7 deletions
|
|
@ -81,11 +81,12 @@ bool VkEncoder::decRef() {
|
|||
}
|
||||
|
||||
std::string VkEncoder::getPacketContents(const uint8_t* ptr, size_t len) {
|
||||
std::string result;
|
||||
std::unique_ptr<char[]> buf(new char[3]);
|
||||
for (size_t i = 0; i < len; i++) {
|
||||
std::snprintf(buf.get(), 3, "%02X", ptr[i]);
|
||||
result += " " + std::string(buf.get(), buf.get() + 2);
|
||||
}
|
||||
return result;
|
||||
std::string result;
|
||||
result.reserve(3 * len);
|
||||
char buf[4];
|
||||
for (size_t i = 0; i < len; i++) {
|
||||
std::snprintf(buf, 4, " %02X", ptr[i]);
|
||||
result.append(buf, 3);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue