Faster fileOut
Andres Valloud
avalloud at entrypoint.com
Mon Apr 17 18:48:57 UTC 2000
Hi.
Here's an improved implementation of Behavior>>allSuperclasses and of a
class method in class ChangeSet that determines the order in which
classes' and metaclasses' changes have to be filed out. I mentioned
earlier that I have a 714 classes, 3 mb changeset and that filing it out
took ~95 seconds. With these modifications, now it takes ~18 seconds;
the part that was improved went from 67 seconds to 3.2 seconds.
Andres.
-------------- next part --------------
'From Squeak2.6 of 11 October 1999 [latest update: #1578] on 17 April 2000 at 11:45:48 am'!
"Change Set: FileOut
Date: 17 April 2000
Author: Andres Valloud
Behavior>>allSuperclasses is a bit faster.
Fixes in ChangeSet --- a part of fileOut
is now 20+ times faster!!!!!!"!
!Behavior methodsFor: 'accessing class hierarchy' stamp: 'SqR 4/12/2000 19:17'!
allSuperclasses
"Answer an OrderedCollection of the receiver's and the receiver's
ancestor's superclasses. The first element is the receiver's immediate
superclass, followed by its superclass; the last element is ProtoObject."
| answer currentClass |
answer _ OrderedCollection new: 20.
currentClass _ self superclass.
[currentClass isNil] whileFalse:
[
answer add: currentClass.
currentClass _ currentClass superclass
].
^answer! !
!ChangeSet class methodsFor: 'fileIn/Out' stamp: 'SqR 4/12/2000 22:02'!
doWeFileOut: aClass given: aSet cache: cache
| aClassAllSuperclasses aClassSoleInstanceAllSuperclasses |
aClassAllSuperclasses _ cache at: aClass
ifAbsent: [cache at: aClass put: aClass allSuperclasses].
(aSet includesAnyOf: aClassAllSuperclasses) ifTrue: [^false].
aClass isMeta ifFalse: [^true].
(aSet includes: aClass soleInstance) ifTrue: [^false].
aClassSoleInstanceAllSuperclasses _ cache at: aClass soleInstance
ifAbsent: [cache at: aClass soleInstance put: aClass soleInstance allSuperclasses].
(aSet includesAnyOf: aClassSoleInstanceAllSuperclasses) ifTrue: [^false].
^true! !
!ChangeSet class methodsFor: 'fileIn/Out' stamp: 'SqR 4/12/2000 22:07'!
superclassOrder2: classes
"Arrange the classes in the collection, classes, in superclass order so the
classes can be properly filed in. Do it in sets instead of ordered collections.
SqR 4/12/2000 22:04"
| all list aClass inclusionSet aClassIndex cache |
list _ classes copy. "list is indexable"
inclusionSet _ list asSet. cache _ Dictionary new.
all _ OrderedCollection new: list size.
list size timesRepeat:
[
aClassIndex _ list findFirst: [:one | one isNil not and:
[self doWeFileOut: one given: inclusionSet cache: cache]].
aClass _ list at: aClassIndex.
all addLast: aClass.
inclusionSet remove: aClass.
list at: aClassIndex put: nil
].
^all! !
!ChangeSet class methodsFor: 'fileIn/Out' stamp: 'SqR 4/13/2000 12:11'!
superclassOrder: classes
"Arrange the classes in the collection, classes, in superclass order so the
classes can be properly filed in."
| all list i aClass |
true ifTrue: [^self superclassOrder2: classes].
list _ classes copy. "list is indexable"
all _ OrderedCollection new: list size.
[list size > 0] whileTrue:
[
i _ 0.
[i _ i + 1. aClass _ list at: i.
(list includesAnyOf: aClass allSuperclasses) or:
[aClass isMeta and: [(list includes: aClass soleInstance) or:
[list includesAnyOf: aClass soleInstance allSuperclasses]]]
] whileTrue.
all addLast: aClass.
list _ list copyWithout: aClass
].
^all! !
More information about the Squeak-dev
mailing list
|