StrCat with this many params is exceedingly rare, but it has been requested... therefore we'll rely on default arguments to make calling slightly less efficient, to preserve code size.
| 148 | // requested... therefore we'll rely on default arguments to make calling |
| 149 | // slightly less efficient, to preserve code size. |
| 150 | string StrCatNineOrMore(const AlphaNum *a, ...) { |
| 151 | string result; |
| 152 | |
| 153 | va_list args; |
| 154 | va_start(args, a); |
| 155 | size_t size = a->size(); |
| 156 | while (const AlphaNum *arg = va_arg(args, const AlphaNum *)) { |
| 157 | size += arg->size(); |
| 158 | } |
| 159 | STLStringResizeUninitialized(&result, size); |
| 160 | va_end(args); |
| 161 | va_start(args, a); |
| 162 | char *const begin = &*result.begin(); |
| 163 | char *out = Append1(begin, *a); |
| 164 | while (const AlphaNum *arg = va_arg(args, const AlphaNum *)) { |
| 165 | out = Append1(out, *arg); |
| 166 | } |
| 167 | va_end(args); |
| 168 | DCHECK_EQ(out, begin + size); |
| 169 | return result; |
| 170 | } |
| 171 | |
| 172 | } // namespace internal |
| 173 | } // namespace strings |
no test coverage detected