Skip to content

Token: allow the compiler to inline *At() calls#6479

Merged
chrchr-github merged 1 commit intocppcheck-opensource:mainfrom
firewave:tok-at
Jun 2, 2024
Merged

Token: allow the compiler to inline *At() calls#6479
chrchr-github merged 1 commit intocppcheck-opensource:mainfrom
firewave:tok-at

Conversation

@firewave
Copy link
Copy Markdown
Collaborator

@firewave firewave commented Jun 1, 2024

No description provided.

@firewave
Copy link
Copy Markdown
Collaborator Author

firewave commented Jun 1, 2024

Token::tokAt() is actually one of the heavier calls.

Clang 17 1,230,369,784 -> 1,195,033,191

Comment thread lib/token.h
{
T *tok = thisTok->tokAt(index);
if (!tok) {
throw InternalError(thisTok, "Internal error. Token::linkAt called with index outside the tokens range.");
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I wonder if we should remove this and just let the code crash.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Does it affect performance?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Technically it should because it can raise an exception (hence why noexcept is a thing).

In a short test:
Clang 17 1,194,021,239 -> 1,191,122,393

@firewave
Copy link
Copy Markdown
Collaborator Author

firewave commented Jun 1, 2024

callgrind in CI 64,212,820,811 -> 63,636,646,190

@chrchr-github chrchr-github merged commit edf0104 into cppcheck-opensource:main Jun 2, 2024
@firewave firewave deleted the tok-at branch June 3, 2024 07:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants