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

Remove #byName cache on group storages #823

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions src/Famix-Java-Entities/FamixJavaContainerEntity.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,3 @@ FamixJavaContainerEntity >> addInterface: anInterface [

types add: anInterface
]

{ #category : #'Famix-Java' }
FamixJavaContainerEntity >> mooseNameWithDots [
^ self mooseName ifNotNil: [ :mName | '.' join: (mName substrings: '::') ]
]
29 changes: 13 additions & 16 deletions src/Moose-Core/MooseAbstractGroup.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -390,23 +390,27 @@ MooseAbstractGroup >> entitiesDo: aBlock [
]

{ #category : #'public interface' }
MooseAbstractGroup >> entityNamed: aSymbol [

^self
entityNamed: aSymbol
ifAbsent: [nil]
MooseAbstractGroup >> entityNamed: aSymbol [

^ self entityNamed: aSymbol ifAbsent: [ nil ]
]

{ #category : #'public interface' }
MooseAbstractGroup >> entityNamed: aMooseName ifAbsent: aBlock [
^ self entityStorage at: aMooseName ifAbsent: aBlock
MooseAbstractGroup >> entityNamed: aMooseName ifAbsent: aBlock [

^ self entities
detect: [ :entity | entity hasUniqueMooseNameInModel and: [ entity mooseName = aMooseName ] ]
ifNone: aBlock
]

{ #category : #'public interface' }
MooseAbstractGroup >> entityNamed: aMooseName ifAbsent: aBlock ifPresent: anotherBlock [

| entity |
entity := self entityStorage at: aMooseName ifAbsent: [ nil ].
^ entity ifNil: [ aBlock value ] ifNotNil: [ anotherBlock value: entity ]
entity := self entityNamed: aMooseName ifAbsent: [ nil ].
^ entity
ifNil: [ aBlock value ]
ifNotNil: [ anotherBlock value: entity ]
]

{ #category : #'public interface' }
Expand Down Expand Up @@ -728,13 +732,6 @@ MooseAbstractGroup >> removeEntity: anEntity [
^ self entityStorage remove: anEntity
]

{ #category : #loading }
MooseAbstractGroup >> resetMooseNameFor: anEntity [
self entityStorage resetMooseNameFor: anEntity.
" this is safe, but probably a bit overdone "
self flush
]

{ #category : #accessing }
MooseAbstractGroup >> second [

Expand Down
42 changes: 4 additions & 38 deletions src/Moose-Core/MooseGroupStorage.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ Class {
#superclass : #Collection,
#type : #variable,
#instVars : [
'byName',
'elements',
'byType',
'species'
Expand Down Expand Up @@ -77,19 +76,6 @@ MooseGroupStorage >> allEntityTypes [
^ byType keys
]

{ #category : #accessing }
MooseGroupStorage >> at: uniqueName [

^self
at: uniqueName asSymbol
ifAbsent: [nil]
]

{ #category : #accessing }
MooseGroupStorage >> at: uniqueName ifAbsent: exceptionBlock [
^byName at: uniqueName asSymbol ifAbsent: exceptionBlock
]

{ #category : #iterators }
MooseGroupStorage >> basicIterator [
^ self elements basicIterator
Expand Down Expand Up @@ -125,7 +111,6 @@ MooseGroupStorage >> includesID: mooseID [
MooseGroupStorage >> initialize: capacity [

byType := IdentityDictionary new: 24.
byName := IdentityHashTable new: capacity.
species := OrderedCollection.
elements := self species new: capacity
]
Expand All @@ -136,10 +121,10 @@ MooseGroupStorage >> iterator [
]

{ #category : #copying }
MooseGroupStorage >> postCopy [
MooseGroupStorage >> postCopy [

super postCopy.
elements := elements copy.
byName := byName copy.
byType := byType copy
]

Expand Down Expand Up @@ -169,17 +154,6 @@ MooseGroupStorage >> removeAll [
self initialize: 10000
]

{ #category : #private }
MooseGroupStorage >> resetMooseNameFor: anEntity [

anEntity hasUniqueMooseNameInModel
ifTrue: [
byName removeKey: anEntity mooseName asSymbol ifAbsent: [ ].
anEntity privateClearMooseName.
byName at: anEntity mooseName asSymbol put: anEntity ]
ifFalse: [ anEntity privateClearMooseName ]
]

{ #category : #enumerating }
MooseGroupStorage >> selectAllWithType: aSmalltalkType [
^ byType
Expand Down Expand Up @@ -217,23 +191,15 @@ MooseGroupStorage >> species: aCollectionClass [

{ #category : #private }
MooseGroupStorage >> updateCacheOnAddingOf: anElement [

(byType atOrOrederedCollection: anElement class) add: anElement.
anElement hasUniqueMooseNameInModel ifTrue: [ byName at: anElement mooseName put: anElement ].
^ anElement
]

{ #category : #private }
MooseGroupStorage >> updateCacheOnRemovalOf: anElement [
byType at: anElement class ifPresent: [ :group |
group remove: anElement ifAbsent: [ self error: 'Internal storage inconsistency' ] ].

anElement hasUniqueMooseNameInModel ifFalse: [ ^ anElement ].
byType at: anElement class ifPresent: [ :group | group remove: anElement ifAbsent: [ self error: 'Internal storage inconsistency' ] ].

byName
at: anElement mooseName
ifAbsent: [ "In theory, objects are registered under their mooseName,
however some objects are still registered by their name
if #resetMooseName was not used when needed" self resetMooseNameFor: anElement ].
byName removeKey: anElement mooseName ifAbsent: [ self error: 'Internal storage inconsistency' ].
^ anElement
]
2 changes: 1 addition & 1 deletion src/Moose-Core/MooseObject.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ MooseObject >> resetMooseName [

(self hasUniqueMooseNameInModel and: [ self hasMooseModel ]) ifFalse: [ ^ false ].

self mooseModel resetMooseNameFor: self.
self privateClearMooseName.

^ true
]
Expand Down
Loading