From 1beeca2bbafed1681518785530d3dfb9b2c56f42 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Mon, 6 Sep 2021 14:20:47 +0200 Subject: libusb: Remove unused context variable The USB managed buffer implementation created a context every time one was generated. The additional load is not very high, because the global session is a singleton, and simply returns the same context again with only a few branches. Also, managed buffers persist for the entire session. However, the context is never used in the managed buffer. This code is thus confusing for the reader of this code, and we remove the extraneous, unused context variable. --- host/lib/transport/libusb1_zero_copy.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/host/lib/transport/libusb1_zero_copy.cpp b/host/lib/transport/libusb1_zero_copy.cpp index 8cf76989b..fc36b36b7 100644 --- a/host/lib/transport/libusb1_zero_copy.cpp +++ b/host/lib/transport/libusb1_zero_copy.cpp @@ -108,6 +108,11 @@ static void LIBUSB_CALL libusb_async_cb(libusb_transfer* lut) * Reusable managed buffer: * - Associated with a particular libusb transfer struct. * - Submits the transfer to libusb in the release method. + * + * A note on the USB context: None of the libusb calls made in this class + * require passing in a USB context. The context is implied by virtue of the + * libusb_transfer struct we pass in, which contains a device handle, which + * contains a context. **********************************************************************/ class libusb_zero_copy_mb : public managed_buffer { @@ -120,7 +125,6 @@ public: : _release_cb(release_cb) , _is_recv(is_recv) , _name(name) - , _ctx(libusb::session::get_global_session()->get_context()) , _lut(lut) , _frame_size(frame_size) { /* NOP */ @@ -194,7 +198,6 @@ private: std::function _release_cb; const bool _is_recv; const std::string _name; - libusb_context* _ctx; libusb_transfer* _lut; const size_t _frame_size; }; -- cgit v1.2.3