Page MenuHomeFreeBSD

Add RB_REINSERT(3)
ClosedPublic

Authored by trasz on Sep 25 2019, 2:29 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Apr 13, 7:54 PM
Unknown Object (File)
Mon, Apr 8, 7:19 PM
Unknown Object (File)
Mon, Apr 8, 4:10 PM
Unknown Object (File)
Mar 5 2024, 8:49 AM
Unknown Object (File)
Dec 20 2023, 3:09 AM
Unknown Object (File)
Nov 8 2023, 12:01 AM
Unknown Object (File)
Nov 1 2023, 1:38 AM
Unknown Object (File)
Oct 31 2023, 8:33 AM
Subscribers

Details

Summary

Add RB_REINSERT(3), a low overhead alternative to removing a node
and reinserting it back with an updated key.

This is one of dependencies for the upcoming stats(3) code.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Small grammo, nothing major.

share/man/man3/tree.3
582 ↗(On Diff #62545)

s/an lower overhead/a lower overhead/

Thanks! Some pretty minor / trivial feedback below. Looks good to me once those are addressed or responded to in some way (I'll be sure to mark it explicitly in Phab).

share/man/man3/tree.3
100–101 ↗(On Diff #62545)

alphabetically, the sort here is backwards ("REI" before "REM").

192–195 ↗(On Diff #62545)

Ditto

577 ↗(On Diff #62545)

"after ... after" is a little awkward, but not especially bad.

I'd prefer "must" over "should," although I guess you could also RB_REMOVE/RB_INSERT if you really wanted.

I would probably write this sentence as:

This must be called if a member of a .Nm tree is modified in a way that affects comparison, such as by modifying a node's key.

(The RB tree macros act on some arbitrary comparator which must be stable in some way, but don't explicitly have keys.)

@bcr, thoughts?

579–581 ↗(On Diff #62545)

I'd just drop this sentence, I think. It's a clarification for the name REBALANCE, which has been changed to be less confusing because of the possible confusion implied by this sentence. (And most functions don't need calling most of the time; we don't document that for every single one.)

sys/sys/tree.h
416 ↗(On Diff #62545)

This might just be phabricator fuckiness, but double check the tabs of the trailing \ line up with the preceding lines?

772–774 ↗(On Diff #62545)

Fwiw, in other macros cmp is just used without the wrapping parentheses.

E.g., cmp(cmpelm, elm) >= 0

Fine as-is, but if you want to change it to be consistent with the other macros that's cool too.

I agree with Conrad here.

share/man/man3/tree.3
577 ↗(On Diff #62545)

I like your rewrite of that sentence better than the original, @cem.

trasz marked 5 inline comments as done.

Fixes from bcr@ and cem@.

share/man/man3/tree.3
100–101 ↗(On Diff #62545)

Those lists don't seem to be alphabetically sorted, though?

Be sure to bump .Dd of tree.3 before you commit. Thanks!

share/man/man3/tree.3
100–101 ↗(On Diff #62545)

They're sort of alpha sorted within a bunch of distinct logical groupings, and I'd contend that something like REINSERT is part of the group of {INSERT, REMOVE}, but I could see the argument that it's distinct. So I'm ok either way here, but if it were me, I'd alpha REINSERT between INSERT and REMOVE. Not a big deal to leave as-is.

This revision is now accepted and ready to land.Sep 27 2019, 12:46 AM