forked from Bitcoin-ABC/bitcoin-abc
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optimized Logger class to do less redundant copying
Summary --- When reviewing !834 I noticed the Logger class does a lot of extra copying and other assorted inefficient operations. Summary of fixes: - Made the real workhorse function, `LogPrintStr` do less copying and also accept an rvalue reference (`&&`) as a parameter as an optimization. - `LogPrintStr` is currently only called in 1 place, from an inline function in the header which builds a temporary string. We `std::move` that temporary string when calling `LogPrintStr` to save on 1 copy there. - The `LogTimestampStr` function was inefficeint and wasn't leveraging RVO and other things. It has been modified and renamed to `PrependTimestampStr` and it now operates on the string it is passed in-place as an in/out parameter for efficienty. This function is private and only called in 1 place, so the "API change" is ok here. - Other assorted cleanup. Test Plan --- - `ninja check check-functional` - Also try building with `cmake -GNinja .. -DCMAKE_BUILD_TYPE=Debug` - Try running bitcoind with `-logthreadnames=1 -logtimemicros -debug=all` (and/or combinations thereof) The debug.log file and the console output should still look ok.
- Loading branch information
Showing
2 changed files
with
42 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters