From ab1e66d31fd63ac8eccf1a258a709e31d0eccf86 Mon Sep 17 00:00:00 2001
From: Aliaksandr Valialkin <valyala@gmail.com>
Date: Sun, 23 Feb 2020 10:03:45 +0200
Subject: [PATCH] vendor: update github.com/valyala/fastjson from v1.4.5 to
 v1.5.0

---
 go.mod                                        |  2 +-
 go.sum                                        |  4 ++--
 .../valyala/fastjson/fastfloat/parse.go       | 24 ++++++++++++-------
 vendor/github.com/valyala/fastjson/go.mod     |  2 ++
 vendor/modules.txt                            |  2 +-
 5 files changed, 21 insertions(+), 13 deletions(-)

diff --git a/go.mod b/go.mod
index 566168339d..5a769f1f1c 100644
--- a/go.mod
+++ b/go.mod
@@ -10,7 +10,7 @@ require (
 	github.com/golang/snappy v0.0.1
 	github.com/klauspost/compress v1.10.0
 	github.com/lithammer/go-jump-consistent-hash v1.0.1
-	github.com/valyala/fastjson v1.4.5
+	github.com/valyala/fastjson v1.5.0
 	github.com/valyala/fastrand v1.0.0
 	github.com/valyala/gozstd v1.6.4
 	github.com/valyala/histogram v1.0.1
diff --git a/go.sum b/go.sum
index f90a59695a..024acd33e6 100644
--- a/go.sum
+++ b/go.sum
@@ -121,8 +121,8 @@ github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81P
 github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
 github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
 github.com/valyala/fasthttp v1.2.0/go.mod h1:4vX61m6KN+xDduDNwXrhIAVZaZaZiQ1luJk8LWSxF3s=
-github.com/valyala/fastjson v1.4.5 h1:uSuLfXk2LzRtzwd3Fy5zGRBe0Vs7zhs11vjdko32xb4=
-github.com/valyala/fastjson v1.4.5/go.mod h1:nV6MsjxL2IMJQUoHDIrjEI7oLyeqK6aBD7EFWPsvP8o=
+github.com/valyala/fastjson v1.5.0 h1:DGrb4wEYso2HdGLyLmNoyNCQnCWfjd8yhghPv5/5YQg=
+github.com/valyala/fastjson v1.5.0/go.mod h1:CLCAqky6SMuOcxStkYQvblddUtoRxhYMGLrsQns1aXY=
 github.com/valyala/fastrand v1.0.0 h1:LUKT9aKer2dVQNUi3waewTbKV+7H17kvWFNKs2ObdkI=
 github.com/valyala/fastrand v1.0.0/go.mod h1:HWqCzkrkg6QXT8V2EXWvXCoow7vLwOFN002oeRzjapQ=
 github.com/valyala/gozstd v1.6.4 h1:nFLddjEf90SFl5cVWyElSHozQDsbvLljPK703/skBS0=
diff --git a/vendor/github.com/valyala/fastjson/fastfloat/parse.go b/vendor/github.com/valyala/fastjson/fastfloat/parse.go
index bc264bda9a..4d9a8bbb71 100644
--- a/vendor/github.com/valyala/fastjson/fastfloat/parse.go
+++ b/vendor/github.com/valyala/fastjson/fastfloat/parse.go
@@ -2,8 +2,8 @@ package fastfloat
 
 import (
 	"math"
-	"strings"
 	"strconv"
+	"strings"
 )
 
 // ParseUint64BestEffort parses uint64 number s.
@@ -95,6 +95,13 @@ func ParseInt64BestEffort(s string) int64 {
 	return d
 }
 
+// Exact powers of 10.
+//
+// This works faster than math.Pow10, since it avoids additional multiplication.
+var float64pow10 = [...]float64{
+	1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16,
+}
+
 // ParseBestEffort parses floating-point number s.
 //
 // It is equivalent to strconv.ParseFloat(s, 64), but is faster.
@@ -159,15 +166,13 @@ func ParseBestEffort(s string) float64 {
 		if i >= uint(len(s)) {
 			return 0
 		}
-		fr := uint64(0)
-		j := i
+		k := i
 		for i < uint(len(s)) {
 			if s[i] >= '0' && s[i] <= '9' {
-				fr = fr*10 + uint64(s[i]-'0')
+				d = d*10 + uint64(s[i]-'0')
 				i++
-				if i-j > 18 {
-					// The fractional part may be out of range for uint64.
-					// Fall back to standard parsing.
+				if i-j >= uint(len(float64pow10)) {
+					// The mantissa is out of range. Fall back to standard parsing.
 					f, err := strconv.ParseFloat(s, 64)
 					if err != nil && !math.IsInf(f, 0) {
 						return 0
@@ -178,10 +183,11 @@ func ParseBestEffort(s string) float64 {
 			}
 			break
 		}
-		if i <= j {
+		if i <= k {
 			return 0
 		}
-		f += float64(fr) / math.Pow10(int(i-j))
+		// Convert the entire mantissa to a float at once to avoid rounding errors.
+		f = float64(d) / float64pow10[i-k]
 		if i >= uint(len(s)) {
 			// Fast path - parsed fractional number.
 			if minus {
diff --git a/vendor/github.com/valyala/fastjson/go.mod b/vendor/github.com/valyala/fastjson/go.mod
index c0a990c771..c85c656561 100644
--- a/vendor/github.com/valyala/fastjson/go.mod
+++ b/vendor/github.com/valyala/fastjson/go.mod
@@ -1 +1,3 @@
 module github.com/valyala/fastjson
+
+go 1.12
diff --git a/vendor/modules.txt b/vendor/modules.txt
index da4159b1b9..a7a23986d7 100644
--- a/vendor/modules.txt
+++ b/vendor/modules.txt
@@ -97,7 +97,7 @@ github.com/klauspost/compress/zstd/internal/xxhash
 github.com/lithammer/go-jump-consistent-hash
 # github.com/valyala/bytebufferpool v1.0.0
 github.com/valyala/bytebufferpool
-# github.com/valyala/fastjson v1.4.5
+# github.com/valyala/fastjson v1.5.0
 github.com/valyala/fastjson
 github.com/valyala/fastjson/fastfloat
 # github.com/valyala/fastrand v1.0.0