mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-28 11:18:45 +07:00
27d0fd410c
The strlist__entry method allows accessing strlists like an array, will be used in the 'perf report' to access the first entry. We now keep the nr_entries so that we can check if we have just one entry, will be used in 'perf report' to improve the output by showing just at the top when we have just, say, one DSO. While at it use nr_entries to optimize strlist__is_empty by not using the far more costly rb_first based implementation. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> LKML-Reference: <1247325517-12272-2-git-send-email-acme@redhat.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
40 lines
978 B
C
40 lines
978 B
C
#ifndef STRLIST_H_
|
|
#define STRLIST_H_
|
|
|
|
#include <linux/rbtree.h>
|
|
#include <stdbool.h>
|
|
|
|
struct str_node {
|
|
struct rb_node rb_node;
|
|
const char *s;
|
|
};
|
|
|
|
struct strlist {
|
|
struct rb_root entries;
|
|
unsigned int nr_entries;
|
|
bool dupstr;
|
|
};
|
|
|
|
struct strlist *strlist__new(bool dupstr, const char *slist);
|
|
void strlist__delete(struct strlist *self);
|
|
|
|
void strlist__remove(struct strlist *self, struct str_node *sn);
|
|
int strlist__load(struct strlist *self, const char *filename);
|
|
int strlist__add(struct strlist *self, const char *str);
|
|
|
|
struct str_node *strlist__entry(const struct strlist *self, unsigned int idx);
|
|
bool strlist__has_entry(struct strlist *self, const char *entry);
|
|
|
|
static inline bool strlist__empty(const struct strlist *self)
|
|
{
|
|
return self->nr_entries == 0;
|
|
}
|
|
|
|
static inline unsigned int strlist__nr_entries(const struct strlist *self)
|
|
{
|
|
return self->nr_entries;
|
|
}
|
|
|
|
int strlist__parse_list(struct strlist *self, const char *s);
|
|
#endif /* STRLIST_H_ */
|