Skip to content
Permalink
Browse files

notify: make Notify::config_initialized() static

This may be slightly more efficient.
  • Loading branch information
rdb committed Mar 8, 2020
1 parent df6c79f commit fd5ec07a47bb8cec413a69dd29baff6bf7b0ed0e
Showing with 11 additions and 9 deletions.
  1. +1 −1 dtool/src/prc/configPageManager.cxx
  2. +7 −5 dtool/src/prc/notify.cxx
  3. +2 −2 dtool/src/prc/notifyCategory.cxx
  4. +1 −1 dtool/src/prc/pnotify.h
@@ -720,7 +720,7 @@ scan_up_from(Filename &result, const Filename &dir,
*/
void ConfigPageManager::
config_initialized() {
Notify::ptr()->config_initialized();
Notify::config_initialized();

#ifndef NDEBUG
ConfigVariableString panda_package_version
@@ -430,7 +430,7 @@ config_initialized() {
// notify-output even after the initial import of Panda3D modules. However,
// 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
("notify-output", "",
"The filename to which to write all the output of notify");
@@ -440,12 +440,14 @@ config_initialized() {

std::string value = notify_output.get_value();
if (!value.empty() && !initialized.test_and_set()) {
Notify *ptr = Notify::ptr();

if (value == "stdout") {
cout.setf(std::ios::unitbuf);
set_ostream_ptr(&cout, false);
ptr->set_ostream_ptr(&cout, false);

} else if (value == "stderr") {
set_ostream_ptr(&cerr, false);
ptr->set_ostream_ptr(&cerr, false);

} else {
Filename filename = value;
@@ -462,7 +464,7 @@ config_initialized() {
dup2(logfile_fd, STDERR_FILENO);
close(logfile_fd);

set_ostream_ptr(&cerr, false);
ptr->set_ostream_ptr(&cerr, false);
}
#else
pofstream *out = new pofstream;
@@ -471,7 +473,7 @@ config_initialized() {
delete out;
} else {
out->setf(std::ios::unitbuf);
set_ostream_ptr(out, true);
ptr->set_ostream_ptr(out, true);
}
#endif // BUILD_IPHONE
}
@@ -184,11 +184,11 @@ update_severity_cache() {

// Take this opportunity to have Notify check whether the notify-output
// variable changed.
Notify::ptr()->config_initialized();
Notify::config_initialized();
}
} else {
_severity_cache = _severity;
Notify::ptr()->config_initialized();
Notify::config_initialized();
}

mark_cache_valid(_local_modified);
@@ -72,7 +72,7 @@ class EXPCL_DTOOL_PRC Notify {

static NotifySeverity string_severity(const std::string &string);

void config_initialized();
static void config_initialized();

private:
std::ostream *_ostream_ptr;

0 comments on commit fd5ec07

Please sign in to comment.
You can’t perform that action at this time.