Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Since I've been back in the
scc
code, I got tempted to make an(other) attempt to break up the complexity in theCountStats
state machine.This changes from states being an enum, with all the state tracked in
CountStats
and passed in/out of the different methods to introduce aState
interface with different states having theirstateXYZ
function moved to being attached to the relevant struct. This means we can drop theswitch
statement in the core loop and instead let the go runtime do the dispatch. It also lets relevant state be tracked in theState
struct instead of being passed in and out ofCountStats
.As a bonus, the different 'flavours' of
slComment
vsslCommentCode
, etc are no longer required.It seems to produce the same result in the examples I've thrown at it, other than python docstrings - issue #246 doesn't exist in this implementation (this mismatch is how I found that issue in the first place). It could probably use a bit more hammering just to make sure though - I haven't tested permutations of optional flags for example.
Performance is roughly on par with the current implementation, only being marginally slower: