Skip to content
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

speedup-ReVariableReferencedOnceRule #6868

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 7 additions & 15 deletions src/GeneralRules/ReVariableReferencedOnceRule.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,13 @@ ReVariableReferencedOnceRule class >> uniqueIdentifierName [

{ #category : #running }
ReVariableReferencedOnceRule >> basicCheck: aClass [
^ aClass instVarNames
anySatisfy: [ :each |
| defClass selector |
(aClass withAllSubclasses
inject: 0
into: [ :sum :class |
| sels |
sels := class whichSelectorsAccess: each.
sels size == 1
ifTrue: [ selector := sels asArray first.
defClass := class ].
sum + sels size ]) == 1
and: [ | tree |
tree := defClass parseTreeFor: selector.
tree notNil and: [ RBReadBeforeWrittenTester isVariable: each writtenBeforeReadIn: tree ] ] ]
^ aClass slots anySatisfy: [ :slot |
| usingMethods |
usingMethods := slot usingMethods.
usingMethods size = 1 and: [
RBReadBeforeWrittenTester
isVariable: slot name
writtenBeforeReadIn: usingMethods first ast ] ]
]

{ #category : #accessing }
Expand Down