Use pool of buffers in TimeToString().

This commit is contained in:
Bartosz Taudul 2017-09-20 21:25:00 +02:00
parent 1fef4f9202
commit 7bc730ab73

View File

@ -337,7 +337,12 @@ uint64_t View::GetLastTime() const
const char* View::TimeToString( uint64_t ns ) const const char* View::TimeToString( uint64_t ns ) const
{ {
static char buf[64]; enum { Pool = 4 };
static char bufpool[Pool][64];
static int bufsel = 0;
char* buf = bufpool[bufsel];
bufsel = ( bufsel + 1 ) % Pool;
if( ns < 1000 ) if( ns < 1000 )
{ {
sprintf( buf, "%i ns", ns ); sprintf( buf, "%i ns", ns );