Skip to content

Count values set on inner nodes of COMPS_ObjRTree - #162

Merged
m-blaha merged 1 commit into
rpm-software-management:masterfrom
prownd:count-values-set-on-inner-nodes-of-COMPS_ObjRTree-s01
Oct 27, 2026
Merged

m-blaha merged 1 commit into
rpm-software-management:masterfrom
prownd:count-values-set-on-inner-nodes-of-COMPS_ObjRTree-s01

Conversation

@prownd

@prownd prownd commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

Setting a key which already exists as an inner node without a value (e.g. "a" after "ab" and "ac") replaced the NULL data without incrementing COMPS_ObjRTree.len, so len() of the dict was too small.

}
if (ended == 3) { //keys equals; data replacement
if (rtdata->data == NULL)
rt->len++;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That only handles transition NULL -> value. Should we handle also NULL -> NULL (where the len is incorrectly increased) and value -> NULL (where the len should be decreased)?
e.g.

if (rtdata->data == NULL && ndata != NULL)
    rt->len++;
else if (rtdata->data != NULL && ndata == NULL)
    rt->len--;

Setting a key which already exists as an inner node without a value
(e.g. "a" after "ab" and "ac") replaced the NULL data without
incrementing COMPS_ObjRTree.len, so len() of the dict was too small.

Also decrement the count when an existing value is replaced with NULL,
and keep it unchanged when NULL is replaced with NULL.

Signed-off-by: hanjinpeng <hanjinpeng@kylinos.cn>
@prownd
prownd force-pushed the count-values-set-on-inner-nodes-of-COMPS_ObjRTree-s01 branch from 02e5acc to 66eb414 Compare October 27, 2026 10:45
@prownd

prownd commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor Author

@m-blaha

Thanks, good point. Updated as suggested.

@m-blaha m-blaha left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

@m-blaha
m-blaha merged commit dbeccd3 into rpm-software-management:master Oct 27, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants