notify: make Notify::config_initialized() static

This may be slightly more efficient.
This commit is contained in:
rdb 2020-03-08 10:48:50 +01:00
parent df6c79f1b3
commit fd5ec07a47
4 changed files with 11 additions and 9 deletions

View File

@ -720,7 +720,7 @@ scan_up_from(Filename &result, const Filename &dir,
*/ */
void ConfigPageManager:: void ConfigPageManager::
config_initialized() { config_initialized() {
Notify::ptr()->config_initialized(); Notify::config_initialized();
#ifndef NDEBUG #ifndef NDEBUG
ConfigVariableString panda_package_version ConfigVariableString panda_package_version

View File

@ -430,7 +430,7 @@ config_initialized() {
// notify-output even after the initial import of Panda3D modules. However, // notify-output even after the initial import of Panda3D modules. However,
// it cannot be changed after the first time it is set. // it cannot be changed after the first time it is set.
if (_ostream_ptr == &cerr) { if (_global_ptr == nullptr || _global_ptr->_ostream_ptr == &cerr) {
static ConfigVariableFilename notify_output static ConfigVariableFilename notify_output
("notify-output", "", ("notify-output", "",
"The filename to which to write all the output of notify"); "The filename to which to write all the output of notify");
@ -440,12 +440,14 @@ config_initialized() {
std::string value = notify_output.get_value(); std::string value = notify_output.get_value();
if (!value.empty() && !initialized.test_and_set()) { if (!value.empty() && !initialized.test_and_set()) {
Notify *ptr = Notify::ptr();
if (value == "stdout") { if (value == "stdout") {
cout.setf(std::ios::unitbuf); cout.setf(std::ios::unitbuf);
set_ostream_ptr(&cout, false); ptr->set_ostream_ptr(&cout, false);
} else if (value == "stderr") { } else if (value == "stderr") {
set_ostream_ptr(&cerr, false); ptr->set_ostream_ptr(&cerr, false);
} else { } else {
Filename filename = value; Filename filename = value;
@ -462,7 +464,7 @@ config_initialized() {
dup2(logfile_fd, STDERR_FILENO); dup2(logfile_fd, STDERR_FILENO);
close(logfile_fd); close(logfile_fd);
set_ostream_ptr(&cerr, false); ptr->set_ostream_ptr(&cerr, false);
} }
#else #else
pofstream *out = new pofstream; pofstream *out = new pofstream;
@ -471,7 +473,7 @@ config_initialized() {
delete out; delete out;
} else { } else {
out->setf(std::ios::unitbuf); out->setf(std::ios::unitbuf);
set_ostream_ptr(out, true); ptr->set_ostream_ptr(out, true);
} }
#endif // BUILD_IPHONE #endif // BUILD_IPHONE
} }

View File

@ -184,11 +184,11 @@ update_severity_cache() {
// Take this opportunity to have Notify check whether the notify-output // Take this opportunity to have Notify check whether the notify-output
// variable changed. // variable changed.
Notify::ptr()->config_initialized(); Notify::config_initialized();
} }
} else { } else {
_severity_cache = _severity; _severity_cache = _severity;
Notify::ptr()->config_initialized(); Notify::config_initialized();
} }
mark_cache_valid(_local_modified); mark_cache_valid(_local_modified);

View File

@ -72,7 +72,7 @@ public:
static NotifySeverity string_severity(const std::string &string); static NotifySeverity string_severity(const std::string &string);
void config_initialized(); static void config_initialized();
private: private:
std::ostream *_ostream_ptr; std::ostream *_ostream_ptr;