Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(524)

Unified Diff: sdk/lib/_internal/compiler/implementation/code_buffer.dart

Issue 24251012: Improve the memory consumption and performance of our string buffer implementation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update comment. Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sdk/lib/_internal/compiler/implementation/code_buffer.dart
diff --git a/sdk/lib/_internal/compiler/implementation/code_buffer.dart b/sdk/lib/_internal/compiler/implementation/code_buffer.dart
index 4934ea3c7d6a9bbc75a35781b6f10c3ce00029d6..f63a99a519dc1761a8675f83361ca68555b2901d 100644
--- a/sdk/lib/_internal/compiler/implementation/code_buffer.dart
+++ b/sdk/lib/_internal/compiler/implementation/code_buffer.dart
@@ -5,22 +5,18 @@
part of dart2js;
class CodeBuffer implements StringBuffer {
- StringBuffer buffer;
- List<CodeBufferMarker> markers;
+
+ StringBuffer buffer = new StringBuffer();
+ List<CodeBufferMarker> markers = new List<CodeBufferMarker>();
+
int lastBufferOffset = 0;
int mappedRangeCounter = 0;
- CodeBuffer()
- : buffer = new StringBuffer(),
- markers = new List<CodeBufferMarker>();
+ CodeBuffer();
Lasse Reichstein Nielsen 2013/09/20 11:40:17 You can even remove the constructor entirely. Prob
int get length => buffer.length;
-
- bool get isEmpty {
- return buffer.isEmpty;
- }
-
- bool get isNotEmpty => !isEmpty;
+ bool get isEmpty => buffer.isEmpty;
+ bool get isNotEmpty => buffer.isNotEmpty;
CodeBuffer add(var object) {
write(object);
@@ -81,7 +77,8 @@ class CodeBuffer implements StringBuffer {
CodeBuffer addCharCode(int charCode) => writeCharCode(charCode);
CodeBuffer writeCharCode(int charCode) {
- return write(new String.fromCharCodes([charCode]));
Lasse Reichstein Nielsen 2013/09/20 11:40:17 Ouch. How much would you gain from just this chang
+ buffer.writeCharCode(charCode);
+ return this;
}
CodeBuffer clear() {

Powered by Google App Engine
This is Rietveld 408576698