Skip to content

Conversation

Explorer09
Copy link
Contributor

This is a follow-up of commit 08166b2

This frees up the need of dirty_index and dirty_count members of Vector object. These two members are not supposed to last long and are only useful in keeping the state between the softRemove() and compact() operations.

Rework the two operations so that the caller would keep the dirtyIndex when calling softRemove() and pass dirtyIndex to the compact() in the final step.

The new dirtyIndex is safe to migrate to using size_t as I don't use any negative value of it.

Copy link
Member

@BenBE BenBE left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good on first glance. Still need to test locally though.

@BenBE BenBE added the enhancement Extension or improvement to existing feature label Oct 9, 2025
@BenBE BenBE added this to the 3.5.0 milestone Oct 9, 2025
Rename the DEFAULT_SIZE macro to VECTOR_DEFAULT_SIZE and hard-code the
size value (10) in the macro rather than use a (-1) flag. This makes
room for the 'Vector.size' member to migrate to an unsigned type.

Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
Use a goto label when a table row should be removed.
No changes to code behavior.
Remove the 'dirty_index' and 'dirty_count' members of Vector object.
Instead, let the callers of the Vector_softRemove() operation track the
'dirtyIndex' and pass it to Vector_compact() when needed.
(The new 'dirtyIndex' local variables are safe to migrate from 'int' to
'size_t' because no negative value is used.)

'dirty_index' is supposed to have shorter lifespan than a Vector
instance, and by removing the member we can reduce object size.

'dirty_count' is redundant and thus removed as well.

A boolean 'isDirty' member is added to a Vector object for ease of
debugging.

Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
@Explorer09 Explorer09 marked this pull request as ready for review October 11, 2025 14:44
@BenBE BenBE merged commit a5e5d08 into htop-dev:main Oct 13, 2025
19 checks passed
@Explorer09 Explorer09 deleted the vector-dirty branch October 13, 2025 10:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Extension or improvement to existing feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants