Thomas Broyer has posted comments on this change.
Change subject: Reduce O(N^2) memory complexity to O(N)
......................................................................
Patch Set 1:
(4 comments)
Nits only.
I'm still somwhat sleep-deprived so feel free to disregard my comments ;-)
(i.e. I can be wrong)
....................................................
Commit Message
Line 7: Reduce O(N^2) memory complexity to O(N)
Could you add "in ClassSourceFileComposer"?
....................................................
File user/src/com/google/gwt/user/rebind/ClassSourceFileComposer.java
Line 151: int i = s.indexOf("\n");
Would indexOf('\n') make any difference? (micro-optimization)
Line 156: printWriter.print(s);
Shouldn't atStart be set to true if "i == s.length() - 1"? (for the next
call to print())
AFAICT, that was also an "issue" with the previous code. How does the
following behave in practice?
composer.print("foo\n");
composer.print("bar");
Is 'bar' correctly indented? (and commented if "inComment" is true) I see
println() sets the atStart flag, which, to me, seems wrong.
Line 162: printWriter.print(s.substring(0, i + 1));
Maybe use append(s, 0, i + 1) or write(s, 0, i + 1). Maybe even use a 'pos'
marker instead of using "s = s.substring(i + 1)"? (I have no idea if it'd
have a non-negligible impact on memory usage)
for (int start = 0; start < s.length(); ) {
…
int end = s.indexOf('\n', start);
if (end < 0) {
end = s.length() - 1;
} else {
// Fix the atStart from the above comment
// 'atStart = true' can thus be removed from println()
atStart = true;
}
printWriter.write(s, start, end + 1);
start = end + 1;
}
--
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 <[email protected]>
Gerrit-Reviewer: Matthew Dempsky <[email protected]>
Gerrit-Reviewer: Thomas Broyer <[email protected]>
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.