if performance is really that critical you should test several
alternatives and check which one is really the best for your case (and
don't forget to test cross-browser; especially IE)


On Sep 30, 10:32 am, Ed <[email protected]> wrote:
> Hmmmm Interesting Dominik.
> Thanks for the information.
> It's sure is clean, but didn't know that performance of regexp is
> "good" in this case..
>
> What I want is: if a character at index X is a white space. That means
> I always have to take first a substring of one character and then do a
> match. So besides checking for a whitespace, I also take a substring,
> does that still perform well ??...
> Besides that: I always understood that object creation should be
> reduces as much as possible. In this case it always creates more
> objects...
>
> Might it be a good idea to store the pattern in a static field, to
> overcome unnecessary pattern compilation?
> So do something like this:
>
> private final static Pattern PATTERN_WHITE_SPACE = Pattern.compile("\
> \S");
> ..
> ...
> ..
> In a helper method:
>
> public static boolean matchWhiteSpace(String input) {
>         return PATTERN_WHITE_SPACE.matcher(input).matches();
>
> }
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to