I have just made a series of changes to property processing in alt.design, intended to 1) make the process look more familiar to Java familiars, and 2) speed things up a bit.
property = (Property)(pclass.newInstance()); properties[propindex] = property; // Set inheritance value if ((inherited[propindex] = pclass.getField("inherited").getInt(null)) != Property.NO) inheritedprops.set(propindex); // Set datatypes datatypes[propindex] = pclass.getField("dataTypes").getInt(null); // Set initialValueTypes initialValueTypes[propindex] = pclass.getField("initialValueType").getInt(null); traitMappings[propindex] = pclass.getField("traitMapping").getInt(null);
Basically, the foregoing code, which used reflection to obtain public static fixed int vales from the Property sub-classes, has been replaced by
// Instantiate the class property = (Property)(pclass.newInstance()); properties[propindex] = property; // Set inheritance value if ((inherited[propindex] = property.getInherited()) != Property.NO) inheritedprops.set(propindex); // Set datatypes datatypes[propindex] = property.getDataTypes(); // Set initialValueTypes initialValueTypes[propindex] = property.getInitialValueType(); traitMappings[propindex] = property.getTraitMapping();
relying on the newly added getters in Property and its subclasses. Because of all the bad press for reflection, I expected to see an improvement of the speed of processing. I was disappointed in this. Unfortunately, I have only a poorly endowed laptop at the moment, so it is difficult to get sound measurements while Eclipse and Mozilla are running, but the results were inconclusive, sometimes recording faster times for the original code, sometimes for the new version. In any case, the approach I originally took incurs no performance penalty under 1.4, and may even be slightly faster.
However, given the disturbance which seems to overcome Java programmers when face by code which is not strictly OO, I have checked in the new version. It may make cross-fertilization with Finn's work easier.
Peter -- Peter B. West <http://www.powerup.com.au/~pbwest/resume.html>