Optimize TextServerAdvanced::_add_features
by using iteration instead of .values()
and .keys()
.
Rename `_add_featuers` to `_add_features`.
This commit is contained in:
parent
3d9b05ad4a
commit
bfc1ef4ab7
@ -6125,17 +6125,15 @@ Glyph TextServerAdvanced::_shape_single_glyph(ShapedTextDataAdvanced *p_sd, char
|
||||
return gl;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ void TextServerAdvanced::_add_featuers(const Dictionary &p_source, Vector<hb_feature_t> &r_ftrs) {
|
||||
Array keys = p_source.keys();
|
||||
Array values = p_source.values();
|
||||
for (int i = 0; i < keys.size(); i++) {
|
||||
int32_t value = values[i];
|
||||
_FORCE_INLINE_ void TextServerAdvanced::_add_features(const Dictionary &p_source, Vector<hb_feature_t> &r_ftrs) {
|
||||
for (const KeyValue<Variant, Variant> &key_value : p_source) {
|
||||
int32_t value = key_value.value;
|
||||
if (value >= 0) {
|
||||
hb_feature_t feature;
|
||||
if (keys[i].is_string()) {
|
||||
feature.tag = _name_to_tag(keys[i]);
|
||||
if (key_value.key.is_string()) {
|
||||
feature.tag = _name_to_tag(key_value.key);
|
||||
} else {
|
||||
feature.tag = keys[i];
|
||||
feature.tag = key_value.key;
|
||||
}
|
||||
feature.value = value;
|
||||
feature.start = 0;
|
||||
@ -6297,8 +6295,8 @@ void TextServerAdvanced::_shape_run(ShapedTextDataAdvanced *p_sd, int64_t p_star
|
||||
hb_buffer_add_utf32(p_sd->hb_buffer, (const uint32_t *)p_sd->text.ptr(), p_sd->text.length(), p_start, p_end - p_start);
|
||||
|
||||
Vector<hb_feature_t> ftrs;
|
||||
_add_featuers(_font_get_opentype_feature_overrides(f), ftrs);
|
||||
_add_featuers(p_sd->spans[p_span].features, ftrs);
|
||||
_add_features(_font_get_opentype_feature_overrides(f), ftrs);
|
||||
_add_features(p_sd->spans[p_span].features, ftrs);
|
||||
|
||||
hb_shape(hb_font, p_sd->hb_buffer, ftrs.is_empty() ? nullptr : &ftrs[0], ftrs.size());
|
||||
|
||||
|
@ -685,7 +685,7 @@ class TextServerAdvanced : public TextServerExtension {
|
||||
Glyph _shape_single_glyph(ShapedTextDataAdvanced *p_sd, char32_t p_char, hb_script_t p_script, hb_direction_t p_direction, const RID &p_font, int64_t p_font_size);
|
||||
_FORCE_INLINE_ RID _find_sys_font_for_text(const RID &p_fdef, const String &p_script_code, const String &p_language, const String &p_text);
|
||||
|
||||
_FORCE_INLINE_ void _add_featuers(const Dictionary &p_source, Vector<hb_feature_t> &r_ftrs);
|
||||
_FORCE_INLINE_ void _add_features(const Dictionary &p_source, Vector<hb_feature_t> &r_ftrs);
|
||||
|
||||
Mutex ft_mutex;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user