i just checked an 1.3 String implementation and there the same thing was done
As far as i know they have to do that. How else would you test for equals for a string?
You have to walk the chars on both sides comparing it. So if you don't test
first for lenght the length can be different and if you walk then over the 2 char arrays you will
get and arrayindexoutofbounds exception.. So i can't imaging an other implementation then that.

an instanceof check is pretty fast. I never have been able to get that popped up in a profiler.
(and that is also directly the null check that you need)
you can read some more here:
http://www.google.com/url?sa=t&ct=res&cd=2&url=""


johan


On 9/22/06, Erik van Oosten <[EMAIL PROTECTED]> wrote:
> You will not be able to see the difference between optimalization...
> String.equals() does exactly that, it test for length

Aha! This is new for me. The last time I checked (Java 1.3) there were
are least 2 instanceof operators in the implementation of
String.equals(String) and no length checking.
I just checked the Java 5 implementation. It looks a lot better, but
there is still 1 instanceof operator.

Anyway, another myth busted.

     Erik.


Johan Compagner schreef:
> You will not be able to see the difference between optimalization...
> String.equals() does exactly that, it test for length
>
> and where we just do this "".equals(value) without testing for null
> i will not rewrite those by first testing null to be able to call for
> length.
>
>
> On 9/21/06, *Erik van Oosten* <[EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]>> wrote:
>
>     If this gets accepted, may I humbly suggest to replace
>
>       value != null && !"".equals(value)
>
>     with
>
>       value != null && value.length() != 0
>
>     The latter performs considerably faster (though it is of course
>     still a
>     micro optimization).
>
>     Regards,
>          Erik.
>
>
>     --
>     Erik van Oosten
>     http://www.day-to-day-stuff.blogspot.com/
>
>
>     Manuel Barzi schreef:
>     > Ok, Igor, I already solved this issue by re-implementing Link
>     class in
>     > my custom LinkButton class, just adding the following snippet
>     > extracted from Button class, and added to the original
>     > "onComponentTag" Link in this new LinkButton class:
>     >
>     > ---
>     > // Default handling for tag
>     >               super.onComponentTag(tag);
>     >
>     >               // manuelbarzi {
>     >               // setting the "value" property to the tag
>     >               try {
>     >                       String value = getModelObjectAsString();
>     >                       if (value != null && !"".equals(value)) {
>     >                               tag.put("value", value);
>     >                       }
>     >               } catch (Exception e) {
>     >                       // ignore.
>     >               }
>     >               // }
>     >
>     >               // Set href to link to this link's linkClicked method
>     > ---
>     >
>     > It works fine now. May this simple addition be interesting for other
>     > people needing this functionality, you'll judge according to
>     > statistics...
>     >
>     > Thank you and regards,
>     >
>     > Manu
>     >
>
>     -------------------------------------------------------------------------
>     Take Surveys. Earn Cash. Influence the Future of IT
>     Join SourceForge.net's Techsay panel and you'll get the chance to
>     share your
>     opinions on IT & business topics through brief surveys -- and earn
>     cash
>     http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
>     <http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV >
>     _______________________________________________
>     Wicket-user mailing list
>     Wicket-user@lists.sourceforge.net
>     <mailto: Wicket-user@lists.sourceforge.net>
>     https://lists.sourceforge.net/lists/listinfo/wicket-user
>
>
> ------------------------------------------------------------------------
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys -- and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> ------------------------------------------------------------------------
>
> _______________________________________________
> Wicket-user mailing list
> Wicket-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/wicket-user
>

--
Erik van Oosten
http://www.day-to-day-stuff.blogspot.com/


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to