aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/influxdata/influxdb/models/inline_strconv_parse.go
diff options
context:
space:
mode:
authorAnton Evangelatov <anton.evangelatov@gmail.com>2018-02-23 17:56:08 +0800
committerPéter Szilágyi <peterke@gmail.com>2018-02-23 17:56:08 +0800
commitae9f97221a96a86e4343a5c3cc4b1db44627a2f3 (patch)
tree0154be72d0f2e1f032d129b9433d1bf3939cd8f0 /vendor/github.com/influxdata/influxdb/models/inline_strconv_parse.go
parent7f74bdf8dded0e1ac3c01e043c2ed89d78f308cf (diff)
downloadgo-tangerine-ae9f97221a96a86e4343a5c3cc4b1db44627a2f3.tar
go-tangerine-ae9f97221a96a86e4343a5c3cc4b1db44627a2f3.tar.gz
go-tangerine-ae9f97221a96a86e4343a5c3cc4b1db44627a2f3.tar.bz2
go-tangerine-ae9f97221a96a86e4343a5c3cc4b1db44627a2f3.tar.lz
go-tangerine-ae9f97221a96a86e4343a5c3cc4b1db44627a2f3.tar.xz
go-tangerine-ae9f97221a96a86e4343a5c3cc4b1db44627a2f3.tar.zst
go-tangerine-ae9f97221a96a86e4343a5c3cc4b1db44627a2f3.zip
metrics: pull library and introduce ResettingTimer and InfluxDB reporter (#15910)
* go-metrics: fork library and introduce ResettingTimer and InfluxDB reporter. * vendor: change nonsense/go-metrics to ethersphere/go-metrics * go-metrics: add tests. move ResettingTimer logic from reporter to type. * all, metrics: pull in metrics package in go-ethereum * metrics/test: make sure metrics are enabled for tests * metrics: apply gosimple rules * metrics/exp, internal/debug: init expvar endpoint when starting pprof server * internal/debug: tiny comment formatting fix
Diffstat (limited to 'vendor/github.com/influxdata/influxdb/models/inline_strconv_parse.go')
-rw-r--r--vendor/github.com/influxdata/influxdb/models/inline_strconv_parse.go44
1 files changed, 44 insertions, 0 deletions
diff --git a/vendor/github.com/influxdata/influxdb/models/inline_strconv_parse.go b/vendor/github.com/influxdata/influxdb/models/inline_strconv_parse.go
new file mode 100644
index 000000000..8db483738
--- /dev/null
+++ b/vendor/github.com/influxdata/influxdb/models/inline_strconv_parse.go
@@ -0,0 +1,44 @@
+package models // import "github.com/influxdata/influxdb/models"
+
+import (
+ "reflect"
+ "strconv"
+ "unsafe"
+)
+
+// parseIntBytes is a zero-alloc wrapper around strconv.ParseInt.
+func parseIntBytes(b []byte, base int, bitSize int) (i int64, err error) {
+ s := unsafeBytesToString(b)
+ return strconv.ParseInt(s, base, bitSize)
+}
+
+// parseUintBytes is a zero-alloc wrapper around strconv.ParseUint.
+func parseUintBytes(b []byte, base int, bitSize int) (i uint64, err error) {
+ s := unsafeBytesToString(b)
+ return strconv.ParseUint(s, base, bitSize)
+}
+
+// parseFloatBytes is a zero-alloc wrapper around strconv.ParseFloat.
+func parseFloatBytes(b []byte, bitSize int) (float64, error) {
+ s := unsafeBytesToString(b)
+ return strconv.ParseFloat(s, bitSize)
+}
+
+// parseBoolBytes is a zero-alloc wrapper around strconv.ParseBool.
+func parseBoolBytes(b []byte) (bool, error) {
+ return strconv.ParseBool(unsafeBytesToString(b))
+}
+
+// unsafeBytesToString converts a []byte to a string without a heap allocation.
+//
+// It is unsafe, and is intended to prepare input to short-lived functions
+// that require strings.
+func unsafeBytesToString(in []byte) string {
+ src := *(*reflect.SliceHeader)(unsafe.Pointer(&in))
+ dst := reflect.StringHeader{
+ Data: src.Data,
+ Len: src.Len,
+ }
+ s := *(*string)(unsafe.Pointer(&dst))
+ return s
+}