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

Unified Diff: runtime/bin/string_stream.dart

Issue 8639004: Fix excess memory usage problem in StringInputStream. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 years, 1 month 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/string_stream.dart
diff --git a/runtime/bin/string_stream.dart b/runtime/bin/string_stream.dart
index eb0c04ff51ff6a1265faad204fd24982acf804f1..875242e2976f8a20074f464d9068d338a2485803 100644
--- a/runtime/bin/string_stream.dart
+++ b/runtime/bin/string_stream.dart
@@ -28,7 +28,7 @@ class DecoderException implements Exception {
class _StringDecoderBase implements _Decoder<String> {
_StringDecoderBase()
: _bufferList = new _BufferList(),
- _result = new StringBuffer();
+ _result = new List<int>();
// Add UTF-8 encoded data.
int write(List<int> buffer) {
@@ -52,8 +52,8 @@ class _StringDecoderBase implements _Decoder<String> {
if (isEmpty()) {
return null;
} else {
- String result = _result.toString();
- _result = new StringBuffer();
+ String result = new String.fromCharCodes(_result);
+ _result = new List<int>();
return result;
}
}
@@ -61,7 +61,7 @@ class _StringDecoderBase implements _Decoder<String> {
abstract bool _processNext();
_BufferList _bufferList;
- StringBuffer _result;
+ List<int> _result;
}
@@ -75,7 +75,7 @@ class _AsciiDecoder extends _StringDecoderBase {
if (byte > 127) {
throw new DecoderException("Illegal ASCII character $byte");
}
- _result.addCharCode(byte);
+ _result.add(byte);
}
return true;
}
@@ -89,7 +89,7 @@ class _Latin1Decoder extends _StringDecoderBase {
bool _processNext() {
while (_bufferList.length > 0) {
int byte = _bufferList.next();
- _result.addCharCode(byte);
+ _result.add(byte);
}
return true;
}
@@ -131,7 +131,7 @@ class _UTF8Decoder extends _StringDecoderBase {
// Remove the value peeked from the buffer list.
_bufferList.next();
}
- _result.addCharCode(value);
+ _result.add(value);
return true;
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698