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 in AlbTextEditorLineSegmentPieceMap #35

Merged
Merged
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
16 changes: 7 additions & 9 deletions src/Album/AlbTextEditorLineSegmentPieceMap.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,18 @@ AlbTextEditorLineSegmentPieceMap >> initialize [

{ #category : #accessing }
AlbTextEditorLineSegmentPieceMap >> pieceForElement: aBlElement ifAbsent: anAbsentBlock [
<return: #AlbTextEditorAbstractSegmentPiece or: #Object>
map associations do: [ :eachAssociation |
(eachAssociation value includes: aBlElement)
ifTrue: [ ^ eachAssociation key ] ].

^ anAbsentBlock value
^ self
pieceForElement: aBlElement
ifPresent: [ :aPiece | ^ aPiece ]
ifAbsent: anAbsentBlock
]

{ #category : #accessing }
AlbTextEditorLineSegmentPieceMap >> pieceForElement: aBlElement ifPresent: aBlock ifAbsent: anAbsentBlock [
<return: #AlbTextEditorAbstractSegmentPiece or: #Object>
map associations do: [ :eachAssociation |
(eachAssociation value includes: aBlElement)
ifTrue: [ ^ aBlock value: eachAssociation key ] ].

map keysAndValuesDo: [ :k :v |
(v includes: aBlElement) ifTrue: [ ^ aBlock value: k ] ].

^ anAbsentBlock value
]
Expand Down