Page MenuHomeFreeBSD

MAC/do: toast_rules(): Minor simplification
ClosedPublic

Authored by olce on Nov 15 2024, 5:08 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Dec 27, 11:02 AM
Unknown Object (File)
Fri, Dec 27, 8:26 AM
Unknown Object (File)
Fri, Dec 27, 3:07 AM
Unknown Object (File)
Thu, Dec 26, 9:47 AM
Unknown Object (File)
Thu, Dec 26, 12:17 AM
Unknown Object (File)
Tue, Dec 17, 9:13 AM
Unknown Object (File)
Dec 9 2024, 12:24 PM
Unknown Object (File)
Nov 29 2024, 7:56 AM

Details

Summary

This revision is part of a series. Click on the Stack tab below to see the context.
This series has also been squeezed into D47633 to provide an overall view.

Commit message:
Use the most common pattern to browse and delete elements of a list, as it reads quicker.

Diff Detail

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

Event Timeline

olce requested review of this revision.Nov 15 2024, 5:08 PM

Slightly more efficient at the cost of being inconsistent during the deletion; no objection from me.

This revision is now accepted and ready to land.Nov 19 2024, 9:49 AM

Slightly more efficient at the cost of being inconsistent during the deletion; no objection from me.

Yes, but the inconsistency can only be observed by concurrent accesses which are not meant to happen, and if they still did because of improper locking, the initial version is not safe either as TAILQ_REMOVE() is not atomic.

Slightly more efficient at the cost of being inconsistent during the deletion; no objection from me.

Yes, but the inconsistency can only be observed by concurrent accesses which are not meant to happen, and if they still did because of improper locking, the initial version is not safe either as TAILQ_REMOVE() is not atomic.

And, to expand a bit more, if for the reason I've just explained I don't see inconsistency during deletion as a cost here, I don't particularly see the switch to TAILQ_FOREACH_SAFE() as a compelling optimization either.

Really, the point of this change, and its real value IMHO, is to remove any friction to the reader by using a commonly used pattern to free elements of a list which can be grasped literally at a glance. The original code is small and not difficult to understand, but still requires slightly more cognitive burden. Code doing boring stuff should be as boring as possible, that's my reason for proposing this change.

This revision was automatically updated to reflect the committed changes.