I see the improvement, but I think it can go further. Instead of this:
String type=find.getClass().getName();
if (type.equals("Boolean")||type.equals("String")||type.equals("Double")
id.value=find;
why no this, which I beleive is faster still:
Class type = find.getClass;
if( (type == Boolean.class) || (type == String.class) || (type == Double.class)
id.value=faind;
If I am wrong, or you have a reason for doing things without using class constants
I apologize.
jBoss CVS Development wrote:
> User: norbert
> Date: 00/05/22 15:01:01
>
> Modified: src/java/org/spyderMQ/selectors Selector.java
> Log:
> Fix for selectors ( no more instanceof )
>
> Revision Changes Path
> 1.5 +7 -6 spyderMQ/src/java/org/spyderMQ/selectors/Selector.java
>
> Index: Selector.java
> ===================================================================
> RCS file:
>/products/cvs/ejboss/spyderMQ/src/java/org/spyderMQ/selectors/Selector.java,v
> retrieving revision 1.4
> retrieving revision 1.5
> diff -u -r1.4 -r1.5
> --- Selector.java 2000/05/20 02:34:01 1.4
> +++ Selector.java 2000/05/22 22:01:01 1.5
> @@ -17,7 +17,7 @@
> *
> * @author Norbert Lataille ([EMAIL PROTECTED])
> *
> - * @version $Revision: 1.4 $
> + * @version $Revision: 1.5 $
> */
> public class Selector
> {
> @@ -57,7 +57,8 @@
> Log.log("Warning : missing property
>"+id.name);
> id.value=null;
> } else {
> - if ((find instanceof Boolean)||(find
>instanceof String)||(find instanceof Double)||(find instanceof Integer))
>id.value=find;
> + String type=find.getClass().getName();
> + if
>(type.equals("Boolean")||type.equals("String")||type.equals("Double")||type.equals("Integer"))
> id.value=find;
> else throw new Exception("Bad property type
>!");
> }
> }
> @@ -65,14 +66,14 @@
> //Compute the result of this operator
> Object res;
>
> - if (result instanceof Identifier) {
> + if (result.getClass().getName().equals("Identifier")) {
> res=((Identifier)result).value;
> - } else if (result instanceof Operator) {
> + } else if (result.getClass().getName().equals("Operator")) {
> res=((Operator)result).apply();
> } else res=result;
>
> if (res==null) throw new Exception("res==null");
> - if (!(res instanceof Boolean)) throw new Exception("Bad
>object type");
> + if (!(res.getClass().getName().equals("Boolean"))) throw new
>Exception("Bad object type");
>
> return ((Boolean)res).booleanValue();
>
> @@ -81,5 +82,5 @@
> return false;
> }
> }
> -
> +
> }
>
>
>