eliminated one sprintf in data json generation
Costa Tsaousis (ktsaou) committed
Apr 29, 2014 at 03:12 UTC
2bfd948e9511c4400cd7f717c24cbedfeee5dedf
1 file changed
+4
-4
netdata.c
+4
-4
@@ -1517,7 +1517,6 @@ unsigned long rrd_stats_json(int type, RRD_STATS *st, struct web_buffer *wb, siz
1517
int dimensions = 0; // the total number of dimensions present
1518
1519
unsigned long long usec = 0;// usec between the entries
1520
- char dtm[201]; // temp variable for storing dates
1520
1521
int we_need_totals = 0; // if set, we should calculate totals for all dimensions
1522
@@ -1636,11 +1635,12 @@ unsigned long rrd_stats_json(int type, RRD_STATS *st, struct web_buffer *wb, siz
1635
// generate the local date time
1636
struct tm *tm = localtime(&st->times[t].tv_sec);
1637
if(!tm) { error("localtime() failed."); continue; }
1639
-
1638
if(st->times[t].tv_sec > last_timestamp) last_timestamp = st->times[t].tv_sec;
1639
1642
- sprintf(dtm, "Date(%d, %d, %d, %d, %d, %d, %d)", tm->tm_year + 1900, tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, (int)(st->times[t].tv_usec / 1000)); // datetime
1643
- web_buffer_printf(wb, "%s {%sc%s:[{%sv%s:%s%s%s}", printed?"]},\n":"", kq, kq, kq, kq, sq, dtm, sq);
1640
+ web_buffer_printf(wb, "%s {%sc%s:[{%sv%s:%sDate(%d, %d, %d, %d, %d, %d, %d)%s}", printed?"]},\n":"",
1641
+ kq, kq, kq, kq, sq,
1642
+ tm->tm_year + 1900, tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, (int)(st->times[t].tv_usec / 1000),
1643
+ sq);
1644
1645
print_this = 1;
1646
}