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

Skip to content
Commit 1fb90c4f authored by Myles Watson's avatar Myles Watson Committed by Andre Eisenbach
Browse files

RemoteDevices: Optimize adding new remote devices



RemoteDevices keeps track of the Bluetooth devices which have been
seen since the Bluetooth stack was initialized.  Each time a remote
device is discovered, it is added to a hash map.  When the size of the
hash map grows beyond a few hundred devices, the performance degrades.

This patch:
 - creates the address string once per search
  reducing the average search time with 300 devices from ~20ms to ~1ms
 - uses the hash of the address string to search
  further reducing the time with 1200 devices from ~2ms to ~1ms

HashMap<BluetoothDevice, DeviceProperties> became
 HashMap<String, DeviceProperties>

mDevice now stores the BluetoothDevice in each instance of
DeviceProperties.

TEST: Used System.nanoTime() to measure the elapsed time of
      getDeviceProperties()

Change-Id: Id44886143fb2910955294341d4938d638c72f7f9
Signed-off-by: default avatarMyles Watson <mylesgw@google.com>
parent 764eb24d
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment