[adb] Optimize adbd's usb reading
Try to not allocate as many blocks on the heap, and reuse
memory instead of copying it
Get rid of unique_ptr and shared_ptr where possible, move
the Block objects themselves
Overall this reduces the time spent in memcpy() from 30% to
15% of the whole 'adb push' command, and gets rid of about 5%
of the time spent in the malloc/free calls
Test: builds
Change-Id: I8995115274b6f08a4df13c58183c928ef384a767
diff --git a/adb/sockets.cpp b/adb/sockets.cpp
index e78530c..7d5bf17 100644
--- a/adb/sockets.cpp
+++ b/adb/sockets.cpp
@@ -125,8 +125,7 @@
if (rc > 0 && static_cast<size_t>(rc) == s->packet_queue.size()) {
s->packet_queue.clear();
} else if (rc > 0) {
- // TODO: Implement a faster drop_front?
- s->packet_queue.take_front(rc);
+ s->packet_queue.drop_front(rc);
fdevent_add(s->fde, FDE_WRITE);
return SocketFlushResult::TryAgain;
} else if (rc == -1 && errno == EAGAIN) {