errorlogger.cpp: avoid unnecessary storing of line contents - reduces average Ir from 201,554 to 164,375 when scanning test folder with --debug warnings
Total Ir - before and after
3,053,160,825
2,606,367,442
This mainly helps daca which produces a lot of warnings. I think we should not be wasting unnecessary resources with it if possible. This can also be even more optimized by using some caching so the file doesn't have to be read over and over.
Performing a --enable=all --inconclusive --debug-warning --check-library and DISABLE_VALUEFLOW=1 scan on mame_regtest
Clang 14 1,924,223,071 -> 1,893,582,865
And scanning cli with --enable=all --inconclusive -Ilib -D __GNUC__ --debug-warning --check-library and DISABLE_VALUEFLOW=1
Clang 14 2,045,651,123 -> 2,044,209,849
std::istream::ignore() is unfortunately still an expensive call so we don't save as much as anticipated and it still takes up over 6% of the Ir with the mame_regtest case. I assume there's packages in daca which are much, much worse.
Okay - the actual problem is different...
We open a file and go through it for each error. If there are 1000 errors in a single files we will read the file 1000 times.
As it is immediately written/converted when calling reportError() there's no way to collect this information and set them afterwards.
In process mode we collect all the data and send it via a pipe to the main process. Maybe this behavior can be used in all cases.
I will close this PR and file a ticket about it.
I filed https://trac.cppcheck.net/ticket/11347 about this.
daca also doesn't lookup the code at all so it would not be affected by this optimization.