Skip to content

Commit

Permalink
reduce the amount of intermediate copying:
Browse files Browse the repository at this point in the history
  - no need to create a Set 
  - use #sort, not #sorted
  • Loading branch information
MarcusDenker committed Oct 14, 2019
1 parent 2268d33 commit 8ad55ef
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/NECompletion/AlphabeticSorter.class.st
Expand Up @@ -16,5 +16,5 @@ AlphabeticSorter class >> kind [
{ #category : #description }
AlphabeticSorter class >> sortCompletionList: aList [

^ aList sorted.
^ aList asOrderedCollection sort
]
2 changes: 1 addition & 1 deletion src/NECompletion/CompletionModel.class.st
Expand Up @@ -146,7 +146,7 @@ CompletionModel >> notEmpty [
{ #category : #accessing }
CompletionModel >> sortList: aList [
"this is where the sorting strategy is set"
^ sorter sortCompletionList: aList asOrderedCollection
^ sorter sortCompletionList: aList
]

{ #category : #accessing }
Expand Down
6 changes: 4 additions & 2 deletions src/NECompletion/CompletionProducerVisitor.class.st
Expand Up @@ -7,6 +7,9 @@ Class {
#instVars : [
'currentClass'
],
#classInstVars : [
'aCollection'
],
#category : #'NECompletion-New'
}

Expand All @@ -29,8 +32,7 @@ CompletionProducerVisitor >> methodNames [

{ #category : #utilities }
CompletionProducerVisitor >> select: aCollection beginningWith: aString [
"Set withAll: is needed to convert potential IdentitySets to regular Sets"
^ Set withAll: (aCollection select: [ :each | each beginsWith: aString asString ])
^ aCollection select: [ :each | each beginsWith: aString asString ]
]

{ #category : #visiting }
Expand Down
2 changes: 1 addition & 1 deletion src/NECompletion/ReverseAlphabeticSorter.class.st
Expand Up @@ -16,5 +16,5 @@ ReverseAlphabeticSorter class >> kind [
{ #category : #description }
ReverseAlphabeticSorter class >> sortCompletionList: aList [

^ aList sorted reverse.
^ aList asOrderedCollection sort reverse
]

0 comments on commit 8ad55ef

Please sign in to comment.