Skip to content

Commit

Permalink
cat: filter: Remove copy from functions
Browse files Browse the repository at this point in the history
Because (con)cat(enate) implies copying the pointer/context.

Signed-off-by: Hiroshi Hatake <[email protected]>
  • Loading branch information
cosmo0920 committed Feb 21, 2024
1 parent 61c040e commit 18d34ef
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 25 deletions.
10 changes: 5 additions & 5 deletions include/cmetrics/cmt_cat.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ struct cmt_untyped;
struct cmt_histogram;
struct cmt_summary;

int cmt_cat_copy_counter(struct cmt *cmt, struct cmt_counter *counter);
int cmt_cat_copy_gauge(struct cmt *cmt, struct cmt_gauge *gauge);
int cmt_cat_copy_untyped(struct cmt *cmt, struct cmt_untyped *untyped);
int cmt_cat_copy_histogram(struct cmt *cmt, struct cmt_histogram *histogram);
int cmt_cat_copy_summary(struct cmt *cmt, struct cmt_summary *summary);
int cmt_cat_counter(struct cmt *cmt, struct cmt_counter *counter);
int cmt_cat_gauge(struct cmt *cmt, struct cmt_gauge *gauge);
int cmt_cat_untyped(struct cmt *cmt, struct cmt_untyped *untyped);
int cmt_cat_histogram(struct cmt *cmt, struct cmt_histogram *histogram);
int cmt_cat_summary(struct cmt *cmt, struct cmt_summary *summary);
int cmt_cat(struct cmt *dst, struct cmt *src);

#endif
20 changes: 10 additions & 10 deletions src/cmt_cat.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ static int copy_map(struct cmt_opts *opts, struct cmt_map *dst, struct cmt_map *

}

int cmt_cat_copy_counter(struct cmt *cmt, struct cmt_counter *counter)
int cmt_cat_counter(struct cmt *cmt, struct cmt_counter *counter)
{
int ret;
char **labels = NULL;
Expand Down Expand Up @@ -213,7 +213,7 @@ int cmt_cat_copy_counter(struct cmt *cmt, struct cmt_counter *counter)
return 0;
}

int cmt_cat_copy_gauge(struct cmt *cmt, struct cmt_gauge *gauge)
int cmt_cat_gauge(struct cmt *cmt, struct cmt_gauge *gauge)
{
int ret;
char **labels = NULL;
Expand Down Expand Up @@ -247,7 +247,7 @@ int cmt_cat_copy_gauge(struct cmt *cmt, struct cmt_gauge *gauge)
return 0;
}

int cmt_cat_copy_untyped(struct cmt *cmt, struct cmt_untyped *untyped)
int cmt_cat_untyped(struct cmt *cmt, struct cmt_untyped *untyped)
{
int ret;
char **labels = NULL;
Expand Down Expand Up @@ -281,7 +281,7 @@ int cmt_cat_copy_untyped(struct cmt *cmt, struct cmt_untyped *untyped)
return 0;
}

int cmt_cat_copy_histogram(struct cmt *cmt, struct cmt_histogram *histogram)
int cmt_cat_histogram(struct cmt *cmt, struct cmt_histogram *histogram)
{
int i;
double val;
Expand Down Expand Up @@ -331,7 +331,7 @@ int cmt_cat_copy_histogram(struct cmt *cmt, struct cmt_histogram *histogram)
return 0;
}

