From 30f1c8ba92df4ee1fc35d7b54ff716ef18272fa4 Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 19 Oct 2018 00:12:53 +0200 Subject: [PATCH] display: slight cleanup of graphicsPipeSelection.cxx This seemed to halve the compile time of this file under MSVC. --- panda/src/display/graphicsPipeSelection.cxx | 42 +++++++-------------- 1 file changed, 14 insertions(+), 28 deletions(-) diff --git a/panda/src/display/graphicsPipeSelection.cxx b/panda/src/display/graphicsPipeSelection.cxx index 9c4f52ff63..58866efef6 100644 --- a/panda/src/display/graphicsPipeSelection.cxx +++ b/panda/src/display/graphicsPipeSelection.cxx @@ -18,7 +18,6 @@ #include "load_dso.h" #include "config_display.h" #include "typeRegistry.h" -#include "pset.h" #include "config_putil.h" #include @@ -61,8 +60,8 @@ GraphicsPipeSelection() : _lock("GraphicsPipeSelection") { // Also get the set of modules named in the various aux-display Config // variables. We'll want to know this when we call load_modules() later. - int num_aux = aux_display.get_num_unique_values(); - for (int i = 0; i < num_aux; i++) { + size_t num_aux = aux_display.get_num_unique_values(); + for (size_t i = 0; i < num_aux; ++i) { string name = aux_display.get_unique_value(i); if (name != _default_display_module) { _display_modules.push_back(name); @@ -124,9 +123,7 @@ print_pipe_types() const { LightMutexHolder holder(_lock); nout << "Known pipe types:" << std::endl; - PipeTypes::const_iterator pi; - for (pi = _pipe_types.begin(); pi != _pipe_types.end(); ++pi) { - const PipeType &pipe_type = (*pi); + for (const PipeType &pipe_type : _pipe_types) { nout << " " << pipe_type._type << "\n"; } if (_display_modules.empty()) { @@ -187,11 +184,9 @@ make_pipe(const string &type_name, const string &module_name) { PT(GraphicsPipe) GraphicsPipeSelection:: make_pipe(TypeHandle type) { LightMutexHolder holder(_lock); - PipeTypes::const_iterator ti; // First, look for an exact match of the requested type. - for (ti = _pipe_types.begin(); ti != _pipe_types.end(); ++ti) { - const PipeType &ptype = (*ti); + for (const PipeType &ptype : _pipe_types) { if (ptype._type == type) { // Here's an exact match. PT(GraphicsPipe) pipe = (*ptype._constructor)(); @@ -202,8 +197,7 @@ make_pipe(TypeHandle type) { } // Now look for a more-specific type. - for (ti = _pipe_types.begin(); ti != _pipe_types.end(); ++ti) { - const PipeType &ptype = (*ti); + for (const PipeType &ptype : _pipe_types) { if (ptype._type.is_derived_from(type)) { // Here's an approximate match. PT(GraphicsPipe) pipe = (*ptype._constructor)(); @@ -215,8 +209,7 @@ make_pipe(TypeHandle type) { // Couldn't find any match; load the default module and try again. load_default_module(); - for (ti = _pipe_types.begin(); ti != _pipe_types.end(); ++ti) { - const PipeType &ptype = (*ti); + for (const PipeType &ptype : _pipe_types) { if (ptype._type.is_derived_from(type)) { // Here's an approximate match. PT(GraphicsPipe) pipe = (*ptype._constructor)(); @@ -260,13 +253,11 @@ make_default_pipe() { load_default_module(); LightMutexHolder holder(_lock); - PipeTypes::const_iterator ti; if (!_default_pipe_name.empty()) { // First, look for an exact match of the default type name from the // Configrc file (excepting case and hyphenunderscore). - for (ti = _pipe_types.begin(); ti != _pipe_types.end(); ++ti) { - const PipeType &ptype = (*ti); + for (const PipeType &ptype : _pipe_types) { if (cmp_nocase_uh(ptype._type.get_name(), _default_pipe_name) == 0) { // Here's an exact match. PT(GraphicsPipe) pipe = (*ptype._constructor)(); @@ -278,8 +269,7 @@ make_default_pipe() { // No match; look for a substring match. string preferred_name = downcase(_default_pipe_name); - for (ti = _pipe_types.begin(); ti != _pipe_types.end(); ++ti) { - const PipeType &ptype = (*ti); + for (const PipeType &ptype : _pipe_types) { string ptype_name = downcase(ptype._type.get_name()); if (ptype_name.find(preferred_name) != string::npos) { // Here's a substring match. @@ -292,8 +282,7 @@ make_default_pipe() { } // Couldn't find a matching pipe type; choose the first one on the list. - for (ti = _pipe_types.begin(); ti != _pipe_types.end(); ++ti) { - const PipeType &ptype = (*ti); + for (const PipeType &ptype : _pipe_types) { PT(GraphicsPipe) pipe = (*ptype._constructor)(); if (pipe != nullptr) { return pipe; @@ -310,9 +299,8 @@ make_default_pipe() { */ void GraphicsPipeSelection:: load_aux_modules() { - DisplayModules::iterator di; - for (di = _display_modules.begin(); di != _display_modules.end(); ++di) { - load_named_module(*di); + for (const string &module : _display_modules) { + load_named_module(module); } _display_modules.clear(); @@ -337,9 +325,7 @@ add_pipe_type(TypeHandle type, PipeConstructorFunc *func) { // First, make sure we don't already have a GraphicsPipe of this type. LightMutexHolder holder(_lock); - PipeTypes::const_iterator ti; - for (ti = _pipe_types.begin(); ti != _pipe_types.end(); ++ti) { - const PipeType &ptype = (*ti); + for (const PipeType &ptype : _pipe_types) { if (ptype._type == type) { display_cat->warning() << "Attempt to register GraphicsPipe type " << type @@ -375,8 +361,8 @@ do_load_default_module() { load_named_module(_default_display_module); DisplayModules::iterator di = - find(_display_modules.begin(), _display_modules.end(), - _default_display_module); + std::find(_display_modules.begin(), _display_modules.end(), + _default_display_module); if (di != _display_modules.end()) { _display_modules.erase(di); }