yaoxinjing / simpleDeviceDriver

0 stars 0 forks source link

Use the right API call for check element presence #4

Closed planetA closed 3 years ago

planetA commented 3 years ago

https://github.com/yaoxinjing/simpleDeviceDriver/blob/575ebb004b1771e8767032e12f068a7123ba28c3/device_file.c#L130-L138

Going through the elements of xarray one-by-one has at best linear (O(n)) complexity. Internally xarray is an RB-tree, a balanced binary search tree. Search inside such a data structure has complexity O(log n). In a long run it is important to use the most fitting interface for the purpose.

yaoxinjing commented 3 years ago

okay,thanks. i guess i don't need this fuc anymore, since i use xa_load to check whether the entry exist.