Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Create check to prefer wxEmptyString over wxT("") #27299

Open Quuxplusone opened 8 years ago

Quuxplusone commented 8 years ago
Bugzilla Link PR27300
Status NEW
Importance P enhancement
Reported by Richard (legalize@xmission.com)
Reported on 2016-04-08 16:16:34 -0700
Last modified on 2018-03-08 01:03:28 -0800
Version unspecified
Hardware All All
CC alexfh@google.com, djasper@google.com, eugene.zelenko@gmail.com, fuscated@gmail.com, klimek@google.com
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also

wxWidgets has a preconstructed empty string object wxEmptyString of type wxString.

This should be preferred over wxT("") as this constructs an anonymously named temporary of type wxString wherever wxEmptyString could be used instead.

Particularly for default values of functions taking references to const wxString, this can save creating and destroying anonymous temporaries for every function call.

There are probably other wxWidgets idioms that make sense for clang-tidy.

This check should probably go in a wxWidgets module.

Quuxplusone commented 8 years ago

Clang-tidy already has readability-redundant-string-init check which work for STL strings. Will be good idea to expand it instead iof introducing new one.

Quuxplusone commented 8 years ago

This isn't the same thing, because we are checking for more things than just constructing an object.

Quuxplusone commented 8 years ago

A similar check could be created for std::string::operator== vs std::string::compare

Quuxplusone commented 8 years ago

Oops, ignore my last comment, it was intended for another bug.