mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Omit needless words: remove arguments that match the default arguments.
For cases where the Clang importer provides a defaulted argument,
e.g., "[]" for option sets and "nil" for optionals, remove the
corresponding arguments at any call sites that simply specify "[]" or
"nil". Such arguments are basically noise, and tend to harm
readability when there are low-content argument labels like "with:" or
"for".
Some examples from Lister:
self.updateUserActivity(AppConfiguration.UserActivity.watch,
userInfo: userInfo, webpageURL: nil)
becomes
self.updateUserActivity(AppConfiguration.UserActivity.watch,
userInfo: userInfo)
and
contentView.hitTest(tapLocation, with: nil)
becomes
contentView.hitTest(tapLocation)
and
document.closeWithCompletionHandler(nil)
becomes simply
document.close()
and a whole pile of optional "completion handler" arguments go away.
Swift SVN r31978
This commit is contained in:
@@ -444,8 +444,9 @@ StringRef swift::omitNeedlessWords(StringRef name, OmissionTypeName typeName,
|
||||
if ((role == NameRole::FirstParameter ||
|
||||
role == NameRole::SubsequentParameter) &&
|
||||
(name == "usingBlock" || name == "withBlock") &&
|
||||
typeName.Name == "Block")
|
||||
typeName.Name == "Block") {
|
||||
return "body";
|
||||
}
|
||||
|
||||
// Get the camel-case words in the name and type name.
|
||||
auto nameWords = camel_case::getWords(name);
|
||||
|
||||
Reference in New Issue
Block a user