mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-06-20 01:19:23 +02:00
Bump github.com/buger/jsonparser from 1.1.1 to 1.1.2 (#5423)
Bumps [github.com/buger/jsonparser](https://github.com/buger/jsonparser) from 1.1.1 to 1.1.2.
This commit is contained in:
@@ -45,7 +45,7 @@ require (
|
||||
|
||||
require (
|
||||
github.com/bahlo/generic-list-go v0.2.0 // indirect
|
||||
github.com/buger/jsonparser v1.1.1 // indirect
|
||||
github.com/buger/jsonparser v1.1.2 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/fatih/color v1.9.0 // indirect
|
||||
github.com/gdamore/encoding v1.0.1 // indirect
|
||||
|
||||
@@ -49,8 +49,8 @@ github.com/aybabtme/humanlog v0.4.1/go.mod h1:B0bnQX4FTSU3oftPMTTPvENCy8LqixLDvY
|
||||
github.com/aybabtme/rgbterm v0.0.0-20170906152045-cc83f3b3ce59/go.mod h1:q/89r3U2H7sSsE2t6Kca0lfwTK8JdoNGS/yzM/4iH5I=
|
||||
github.com/bahlo/generic-list-go v0.2.0 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPnH1Wvgk=
|
||||
github.com/bahlo/generic-list-go v0.2.0/go.mod h1:2KvAjgMlE5NNynlg/5iLrrCCZ2+5xWbdbCW3pNTGyYg=
|
||||
github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs=
|
||||
github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
|
||||
github.com/buger/jsonparser v1.1.2 h1:frqHqw7otoVbk5M8LlE/L7HTnIq2v9RX6EJ48i9AxJk=
|
||||
github.com/buger/jsonparser v1.1.2/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
|
||||
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
|
||||
|
||||
+6
-5
@@ -3,9 +3,10 @@ arch:
|
||||
- amd64
|
||||
- ppc64le
|
||||
go:
|
||||
- 1.7.x
|
||||
- 1.8.x
|
||||
- 1.9.x
|
||||
- 1.10.x
|
||||
- 1.11.x
|
||||
- 1.13.x
|
||||
- 1.14.x
|
||||
- 1.15.x
|
||||
- 1.16.x
|
||||
- 1.17.x
|
||||
- 1.18.x
|
||||
script: go test -v ./.
|
||||
|
||||
-4
@@ -90,10 +90,6 @@ jsonparser.EachKey(data, func(idx int, value []byte, vt jsonparser.ValueType, er
|
||||
// For more information see docs below
|
||||
```
|
||||
|
||||
## Need to speedup your app?
|
||||
|
||||
I'm available for consulting and can help you push your app performance to the limits. Ping me at: leonsbox@gmail.com.
|
||||
|
||||
## Reference
|
||||
|
||||
Library API is really simple. You just need the `Get` method to perform any operation. The rest is just helpers around it.
|
||||
|
||||
+18
-18
@@ -1,11 +1,8 @@
|
||||
package jsonparser
|
||||
|
||||
import (
|
||||
bio "bytes"
|
||||
)
|
||||
|
||||
// minInt64 '-9223372036854775808' is the smallest representable number in int64
|
||||
const minInt64 = `9223372036854775808`
|
||||
const absMinInt64 = 1 << 63
|
||||
const maxInt64 = 1<<63 - 1
|
||||
const maxUint64 = 1<<64 - 1
|
||||
|
||||
// About 2x faster then strconv.ParseInt because it only supports base 10, which is enough for JSON
|
||||
func parseInt(bytes []byte) (v int64, ok bool, overflow bool) {
|
||||
@@ -19,29 +16,32 @@ func parseInt(bytes []byte) (v int64, ok bool, overflow bool) {
|
||||
bytes = bytes[1:]
|
||||
}
|
||||
|
||||
var b int64 = 0
|
||||
var n uint64 = 0
|
||||
for _, c := range bytes {
|
||||
if c >= '0' && c <= '9' {
|
||||
b = (10 * v) + int64(c-'0')
|
||||
} else {
|
||||
if c < '0' || c > '9' {
|
||||
return 0, false, false
|
||||
}
|
||||
if overflow = (b < v); overflow {
|
||||
break
|
||||
if n > maxUint64/10 {
|
||||
return 0, false, true
|
||||
}
|
||||
v = b
|
||||
n *= 10
|
||||
n1 := n + uint64(c-'0')
|
||||
if n1 < n {
|
||||
return 0, false, true
|
||||
}
|
||||
n = n1
|
||||
}
|
||||
|
||||
if overflow {
|
||||
if neg && bio.Equal(bytes, []byte(minInt64)) {
|
||||
return b, true, false
|
||||
if n > maxInt64 {
|
||||
if neg && n == absMinInt64 {
|
||||
return -absMinInt64, true, false
|
||||
}
|
||||
return 0, false, true
|
||||
}
|
||||
|
||||
if neg {
|
||||
return -v, true, false
|
||||
return -int64(n), true, false
|
||||
} else {
|
||||
return v, true, false
|
||||
return int64(n), true, false
|
||||
}
|
||||
}
|
||||
|
||||
+47
-12
@@ -18,6 +18,7 @@ var (
|
||||
MalformedValueError = errors.New("Value looks like Number/Boolean/None, but can't find its end: ',' or '}' symbol")
|
||||
OverflowIntegerError = errors.New("Value is number, but overflowed while parsing")
|
||||
MalformedStringEscapeError = errors.New("Encountered an invalid escape sequence in a string")
|
||||
NullValueError = errors.New("Value is null")
|
||||
)
|
||||
|
||||
// How much stack space to allocate for unescaping JSON strings; if a string longer
|
||||
@@ -49,10 +50,13 @@ func findTokenStart(data []byte, token byte) int {
|
||||
}
|
||||
|
||||
func findKeyStart(data []byte, key string) (int, error) {
|
||||
i := 0
|
||||
i := nextToken(data)
|
||||
if i == -1 {
|
||||
return i, KeyPathNotFoundError
|
||||
}
|
||||
ln := len(data)
|
||||
if ln > 0 && (data[0] == '{' || data[0] == '[') {
|
||||
i = 1
|
||||
if ln > 0 && (data[i] == '{' || data[i] == '[') {
|
||||
i += 1
|
||||
}
|
||||
var stackbuf [unescapeStackBufSize]byte // stack-allocated array for allocation-free unescaping of small strings
|
||||
|
||||
@@ -308,7 +312,7 @@ func searchKeys(data []byte, keys ...string) int {
|
||||
case '[':
|
||||
// If we want to get array element by index
|
||||
if keyLevel == level && keys[level][0] == '[' {
|
||||
var keyLen = len(keys[level])
|
||||
keyLen := len(keys[level])
|
||||
if keyLen < 3 || keys[level][0] != '[' || keys[level][keyLen-1] != ']' {
|
||||
return -1
|
||||
}
|
||||
@@ -319,7 +323,7 @@ func searchKeys(data []byte, keys ...string) int {
|
||||
var curIdx int
|
||||
var valueFound []byte
|
||||
var valueOffset int
|
||||
var curI = i
|
||||
curI := i
|
||||
ArrayEach(data[i:], func(value []byte, dataType ValueType, offset int, err error) {
|
||||
if curIdx == aIdx {
|
||||
valueFound = value
|
||||
@@ -374,12 +378,19 @@ func sameTree(p1, p2 []string) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
const stackArraySize = 128
|
||||
|
||||
func EachKey(data []byte, cb func(int, []byte, ValueType, error), paths ...[]string) int {
|
||||
var x struct{}
|
||||
pathFlags := make([]bool, len(paths))
|
||||
var level, pathsMatched, i int
|
||||
ln := len(data)
|
||||
|
||||
pathFlags := make([]bool, stackArraySize)[:]
|
||||
if len(paths) > cap(pathFlags) {
|
||||
pathFlags = make([]bool, len(paths))[:]
|
||||
}
|
||||
pathFlags = pathFlags[0:len(paths)]
|
||||
|
||||
var maxPath int
|
||||
for _, p := range paths {
|
||||
if len(p) > maxPath {
|
||||
@@ -387,7 +398,11 @@ func EachKey(data []byte, cb func(int, []byte, ValueType, error), paths ...[]str
|
||||
}
|
||||
}
|
||||
|
||||
pathsBuf := make([]string, maxPath)
|
||||
pathsBuf := make([]string, stackArraySize)[:]
|
||||
if maxPath > cap(pathsBuf) {
|
||||
pathsBuf = make([]string, maxPath)[:]
|
||||
}
|
||||
pathsBuf = pathsBuf[0:maxPath]
|
||||
|
||||
for i < ln {
|
||||
switch data[i] {
|
||||
@@ -484,7 +499,12 @@ func EachKey(data []byte, cb func(int, []byte, ValueType, error), paths ...[]str
|
||||
case '[':
|
||||
var ok bool
|
||||
arrIdxFlags := make(map[int]struct{})
|
||||
pIdxFlags := make([]bool, len(paths))
|
||||
|
||||
pIdxFlags := make([]bool, stackArraySize)[:]
|
||||
if len(paths) > cap(pIdxFlags) {
|
||||
pIdxFlags = make([]bool, len(paths))[:]
|
||||
}
|
||||
pIdxFlags = pIdxFlags[0:len(paths)]
|
||||
|
||||
if level < 0 {
|
||||
cb(-1, nil, Unknown, MalformedJsonError)
|
||||
@@ -662,7 +682,6 @@ func calcAllocateSpace(keys []string, setValue []byte, comma, object bool) int {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
lk += len(setValue)
|
||||
for i := 1; i < len(keys); i++ {
|
||||
if string(keys[i][0]) == "[" {
|
||||
@@ -712,7 +731,7 @@ func Delete(data []byte, keys ...string) []byte {
|
||||
if !array {
|
||||
if len(keys) > 1 {
|
||||
_, _, startOffset, endOffset, err = internalGet(data, keys[:lk-1]...)
|
||||
if err == KeyPathNotFoundError {
|
||||
if err != nil {
|
||||
// problem parsing the data
|
||||
return data
|
||||
}
|
||||
@@ -724,7 +743,11 @@ func Delete(data []byte, keys ...string) []byte {
|
||||
return data
|
||||
}
|
||||
keyOffset += startOffset
|
||||
_, _, _, subEndOffset, _ := internalGet(data[startOffset:endOffset], keys[lk-1])
|
||||
var subEndOffset int
|
||||
_, _, _, subEndOffset, err = internalGet(data[startOffset:endOffset], keys[lk-1])
|
||||
if err != nil {
|
||||
return data
|
||||
}
|
||||
endOffset = startOffset + subEndOffset
|
||||
tokEnd := tokenEnd(data[endOffset:])
|
||||
tokStart := findTokenStart(data[:keyOffset], ","[0])
|
||||
@@ -738,7 +761,7 @@ func Delete(data []byte, keys ...string) []byte {
|
||||
}
|
||||
} else {
|
||||
_, _, keyOffset, endOffset, err = internalGet(data, keys...)
|
||||
if err == KeyPathNotFoundError {
|
||||
if err != nil {
|
||||
// problem parsing the data
|
||||
return data
|
||||
}
|
||||
@@ -1178,6 +1201,9 @@ func GetString(data []byte, keys ...string) (val string, err error) {
|
||||
}
|
||||
|
||||
if t != String {
|
||||
if t == Null {
|
||||
return "", NullValueError
|
||||
}
|
||||
return "", fmt.Errorf("Value is not a string: %s", string(v))
|
||||
}
|
||||
|
||||
@@ -1200,6 +1226,9 @@ func GetFloat(data []byte, keys ...string) (val float64, err error) {
|
||||
}
|
||||
|
||||
if t != Number {
|
||||
if t == Null {
|
||||
return 0, NullValueError
|
||||
}
|
||||
return 0, fmt.Errorf("Value is not a number: %s", string(v))
|
||||
}
|
||||
|
||||
@@ -1216,6 +1245,9 @@ func GetInt(data []byte, keys ...string) (val int64, err error) {
|
||||
}
|
||||
|
||||
if t != Number {
|
||||
if t == Null {
|
||||
return 0, NullValueError
|
||||
}
|
||||
return 0, fmt.Errorf("Value is not a number: %s", string(v))
|
||||
}
|
||||
|
||||
@@ -1233,6 +1265,9 @@ func GetBoolean(data []byte, keys ...string) (val bool, err error) {
|
||||
}
|
||||
|
||||
if t != Boolean {
|
||||
if t == Null {
|
||||
return false, NullValueError
|
||||
}
|
||||
return false, fmt.Errorf("Value is not a boolean: %s", string(v))
|
||||
}
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -14,7 +14,7 @@ github.com/aybabtme/humanlog
|
||||
# github.com/bahlo/generic-list-go v0.2.0
|
||||
## explicit; go 1.18
|
||||
github.com/bahlo/generic-list-go
|
||||
# github.com/buger/jsonparser v1.1.1
|
||||
# github.com/buger/jsonparser v1.1.2
|
||||
## explicit; go 1.13
|
||||
github.com/buger/jsonparser
|
||||
# github.com/cloudfoundry/jibber_jabber v0.0.0-20151120183258-bcc4c8345a21
|
||||
|
||||
Reference in New Issue
Block a user