Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use constinit in logs.cpp #16287

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions rpcs3/util/logs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,16 +397,22 @@ void logs::message::broadcast(const char* fmt, const fmt_type_info* sup, ...) co
g_tls_log_control(fmt, 0);

// Get text, extract va_args
/*constinit thread_local*/ std::string text;
/*constinit thread_local*/ std::basic_string<u64> args;
constinit thread_local std::unique_ptr<std::string> text_;
constinit thread_local std::unique_ptr<std::vector<u64>> args_;
if (!text_)
text_ = std::make_unique<std::string>();
if (!args_)
args_ = std::make_unique<std::vector<u64>>();
auto& text = *text_.get();
auto& args = *args_.get();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think .get is needed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, okay, it isn't


static constexpr fmt_type_info empty_sup{};

usz args_count = 0;
for (auto v = sup; v && v->fmt_string; v++)
args_count++;

text.reserve(50000);
text.clear();
args.resize(args_count);

va_list c_args;
Expand Down
Loading