Skip to content

Commit

Permalink
Make memberToSelector:for:arguments: more efficient
Browse files Browse the repository at this point in the history
  • Loading branch information
fniephaus committed Aug 29, 2021
1 parent f96af0f commit aef306b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
dispatch
memberToSelector: aMember for: anObject arguments: arguments
| selectorName currentClass |
selectorName := (aMember asString copyReplaceAll: '_' with: ':'), (
arguments ifEmpty: [ '' ] ifNotEmpty: [ ':' ]).
currentClass := anObject class.
[ currentClass isNil ] whileFalse: [
currentClass selectors
detect: [ :ea | ea = selectorName ]
ifFound: [ :s | ^ s ].
currentClass := currentClass superclass ].
^ nil
| selector |
selector := ((aMember asString copyReplaceAll: '_' with: ':'), (
arguments ifEmpty: [ '' ] ifNotEmpty: [ ':' ])) asSymbol.
^ (anObject class canUnderstand: selector)
ifTrue: [ selector ] ifFalse: [ nil ]
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
"isTime:" : "fn 3/5/2021 14:27",
"isTimeZone:" : "fn 3/5/2021 14:27",
"memberToSelector:for:" : "fn 3/9/2021 12:49",
"memberToSelector:for:arguments:" : "fn 3/9/2021 12:49",
"memberToSelector:for:arguments:" : "fn 8/19/2021 14:49",
"readArrayElement:index:" : "fn 3/5/2021 14:52",
"readBufferByte:index:" : "fn 6/26/2021 14:35",
"readBufferDouble:index:" : "fn 6/26/2021 14:35",
Expand Down

0 comments on commit aef306b

Please sign in to comment.