### 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
}
	if (!_shape_substr(new_sd, sd, p_start, p_length)) {
		memdelete(new_sd);
		return RID();
	}
	return shaped_owner.make_rid(new_sd);
}
bool TextServerAdvanced::_shape_substr(ShapedTextDataAdvanced *p_new_sd, const ShapedTextDataAdvanced *p_sd, int64_t p_start, int64_t p_length) const {
	if (p_new_sd->valid) {
		return true;
	}
	p_new_sd->hb_buffer = hb_buffer_create();
	p_new_sd->line_breaks_valid = p_sd->line_breaks_valid;
	p_new_sd->justification_ops_valid = p_sd->justification_ops_valid;
	p_new_sd->sort_valid = false;
	p_new_sd->upos = p_sd->upos;
	p_new_sd->uthk = p_sd->uthk;
	if (p_length > 0) {
		p_new_sd->text = p_sd->text.substr(p_start - p_sd->start, p_length);
		p_new_sd->utf16 = p_new_sd->text.utf16();
		p_new_sd->script_iter = memnew(ScriptIterator(p_new_sd->text, 0, p_new_sd->text.length()));
		int sd_size = p_sd->glyphs.size();
		const Glyph *sd_glyphs = p_sd->glyphs.ptr();
		for (int ov = 0; ov < p_sd->bidi_override.size(); ov++) {
			UErrorCode err = U_ZERO_ERROR;
			if (p_sd->bidi_override[ov].x >= p_start + p_length || p_sd->bidi_override[ov].y <= p_start) {
				continue;
			}
			int ov_start = _convert_pos_inv(p_sd, p_sd->bidi_override[ov].x);
			int start = MAX(0, _convert_pos_inv(p_sd, p_start) - ov_start);