Skip to content

Instantly share code, notes, and snippets.

@eneveu
Last active December 26, 2015 23:39
Show Gist options
  • Save eneveu/7232549 to your computer and use it in GitHub Desktop.
Save eneveu/7232549 to your computer and use it in GitHub Desktop.
GWT.create() performance question: Do I improve performances if I store the result of GWT.create() in a constant, or does the GWT compiler do that for me?
@Nonnull
public SafeHtml decorateWithLinkIfAny(@Nullable String link, @Nonnull SafeHtml content) {
return link == null ? content : SAFE_HTML_TEMPLATES.link(UriUtils.fromString(link), content);
}
private static final MySafeHtmlTemplates SAFE_HTML_TEMPLATES = GWT.create(MySafeHtmlTemplates.class);
// vs
@Nonnull
public SafeHtml decorateWithLinkIfAny(@Nullable String link, @Nonnull SafeHtml content) {
MySafeHtmlTemplates templates = GWT.create(MySafeHtmlTemplates.class);
return link == null ? content : templates.link(UriUtils.fromString(link), content);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment