You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
Replace most uses of Map by HashMap
* Map is unnecessary and inefficient in almost every case. * Replaced by the new HashMap. * Renamed Map to RBMap and Set to RBSet for cases that still make sense (order matters) but use is discouraged. There were very few cases where replacing by HashMap was undesired because keeping the key order was intended. I tried to keep those (as RBMap) as much as possible, but might have missed some. Review appreciated!
This commit is contained in:
@@ -33,10 +33,10 @@
|
||||
void GridContainer::_notification(int p_what) {
|
||||
switch (p_what) {
|
||||
case NOTIFICATION_SORT_CHILDREN: {
|
||||
Map<int, int> col_minw; // Max of min_width of all controls in each col (indexed by col).
|
||||
Map<int, int> row_minh; // Max of min_height of all controls in each row (indexed by row).
|
||||
Set<int> col_expanded; // Columns which have the SIZE_EXPAND flag set.
|
||||
Set<int> row_expanded; // Rows which have the SIZE_EXPAND flag set.
|
||||
HashMap<int, int> col_minw; // Max of min_width of all controls in each col (indexed by col).
|
||||
HashMap<int, int> row_minh; // Max of min_height of all controls in each row (indexed by row).
|
||||
RBSet<int> col_expanded; // Columns which have the SIZE_EXPAND flag set.
|
||||
RBSet<int> row_expanded; // Rows which have the SIZE_EXPAND flag set.
|
||||
|
||||
int hsep = get_theme_constant(SNAME("h_separation"));
|
||||
int vsep = get_theme_constant(SNAME("v_separation"));
|
||||
@@ -104,7 +104,7 @@ void GridContainer::_notification(int p_what) {
|
||||
// Check if all minwidth constraints are OK if we use the remaining space.
|
||||
can_fit = true;
|
||||
int max_index = col_expanded.front()->get();
|
||||
for (Set<int>::Element *E = col_expanded.front(); E; E = E->next()) {
|
||||
for (RBSet<int>::Element *E = col_expanded.front(); E; E = E->next()) {
|
||||
if (col_minw[E->get()] > col_minw[max_index]) {
|
||||
max_index = E->get();
|
||||
}
|
||||
@@ -125,7 +125,7 @@ void GridContainer::_notification(int p_what) {
|
||||
// Check if all minheight constraints are OK if we use the remaining space.
|
||||
can_fit = true;
|
||||
int max_index = row_expanded.front()->get();
|
||||
for (Set<int>::Element *E = row_expanded.front(); E; E = E->next()) {
|
||||
for (RBSet<int>::Element *E = row_expanded.front(); E; E = E->next()) {
|
||||
if (row_minh[E->get()] > row_minh[max_index]) {
|
||||
max_index = E->get();
|
||||
}
|
||||
@@ -214,8 +214,8 @@ void GridContainer::_bind_methods() {
|
||||
}
|
||||
|
||||
Size2 GridContainer::get_minimum_size() const {
|
||||
Map<int, int> col_minw;
|
||||
Map<int, int> row_minh;
|
||||
HashMap<int, int> col_minw;
|
||||
HashMap<int, int> row_minh;
|
||||
|
||||
int hsep = get_theme_constant(SNAME("h_separation"));
|
||||
int vsep = get_theme_constant(SNAME("v_separation"));
|
||||
|
||||
Reference in New Issue
Block a user