Don't use printf("%d") just to convert an int to a string.

std::to_string, std::to_wstring are more appropriate
This commit is contained in:
Aaron Gyes
2019-02-18 23:12:03 -08:00
parent 59cb2d02a8
commit c2bc0c67f2
3 changed files with 5 additions and 10 deletions

View File

@@ -2013,15 +2013,13 @@ bool reader_get_selection(size_t *start, size_t *len) {
void set_env_cmd_duration(struct timeval *after, struct timeval *before, env_stack_t &vars) {
time_t secs = after->tv_sec - before->tv_sec;
suseconds_t usecs = after->tv_usec - before->tv_usec;
wchar_t buf[16];
if (after->tv_usec < before->tv_usec) {
usecs += 1000000;
secs -= 1;
}
swprintf(buf, 16, L"%d", (secs * 1000) + (usecs / 1000));
vars.set_one(ENV_CMD_DURATION, ENV_UNEXPORT, buf);
vars.set_one(ENV_CMD_DURATION, ENV_UNEXPORT, std::to_wstring((secs * 1000) + (usecs / 1000)));
}
void reader_run_command(parser_t &parser, const wcstring &cmd) {