-
Notifications
You must be signed in to change notification settings - Fork 695
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
Optimization for Logging RAM usage #724
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,12 +41,26 @@ class message | |
int_type overflow(int_type); | ||
std::streamsize xsputn(const char *, std::streamsize); | ||
|
||
inline void activate() { | ||
active_ = true; | ||
} | ||
|
||
inline bool isActive() const { | ||
return active_; | ||
} | ||
|
||
inline std::string str() const { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm curious if a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not 100% sure, std::stringstream::str() constructs a new string anyway and wouldn't std::string_view then point to a temporaray object? Maybe I am wrong ... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I could be entirely wrong, but I think what happens here that a new I suppose the only way to know would be to test it out. I can try to set up something small on godbolt. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I set up a minimal example in godbolt and found exactly where I was confused. I didn't see that That said, C++20 has a stringstream::view that returns a |
||
return data_.str(); | ||
} | ||
|
||
private: | ||
bool active_ = false; | ||
std::stringstream data_; | ||
}; | ||
|
||
std::chrono::system_clock::time_point when_; | ||
buffer buffer_; | ||
level_e level_; | ||
const level_e level_; | ||
static std::mutex mutex__; | ||
}; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't
cerr
be more appropriate?