It was in a loop. I'm using Stringbuilder now, and I got it down from 38 seconds to about 1.
On Sep 4, 7:10 pm, Nick Risaro <[email protected]> wrote: > On Sun, Sep 4, 2011 at 9:02 PM, bob <[email protected]> wrote: > > I am seeing some remarkable slowness in code like this: > > > String html = "<html><head><style > > type=\"text/css\">tr:nth-child(odd) > > { background-color: rgba(0, 0, 0, 1.0); }" > > + " tr:nth-child(even) { background-color: > > rgba(0, 0, 0, 1.0); } > > td { padding: 4px; font-size: 13px; } " > > + "body { color: white; font-family: > > \"Helvetica Neue\"; padding: > > 0; border: 0; margin: 0;" > > + "}" + > > > "</style></head><body bgcolor=0><table > > width=320 border=0>"; > > > String dotline = "<tr><td colspan=4 align=center><font > > color=#aed136 > > size=3px><b>· · · · · · > > · · · · · · · > > · · · · · · · > > · · · · · · · > > · · · ·</td></tr>"; > > html += dotline; > > html += "<tr><td/><td align=center><font > > color=#aed136><b>TEAMS</ > > td><td align=center><font color=#aed136><b>TIME</td></tr>\n"; > > > The only thing I can think of is that I ought to use a StringBuffer to > > build the HTML. Can a mistake like that really cause so much > > slowness? > > Each time you concatenate two strings a third one is created to hold the > result. Strings are inmutables and expensive. Try with the > StringBuffer/StringBuilder and check the results. Your code will be faster > and more legible. > > > > > > > > > -- > > You received this message because you are subscribed to the Google > > Groups "Android Developers" 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/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups "Android Developers" 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/android-developers?hl=en

