Skip to content

Commit

Permalink
Minor optimization: List -> Queue (stablekernel#71)
Browse files Browse the repository at this point in the history
* Minor optimization: List -> Queue

* Fixing test.
  • Loading branch information
isoos authored and itsjoeconway committed Dec 17, 2018
1 parent 95ac5f9 commit 8355255
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions lib/src/message_window.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import 'dart:typed_data';
import 'dart:collection';
import 'dart:io';
import 'dart:typed_data';

import 'server_messages.dart';

class MessageFrame {
Expand Down Expand Up @@ -132,7 +134,7 @@ class MessageFrame {

class MessageFramer {
MessageFrame messageInProgress = new MessageFrame();
List<MessageFrame> messageQueue = [];
final messageQueue = new Queue<MessageFrame>();

void addBytes(Uint8List bytes) {
var offsetIntoBytesRead = 0;
Expand All @@ -151,6 +153,6 @@ class MessageFramer {
bool get hasMessage => messageQueue.isNotEmpty;

MessageFrame popMessage() {
return messageQueue.removeAt(0);
return messageQueue.removeFirst();
}
}
2 changes: 1 addition & 1 deletion test/framer_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ List<int> bufferWithMessages(List<List<int>> messages) {
}

flush(MessageFramer framer) {
framer.messageQueue = [];
framer.messageQueue.clear();
framer.addBytes(bufferWithMessages([
messageWithBytes([1, 2, 3], 1)
]));
Expand Down

0 comments on commit 8355255

Please sign in to comment.