int cmt_cat_copy_summary(struct cmt *cmt, struct cmt_summary *summary)
int cmt_cat_summary(struct cmt *cmt, struct cmt_summary *summary)
{
int i;
int ret;
Expand Down Expand Up @@ -395,7 +395,7 @@ static int append_context(struct cmt *dst, struct cmt *src)
/* Counters */
cfl_list_foreach(head, &src->counters) {
counter = cfl_list_entry(head, struct cmt_counter, _head);
ret = cmt_cat_copy_counter(dst, counter);
ret = cmt_cat_counter(dst, counter);
if (ret == -1) {
return -1;
}
Expand All @@ -404,7 +404,7 @@ static int append_context(struct cmt *dst, struct cmt *src)
/* Gauges */
cfl_list_foreach(head, &src->gauges) {
gauge = cfl_list_entry(head, struct cmt_gauge, _head);
ret = cmt_cat_copy_gauge(dst, gauge);
ret = cmt_cat_gauge(dst, gauge);
if (ret == -1) {
return -1;
}
Expand All @@ -413,7 +413,7 @@ static int append_context(struct cmt *dst, struct cmt *src)
/* Untyped */
cfl_list_foreach(head, &src->untypeds) {
untyped = cfl_list_entry(head, struct cmt_untyped, _head);
ret = cmt_cat_copy_untyped(dst, untyped);
ret = cmt_cat_untyped(dst, untyped);
if (ret == -1) {
return -1;
}
Expand All @@ -422,7 +422,7 @@ static int append_context(struct cmt *dst, struct cmt *src)
/* Histogram */
cfl_list_foreach(head, &src->histograms) {
histogram = cfl_list_entry(head, struct cmt_histogram, _head);
ret = cmt_cat_copy_histogram(dst, histogram);
ret = cmt_cat_histogram(dst, histogram);
if (ret == -1) {
return -1;
}
Expand All @@ -431,7 +431,7 @@ static int append_context(struct cmt *dst, struct cmt *src)
/* Summary */
cfl_list_foreach(head, &src->summaries) {
summary = cfl_list_entry(head, struct cmt_summary, _head);
ret = cmt_cat_copy_summary(dst, summary);
ret = cmt_cat_summary(dst, summary);
if (ret == -1) {
return -1;
}
Expand Down
20 changes: 10 additions & 10 deletions src/cmt_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ static int filter_context_label_key(struct cmt *dst, struct cmt *src,
continue;
}

ret = cmt_cat_copy_counter(dst, counter);
ret = cmt_cat_counter(dst, counter);
if (ret == -1) {
return -1;
}
Expand All @@ -107,7 +107,7 @@ static int filter_context_label_key(struct cmt *dst, struct cmt *src,
continue;
}

ret = cmt_cat_copy_gauge(dst, gauge);
ret = cmt_cat_gauge(dst, gauge);
if (ret == -1) {
return -1;
}
Expand All @@ -121,7 +121,7 @@ static int filter_context_label_key(struct cmt *dst, struct cmt *src,
continue;
}

ret = cmt_cat_copy_untyped(dst, untyped);
ret = cmt_cat_untyped(dst, untyped);
if (ret == -1) {
return -1;
}
Expand All @@ -135,7 +135,7 @@ static int filter_context_label_key(struct cmt *dst, struct cmt *src,
continue;
}

ret = cmt_cat_copy_histogram(dst, histogram);
ret = cmt_cat_histogram(dst, histogram);
if (ret == -1) {
return -1;
}
Expand All @@ -149,7 +149,7 @@ static int filter_context_label_key(struct cmt *dst, struct cmt *src,
continue;
}

ret = cmt_cat_copy_summary(dst, summary);
ret = cmt_cat_summary(dst, summary);
if (ret == -1) {
return -1;
}
Expand Down Expand Up @@ -213,7 +213,7 @@ static int filter_context_fqname(struct cmt *dst, struct cmt *src,
continue;
}

ret = cmt_cat_copy_counter(dst, counter);
ret = cmt_cat_counter(dst, counter);
if (ret == -1) {
return -1;
}
Expand All @@ -226,7 +226,7 @@ static int filter_context_fqname(struct cmt *dst, struct cmt *src,
continue;
}

ret = cmt_cat_copy_gauge(dst, gauge);
ret = cmt_cat_gauge(dst, gauge);
if (ret == -1) {
return -1;
}
Expand All @@ -239,7 +239,7 @@ static int filter_context_fqname(struct cmt *dst, struct cmt *src,
continue;
}

ret = cmt_cat_copy_untyped(dst, untyped);
ret = cmt_cat_untyped(dst, untyped);
if (ret == -1) {
return -1;
}
Expand All @@ -252,7 +252,7 @@ static int filter_context_fqname(struct cmt *dst, struct cmt *src,
continue;
}

ret = cmt_cat_copy_histogram(dst, histogram);
ret = cmt_cat_histogram(dst, histogram);
if (ret == -1) {
return -1;
}
Expand All @@ -265,7 +265,7 @@ static int filter_context_fqname(struct cmt *dst, struct cmt *src,
continue;
}

ret = cmt_cat_copy_summary(dst, summary);
ret = cmt_cat_summary(dst, summary);
if (ret == -1) {
return -1;
}
Expand Down

0 comments on commit 18d34ef

Please sign in to comment.