StandardFileStream>>readOnlyFileNamed:
Eric Arseneau
earseneau at exobox.com
Sat Dec 2 21:52:59 UTC 2000
There seems to be a slight performance problem with this method:
readOnlyFileNamed: fileName
"Open an existing file with the given name for reading."
"Changed to open a more usefull popup menu. It now also includes
the most likely choices. jaf"
| selection dir files choices newName fullName |
fullName _ self fullName: fileName.
(self isAFileNamed: fullName)
ifTrue: [^ self new open: fullName forWrite: false].
...
And now look at:
isAFileNamed: fileName
"Answer true if a file of the given name exists."
| f |
f _ self new open: fileName forWrite: false.
f ifNil: [^ false].
f close.
^ true
Note that there is two new open:forWrite: calls to open a single file. If
we change the previous code to:
readOnlyFileNamed: fileName
"Open an existing file with the given name for reading."
"Changed to open a more usefull popup menu. It now also includes
the most likely choices. jaf"
| selection dir files choices newName fullName |
fullName _ self fullName: fileName.
f := self new self new open: fullName forWrite: false.
f isNil ifFalse: [^f].
...
Would this not be more efficient ? It looks like the latest release could
use this same trick.
Does anybody see anything wrong with submitting this change as an [enh] ?
More information about the Squeak-dev
mailing list
|