Skip to content

Commit 551ce65

Browse files
committed
Merge pull request #98317 from YYF233333/vformat
Optimize `TileSetAtlasSource::_get_property_list`
2 parents ca81cd3 + b5141b8 commit 551ce65

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

scene/resources/2d/tile_set.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4931,10 +4931,13 @@ void TileSetAtlasSource::_get_property_list(List<PropertyInfo> *p_list) const {
49314931
}
49324932

49334933
for (const KeyValue<int, TileData *> &E_alternative : E_tile.value.alternatives) {
4934+
const String formatted_key = itos(E_alternative.key);
4935+
49344936
// Add a dummy property to show the alternative exists.
4935-
tile_property_list.push_back(PropertyInfo(Variant::INT, vformat("%d", E_alternative.key), PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR));
4937+
tile_property_list.push_back(PropertyInfo(Variant::INT, formatted_key, PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR));
49364938

49374939
// Get the alternative tile's properties and append them to the list of properties.
4940+
const String alternative_property_info_prefix = formatted_key + '/';
49384941
List<PropertyInfo> alternative_property_list;
49394942
E_alternative.value->get_property_list(&alternative_property_list);
49404943
for (PropertyInfo &alternative_property_info : alternative_property_list) {
@@ -4943,14 +4946,15 @@ void TileSetAtlasSource::_get_property_list(List<PropertyInfo> *p_list) const {
49434946
if (default_value.get_type() != Variant::NIL && bool(Variant::evaluate(Variant::OP_EQUAL, value, default_value))) {
49444947
alternative_property_info.usage ^= PROPERTY_USAGE_STORAGE;
49454948
}
4946-
alternative_property_info.name = vformat("%s/%s", vformat("%d", E_alternative.key), alternative_property_info.name);
4949+
alternative_property_info.name = alternative_property_info_prefix + alternative_property_info.name;
49474950
tile_property_list.push_back(alternative_property_info);
49484951
}
49494952
}
49504953

49514954
// Add all alternative.
4955+
const String property_info_prefix = vformat("%d:%d/", E_tile.key.x, E_tile.key.y);
49524956
for (PropertyInfo &tile_property_info : tile_property_list) {
4953-
tile_property_info.name = vformat("%s/%s", vformat("%d:%d", E_tile.key.x, E_tile.key.y), tile_property_info.name);
4957+
tile_property_info.name = property_info_prefix + tile_property_info.name;
49544958
p_list->push_back(tile_property_info);
49554959
}
49564960
}

0 commit comments

Comments
 (0)