mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-12 03:29:00 +08:00
optimize string_printf
This commit is contained in:
parent
c6310e49b3
commit
ad3e3be3bc
@ -585,8 +585,8 @@ std::string string_printf(const char *format, ...)
|
|||||||
va_list args2;
|
va_list args2;
|
||||||
va_copy(args2, args1);
|
va_copy(args2, args1);
|
||||||
|
|
||||||
static const size_t INITIAL_LEN = 1024;
|
static const size_t INITIAL_LEN = 200;
|
||||||
std::vector<char> buffer(INITIAL_LEN, '\0');
|
std::string buffer(INITIAL_LEN, '\0');
|
||||||
|
|
||||||
int bufflen = ::vsnprintf(buffer.data(), INITIAL_LEN - 1, format, args1);
|
int bufflen = ::vsnprintf(buffer.data(), INITIAL_LEN - 1, format, args1);
|
||||||
|
|
||||||
@ -595,7 +595,9 @@ std::string string_printf(const char *format, ...)
|
|||||||
::vsnprintf(buffer.data(), buffer.size(), format, args2);
|
::vsnprintf(buffer.data(), buffer.size(), format, args2);
|
||||||
}
|
}
|
||||||
|
|
||||||
return std::string(buffer.begin(), buffer.begin() + bufflen);
|
buffer.resize(bufflen);
|
||||||
|
|
||||||
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string header_slic3r_generated()
|
std::string header_slic3r_generated()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user