mirror of
https://github.com/pybind/pybind11.git
synced 2026-04-19 22:39:09 +00:00
fix(clang-tidy): performance fixes applied in tests and CI (#3051)
* Initial fixes * Whoops * Finish clang-tidy manual fixes * Add two missing fixes * Revert * Update clang-tidy * Try to fix unreachable code error * Move nolint comment * Apply missing fix * Don't override clang-tidy config * Does this fix clang-tidy? * Make all clang-tidy errors visible * Add comments about NOLINTs and remove a few * Fix typo
This commit is contained in:
@@ -17,15 +17,14 @@
|
||||
#include <iostream>
|
||||
#include <thread>
|
||||
|
||||
|
||||
void noisy_function(std::string msg, bool flush) {
|
||||
void noisy_function(const std::string &msg, bool flush) {
|
||||
|
||||
std::cout << msg;
|
||||
if (flush)
|
||||
std::cout << std::flush;
|
||||
}
|
||||
|
||||
void noisy_funct_dual(std::string msg, std::string emsg) {
|
||||
void noisy_funct_dual(const std::string &msg, const std::string &emsg) {
|
||||
std::cout << msg;
|
||||
std::cerr << emsg;
|
||||
}
|
||||
@@ -70,12 +69,12 @@ TEST_SUBMODULE(iostream, m) {
|
||||
|
||||
// test_evals
|
||||
|
||||
m.def("captured_output_default", [](std::string msg) {
|
||||
m.def("captured_output_default", [](const std::string &msg) {
|
||||
py::scoped_ostream_redirect redir;
|
||||
std::cout << msg << std::flush;
|
||||
});
|
||||
|
||||
m.def("captured_output", [](std::string msg) {
|
||||
m.def("captured_output", [](const std::string &msg) {
|
||||
py::scoped_ostream_redirect redir(std::cout, py::module_::import("sys").attr("stdout"));
|
||||
std::cout << msg << std::flush;
|
||||
});
|
||||
@@ -84,7 +83,7 @@ TEST_SUBMODULE(iostream, m) {
|
||||
py::call_guard<py::scoped_ostream_redirect>(),
|
||||
py::arg("msg"), py::arg("flush")=true);
|
||||
|
||||
m.def("captured_err", [](std::string msg) {
|
||||
m.def("captured_err", [](const std::string &msg) {
|
||||
py::scoped_ostream_redirect redir(std::cerr, py::module_::import("sys").attr("stderr"));
|
||||
std::cerr << msg << std::flush;
|
||||
});
|
||||
@@ -95,15 +94,11 @@ TEST_SUBMODULE(iostream, m) {
|
||||
py::call_guard<py::scoped_ostream_redirect, py::scoped_estream_redirect>(),
|
||||
py::arg("msg"), py::arg("emsg"));
|
||||
|
||||
m.def("raw_output", [](std::string msg) {
|
||||
std::cout << msg << std::flush;
|
||||
});
|
||||
m.def("raw_output", [](const std::string &msg) { std::cout << msg << std::flush; });
|
||||
|
||||
m.def("raw_err", [](std::string msg) {
|
||||
std::cerr << msg << std::flush;
|
||||
});
|
||||
m.def("raw_err", [](const std::string &msg) { std::cerr << msg << std::flush; });
|
||||
|
||||
m.def("captured_dual", [](std::string msg, std::string emsg) {
|
||||
m.def("captured_dual", [](const std::string &msg, const std::string &emsg) {
|
||||
py::scoped_ostream_redirect redirout(std::cout, py::module_::import("sys").attr("stdout"));
|
||||
py::scoped_ostream_redirect redirerr(std::cerr, py::module_::import("sys").attr("stderr"));
|
||||
std::cout << msg << std::flush;
|
||||
|
||||
Reference in New Issue
Block a user