mirror of
https://github.com/ocornut/imgui.git
synced 2026-01-18 01:14:19 +00:00
ImGuiTextBuffer: Avoid heap allocation when empty.
This commit is contained in:
parent
1efafa1d29
commit
d02b11dfbd
3 changed files with 18 additions and 12 deletions
|
|
@ -1956,6 +1956,8 @@ bool ImGuiTextFilter::PassFilter(const char* text, const char* text_end) const
|
|||
#endif
|
||||
#endif
|
||||
|
||||
char ImGuiTextBuffer::EmptyString[1] = { 0 };
|
||||
|
||||
// Helper: Text buffer for logging/accumulating text
|
||||
void ImGuiTextBuffer::appendfv(const char* fmt, va_list args)
|
||||
{
|
||||
|
|
@ -1969,7 +1971,8 @@ void ImGuiTextBuffer::appendfv(const char* fmt, va_list args)
|
|||
return;
|
||||
}
|
||||
|
||||
const int write_off = Buf.Size;
|
||||
// Add zero-terminator the first time
|
||||
const int write_off = (Buf.Size != 0) ? Buf.Size : 1;
|
||||
const int needed_sz = write_off + len;
|
||||
if (write_off + len >= Buf.Capacity)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue