### Godot version

8449592d92eaeef990f5502b419d491ee3eeb7a6

### System information

Windows 11

### Issue description

Zooming in the script editor on an empty script freezes the entire editor for a few seconds, but if the file is large then it freezes for 4-5 seconds (which is unacceptable). Looks like a recent regression.

### Steps to reproduce

Just zoom in/out on the large script file.

### Minimal reproduction project

N/A
bool rewrite = false;
	int sd_shift = 0;
	int sd_size = sd->glyphs.size();
	Glyph *sd_glyphs = sd->glyphs.ptrw();
	Glyph *sd_glyphs_new = nullptr;
	if (sd->break_inserts > 0) {
		glyphs_new.resize(sd->glyphs.size() + sd->break_inserts);
		sd_glyphs_new = glyphs_new.ptrw();
		rewrite = true;
	} else {
		sd_glyphs_new = sd_glyphs;
	}
	sd->sort_valid = false;
	sd->glyphs_logical.clear();
	const char32_t *ch = sd->text.ptr();
	int c_punct_size = sd->custom_punct.length();
	const char32_t *c_punct = sd->custom_punct.ptr();
	for (int i = 0; i < sd_size; i++) {
		if (rewrite) {
			for (int j = 0; j < sd_glyphs[i].count; j++) {
				sd_glyphs_new[sd_shift + i + j] = sd_glyphs[i + j];
			}
		}
		if (sd_glyphs[i].count > 0) {
			char32_t c = ch[sd_glyphs[i].start - sd->start];
			if (c == 0xfffc) {
				i += (sd_glyphs[i].count - 1);
				continue;
			}
			if (c == 0x0009 || c == 0x000b) {