-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove excessive usage of string_format
#33430
Conversation
… do it. The called functions do string formatting on their own.
The format string does not contain any format specifier so the output will be the same as the input anyway, so why even call the function?
No comment. Really: none. I have no words for this. Why? And ... Just: no.
especially as there are no further arguments there to be formatted.
Translate the raw string literal, not the formatted string. Use `to_string( time_duration )` instead of replicating the code.
} else { | ||
return _( string_format( "%d %s", to_hours<int>( turns * 1_turns ), "hours" ) ); | ||
return to_string( time_duration::from_turns( moves / 100 ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this round the time duration string like in the previous code, or does this give you an exact number?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It yields a string with up to two units (e.g. "2 hours and 5 minutes" - remaining seconds are ignored here).
@@ -909,13 +909,14 @@ std::string spell::enumerate_targets() const | |||
return all_valid_targets[0]; | |||
} | |||
std::string ret; | |||
// @todo if only we had a function to enumerate strings and concatenate them... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
enumerate_as_string
in output.h
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I was ironically referring to that one. As of now, I leave it to someone else to actually implement it.
SUMMARY: None
Removes usage when calling functions that do string formatting on their own (e.g.
add_msg
).Removes it when called on a string without any formatting specifiers.
Removes it when called with the format string "%s" (as it just passes the next argument through).
Fix some missing / incorrect translation code.