Much smaller improvement on Windows but still nice to have. Old: '10,100 per second. 98.6 microseconds per run. 0 % GC time.' New: '14,700 per second. 67.8 microseconds per run. 0 % GC time.'
(paths used '\no\where\at\all', '\Users\eliot\Desktop\not there' FileDirectory default)
On Wed, Jul 13, 2022 at 9:09 PM commits@source.squeak.org wrote:
Eliot Miranda uploaded a new version of Files to project The Trunk: http://source.squeak.org/trunk/Files-eem.195.mcz
==================== Summary ====================
Name: Files-eem.195 Author: eem Time: 13 July 2022, 9:09:36.427827 pm UUID: 7ccbfb5c-e5d3-4911-9497-09fdc484d09c Ancestors: Files-eem.194
Occasionally FileDirectory>>exists fails. The old implementation seems unreliable, but it's also slow. So if possible, implement it above primLookupEntryIn:name:
Old: | foo bar baz | foo := FileDirectory on: '/no/where/at/all'. bar := FileDirectory on: '/Users/eliot/Desktop/not there'. baz := FileDirectory default. [foo exists. bar exists. baz exists] bench '8,070 per second. 124 microseconds per run. 0 % GC time.'
New: | foo bar baz | foo := FileDirectory on: '/no/where/at/all'. bar := FileDirectory on: '/Users/eliot/Desktop/not there'. baz := FileDirectory default. [foo exists. bar exists. baz exists] bench '73,700 per second. 13.6 microseconds per run. 0.64 % GC time.'
=============== Diff against Files-eem.194 ===============
Item was changed: ----- Method: FileDirectory>>exists (in category 'testing') ----- exists
"Answer whether the directory exists"
^self class currentDirectoryNickname
ifNotNil:
[:me|
(self primLookupEntryIn: pathName asVmPathName
name: me asVmPathName)
ifNil: [false]
ifNotNil: [:maybeErr| maybeErr ~~
#primFailed]]
ifNil:
[(self primLookupEntryIn: pathName asVmPathName
index: 1) ~~ #badDirectoryPath]!
- "Answer whether the directory exists"
| result |
result := self primLookupEntryIn: pathName asVmPathName index: 1.
^ result ~= #badDirectoryPath
- !