summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 74f51aa)
raw | patch | inline | side by side (parent: 74f51aa)
author | Florian Forster <octo@collectd.org> | |
Thu, 11 Jul 2013 11:03:12 +0000 (13:03 +0200) | ||
committer | Florian Forster <octo@collectd.org> | |
Thu, 11 Jul 2013 11:03:12 +0000 (13:03 +0200) |
parse_value() is doing a strdup() do it can remove trailing whitespace.
We don't need that for the statsd protocol, so we just call strtoull()
instead, improving performance but a couple of percent again.
We don't need that for the statsd protocol, so we just call strtoull()
instead, improving performance but a couple of percent again.
src/statsd.c | patch | blob | history |
diff --git a/src/statsd.c b/src/statsd.c
index b8fee175574334521120642c78714e80d2db6e84..a83cc9a2ece6907c9f2009286f04e3e5259b920e 100644 (file)
--- a/src/statsd.c
+++ b/src/statsd.c
static size_t conf_timer_percentile_num = 0;
/* Must hold metrics_lock when calling this function. */
-static statsd_metric_t *statsd_metric_lookup_unsafe (char const *name,
+static statsd_metric_t *statsd_metric_lookup_unsafe (char const *name, /* {{{ */
metric_type_t type)
{
char key[DATA_MAX_NAME_LEN + 2];
return (0);
} /* }}} int statsd_metric_add */
+static int statsd_parse_value (char const *str, value_t *ret_value) /* {{{ */
+{
+ char *endptr = NULL;
+
+ ret_value->derive = (derive_t) strtoll (str, &endptr, /* base = */ 0);
+ if ((str == endptr) || ((endptr != NULL) && (*endptr != 0)))
+ return (-1);
+
+ return (0);
+} /* }}} int statsd_parse_value */
+
static int statsd_handle_counter (char const *name, /* {{{ */
char const *value_str,
char const *extra)
}
value.derive = 1;
- status = parse_value (value_str, &value, DS_TYPE_DERIVE);
+ status = statsd_parse_value (value_str, &value);
if (status != 0)
return (status);
int status;
value.derive = 0;
- status = parse_value (value_str, &value, DS_TYPE_DERIVE);
+ status = statsd_parse_value (value_str, &value);
if (status != 0)
return (status);
int status;
value_ms.derive = 0;
- status = parse_value (value_str, &value_ms, DS_TYPE_DERIVE);
+ status = statsd_parse_value (value_str, &value_ms);
if (status != 0)
return (status);