Friday, May 28, 2010

Re: Fastest way to create lots of similar elements

On 28 mai, 17:35, Chris Lercher <cl_for_mail...@gmx.net> wrote:
> On May 28, 4:28 pm, Thomas Broyer <t.bro...@gmail.com> wrote:
>
> > Use a StringBuilder, it'll optimize dependending on the browser
> > (pushing into an array and then joining the items, or concatenating
> > strings, whichever has been benchmarked the fastest by the GWT team)
>
> You're right - I just looked into StringBuilderImpl, and now I'm
> convinced, it's really something I should leave to GWT!
>
> I'm still looking for a solution that would remove the need for all
> the manual concatenation. I'd like to use either some templating (as
> with UiBinder), or some API (as with GWT widgets, or GQuery), but it
> would have to give me approximately the same performance...

Messages could help you, even if you don't use its "localizable
facet":

public interface Images extends Messages {
@DefaultMessage("<img src='images/{0}.gif' style='top: {1}em;'>")
String image(String image, int emTop);
}

Then use it as:
images.image(flag ? "a" : "b", index);


--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment