-
Notifications
You must be signed in to change notification settings - Fork 1.9k
mp: sort flb_record_accessor by a number of subkeys(#5546) #5590
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
53817cd
a0c21b0
8a4ded6
3696447
c9ece83
b98c063
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,6 +27,21 @@ | |
| #include "ra_parser.h" | ||
| #include "ra_lex.h" | ||
|
|
||
| int flb_ra_parser_subkey_count(struct flb_ra_parser *rp) | ||
| { | ||
| if (rp == NULL || rp->key == NULL) { | ||
| return -1; | ||
| } | ||
| else if (rp->type != FLB_RA_PARSER_KEYMAP) { | ||
| return 0; | ||
| } | ||
| else if(rp->key->subkeys == NULL) { | ||
| return -1; | ||
| } | ||
|
|
||
| return mk_list_size(rp->key->subkeys); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Beware of
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm glad monkey API supports that feature. However we don't pass a head node pointer to
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's true and the possible side effect could be a lot worse than the original issue, you're right. |
||
| } | ||
|
|
||
| void flb_ra_parser_dump(struct flb_ra_parser *rp) | ||
| { | ||
| struct mk_list *head; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe returning 0 in this case would be better even if that would make it undistinguishable from legitimate empty ra it would be it less error prone (ie. someone using a size_t without paying attention) since at the moment the result is not being checked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer returning negative value.
In a future, the result can be checked.