Anonymous | Login | 04-12-2021 13:32 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 | ||||
Reporter | johnmci | View Status | public | ||||||
Assigned To | |||||||||
Priority | normal | Resolution | fixed | ||||||
Status | closed | Product Version | |||||||
Summary | 0002143: usage of second/third/fourth/fifth/etc | ||||||||
Description |
Use of method accessors that resolve to at: are expensive and contain uneeded code. SequenceableCollection>>fifth for example fifth "Answer the fifth element of the receiver. Raise an error if there are not enough elements." ^ self checkedAt: 5 SequenceableCollection>>checkedAt: index 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: ' at: index "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 whatIsAPrimitive." <primitive: 60> index isInteger ifTrue: [self class isVariable ifTrue: [self errorSubscriptBounds: index] ifFalse: [self errorNotIndexable]]. index isNumber ifTrue: [^self at: index asInteger] ifFalse: [self errorNonIntegerIndex] |
||||||||
Additional Information |
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 |
![]() |
||||||||
|
Mantis 1.0.8[^]
Copyright © 2000 - 2007 Mantis Group
37 total queries executed. 30 unique queries executed. |