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

Unified Diff: runtime/lib/string_buffer_patch.dart

Issue 1888453011: Avoid multiple reallocations of StringBuffer._parts (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 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
« 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/lib/string_buffer_patch.dart
diff --git a/runtime/lib/string_buffer_patch.dart b/runtime/lib/string_buffer_patch.dart
index d08755082a1c82aac149d3111da98f843a9816c9..401d258da8eb36db420198e7caa26c2106374b8a 100644
--- a/runtime/lib/string_buffer_patch.dart
+++ b/runtime/lib/string_buffer_patch.dart
@@ -148,7 +148,8 @@ patch class StringBuffer {
_partsCodeUnitsSinceCompaction += length;
if (_parts == null) {
- _parts = [ str ];
+ // Empirically this is a good capacity to minimize total bytes allocated.
+ _parts = new _GrowableList.withCapacity(10)..add(str);
} else {
_parts.add(str);
int partsSinceCompaction = _parts.length - _partsCompactionIndex;
« 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