Pārlūkot izejas kodu

Improve output log performance.

Added method to create a new line in RichTextLabel without adding an ItemNewline to the previous line. Previously, removing a line then adding a newline was adding unnecessary ItemNewline instances to the previous line, significantly the remove_line method.
Eric M 5 gadi atpakaļ
vecāks
revīzija
77fd9e4dd3

+ 1 - 6
editor/editor_log.cpp

@@ -122,12 +122,7 @@ void EditorLog::_process_message(const String &p_msg, MessageType p_type) {
 		LogMessage &previous = messages.write[messages.size() - 1];
 		LogMessage &previous = messages.write[messages.size() - 1];
 		previous.count++;
 		previous.count++;
 
 
-		if (collapse) {
-			// Remove last line if collapsing, as it will be replace by the next added line with an updated count.
-			log->remove_line(log->get_line_count() - 1);
-		}
-
-		_add_log_line(previous);
+		_add_log_line(previous, collapse);
 	} else {
 	} else {
 		// Different message to the previous one received.
 		// Different message to the previous one received.
 		LogMessage message(p_msg, p_type);
 		LogMessage message(p_msg, p_type);

+ 7 - 0
scene/gui/rich_text_label.cpp

@@ -2612,6 +2612,13 @@ void RichTextLabel::pop() {
 	current = current->parent;
 	current = current->parent;
 }
 }
 
 
+// Creates a new line without adding an ItemNewline to the previous line.
+// Useful when wanting to calling remove_line and add a new line immediately after.
+void RichTextLabel::increment_line_count() {
+	current_frame->lines.resize(current_frame->lines.size() + 1);
+	_invalidate_current_line(current_frame);
+}
+
 void RichTextLabel::clear() {
 void RichTextLabel::clear() {
 	main->_clear_children();
 	main->_clear_children();
 	current = main;
 	current = main;

+ 2 - 0
scene/gui/rich_text_label.h

@@ -483,6 +483,8 @@ public:
 	void push_cell();
 	void push_cell();
 	void pop();
 	void pop();
 
 
+	void increment_line_count();
+
 	void clear();
 	void clear();
 
 
 	void set_offset(int p_pixel);
 	void set_offset(int p_pixel);