Optimize for binary size

This commit is contained in:
topjohnwu 2024-03-22 16:47:48 -07:00
parent 08dbf728a4
commit 9a008c17ba

View File

@ -55,14 +55,10 @@ static inline void expand(F &&f, T &&...args) {
template<typename ...T> template<typename ...T>
static inline void expand(const Str &s, T &&...args) { static inline void expand(const Str &s, T &&...args) {
char buf[64];
if (s.length() >= sizeof(buf)) return;
if (s.empty()) { if (s.empty()) {
expand(std::forward<T>(args)..., (char *) nullptr); expand(std::forward<T>(args)..., (char *) nullptr);
} else { } else {
memcpy(buf, s.data(), s.length()); expand(std::forward<T>(args)..., std::string(s).data());
buf[s.length()] = '\0';
expand(std::forward<T>(args)..., buf);
} }
} }