Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use deque instead of list for FIFO queue in Linux Socket buffer #1453

Merged
merged 1 commit into from
Jun 4, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions manticore/platforms/linux.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,9 @@ def pair():
return a, b

def __init__(self):
self.buffer = [] # queue os bytes
from collections import deque

self.buffer = deque() # queue os bytes
self.peer = None

def __repr__(self):
Expand Down Expand Up @@ -399,7 +401,7 @@ def receive(self, size):
rx_bytes = min(size, len(self.buffer))
ret = []
for i in range(rx_bytes):
ret.append(self.buffer.pop())
ret.append(self.buffer.popleft())
return ret

def write(self, buf):
Expand All @@ -408,7 +410,7 @@ def write(self, buf):

def _transmit(self, buf):
for c in buf:
self.buffer.insert(0, c)
self.buffer.append(c)
return len(buf)

def sync(self):
Expand Down