|Anonymous | Login||02-19-2019 21:29 UTC|
|Main | My View | View Issues | Change Log | Docs|
|Viewing Issue Simple Details [ Jump to Notes ]||[ View Advanced ] [ Issue History ] [ Print ]|
|ID||Category||Severity||Reproducibility||Date Submitted||Last Update|
|0002143||[Squeak] Collections||minor||always||10-30-05 18:36||01-18-06 19:21|
|Summary||0002143: usage of second/third/fourth/fifth/etc|
Use of method accessors that resolve to at: are expensive and contain uneeded code.
SequenceableCollection>>fifth for example
"Answer the fifth element of the receiver.
Raise an error if there are not enough elements."
^ self checkedAt: 5
index > self size ifTrue: [self error: 'not enough elements'].
^ self at: index
Note the index check, but then we fall into self at: which I believe all at: do an index anyways to protect us from disaster. I'll also note that foo fifth under an error condition would have raised error: 'not enough elements': versus saying foo at: which would have raised error: 'subscript is out of bounds: '
"Primitive. Assumes receiver is indexable. Answer the value of an
indexable element in the receiver. Fail if the argument index is not an
Integer or is out of bounds. Essential. See Object documentation
index isInteger ifTrue:
[self class isVariable
ifTrue: [self errorSubscriptBounds: index]
ifFalse: [self errorNotIndexable]].
ifTrue: [^self at: index asInteger]
ifFalse: [self errorNonIntegerIndex]
I've included a changset to change the second/third/.../ninth methods to just invoke at:
method first is a bit different and I left it unaltered for now.
However one might look at first and see if the logic there is needed?
Some implementations invoke self emptyCheck, but is that any different than saying at: 1 ?
|Attached Files||JMMRemoveExtraIndexCheck.1.cs [^] (1,695 bytes) 10-30-05 18:36|
|10-30-05 18:36||johnmci||New Issue|
|10-30-05 18:36||johnmci||File Added: JMMRemoveExtraIndexCheck.1.cs|
|01-18-06 19:21||MarcusDenker||Status||new => closed|
|01-18-06 19:21||MarcusDenker||Note Added: 0003535|
|01-18-06 19:21||MarcusDenker||Resolution||open => fixed|
|01-18-06 19:21||MarcusDenker||Fixed in Version||=> 3.9|
| Mantis 1.0.8[^]
Copyright © 2000 - 2007 Mantis Group
37 total queries executed.|
30 unique queries executed.