This function is rarely used, so don't add another function pointer to reduce performance of most common case.
| 408 | // This function is rarely used, so don't add another function pointer to |
| 409 | // reduce performance of most common case. |
| 410 | int FormatPrintArg::AsInt() const |
| 411 | { |
| 412 | PrintSpecification spec; |
| 413 | spec.specifier = 'd'; |
| 414 | char buffer[32]; |
| 415 | { // Put t into a separate scope ensure '\0' is append after written. |
| 416 | BufferFormatPrintTarget t(buffer, sizeof(buffer)); |
| 417 | if (Write(&t, spec) <= 0) |
| 418 | return -1; |
| 419 | } |
| 420 | int n; |
| 421 | if (!StringToNumber(buffer, &n)) |
| 422 | return -1; |
| 423 | return n; |
| 424 | } |
| 425 | |
| 426 | } // namespace toft |
no test coverage detected