mirror of
				https://github.com/Drezil/imgui.git
				synced 2025-10-31 13:11:05 +01:00 
			
		
		
		
	RenderText(), InputTextMultiline(): Optimization for large text by using memchr, wmemchr, wcschr when appropriate.
This commit is contained in:
		| @@ -2646,11 +2646,11 @@ void ImFont::RenderText(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col | ||||
|     // Fast-forward to first visible line | ||||
|     const char* s = text_begin; | ||||
|     if (y + line_height < clip_rect.y && !word_wrap_enabled) | ||||
|         while (y + line_height < clip_rect.y) | ||||
|         while (y + line_height < clip_rect.y && s < text_end) | ||||
|         { | ||||
|             while (s < text_end) | ||||
|                 if (*s++ == '\n') | ||||
|                     break; | ||||
|             s = (const char*)memchr(s, '\n', text_end - s) + 1; | ||||
|             if (s == NULL) | ||||
|                 s = text_end; | ||||
|             y += line_height; | ||||
|         } | ||||
|  | ||||
| @@ -2660,15 +2660,15 @@ void ImFont::RenderText(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col | ||||
|     { | ||||
|         const char* s_end = s; | ||||
|         float y_end = y; | ||||
|         while (y_end < clip_rect.w) | ||||
|         while (y_end < clip_rect.w && s_end < text_end) | ||||
|         { | ||||
|             while (s_end < text_end) | ||||
|                 if (*s_end++ == '\n') | ||||
|                     break; | ||||
|             s_end = (const char*)memchr(s_end, '\n', text_end - s_end) + 1; | ||||
|             y_end += line_height; | ||||
|         } | ||||
|         text_end = s_end; | ||||
|     } | ||||
|     if (s == text_end) | ||||
|         return; | ||||
|  | ||||
|     // Reserve vertices for remaining worse case (over-reserving is useful and easily amortized) | ||||
|     const int vtx_count_max = (int)(text_end - s) * 4; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user