tst2005googlecode / re2

Automatically exported from code.google.com/p/re2
BSD 3-Clause "New" or "Revised" License
1 stars 0 forks source link

[cppcheck] suggested a few performance improvements #2

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Download cppcheck at http://sourceforge.net/projects/cppcheck/ and
install it
2. run it against re2 sources with ./cppcheck --enable=all re2/
3.

What is the expected output? What do you see instead?
Cppcheck prints a few hints to imporove performance, such as :

[re2/dfa.cc:59]: (Style) The function 'DFA::ok' can be const
[re2/dfa.cc:97]: (Style) The function 'DFA::State::IsMatch' can be const
[re2/prefilter.cc:162]: (possible style) Use ss.empty() instead of
ss.size() to guarantee fast code.

What version of the product are you using? On what operating system?
current head

Please provide any additional information below.

cppcheck printed a few other warnings:

[re2/nfa.cc:70]: (Style) Member variable not initialized in the constructor
'AddState::cap_j'
[re2/nfa.cc:72]: (Style) Member variable not initialized in the constructor
'AddState::cap_j'
[re2/nfa.cc:124]: (Style) Unused private function
'NFA::DISALLOW_EVIL_CONSTRUCTORS'
[re2/re2.cc:210]: (Style) Redundant condition. It is safe to deallocate a
NULL pointer
[re2/re2.cc:212]: (Style) Redundant condition. It is safe to deallocate a
NULL pointer
[re2/re2.cc:214]: (Style) Redundant condition. It is safe to deallocate a
NULL pointer
[re2/testing/backtrack.cc:78]: (Style) Member variable not initialized in
the constructor 'Backtracker::endmatch_'
[re2/testing/backtrack.cc:123]: (Style) Redundant condition. It is safe to
deallocate a NULL pointer
[re2/testing/string_generator.cc:30]: (Style) Redundant condition. It is
safe to deallocate a NULL pointer
[re2/testing/dfa_test.cc:93]: (Style) Variable 'dfamem' is assigned a value
that is never used
[re2/testing/dfa_test.cc:93]: (Style) Variable 'progusage' is assigned a
value that is never used
[re2/testing/tester.cc:268]: (Style) Redundant condition. It is safe to
deallocate a NULL pointer
[re2/testing/tester.cc:270]: (Style) Redundant condition. It is safe to
deallocate a NULL pointer
[re2/testing/tester.cc:272]: (Style) Redundant condition. It is safe to
deallocate a NULL pointer
[re2/testing/tester.cc:274]: (Style) Redundant condition. It is safe to
deallocate a NULL pointer
[re2/compile.cc:208]: (Style) Redundant condition. It is safe to deallocate
a NULL pointer
[re2/dfa.cc:407]: (Style) Member variable not initialized in the
constructor 'DFA::start_'

Please refer the attached patch that fixes the performance related things.

Best regards

Ettl Martin

Original issue reported on code.google.com by ettl.mar...@gmail.com on 14 Mar 2010 at 10:36

Attachments:

GoogleCodeExporter commented 9 years ago
This issue was closed by revision e74c398329.

Original comment by rsc+personal@swtch.com on 20 Mar 2010 at 4:56