Page MenuHomeFreeBSD

Drop redundant case from RB_NEXT, RB_PREV
ClosedPublic

Authored by dougm on Jun 10 2022, 7:12 PM.
Tags
None
Referenced Files
Unknown Object (File)
Feb 5 2024, 7:01 AM
Unknown Object (File)
Jan 8 2024, 11:26 PM
Unknown Object (File)
Dec 22 2023, 11:59 PM
Unknown Object (File)
Dec 14 2023, 3:48 PM
Unknown Object (File)
Sep 20 2023, 7:59 AM
Unknown Object (File)
Sep 17 2023, 9:57 AM
Unknown Object (File)
Aug 27 2023, 4:04 PM
Unknown Object (File)
Jul 3 2023, 10:48 AM
Subscribers

Details

Summary

In RB_NEXT, when there is no RB_RIGHT node, the search must proceed through the parent node.

There is code written to handle the case when the parent is non-NULL and the current element is the left child of that parent. If you assume that the current element is either the left child of its parent, or the right child of its parent, but not both, then this test is not necessary. Instead of assigning RB_PARENT(elm, field) to elm when elm == RB_LEFT, removing the test has the code assign RB_PARENT(elm, field) to elm when elm != RB_RIGHT. There's no need to examine the RB_LEFT field at all.

This change removes that needless RB_LEFT test, and makes a similar change to the RB_PREV implementation.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable