From d1650afd37e430be9c4b983b7b755dfcc3603133 Mon Sep 17 00:00:00 2001 From: mbanth Date: Tue, 25 May 2021 16:00:32 +0100 Subject: [PATCH] Avoid unnecessary preparation --- lib_xua/src/hid/hid_report_descriptor.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib_xua/src/hid/hid_report_descriptor.c b/lib_xua/src/hid/hid_report_descriptor.c index 2bddc6cc..26d03e2e 100644 --- a/lib_xua/src/hid/hid_report_descriptor.c +++ b/lib_xua/src/hid/hid_report_descriptor.c @@ -267,12 +267,14 @@ unsigned char* hidGetReportDescriptor( void ) void hidPrepareReportDescriptor( void ) { - unsigned char* ptr = hidReportDescriptor; - for( unsigned idx = 0; idx < sizeof hidReportDescriptorItems / sizeof( USB_HID_Short_Item_t ); ++idx ) { - ptr = hidTranslateItem( hidReportDescriptorItems[ idx ], ptr ); - } + if( !hidReportDescriptorPrepared ) { + unsigned char* ptr = hidReportDescriptor; + for( unsigned idx = 0; idx < sizeof hidReportDescriptorItems / sizeof( USB_HID_Short_Item_t ); ++idx ) { + ptr = hidTranslateItem( hidReportDescriptorItems[ idx ], ptr ); + } - hidReportDescriptorPrepared = 1; + hidReportDescriptorPrepared = 1; + } } unsigned hidSetReportItem( const unsigned byte, const unsigned bit, const unsigned char header, const unsigned char data[] )