I added a new patch that caches the lengths but not the actual style
sheet contents.  In the worst case, if the lengths are wrong we will
just append in a suboptimal way, but not lose any data.  Benchmarking
shows that the performance difference is minor -- still just 2-3 ms per
injection in my particular benchmark.

On 2010/03/05 17:19:51, jlabanca wrote:
http://gwt-code-reviews.appspot.com/159804/diff/1/3
File user/src/com/google/gwt/dom/client/StyleInjector.java (right):

http://gwt-code-reviews.appspot.com/159804/diff/1/3#newcode101
Line 101: private static native int getDocumentStyleSheetLength(int
idx) /*-{
I don't know for sure if reading cssText.length is slow, but I'm
worried that we
had a reason to cache the length originally.  I agree that there is no
way to
cache the info because we can't control what happens outside of GWT,
so we
wouldn't even know if external code modified the style sheets.

Can you just try injecting 40 large style sheets and compare the
performance
before and after the change?  At the very least, we should warn people
if its
going to get really slow.



http://gwt-code-reviews.appspot.com/159804

--
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to