Skip to content

enable more clang-tidy performance options #19656

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

Merged
merged 4 commits into from
May 6, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ Checks: >
-*,
performance-faster-string-find,
performance-for-range-copy,
performance-implicit-conversion-in-loop,
performance-inefficient-algorithm,
performance-inefficient-vector-operation,
performance-move-const-arg,
performance-type-promotion-in-math-fn,

WarningsAsErrors: '*'
HeaderFilterRegex: '/(?!external)/.*'
Expand Down
3 changes: 2 additions & 1 deletion cocos/base/ccUTF8.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,8 @@ long cc_utf8_strlen (const char * p, int /*max*/)
unsigned int cc_utf8_find_last_not_char(const std::vector<unsigned short>& str, unsigned short c)
{
std::vector<char16_t> char16Vector;
for (const auto& e : str)
char16Vector.reserve(str.size());
for (const auto& e : str)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

error indent

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. How do I even missed that?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@minggo is it possible to create .clang-format file for cocos2d-x and use automated formatting everywhere?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, sure. Would you please add one?

{
char16Vector.push_back(e);
}
Expand Down
2 changes: 1 addition & 1 deletion cocos/deprecated/CCString.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ __String* __String::createWithFormat(const char* format, ...)
__String* __String::createWithContentsOfFile(const std::string &filename)
{
std::string str = FileUtils::getInstance()->getStringFromFile(filename);
return __String::create(std::move(str));
return __String::create(str);
}

void __String::acceptVisitor(DataVisitor &visitor)
Expand Down
2 changes: 1 addition & 1 deletion cocos/editor-support/spine/Bone.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ void spBone_updateWorldTransformWith (spBone* self, float x, float y, float rota
za *= s;
zc *= s;
s = SQRT(za * za + zc * zc);
r = PI / 2 + atan2(zc, za);
r = PI / 2 + atan2f(zc, za);
zb = COS(r) * s;
zd = SIN(r) * s;
la = COS_DEG(shearX) * scaleX;
Expand Down
4 changes: 2 additions & 2 deletions cocos/platform/CCFileUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,7 @@ std::string FileUtils::fullPathForDirectory(const std::string &dir) const
{
for (const auto& resolutionIt : _searchResolutionsOrderArray)
{
fullpath = searchIt + longdir + resolutionIt;
fullpath.append(searchIt).append(longdir).append(resolutionIt);
auto exists = isDirectoryExistInternal(fullpath);

if (exists && !fullpath.empty())
Expand Down Expand Up @@ -1180,7 +1180,7 @@ bool FileUtils::isDirectoryExist(const std::string& dirPath) const
for (const auto& resolutionIt : _searchResolutionsOrderArray)
{
// searchPath + file_path + resourceDirectory
fullpath = fullPathForDirectory(searchIt + dirPath + resolutionIt);
fullpath = fullPathForDirectory(std::string(searchIt).append(dirPath).append(resolutionIt));
if (isDirectoryExistInternal(fullpath))
{
_fullPathCacheDir.emplace(dirPath, fullpath);
Expand Down
2 changes: 1 addition & 1 deletion cocos/renderer/CCGLProgramState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ bool GLProgramState::init(GLProgram* glprogram)

for(auto &uniform : _glprogram->_userUniforms) {
UniformValue value(&uniform.second, _glprogram);
_uniforms[uniform.second.location] = std::move(value);
_uniforms[uniform.second.location] = value;
_uniformsByName[uniform.first] = uniform.second.location;
}

Expand Down
6 changes: 4 additions & 2 deletions extensions/Particle3D/PU/CCPUScriptLexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,10 @@ void PUScriptLexer::openLexer(const std::string &str,const std::string &source,P
else
{
// Backtrack here and allow a backslash normally within the quote
if(lastc == backslash)
lexeme = lexeme + "\\" + c;
if(lastc == backslash) {
lexeme += '\\';
lexeme += c;
}
else
lexeme += c;
}
Expand Down