### Godot version

4.0.3 stable

### System information

Windows 10, i5 8600, RTX3060, 64 GB ram

### Issue description

In Godot 4, labels with lots of text cause scenes to load extremely slowly, both in the editor and in-game.

I measured a few game starts with different amounts of text in a label:

Text length | Game start time
-- | --
11323 | 2.33
22693 | 7.93
34064 | 19.69
45431 | 40.59

In Godot 3, the startup times for all test lengths was almost instantaneous.

The text I used was multiple copies of the license agreement for Google's [Roboto](https://fonts.google.com/specimen/Roboto) font. A "credits" page on a game could easily get well above this length.
Looking at a scatter plot with a best fit, it's pretty clearly increasing at around n^2:

![image](https://github.com/godotengine/godot/assets/8082633/6e2a9c41-f3fb-429d-acd3-288c24c6b744)

Results are the same whether I'm using the built-in font or a custom font, and results are similar across all renderers. Settings like text wrapping don't seem to affect it either.

### Steps to reproduce

Create a scene, add a label to that scene, and fill the label with a large amount of text. Try to launch the game and load that scene.

### Minimal reproduction project

[Godot3LargeLabel.zip](https://github.com/godotengine/godot/files/11521494/Godot3LargeLabel.zip)
[Godot4LargeLabel.zip](https://github.com/godotengine/godot/files/11521495/Godot4LargeLabel.zip)

}
		autowrap_flags = autowrap_flags | TextServer::BREAK_TRIM_EDGE_SPACES;
		PackedInt32Array line_breaks = TS->shaped_text_get_line_breaks(text_rid, width, 0, autowrap_flags);
		for (int i = 0; i < line_breaks.size(); i = i + 2) {
			RID line = TS->shaped_text_substr(text_rid, line_breaks[i], line_breaks[i + 1] - line_breaks[i]);
			if (!tab_stops.is_empty()) {
				TS->shaped_text_tab_align(line, tab_stops);
			}
			lines_rid.push_back(line);
		}
	}
	if (xl_text.length() == 0) {
		minsize = Size2(1, get_line_height());
		return;
	}
	if (autowrap_mode == TextServer::AUTOWRAP_OFF) {
		minsize.width = 0.0f;
		for (int i = 0; i < lines_rid.size(); i++) {
			if (minsize.width < TS->shaped_text_get_size(lines_rid[i]).x) {
				minsize.width = TS->shaped_text_get_size(lines_rid[i]).x;
			}
		}
	}
	if (lines_dirty) {
		BitField<TextServer::TextOverrunFlag> overrun_flags = TextServer::OVERRUN_NO_TRIM;
		switch (overrun_behavior) {
			case TextServer::OVERRUN_TRIM_WORD_ELLIPSIS:
				overrun_flags.set_flag(TextServer::OVERRUN_TRIM);
				overrun_flags.set_flag(TextServer::OVERRUN_TRIM_WORD_ONLY);
				overrun_flags.set_flag(TextServer::OVERRUN_ADD_ELLIPSIS);