mirror of
https://github.com/catchorg/Catch2.git
synced 2024-12-22 19:33:29 +01:00
Use precomputed string sizes when constructing std::strings
This commit is contained in:
parent
a01073d871
commit
0e2895934c
@ -69,11 +69,13 @@ namespace Catch {
|
||||
// Save previous errno, to prevent sprintf from overwriting it
|
||||
ErrnoGuard guard;
|
||||
#ifdef _MSC_VER
|
||||
sprintf_s( buffer, "%.3f", duration );
|
||||
size_t printedLength = static_cast<size_t>(
|
||||
sprintf_s( buffer, "%.3f", duration ) );
|
||||
#else
|
||||
std::snprintf( buffer, maxDoubleSize, "%.3f", duration );
|
||||
size_t printedLength = static_cast<size_t>(
|
||||
std::snprintf( buffer, maxDoubleSize, "%.3f", duration ) );
|
||||
#endif
|
||||
return std::string( buffer );
|
||||
return std::string( buffer, printedLength );
|
||||
}
|
||||
|
||||
bool shouldShowDuration( IConfig const& config, double duration ) {
|
||||
|
@ -38,7 +38,7 @@ namespace Catch {
|
||||
|
||||
std::strftime(timeStamp, timeStampSize, fmt, &timeInfo);
|
||||
|
||||
return std::string(timeStamp);
|
||||
return std::string(timeStamp, timeStampSize - 1);
|
||||
}
|
||||
|
||||
std::string fileNameTag(std::vector<Tag> const& tags) {
|
||||
|
Loading…
Reference in New Issue
Block a user