Matthew Dempsky has posted comments on this change.

Change subject: Reduce O(N^2) memory complexity to O(N)
......................................................................


Patch Set 1:

(4 comments)

Thanks for the review!

....................................................
Commit Message
Line 7: Reduce O(N^2) memory complexity to O(N)
Done


....................................................
File user/src/com/google/gwt/user/rebind/ClassSourceFileComposer.java
Line 151:       int i = s.indexOf("\n");
Done.

(Oops, I had originally made that tweak, but then started over and forgot to re-add it.)


Line 156:         printWriter.print(s);
Yeah, agreed that I think print() is doing the wrong thing for strings ending with a newline, but I tried to preserve the existing semantics and simply fix the memory usage.

I'd rather address the weird semantics in a separate change.


Line 162:       printWriter.print(s.substring(0, i + 1));
Hm, according to Stack Overflow, substring() is an O(N) time complexity operation now in Java 7, so even though the substring loop only requires O(N) memory, it still takes O(N^2) CPU. (Though CPU isn't as limiting an issue at the moment.)

Switched to using a pos offset, so it should only take O(N) CPU now too. This means the full string has to be kept in memory the whole time, but I doubt that'll be a problem.


--
To view, visit https://gwt-review.googlesource.com/2460
To unsubscribe, visit https://gwt-review.googlesource.com/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I30301a58bad0244a41b08fb534c4cb18b90c9494
Gerrit-PatchSet: 1
Gerrit-Project: gwt
Gerrit-Branch: master
Gerrit-Owner: Matthew Dempsky <mdemp...@google.com>
Gerrit-Reviewer: Matthew Dempsky <mdemp...@google.com>
Gerrit-Reviewer: Thomas Broyer <t.bro...@gmail.com>
Gerrit-HasComments: Yes

--
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors
--- You received this message because you are subscribed to the Google Groups "Google Web Toolkit Contributors" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit-contributors+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to