-
Notifications
You must be signed in to change notification settings - Fork 896
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CodeHealth] Use span of bytes to read arbitrary data
This PR touches in different places of the code base where the use of `reinterpret_cast` was necessary to allow data to be handled in different format. Span is both safer and more ergonimic. It is preferrable over `void*`, and particularly we should avoid any type of casts involving byte values to numeric values, as those can cause undefined behaviour. This change additionally refactors `DeviceIdImpl::IsValidMacAddress` to use `base::MakeFixedFlatSet` for the set of invalid mac addresses we were searching for, as the search was sequential, and for successful values it meant visiting every element in the array to check for comparison. To make sure the binary search works as expected, a test has been added.
- Loading branch information
1 parent
d67b8d0
commit d0160c0
Showing
10 changed files
with
412 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.