@cryptotaxi247 / netdata-1 / commits / fc82c47b3

Get last_entry_t only when st changes (#13448)

get last_entry_t when st changes

Emmanuel Vasilakis committed Jul 28, 2022 at 17:26 UTC fc82c47b32dd023003e60a6c071fd53c7eb751a5
1 file changed +14 -2
web/api/formatters/rrd2json.c
+14 -2
@@ -62,10 +62,22 @@ void rebuild_context_param_list(ONEWAYALLOC *owa, struct context_param *context_
62 RRDDIM *temp_rd = context_param_list->rd;
63 RRDDIM *new_rd_list = NULL, *t;
64 int is_archived = (context_param_list->flags & CONTEXT_FLAGS_ARCHIVE);
65 +
66 + RRDSET *st = temp_rd->rrdset;
67 + RRDSET *last_st = st;
68 + time_t last_entry_t = is_archived ? st->last_entry_t : rrdset_last_entry_t(st);
69 + time_t last_last_entry_t = last_entry_t;
70 while (temp_rd) {
71 t = temp_rd->next;
67 - RRDSET *st = temp_rd->rrdset;
68 - time_t last_entry_t = is_archived ? st->last_entry_t : rrdset_last_entry_t(st);
72 +
73 + st = temp_rd->rrdset;
74 + if (st == last_st) {
75 + last_entry_t = last_last_entry_t;
76 + }else {
77 + last_entry_t = is_archived ? st->last_entry_t : rrdset_last_entry_t(st);
78 + last_last_entry_t = last_entry_t;
79 + last_st = st;
80 + }
81
82 if (last_entry_t >= after_requested) {
83 temp_rd->next = new_rd_list;