You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
Merge pull request #102129 from Ivorforce/optimize-text-server-adv-break-iter
Optimize text rendering by caching `UBreakIterator` instances.
This commit is contained in:
@@ -545,6 +545,11 @@ class TextServerAdvanced : public TextServerExtension {
|
||||
bool js_ops_valid = false;
|
||||
bool chars_valid = false;
|
||||
|
||||
HashMap<String, UBreakIterator *> line_break_iterators_per_language;
|
||||
|
||||
// Creating UBreakIterator is surprisingly costly. To improve efficiency, we cache them.
|
||||
UBreakIterator *_get_break_iterator_for_locale(const String &p_language, UErrorCode *r_err);
|
||||
|
||||
~ShapedTextDataAdvanced() {
|
||||
for (int i = 0; i < bidi_iter.size(); i++) {
|
||||
if (bidi_iter[i]) {
|
||||
@@ -557,6 +562,9 @@ class TextServerAdvanced : public TextServerExtension {
|
||||
if (hb_buffer) {
|
||||
hb_buffer_destroy(hb_buffer);
|
||||
}
|
||||
for (const KeyValue<String, UBreakIterator *> &bi : line_break_iterators_per_language) {
|
||||
ubrk_close(bi.value);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user