On May 28, 1:48 am, Chris Lercher <cl_for_mail...@gmx.net> wrote: > Hi George, > > absolutely - the other browsers are fine with simple DOM manipulation. > > Inspired by the (a little bit outdated) benchmark [1], I changed my > code to join arrays instead of strings: > > -------------- > void attachImages(...) { > final JsArrayString array = JavaScriptObject.createArray().cast(); > for (...) { > boolean flag = ...; > array.push(flag ? "<img src='images/a.gif' style='left:" : "<img > src='images/b.gif' style='top:"); > array.push(String.valueOf(i)); > array.push("em'/>"); > } > div1.setHTML(array.join("")); > > } > > -------------- > > This also only calls setHTML() once at the end of the loop. > > Does anybody see possibilities for optimization - either improving > performance or resulting in cleaner code?
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 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-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.