Open
Description
At the moment substringFrom:to:
is implemented thus:
substringFrom: start to: end = (
((end <= self length) && (start > 0) && (start <= end))
ifTrue: [^self primSubstringFrom: start to: end]
ifFalse: [
self error: 'Attempting to index string out of its bounds (start: ' + start asString + ' end: ' + end asString + ' length: ' + self length asString + ')' ]
)
which feels unidiomatic because:
- there's no way that
primSubStringFrom:to:
can not recheck those indexes, since any old Tom, Dick, or Harry can callprimSubStringFrom:to:
with whatever arguments they want. - other indexing primitives such as
Array at:
do not have aprimAt
variant (i.e. the VM is expected to check the indexes).
I was expecting this part of the library to just be substringFrom:to: = primitive
-- perhaps we can simplify (and speed up!) this code by doing so?