removed usage of package "unsafe" for Google App Engine compatibility

This commit is contained in:
Johnnie Kearse III 2018-04-09 15:35:14 -04:00
parent 9ed3f8e1a5
commit 58fc9b4bc4
1 changed files with 24 additions and 17 deletions

View File

@ -13,7 +13,6 @@ import (
"time"
"unicode/utf16"
"unicode/utf8"
"unsafe"
"github.com/tidwall/match"
)
@ -1292,7 +1291,7 @@ func parseArray(c *parseContext, i int, path string) (int, bool) {
c.value.Raw = val
c.value.Type = Number
c.value.Num = float64(h - 1)
c.calcd = true
// c.calcd = true
return i + 1, true
}
if len(multires) > 0 && !c.value.Exists() {
@ -1329,7 +1328,7 @@ func ForEachLine(json string, iterator func(line Result) bool) {
type parseContext struct {
json string
value Result
calcd bool
// calcd bool
lines bool
}
@ -1385,6 +1384,7 @@ func Get(json, path string) Result {
}
}
}
/*
if len(c.value.Raw) > 0 && !c.calcd {
jhdr := *(*reflect.StringHeader)(unsafe.Pointer(&json))
rhdr := *(*reflect.StringHeader)(unsafe.Pointer(&(c.value.Raw)))
@ -1393,8 +1393,11 @@ func Get(json, path string) Result {
c.value.Index = 0
}
}
*/
return c.value
}
/*
func fromBytesGet(result Result) Result {
// safely get the string headers
rawhi := *(*reflect.StringHeader)(unsafe.Pointer(&result.Raw))
@ -1432,10 +1435,13 @@ func fromBytesGet(result Result) Result {
}
return result
}
*/
// GetBytes searches json for the specified path.
// If working with bytes, this method preferred over Get(string(data), path)
func GetBytes(json []byte, path string) Result {
return Get(string(json), path)
/*
var result Result
if json != nil {
// unsafe cast to string
@ -1443,6 +1449,7 @@ func GetBytes(json []byte, path string) Result {
result = fromBytesGet(result)
}
return result
*/
}
// runeit returns the rune from the the \uXXXX