display: slight cleanup of graphicsPipeSelection.cxx

This seemed to halve the compile time of this file under MSVC.
This commit is contained in:
rdb 2018-10-19 00:12:53 +02:00
parent f8b47dc14c
commit 30f1c8ba92

View File

@ -18,7 +18,6 @@
#include "load_dso.h" #include "load_dso.h"
#include "config_display.h" #include "config_display.h"
#include "typeRegistry.h" #include "typeRegistry.h"
#include "pset.h"
#include "config_putil.h" #include "config_putil.h"
#include <algorithm> #include <algorithm>
@ -61,8 +60,8 @@ GraphicsPipeSelection() : _lock("GraphicsPipeSelection") {
// Also get the set of modules named in the various aux-display Config // 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. // variables. We'll want to know this when we call load_modules() later.
int num_aux = aux_display.get_num_unique_values(); size_t num_aux = aux_display.get_num_unique_values();
for (int i = 0; i < num_aux; i++) { for (size_t i = 0; i < num_aux; ++i) {
string name = aux_display.get_unique_value(i); string name = aux_display.get_unique_value(i);
if (name != _default_display_module) { if (name != _default_display_module) {
_display_modules.push_back(name); _display_modules.push_back(name);
@ -124,9 +123,7 @@ print_pipe_types() const {
LightMutexHolder holder(_lock); LightMutexHolder holder(_lock);
nout << "Known pipe types:" << std::endl; nout << "Known pipe types:" << std::endl;
PipeTypes::const_iterator pi; for (const PipeType &pipe_type : _pipe_types) {
for (pi = _pipe_types.begin(); pi != _pipe_types.end(); ++pi) {
const PipeType &pipe_type = (*pi);
nout << " " << pipe_type._type << "\n"; nout << " " << pipe_type._type << "\n";
} }
if (_display_modules.empty()) { if (_display_modules.empty()) {
@ -187,11 +184,9 @@ make_pipe(const string &type_name, const string &module_name) {
PT(GraphicsPipe) GraphicsPipeSelection:: PT(GraphicsPipe) GraphicsPipeSelection::
make_pipe(TypeHandle type) { make_pipe(TypeHandle type) {
LightMutexHolder holder(_lock); LightMutexHolder holder(_lock);
PipeTypes::const_iterator ti;
// First, look for an exact match of the requested type. // First, look for an exact match of the requested type.
for (ti = _pipe_types.begin(); ti != _pipe_types.end(); ++ti) { for (const PipeType &ptype : _pipe_types) {
const PipeType &ptype = (*ti);
if (ptype._type == type) { if (ptype._type == type) {
// Here's an exact match. // Here's an exact match.
PT(GraphicsPipe) pipe = (*ptype._constructor)(); PT(GraphicsPipe) pipe = (*ptype._constructor)();
@ -202,8 +197,7 @@ make_pipe(TypeHandle type) {
} }
// Now look for a more-specific type. // Now look for a more-specific type.
for (ti = _pipe_types.begin(); ti != _pipe_types.end(); ++ti) { for (const PipeType &ptype : _pipe_types) {
const PipeType &ptype = (*ti);
if (ptype._type.is_derived_from(type)) { if (ptype._type.is_derived_from(type)) {
// Here's an approximate match. // Here's an approximate match.
PT(GraphicsPipe) pipe = (*ptype._constructor)(); 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. // Couldn't find any match; load the default module and try again.
load_default_module(); load_default_module();
for (ti = _pipe_types.begin(); ti != _pipe_types.end(); ++ti) { for (const PipeType &ptype : _pipe_types) {
const PipeType &ptype = (*ti);
if (ptype._type.is_derived_from(type)) { if (ptype._type.is_derived_from(type)) {
// Here's an approximate match. // Here's an approximate match.
PT(GraphicsPipe) pipe = (*ptype._constructor)(); PT(GraphicsPipe) pipe = (*ptype._constructor)();
@ -260,13 +253,11 @@ make_default_pipe() {
load_default_module(); load_default_module();
LightMutexHolder holder(_lock); LightMutexHolder holder(_lock);
PipeTypes::const_iterator ti;
if (!_default_pipe_name.empty()) { if (!_default_pipe_name.empty()) {
// First, look for an exact match of the default type name from the // First, look for an exact match of the default type name from the
// Configrc file (excepting case and hyphenunderscore). // Configrc file (excepting case and hyphenunderscore).
for (ti = _pipe_types.begin(); ti != _pipe_types.end(); ++ti) { for (const PipeType &ptype : _pipe_types) {
const PipeType &ptype = (*ti);
if (cmp_nocase_uh(ptype._type.get_name(), _default_pipe_name) == 0) { if (cmp_nocase_uh(ptype._type.get_name(), _default_pipe_name) == 0) {
// Here's an exact match. // Here's an exact match.
PT(GraphicsPipe) pipe = (*ptype._constructor)(); PT(GraphicsPipe) pipe = (*ptype._constructor)();
@ -278,8 +269,7 @@ make_default_pipe() {
// No match; look for a substring match. // No match; look for a substring match.
string preferred_name = downcase(_default_pipe_name); string preferred_name = downcase(_default_pipe_name);
for (ti = _pipe_types.begin(); ti != _pipe_types.end(); ++ti) { for (const PipeType &ptype : _pipe_types) {
const PipeType &ptype = (*ti);
string ptype_name = downcase(ptype._type.get_name()); string ptype_name = downcase(ptype._type.get_name());
if (ptype_name.find(preferred_name) != string::npos) { if (ptype_name.find(preferred_name) != string::npos) {
// Here's a substring match. // 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. // Couldn't find a matching pipe type; choose the first one on the list.
for (ti = _pipe_types.begin(); ti != _pipe_types.end(); ++ti) { for (const PipeType &ptype : _pipe_types) {
const PipeType &ptype = (*ti);
PT(GraphicsPipe) pipe = (*ptype._constructor)(); PT(GraphicsPipe) pipe = (*ptype._constructor)();
if (pipe != nullptr) { if (pipe != nullptr) {
return pipe; return pipe;
@ -310,9 +299,8 @@ make_default_pipe() {
*/ */
void GraphicsPipeSelection:: void GraphicsPipeSelection::
load_aux_modules() { load_aux_modules() {
DisplayModules::iterator di; for (const string &module : _display_modules) {
for (di = _display_modules.begin(); di != _display_modules.end(); ++di) { load_named_module(module);
load_named_module(*di);
} }
_display_modules.clear(); _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. // First, make sure we don't already have a GraphicsPipe of this type.
LightMutexHolder holder(_lock); LightMutexHolder holder(_lock);
PipeTypes::const_iterator ti; for (const PipeType &ptype : _pipe_types) {
for (ti = _pipe_types.begin(); ti != _pipe_types.end(); ++ti) {
const PipeType &ptype = (*ti);
if (ptype._type == type) { if (ptype._type == type) {
display_cat->warning() display_cat->warning()
<< "Attempt to register GraphicsPipe type " << type << "Attempt to register GraphicsPipe type " << type
@ -375,8 +361,8 @@ do_load_default_module() {
load_named_module(_default_display_module); load_named_module(_default_display_module);
DisplayModules::iterator di = DisplayModules::iterator di =
find(_display_modules.begin(), _display_modules.end(), std::find(_display_modules.begin(), _display_modules.end(),
_default_display_module); _default_display_module);
if (di != _display_modules.end()) { if (di != _display_modules.end()) {
_display_modules.erase(di); _display_modules.erase(di);
} }