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