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

Unified Diff: sdk/lib/_internal/pub_generated/lib/src/transcript.dart

Issue 557563002: Store the async-await compiled pub code directly in the repo. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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/pub_generated/lib/src/transcript.dart
diff --git a/sdk/lib/_internal/pub_generated/lib/src/transcript.dart b/sdk/lib/_internal/pub_generated/lib/src/transcript.dart
new file mode 100644
index 0000000000000000000000000000000000000000..38702e135780e89293f80f8f789a4d6cd3e9f5a1
--- /dev/null
+++ b/sdk/lib/_internal/pub_generated/lib/src/transcript.dart
@@ -0,0 +1,30 @@
+library pub.transcript;
+import 'dart:collection';
+class Transcript<T> {
+ final int max;
+ int get discarded => _discarded;
+ int _discarded = 0;
+ final _oldest = new List<T>();
+ final _newest = new Queue<T>();
+ Transcript(this.max);
+ void add(T entry) {
+ if (discarded > 0) {
+ _newest.removeFirst();
+ _discarded++;
+ } else if (_newest.length == max) {
+ while (_newest.length > max ~/ 2) {
+ _oldest.add(_newest.removeFirst());
+ }
+ _newest.removeFirst();
+ _discarded++;
+ }
+ _newest.add(entry);
+ }
+ void forEach(void onEntry(T entry), [void onGap(int)]) {
+ if (_oldest.isNotEmpty) {
+ _oldest.forEach(onEntry);
+ if (onGap != null) onGap(discarded);
+ }
+ _newest.forEach(onEntry);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698