<div style="direction: ltr;">I have implemented an improvement to the Set class and its many subclasses. <br>For the class Set this improvement reduces the number of (elements of S) compares <br>done during an 'add:' operation by 8-20% with an average of about 14%.
<br>For the many subclasses of class Set the level of improvement should be about the same.<br>Since I don't even know what all of the subclasses of Set are for, <br>I cannot claim to have properly tested all of my changes but
<br>they appear to work properly in Squeak 3.6, 3.7, and 3.8 for a large project I am working on. <br>(I do seem to be having performance problems with Squeak 3.8 after porting my project<br>from Squeak 3.6 but I do not see why this is related to my Set improvement code.)
<br> <br>I would like to forward my code to someone who has the knowledge to test the code thouroughly<br>and the authority to then incorporate the improvement into Squeak
3.9.<br>Could the powers that be designate someone who I can forward this code to.<br><br>The improvement I have made is described below:<br><br>During a grow operation a set S assigns a local variable (oldElements)<br>
to the instance variable 'array' containing the elements of S <br>and then reassigns array to a new Array object <br>larger (occasionally smaller) than (oldElements size). <br>This makes S temporarily an empty set.
<br>Then S performs an 'add:' operation on itself for each element in oldElements <br>(In Sqeuak 3.8 the 'add:' operation is replaced by a 'noCheckAdd:' operation;<br>an improvement but no cigar).<br><br>This 'add:' ('noCheckAdd:') operation is inefficient
<br>in that it does compares with elements already in S <br>(from the 'add:' operations done by S on itself since the beginning of the grow operation).<br>These comparisons always return that the objects are different since, if they were
<br>the same, the set S would have corrupt data.<br>Thus these compares are always unnecessary.<br><br>I have replaced this 'add:' operation by a 'noCompareAdd:' operation which adds an element<br>to a set without doing any comparisions.
<br>I consider this method private; to be used only during grow operations.<br>Admittedly, if you are sure that the element you are adding to a set is not already there <br>and you are insane,<br>then you could use this method as a public method to save some time.
<br>Actually, even this is not true because 'noCompareAdd:' makes no allowance for<br>the set to grow! Of course, this could be changed to accommadate the insane.<br><br>There are actually quite a few changes since 'noCompareAdd:' is implemented for
<br>many subclasses of class Set and some further clean up of code became necessary.<br><br>If someone could point out the versions of Smalltalk for which this improvement could also<br>be made that would also be appreciated.
<br><br>Thanks, <br></div><span class="sg"><br>Ralph Boland</span>