1
0
mirror of https://github.com/ocornut/imgui.git synced 2024-11-25 00:00:40 +01:00

InputText(): removed a call to strlen() in the active edit path (#200)

This commit is contained in:
ocornut 2015-06-18 20:49:20 -06:00
parent 2b68a5c0cf
commit b524c59c70

View File

@ -6539,10 +6539,7 @@ static ImVec2 InputTextCalcTextSizeW(const ImWchar* text_begin, const ImWchar* t
const ImWchar* s = text_begin; const ImWchar* s = text_begin;
while (s < text_end) while (s < text_end)
{ {
const unsigned int c = (unsigned int)(*s++); unsigned int c = (unsigned int)(*s++);
if (c < 32)
{
if (c == '\n') if (c == '\n')
{ {
text_size.x = ImMax(text_size.x, line_width); text_size.x = ImMax(text_size.x, line_width);
@ -6554,7 +6551,6 @@ static ImVec2 InputTextCalcTextSizeW(const ImWchar* text_begin, const ImWchar* t
} }
if (c == '\r') if (c == '\r')
continue; continue;
}
const float char_width = font->GetCharAdvance((unsigned short)c) * scale; const float char_width = font->GetCharAdvance((unsigned short)c) * scale;
line_width += char_width; line_width += char_width;
@ -7165,7 +7161,7 @@ static bool InputTextEx(const char* label, char* buf, size_t buf_size, const ImV
} }
} }
draw_window->DrawList->AddText(g.Font, g.FontSize, render_pos - render_scroll, draw_window->Color(ImGuiCol_Text), buf, NULL, 0.0f, is_multiline ? NULL : &clip_rect); draw_window->DrawList->AddText(g.Font, g.FontSize, render_pos - render_scroll, draw_window->Color(ImGuiCol_Text), buf, buf+edit_state.CurLenA, 0.0f, is_multiline ? NULL : &clip_rect);
// Draw blinking cursor // Draw blinking cursor
ImVec2 cursor_screen_pos = render_pos + cursor_offset - ImVec2(edit_state.ScrollX, 0.0f); ImVec2 cursor_screen_pos = render_pos + cursor_offset - ImVec2(edit_state.ScrollX, 0.0f);