Skip to content

Commit

Permalink
Merge pull request #6868 from MarcusDenker/speedup-ReVariableReferenc…
Browse files Browse the repository at this point in the history
…edOnceRule

speedup-ReVariableReferencedOnceRule
  • Loading branch information
MarcusDenker committed Jul 17, 2020
2 parents b1eb4b6 + 3c4a584 commit a1044ca
Showing 1 changed file with 7 additions and 15 deletions.
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

0 comments on commit a1044ca

Please sign in to comment.