Jody Garnett a écrit :
> Changing Utilities.equals( obj, obj ) to do reflection on arrays has
> helped matters to the point that shapefile renderer tests pass. Woot!
As of revision 28180, I reverted back Utilities.equals(...) to its old
implementation and renamed the new implementation as Utilities.deepEquals(...).
I did a search on the whole code base and tried to invoke 'deepEquals' only for
those who may need it. They are:
modules/library/main/src/main/java/org/geotools/styling/LayerFeatureConstraintsImpl.java
modules/library/main/src/main/java/org/geotools/styling/FeatureTypeConstraintImpl.java
modules/library/main/src/main/java/org/geotools/styling/GraphicImpl.java
modules/library/main/src/main/java/org/geotools/styling/StrokeImpl.java
modules/library/main/src/main/java/org/geotools/feature/GeometryAttributeImpl.java
modules/library/main/src/main/java/org/geotools/feature/type/AttributeDescriptorImpl.java
modules/library/main/src/main/java/org/geotools/feature/PropertyImpl.java
modules/unsupported/community-schemas/fm/src/main/java/org/geotools/feature/iso/AttributeImpl.java
Doing reflection on array was an overkill for the large majority of the hundred
of Utilities.equals(...) invocations in the GeoTools code base (some of them in
loops) - with performance impact.
Rules for choosing a 'equals'/'deepEquals' method:
--------------------------------------------------
* If *both* objects are exactly Object[] (not anything else like String[]),
you may consider java.util.Arrays.deepEquals(...) - except if you know
that the array element can never be other arrays.
* Otherwise if both objects are array of the same kind (e.g. Expression[],
String[], int[], etc.), uses java.util.Arrays.equals(...). This is valid
for array of primitive type too.
* Otherwise if both objects are anything else than Object (e.g. String,
Expression, etc.), use Utilities.equals(...). Using 'deepEquals' would
be an overkill since there is no chance that String or Expression could
be an array.
* Otherwise if *both* objects are declared exactly as Object type and you
know that they could be arrays, only then invoke Utilities.deepEquals.
Martin
-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell. From the desktop to the data center, Linux is going
mainstream. Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel