Page MenuHomeFreeBSD

top: improve sort field storage/lookup
Needs ReviewPublic

Authored by kevans on Oct 21 2022, 8:59 PM.
Tags
None
Referenced Files
Unknown Object (File)
Nov 29 2023, 1:55 AM
Unknown Object (File)
Nov 28 2023, 6:12 PM
Unknown Object (File)
Nov 13 2023, 2:38 AM
Unknown Object (File)
Nov 8 2023, 3:22 PM
Unknown Object (File)
Oct 10 2023, 1:38 AM
Unknown Object (File)
Oct 8 2023, 10:19 AM
Unknown Object (File)
Oct 7 2023, 2:08 PM
Unknown Object (File)
Sep 29 2023, 2:08 PM

Details

Reviewers
bapt
imp
pstef
Summary

Switch up comparator mapping to avoid these kinds of errors, use a
simple array of (name, comparator) pairs rather than having to maintain
entries in two separate arrays that must have matching indices.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 49832
Build 46723: arc lint + arc unit

Event Timeline

kevans created this revision.
pstef added a subscriber: pstef.

But the summary contains the same phrase twice, seems unintentional.

This revision is now accepted and ready to land.Oct 21 2022, 10:20 PM

But the summary contains the same phrase twice, seems unintentional.

Whoops, good shout. Just axing this entirely:

, but the
`equivalent comparator wasn't added at that time.[...]
kib added inline comments.
usr.bin/top/machine.c
1667–1668

Switch to designated initializers?

usr.bin/top/machine.c
1667–1668

It's a bit awkward since we're cross-referencing between two arrays, but yeah, good point- I'll go ahead and switch this to a simple array of string, comparator pairs

Improve underlying storage/lookup mechanism for sort orders

This revision now requires review to proceed.Feb 13 2023, 6:42 AM
kevans retitled this revision from top: fix sorting by pid (-o pid) to top: improve sort field storage/lookup.Feb 13 2023, 6:42 AM
kevans edited the summary of this revision. (Show Details)

I'm going to commit the previous version of this as a stupid simple fix to get into 13.2, but still wanted to improve this.

usr.bin/top/machine.c
237

Could this array be const?

kevans marked an inline comment as done.
kevans edited the summary of this revision. (Show Details)

Sprinkle const around, our sort data should never change