Depsgraph: use blender::Vector instead of std::vector

We decided that `blender::Vector` should be the default choice for
a vector data structure in Blender.

Reviewers: sergey

Differential Revision: https://developer.blender.org/D7981
This commit is contained in:
2020-06-10 15:25:39 +02:00
parent 044b824c9d
commit a7ea07c677
12 changed files with 17 additions and 19 deletions

View File

@@ -179,7 +179,7 @@ IDNode *DepsgraphNodeBuilder::add_id_node(ID *id)
OperationCode::COPY_ON_WRITE,
"",
-1);
graph_->operations.push_back(op_cow);
graph_->operations.append(op_cow);
}
return id_node;
}
@@ -213,7 +213,7 @@ OperationNode *DepsgraphNodeBuilder::add_operation_node(ComponentNode *comp_node
OperationNode *op_node = comp_node->find_operation(opcode, name, name_tag);
if (op_node == nullptr) {
op_node = comp_node->add_operation(op, opcode, name, name_tag);
graph_->operations.push_back(op_node);
graph_->operations.append(op_node);
}
else {
fprintf(stderr,
@@ -347,7 +347,7 @@ void DepsgraphNodeBuilder::begin_build()
entry_tag.opcode = op_node->opcode;
entry_tag.name = op_node->name;
entry_tag.name_tag = op_node->name_tag;
saved_entry_tags_.push_back(entry_tag);
saved_entry_tags_.append(entry_tag);
}
/* Make sure graph has no nodes left from previous state. */

View File

@@ -251,7 +251,7 @@ class DepsgraphNodeBuilder : public DepsgraphBuilder {
string name;
int name_tag;
};
vector<SavedEntryTag> saved_entry_tags_;
Vector<SavedEntryTag> saved_entry_tags_;
struct BuilderWalkUserData {
DepsgraphNodeBuilder *builder;

View File

@@ -2887,7 +2887,7 @@ void DepsgraphRelationBuilder::build_driver_relations(IDNode *id_node)
}
// Mapping from RNA prefix -> set of driver evaluation nodes:
typedef vector<Node *> DriverGroup;
typedef Vector<Node *> DriverGroup;
typedef map<string, DriverGroup> DriverGroupMap;
DriverGroupMap driver_groups;
@@ -2906,7 +2906,7 @@ void DepsgraphRelationBuilder::build_driver_relations(IDNode *id_node)
OperationKey driver_key(
id_orig, NodeType::PARAMETERS, OperationCode::DRIVER, fcu->rna_path, fcu->array_index);
Node *node_driver = get_node(driver_key);
driver_groups[rna_prefix].push_back(node_driver);
driver_groups[rna_prefix].append(node_driver);
}
for (pair<string, DriverGroup> prefix_group : driver_groups) {

View File

@@ -442,7 +442,7 @@ static void deg_debug_graphviz_node(const DebugContext &ctx, const Node *node)
case NodeType::GENERIC_DATABLOCK:
case NodeType::SIMULATION: {
ComponentNode *comp_node = (ComponentNode *)node;
if (!comp_node->operations.empty()) {
if (!comp_node->operations.is_empty()) {
deg_debug_graphviz_node_cluster_begin(ctx, node);
for (Node *op_node : comp_node->operations) {
deg_debug_graphviz_node(ctx, op_node);
@@ -480,7 +480,7 @@ static bool deg_debug_graphviz_is_cluster(const Node *node)
case NodeType::EVAL_POSE:
case NodeType::BONE: {
ComponentNode *comp_node = (ComponentNode *)node;
return !comp_node->operations.empty();
return !comp_node->operations.is_empty();
}
default:
return false;

View File

@@ -96,7 +96,7 @@ string gnuplotify_name(const string &name)
void write_stats_data(const DebugContext &ctx)
{
// Fill in array of all stats which are to be displayed.
vector<StatsEntry> stats;
Vector<StatsEntry> stats;
stats.reserve(ctx.graph->id_nodes.size());
for (const IDNode *id_node : ctx.graph->id_nodes) {
const double time = get_node_time(ctx, id_node);
@@ -106,7 +106,7 @@ void write_stats_data(const DebugContext &ctx)
StatsEntry entry;
entry.id_node = id_node;
entry.time = time;
stats.push_back(entry);
stats.append(entry);
}
// Sort the data.
std::sort(stats.begin(), stats.end(), stat_entry_comparator);

View File

@@ -120,7 +120,7 @@ IDNode *Depsgraph::add_id_node(ID *id, ID *id_cow_hint)
* NOTE: We address ID nodes by the original ID pointer they are
* referencing to. */
id_hash.add_new(id, id_node);
id_nodes.push_back(id_node);
id_nodes.append(id_node);
id_type_exist[BKE_idtype_idcode_to_index(GS(id->name))] = 1;
}

View File

@@ -57,9 +57,8 @@ struct TimeSourceNode;
/* Dependency Graph object */
struct Depsgraph {
// TODO(sergey): Go away from C++ container and use some native BLI.
typedef vector<OperationNode *> OperationNodes;
typedef vector<IDNode *> IDDepsNodes;
typedef Vector<OperationNode *> OperationNodes;
typedef Vector<IDNode *> IDDepsNodes;
Depsgraph(Main *bmain, Scene *scene, ViewLayer *view_layer, eEvaluationMode mode);
~Depsgraph();

View File

@@ -66,7 +66,6 @@ using std::pair;
using std::set;
using std::string;
using std::unique_ptr;
using std::vector;
/* Commonly used functions. */
using std::make_pair;

View File

@@ -70,7 +70,7 @@ void animated_property_store_cb(ID *id, FCurve *fcurve, void *data_v)
return;
}
data->backup->values_backup.emplace_back(fcurve->rna_path, fcurve->array_index, value);
data->backup->values_backup.append({fcurve->rna_path, fcurve->array_index, value});
}
} // namespace

View File

@@ -59,7 +59,7 @@ class AnimationBackup {
void restore_to_id(ID *id);
bool meed_value_backup;
vector<AnimationValueBackup> values_backup;
Vector<AnimationValueBackup> values_backup;
};
} // namespace DEG

View File

@@ -293,7 +293,7 @@ void ComponentNode::finalize_build(Depsgraph * /*graph*/)
{
operations.reserve(operations_map->size());
for (OperationNode *op_node : operations_map->values()) {
operations.push_back(op_node);
operations.append(op_node);
}
delete operations_map;
operations_map = nullptr;

View File

@@ -119,7 +119,7 @@ struct ComponentNode : public Node {
/* This is a "normal" list of operations, used by evaluation
* and other routines after construction. */
vector<OperationNode *> operations;
Vector<OperationNode *> operations;
OperationNode *entry_operation;
OperationNode *exit_operation;