Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 323643d3 authored by Hui Peng's avatar Hui Peng
Browse files

Improve the implementation of GetAclInterface

The current implementation of GetAclInterface allocates
a new acl_interface_t, initialize it and makes a new copy
upon return, which is unecessary.
This patch improves its implementation by reusing a static variable
and returns a reference to it.

Bug: 263277439
Test: refactoring, existing test pass
Change-Id: Ib6bc5de6a9e84419fd8019be5a7fd16fc0f1368d
parent 712a1470
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -30,8 +30,8 @@ namespace bluetooth {
namespace shim {
namespace legacy {

const acl_interface_t GetAclInterface() {
  acl_interface_t acl_interface{
const acl_interface_t& GetAclInterface() {
  static acl_interface_t acl_interface{
      .on_send_data_upwards = acl_rcv_acl_data,
      .on_packets_completed = acl_packets_completed,

+1 −1
Original line number Diff line number Diff line
@@ -150,7 +150,7 @@ typedef struct {
  acl_link_interface_t link;
} acl_interface_t;

const acl_interface_t GetAclInterface();
const acl_interface_t& GetAclInterface();

}  // namespace legacy
}  // namespace shim