Skip to content

Dead code in binary search function in sstable. #11

Description

@loga4m

Hi there! Thanks for the series!

While reading the sstable part, I have found that there is an unreachable check in the implementation of binary search.

Here is the exact line:

if m == usize::MAX {

Explanation

The if expression checks if the mid index equals to usize::MAX which never happens. Note that in the last point of usage of the variable of m, we read the offset from the offsets vector by using m as index. If m were equal to the above bound, the program would have panicked (out of bounds) since Vec type is bounded by isize::MAX which is far lower than usize::MAX. Thus, if the code made to pass till this check, m is definitely lower than usize::MAX. Hence, the check is dead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions