Skip to content
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

Merged
merged 8 commits into from
Aug 22, 2019
Merged

Conversation

BevapDin
Copy link
Contributor

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.

… 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 ) );
Copy link
Member

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?

Copy link
Contributor Author

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).

@KorGgenT KorGgenT added [C++] Changes (can be) made in C++. Previously named `Code` Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style Translation I18n labels Aug 21, 2019
@@ -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...
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@ZhilkinSerg ZhilkinSerg merged commit 8348c9f into CleverRaven:master Aug 22, 2019
@BevapDin BevapDin deleted the hps branch August 22, 2019 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C++] Changes (can be) made in C++. Previously named `Code` Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style Translation I18n
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants