Skip to content

Commit

Permalink
Avoid syncing with stdio
Browse files Browse the repository at this point in the history
When writing to `std::cout` and `std::cerr`, and reading from `std::cin`
we sync with C standard stream by default, which has overhead.  As we
don't use C standard streams we can avoid this and gain a bit of
performance.
  • Loading branch information
elliotgoodrich committed Nov 21, 2024
1 parent 6d65d7d commit ec0772c
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/trimja.m.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ bool instrumentMemory = false;
// avoids the overhead of destructing objects on the stack.
using namespace trimja;

std::ios_base::sync_with_stdio(false);

struct StdIn {};
std::variant<std::monostate, StdIn, std::filesystem::path> affectedFile;

Expand Down

0 comments on commit ec0772c

Please sign in to comment.