diff --git a/go.mod b/go.mod
index ba1f78a..bb28235 100644
--- a/go.mod
+++ b/go.mod
@@ -1,24 +1,36 @@
module github.com/locrep/maven
require (
- github.com/elazarl/goproxy v0.0.0-20181111060418-2ce16c963a8a // indirect
- github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3 // indirect
- github.com/gin-gonic/gin v1.3.0
+ github.com/gin-gonic/gin v1.7.0
github.com/go-sql-driver/mysql v1.4.1
- github.com/golang/protobuf v1.3.0 // indirect
- github.com/json-iterator/go v1.1.6 // indirect
- github.com/mattn/go-isatty v0.0.7 // indirect
- github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
- github.com/modern-go/reflect2 v1.0.1 // indirect
- github.com/moul/http2curl v1.0.0 // indirect
github.com/onsi/ginkgo v1.8.0
github.com/onsi/gomega v1.5.0
github.com/parnurzeal/gorequest v0.2.15
+ gopkg.in/yaml.v2 v2.2.8
+)
+
+require (
+ github.com/elazarl/goproxy v0.0.0-20181111060418-2ce16c963a8a // indirect
+ github.com/gin-contrib/sse v0.1.0 // indirect
+ github.com/go-playground/locales v0.13.0 // indirect
+ github.com/go-playground/universal-translator v0.17.0 // indirect
+ github.com/go-playground/validator/v10 v10.4.1 // indirect
+ github.com/golang/protobuf v1.3.3 // indirect
+ github.com/hpcloud/tail v1.0.0 // indirect
+ github.com/json-iterator/go v1.1.9 // indirect
+ github.com/leodido/go-urn v1.2.0 // indirect
+ github.com/mattn/go-isatty v0.0.12 // indirect
+ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
+ github.com/modern-go/reflect2 v1.0.1 // indirect
+ github.com/moul/http2curl v1.0.0 // indirect
github.com/pkg/errors v0.8.1 // indirect
github.com/smartystreets/goconvey v0.0.0-20190306220146-200a235640ff // indirect
- github.com/stretchr/testify v1.3.0 // indirect
- github.com/ugorji/go/codec v0.0.0-20190309163734-c4a1c341dc93 // indirect
- gopkg.in/go-playground/assert.v1 v1.2.1 // indirect
- gopkg.in/go-playground/validator.v8 v8.18.2 // indirect
- gopkg.in/yaml.v2 v2.2.2
+ github.com/ugorji/go/codec v1.1.7 // indirect
+ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 // indirect
+ golang.org/x/net v0.0.0-20190603091049-60506f45cf65 // indirect
+ golang.org/x/sys v0.0.0-20200116001909-b77594299b42 // indirect
+ golang.org/x/text v0.3.2 // indirect
+ google.golang.org/appengine v1.6.7 // indirect
+ gopkg.in/fsnotify.v1 v1.4.7 // indirect
+ gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
)
diff --git a/go.sum b/go.sum
index 3b12ee6..2dd104c 100644
--- a/go.sum
+++ b/go.sum
@@ -1,31 +1,45 @@
-github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
+github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/elazarl/goproxy v0.0.0-20181111060418-2ce16c963a8a h1:A4wNiqeKqU56ZhtnzJCTyPZ1+cyu8jKtIchQ3TtxHgw=
github.com/elazarl/goproxy v0.0.0-20181111060418-2ce16c963a8a/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc=
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
-github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3 h1:t8FVkw33L+wilf2QiWkw0UV77qRpcH/JHPKGpKa2E8g=
-github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3/go.mod h1:VJ0WA2NBN22VlZ2dKZQPAPnyWw5XTlK1KymzLKsr59s=
-github.com/gin-gonic/gin v1.3.0 h1:kCmZyPklC0gVdL728E6Aj20uYBJV93nj/TkwBTKhFbs=
-github.com/gin-gonic/gin v1.3.0/go.mod h1:7cKuhb5qV2ggCFctp2fJQ+ErvciLZrIeoOSOm6mUr7Y=
+github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
+github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
+github.com/gin-gonic/gin v1.7.0 h1:jGB9xAJQ12AIGNB4HguylppmDK1Am9ppF7XnGXXJuoU=
+github.com/gin-gonic/gin v1.7.0/go.mod h1:jD2toBW3GZUr5UMcdrwQA10I7RuaFOl/SGeDjXkfUtY=
+github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A=
+github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
+github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q=
+github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8=
+github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no=
+github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA=
+github.com/go-playground/validator/v10 v10.4.1 h1:pH2c5ADXtd66mxoE0Zm9SUhxE20r7aM3F26W0hOn+GE=
+github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4=
github.com/go-sql-driver/mysql v1.4.1 h1:g24URVg0OFbNUTx9qqY1IRZ9D9z3iPyi5zKhQZpNwpA=
github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
-github.com/golang/protobuf v1.3.0 h1:kbxbvI4Un1LUWKxufD+BiE6AEExYYgkQLQmLFqA1LFk=
-github.com/golang/protobuf v1.3.0/go.mod h1:Qd/q+1AKNOZr9uGQzbzCmRO6sUih6GTPZv6a1/R87v0=
+github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
+github.com/golang/protobuf v1.3.3 h1:gyjaxf+svBWX08ZjK86iN9geUJF0H6gp2IRKX6Nf6/I=
+github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
+github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
-github.com/json-iterator/go v1.1.6 h1:MrUvLMLTMxbqFJ9kzlvat/rYZqZnW3u4wkLzWTaFwKs=
-github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
+github.com/json-iterator/go v1.1.9 h1:9yzud/Ht36ygwatGx56VwCZtlI/2AD15T1X2sjSuGns=
+github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
-github.com/locrep/locrep v0.0.0-20190627195205-5d0af5972e9e h1:2kqj0Kl22KUelypua3Kn93b5+TZBsD1uo0IjbQHy/rc=
-github.com/mattn/go-isatty v0.0.7 h1:UvyT9uN+3r7yLEYSlJsbQGdsaB/a0DlgWP3pql6iwOc=
-github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
+github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y=
+github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
+github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
+github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
+github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
+github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/moul/http2curl v1.0.0 h1:dRMWoAtb+ePxMlLkrCbAqh4TlPHXvoGUSQ323/9Zahs=
@@ -46,32 +60,38 @@ github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1
github.com/smartystreets/goconvey v0.0.0-20190306220146-200a235640ff h1:86HlEv0yBCry9syNuylzqznKXDK11p6D0DT596yNMys=
github.com/smartystreets/goconvey v0.0.0-20190306220146-200a235640ff/go.mod h1:KSQcGKpxUMHk3nbYzs/tIBAM2iDooCn0BmttHOJEbLs=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
-github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
-github.com/ugorji/go v1.1.2 h1:JON3E2/GPW2iDNGoSAusl1KDf5TRQ8k8q7Tp097pZGs=
-github.com/ugorji/go v1.1.2/go.mod h1:hnLbHMwcvSihnDhEfx2/BzKp2xb0Y+ErdfYcrs9tkJQ=
-github.com/ugorji/go/codec v0.0.0-20190309163734-c4a1c341dc93 h1:JnDJ9gMf6CfErtoOXnghtY5hhMuDtW4tUBaWSBrqvKs=
-github.com/ugorji/go/codec v0.0.0-20190309163734-c4a1c341dc93/go.mod h1:iT03XoTwV7xq/+UGwKO3UbC1nNNlopQiY61beSdrtOA=
-golang.org/x/net v0.0.0-20180906233101-161cd47e91fd h1:nTDtHvHSdCn1m6ITfMRqtOd/9+7a3s8RBNOZ3eYZzJA=
+github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
+github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
+github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
+github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs=
+github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
+golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
+golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI=
+golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
-golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f h1:wMNYb4v58l5UBM7MYRLPG6ZhfOqbKu7X5eyFl8ZhKvA=
+golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
+golang.org/x/net v0.0.0-20190603091049-60506f45cf65 h1:+rhAzEzT3f4JtomfC371qB+0Ola2caSKcY69NUBZrRQ=
+golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
-golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223 h1:DH4skfRX4EBpamg7iV4ZlCpblAHI6s6TDM39bFZumv8=
-golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
-golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
+golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200116001909-b77594299b42 h1:vEOn+mP2zCOVzKckCZy6YsCtDblrpj/w7B9nxGNELpg=
+golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
-google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
+golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
+golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
+golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c=
+google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
-gopkg.in/go-playground/assert.v1 v1.2.1 h1:xoYuJVE7KT85PYWrN730RguIQO0ePzVRfFMXadIrXTM=
-gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE=
-gopkg.in/go-playground/validator.v8 v8.18.2 h1:lFB4DoMU6B626w8ny76MV7VX6W2VHct2GVOI3xgiMrQ=
-gopkg.in/go-playground/validator.v8 v8.18.2/go.mod h1:RX2a/7Ha8BgOhfk7j780h4/u/RRjR0eouCJSH80/M2Y=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
-gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
+gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
diff --git a/vendor/github.com/gin-gonic/gin/.gitignore b/vendor/github.com/gin-gonic/gin/.gitignore
index 14dc8f2..bdd50c9 100644
--- a/vendor/github.com/gin-gonic/gin/.gitignore
+++ b/vendor/github.com/gin-gonic/gin/.gitignore
@@ -3,3 +3,5 @@ vendor/*
coverage.out
count.out
test
+profile.out
+tmp.out
diff --git a/vendor/github.com/gin-gonic/gin/.travis.yml b/vendor/github.com/gin-gonic/gin/.travis.yml
index e910156..8ebae71 100644
--- a/vendor/github.com/gin-gonic/gin/.travis.yml
+++ b/vendor/github.com/gin-gonic/gin/.travis.yml
@@ -1,25 +1,40 @@
language: go
-sudo: false
-go:
- - 1.6.x
- - 1.7.x
- - 1.8.x
- - 1.9.x
- - 1.10.x
- - master
+
+matrix:
+ fast_finish: true
+ include:
+ - go: 1.12.x
+ env: GO111MODULE=on
+ - go: 1.13.x
+ - go: 1.13.x
+ env:
+ - TESTTAGS=nomsgpack
+ - go: 1.14.x
+ - go: 1.14.x
+ env:
+ - TESTTAGS=nomsgpack
+ - go: 1.15.x
+ - go: 1.15.x
+ env:
+ - TESTTAGS=nomsgpack
+ - go: master
git:
depth: 10
+before_install:
+ - if [[ "${GO111MODULE}" = "on" ]]; then mkdir "${HOME}/go"; export GOPATH="${HOME}/go"; fi
+
install:
- - make install
+ - if [[ "${GO111MODULE}" = "on" ]]; then go mod download; fi
+ - if [[ "${GO111MODULE}" = "on" ]]; then export PATH="${GOPATH}/bin:${GOROOT}/bin:${PATH}"; fi
+ - if [[ "${GO111MODULE}" = "on" ]]; then make tools; fi
go_import_path: github.com/gin-gonic/gin
script:
- make vet
- make fmt-check
- - make embedmd
- make misspell-check
- make test
diff --git a/vendor/github.com/gin-gonic/gin/AUTHORS.md b/vendor/github.com/gin-gonic/gin/AUTHORS.md
index dda19bc..c634e6b 100644
--- a/vendor/github.com/gin-gonic/gin/AUTHORS.md
+++ b/vendor/github.com/gin-gonic/gin/AUTHORS.md
@@ -156,7 +156,7 @@ People and companies, who have contributed, in alphabetical order.
- Fix variadic parameter in the flexible render API
- Fix Corrupted plain render
- Add Pluggable View Renderer Example
-
+
**@msemenistyi (Mykyta Semenistyi)**
- update Readme.md. Add code to String method
@@ -190,6 +190,8 @@ People and companies, who have contributed, in alphabetical order.
**@rogierlommers (Rogier Lommers)**
- Add updated static serve example
+**@rw-access (Ross Wolf)**
+- Added support to mix exact and param routes
**@se77en (Damon Zhao)**
- Improve color logging
diff --git a/vendor/github.com/gin-gonic/gin/BENCHMARKS.md b/vendor/github.com/gin-gonic/gin/BENCHMARKS.md
index 9a7df86..c11ee99 100644
--- a/vendor/github.com/gin-gonic/gin/BENCHMARKS.md
+++ b/vendor/github.com/gin-gonic/gin/BENCHMARKS.md
@@ -1,604 +1,666 @@
-## Benchmark System
+# Benchmark System
-**VM HOST:** DigitalOcean
-**Machine:** 4 CPU, 8 GB RAM. Ubuntu 16.04.2 x64
-**Date:** July 19th, 2017
-**Go Version:** 1.8.3 linux/amd64
-**Source:** [Go HTTP Router Benchmark](https://github.com/julienschmidt/go-http-routing-benchmark)
+**VM HOST:** Travis
+**Machine:** Ubuntu 16.04.6 LTS x64
+**Date:** May 04th, 2020
+**Version:** Gin v1.6.3
+**Go Version:** 1.14.2 linux/amd64
+**Source:** [Go HTTP Router Benchmark](https://github.com/gin-gonic/go-http-routing-benchmark)
+**Result:** [See the gist](https://gist.github.com/appleboy/b5f2ecfaf50824ae9c64dcfb9165ae5e) or [Travis result](https://travis-ci.org/github/gin-gonic/go-http-routing-benchmark/jobs/682947061)
## Static Routes: 157
-```
-Gin: 30512 Bytes
+```sh
+Gin: 34936 Bytes
-HttpServeMux: 17344 Bytes
-Ace: 30080 Bytes
-Bear: 30472 Bytes
-Beego: 96408 Bytes
-Bone: 37904 Bytes
-Denco: 10464 Bytes
-Echo: 73680 Bytes
-GocraftWeb: 55720 Bytes
-Goji: 27200 Bytes
-Gojiv2: 104464 Bytes
-GoJsonRest: 136472 Bytes
-GoRestful: 914904 Bytes
-GorillaMux: 675568 Bytes
-HttpRouter: 21128 Bytes
-HttpTreeMux: 73448 Bytes
-Kocha: 115072 Bytes
-LARS: 30120 Bytes
-Macaron: 37984 Bytes
-Martini: 310832 Bytes
-Pat: 20464 Bytes
-Possum: 91328 Bytes
-R2router: 23712 Bytes
-Rivet: 23880 Bytes
-Tango: 28008 Bytes
-TigerTonic: 80368 Bytes
-Traffic: 626480 Bytes
-Vulcan: 369064 Bytes
+HttpServeMux: 14512 Bytes
+Ace: 30680 Bytes
+Aero: 34536 Bytes
+Bear: 30456 Bytes
+Beego: 98456 Bytes
+Bone: 40224 Bytes
+Chi: 83608 Bytes
+Denco: 10216 Bytes
+Echo: 80328 Bytes
+GocraftWeb: 55288 Bytes
+Goji: 29744 Bytes
+Gojiv2: 105840 Bytes
+GoJsonRest: 137496 Bytes
+GoRestful: 816936 Bytes
+GorillaMux: 585632 Bytes
+GowwwRouter: 24968 Bytes
+HttpRouter: 21712 Bytes
+HttpTreeMux: 73448 Bytes
+Kocha: 115472 Bytes
+LARS: 30640 Bytes
+Macaron: 38592 Bytes
+Martini: 310864 Bytes
+Pat: 19696 Bytes
+Possum: 89920 Bytes
+R2router: 23712 Bytes
+Rivet: 24608 Bytes
+Tango: 28264 Bytes
+TigerTonic: 78768 Bytes
+Traffic: 538976 Bytes
+Vulcan: 369960 Bytes
```
## GithubAPI Routes: 203
-```
-Gin: 52672 Bytes
+```sh
+Gin: 58512 Bytes
-Ace: 48992 Bytes
-Bear: 161592 Bytes
-Beego: 147992 Bytes
-Bone: 97728 Bytes
-Denco: 36440 Bytes
-Echo: 95672 Bytes
-GocraftWeb: 95640 Bytes
-Goji: 86088 Bytes
-Gojiv2: 144392 Bytes
-GoJsonRest: 134648 Bytes
-GoRestful: 1410760 Bytes
-GorillaMux: 1509488 Bytes
-HttpRouter: 37464 Bytes
-HttpTreeMux: 78800 Bytes
-Kocha: 785408 Bytes
-LARS: 49032 Bytes
-Macaron: 132712 Bytes
-Martini: 564352 Bytes
-Pat: 21200 Bytes
-Possum: 83888 Bytes
-R2router: 47104 Bytes
-Rivet: 42840 Bytes
-Tango: 54584 Bytes
-TigerTonic: 96384 Bytes
-Traffic: 1061920 Bytes
-Vulcan: 465296 Bytes
+Ace: 48688 Bytes
+Aero: 318568 Bytes
+Bear: 84248 Bytes
+Beego: 150936 Bytes
+Bone: 100976 Bytes
+Chi: 95112 Bytes
+Denco: 36736 Bytes
+Echo: 100296 Bytes
+GocraftWeb: 95432 Bytes
+Goji: 49680 Bytes
+Gojiv2: 104704 Bytes
+GoJsonRest: 141976 Bytes
+GoRestful: 1241656 Bytes
+GorillaMux: 1322784 Bytes
+GowwwRouter: 80008 Bytes
+HttpRouter: 37144 Bytes
+HttpTreeMux: 78800 Bytes
+Kocha: 785120 Bytes
+LARS: 48600 Bytes
+Macaron: 92784 Bytes
+Martini: 485264 Bytes
+Pat: 21200 Bytes
+Possum: 85312 Bytes
+R2router: 47104 Bytes
+Rivet: 42840 Bytes
+Tango: 54840 Bytes
+TigerTonic: 95264 Bytes
+Traffic: 921744 Bytes
+Vulcan: 425992 Bytes
```
## GPlusAPI Routes: 13
-```
-Gin: 3968 Bytes
+```sh
+Gin: 4384 Bytes
-Ace: 3600 Bytes
-Bear: 7112 Bytes
-Beego: 10048 Bytes
-Bone: 6480 Bytes
-Denco: 3256 Bytes
-Echo: 9000 Bytes
-GocraftWeb: 7496 Bytes
-Goji: 2912 Bytes
-Gojiv2: 7376 Bytes
-GoJsonRest: 11544 Bytes
-GoRestful: 88776 Bytes
-GorillaMux: 71488 Bytes
-HttpRouter: 2712 Bytes
-HttpTreeMux: 7440 Bytes
-Kocha: 128880 Bytes
-LARS: 3640 Bytes
-Macaron: 8656 Bytes
-Martini: 23936 Bytes
-Pat: 1856 Bytes
-Possum: 7248 Bytes
-R2router: 3928 Bytes
-Rivet: 3064 Bytes
-Tango: 4912 Bytes
-TigerTonic: 9408 Bytes
-Traffic: 49472 Bytes
-Vulcan: 25496 Bytes
+Ace: 3712 Bytes
+Aero: 26056 Bytes
+Bear: 7112 Bytes
+Beego: 10272 Bytes
+Bone: 6688 Bytes
+Chi: 8024 Bytes
+Denco: 3264 Bytes
+Echo: 9688 Bytes
+GocraftWeb: 7496 Bytes
+Goji: 3152 Bytes
+Gojiv2: 7376 Bytes
+GoJsonRest: 11400 Bytes
+GoRestful: 74328 Bytes
+GorillaMux: 66208 Bytes
+GowwwRouter: 5744 Bytes
+HttpRouter: 2808 Bytes
+HttpTreeMux: 7440 Bytes
+Kocha: 128880 Bytes
+LARS: 3656 Bytes
+Macaron: 8656 Bytes
+Martini: 23920 Bytes
+Pat: 1856 Bytes
+Possum: 7248 Bytes
+R2router: 3928 Bytes
+Rivet: 3064 Bytes
+Tango: 5168 Bytes
+TigerTonic: 9408 Bytes
+Traffic: 46400 Bytes
+Vulcan: 25544 Bytes
```
## ParseAPI Routes: 26
-```
-Gin: 6928 Bytes
+```sh
+Gin: 7776 Bytes
-Ace: 6592 Bytes
-Bear: 12320 Bytes
-Beego: 18960 Bytes
-Bone: 11024 Bytes
-Denco: 4184 Bytes
-Echo: 11168 Bytes
-GocraftWeb: 12800 Bytes
-Goji: 5232 Bytes
-Gojiv2: 14464 Bytes
-GoJsonRest: 14216 Bytes
-GoRestful: 127368 Bytes
-GorillaMux: 123016 Bytes
-HttpRouter: 4976 Bytes
-HttpTreeMux: 7848 Bytes
-Kocha: 181712 Bytes
-LARS: 6632 Bytes
-Macaron: 13648 Bytes
-Martini: 45952 Bytes
-Pat: 2560 Bytes
-Possum: 9200 Bytes
-R2router: 7056 Bytes
-Rivet: 5680 Bytes
-Tango: 8664 Bytes
-TigerTonic: 9840 Bytes
-Traffic: 93480 Bytes
-Vulcan: 44504 Bytes
+Ace: 6704 Bytes
+Aero: 28488 Bytes
+Bear: 12320 Bytes
+Beego: 19280 Bytes
+Bone: 11440 Bytes
+Chi: 9744 Bytes
+Denco: 4192 Bytes
+Echo: 11664 Bytes
+GocraftWeb: 12800 Bytes
+Goji: 5680 Bytes
+Gojiv2: 14464 Bytes
+GoJsonRest: 14072 Bytes
+GoRestful: 116264 Bytes
+GorillaMux: 105880 Bytes
+GowwwRouter: 9344 Bytes
+HttpRouter: 5072 Bytes
+HttpTreeMux: 7848 Bytes
+Kocha: 181712 Bytes
+LARS: 6632 Bytes
+Macaron: 13648 Bytes
+Martini: 45888 Bytes
+Pat: 2560 Bytes
+Possum: 9200 Bytes
+R2router: 7056 Bytes
+Rivet: 5680 Bytes
+Tango: 8920 Bytes
+TigerTonic: 9840 Bytes
+Traffic: 79096 Bytes
+Vulcan: 44504 Bytes
```
## Static Routes
-```
-BenchmarkGin_StaticAll 50000 34506 ns/op 0 B/op 0 allocs/op
+```sh
+BenchmarkGin_StaticAll 62169 19319 ns/op 0 B/op 0 allocs/op
-BenchmarkAce_StaticAll 30000 49657 ns/op 0 B/op 0 allocs/op
-BenchmarkHttpServeMux_StaticAll 2000 1183737 ns/op 96 B/op 8 allocs/op
-BenchmarkBeego_StaticAll 5000 412621 ns/op 57776 B/op 628 allocs/op
-BenchmarkBear_StaticAll 10000 149242 ns/op 20336 B/op 461 allocs/op
-BenchmarkBone_StaticAll 10000 118583 ns/op 0 B/op 0 allocs/op
-BenchmarkDenco_StaticAll 100000 13247 ns/op 0 B/op 0 allocs/op
-BenchmarkEcho_StaticAll 20000 79914 ns/op 5024 B/op 157 allocs/op
-BenchmarkGocraftWeb_StaticAll 10000 211823 ns/op 46440 B/op 785 allocs/op
-BenchmarkGoji_StaticAll 10000 109390 ns/op 0 B/op 0 allocs/op
-BenchmarkGojiv2_StaticAll 3000 415533 ns/op 145696 B/op 1099 allocs/op
-BenchmarkGoJsonRest_StaticAll 5000 364403 ns/op 51653 B/op 1727 allocs/op
-BenchmarkGoRestful_StaticAll 500 2578579 ns/op 314936 B/op 3144 allocs/op
-BenchmarkGorillaMux_StaticAll 500 2704856 ns/op 115648 B/op 1578 allocs/op
-BenchmarkHttpRouter_StaticAll 100000 18541 ns/op 0 B/op 0 allocs/op
-BenchmarkHttpTreeMux_StaticAll 100000 22332 ns/op 0 B/op 0 allocs/op
-BenchmarkKocha_StaticAll 50000 31176 ns/op 0 B/op 0 allocs/op
-BenchmarkLARS_StaticAll 50000 40840 ns/op 0 B/op 0 allocs/op
-BenchmarkMacaron_StaticAll 5000 517656 ns/op 120576 B/op 1413 allocs/op
-BenchmarkMartini_StaticAll 300 4462289 ns/op 125442 B/op 1717 allocs/op
-BenchmarkPat_StaticAll 500 2157275 ns/op 533904 B/op 11123 allocs/op
-BenchmarkPossum_StaticAll 10000 254701 ns/op 65312 B/op 471 allocs/op
-BenchmarkR2router_StaticAll 10000 133956 ns/op 22608 B/op 628 allocs/op
-BenchmarkRivet_StaticAll 30000 46812 ns/op 0 B/op 0 allocs/op
-BenchmarkTango_StaticAll 5000 390613 ns/op 39225 B/op 1256 allocs/op
-BenchmarkTigerTonic_StaticAll 20000 88060 ns/op 7504 B/op 157 allocs/op
-BenchmarkTraffic_StaticAll 500 2910236 ns/op 729736 B/op 14287 allocs/op
-BenchmarkVulcan_StaticAll 5000 277366 ns/op 15386 B/op 471 allocs/op
+BenchmarkAce_StaticAll 65428 18313 ns/op 0 B/op 0 allocs/op
+BenchmarkAero_StaticAll 121132 9632 ns/op 0 B/op 0 allocs/op
+BenchmarkHttpServeMux_StaticAll 52626 22758 ns/op 0 B/op 0 allocs/op
+BenchmarkBeego_StaticAll 9962 179058 ns/op 55264 B/op 471 allocs/op
+BenchmarkBear_StaticAll 14894 80966 ns/op 20272 B/op 469 allocs/op
+BenchmarkBone_StaticAll 18718 64065 ns/op 0 B/op 0 allocs/op
+BenchmarkChi_StaticAll 10000 149827 ns/op 67824 B/op 471 allocs/op
+BenchmarkDenco_StaticAll 211393 5680 ns/op 0 B/op 0 allocs/op
+BenchmarkEcho_StaticAll 49341 24343 ns/op 0 B/op 0 allocs/op
+BenchmarkGocraftWeb_StaticAll 10000 126209 ns/op 46312 B/op 785 allocs/op
+BenchmarkGoji_StaticAll 27956 43174 ns/op 0 B/op 0 allocs/op
+BenchmarkGojiv2_StaticAll 3430 370718 ns/op 205984 B/op 1570 allocs/op
+BenchmarkGoJsonRest_StaticAll 9134 188888 ns/op 51653 B/op 1727 allocs/op
+BenchmarkGoRestful_StaticAll 706 1703330 ns/op 613280 B/op 2053 allocs/op
+BenchmarkGorillaMux_StaticAll 1268 924083 ns/op 153233 B/op 1413 allocs/op
+BenchmarkGowwwRouter_StaticAll 63374 18935 ns/op 0 B/op 0 allocs/op
+BenchmarkHttpRouter_StaticAll 109938 10902 ns/op 0 B/op 0 allocs/op
+BenchmarkHttpTreeMux_StaticAll 109166 10861 ns/op 0 B/op 0 allocs/op
+BenchmarkKocha_StaticAll 92258 12992 ns/op 0 B/op 0 allocs/op
+BenchmarkLARS_StaticAll 65200 18387 ns/op 0 B/op 0 allocs/op
+BenchmarkMacaron_StaticAll 5671 291501 ns/op 115553 B/op 1256 allocs/op
+BenchmarkMartini_StaticAll 807 1460498 ns/op 125444 B/op 1717 allocs/op
+BenchmarkPat_StaticAll 513 2342396 ns/op 602832 B/op 12559 allocs/op
+BenchmarkPossum_StaticAll 10000 128270 ns/op 65312 B/op 471 allocs/op
+BenchmarkR2router_StaticAll 16726 71760 ns/op 22608 B/op 628 allocs/op
+BenchmarkRivet_StaticAll 41722 28723 ns/op 0 B/op 0 allocs/op
+BenchmarkTango_StaticAll 7606 205082 ns/op 39209 B/op 1256 allocs/op
+BenchmarkTigerTonic_StaticAll 26247 45806 ns/op 7376 B/op 157 allocs/op
+BenchmarkTraffic_StaticAll 550 2284518 ns/op 754864 B/op 14601 allocs/op
+BenchmarkVulcan_StaticAll 10000 131343 ns/op 15386 B/op 471 allocs/op
```
## Micro Benchmarks
-```
-BenchmarkGin_Param 20000000 113 ns/op 0 B/op 0 allocs/op
+```sh
+BenchmarkGin_Param 18785022 63.9 ns/op 0 B/op 0 allocs/op
-BenchmarkAce_Param 5000000 375 ns/op 32 B/op 1 allocs/op
-BenchmarkBear_Param 1000000 1709 ns/op 456 B/op 5 allocs/op
-BenchmarkBeego_Param 1000000 2484 ns/op 368 B/op 4 allocs/op
-BenchmarkBone_Param 1000000 2391 ns/op 688 B/op 5 allocs/op
-BenchmarkDenco_Param 10000000 240 ns/op 32 B/op 1 allocs/op
-BenchmarkEcho_Param 5000000 366 ns/op 32 B/op 1 allocs/op
-BenchmarkGocraftWeb_Param 1000000 2343 ns/op 648 B/op 8 allocs/op
-BenchmarkGoji_Param 1000000 1197 ns/op 336 B/op 2 allocs/op
-BenchmarkGojiv2_Param 1000000 2771 ns/op 944 B/op 8 allocs/op
-BenchmarkGoJsonRest_Param 1000000 2993 ns/op 649 B/op 13 allocs/op
-BenchmarkGoRestful_Param 200000 8860 ns/op 2296 B/op 21 allocs/op
-BenchmarkGorillaMux_Param 500000 4461 ns/op 1056 B/op 11 allocs/op
-BenchmarkHttpRouter_Param 10000000 175 ns/op 32 B/op 1 allocs/op
-BenchmarkHttpTreeMux_Param 1000000 1167 ns/op 352 B/op 3 allocs/op
-BenchmarkKocha_Param 3000000 429 ns/op 56 B/op 3 allocs/op
-BenchmarkLARS_Param 10000000 134 ns/op 0 B/op 0 allocs/op
-BenchmarkMacaron_Param 500000 4635 ns/op 1056 B/op 10 allocs/op
-BenchmarkMartini_Param 200000 9933 ns/op 1072 B/op 10 allocs/op
-BenchmarkPat_Param 1000000 2929 ns/op 648 B/op 12 allocs/op
-BenchmarkPossum_Param 1000000 2503 ns/op 560 B/op 6 allocs/op
-BenchmarkR2router_Param 1000000 1507 ns/op 432 B/op 5 allocs/op
-BenchmarkRivet_Param 5000000 297 ns/op 48 B/op 1 allocs/op
-BenchmarkTango_Param 1000000 1862 ns/op 248 B/op 8 allocs/op
-BenchmarkTigerTonic_Param 500000 5660 ns/op 992 B/op 17 allocs/op
-BenchmarkTraffic_Param 200000 8408 ns/op 1960 B/op 21 allocs/op
-BenchmarkVulcan_Param 2000000 963 ns/op 98 B/op 3 allocs/op
-BenchmarkAce_Param5 2000000 740 ns/op 160 B/op 1 allocs/op
-BenchmarkBear_Param5 1000000 2777 ns/op 501 B/op 5 allocs/op
-BenchmarkBeego_Param5 1000000 3740 ns/op 368 B/op 4 allocs/op
-BenchmarkBone_Param5 1000000 2950 ns/op 736 B/op 5 allocs/op
-BenchmarkDenco_Param5 2000000 644 ns/op 160 B/op 1 allocs/op
-BenchmarkEcho_Param5 3000000 558 ns/op 32 B/op 1 allocs/op
-BenchmarkGin_Param5 10000000 198 ns/op 0 B/op 0 allocs/op
-BenchmarkGocraftWeb_Param5 500000 3870 ns/op 920 B/op 11 allocs/op
-BenchmarkGoji_Param5 1000000 1746 ns/op 336 B/op 2 allocs/op
-BenchmarkGojiv2_Param5 1000000 3214 ns/op 1008 B/op 8 allocs/op
-BenchmarkGoJsonRest_Param5 500000 5509 ns/op 1097 B/op 16 allocs/op
-BenchmarkGoRestful_Param5 200000 11232 ns/op 2392 B/op 21 allocs/op
-BenchmarkGorillaMux_Param5 300000 7777 ns/op 1184 B/op 11 allocs/op
-BenchmarkHttpRouter_Param5 3000000 631 ns/op 160 B/op 1 allocs/op
-BenchmarkHttpTreeMux_Param5 1000000 2800 ns/op 576 B/op 6 allocs/op
-BenchmarkKocha_Param5 1000000 2053 ns/op 440 B/op 10 allocs/op
-BenchmarkLARS_Param5 10000000 232 ns/op 0 B/op 0 allocs/op
-BenchmarkMacaron_Param5 500000 5888 ns/op 1056 B/op 10 allocs/op
-BenchmarkMartini_Param5 200000 12807 ns/op 1232 B/op 11 allocs/op
-BenchmarkPat_Param5 300000 7320 ns/op 964 B/op 32 allocs/op
-BenchmarkPossum_Param5 1000000 2495 ns/op 560 B/op 6 allocs/op
-BenchmarkR2router_Param5 1000000 1844 ns/op 432 B/op 5 allocs/op
-BenchmarkRivet_Param5 2000000 935 ns/op 240 B/op 1 allocs/op
-BenchmarkTango_Param5 1000000 2327 ns/op 360 B/op 8 allocs/op
-BenchmarkTigerTonic_Param5 100000 18514 ns/op 2551 B/op 43 allocs/op
-BenchmarkTraffic_Param5 200000 11997 ns/op 2248 B/op 25 allocs/op
-BenchmarkVulcan_Param5 1000000 1333 ns/op 98 B/op 3 allocs/op
-BenchmarkAce_Param20 1000000 2031 ns/op 640 B/op 1 allocs/op
-BenchmarkBear_Param20 200000 7285 ns/op 1664 B/op 5 allocs/op
-BenchmarkBeego_Param20 300000 6224 ns/op 368 B/op 4 allocs/op
-BenchmarkBone_Param20 200000 8023 ns/op 1903 B/op 5 allocs/op
-BenchmarkDenco_Param20 1000000 2262 ns/op 640 B/op 1 allocs/op
-BenchmarkEcho_Param20 1000000 1387 ns/op 32 B/op 1 allocs/op
-BenchmarkGin_Param20 3000000 503 ns/op 0 B/op 0 allocs/op
-BenchmarkGocraftWeb_Param20 100000 14408 ns/op 3795 B/op 15 allocs/op
-BenchmarkGoji_Param20 500000 5272 ns/op 1247 B/op 2 allocs/op
-BenchmarkGojiv2_Param20 1000000 4163 ns/op 1248 B/op 8 allocs/op
-BenchmarkGoJsonRest_Param20 100000 17866 ns/op 4485 B/op 20 allocs/op
-BenchmarkGoRestful_Param20 100000 21022 ns/op 4724 B/op 23 allocs/op
-BenchmarkGorillaMux_Param20 100000 17055 ns/op 3547 B/op 13 allocs/op
-BenchmarkHttpRouter_Param20 1000000 1748 ns/op 640 B/op 1 allocs/op
-BenchmarkHttpTreeMux_Param20 200000 12246 ns/op 3196 B/op 10 allocs/op
-BenchmarkKocha_Param20 300000 6861 ns/op 1808 B/op 27 allocs/op
-BenchmarkLARS_Param20 3000000 526 ns/op 0 B/op 0 allocs/op
-BenchmarkMacaron_Param20 100000 13069 ns/op 2906 B/op 12 allocs/op
-BenchmarkMartini_Param20 100000 23602 ns/op 3597 B/op 13 allocs/op
-BenchmarkPat_Param20 50000 32143 ns/op 4688 B/op 111 allocs/op
-BenchmarkPossum_Param20 1000000 2396 ns/op 560 B/op 6 allocs/op
-BenchmarkR2router_Param20 200000 8907 ns/op 2283 B/op 7 allocs/op
-BenchmarkRivet_Param20 1000000 3280 ns/op 1024 B/op 1 allocs/op
-BenchmarkTango_Param20 500000 4640 ns/op 856 B/op 8 allocs/op
-BenchmarkTigerTonic_Param20 20000 67581 ns/op 10532 B/op 138 allocs/op
-BenchmarkTraffic_Param20 50000 40313 ns/op 7941 B/op 45 allocs/op
-BenchmarkVulcan_Param20 1000000 2264 ns/op 98 B/op 3 allocs/op
-BenchmarkAce_ParamWrite 3000000 532 ns/op 40 B/op 2 allocs/op
-BenchmarkBear_ParamWrite 1000000 1778 ns/op 456 B/op 5 allocs/op
-BenchmarkBeego_ParamWrite 1000000 2596 ns/op 376 B/op 5 allocs/op
-BenchmarkBone_ParamWrite 1000000 2519 ns/op 688 B/op 5 allocs/op
-BenchmarkDenco_ParamWrite 5000000 411 ns/op 32 B/op 1 allocs/op
-BenchmarkEcho_ParamWrite 2000000 718 ns/op 40 B/op 2 allocs/op
-BenchmarkGin_ParamWrite 5000000 283 ns/op 0 B/op 0 allocs/op
-BenchmarkGocraftWeb_ParamWrite 1000000 2561 ns/op 656 B/op 9 allocs/op
-BenchmarkGoji_ParamWrite 1000000 1378 ns/op 336 B/op 2 allocs/op
-BenchmarkGojiv2_ParamWrite 1000000 3128 ns/op 976 B/op 10 allocs/op
-BenchmarkGoJsonRest_ParamWrite 500000 4446 ns/op 1128 B/op 18 allocs/op
-BenchmarkGoRestful_ParamWrite 200000 10291 ns/op 2304 B/op 22 allocs/op
-BenchmarkGorillaMux_ParamWrite 500000 5153 ns/op 1064 B/op 12 allocs/op
-BenchmarkHttpRouter_ParamWrite 5000000 263 ns/op 32 B/op 1 allocs/op
-BenchmarkHttpTreeMux_ParamWrite 1000000 1351 ns/op 352 B/op 3 allocs/op
-BenchmarkKocha_ParamWrite 3000000 538 ns/op 56 B/op 3 allocs/op
-BenchmarkLARS_ParamWrite 5000000 316 ns/op 0 B/op 0 allocs/op
-BenchmarkMacaron_ParamWrite 500000 5756 ns/op 1160 B/op 14 allocs/op
-BenchmarkMartini_ParamWrite 200000 13097 ns/op 1176 B/op 14 allocs/op
-BenchmarkPat_ParamWrite 500000 4954 ns/op 1072 B/op 17 allocs/op
-BenchmarkPossum_ParamWrite 1000000 2499 ns/op 560 B/op 6 allocs/op
-BenchmarkR2router_ParamWrite 1000000 1531 ns/op 432 B/op 5 allocs/op
-BenchmarkRivet_ParamWrite 3000000 570 ns/op 112 B/op 2 allocs/op
-BenchmarkTango_ParamWrite 2000000 957 ns/op 136 B/op 4 allocs/op
-BenchmarkTigerTonic_ParamWrite 200000 7025 ns/op 1424 B/op 23 allocs/op
-BenchmarkTraffic_ParamWrite 200000 10112 ns/op 2384 B/op 25 allocs/op
-BenchmarkVulcan_ParamWrite 1000000 1006 ns/op 98 B/op 3 allocs/op
+BenchmarkAce_Param 14689765 81.5 ns/op 0 B/op 0 allocs/op
+BenchmarkAero_Param 23094770 51.2 ns/op 0 B/op 0 allocs/op
+BenchmarkBear_Param 1417045 845 ns/op 456 B/op 5 allocs/op
+BenchmarkBeego_Param 1000000 1080 ns/op 352 B/op 3 allocs/op
+BenchmarkBone_Param 1000000 1463 ns/op 816 B/op 6 allocs/op
+BenchmarkChi_Param 1378756 885 ns/op 432 B/op 3 allocs/op
+BenchmarkDenco_Param 8557899 143 ns/op 32 B/op 1 allocs/op
+BenchmarkEcho_Param 16433347 75.5 ns/op 0 B/op 0 allocs/op
+BenchmarkGocraftWeb_Param 1000000 1218 ns/op 648 B/op 8 allocs/op
+BenchmarkGoji_Param 1921248 617 ns/op 336 B/op 2 allocs/op
+BenchmarkGojiv2_Param 561848 2156 ns/op 1328 B/op 11 allocs/op
+BenchmarkGoJsonRest_Param 1000000 1358 ns/op 649 B/op 13 allocs/op
+BenchmarkGoRestful_Param 224857 5307 ns/op 4192 B/op 14 allocs/op
+BenchmarkGorillaMux_Param 498313 2459 ns/op 1280 B/op 10 allocs/op
+BenchmarkGowwwRouter_Param 1864354 654 ns/op 432 B/op 3 allocs/op
+BenchmarkHttpRouter_Param 26269074 47.7 ns/op 0 B/op 0 allocs/op
+BenchmarkHttpTreeMux_Param 2109829 557 ns/op 352 B/op 3 allocs/op
+BenchmarkKocha_Param 5050216 243 ns/op 56 B/op 3 allocs/op
+BenchmarkLARS_Param 19811712 59.9 ns/op 0 B/op 0 allocs/op
+BenchmarkMacaron_Param 662746 2329 ns/op 1072 B/op 10 allocs/op
+BenchmarkMartini_Param 279902 4260 ns/op 1072 B/op 10 allocs/op
+BenchmarkPat_Param 1000000 1382 ns/op 536 B/op 11 allocs/op
+BenchmarkPossum_Param 1000000 1014 ns/op 496 B/op 5 allocs/op
+BenchmarkR2router_Param 1712559 707 ns/op 432 B/op 5 allocs/op
+BenchmarkRivet_Param 6648086 182 ns/op 48 B/op 1 allocs/op
+BenchmarkTango_Param 1221504 994 ns/op 248 B/op 8 allocs/op
+BenchmarkTigerTonic_Param 891661 2261 ns/op 776 B/op 16 allocs/op
+BenchmarkTraffic_Param 350059 3598 ns/op 1856 B/op 21 allocs/op
+BenchmarkVulcan_Param 2517823 472 ns/op 98 B/op 3 allocs/op
+BenchmarkAce_Param5 9214365 130 ns/op 0 B/op 0 allocs/op
+BenchmarkAero_Param5 15369013 77.9 ns/op 0 B/op 0 allocs/op
+BenchmarkBear_Param5 1000000 1113 ns/op 501 B/op 5 allocs/op
+BenchmarkBeego_Param5 1000000 1269 ns/op 352 B/op 3 allocs/op
+BenchmarkBone_Param5 986820 1873 ns/op 864 B/op 6 allocs/op
+BenchmarkChi_Param5 1000000 1156 ns/op 432 B/op 3 allocs/op
+BenchmarkDenco_Param5 3036331 400 ns/op 160 B/op 1 allocs/op
+BenchmarkEcho_Param5 6447133 186 ns/op 0 B/op 0 allocs/op
+BenchmarkGin_Param5 10786068 110 ns/op 0 B/op 0 allocs/op
+BenchmarkGocraftWeb_Param5 844820 1944 ns/op 920 B/op 11 allocs/op
+BenchmarkGoji_Param5 1474965 827 ns/op 336 B/op 2 allocs/op
+BenchmarkGojiv2_Param5 442820 2516 ns/op 1392 B/op 11 allocs/op
+BenchmarkGoJsonRest_Param5 507555 2711 ns/op 1097 B/op 16 allocs/op
+BenchmarkGoRestful_Param5 216481 6093 ns/op 4288 B/op 14 allocs/op
+BenchmarkGorillaMux_Param5 314402 3628 ns/op 1344 B/op 10 allocs/op
+BenchmarkGowwwRouter_Param5 1624660 733 ns/op 432 B/op 3 allocs/op
+BenchmarkHttpRouter_Param5 13167324 92.0 ns/op 0 B/op 0 allocs/op
+BenchmarkHttpTreeMux_Param5 1000000 1295 ns/op 576 B/op 6 allocs/op
+BenchmarkKocha_Param5 1000000 1138 ns/op 440 B/op 10 allocs/op
+BenchmarkLARS_Param5 11580613 105 ns/op 0 B/op 0 allocs/op
+BenchmarkMacaron_Param5 473596 2755 ns/op 1072 B/op 10 allocs/op
+BenchmarkMartini_Param5 230756 5111 ns/op 1232 B/op 11 allocs/op
+BenchmarkPat_Param5 469190 3370 ns/op 888 B/op 29 allocs/op
+BenchmarkPossum_Param5 1000000 1002 ns/op 496 B/op 5 allocs/op
+BenchmarkR2router_Param5 1422129 844 ns/op 432 B/op 5 allocs/op
+BenchmarkRivet_Param5 2263789 539 ns/op 240 B/op 1 allocs/op
+BenchmarkTango_Param5 1000000 1256 ns/op 360 B/op 8 allocs/op
+BenchmarkTigerTonic_Param5 175500 7492 ns/op 2279 B/op 39 allocs/op
+BenchmarkTraffic_Param5 233631 5816 ns/op 2208 B/op 27 allocs/op
+BenchmarkVulcan_Param5 1923416 629 ns/op 98 B/op 3 allocs/op
+BenchmarkAce_Param20 4321266 281 ns/op 0 B/op 0 allocs/op
+BenchmarkAero_Param20 31501641 35.2 ns/op 0 B/op 0 allocs/op
+BenchmarkBear_Param20 335204 3489 ns/op 1665 B/op 5 allocs/op
+BenchmarkBeego_Param20 503674 2860 ns/op 352 B/op 3 allocs/op
+BenchmarkBone_Param20 298922 4741 ns/op 2031 B/op 6 allocs/op
+BenchmarkChi_Param20 878181 1957 ns/op 432 B/op 3 allocs/op
+BenchmarkDenco_Param20 1000000 1360 ns/op 640 B/op 1 allocs/op
+BenchmarkEcho_Param20 2104946 580 ns/op 0 B/op 0 allocs/op
+BenchmarkGin_Param20 4167204 290 ns/op 0 B/op 0 allocs/op
+BenchmarkGocraftWeb_Param20 173064 7514 ns/op 3796 B/op 15 allocs/op
+BenchmarkGoji_Param20 458778 2651 ns/op 1247 B/op 2 allocs/op
+BenchmarkGojiv2_Param20 364862 3178 ns/op 1632 B/op 11 allocs/op
+BenchmarkGoJsonRest_Param20 125514 9760 ns/op 4485 B/op 20 allocs/op
+BenchmarkGoRestful_Param20 101217 11964 ns/op 6715 B/op 18 allocs/op
+BenchmarkGorillaMux_Param20 147654 8132 ns/op 3452 B/op 12 allocs/op
+BenchmarkGowwwRouter_Param20 1000000 1225 ns/op 432 B/op 3 allocs/op
+BenchmarkHttpRouter_Param20 4920895 247 ns/op 0 B/op 0 allocs/op
+BenchmarkHttpTreeMux_Param20 173202 6605 ns/op 3196 B/op 10 allocs/op
+BenchmarkKocha_Param20 345988 3620 ns/op 1808 B/op 27 allocs/op
+BenchmarkLARS_Param20 4592326 262 ns/op 0 B/op 0 allocs/op
+BenchmarkMacaron_Param20 166492 7286 ns/op 2924 B/op 12 allocs/op
+BenchmarkMartini_Param20 122162 10653 ns/op 3595 B/op 13 allocs/op
+BenchmarkPat_Param20 78630 15239 ns/op 4424 B/op 93 allocs/op
+BenchmarkPossum_Param20 1000000 1008 ns/op 496 B/op 5 allocs/op
+BenchmarkR2router_Param20 294981 4587 ns/op 2284 B/op 7 allocs/op
+BenchmarkRivet_Param20 691798 2090 ns/op 1024 B/op 1 allocs/op
+BenchmarkTango_Param20 842440 2505 ns/op 856 B/op 8 allocs/op
+BenchmarkTigerTonic_Param20 38614 31509 ns/op 9870 B/op 119 allocs/op
+BenchmarkTraffic_Param20 57633 21107 ns/op 7853 B/op 47 allocs/op
+BenchmarkVulcan_Param20 1000000 1178 ns/op 98 B/op 3 allocs/op
+BenchmarkAce_ParamWrite 7330743 180 ns/op 8 B/op 1 allocs/op
+BenchmarkAero_ParamWrite 13833598 86.7 ns/op 0 B/op 0 allocs/op
+BenchmarkBear_ParamWrite 1363321 867 ns/op 456 B/op 5 allocs/op
+BenchmarkBeego_ParamWrite 1000000 1104 ns/op 360 B/op 4 allocs/op
+BenchmarkBone_ParamWrite 1000000 1475 ns/op 816 B/op 6 allocs/op
+BenchmarkChi_ParamWrite 1320590 892 ns/op 432 B/op 3 allocs/op
+BenchmarkDenco_ParamWrite 7093605 172 ns/op 32 B/op 1 allocs/op
+BenchmarkEcho_ParamWrite 8434424 161 ns/op 8 B/op 1 allocs/op
+BenchmarkGin_ParamWrite 10377034 118 ns/op 0 B/op 0 allocs/op
+BenchmarkGocraftWeb_ParamWrite 1000000 1266 ns/op 656 B/op 9 allocs/op
+BenchmarkGoji_ParamWrite 1874168 654 ns/op 336 B/op 2 allocs/op
+BenchmarkGojiv2_ParamWrite 459032 2352 ns/op 1360 B/op 13 allocs/op
+BenchmarkGoJsonRest_ParamWrite 499434 2145 ns/op 1128 B/op 18 allocs/op
+BenchmarkGoRestful_ParamWrite 241087 5470 ns/op 4200 B/op 15 allocs/op
+BenchmarkGorillaMux_ParamWrite 425686 2522 ns/op 1280 B/op 10 allocs/op
+BenchmarkGowwwRouter_ParamWrite 922172 1778 ns/op 976 B/op 8 allocs/op
+BenchmarkHttpRouter_ParamWrite 15392049 77.7 ns/op 0 B/op 0 allocs/op
+BenchmarkHttpTreeMux_ParamWrite 1973385 597 ns/op 352 B/op 3 allocs/op
+BenchmarkKocha_ParamWrite 4262500 281 ns/op 56 B/op 3 allocs/op
+BenchmarkLARS_ParamWrite 10764410 113 ns/op 0 B/op 0 allocs/op
+BenchmarkMacaron_ParamWrite 486769 2726 ns/op 1176 B/op 14 allocs/op
+BenchmarkMartini_ParamWrite 264804 4842 ns/op 1176 B/op 14 allocs/op
+BenchmarkPat_ParamWrite 735116 2047 ns/op 960 B/op 15 allocs/op
+BenchmarkPossum_ParamWrite 1000000 1004 ns/op 496 B/op 5 allocs/op
+BenchmarkR2router_ParamWrite 1592136 768 ns/op 432 B/op 5 allocs/op
+BenchmarkRivet_ParamWrite 3582051 339 ns/op 112 B/op 2 allocs/op
+BenchmarkTango_ParamWrite 2237337 534 ns/op 136 B/op 4 allocs/op
+BenchmarkTigerTonic_ParamWrite 439608 3136 ns/op 1216 B/op 21 allocs/op
+BenchmarkTraffic_ParamWrite 306979 4328 ns/op 2280 B/op 25 allocs/op
+BenchmarkVulcan_ParamWrite 2529973 472 ns/op 98 B/op 3 allocs/op
```
## GitHub
-```
-BenchmarkGin_GithubStatic 10000000 156 ns/op 0 B/op 0 allocs/op
+```sh
+BenchmarkGin_GithubStatic 15629472 76.7 ns/op 0 B/op 0 allocs/op
-BenchmarkAce_GithubStatic 5000000 294 ns/op 0 B/op 0 allocs/op
-BenchmarkBear_GithubStatic 2000000 893 ns/op 120 B/op 3 allocs/op
-BenchmarkBeego_GithubStatic 1000000 2491 ns/op 368 B/op 4 allocs/op
-BenchmarkBone_GithubStatic 50000 25300 ns/op 2880 B/op 60 allocs/op
-BenchmarkDenco_GithubStatic 20000000 76.0 ns/op 0 B/op 0 allocs/op
-BenchmarkEcho_GithubStatic 2000000 516 ns/op 32 B/op 1 allocs/op
-BenchmarkGocraftWeb_GithubStatic 1000000 1448 ns/op 296 B/op 5 allocs/op
-BenchmarkGoji_GithubStatic 3000000 496 ns/op 0 B/op 0 allocs/op
-BenchmarkGojiv2_GithubStatic 1000000 2941 ns/op 928 B/op 7 allocs/op
-BenchmarkGoRestful_GithubStatic 100000 27256 ns/op 3224 B/op 22 allocs/op
-BenchmarkGoJsonRest_GithubStatic 1000000 2196 ns/op 329 B/op 11 allocs/op
-BenchmarkGorillaMux_GithubStatic 50000 31617 ns/op 736 B/op 10 allocs/op
-BenchmarkHttpRouter_GithubStatic 20000000 88.4 ns/op 0 B/op 0 allocs/op
-BenchmarkHttpTreeMux_GithubStatic 10000000 134 ns/op 0 B/op 0 allocs/op
-BenchmarkKocha_GithubStatic 20000000 113 ns/op 0 B/op 0 allocs/op
-BenchmarkLARS_GithubStatic 10000000 195 ns/op 0 B/op 0 allocs/op
-BenchmarkMacaron_GithubStatic 500000 3740 ns/op 768 B/op 9 allocs/op
-BenchmarkMartini_GithubStatic 50000 27673 ns/op 768 B/op 9 allocs/op
-BenchmarkPat_GithubStatic 100000 19470 ns/op 3648 B/op 76 allocs/op
-BenchmarkPossum_GithubStatic 1000000 1729 ns/op 416 B/op 3 allocs/op
-BenchmarkR2router_GithubStatic 2000000 879 ns/op 144 B/op 4 allocs/op
-BenchmarkRivet_GithubStatic 10000000 231 ns/op 0 B/op 0 allocs/op
-BenchmarkTango_GithubStatic 1000000 2325 ns/op 248 B/op 8 allocs/op
-BenchmarkTigerTonic_GithubStatic 3000000 610 ns/op 48 B/op 1 allocs/op
-BenchmarkTraffic_GithubStatic 20000 62973 ns/op 18904 B/op 148 allocs/op
-BenchmarkVulcan_GithubStatic 1000000 1447 ns/op 98 B/op 3 allocs/op
-BenchmarkAce_GithubParam 2000000 686 ns/op 96 B/op 1 allocs/op
-BenchmarkBear_GithubParam 1000000 2155 ns/op 496 B/op 5 allocs/op
-BenchmarkBeego_GithubParam 1000000 2713 ns/op 368 B/op 4 allocs/op
-BenchmarkBone_GithubParam 100000 15088 ns/op 1760 B/op 18 allocs/op
-BenchmarkDenco_GithubParam 2000000 629 ns/op 128 B/op 1 allocs/op
-BenchmarkEcho_GithubParam 2000000 653 ns/op 32 B/op 1 allocs/op
-BenchmarkGin_GithubParam 5000000 255 ns/op 0 B/op 0 allocs/op
-BenchmarkGocraftWeb_GithubParam 1000000 3145 ns/op 712 B/op 9 allocs/op
-BenchmarkGoji_GithubParam 1000000 1916 ns/op 336 B/op 2 allocs/op
-BenchmarkGojiv2_GithubParam 1000000 3975 ns/op 1024 B/op 10 allocs/op
-BenchmarkGoJsonRest_GithubParam 300000 4134 ns/op 713 B/op 14 allocs/op
-BenchmarkGoRestful_GithubParam 50000 30782 ns/op 2360 B/op 21 allocs/op
-BenchmarkGorillaMux_GithubParam 100000 17148 ns/op 1088 B/op 11 allocs/op
-BenchmarkHttpRouter_GithubParam 3000000 523 ns/op 96 B/op 1 allocs/op
-BenchmarkHttpTreeMux_GithubParam 1000000 1671 ns/op 384 B/op 4 allocs/op
-BenchmarkKocha_GithubParam 1000000 1021 ns/op 128 B/op 5 allocs/op
-BenchmarkLARS_GithubParam 5000000 283 ns/op 0 B/op 0 allocs/op
-BenchmarkMacaron_GithubParam 500000 4270 ns/op 1056 B/op 10 allocs/op
-BenchmarkMartini_GithubParam 100000 21728 ns/op 1152 B/op 11 allocs/op
-BenchmarkPat_GithubParam 200000 11208 ns/op 2464 B/op 48 allocs/op
-BenchmarkPossum_GithubParam 1000000 2334 ns/op 560 B/op 6 allocs/op
-BenchmarkR2router_GithubParam 1000000 1487 ns/op 432 B/op 5 allocs/op
-BenchmarkRivet_GithubParam 2000000 782 ns/op 96 B/op 1 allocs/op
-BenchmarkTango_GithubParam 1000000 2653 ns/op 344 B/op 8 allocs/op
-BenchmarkTigerTonic_GithubParam 300000 14073 ns/op 1440 B/op 24 allocs/op
-BenchmarkTraffic_GithubParam 50000 29164 ns/op 5992 B/op 52 allocs/op
-BenchmarkVulcan_GithubParam 1000000 2529 ns/op 98 B/op 3 allocs/op
-BenchmarkAce_GithubAll 10000 134059 ns/op 13792 B/op 167 allocs/op
-BenchmarkBear_GithubAll 5000 534445 ns/op 86448 B/op 943 allocs/op
-BenchmarkBeego_GithubAll 3000 592444 ns/op 74705 B/op 812 allocs/op
-BenchmarkBone_GithubAll 200 6957308 ns/op 698784 B/op 8453 allocs/op
-BenchmarkDenco_GithubAll 10000 158819 ns/op 20224 B/op 167 allocs/op
-BenchmarkEcho_GithubAll 10000 154700 ns/op 6496 B/op 203 allocs/op
-BenchmarkGin_GithubAll 30000 48375 ns/op 0 B/op 0 allocs/op
-BenchmarkGocraftWeb_GithubAll 3000 570806 ns/op 131656 B/op 1686 allocs/op
-BenchmarkGoji_GithubAll 2000 818034 ns/op 56112 B/op 334 allocs/op
-BenchmarkGojiv2_GithubAll 2000 1213973 ns/op 274768 B/op 3712 allocs/op
-BenchmarkGoJsonRest_GithubAll 2000 785796 ns/op 134371 B/op 2737 allocs/op
-BenchmarkGoRestful_GithubAll 300 5238188 ns/op 689672 B/op 4519 allocs/op
-BenchmarkGorillaMux_GithubAll 100 10257726 ns/op 211840 B/op 2272 allocs/op
-BenchmarkHttpRouter_GithubAll 20000 105414 ns/op 13792 B/op 167 allocs/op
-BenchmarkHttpTreeMux_GithubAll 10000 319934 ns/op 65856 B/op 671 allocs/op
-BenchmarkKocha_GithubAll 10000 209442 ns/op 23304 B/op 843 allocs/op
-BenchmarkLARS_GithubAll 20000 62565 ns/op 0 B/op 0 allocs/op
-BenchmarkMacaron_GithubAll 2000 1161270 ns/op 204194 B/op 2000 allocs/op
-BenchmarkMartini_GithubAll 200 9991713 ns/op 226549 B/op 2325 allocs/op
-BenchmarkPat_GithubAll 200 5590793 ns/op 1499568 B/op 27435 allocs/op
-BenchmarkPossum_GithubAll 10000 319768 ns/op 84448 B/op 609 allocs/op
-BenchmarkR2router_GithubAll 10000 305134 ns/op 77328 B/op 979 allocs/op
-BenchmarkRivet_GithubAll 10000 132134 ns/op 16272 B/op 167 allocs/op
-BenchmarkTango_GithubAll 3000 552754 ns/op 63826 B/op 1618 allocs/op
-BenchmarkTigerTonic_GithubAll 1000 1439483 ns/op 239104 B/op 5374 allocs/op
-BenchmarkTraffic_GithubAll 100 11383067 ns/op 2659329 B/op 21848 allocs/op
-BenchmarkVulcan_GithubAll 5000 394253 ns/op 19894 B/op 609 allocs/op
+BenchmarkAce_GithubStatic 15542612 75.9 ns/op 0 B/op 0 allocs/op
+BenchmarkAero_GithubStatic 24777151 48.5 ns/op 0 B/op 0 allocs/op
+BenchmarkBear_GithubStatic 2788894 435 ns/op 120 B/op 3 allocs/op
+BenchmarkBeego_GithubStatic 1000000 1064 ns/op 352 B/op 3 allocs/op
+BenchmarkBone_GithubStatic 93507 12838 ns/op 2880 B/op 60 allocs/op
+BenchmarkChi_GithubStatic 1387743 860 ns/op 432 B/op 3 allocs/op
+BenchmarkDenco_GithubStatic 39384996 30.4 ns/op 0 B/op 0 allocs/op
+BenchmarkEcho_GithubStatic 12076382 99.1 ns/op 0 B/op 0 allocs/op
+BenchmarkGocraftWeb_GithubStatic 1596495 756 ns/op 296 B/op 5 allocs/op
+BenchmarkGoji_GithubStatic 6364876 189 ns/op 0 B/op 0 allocs/op
+BenchmarkGojiv2_GithubStatic 550202 2098 ns/op 1312 B/op 10 allocs/op
+BenchmarkGoRestful_GithubStatic 102183 12552 ns/op 4256 B/op 13 allocs/op
+BenchmarkGoJsonRest_GithubStatic 1000000 1029 ns/op 329 B/op 11 allocs/op
+BenchmarkGorillaMux_GithubStatic 255552 5190 ns/op 976 B/op 9 allocs/op
+BenchmarkGowwwRouter_GithubStatic 15531916 77.1 ns/op 0 B/op 0 allocs/op
+BenchmarkHttpRouter_GithubStatic 27920724 43.1 ns/op 0 B/op 0 allocs/op
+BenchmarkHttpTreeMux_GithubStatic 21448953 55.8 ns/op 0 B/op 0 allocs/op
+BenchmarkKocha_GithubStatic 21405310 56.0 ns/op 0 B/op 0 allocs/op
+BenchmarkLARS_GithubStatic 13625156 89.0 ns/op 0 B/op 0 allocs/op
+BenchmarkMacaron_GithubStatic 1000000 1747 ns/op 736 B/op 8 allocs/op
+BenchmarkMartini_GithubStatic 187186 7326 ns/op 768 B/op 9 allocs/op
+BenchmarkPat_GithubStatic 109143 11563 ns/op 3648 B/op 76 allocs/op
+BenchmarkPossum_GithubStatic 1575898 770 ns/op 416 B/op 3 allocs/op
+BenchmarkR2router_GithubStatic 3046231 404 ns/op 144 B/op 4 allocs/op
+BenchmarkRivet_GithubStatic 11484826 105 ns/op 0 B/op 0 allocs/op
+BenchmarkTango_GithubStatic 1000000 1153 ns/op 248 B/op 8 allocs/op
+BenchmarkTigerTonic_GithubStatic 4929780 249 ns/op 48 B/op 1 allocs/op
+BenchmarkTraffic_GithubStatic 106351 11819 ns/op 4664 B/op 90 allocs/op
+BenchmarkVulcan_GithubStatic 1613271 722 ns/op 98 B/op 3 allocs/op
+BenchmarkAce_GithubParam 8386032 143 ns/op 0 B/op 0 allocs/op
+BenchmarkAero_GithubParam 11816200 102 ns/op 0 B/op 0 allocs/op
+BenchmarkBear_GithubParam 1000000 1012 ns/op 496 B/op 5 allocs/op
+BenchmarkBeego_GithubParam 1000000 1157 ns/op 352 B/op 3 allocs/op
+BenchmarkBone_GithubParam 184653 6912 ns/op 1888 B/op 19 allocs/op
+BenchmarkChi_GithubParam 1000000 1102 ns/op 432 B/op 3 allocs/op
+BenchmarkDenco_GithubParam 3484798 352 ns/op 128 B/op 1 allocs/op
+BenchmarkEcho_GithubParam 6337380 189 ns/op 0 B/op 0 allocs/op
+BenchmarkGin_GithubParam 9132032 131 ns/op 0 B/op 0 allocs/op
+BenchmarkGocraftWeb_GithubParam 1000000 1446 ns/op 712 B/op 9 allocs/op
+BenchmarkGoji_GithubParam 1248640 977 ns/op 336 B/op 2 allocs/op
+BenchmarkGojiv2_GithubParam 383233 2784 ns/op 1408 B/op 13 allocs/op
+BenchmarkGoJsonRest_GithubParam 1000000 1991 ns/op 713 B/op 14 allocs/op
+BenchmarkGoRestful_GithubParam 76414 16015 ns/op 4352 B/op 16 allocs/op
+BenchmarkGorillaMux_GithubParam 150026 7663 ns/op 1296 B/op 10 allocs/op
+BenchmarkGowwwRouter_GithubParam 1592044 751 ns/op 432 B/op 3 allocs/op
+BenchmarkHttpRouter_GithubParam 10420628 115 ns/op 0 B/op 0 allocs/op
+BenchmarkHttpTreeMux_GithubParam 1403755 835 ns/op 384 B/op 4 allocs/op
+BenchmarkKocha_GithubParam 2286170 533 ns/op 128 B/op 5 allocs/op
+BenchmarkLARS_GithubParam 9540374 129 ns/op 0 B/op 0 allocs/op
+BenchmarkMacaron_GithubParam 533154 2742 ns/op 1072 B/op 10 allocs/op
+BenchmarkMartini_GithubParam 119397 9638 ns/op 1152 B/op 11 allocs/op
+BenchmarkPat_GithubParam 150675 8858 ns/op 2408 B/op 48 allocs/op
+BenchmarkPossum_GithubParam 1000000 1001 ns/op 496 B/op 5 allocs/op
+BenchmarkR2router_GithubParam 1602886 761 ns/op 432 B/op 5 allocs/op
+BenchmarkRivet_GithubParam 2986579 409 ns/op 96 B/op 1 allocs/op
+BenchmarkTango_GithubParam 1000000 1356 ns/op 344 B/op 8 allocs/op
+BenchmarkTigerTonic_GithubParam 388899 3429 ns/op 1176 B/op 22 allocs/op
+BenchmarkTraffic_GithubParam 123160 9734 ns/op 2816 B/op 40 allocs/op
+BenchmarkVulcan_GithubParam 1000000 1138 ns/op 98 B/op 3 allocs/op
+BenchmarkAce_GithubAll 40543 29670 ns/op 0 B/op 0 allocs/op
+BenchmarkAero_GithubAll 57632 20648 ns/op 0 B/op 0 allocs/op
+BenchmarkBear_GithubAll 9234 216179 ns/op 86448 B/op 943 allocs/op
+BenchmarkBeego_GithubAll 7407 243496 ns/op 71456 B/op 609 allocs/op
+BenchmarkBone_GithubAll 420 2922835 ns/op 720160 B/op 8620 allocs/op
+BenchmarkChi_GithubAll 7620 238331 ns/op 87696 B/op 609 allocs/op
+BenchmarkDenco_GithubAll 18355 64494 ns/op 20224 B/op 167 allocs/op
+BenchmarkEcho_GithubAll 31251 38479 ns/op 0 B/op 0 allocs/op
+BenchmarkGin_GithubAll 43550 27364 ns/op 0 B/op 0 allocs/op
+BenchmarkGocraftWeb_GithubAll 4117 300062 ns/op 131656 B/op 1686 allocs/op
+BenchmarkGoji_GithubAll 3274 416158 ns/op 56112 B/op 334 allocs/op
+BenchmarkGojiv2_GithubAll 1402 870518 ns/op 352720 B/op 4321 allocs/op
+BenchmarkGoJsonRest_GithubAll 2976 401507 ns/op 134371 B/op 2737 allocs/op
+BenchmarkGoRestful_GithubAll 410 2913158 ns/op 910144 B/op 2938 allocs/op
+BenchmarkGorillaMux_GithubAll 346 3384987 ns/op 251650 B/op 1994 allocs/op
+BenchmarkGowwwRouter_GithubAll 10000 143025 ns/op 72144 B/op 501 allocs/op
+BenchmarkHttpRouter_GithubAll 55938 21360 ns/op 0 B/op 0 allocs/op
+BenchmarkHttpTreeMux_GithubAll 10000 153944 ns/op 65856 B/op 671 allocs/op
+BenchmarkKocha_GithubAll 10000 106315 ns/op 23304 B/op 843 allocs/op
+BenchmarkLARS_GithubAll 47779 25084 ns/op 0 B/op 0 allocs/op
+BenchmarkMacaron_GithubAll 3266 371907 ns/op 149409 B/op 1624 allocs/op
+BenchmarkMartini_GithubAll 331 3444706 ns/op 226551 B/op 2325 allocs/op
+BenchmarkPat_GithubAll 273 4381818 ns/op 1483152 B/op 26963 allocs/op
+BenchmarkPossum_GithubAll 10000 164367 ns/op 84448 B/op 609 allocs/op
+BenchmarkR2router_GithubAll 10000 160220 ns/op 77328 B/op 979 allocs/op
+BenchmarkRivet_GithubAll 14625 82453 ns/op 16272 B/op 167 allocs/op
+BenchmarkTango_GithubAll 6255 279611 ns/op 63826 B/op 1618 allocs/op
+BenchmarkTigerTonic_GithubAll 2008 687874 ns/op 193856 B/op 4474 allocs/op
+BenchmarkTraffic_GithubAll 355 3478508 ns/op 820744 B/op 14114 allocs/op
+BenchmarkVulcan_GithubAll 6885 193333 ns/op 19894 B/op 609 allocs/op
```
## Google+
-```
-BenchmarkGin_GPlusStatic 10000000 183 ns/op 0 B/op 0 allocs/op
+```sh
+BenchmarkGin_GPlusStatic 19247326 62.2 ns/op 0 B/op 0 allocs/op
-BenchmarkAce_GPlusStatic 5000000 276 ns/op 0 B/op 0 allocs/op
-BenchmarkBear_GPlusStatic 2000000 652 ns/op 104 B/op 3 allocs/op
-BenchmarkBeego_GPlusStatic 1000000 2239 ns/op 368 B/op 4 allocs/op
-BenchmarkBone_GPlusStatic 5000000 380 ns/op 32 B/op 1 allocs/op
-BenchmarkDenco_GPlusStatic 30000000 45.8 ns/op 0 B/op 0 allocs/op
-BenchmarkEcho_GPlusStatic 5000000 338 ns/op 32 B/op 1 allocs/op
-BenchmarkGocraftWeb_GPlusStatic 1000000 1158 ns/op 280 B/op 5 allocs/op
-BenchmarkGoji_GPlusStatic 5000000 331 ns/op 0 B/op 0 allocs/op
-BenchmarkGojiv2_GPlusStatic 1000000 2106 ns/op 928 B/op 7 allocs/op
-BenchmarkGoJsonRest_GPlusStatic 1000000 1626 ns/op 329 B/op 11 allocs/op
-BenchmarkGoRestful_GPlusStatic 300000 7598 ns/op 1976 B/op 20 allocs/op
-BenchmarkGorillaMux_GPlusStatic 1000000 2629 ns/op 736 B/op 10 allocs/op
-BenchmarkHttpRouter_GPlusStatic 30000000 52.5 ns/op 0 B/op 0 allocs/op
-BenchmarkHttpTreeMux_GPlusStatic 20000000 85.8 ns/op 0 B/op 0 allocs/op
-BenchmarkKocha_GPlusStatic 20000000 89.2 ns/op 0 B/op 0 allocs/op
-BenchmarkLARS_GPlusStatic 10000000 162 ns/op 0 B/op 0 allocs/op
-BenchmarkMacaron_GPlusStatic 500000 3479 ns/op 768 B/op 9 allocs/op
-BenchmarkMartini_GPlusStatic 200000 9092 ns/op 768 B/op 9 allocs/op
-BenchmarkPat_GPlusStatic 3000000 493 ns/op 96 B/op 2 allocs/op
-BenchmarkPossum_GPlusStatic 1000000 1467 ns/op 416 B/op 3 allocs/op
-BenchmarkR2router_GPlusStatic 2000000 788 ns/op 144 B/op 4 allocs/op
-BenchmarkRivet_GPlusStatic 20000000 114 ns/op 0 B/op 0 allocs/op
-BenchmarkTango_GPlusStatic 1000000 1534 ns/op 200 B/op 8 allocs/op
-BenchmarkTigerTonic_GPlusStatic 5000000 282 ns/op 32 B/op 1 allocs/op
-BenchmarkTraffic_GPlusStatic 500000 3798 ns/op 1192 B/op 15 allocs/op
-BenchmarkVulcan_GPlusStatic 2000000 1125 ns/op 98 B/op 3 allocs/op
-BenchmarkAce_GPlusParam 3000000 528 ns/op 64 B/op 1 allocs/op
-BenchmarkBear_GPlusParam 1000000 1570 ns/op 480 B/op 5 allocs/op
-BenchmarkBeego_GPlusParam 1000000 2369 ns/op 368 B/op 4 allocs/op
-BenchmarkBone_GPlusParam 1000000 2028 ns/op 688 B/op 5 allocs/op
-BenchmarkDenco_GPlusParam 5000000 385 ns/op 64 B/op 1 allocs/op
-BenchmarkEcho_GPlusParam 3000000 441 ns/op 32 B/op 1 allocs/op
-BenchmarkGin_GPlusParam 10000000 174 ns/op 0 B/op 0 allocs/op
-BenchmarkGocraftWeb_GPlusParam 1000000 2033 ns/op 648 B/op 8 allocs/op
-BenchmarkGoji_GPlusParam 1000000 1399 ns/op 336 B/op 2 allocs/op
-BenchmarkGojiv2_GPlusParam 1000000 2641 ns/op 944 B/op 8 allocs/op
-BenchmarkGoJsonRest_GPlusParam 1000000 2824 ns/op 649 B/op 13 allocs/op
-BenchmarkGoRestful_GPlusParam 200000 8875 ns/op 2296 B/op 21 allocs/op
-BenchmarkGorillaMux_GPlusParam 200000 6291 ns/op 1056 B/op 11 allocs/op
-BenchmarkHttpRouter_GPlusParam 5000000 316 ns/op 64 B/op 1 allocs/op
-BenchmarkHttpTreeMux_GPlusParam 1000000 1129 ns/op 352 B/op 3 allocs/op
-BenchmarkKocha_GPlusParam 3000000 538 ns/op 56 B/op 3 allocs/op
-BenchmarkLARS_GPlusParam 10000000 198 ns/op 0 B/op 0 allocs/op
-BenchmarkMacaron_GPlusParam 500000 3554 ns/op 1056 B/op 10 allocs/op
-BenchmarkMartini_GPlusParam 200000 9831 ns/op 1072 B/op 10 allocs/op
-BenchmarkPat_GPlusParam 1000000 2706 ns/op 688 B/op 12 allocs/op
-BenchmarkPossum_GPlusParam 1000000 2297 ns/op 560 B/op 6 allocs/op
-BenchmarkR2router_GPlusParam 1000000 1318 ns/op 432 B/op 5 allocs/op
-BenchmarkRivet_GPlusParam 5000000 399 ns/op 48 B/op 1 allocs/op
-BenchmarkTango_GPlusParam 1000000 2070 ns/op 264 B/op 8 allocs/op
-BenchmarkTigerTonic_GPlusParam 500000 4853 ns/op 1056 B/op 17 allocs/op
-BenchmarkTraffic_GPlusParam 200000 8278 ns/op 1976 B/op 21 allocs/op
-BenchmarkVulcan_GPlusParam 1000000 1243 ns/op 98 B/op 3 allocs/op
-BenchmarkAce_GPlus2Params 3000000 549 ns/op 64 B/op 1 allocs/op
-BenchmarkBear_GPlus2Params 1000000 2112 ns/op 496 B/op 5 allocs/op
-BenchmarkBeego_GPlus2Params 500000 2750 ns/op 368 B/op 4 allocs/op
-BenchmarkBone_GPlus2Params 300000 7032 ns/op 1040 B/op 9 allocs/op
-BenchmarkDenco_GPlus2Params 3000000 502 ns/op 64 B/op 1 allocs/op
-BenchmarkEcho_GPlus2Params 3000000 641 ns/op 32 B/op 1 allocs/op
-BenchmarkGin_GPlus2Params 5000000 250 ns/op 0 B/op 0 allocs/op
-BenchmarkGocraftWeb_GPlus2Params 1000000 2681 ns/op 712 B/op 9 allocs/op
-BenchmarkGoji_GPlus2Params 1000000 1926 ns/op 336 B/op 2 allocs/op
-BenchmarkGojiv2_GPlus2Params 500000 3996 ns/op 1024 B/op 11 allocs/op
-BenchmarkGoJsonRest_GPlus2Params 500000 3886 ns/op 713 B/op 14 allocs/op
-BenchmarkGoRestful_GPlus2Params 200000 10376 ns/op 2360 B/op 21 allocs/op
-BenchmarkGorillaMux_GPlus2Params 100000 14162 ns/op 1088 B/op 11 allocs/op
-BenchmarkHttpRouter_GPlus2Params 5000000 336 ns/op 64 B/op 1 allocs/op
-BenchmarkHttpTreeMux_GPlus2Params 1000000 1523 ns/op 384 B/op 4 allocs/op
-BenchmarkKocha_GPlus2Params 2000000 970 ns/op 128 B/op 5 allocs/op
-BenchmarkLARS_GPlus2Params 5000000 238 ns/op 0 B/op 0 allocs/op
-BenchmarkMacaron_GPlus2Params 500000 4016 ns/op 1056 B/op 10 allocs/op
-BenchmarkMartini_GPlus2Params 100000 21253 ns/op 1200 B/op 13 allocs/op
-BenchmarkPat_GPlus2Params 200000 8632 ns/op 2256 B/op 34 allocs/op
-BenchmarkPossum_GPlus2Params 1000000 2171 ns/op 560 B/op 6 allocs/op
-BenchmarkR2router_GPlus2Params 1000000 1340 ns/op 432 B/op 5 allocs/op
-BenchmarkRivet_GPlus2Params 3000000 557 ns/op 96 B/op 1 allocs/op
-BenchmarkTango_GPlus2Params 1000000 2186 ns/op 344 B/op 8 allocs/op
-BenchmarkTigerTonic_GPlus2Params 200000 9060 ns/op 1488 B/op 24 allocs/op
-BenchmarkTraffic_GPlus2Params 100000 20324 ns/op 3272 B/op 31 allocs/op
-BenchmarkVulcan_GPlus2Params 1000000 2039 ns/op 98 B/op 3 allocs/op
-BenchmarkAce_GPlusAll 300000 6603 ns/op 640 B/op 11 allocs/op
-BenchmarkBear_GPlusAll 100000 22363 ns/op 5488 B/op 61 allocs/op
-BenchmarkBeego_GPlusAll 50000 38757 ns/op 4784 B/op 52 allocs/op
-BenchmarkBone_GPlusAll 20000 54916 ns/op 10336 B/op 98 allocs/op
-BenchmarkDenco_GPlusAll 300000 4959 ns/op 672 B/op 11 allocs/op
-BenchmarkEcho_GPlusAll 200000 6558 ns/op 416 B/op 13 allocs/op
-BenchmarkGin_GPlusAll 500000 2757 ns/op 0 B/op 0 allocs/op
-BenchmarkGocraftWeb_GPlusAll 50000 34615 ns/op 8040 B/op 103 allocs/op
-BenchmarkGoji_GPlusAll 100000 16002 ns/op 3696 B/op 22 allocs/op
-BenchmarkGojiv2_GPlusAll 50000 35060 ns/op 12624 B/op 115 allocs/op
-BenchmarkGoJsonRest_GPlusAll 50000 41479 ns/op 8117 B/op 170 allocs/op
-BenchmarkGoRestful_GPlusAll 10000 131653 ns/op 32024 B/op 275 allocs/op
-BenchmarkGorillaMux_GPlusAll 10000 101380 ns/op 13296 B/op 142 allocs/op
-BenchmarkHttpRouter_GPlusAll 500000 3711 ns/op 640 B/op 11 allocs/op
-BenchmarkHttpTreeMux_GPlusAll 100000 14438 ns/op 4032 B/op 38 allocs/op
-BenchmarkKocha_GPlusAll 200000 8039 ns/op 976 B/op 43 allocs/op
-BenchmarkLARS_GPlusAll 500000 2630 ns/op 0 B/op 0 allocs/op
-BenchmarkMacaron_GPlusAll 30000 51123 ns/op 13152 B/op 128 allocs/op
-BenchmarkMartini_GPlusAll 10000 176157 ns/op 14016 B/op 145 allocs/op
-BenchmarkPat_GPlusAll 20000 69911 ns/op 16576 B/op 298 allocs/op
-BenchmarkPossum_GPlusAll 100000 20716 ns/op 5408 B/op 39 allocs/op
-BenchmarkR2router_GPlusAll 100000 17463 ns/op 5040 B/op 63 allocs/op
-BenchmarkRivet_GPlusAll 300000 5142 ns/op 768 B/op 11 allocs/op
-BenchmarkTango_GPlusAll 50000 27321 ns/op 3656 B/op 104 allocs/op
-BenchmarkTigerTonic_GPlusAll 20000 77597 ns/op 14512 B/op 288 allocs/op
-BenchmarkTraffic_GPlusAll 10000 151406 ns/op 37360 B/op 392 allocs/op
-BenchmarkVulcan_GPlusAll 100000 18555 ns/op 1274 B/op 39 allocs/op
+BenchmarkAce_GPlusStatic 20235060 59.2 ns/op 0 B/op 0 allocs/op
+BenchmarkAero_GPlusStatic 31978935 37.6 ns/op 0 B/op 0 allocs/op
+BenchmarkBear_GPlusStatic 3516523 341 ns/op 104 B/op 3 allocs/op
+BenchmarkBeego_GPlusStatic 1212036 991 ns/op 352 B/op 3 allocs/op
+BenchmarkBone_GPlusStatic 6736242 183 ns/op 32 B/op 1 allocs/op
+BenchmarkChi_GPlusStatic 1490640 814 ns/op 432 B/op 3 allocs/op
+BenchmarkDenco_GPlusStatic 55006856 21.8 ns/op 0 B/op 0 allocs/op
+BenchmarkEcho_GPlusStatic 17688258 67.9 ns/op 0 B/op 0 allocs/op
+BenchmarkGocraftWeb_GPlusStatic 1829181 666 ns/op 280 B/op 5 allocs/op
+BenchmarkGoji_GPlusStatic 9147451 130 ns/op 0 B/op 0 allocs/op
+BenchmarkGojiv2_GPlusStatic 594015 2063 ns/op 1312 B/op 10 allocs/op
+BenchmarkGoJsonRest_GPlusStatic 1264906 950 ns/op 329 B/op 11 allocs/op
+BenchmarkGoRestful_GPlusStatic 231558 5341 ns/op 3872 B/op 13 allocs/op
+BenchmarkGorillaMux_GPlusStatic 908418 1809 ns/op 976 B/op 9 allocs/op
+BenchmarkGowwwRouter_GPlusStatic 40684604 29.5 ns/op 0 B/op 0 allocs/op
+BenchmarkHttpRouter_GPlusStatic 46742804 25.7 ns/op 0 B/op 0 allocs/op
+BenchmarkHttpTreeMux_GPlusStatic 32567161 36.9 ns/op 0 B/op 0 allocs/op
+BenchmarkKocha_GPlusStatic 33800060 35.3 ns/op 0 B/op 0 allocs/op
+BenchmarkLARS_GPlusStatic 20431858 60.0 ns/op 0 B/op 0 allocs/op
+BenchmarkMacaron_GPlusStatic 1000000 1745 ns/op 736 B/op 8 allocs/op
+BenchmarkMartini_GPlusStatic 442248 3619 ns/op 768 B/op 9 allocs/op
+BenchmarkPat_GPlusStatic 4328004 292 ns/op 96 B/op 2 allocs/op
+BenchmarkPossum_GPlusStatic 1570753 763 ns/op 416 B/op 3 allocs/op
+BenchmarkR2router_GPlusStatic 3339474 355 ns/op 144 B/op 4 allocs/op
+BenchmarkRivet_GPlusStatic 18570961 64.7 ns/op 0 B/op 0 allocs/op
+BenchmarkTango_GPlusStatic 1388702 860 ns/op 200 B/op 8 allocs/op
+BenchmarkTigerTonic_GPlusStatic 7803543 159 ns/op 32 B/op 1 allocs/op
+BenchmarkTraffic_GPlusStatic 878605 2171 ns/op 1112 B/op 16 allocs/op
+BenchmarkVulcan_GPlusStatic 2742446 437 ns/op 98 B/op 3 allocs/op
+BenchmarkAce_GPlusParam 11626975 105 ns/op 0 B/op 0 allocs/op
+BenchmarkAero_GPlusParam 16914322 71.6 ns/op 0 B/op 0 allocs/op
+BenchmarkBear_GPlusParam 1405173 832 ns/op 480 B/op 5 allocs/op
+BenchmarkBeego_GPlusParam 1000000 1075 ns/op 352 B/op 3 allocs/op
+BenchmarkBone_GPlusParam 1000000 1557 ns/op 816 B/op 6 allocs/op
+BenchmarkChi_GPlusParam 1347926 894 ns/op 432 B/op 3 allocs/op
+BenchmarkDenco_GPlusParam 5513000 212 ns/op 64 B/op 1 allocs/op
+BenchmarkEcho_GPlusParam 11884383 101 ns/op 0 B/op 0 allocs/op
+BenchmarkGin_GPlusParam 12898952 93.1 ns/op 0 B/op 0 allocs/op
+BenchmarkGocraftWeb_GPlusParam 1000000 1194 ns/op 648 B/op 8 allocs/op
+BenchmarkGoji_GPlusParam 1857229 645 ns/op 336 B/op 2 allocs/op
+BenchmarkGojiv2_GPlusParam 520939 2322 ns/op 1328 B/op 11 allocs/op
+BenchmarkGoJsonRest_GPlusParam 1000000 1536 ns/op 649 B/op 13 allocs/op
+BenchmarkGoRestful_GPlusParam 205449 5800 ns/op 4192 B/op 14 allocs/op
+BenchmarkGorillaMux_GPlusParam 395310 3188 ns/op 1280 B/op 10 allocs/op
+BenchmarkGowwwRouter_GPlusParam 1851798 667 ns/op 432 B/op 3 allocs/op
+BenchmarkHttpRouter_GPlusParam 18420789 65.2 ns/op 0 B/op 0 allocs/op
+BenchmarkHttpTreeMux_GPlusParam 1878463 629 ns/op 352 B/op 3 allocs/op
+BenchmarkKocha_GPlusParam 4495610 273 ns/op 56 B/op 3 allocs/op
+BenchmarkLARS_GPlusParam 14615976 83.2 ns/op 0 B/op 0 allocs/op
+BenchmarkMacaron_GPlusParam 584145 2549 ns/op 1072 B/op 10 allocs/op
+BenchmarkMartini_GPlusParam 250501 4583 ns/op 1072 B/op 10 allocs/op
+BenchmarkPat_GPlusParam 1000000 1645 ns/op 576 B/op 11 allocs/op
+BenchmarkPossum_GPlusParam 1000000 1008 ns/op 496 B/op 5 allocs/op
+BenchmarkR2router_GPlusParam 1708191 688 ns/op 432 B/op 5 allocs/op
+BenchmarkRivet_GPlusParam 5795014 211 ns/op 48 B/op 1 allocs/op
+BenchmarkTango_GPlusParam 1000000 1091 ns/op 264 B/op 8 allocs/op
+BenchmarkTigerTonic_GPlusParam 760221 2489 ns/op 856 B/op 16 allocs/op
+BenchmarkTraffic_GPlusParam 309774 4039 ns/op 1872 B/op 21 allocs/op
+BenchmarkVulcan_GPlusParam 1935730 623 ns/op 98 B/op 3 allocs/op
+BenchmarkAce_GPlus2Params 9158314 134 ns/op 0 B/op 0 allocs/op
+BenchmarkAero_GPlus2Params 11300517 107 ns/op 0 B/op 0 allocs/op
+BenchmarkBear_GPlus2Params 1239238 961 ns/op 496 B/op 5 allocs/op
+BenchmarkBeego_GPlus2Params 1000000 1202 ns/op 352 B/op 3 allocs/op
+BenchmarkBone_GPlus2Params 335576 3725 ns/op 1168 B/op 10 allocs/op
+BenchmarkChi_GPlus2Params 1000000 1014 ns/op 432 B/op 3 allocs/op
+BenchmarkDenco_GPlus2Params 4394598 280 ns/op 64 B/op 1 allocs/op
+BenchmarkEcho_GPlus2Params 7851861 154 ns/op 0 B/op 0 allocs/op
+BenchmarkGin_GPlus2Params 9958588 120 ns/op 0 B/op 0 allocs/op
+BenchmarkGocraftWeb_GPlus2Params 1000000 1433 ns/op 712 B/op 9 allocs/op
+BenchmarkGoji_GPlus2Params 1325134 909 ns/op 336 B/op 2 allocs/op
+BenchmarkGojiv2_GPlus2Params 405955 2870 ns/op 1408 B/op 14 allocs/op
+BenchmarkGoJsonRest_GPlus2Params 977038 1987 ns/op 713 B/op 14 allocs/op
+BenchmarkGoRestful_GPlus2Params 205018 6142 ns/op 4384 B/op 16 allocs/op
+BenchmarkGorillaMux_GPlus2Params 205641 6015 ns/op 1296 B/op 10 allocs/op
+BenchmarkGowwwRouter_GPlus2Params 1748542 684 ns/op 432 B/op 3 allocs/op
+BenchmarkHttpRouter_GPlus2Params 14047102 87.7 ns/op 0 B/op 0 allocs/op
+BenchmarkHttpTreeMux_GPlus2Params 1418673 828 ns/op 384 B/op 4 allocs/op
+BenchmarkKocha_GPlus2Params 2334562 520 ns/op 128 B/op 5 allocs/op
+BenchmarkLARS_GPlus2Params 11954094 101 ns/op 0 B/op 0 allocs/op
+BenchmarkMacaron_GPlus2Params 491552 2890 ns/op 1072 B/op 10 allocs/op
+BenchmarkMartini_GPlus2Params 120532 9545 ns/op 1200 B/op 13 allocs/op
+BenchmarkPat_GPlus2Params 194739 6766 ns/op 2168 B/op 33 allocs/op
+BenchmarkPossum_GPlus2Params 1201224 1009 ns/op 496 B/op 5 allocs/op
+BenchmarkR2router_GPlus2Params 1575535 756 ns/op 432 B/op 5 allocs/op
+BenchmarkRivet_GPlus2Params 3698930 325 ns/op 96 B/op 1 allocs/op
+BenchmarkTango_GPlus2Params 1000000 1212 ns/op 344 B/op 8 allocs/op
+BenchmarkTigerTonic_GPlus2Params 349350 3660 ns/op 1200 B/op 22 allocs/op
+BenchmarkTraffic_GPlus2Params 169714 7862 ns/op 2248 B/op 28 allocs/op
+BenchmarkVulcan_GPlus2Params 1222288 974 ns/op 98 B/op 3 allocs/op
+BenchmarkAce_GPlusAll 845606 1398 ns/op 0 B/op 0 allocs/op
+BenchmarkAero_GPlusAll 1000000 1009 ns/op 0 B/op 0 allocs/op
+BenchmarkBear_GPlusAll 103830 11386 ns/op 5488 B/op 61 allocs/op
+BenchmarkBeego_GPlusAll 82653 14784 ns/op 4576 B/op 39 allocs/op
+BenchmarkBone_GPlusAll 36601 33123 ns/op 11744 B/op 109 allocs/op
+BenchmarkChi_GPlusAll 95264 12831 ns/op 5616 B/op 39 allocs/op
+BenchmarkDenco_GPlusAll 567681 2950 ns/op 672 B/op 11 allocs/op
+BenchmarkEcho_GPlusAll 720366 1665 ns/op 0 B/op 0 allocs/op
+BenchmarkGin_GPlusAll 1000000 1185 ns/op 0 B/op 0 allocs/op
+BenchmarkGocraftWeb_GPlusAll 71575 16365 ns/op 8040 B/op 103 allocs/op
+BenchmarkGoji_GPlusAll 136352 9191 ns/op 3696 B/op 22 allocs/op
+BenchmarkGojiv2_GPlusAll 38006 31802 ns/op 17616 B/op 154 allocs/op
+BenchmarkGoJsonRest_GPlusAll 57238 21561 ns/op 8117 B/op 170 allocs/op
+BenchmarkGoRestful_GPlusAll 15147 79276 ns/op 55520 B/op 192 allocs/op
+BenchmarkGorillaMux_GPlusAll 24446 48410 ns/op 16112 B/op 128 allocs/op
+BenchmarkGowwwRouter_GPlusAll 150112 7770 ns/op 4752 B/op 33 allocs/op
+BenchmarkHttpRouter_GPlusAll 1367820 878 ns/op 0 B/op 0 allocs/op
+BenchmarkHttpTreeMux_GPlusAll 166628 8004 ns/op 4032 B/op 38 allocs/op
+BenchmarkKocha_GPlusAll 265694 4570 ns/op 976 B/op 43 allocs/op
+BenchmarkLARS_GPlusAll 1000000 1068 ns/op 0 B/op 0 allocs/op
+BenchmarkMacaron_GPlusAll 54564 23305 ns/op 9568 B/op 104 allocs/op
+BenchmarkMartini_GPlusAll 16274 73845 ns/op 14016 B/op 145 allocs/op
+BenchmarkPat_GPlusAll 27181 44478 ns/op 15264 B/op 271 allocs/op
+BenchmarkPossum_GPlusAll 122587 10277 ns/op 5408 B/op 39 allocs/op
+BenchmarkR2router_GPlusAll 130137 9297 ns/op 5040 B/op 63 allocs/op
+BenchmarkRivet_GPlusAll 532438 3323 ns/op 768 B/op 11 allocs/op
+BenchmarkTango_GPlusAll 86054 14531 ns/op 3656 B/op 104 allocs/op
+BenchmarkTigerTonic_GPlusAll 33936 35356 ns/op 11600 B/op 242 allocs/op
+BenchmarkTraffic_GPlusAll 17833 68181 ns/op 26248 B/op 341 allocs/op
+BenchmarkVulcan_GPlusAll 120109 9861 ns/op 1274 B/op 39 allocs/op
```
## Parse.com
-```
-BenchmarkGin_ParseStatic 10000000 133 ns/op 0 B/op 0 allocs/op
+```sh
+BenchmarkGin_ParseStatic 18877833 63.5 ns/op 0 B/op 0 allocs/op
-BenchmarkAce_ParseStatic 5000000 241 ns/op 0 B/op 0 allocs/op
-BenchmarkBear_ParseStatic 2000000 728 ns/op 120 B/op 3 allocs/op
-BenchmarkBeego_ParseStatic 1000000 2623 ns/op 368 B/op 4 allocs/op
-BenchmarkBone_ParseStatic 1000000 1285 ns/op 144 B/op 3 allocs/op
-BenchmarkDenco_ParseStatic 30000000 57.8 ns/op 0 B/op 0 allocs/op
-BenchmarkEcho_ParseStatic 5000000 342 ns/op 32 B/op 1 allocs/op
-BenchmarkGocraftWeb_ParseStatic 1000000 1478 ns/op 296 B/op 5 allocs/op
-BenchmarkGoji_ParseStatic 3000000 415 ns/op 0 B/op 0 allocs/op
-BenchmarkGojiv2_ParseStatic 1000000 2087 ns/op 928 B/op 7 allocs/op
-BenchmarkGoJsonRest_ParseStatic 1000000 1712 ns/op 329 B/op 11 allocs/op
-BenchmarkGoRestful_ParseStatic 200000 11072 ns/op 3224 B/op 22 allocs/op
-BenchmarkGorillaMux_ParseStatic 500000 4129 ns/op 752 B/op 11 allocs/op
-BenchmarkHttpRouter_ParseStatic 30000000 52.4 ns/op 0 B/op 0 allocs/op
-BenchmarkHttpTreeMux_ParseStatic 20000000 109 ns/op 0 B/op 0 allocs/op
-BenchmarkKocha_ParseStatic 20000000 81.8 ns/op 0 B/op 0 allocs/op
-BenchmarkLARS_ParseStatic 10000000 150 ns/op 0 B/op 0 allocs/op
-BenchmarkMacaron_ParseStatic 1000000 3288 ns/op 768 B/op 9 allocs/op
-BenchmarkMartini_ParseStatic 200000 9110 ns/op 768 B/op 9 allocs/op
-BenchmarkPat_ParseStatic 1000000 1135 ns/op 240 B/op 5 allocs/op
-BenchmarkPossum_ParseStatic 1000000 1557 ns/op 416 B/op 3 allocs/op
-BenchmarkR2router_ParseStatic 2000000 730 ns/op 144 B/op 4 allocs/op
-BenchmarkRivet_ParseStatic 10000000 121 ns/op 0 B/op 0 allocs/op
-BenchmarkTango_ParseStatic 1000000 1688 ns/op 248 B/op 8 allocs/op
-BenchmarkTigerTonic_ParseStatic 3000000 427 ns/op 48 B/op 1 allocs/op
-BenchmarkTraffic_ParseStatic 500000 5962 ns/op 1816 B/op 20 allocs/op
-BenchmarkVulcan_ParseStatic 2000000 969 ns/op 98 B/op 3 allocs/op
-BenchmarkAce_ParseParam 3000000 497 ns/op 64 B/op 1 allocs/op
-BenchmarkBear_ParseParam 1000000 1473 ns/op 467 B/op 5 allocs/op
-BenchmarkBeego_ParseParam 1000000 2384 ns/op 368 B/op 4 allocs/op
-BenchmarkBone_ParseParam 1000000 2513 ns/op 768 B/op 6 allocs/op
-BenchmarkDenco_ParseParam 5000000 364 ns/op 64 B/op 1 allocs/op
-BenchmarkEcho_ParseParam 5000000 418 ns/op 32 B/op 1 allocs/op
-BenchmarkGin_ParseParam 10000000 163 ns/op 0 B/op 0 allocs/op
-BenchmarkGocraftWeb_ParseParam 1000000 2361 ns/op 664 B/op 8 allocs/op
-BenchmarkGoji_ParseParam 1000000 1590 ns/op 336 B/op 2 allocs/op
-BenchmarkGojiv2_ParseParam 1000000 2851 ns/op 976 B/op 9 allocs/op
-BenchmarkGoJsonRest_ParseParam 1000000 2965 ns/op 649 B/op 13 allocs/op
-BenchmarkGoRestful_ParseParam 200000 12207 ns/op 3544 B/op 23 allocs/op
-BenchmarkGorillaMux_ParseParam 500000 5187 ns/op 1088 B/op 12 allocs/op
-BenchmarkHttpRouter_ParseParam 5000000 275 ns/op 64 B/op 1 allocs/op
-BenchmarkHttpTreeMux_ParseParam 1000000 1108 ns/op 352 B/op 3 allocs/op
-BenchmarkKocha_ParseParam 3000000 495 ns/op 56 B/op 3 allocs/op
-BenchmarkLARS_ParseParam 10000000 192 ns/op 0 B/op 0 allocs/op
-BenchmarkMacaron_ParseParam 500000 4103 ns/op 1056 B/op 10 allocs/op
-BenchmarkMartini_ParseParam 200000 9878 ns/op 1072 B/op 10 allocs/op
-BenchmarkPat_ParseParam 500000 3657 ns/op 1120 B/op 17 allocs/op
-BenchmarkPossum_ParseParam 1000000 2084 ns/op 560 B/op 6 allocs/op
-BenchmarkR2router_ParseParam 1000000 1251 ns/op 432 B/op 5 allocs/op
-BenchmarkRivet_ParseParam 5000000 335 ns/op 48 B/op 1 allocs/op
-BenchmarkTango_ParseParam 1000000 1854 ns/op 280 B/op 8 allocs/op
-BenchmarkTigerTonic_ParseParam 500000 4582 ns/op 1008 B/op 17 allocs/op
-BenchmarkTraffic_ParseParam 200000 8125 ns/op 2248 B/op 23 allocs/op
-BenchmarkVulcan_ParseParam 1000000 1148 ns/op 98 B/op 3 allocs/op
-BenchmarkAce_Parse2Params 3000000 539 ns/op 64 B/op 1 allocs/op
-BenchmarkBear_Parse2Params 1000000 1778 ns/op 496 B/op 5 allocs/op
-BenchmarkBeego_Parse2Params 1000000 2519 ns/op 368 B/op 4 allocs/op
-BenchmarkBone_Parse2Params 1000000 2596 ns/op 720 B/op 5 allocs/op
-BenchmarkDenco_Parse2Params 3000000 492 ns/op 64 B/op 1 allocs/op
-BenchmarkEcho_Parse2Params 3000000 484 ns/op 32 B/op 1 allocs/op
-BenchmarkGin_Parse2Params 10000000 193 ns/op 0 B/op 0 allocs/op
-BenchmarkGocraftWeb_Parse2Params 1000000 2575 ns/op 712 B/op 9 allocs/op
-BenchmarkGoji_Parse2Params 1000000 1373 ns/op 336 B/op 2 allocs/op
-BenchmarkGojiv2_Parse2Params 500000 2416 ns/op 960 B/op 8 allocs/op
-BenchmarkGoJsonRest_Parse2Params 300000 3452 ns/op 713 B/op 14 allocs/op
-BenchmarkGoRestful_Parse2Params 100000 17719 ns/op 6008 B/op 25 allocs/op
-BenchmarkGorillaMux_Parse2Params 300000 5102 ns/op 1088 B/op 11 allocs/op
-BenchmarkHttpRouter_Parse2Params 5000000 303 ns/op 64 B/op 1 allocs/op
-BenchmarkHttpTreeMux_Parse2Params 1000000 1372 ns/op 384 B/op 4 allocs/op
-BenchmarkKocha_Parse2Params 2000000 874 ns/op 128 B/op 5 allocs/op
-BenchmarkLARS_Parse2Params 10000000 192 ns/op 0 B/op 0 allocs/op
-BenchmarkMacaron_Parse2Params 500000 3871 ns/op 1056 B/op 10 allocs/op
-BenchmarkMartini_Parse2Params 200000 9954 ns/op 1152 B/op 11 allocs/op
-BenchmarkPat_Parse2Params 500000 4194 ns/op 832 B/op 17 allocs/op
-BenchmarkPossum_Parse2Params 1000000 2121 ns/op 560 B/op 6 allocs/op
-BenchmarkR2router_Parse2Params 1000000 1415 ns/op 432 B/op 5 allocs/op
-BenchmarkRivet_Parse2Params 3000000 457 ns/op 96 B/op 1 allocs/op
-BenchmarkTango_Parse2Params 1000000 1914 ns/op 312 B/op 8 allocs/op
-BenchmarkTigerTonic_Parse2Params 300000 6895 ns/op 1408 B/op 24 allocs/op
-BenchmarkTraffic_Parse2Params 200000 8317 ns/op 2040 B/op 22 allocs/op
-BenchmarkVulcan_Parse2Params 1000000 1274 ns/op 98 B/op 3 allocs/op
-BenchmarkAce_ParseAll 200000 10401 ns/op 640 B/op 16 allocs/op
-BenchmarkBear_ParseAll 50000 37743 ns/op 8928 B/op 110 allocs/op
-BenchmarkBeego_ParseAll 20000 63193 ns/op 9568 B/op 104 allocs/op
-BenchmarkBone_ParseAll 20000 61767 ns/op 14160 B/op 131 allocs/op
-BenchmarkDenco_ParseAll 300000 7036 ns/op 928 B/op 16 allocs/op
-BenchmarkEcho_ParseAll 200000 11824 ns/op 832 B/op 26 allocs/op
-BenchmarkGin_ParseAll 300000 4199 ns/op 0 B/op 0 allocs/op
-BenchmarkGocraftWeb_ParseAll 30000 51758 ns/op 13728 B/op 181 allocs/op
-BenchmarkGoji_ParseAll 50000 29614 ns/op 5376 B/op 32 allocs/op
-BenchmarkGojiv2_ParseAll 20000 68676 ns/op 24464 B/op 199 allocs/op
-BenchmarkGoJsonRest_ParseAll 20000 76135 ns/op 13866 B/op 321 allocs/op
-BenchmarkGoRestful_ParseAll 5000 389487 ns/op 110928 B/op 600 allocs/op
-BenchmarkGorillaMux_ParseAll 10000 221250 ns/op 24864 B/op 292 allocs/op
-BenchmarkHttpRouter_ParseAll 200000 6444 ns/op 640 B/op 16 allocs/op
-BenchmarkHttpTreeMux_ParseAll 50000 30702 ns/op 5728 B/op 51 allocs/op
-BenchmarkKocha_ParseAll 200000 13712 ns/op 1112 B/op 54 allocs/op
-BenchmarkLARS_ParseAll 300000 6925 ns/op 0 B/op 0 allocs/op
-BenchmarkMacaron_ParseAll 20000 96278 ns/op 24576 B/op 250 allocs/op
-BenchmarkMartini_ParseAll 5000 271352 ns/op 25072 B/op 253 allocs/op
-BenchmarkPat_ParseAll 20000 74941 ns/op 17264 B/op 343 allocs/op
-BenchmarkPossum_ParseAll 50000 39947 ns/op 10816 B/op 78 allocs/op
-BenchmarkR2router_ParseAll 50000 42479 ns/op 8352 B/op 120 allocs/op
-BenchmarkRivet_ParseAll 200000 7726 ns/op 912 B/op 16 allocs/op
-BenchmarkTango_ParseAll 30000 50014 ns/op 7168 B/op 208 allocs/op
-BenchmarkTigerTonic_ParseAll 10000 106550 ns/op 19728 B/op 379 allocs/op
-BenchmarkTraffic_ParseAll 10000 216037 ns/op 57776 B/op 642 allocs/op
-BenchmarkVulcan_ParseAll 50000 34379 ns/op 2548 B/op 78 allocs/op
+BenchmarkAce_ParseStatic 19663731 60.8 ns/op 0 B/op 0 allocs/op
+BenchmarkAero_ParseStatic 28967341 41.5 ns/op 0 B/op 0 allocs/op
+BenchmarkBear_ParseStatic 3006984 402 ns/op 120 B/op 3 allocs/op
+BenchmarkBeego_ParseStatic 1000000 1031 ns/op 352 B/op 3 allocs/op
+BenchmarkBone_ParseStatic 1782482 675 ns/op 144 B/op 3 allocs/op
+BenchmarkChi_ParseStatic 1453261 819 ns/op 432 B/op 3 allocs/op
+BenchmarkDenco_ParseStatic 45023595 26.5 ns/op 0 B/op 0 allocs/op
+BenchmarkEcho_ParseStatic 17330470 69.3 ns/op 0 B/op 0 allocs/op
+BenchmarkGocraftWeb_ParseStatic 1644006 731 ns/op 296 B/op 5 allocs/op
+BenchmarkGoji_ParseStatic 7026930 170 ns/op 0 B/op 0 allocs/op
+BenchmarkGojiv2_ParseStatic 517618 2037 ns/op 1312 B/op 10 allocs/op
+BenchmarkGoJsonRest_ParseStatic 1227080 975 ns/op 329 B/op 11 allocs/op
+BenchmarkGoRestful_ParseStatic 192458 6659 ns/op 4256 B/op 13 allocs/op
+BenchmarkGorillaMux_ParseStatic 744062 2109 ns/op 976 B/op 9 allocs/op
+BenchmarkGowwwRouter_ParseStatic 37781062 31.8 ns/op 0 B/op 0 allocs/op
+BenchmarkHttpRouter_ParseStatic 45311223 26.5 ns/op 0 B/op 0 allocs/op
+BenchmarkHttpTreeMux_ParseStatic 21383475 56.1 ns/op 0 B/op 0 allocs/op
+BenchmarkKocha_ParseStatic 29953290 40.1 ns/op 0 B/op 0 allocs/op
+BenchmarkLARS_ParseStatic 20036196 62.7 ns/op 0 B/op 0 allocs/op
+BenchmarkMacaron_ParseStatic 1000000 1740 ns/op 736 B/op 8 allocs/op
+BenchmarkMartini_ParseStatic 404156 3801 ns/op 768 B/op 9 allocs/op
+BenchmarkPat_ParseStatic 1547180 772 ns/op 240 B/op 5 allocs/op
+BenchmarkPossum_ParseStatic 1608991 757 ns/op 416 B/op 3 allocs/op
+BenchmarkR2router_ParseStatic 3177936 385 ns/op 144 B/op 4 allocs/op
+BenchmarkRivet_ParseStatic 17783205 67.4 ns/op 0 B/op 0 allocs/op
+BenchmarkTango_ParseStatic 1210777 990 ns/op 248 B/op 8 allocs/op
+BenchmarkTigerTonic_ParseStatic 5316440 231 ns/op 48 B/op 1 allocs/op
+BenchmarkTraffic_ParseStatic 496050 2539 ns/op 1256 B/op 19 allocs/op
+BenchmarkVulcan_ParseStatic 2462798 488 ns/op 98 B/op 3 allocs/op
+BenchmarkAce_ParseParam 13393669 89.6 ns/op 0 B/op 0 allocs/op
+BenchmarkAero_ParseParam 19836619 60.4 ns/op 0 B/op 0 allocs/op
+BenchmarkBear_ParseParam 1405954 864 ns/op 467 B/op 5 allocs/op
+BenchmarkBeego_ParseParam 1000000 1065 ns/op 352 B/op 3 allocs/op
+BenchmarkBone_ParseParam 1000000 1698 ns/op 896 B/op 7 allocs/op
+BenchmarkChi_ParseParam 1356037 873 ns/op 432 B/op 3 allocs/op
+BenchmarkDenco_ParseParam 6241392 204 ns/op 64 B/op 1 allocs/op
+BenchmarkEcho_ParseParam 14088100 85.1 ns/op 0 B/op 0 allocs/op
+BenchmarkGin_ParseParam 17426064 68.9 ns/op 0 B/op 0 allocs/op
+BenchmarkGocraftWeb_ParseParam 1000000 1254 ns/op 664 B/op 8 allocs/op
+BenchmarkGoji_ParseParam 1682574 713 ns/op 336 B/op 2 allocs/op
+BenchmarkGojiv2_ParseParam 502224 2333 ns/op 1360 B/op 12 allocs/op
+BenchmarkGoJsonRest_ParseParam 1000000 1401 ns/op 649 B/op 13 allocs/op
+BenchmarkGoRestful_ParseParam 182623 7097 ns/op 4576 B/op 14 allocs/op
+BenchmarkGorillaMux_ParseParam 482332 2477 ns/op 1280 B/op 10 allocs/op
+BenchmarkGowwwRouter_ParseParam 1834873 657 ns/op 432 B/op 3 allocs/op
+BenchmarkHttpRouter_ParseParam 23593393 51.0 ns/op 0 B/op 0 allocs/op
+BenchmarkHttpTreeMux_ParseParam 2100160 574 ns/op 352 B/op 3 allocs/op
+BenchmarkKocha_ParseParam 4837220 252 ns/op 56 B/op 3 allocs/op
+BenchmarkLARS_ParseParam 18411192 66.2 ns/op 0 B/op 0 allocs/op
+BenchmarkMacaron_ParseParam 571870 2398 ns/op 1072 B/op 10 allocs/op
+BenchmarkMartini_ParseParam 286262 4268 ns/op 1072 B/op 10 allocs/op
+BenchmarkPat_ParseParam 692906 2157 ns/op 992 B/op 15 allocs/op
+BenchmarkPossum_ParseParam 1000000 1011 ns/op 496 B/op 5 allocs/op
+BenchmarkR2router_ParseParam 1722735 697 ns/op 432 B/op 5 allocs/op
+BenchmarkRivet_ParseParam 6058054 203 ns/op 48 B/op 1 allocs/op
+BenchmarkTango_ParseParam 1000000 1061 ns/op 280 B/op 8 allocs/op
+BenchmarkTigerTonic_ParseParam 890275 2277 ns/op 784 B/op 15 allocs/op
+BenchmarkTraffic_ParseParam 351322 3543 ns/op 1896 B/op 21 allocs/op
+BenchmarkVulcan_ParseParam 2076544 572 ns/op 98 B/op 3 allocs/op
+BenchmarkAce_Parse2Params 11718074 101 ns/op 0 B/op 0 allocs/op
+BenchmarkAero_Parse2Params 16264988 73.4 ns/op 0 B/op 0 allocs/op
+BenchmarkBear_Parse2Params 1238322 973 ns/op 496 B/op 5 allocs/op
+BenchmarkBeego_Parse2Params 1000000 1120 ns/op 352 B/op 3 allocs/op
+BenchmarkBone_Parse2Params 1000000 1632 ns/op 848 B/op 6 allocs/op
+BenchmarkChi_Parse2Params 1239477 955 ns/op 432 B/op 3 allocs/op
+BenchmarkDenco_Parse2Params 4944133 245 ns/op 64 B/op 1 allocs/op
+BenchmarkEcho_Parse2Params 10518286 114 ns/op 0 B/op 0 allocs/op
+BenchmarkGin_Parse2Params 14505195 82.7 ns/op 0 B/op 0 allocs/op
+BenchmarkGocraftWeb_Parse2Params 1000000 1437 ns/op 712 B/op 9 allocs/op
+BenchmarkGoji_Parse2Params 1689883 707 ns/op 336 B/op 2 allocs/op
+BenchmarkGojiv2_Parse2Params 502334 2308 ns/op 1344 B/op 11 allocs/op
+BenchmarkGoJsonRest_Parse2Params 1000000 1771 ns/op 713 B/op 14 allocs/op
+BenchmarkGoRestful_Parse2Params 159092 7583 ns/op 4928 B/op 14 allocs/op
+BenchmarkGorillaMux_Parse2Params 417548 2980 ns/op 1296 B/op 10 allocs/op
+BenchmarkGowwwRouter_Parse2Params 1751737 686 ns/op 432 B/op 3 allocs/op
+BenchmarkHttpRouter_Parse2Params 18089204 66.3 ns/op 0 B/op 0 allocs/op
+BenchmarkHttpTreeMux_Parse2Params 1556986 777 ns/op 384 B/op 4 allocs/op
+BenchmarkKocha_Parse2Params 2493082 485 ns/op 128 B/op 5 allocs/op
+BenchmarkLARS_Parse2Params 15350108 78.5 ns/op 0 B/op 0 allocs/op
+BenchmarkMacaron_Parse2Params 530974 2605 ns/op 1072 B/op 10 allocs/op
+BenchmarkMartini_Parse2Params 247069 4673 ns/op 1152 B/op 11 allocs/op
+BenchmarkPat_Parse2Params 816295 2126 ns/op 752 B/op 16 allocs/op
+BenchmarkPossum_Parse2Params 1000000 1002 ns/op 496 B/op 5 allocs/op
+BenchmarkR2router_Parse2Params 1569771 733 ns/op 432 B/op 5 allocs/op
+BenchmarkRivet_Parse2Params 4080546 295 ns/op 96 B/op 1 allocs/op
+BenchmarkTango_Parse2Params 1000000 1121 ns/op 312 B/op 8 allocs/op
+BenchmarkTigerTonic_Parse2Params 399556 3470 ns/op 1168 B/op 22 allocs/op
+BenchmarkTraffic_Parse2Params 314194 4159 ns/op 1944 B/op 22 allocs/op
+BenchmarkVulcan_Parse2Params 1827559 664 ns/op 98 B/op 3 allocs/op
+BenchmarkAce_ParseAll 478395 2503 ns/op 0 B/op 0 allocs/op
+BenchmarkAero_ParseAll 715392 1658 ns/op 0 B/op 0 allocs/op
+BenchmarkBear_ParseAll 59191 20124 ns/op 8928 B/op 110 allocs/op
+BenchmarkBeego_ParseAll 45507 27266 ns/op 9152 B/op 78 allocs/op
+BenchmarkBone_ParseAll 29328 41459 ns/op 16208 B/op 147 allocs/op
+BenchmarkChi_ParseAll 48531 25053 ns/op 11232 B/op 78 allocs/op
+BenchmarkDenco_ParseAll 325532 4284 ns/op 928 B/op 16 allocs/op
+BenchmarkEcho_ParseAll 433771 2759 ns/op 0 B/op 0 allocs/op
+BenchmarkGin_ParseAll 576316 2082 ns/op 0 B/op 0 allocs/op
+BenchmarkGocraftWeb_ParseAll 41500 29692 ns/op 13728 B/op 181 allocs/op
+BenchmarkGoji_ParseAll 80833 15563 ns/op 5376 B/op 32 allocs/op
+BenchmarkGojiv2_ParseAll 19836 60335 ns/op 34448 B/op 277 allocs/op
+BenchmarkGoJsonRest_ParseAll 32210 38027 ns/op 13866 B/op 321 allocs/op
+BenchmarkGoRestful_ParseAll 6644 190842 ns/op 117600 B/op 354 allocs/op
+BenchmarkGorillaMux_ParseAll 12634 95894 ns/op 30288 B/op 250 allocs/op
+BenchmarkGowwwRouter_ParseAll 98152 12159 ns/op 6912 B/op 48 allocs/op
+BenchmarkHttpRouter_ParseAll 933208 1273 ns/op 0 B/op 0 allocs/op
+BenchmarkHttpTreeMux_ParseAll 107191 11554 ns/op 5728 B/op 51 allocs/op
+BenchmarkKocha_ParseAll 184862 6225 ns/op 1112 B/op 54 allocs/op
+BenchmarkLARS_ParseAll 644546 1858 ns/op 0 B/op 0 allocs/op
+BenchmarkMacaron_ParseAll 26145 46484 ns/op 19136 B/op 208 allocs/op
+BenchmarkMartini_ParseAll 10000 121838 ns/op 25072 B/op 253 allocs/op
+BenchmarkPat_ParseAll 25417 47196 ns/op 15216 B/op 308 allocs/op
+BenchmarkPossum_ParseAll 58550 20735 ns/op 10816 B/op 78 allocs/op
+BenchmarkR2router_ParseAll 72732 16584 ns/op 8352 B/op 120 allocs/op
+BenchmarkRivet_ParseAll 281365 4968 ns/op 912 B/op 16 allocs/op
+BenchmarkTango_ParseAll 42831 28668 ns/op 7168 B/op 208 allocs/op
+BenchmarkTigerTonic_ParseAll 23774 49972 ns/op 16048 B/op 332 allocs/op
+BenchmarkTraffic_ParseAll 10000 104679 ns/op 45520 B/op 605 allocs/op
+BenchmarkVulcan_ParseAll 64810 18108 ns/op 2548 B/op 78 allocs/op
```
diff --git a/vendor/github.com/gin-gonic/gin/CHANGELOG.md b/vendor/github.com/gin-gonic/gin/CHANGELOG.md
index e6a108c..44d6251 100644
--- a/vendor/github.com/gin-gonic/gin/CHANGELOG.md
+++ b/vendor/github.com/gin-gonic/gin/CHANGELOG.md
@@ -1,6 +1,199 @@
-# CHANGELOG
+# Gin ChangeLog
-### Gin 1.3.0
+## Gin v1.7.0
+
+### BUGFIXES
+
+* fix compile error from [#2572](https://github.com/gin-gonic/gin/pull/2572) ([#2600](https://github.com/gin-gonic/gin/pull/2600))
+* fix: print headers without Authorization header on broken pipe ([#2528](https://github.com/gin-gonic/gin/pull/2528))
+* fix(tree): reassign fullpath when register new node ([#2366](https://github.com/gin-gonic/gin/pull/2366))
+
+### ENHANCEMENTS
+
+* Support params and exact routes without creating conflicts ([#2663](https://github.com/gin-gonic/gin/pull/2663))
+* chore: improve render string performance ([#2365](https://github.com/gin-gonic/gin/pull/2365))
+* Sync route tree to httprouter latest code ([#2368](https://github.com/gin-gonic/gin/pull/2368))
+* chore: rename getQueryCache/getFormCache to initQueryCache/initFormCa ([#2375](https://github.com/gin-gonic/gin/pull/2375))
+* chore(performance): improve countParams ([#2378](https://github.com/gin-gonic/gin/pull/2378))
+* Remove some functions that have the same effect as the bytes package ([#2387](https://github.com/gin-gonic/gin/pull/2387))
+* update:SetMode function ([#2321](https://github.com/gin-gonic/gin/pull/2321))
+* remove a unused type SecureJSONPrefix ([#2391](https://github.com/gin-gonic/gin/pull/2391))
+* Add a redirect sample for POST method ([#2389](https://github.com/gin-gonic/gin/pull/2389))
+* Add CustomRecovery builtin middleware ([#2322](https://github.com/gin-gonic/gin/pull/2322))
+* binding: avoid 2038 problem on 32-bit architectures ([#2450](https://github.com/gin-gonic/gin/pull/2450))
+* Prevent panic in Context.GetQuery() when there is no Request ([#2412](https://github.com/gin-gonic/gin/pull/2412))
+* Add GetUint and GetUint64 method on gin.context ([#2487](https://github.com/gin-gonic/gin/pull/2487))
+* update content-disposition header to MIME-style ([#2512](https://github.com/gin-gonic/gin/pull/2512))
+* reduce allocs and improve the render `WriteString` ([#2508](https://github.com/gin-gonic/gin/pull/2508))
+* implement ".Unwrap() error" on Error type ([#2525](https://github.com/gin-gonic/gin/pull/2525)) ([#2526](https://github.com/gin-gonic/gin/pull/2526))
+* Allow bind with a map[string]string ([#2484](https://github.com/gin-gonic/gin/pull/2484))
+* chore: update tree ([#2371](https://github.com/gin-gonic/gin/pull/2371))
+* Support binding for slice/array obj [Rewrite] ([#2302](https://github.com/gin-gonic/gin/pull/2302))
+* basic auth: fix timing oracle ([#2609](https://github.com/gin-gonic/gin/pull/2609))
+* Add mixed param and non-param paths (port of httprouter[#329](https://github.com/gin-gonic/gin/pull/329)) ([#2663](https://github.com/gin-gonic/gin/pull/2663))
+* feat(engine): add trustedproxies and remoteIP ([#2632](https://github.com/gin-gonic/gin/pull/2632))
+
+## Gin v1.6.3
+
+### ENHANCEMENTS
+
+ * Improve performance: Change `*sync.RWMutex` to `sync.RWMutex` in context. [#2351](https://github.com/gin-gonic/gin/pull/2351)
+
+## Gin v1.6.2
+
+### BUGFIXES
+ * fix missing initial sync.RWMutex [#2305](https://github.com/gin-gonic/gin/pull/2305)
+### ENHANCEMENTS
+ * Add set samesite in cookie. [#2306](https://github.com/gin-gonic/gin/pull/2306)
+
+## Gin v1.6.1
+
+### BUGFIXES
+ * Revert "fix accept incoming network connections" [#2294](https://github.com/gin-gonic/gin/pull/2294)
+
+## Gin v1.6.0
+
+### BREAKING
+ * chore(performance): Improve performance for adding RemoveExtraSlash flag [#2159](https://github.com/gin-gonic/gin/pull/2159)
+ * drop support govendor [#2148](https://github.com/gin-gonic/gin/pull/2148)
+ * Added support for SameSite cookie flag [#1615](https://github.com/gin-gonic/gin/pull/1615)
+### FEATURES
+ * add yaml negotiation [#2220](https://github.com/gin-gonic/gin/pull/2220)
+ * FileFromFS [#2112](https://github.com/gin-gonic/gin/pull/2112)
+### BUGFIXES
+ * Unix Socket Handling [#2280](https://github.com/gin-gonic/gin/pull/2280)
+ * Use json marshall in context json to fix breaking new line issue. Fixes #2209 [#2228](https://github.com/gin-gonic/gin/pull/2228)
+ * fix accept incoming network connections [#2216](https://github.com/gin-gonic/gin/pull/2216)
+ * Fixed a bug in the calculation of the maximum number of parameters [#2166](https://github.com/gin-gonic/gin/pull/2166)
+ * [FIX] allow empty headers on DataFromReader [#2121](https://github.com/gin-gonic/gin/pull/2121)
+ * Add mutex for protect Context.Keys map [#1391](https://github.com/gin-gonic/gin/pull/1391)
+### ENHANCEMENTS
+ * Add mitigation for log injection [#2277](https://github.com/gin-gonic/gin/pull/2277)
+ * tree: range over nodes values [#2229](https://github.com/gin-gonic/gin/pull/2229)
+ * tree: remove duplicate assignment [#2222](https://github.com/gin-gonic/gin/pull/2222)
+ * chore: upgrade go-isatty and json-iterator/go [#2215](https://github.com/gin-gonic/gin/pull/2215)
+ * path: sync code with httprouter [#2212](https://github.com/gin-gonic/gin/pull/2212)
+ * Use zero-copy approach to convert types between string and byte slice [#2206](https://github.com/gin-gonic/gin/pull/2206)
+ * Reuse bytes when cleaning the URL paths [#2179](https://github.com/gin-gonic/gin/pull/2179)
+ * tree: remove one else statement [#2177](https://github.com/gin-gonic/gin/pull/2177)
+ * tree: sync httprouter update (#2173) (#2172) [#2171](https://github.com/gin-gonic/gin/pull/2171)
+ * tree: sync part httprouter codes and reduce if/else [#2163](https://github.com/gin-gonic/gin/pull/2163)
+ * use http method constant [#2155](https://github.com/gin-gonic/gin/pull/2155)
+ * upgrade go-validator to v10 [#2149](https://github.com/gin-gonic/gin/pull/2149)
+ * Refactor redirect request in gin.go [#1970](https://github.com/gin-gonic/gin/pull/1970)
+ * Add build tag nomsgpack [#1852](https://github.com/gin-gonic/gin/pull/1852)
+### DOCS
+ * docs(path): improve comments [#2223](https://github.com/gin-gonic/gin/pull/2223)
+ * Renew README to fit the modification of SetCookie method [#2217](https://github.com/gin-gonic/gin/pull/2217)
+ * Fix spelling [#2202](https://github.com/gin-gonic/gin/pull/2202)
+ * Remove broken link from README. [#2198](https://github.com/gin-gonic/gin/pull/2198)
+ * Update docs on Context.Done(), Context.Deadline() and Context.Err() [#2196](https://github.com/gin-gonic/gin/pull/2196)
+ * Update validator to v10 [#2190](https://github.com/gin-gonic/gin/pull/2190)
+ * upgrade go-validator to v10 for README [#2189](https://github.com/gin-gonic/gin/pull/2189)
+ * Update to currently output [#2188](https://github.com/gin-gonic/gin/pull/2188)
+ * Fix "Custom Validators" example [#2186](https://github.com/gin-gonic/gin/pull/2186)
+ * Add project to README [#2165](https://github.com/gin-gonic/gin/pull/2165)
+ * docs(benchmarks): for gin v1.5 [#2153](https://github.com/gin-gonic/gin/pull/2153)
+ * Changed wording for clarity in README.md [#2122](https://github.com/gin-gonic/gin/pull/2122)
+### MISC
+ * ci support go1.14 [#2262](https://github.com/gin-gonic/gin/pull/2262)
+ * chore: upgrade depend version [#2231](https://github.com/gin-gonic/gin/pull/2231)
+ * Drop support go1.10 [#2147](https://github.com/gin-gonic/gin/pull/2147)
+ * fix comment in `mode.go` [#2129](https://github.com/gin-gonic/gin/pull/2129)
+
+## Gin v1.5.0
+
+- [FIX] Use DefaultWriter and DefaultErrorWriter for debug messages [#1891](https://github.com/gin-gonic/gin/pull/1891)
+- [NEW] Now you can parse the inline lowercase start structure [#1893](https://github.com/gin-gonic/gin/pull/1893)
+- [FIX] Some code improvements [#1909](https://github.com/gin-gonic/gin/pull/1909)
+- [FIX] Use encode replace json marshal increase json encoder speed [#1546](https://github.com/gin-gonic/gin/pull/1546)
+- [NEW] Hold matched route full path in the Context [#1826](https://github.com/gin-gonic/gin/pull/1826)
+- [FIX] Fix context.Params race condition on Copy() [#1841](https://github.com/gin-gonic/gin/pull/1841)
+- [NEW] Add context param query cache [#1450](https://github.com/gin-gonic/gin/pull/1450)
+- [FIX] Improve GetQueryMap performance [#1918](https://github.com/gin-gonic/gin/pull/1918)
+- [FIX] Improve get post data [#1920](https://github.com/gin-gonic/gin/pull/1920)
+- [FIX] Use context instead of x/net/context [#1922](https://github.com/gin-gonic/gin/pull/1922)
+- [FIX] Attempt to fix PostForm cache bug [#1931](https://github.com/gin-gonic/gin/pull/1931)
+- [NEW] Add support of multipart multi files [#1949](https://github.com/gin-gonic/gin/pull/1949)
+- [NEW] Support bind http header param [#1957](https://github.com/gin-gonic/gin/pull/1957)
+- [FIX] Drop support for go1.8 and go1.9 [#1933](https://github.com/gin-gonic/gin/pull/1933)
+- [FIX] Bugfix for the FullPath feature [#1919](https://github.com/gin-gonic/gin/pull/1919)
+- [FIX] Gin1.5 bytes.Buffer to strings.Builder [#1939](https://github.com/gin-gonic/gin/pull/1939)
+- [FIX] Upgrade github.com/ugorji/go/codec [#1969](https://github.com/gin-gonic/gin/pull/1969)
+- [NEW] Support bind unix time [#1980](https://github.com/gin-gonic/gin/pull/1980)
+- [FIX] Simplify code [#2004](https://github.com/gin-gonic/gin/pull/2004)
+- [NEW] Support negative Content-Length in DataFromReader [#1981](https://github.com/gin-gonic/gin/pull/1981)
+- [FIX] Identify terminal on a RISC-V architecture for auto-colored logs [#2019](https://github.com/gin-gonic/gin/pull/2019)
+- [BREAKING] `Context.JSONP()` now expects a semicolon (`;`) at the end [#2007](https://github.com/gin-gonic/gin/pull/2007)
+- [BREAKING] Upgrade default `binding.Validator` to v9 (see [its changelog](https://github.com/go-playground/validator/releases/tag/v9.0.0)) [#1015](https://github.com/gin-gonic/gin/pull/1015)
+- [NEW] Add `DisallowUnknownFields()` in `Context.BindJSON()` [#2028](https://github.com/gin-gonic/gin/pull/2028)
+- [NEW] Use specific `net.Listener` with `Engine.RunListener()` [#2023](https://github.com/gin-gonic/gin/pull/2023)
+- [FIX] Fix some typo [#2079](https://github.com/gin-gonic/gin/pull/2079) [#2080](https://github.com/gin-gonic/gin/pull/2080)
+- [FIX] Relocate binding body tests [#2086](https://github.com/gin-gonic/gin/pull/2086)
+- [FIX] Use Writer in Context.Status [#1606](https://github.com/gin-gonic/gin/pull/1606)
+- [FIX] `Engine.RunUnix()` now returns the error if it can't change the file mode [#2093](https://github.com/gin-gonic/gin/pull/2093)
+- [FIX] `RouterGroup.StaticFS()` leaked files. Now it closes them. [#2118](https://github.com/gin-gonic/gin/pull/2118)
+- [FIX] `Context.Request.FormFile` leaked file. Now it closes it. [#2114](https://github.com/gin-gonic/gin/pull/2114)
+- [FIX] Ignore walking on `form:"-"` mapping [#1943](https://github.com/gin-gonic/gin/pull/1943)
+
+### Gin v1.4.0
+
+- [NEW] Support for [Go Modules](https://github.com/golang/go/wiki/Modules) [#1569](https://github.com/gin-gonic/gin/pull/1569)
+- [NEW] Refactor of form mapping multipart request [#1829](https://github.com/gin-gonic/gin/pull/1829)
+- [FIX] Truncate Latency precision in long running request [#1830](https://github.com/gin-gonic/gin/pull/1830)
+- [FIX] IsTerm flag should not be affected by DisableConsoleColor method. [#1802](https://github.com/gin-gonic/gin/pull/1802)
+- [NEW] Supporting file binding [#1264](https://github.com/gin-gonic/gin/pull/1264)
+- [NEW] Add support for mapping arrays [#1797](https://github.com/gin-gonic/gin/pull/1797)
+- [FIX] Readme updates [#1793](https://github.com/gin-gonic/gin/pull/1793) [#1788](https://github.com/gin-gonic/gin/pull/1788) [1789](https://github.com/gin-gonic/gin/pull/1789)
+- [FIX] StaticFS: Fixed Logging two log lines on 404. [#1805](https://github.com/gin-gonic/gin/pull/1805), [#1804](https://github.com/gin-gonic/gin/pull/1804)
+- [NEW] Make context.Keys available as LogFormatterParams [#1779](https://github.com/gin-gonic/gin/pull/1779)
+- [NEW] Use internal/json for Marshal/Unmarshal [#1791](https://github.com/gin-gonic/gin/pull/1791)
+- [NEW] Support mapping time.Duration [#1794](https://github.com/gin-gonic/gin/pull/1794)
+- [NEW] Refactor form mappings [#1749](https://github.com/gin-gonic/gin/pull/1749)
+- [NEW] Added flag to context.Stream indicates if client disconnected in middle of stream [#1252](https://github.com/gin-gonic/gin/pull/1252)
+- [FIX] Moved [examples](https://github.com/gin-gonic/examples) to stand alone Repo [#1775](https://github.com/gin-gonic/gin/pull/1775)
+- [NEW] Extend context.File to allow for the content-disposition attachments via a new method context.Attachment [#1260](https://github.com/gin-gonic/gin/pull/1260)
+- [FIX] Support HTTP content negotiation wildcards [#1112](https://github.com/gin-gonic/gin/pull/1112)
+- [NEW] Add prefix from X-Forwarded-Prefix in redirectTrailingSlash [#1238](https://github.com/gin-gonic/gin/pull/1238)
+- [FIX] context.Copy() race condition [#1020](https://github.com/gin-gonic/gin/pull/1020)
+- [NEW] Add context.HandlerNames() [#1729](https://github.com/gin-gonic/gin/pull/1729)
+- [FIX] Change color methods to public in the defaultLogger. [#1771](https://github.com/gin-gonic/gin/pull/1771)
+- [FIX] Update writeHeaders method to use http.Header.Set [#1722](https://github.com/gin-gonic/gin/pull/1722)
+- [NEW] Add response size to LogFormatterParams [#1752](https://github.com/gin-gonic/gin/pull/1752)
+- [NEW] Allow ignoring field on form mapping [#1733](https://github.com/gin-gonic/gin/pull/1733)
+- [NEW] Add a function to force color in console output. [#1724](https://github.com/gin-gonic/gin/pull/1724)
+- [FIX] Context.Next() - recheck len of handlers on every iteration. [#1745](https://github.com/gin-gonic/gin/pull/1745)
+- [FIX] Fix all errcheck warnings [#1739](https://github.com/gin-gonic/gin/pull/1739) [#1653](https://github.com/gin-gonic/gin/pull/1653)
+- [NEW] context: inherits context cancellation and deadline from http.Request context for Go>=1.7 [#1690](https://github.com/gin-gonic/gin/pull/1690)
+- [NEW] Binding for URL Params [#1694](https://github.com/gin-gonic/gin/pull/1694)
+- [NEW] Add LoggerWithFormatter method [#1677](https://github.com/gin-gonic/gin/pull/1677)
+- [FIX] CI testing updates [#1671](https://github.com/gin-gonic/gin/pull/1671) [#1670](https://github.com/gin-gonic/gin/pull/1670) [#1682](https://github.com/gin-gonic/gin/pull/1682) [#1669](https://github.com/gin-gonic/gin/pull/1669)
+- [FIX] StaticFS(): Send 404 when path does not exist [#1663](https://github.com/gin-gonic/gin/pull/1663)
+- [FIX] Handle nil body for JSON binding [#1638](https://github.com/gin-gonic/gin/pull/1638)
+- [FIX] Support bind uri param [#1612](https://github.com/gin-gonic/gin/pull/1612)
+- [FIX] recovery: fix issue with syscall import on google app engine [#1640](https://github.com/gin-gonic/gin/pull/1640)
+- [FIX] Make sure the debug log contains line breaks [#1650](https://github.com/gin-gonic/gin/pull/1650)
+- [FIX] Panic stack trace being printed during recovery of broken pipe [#1089](https://github.com/gin-gonic/gin/pull/1089) [#1259](https://github.com/gin-gonic/gin/pull/1259)
+- [NEW] RunFd method to run http.Server through a file descriptor [#1609](https://github.com/gin-gonic/gin/pull/1609)
+- [NEW] Yaml binding support [#1618](https://github.com/gin-gonic/gin/pull/1618)
+- [FIX] Pass MaxMultipartMemory when FormFile is called [#1600](https://github.com/gin-gonic/gin/pull/1600)
+- [FIX] LoadHTML* tests [#1559](https://github.com/gin-gonic/gin/pull/1559)
+- [FIX] Removed use of sync.pool from HandleContext [#1565](https://github.com/gin-gonic/gin/pull/1565)
+- [FIX] Format output log to os.Stderr [#1571](https://github.com/gin-gonic/gin/pull/1571)
+- [FIX] Make logger use a yellow background and a darkgray text for legibility [#1570](https://github.com/gin-gonic/gin/pull/1570)
+- [FIX] Remove sensitive request information from panic log. [#1370](https://github.com/gin-gonic/gin/pull/1370)
+- [FIX] log.Println() does not print timestamp [#829](https://github.com/gin-gonic/gin/pull/829) [#1560](https://github.com/gin-gonic/gin/pull/1560)
+- [NEW] Add PureJSON renderer [#694](https://github.com/gin-gonic/gin/pull/694)
+- [FIX] Add missing copyright and update if/else [#1497](https://github.com/gin-gonic/gin/pull/1497)
+- [FIX] Update msgpack usage [#1498](https://github.com/gin-gonic/gin/pull/1498)
+- [FIX] Use protobuf on render [#1496](https://github.com/gin-gonic/gin/pull/1496)
+- [FIX] Add support for Protobuf format response [#1479](https://github.com/gin-gonic/gin/pull/1479)
+- [NEW] Set default time format in form binding [#1487](https://github.com/gin-gonic/gin/pull/1487)
+- [FIX] Add BindXML and ShouldBindXML [#1485](https://github.com/gin-gonic/gin/pull/1485)
+- [NEW] Upgrade dependency libraries [#1491](https://github.com/gin-gonic/gin/pull/1491)
+
+
+## Gin v1.3.0
- [NEW] Add [`func (*Context) QueryMap`](https://godoc.org/github.com/gin-gonic/gin#Context.QueryMap), [`func (*Context) GetQueryMap`](https://godoc.org/github.com/gin-gonic/gin#Context.GetQueryMap), [`func (*Context) PostFormMap`](https://godoc.org/github.com/gin-gonic/gin#Context.PostFormMap) and [`func (*Context) GetPostFormMap`](https://godoc.org/github.com/gin-gonic/gin#Context.GetPostFormMap) to support `type map[string]string` as query string or form parameters, see [#1383](https://github.com/gin-gonic/gin/pull/1383)
- [NEW] Add [`func (*Context) AsciiJSON`](https://godoc.org/github.com/gin-gonic/gin#Context.AsciiJSON), see [#1358](https://github.com/gin-gonic/gin/pull/1358)
@@ -22,7 +215,7 @@
- [FIX] Gin Mode `""` when calling [`func Mode`](https://godoc.org/github.com/gin-gonic/gin#Mode) now returns `const DebugMode`, see [#1250](https://github.com/gin-gonic/gin/pull/1250)
- [FIX] `Flush()` now doesn't overwrite `responseWriter` status code, see [#1460](https://github.com/gin-gonic/gin/pull/1460)
-### Gin 1.2.0
+## Gin 1.2.0
- [NEW] Switch from godeps to govendor
- [NEW] Add support for Let's Encrypt via gin-gonic/autotls
@@ -45,25 +238,25 @@
- [FIX] Use X-Forwarded-For before X-Real-Ip
- [FIX] time.Time binding (#904)
-### Gin 1.1.4
+## Gin 1.1.4
- [NEW] Support google appengine for IsTerminal func
-### Gin 1.1.3
+## Gin 1.1.3
- [FIX] Reverted Logger: skip ANSI color commands
-### Gin 1.1
+## Gin 1.1
-- [NEW] Implement QueryArray and PostArray methods
-- [NEW] Refactor GetQuery and GetPostForm
-- [NEW] Add contribution guide
+- [NEW] Implement QueryArray and PostArray methods
+- [NEW] Refactor GetQuery and GetPostForm
+- [NEW] Add contribution guide
- [FIX] Corrected typos in README
-- [FIX] Removed additional Iota
-- [FIX] Changed imports to gopkg instead of github in README (#733)
+- [FIX] Removed additional Iota
+- [FIX] Changed imports to gopkg instead of github in README (#733)
- [FIX] Logger: skip ANSI color commands if output is not a tty
-### Gin 1.0rc2 (...)
+## Gin 1.0rc2 (...)
- [PERFORMANCE] Fast path for writing Content-Type.
- [PERFORMANCE] Much faster 404 routing
@@ -98,7 +291,7 @@
- [FIX] MIT license in every file
-### Gin 1.0rc1 (May 22, 2015)
+## Gin 1.0rc1 (May 22, 2015)
- [PERFORMANCE] Zero allocation router
- [PERFORMANCE] Faster JSON, XML and text rendering
@@ -106,7 +299,7 @@
- [PERFORMANCE] Misc code optimizations. Inlining, tail call optimizations
- [NEW] Built-in support for golang.org/x/net/context
- [NEW] Any(path, handler). Create a route that matches any path
-- [NEW] Refactored rendering pipeline (faster and static typeded)
+- [NEW] Refactored rendering pipeline (faster and static typed)
- [NEW] Refactored errors API
- [NEW] IndentedJSON() prints pretty JSON
- [NEW] Added gin.DefaultWriter
@@ -142,7 +335,7 @@
- [FIX] Better support for Google App Engine (using log instead of fmt)
-### Gin 0.6 (Mar 9, 2015)
+## Gin 0.6 (Mar 9, 2015)
- [NEW] Support multipart/form-data
- [NEW] NoMethod handler
@@ -152,14 +345,14 @@
- [FIX] Improve color logger
-### Gin 0.5 (Feb 7, 2015)
+## Gin 0.5 (Feb 7, 2015)
- [NEW] Content Negotiation
- [FIX] Solved security bug that allow a client to spoof ip
- [FIX] Fix unexported/ignored fields in binding
-### Gin 0.4 (Aug 21, 2014)
+## Gin 0.4 (Aug 21, 2014)
- [NEW] Development mode
- [NEW] Unit tests
@@ -168,14 +361,14 @@
- [FIX] Improved documentation for model binding
-### Gin 0.3 (Jul 18, 2014)
+## Gin 0.3 (Jul 18, 2014)
- [PERFORMANCE] Normal log and error log are printed in the same call.
- [PERFORMANCE] Improve performance of NoRouter()
- [PERFORMANCE] Improve context's memory locality, reduce CPU cache faults.
- [NEW] Flexible rendering API
- [NEW] Add Context.File()
-- [NEW] Add shorcut RunTLS() for http.ListenAndServeTLS
+- [NEW] Add shortcut RunTLS() for http.ListenAndServeTLS
- [FIX] Rename NotFound404() to NoRoute()
- [FIX] Errors in context are purged
- [FIX] Adds HEAD method in Static file serving
@@ -186,7 +379,7 @@
- [FIX] Check application/x-www-form-urlencoded when parsing form
-### Gin 0.2b (Jul 08, 2014)
+## Gin 0.2b (Jul 08, 2014)
- [PERFORMANCE] Using sync.Pool to allocatio/gc overhead
- [NEW] Travis CI integration
- [NEW] Completely new logger
@@ -198,14 +391,14 @@
- [NEW] New Bind() and BindWith() methods for parsing request body.
- [NEW] Add Content.Copy()
- [NEW] Add context.LastError()
-- [NEW] Add shorcut for OPTIONS HTTP method
+- [NEW] Add shortcut for OPTIONS HTTP method
- [FIX] Tons of README fixes
- [FIX] Header is written before body
- [FIX] BasicAuth() and changes API a little bit
- [FIX] Recovery() middleware only prints panics
- [FIX] Context.Get() does not panic anymore. Use MustGet() instead.
- [FIX] Multiple http.WriteHeader() in NotFound handlers
-- [FIX] Engine.Run() panics if http server can't be setted up
+- [FIX] Engine.Run() panics if http server can't be set up
- [FIX] Crash when route path doesn't start with '/'
- [FIX] Do not update header when status code is negative
- [FIX] Setting response headers before calling WriteHeader in context.String()
diff --git a/vendor/github.com/gin-gonic/gin/CONTRIBUTING.md b/vendor/github.com/gin-gonic/gin/CONTRIBUTING.md
index 547b777..97daa80 100644
--- a/vendor/github.com/gin-gonic/gin/CONTRIBUTING.md
+++ b/vendor/github.com/gin-gonic/gin/CONTRIBUTING.md
@@ -1,4 +1,4 @@
-## Contributing
+## Contributing
- With issues:
- Use the search tool before opening a new issue.
@@ -8,6 +8,6 @@
- With pull requests:
- Open your pull request against `master`
- Your pull request should have no more than two commits, if not you should squash them.
- - It should pass all tests in the available continuous integrations systems such as TravisCI.
+ - It should pass all tests in the available continuous integration systems such as TravisCI.
- You should add/modify tests to cover your proposed code changes.
- If your pull request contains a new feature, please document it on the README.
diff --git a/vendor/github.com/gin-gonic/gin/Makefile b/vendor/github.com/gin-gonic/gin/Makefile
index 51b9969..1a99193 100644
--- a/vendor/github.com/gin-gonic/gin/Makefile
+++ b/vendor/github.com/gin-gonic/gin/Makefile
@@ -1,16 +1,32 @@
+GO ?= go
GOFMT ?= gofmt "-s"
-PACKAGES ?= $(shell go list ./... | grep -v /vendor/)
-VETPACKAGES ?= $(shell go list ./... | grep -v /vendor/ | grep -v /examples/)
-GOFILES := $(shell find . -name "*.go" -type f -not -path "./vendor/*")
-
-all: install
-
-install: deps
- govendor sync
+PACKAGES ?= $(shell $(GO) list ./...)
+VETPACKAGES ?= $(shell $(GO) list ./... | grep -v /examples/)
+GOFILES := $(shell find . -name "*.go")
+TESTFOLDER := $(shell $(GO) list ./... | grep -E 'gin$$|binding$$|render$$' | grep -v examples)
+TESTTAGS ?= ""
.PHONY: test
test:
- sh coverage.sh
+ echo "mode: count" > coverage.out
+ for d in $(TESTFOLDER); do \
+ $(GO) test -tags $(TESTTAGS) -v -covermode=count -coverprofile=profile.out $$d > tmp.out; \
+ cat tmp.out; \
+ if grep -q "^--- FAIL" tmp.out; then \
+ rm tmp.out; \
+ exit 1; \
+ elif grep -q "build failed" tmp.out; then \
+ rm tmp.out; \
+ exit 1; \
+ elif grep -q "setup failed" tmp.out; then \
+ rm tmp.out; \
+ exit 1; \
+ fi; \
+ if [ -f profile.out ]; then \
+ cat profile.out | grep -v "mode:" >> coverage.out; \
+ rm profile.out; \
+ fi; \
+ done
.PHONY: fmt
fmt:
@@ -18,7 +34,6 @@ fmt:
.PHONY: fmt-check
fmt-check:
- # get all go files and run go fmt on them
@diff=$$($(GOFMT) -d $(GOFILES)); \
if [ -n "$$diff" ]; then \
echo "Please run 'make fmt' and commit the result:"; \
@@ -27,36 +42,30 @@ fmt-check:
fi;
vet:
- go vet $(VETPACKAGES)
-
-deps:
- @hash govendor > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
- go get -u github.com/kardianos/govendor; \
- fi
- @hash embedmd > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
- go get -u github.com/campoy/embedmd; \
- fi
-
-embedmd:
- embedmd -d *.md
+ $(GO) vet $(VETPACKAGES)
.PHONY: lint
lint:
@hash golint > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
- go get -u github.com/golang/lint/golint; \
+ $(GO) get -u golang.org/x/lint/golint; \
fi
for PKG in $(PACKAGES); do golint -set_exit_status $$PKG || exit 1; done;
.PHONY: misspell-check
misspell-check:
@hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
- go get -u github.com/client9/misspell/cmd/misspell; \
+ $(GO) get -u github.com/client9/misspell/cmd/misspell; \
fi
misspell -error $(GOFILES)
.PHONY: misspell
misspell:
@hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
- go get -u github.com/client9/misspell/cmd/misspell; \
+ $(GO) get -u github.com/client9/misspell/cmd/misspell; \
fi
misspell -w $(GOFILES)
+
+.PHONY: tools
+tools:
+ go install golang.org/x/lint/golint; \
+ go install github.com/client9/misspell/cmd/misspell;
diff --git a/vendor/github.com/gin-gonic/gin/README.md b/vendor/github.com/gin-gonic/gin/README.md
index 28598ba..d4772d7 100644
--- a/vendor/github.com/gin-gonic/gin/README.md
+++ b/vendor/github.com/gin-gonic/gin/README.md
@@ -5,46 +5,61 @@
[](https://travis-ci.org/gin-gonic/gin)
[](https://codecov.io/gh/gin-gonic/gin)
[](https://goreportcard.com/report/github.com/gin-gonic/gin)
-[](https://godoc.org/github.com/gin-gonic/gin)
+[](https://pkg.go.dev/github.com/gin-gonic/gin?tab=doc)
[](https://gitter.im/gin-gonic/gin?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[](https://sourcegraph.com/github.com/gin-gonic/gin?badge)
[](https://www.codetriage.com/gin-gonic/gin)
+[](https://github.com/gin-gonic/gin/releases)
+[](https://www.tickgit.com/browse?repo=github.com/gin-gonic/gin)
-Gin is a web framework written in Go (Golang). It features a martini-like API with much better performance, up to 40 times faster thanks to [httprouter](https://github.com/julienschmidt/httprouter). If you need performance and good productivity, you will love Gin.
+Gin is a web framework written in Go (Golang). It features a martini-like API with performance that is up to 40 times faster thanks to [httprouter](https://github.com/julienschmidt/httprouter). If you need performance and good productivity, you will love Gin.
-
## Contents
-- [Installation](#installation)
-- [Prerequisite](#prerequisite)
-- [Quick start](#quick-start)
-- [Benchmarks](#benchmarks)
-- [Gin v1.stable](#gin-v1-stable)
-- [Build with jsoniter](#build-with-jsoniter)
-- [API Examples](#api-examples)
- - [Using GET,POST,PUT,PATCH,DELETE and OPTIONS](#using-get-post-put-patch-delete-and-options)
+- [Gin Web Framework](#gin-web-framework)
+ - [Contents](#contents)
+ - [Installation](#installation)
+ - [Quick start](#quick-start)
+ - [Benchmarks](#benchmarks)
+ - [Gin v1. stable](#gin-v1-stable)
+ - [Build with jsoniter](#build-with-jsoniter)
+ - [API Examples](#api-examples)
+ - [Using GET, POST, PUT, PATCH, DELETE and OPTIONS](#using-get-post-put-patch-delete-and-options)
- [Parameters in path](#parameters-in-path)
- [Querystring parameters](#querystring-parameters)
- [Multipart/Urlencoded Form](#multiparturlencoded-form)
- [Another example: query + post form](#another-example-query--post-form)
- [Map as querystring or postform parameters](#map-as-querystring-or-postform-parameters)
- [Upload files](#upload-files)
+ - [Single file](#single-file)
+ - [Multiple files](#multiple-files)
- [Grouping routes](#grouping-routes)
- [Blank Gin without middleware by default](#blank-gin-without-middleware-by-default)
- [Using middleware](#using-middleware)
- [How to write log file](#how-to-write-log-file)
+ - [Custom Log Format](#custom-log-format)
+ - [Controlling Log output coloring](#controlling-log-output-coloring)
- [Model binding and validation](#model-binding-and-validation)
- [Custom Validators](#custom-validators)
- [Only Bind Query String](#only-bind-query-string)
- [Bind Query String or Post Data](#bind-query-string-or-post-data)
+ - [Bind Uri](#bind-uri)
+ - [Bind Header](#bind-header)
- [Bind HTML checkboxes](#bind-html-checkboxes)
- [Multipart/Urlencoded binding](#multiparturlencoded-binding)
- - [XML, JSON and YAML rendering](#xml-json-and-yaml-rendering)
- - [JSONP rendering](#jsonp)
+ - [XML, JSON, YAML and ProtoBuf rendering](#xml-json-yaml-and-protobuf-rendering)
+ - [SecureJSON](#securejson)
+ - [JSONP](#jsonp)
+ - [AsciiJSON](#asciijson)
+ - [PureJSON](#purejson)
- [Serving static files](#serving-static-files)
+ - [Serving data from file](#serving-data-from-file)
- [Serving data from reader](#serving-data-from-reader)
- [HTML rendering](#html-rendering)
+ - [Custom Template renderer](#custom-template-renderer)
+ - [Custom Delimiters](#custom-delimiters)
+ - [Custom Template Funcs](#custom-template-funcs)
- [Multitemplate](#multitemplate)
- [Redirects](#redirects)
- [Custom Middleware](#custom-middleware)
@@ -53,19 +68,23 @@ Gin is a web framework written in Go (Golang). It features a martini-like API wi
- [Custom HTTP configuration](#custom-http-configuration)
- [Support Let's Encrypt](#support-lets-encrypt)
- [Run multiple service using Gin](#run-multiple-service-using-gin)
- - [Graceful restart or stop](#graceful-restart-or-stop)
+ - [Graceful shutdown or restart](#graceful-shutdown-or-restart)
+ - [Third-party packages](#third-party-packages)
+ - [Manually](#manually)
- [Build a single binary with templates](#build-a-single-binary-with-templates)
- [Bind form-data request with custom struct](#bind-form-data-request-with-custom-struct)
- [Try to bind body into different structs](#try-to-bind-body-into-different-structs)
- [http2 server push](#http2-server-push)
-- [Testing](#testing)
-- [Users](#users--)
+ - [Define format for the log of routes](#define-format-for-the-log-of-routes)
+ - [Set and get a cookie](#set-and-get-a-cookie)
+ - [Testing](#testing)
+ - [Users](#users)
## Installation
To install Gin package, you need to install Go and set your Go workspace first.
-1. Download and install it:
+1. The first need [Go](https://golang.org/) installed (**version 1.12+ is required**), then you can use the below Go command to install Gin.
```sh
$ go get -u github.com/gin-gonic/gin
@@ -83,44 +102,8 @@ import "github.com/gin-gonic/gin"
import "net/http"
```
-### Use a vendor tool like [Govendor](https://github.com/kardianos/govendor)
-
-1. `go get` govendor
-
-```sh
-$ go get github.com/kardianos/govendor
-```
-2. Create your project folder and `cd` inside
-
-```sh
-$ mkdir -p $GOPATH/src/github.com/myusername/project && cd "$_"
-```
-
-3. Vendor init your project and add gin
-
-```sh
-$ govendor init
-$ govendor fetch github.com/gin-gonic/gin@v1.2
-```
-
-4. Copy a starting template inside your project
-
-```sh
-$ curl https://raw.githubusercontent.com/gin-gonic/gin/master/examples/basic/main.go > main.go
-```
-
-5. Run your project
-
-```sh
-$ go run main.go
-```
-
-## Prerequisite
-
-Now Gin requires Go 1.6 or later and Go 1.7 will be required soon.
-
## Quick start
-
+
```sh
# assume the following codes in example.go file
$ cat example.go
@@ -138,12 +121,12 @@ func main() {
"message": "pong",
})
})
- r.Run() // listen and serve on 0.0.0.0:8080
+ r.Run() // listen and serve on 0.0.0.0:8080 (for windows "localhost:8080")
}
```
```
-# run example.go and visit 0.0.0.0:8080/ping on browser
+# run example.go and visit 0.0.0.0:8080/ping (for windows "localhost:8080/ping") on browser
$ go run example.go
```
@@ -153,35 +136,38 @@ Gin uses a custom version of [HttpRouter](https://github.com/julienschmidt/httpr
[See all benchmarks](/BENCHMARKS.md)
-Benchmark name | (1) | (2) | (3) | (4)
---------------------------------------------|-----------:|------------:|-----------:|---------:
-**BenchmarkGin_GithubAll** | **30000** | **48375** | **0** | **0**
-BenchmarkAce_GithubAll | 10000 | 134059 | 13792 | 167
-BenchmarkBear_GithubAll | 5000 | 534445 | 86448 | 943
-BenchmarkBeego_GithubAll | 3000 | 592444 | 74705 | 812
-BenchmarkBone_GithubAll | 200 | 6957308 | 698784 | 8453
-BenchmarkDenco_GithubAll | 10000 | 158819 | 20224 | 167
-BenchmarkEcho_GithubAll | 10000 | 154700 | 6496 | 203
-BenchmarkGocraftWeb_GithubAll | 3000 | 570806 | 131656 | 1686
-BenchmarkGoji_GithubAll | 2000 | 818034 | 56112 | 334
-BenchmarkGojiv2_GithubAll | 2000 | 1213973 | 274768 | 3712
-BenchmarkGoJsonRest_GithubAll | 2000 | 785796 | 134371 | 2737
-BenchmarkGoRestful_GithubAll | 300 | 5238188 | 689672 | 4519
-BenchmarkGorillaMux_GithubAll | 100 | 10257726 | 211840 | 2272
-BenchmarkHttpRouter_GithubAll | 20000 | 105414 | 13792 | 167
-BenchmarkHttpTreeMux_GithubAll | 10000 | 319934 | 65856 | 671
-BenchmarkKocha_GithubAll | 10000 | 209442 | 23304 | 843
-BenchmarkLARS_GithubAll | 20000 | 62565 | 0 | 0
-BenchmarkMacaron_GithubAll | 2000 | 1161270 | 204194 | 2000
-BenchmarkMartini_GithubAll | 200 | 9991713 | 226549 | 2325
-BenchmarkPat_GithubAll | 200 | 5590793 | 1499568 | 27435
-BenchmarkPossum_GithubAll | 10000 | 319768 | 84448 | 609
-BenchmarkR2router_GithubAll | 10000 | 305134 | 77328 | 979
-BenchmarkRivet_GithubAll | 10000 | 132134 | 16272 | 167
-BenchmarkTango_GithubAll | 3000 | 552754 | 63826 | 1618
-BenchmarkTigerTonic_GithubAll | 1000 | 1439483 | 239104 | 5374
-BenchmarkTraffic_GithubAll | 100 | 11383067 | 2659329 | 21848
-BenchmarkVulcan_GithubAll | 5000 | 394253 | 19894 | 609
+| Benchmark name | (1) | (2) | (3) | (4) |
+| ------------------------------ | ---------:| ---------------:| ------------:| ---------------:|
+| BenchmarkGin_GithubAll | **43550** | **27364 ns/op** | **0 B/op** | **0 allocs/op** |
+| BenchmarkAce_GithubAll | 40543 | 29670 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkAero_GithubAll | 57632 | 20648 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkBear_GithubAll | 9234 | 216179 ns/op | 86448 B/op | 943 allocs/op |
+| BenchmarkBeego_GithubAll | 7407 | 243496 ns/op | 71456 B/op | 609 allocs/op |
+| BenchmarkBone_GithubAll | 420 | 2922835 ns/op | 720160 B/op | 8620 allocs/op |
+| BenchmarkChi_GithubAll | 7620 | 238331 ns/op | 87696 B/op | 609 allocs/op |
+| BenchmarkDenco_GithubAll | 18355 | 64494 ns/op | 20224 B/op | 167 allocs/op |
+| BenchmarkEcho_GithubAll | 31251 | 38479 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkGocraftWeb_GithubAll | 4117 | 300062 ns/op | 131656 B/op | 1686 allocs/op |
+| BenchmarkGoji_GithubAll | 3274 | 416158 ns/op | 56112 B/op | 334 allocs/op |
+| BenchmarkGojiv2_GithubAll | 1402 | 870518 ns/op | 352720 B/op | 4321 allocs/op |
+| BenchmarkGoJsonRest_GithubAll | 2976 | 401507 ns/op | 134371 B/op | 2737 allocs/op |
+| BenchmarkGoRestful_GithubAll | 410 | 2913158 ns/op | 910144 B/op | 2938 allocs/op |
+| BenchmarkGorillaMux_GithubAll | 346 | 3384987 ns/op | 251650 B/op | 1994 allocs/op |
+| BenchmarkGowwwRouter_GithubAll | 10000 | 143025 ns/op | 72144 B/op | 501 allocs/op |
+| BenchmarkHttpRouter_GithubAll | 55938 | 21360 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkHttpTreeMux_GithubAll | 10000 | 153944 ns/op | 65856 B/op | 671 allocs/op |
+| BenchmarkKocha_GithubAll | 10000 | 106315 ns/op | 23304 B/op | 843 allocs/op |
+| BenchmarkLARS_GithubAll | 47779 | 25084 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkMacaron_GithubAll | 3266 | 371907 ns/op | 149409 B/op | 1624 allocs/op |
+| BenchmarkMartini_GithubAll | 331 | 3444706 ns/op | 226551 B/op | 2325 allocs/op |
+| BenchmarkPat_GithubAll | 273 | 4381818 ns/op | 1483152 B/op | 26963 allocs/op |
+| BenchmarkPossum_GithubAll | 10000 | 164367 ns/op | 84448 B/op | 609 allocs/op |
+| BenchmarkR2router_GithubAll | 10000 | 160220 ns/op | 77328 B/op | 979 allocs/op |
+| BenchmarkRivet_GithubAll | 14625 | 82453 ns/op | 16272 B/op | 167 allocs/op |
+| BenchmarkTango_GithubAll | 6255 | 279611 ns/op | 63826 B/op | 1618 allocs/op |
+| BenchmarkTigerTonic_GithubAll | 2008 | 687874 ns/op | 193856 B/op | 4474 allocs/op |
+| BenchmarkTraffic_GithubAll | 355 | 3478508 ns/op | 820744 B/op | 14114 allocs/op |
+| BenchmarkVulcan_GithubAll | 6885 | 193333 ns/op | 19894 B/op | 609 allocs/op |
- (1): Total Repetitions achieved in constant time, higher means more confident result
- (2): Single Repetition Duration (ns/op), lower is better
@@ -192,13 +178,13 @@ BenchmarkVulcan_GithubAll | 5000 | 394253 | 19894
- [x] Zero allocation router.
- [x] Still the fastest http router and framework. From routing to writing.
-- [x] Complete suite of unit tests
-- [x] Battle tested
+- [x] Complete suite of unit tests.
+- [x] Battle tested.
- [x] API frozen, new releases will not break your code.
## Build with [jsoniter](https://github.com/json-iterator/go)
-Gin use `encoding/json` as default json package but you can change to [jsoniter](https://github.com/json-iterator/go) by build from other tags.
+Gin uses `encoding/json` as default json package but you can change to [jsoniter](https://github.com/json-iterator/go) by build from other tags.
```sh
$ go build -tags=jsoniter .
@@ -206,13 +192,12 @@ $ go build -tags=jsoniter .
## API Examples
+You can find a number of ready-to-run examples at [Gin examples repository](https://github.com/gin-gonic/examples).
+
### Using GET, POST, PUT, PATCH, DELETE and OPTIONS
```go
func main() {
- // Disable Console Color
- // gin.DisableConsoleColor()
-
// Creates a gin router with default middleware:
// logger and recovery (crash-free) middleware
router := gin.Default()
@@ -253,6 +238,18 @@ func main() {
c.String(http.StatusOK, message)
})
+ // For each matched request Context will hold the route definition
+ router.POST("/user/:name/*action", func(c *gin.Context) {
+ c.FullPath() == "/user/:name/*action" // true
+ })
+
+ // This handler will add a new router for /user/groups.
+ // Exact routes are resolved before param routes, regardless of the order they were defined.
+ // Routes starting with /user/groups are never interpreted as /user/:name/... routes
+ router.GET("/user/groups", func(c *gin.Context) {
+ c.String(http.StatusOK, "The available groups are [...]", name)
+ })
+
router.Run(":8080")
}
```
@@ -350,27 +347,31 @@ func main() {
```
```
-ids: map[b:hello a:1234], names: map[second:tianou first:thinkerou]
+ids: map[b:hello a:1234]; names: map[second:tianou first:thinkerou]
```
### Upload files
#### Single file
-References issue [#774](https://github.com/gin-gonic/gin/issues/774) and detail [example code](examples/upload-file/single).
+References issue [#774](https://github.com/gin-gonic/gin/issues/774) and detail [example code](https://github.com/gin-gonic/examples/tree/master/upload-file/single).
+
+`file.Filename` **SHOULD NOT** be trusted. See [`Content-Disposition` on MDN](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition#Directives) and [#1693](https://github.com/gin-gonic/gin/issues/1693)
+
+> The filename is always optional and must not be used blindly by the application: path information should be stripped, and conversion to the server file system rules should be done.
```go
func main() {
router := gin.Default()
// Set a lower memory limit for multipart forms (default is 32 MiB)
- // router.MaxMultipartMemory = 8 << 20 // 8 MiB
+ router.MaxMultipartMemory = 8 << 20 // 8 MiB
router.POST("/upload", func(c *gin.Context) {
// single file
file, _ := c.FormFile("file")
log.Println(file.Filename)
// Upload the file to specific dst.
- // c.SaveUploadedFile(file, dst)
+ c.SaveUploadedFile(file, dst)
c.String(http.StatusOK, fmt.Sprintf("'%s' uploaded!", file.Filename))
})
@@ -388,13 +389,13 @@ curl -X POST http://localhost:8080/upload \
#### Multiple files
-See the detail [example code](examples/upload-file/multiple).
+See the detail [example code](https://github.com/gin-gonic/examples/tree/master/upload-file/multiple).
```go
func main() {
router := gin.Default()
// Set a lower memory limit for multipart forms (default is 32 MiB)
- // router.MaxMultipartMemory = 8 << 20 // 8 MiB
+ router.MaxMultipartMemory = 8 << 20 // 8 MiB
router.POST("/upload", func(c *gin.Context) {
// Multipart form
form, _ := c.MultipartForm()
@@ -404,7 +405,7 @@ func main() {
log.Println(file.Filename)
// Upload the file to specific dst.
- // c.SaveUploadedFile(file, dst)
+ c.SaveUploadedFile(file, dst)
}
c.String(http.StatusOK, fmt.Sprintf("%d files uploaded!", len(files)))
})
@@ -502,6 +503,39 @@ func main() {
}
```
+### Custom Recovery behavior
+```go
+func main() {
+ // Creates a router without any middleware by default
+ r := gin.New()
+
+ // Global middleware
+ // Logger middleware will write the logs to gin.DefaultWriter even if you set with GIN_MODE=release.
+ // By default gin.DefaultWriter = os.Stdout
+ r.Use(gin.Logger())
+
+ // Recovery middleware recovers from any panics and writes a 500 if there was one.
+ r.Use(gin.CustomRecovery(func(c *gin.Context, recovered interface{}) {
+ if err, ok := recovered.(string); ok {
+ c.String(http.StatusInternalServerError, fmt.Sprintf("error: %s", err))
+ }
+ c.AbortWithStatus(http.StatusInternalServerError)
+ }))
+
+ r.GET("/panic", func(c *gin.Context) {
+ // panic with a string -- the custom middleware could save this to a database or report it to the user
+ panic("foo")
+ })
+
+ r.GET("/", func(c *gin.Context) {
+ c.String(http.StatusOK, "ohai")
+ })
+
+ // Listen and serve on 0.0.0.0:8080
+ r.Run(":8080")
+}
+```
+
### How to write log file
```go
func main() {
@@ -524,20 +558,99 @@ func main() {
}
```
+### Custom Log Format
+```go
+func main() {
+ router := gin.New()
+
+ // LoggerWithFormatter middleware will write the logs to gin.DefaultWriter
+ // By default gin.DefaultWriter = os.Stdout
+ router.Use(gin.LoggerWithFormatter(func(param gin.LogFormatterParams) string {
+
+ // your custom format
+ return fmt.Sprintf("%s - [%s] \"%s %s %s %d %s \"%s\" %s\"\n",
+ param.ClientIP,
+ param.TimeStamp.Format(time.RFC1123),
+ param.Method,
+ param.Path,
+ param.Request.Proto,
+ param.StatusCode,
+ param.Latency,
+ param.Request.UserAgent(),
+ param.ErrorMessage,
+ )
+ }))
+ router.Use(gin.Recovery())
+
+ router.GET("/ping", func(c *gin.Context) {
+ c.String(200, "pong")
+ })
+
+ router.Run(":8080")
+}
+```
+
+**Sample Output**
+```
+::1 - [Fri, 07 Dec 2018 17:04:38 JST] "GET /ping HTTP/1.1 200 122.767µs "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.80 Safari/537.36" "
+```
+
+### Controlling Log output coloring
+
+By default, logs output on console should be colorized depending on the detected TTY.
+
+Never colorize logs:
+
+```go
+func main() {
+ // Disable log's color
+ gin.DisableConsoleColor()
+
+ // Creates a gin router with default middleware:
+ // logger and recovery (crash-free) middleware
+ router := gin.Default()
+
+ router.GET("/ping", func(c *gin.Context) {
+ c.String(200, "pong")
+ })
+
+ router.Run(":8080")
+}
+```
+
+Always colorize logs:
+
+```go
+func main() {
+ // Force log's color
+ gin.ForceConsoleColor()
+
+ // Creates a gin router with default middleware:
+ // logger and recovery (crash-free) middleware
+ router := gin.Default()
+
+ router.GET("/ping", func(c *gin.Context) {
+ c.String(200, "pong")
+ })
+
+ router.Run(":8080")
+}
+```
+
### Model binding and validation
-To bind a request body into a type, use model binding. We currently support binding of JSON, XML and standard form values (foo=bar&boo=baz).
+To bind a request body into a type, use model binding. We currently support binding of JSON, XML, YAML and standard form values (foo=bar&boo=baz).
-Gin uses [**go-playground/validator.v8**](https://github.com/go-playground/validator) for validation. Check the full docs on tags usage [here](http://godoc.org/gopkg.in/go-playground/validator.v8#hdr-Baked_In_Validators_and_Tags).
+Gin uses [**go-playground/validator/v10**](https://github.com/go-playground/validator) for validation. Check the full docs on tags usage [here](https://godoc.org/github.com/go-playground/validator#hdr-Baked_In_Validators_and_Tags).
Note that you need to set the corresponding binding tag on all fields you want to bind. For example, when binding from JSON, set `json:"fieldname"`.
Also, Gin provides two sets of methods for binding:
- **Type** - Must bind
- - **Methods** - `Bind`, `BindJSON`, `BindQuery`
+ - **Methods** - `Bind`, `BindJSON`, `BindXML`, `BindQuery`, `BindYAML`, `BindHeader`
- **Behavior** - These methods use `MustBindWith` under the hood. If there is a binding error, the request is aborted with `c.AbortWithError(400, err).SetType(ErrorTypeBind)`. This sets the response status code to 400 and the `Content-Type` header is set to `text/plain; charset=utf-8`. Note that if you try to set the response code after this, it will result in a warning `[GIN-debug] [WARNING] Headers were already written. Wanted to override status code 400 with 422`. If you wish to have greater control over the behavior, consider using the `ShouldBind` equivalent method.
- **Type** - Should bind
- - **Methods** - `ShouldBind`, `ShouldBindJSON`, `ShouldBindQuery`
+ - **Methods** - `ShouldBind`, `ShouldBindJSON`, `ShouldBindXML`, `ShouldBindQuery`, `ShouldBindYAML`, `ShouldBindHeader`
- **Behavior** - These methods use `ShouldBindWith` under the hood. If there is a binding error, the error is returned and it is the developer's responsibility to handle the request and error appropriately.
When using the Bind-method, Gin tries to infer the binder depending on the Content-Type header. If you are sure what you are binding, you can use `MustBindWith` or `ShouldBindWith`.
@@ -547,8 +660,8 @@ You can also specify that specific fields are required. If a field is decorated
```go
// Binding from JSON
type Login struct {
- User string `form:"user" json:"user" binding:"required"`
- Password string `form:"password" json:"password" binding:"required"`
+ User string `form:"user" json:"user" xml:"user" binding:"required"`
+ Password string `form:"password" json:"password" xml:"password" binding:"required"`
}
func main() {
@@ -557,30 +670,55 @@ func main() {
// Example for binding JSON ({"user": "manu", "password": "123"})
router.POST("/loginJSON", func(c *gin.Context) {
var json Login
- if err := c.ShouldBindJSON(&json); err == nil {
- if json.User == "manu" && json.Password == "123" {
- c.JSON(http.StatusOK, gin.H{"status": "you are logged in"})
- } else {
- c.JSON(http.StatusUnauthorized, gin.H{"status": "unauthorized"})
- }
- } else {
+ if err := c.ShouldBindJSON(&json); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
+ return
+ }
+
+ if json.User != "manu" || json.Password != "123" {
+ c.JSON(http.StatusUnauthorized, gin.H{"status": "unauthorized"})
+ return
+ }
+
+ c.JSON(http.StatusOK, gin.H{"status": "you are logged in"})
+ })
+
+ // Example for binding XML (
+ //
+ //
+ // user
+ // 123
+ // )
+ router.POST("/loginXML", func(c *gin.Context) {
+ var xml Login
+ if err := c.ShouldBindXML(&xml); err != nil {
+ c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
+ return
+ }
+
+ if xml.User != "manu" || xml.Password != "123" {
+ c.JSON(http.StatusUnauthorized, gin.H{"status": "unauthorized"})
+ return
}
+
+ c.JSON(http.StatusOK, gin.H{"status": "you are logged in"})
})
// Example for binding a HTML form (user=manu&password=123)
router.POST("/loginForm", func(c *gin.Context) {
var form Login
// This will infer what binder to use depending on the content-type header.
- if err := c.ShouldBind(&form); err == nil {
- if form.User == "manu" && form.Password == "123" {
- c.JSON(http.StatusOK, gin.H{"status": "you are logged in"})
- } else {
- c.JSON(http.StatusUnauthorized, gin.H{"status": "unauthorized"})
- }
- } else {
+ if err := c.ShouldBind(&form); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
+ return
}
+
+ if form.User != "manu" || form.Password != "123" {
+ c.JSON(http.StatusUnauthorized, gin.H{"status": "unauthorized"})
+ return
+ }
+
+ c.JSON(http.StatusOK, gin.H{"status": "you are logged in"})
})
// Listen and serve on 0.0.0.0:8080
@@ -616,34 +754,31 @@ When running the above example using the above the `curl` command, it returns er
### Custom Validators
-It is also possible to register custom validators. See the [example code](examples/custom-validation/server.go).
+It is also possible to register custom validators. See the [example code](https://github.com/gin-gonic/examples/tree/master/custom-validation/server.go).
-[embedmd]:# (examples/custom-validation/server.go go)
```go
package main
import (
"net/http"
- "reflect"
"time"
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin/binding"
- "gopkg.in/go-playground/validator.v8"
+ "github.com/go-playground/validator/v10"
)
+// Booking contains binded and validated data.
type Booking struct {
CheckIn time.Time `form:"check_in" binding:"required,bookabledate" time_format:"2006-01-02"`
CheckOut time.Time `form:"check_out" binding:"required,gtfield=CheckIn" time_format:"2006-01-02"`
}
-func bookableDate(
- v *validator.Validate, topStruct reflect.Value, currentStructOrField reflect.Value,
- field reflect.Value, fieldType reflect.Type, fieldKind reflect.Kind, param string,
-) bool {
- if date, ok := field.Interface().(time.Time); ok {
+var bookableDate validator.Func = func(fl validator.FieldLevel) bool {
+ date, ok := fl.Field().Interface().(time.Time)
+ if ok {
today := time.Now()
- if today.Year() > date.Year() || today.YearDay() > date.YearDay() {
+ if today.After(date) {
return false
}
}
@@ -672,15 +807,18 @@ func getBookable(c *gin.Context) {
```
```console
-$ curl "localhost:8085/bookable?check_in=2018-04-16&check_out=2018-04-17"
+$ curl "localhost:8085/bookable?check_in=2030-04-16&check_out=2030-04-17"
{"message":"Booking dates are valid!"}
-$ curl "localhost:8085/bookable?check_in=2018-03-08&check_out=2018-03-09"
-{"error":"Key: 'Booking.CheckIn' Error:Field validation for 'CheckIn' failed on the 'bookabledate' tag"}
+$ curl "localhost:8085/bookable?check_in=2030-03-10&check_out=2030-03-09"
+{"error":"Key: 'Booking.CheckOut' Error:Field validation for 'CheckOut' failed on the 'gtfield' tag"}
+
+$ curl "localhost:8085/bookable?check_in=2000-03-09&check_out=2000-03-10"
+{"error":"Key: 'Booking.CheckIn' Error:Field validation for 'CheckIn' failed on the 'bookabledate' tag"}%
```
-[Struct level validations](https://github.com/go-playground/validator/releases/tag/v8.7) can also be registed this way.
-See the [struct-lvl-validation example](examples/struct-lvl-validations) to learn more.
+[Struct level validations](https://github.com/go-playground/validator/releases/tag/v8.7) can also be registered this way.
+See the [struct-lvl-validation example](https://github.com/gin-gonic/examples/tree/master/struct-lvl-validations) to learn more.
### Only Bind Query String
@@ -725,14 +863,19 @@ See the [detail information](https://github.com/gin-gonic/gin/issues/742#issueco
```go
package main
-import "log"
-import "github.com/gin-gonic/gin"
-import "time"
+import (
+ "log"
+ "time"
+
+ "github.com/gin-gonic/gin"
+)
type Person struct {
- Name string `form:"name"`
- Address string `form:"address"`
- Birthday time.Time `form:"birthday" time_format:"2006-01-02" time_utc:"1"`
+ Name string `form:"name"`
+ Address string `form:"address"`
+ Birthday time.Time `form:"birthday" time_format:"2006-01-02" time_utc:"1"`
+ CreateTime time.Time `form:"createTime" time_format:"unixNano"`
+ UnixTime time.Time `form:"unixTime" time_format:"unix"`
}
func main() {
@@ -746,11 +889,13 @@ func startPage(c *gin.Context) {
// If `GET`, only `Form` binding engine (`query`) used.
// If `POST`, first checks the `content-type` for `JSON` or `XML`, then uses `Form` (`form-data`).
// See more at https://github.com/gin-gonic/gin/blob/master/binding/binding.go#L48
- if c.ShouldBind(&person) == nil {
- log.Println(person.Name)
- log.Println(person.Address)
- log.Println(person.Birthday)
- }
+ if c.ShouldBind(&person) == nil {
+ log.Println(person.Name)
+ log.Println(person.Address)
+ log.Println(person.Birthday)
+ log.Println(person.CreateTime)
+ log.Println(person.UnixTime)
+ }
c.String(200, "Success")
}
@@ -758,7 +903,78 @@ func startPage(c *gin.Context) {
Test it with:
```sh
-$ curl -X GET "localhost:8085/testing?name=appleboy&address=xyz&birthday=1992-03-15"
+$ curl -X GET "localhost:8085/testing?name=appleboy&address=xyz&birthday=1992-03-15&createTime=1562400033000000123&unixTime=1562400033"
+```
+
+### Bind Uri
+
+See the [detail information](https://github.com/gin-gonic/gin/issues/846).
+
+```go
+package main
+
+import "github.com/gin-gonic/gin"
+
+type Person struct {
+ ID string `uri:"id" binding:"required,uuid"`
+ Name string `uri:"name" binding:"required"`
+}
+
+func main() {
+ route := gin.Default()
+ route.GET("/:name/:id", func(c *gin.Context) {
+ var person Person
+ if err := c.ShouldBindUri(&person); err != nil {
+ c.JSON(400, gin.H{"msg": err})
+ return
+ }
+ c.JSON(200, gin.H{"name": person.Name, "uuid": person.ID})
+ })
+ route.Run(":8088")
+}
+```
+
+Test it with:
+```sh
+$ curl -v localhost:8088/thinkerou/987fbc97-4bed-5078-9f07-9141ba07c9f3
+$ curl -v localhost:8088/thinkerou/not-uuid
+```
+
+### Bind Header
+
+```go
+package main
+
+import (
+ "fmt"
+ "github.com/gin-gonic/gin"
+)
+
+type testHeader struct {
+ Rate int `header:"Rate"`
+ Domain string `header:"Domain"`
+}
+
+func main() {
+ r := gin.Default()
+ r.GET("/", func(c *gin.Context) {
+ h := testHeader{}
+
+ if err := c.ShouldBindHeader(&h); err != nil {
+ c.JSON(200, err)
+ }
+
+ fmt.Printf("%#v\n", h)
+ c.JSON(200, gin.H{"Rate": h.Rate, "Domain": h.Domain})
+ })
+
+ r.Run()
+
+// client
+// curl -H "rate:300" -H "domain:music" 127.0.0.1:8080/
+// output
+// {"Domain":"music","Rate":300}
+}
```
### Bind HTML checkboxes
@@ -792,12 +1008,12 @@ form.html
```
@@ -810,32 +1026,36 @@ result:
### Multipart/Urlencoded binding
```go
-package main
-
-import (
- "github.com/gin-gonic/gin"
-)
+type ProfileForm struct {
+ Name string `form:"name" binding:"required"`
+ Avatar *multipart.FileHeader `form:"avatar" binding:"required"`
-type LoginForm struct {
- User string `form:"user" binding:"required"`
- Password string `form:"password" binding:"required"`
+ // or for multiple files
+ // Avatars []*multipart.FileHeader `form:"avatar" binding:"required"`
}
func main() {
router := gin.Default()
- router.POST("/login", func(c *gin.Context) {
+ router.POST("/profile", func(c *gin.Context) {
// you can bind multipart form with explicit binding declaration:
// c.ShouldBindWith(&form, binding.Form)
// or you can simply use autobinding with ShouldBind method:
- var form LoginForm
+ var form ProfileForm
// in this case proper binding will be automatically selected
- if c.ShouldBind(&form) == nil {
- if form.User == "user" && form.Password == "password" {
- c.JSON(200, gin.H{"status": "you are logged in"})
- } else {
- c.JSON(401, gin.H{"status": "unauthorized"})
- }
+ if err := c.ShouldBind(&form); err != nil {
+ c.String(http.StatusBadRequest, "bad request")
+ return
}
+
+ err := c.SaveUploadedFile(form.Avatar, form.Avatar.Filename)
+ if err != nil {
+ c.String(http.StatusInternalServerError, "unknown error")
+ return
+ }
+
+ // db.Save(&form)
+
+ c.String(http.StatusOK, "ok")
})
router.Run(":8080")
}
@@ -843,10 +1063,10 @@ func main() {
Test it with:
```sh
-$ curl -v --form user=user --form password=password http://localhost:8080/login
+$ curl -X POST -v --form name=user --form "avatar=@./avatar.png" http://localhost:8080/profile
```
-### XML, JSON and YAML rendering
+### XML, JSON, YAML and ProtoBuf rendering
```go
func main() {
@@ -880,6 +1100,19 @@ func main() {
c.YAML(http.StatusOK, gin.H{"message": "hey", "status": http.StatusOK})
})
+ r.GET("/someProtoBuf", func(c *gin.Context) {
+ reps := []int64{int64(1), int64(2)}
+ label := "test"
+ // The specific definition of protobuf is written in the testdata/protoexample file.
+ data := &protoexample.Test{
+ Label: &label,
+ Reps: reps,
+ }
+ // Note that data becomes binary data in the response
+ // Will output protoexample.Test protobuf serialized data
+ c.ProtoBuf(http.StatusOK, data)
+ })
+
// Listen and serve on 0.0.0.0:8080
r.Run(":8080")
}
@@ -915,11 +1148,11 @@ Using JSONP to request data from a server in a different domain. Add callback t
func main() {
r := gin.Default()
- r.GET("/JSONP?callback=x", func(c *gin.Context) {
- data := map[string]interface{}{
+ r.GET("/JSONP", func(c *gin.Context) {
+ data := gin.H{
"foo": "bar",
}
-
+
//callback is x
// Will output : x({\"foo\":\"bar\"})
c.JSONP(http.StatusOK, data)
@@ -927,19 +1160,22 @@ func main() {
// Listen and serve on 0.0.0.0:8080
r.Run(":8080")
+
+ // client
+ // curl http://127.0.0.1:8080/JSONP?callback=x
}
```
#### AsciiJSON
-Using AsciiJSON to Generates ASCII-only JSON with escaped non-ASCII chracters.
+Using AsciiJSON to Generates ASCII-only JSON with escaped non-ASCII characters.
```go
func main() {
r := gin.Default()
r.GET("/someJSON", func(c *gin.Context) {
- data := map[string]interface{}{
+ data := gin.H{
"lang": "GO语言",
"tag": "
",
}
@@ -953,6 +1189,34 @@ func main() {
}
```
+#### PureJSON
+
+Normally, JSON replaces special HTML characters with their unicode entities, e.g. `<` becomes `\u003c`. If you want to encode such characters literally, you can use PureJSON instead.
+This feature is unavailable in Go 1.6 and lower.
+
+```go
+func main() {
+ r := gin.Default()
+
+ // Serves unicode entities
+ r.GET("/json", func(c *gin.Context) {
+ c.JSON(200, gin.H{
+ "html": "Hello, world!",
+ })
+ })
+
+ // Serves literal characters
+ r.GET("/purejson", func(c *gin.Context) {
+ c.PureJSON(200, gin.H{
+ "html": "Hello, world!",
+ })
+ })
+
+ // listen and serve on 0.0.0.0:8080
+ r.Run(":8080")
+}
+```
+
### Serving static files
```go
@@ -967,6 +1231,24 @@ func main() {
}
```
+### Serving data from file
+
+```go
+func main() {
+ router := gin.Default()
+
+ router.GET("/local/file", func(c *gin.Context) {
+ c.File("local/file.go")
+ })
+
+ var fs http.FileSystem = // ...
+ router.GET("/fs/file", func(c *gin.Context) {
+ c.FileFromFS("fs/file.go", fs)
+ })
+}
+
+```
+
### Serving data from reader
```go
@@ -980,6 +1262,7 @@ func main() {
}
reader := response.Body
+ defer reader.Close()
contentLength := response.ContentLength
contentType := response.Header.Get("Content-Type")
@@ -1087,12 +1370,12 @@ You may use custom delims
```go
r := gin.Default()
r.Delims("{[{", "}]}")
- r.LoadHTMLGlob("/path/to/templates"))
+ r.LoadHTMLGlob("/path/to/templates")
```
#### Custom Template Funcs
-See the detail [example code](examples/template).
+See the detail [example code](https://github.com/gin-gonic/examples/tree/master/template).
main.go
@@ -1120,7 +1403,7 @@ func main() {
router.LoadHTMLFiles("./testdata/template/raw.tmpl")
router.GET("/raw", func(c *gin.Context) {
- c.HTML(http.StatusOK, "raw.tmpl", map[string]interface{}{
+ c.HTML(http.StatusOK, "raw.tmpl", gin.H{
"now": time.Date(2017, 07, 01, 0, 0, 0, 0, time.UTC),
})
})
@@ -1155,6 +1438,12 @@ r.GET("/test", func(c *gin.Context) {
})
```
+Issuing a HTTP redirect from POST. Refer to issue: [#444](https://github.com/gin-gonic/gin/issues/444)
+```go
+r.POST("/test", func(c *gin.Context) {
+ c.Redirect(http.StatusFound, "/foo")
+})
+```
Issuing a Router redirect, use `HandleContext` like below.
@@ -1312,7 +1601,6 @@ func main() {
example for 1-line LetsEncrypt HTTPS servers.
-[embedmd]:# (examples/auto-tls/example1/main.go go)
```go
package main
@@ -1337,7 +1625,6 @@ func main() {
example for custom autocert manager.
-[embedmd]:# (examples/auto-tls/example2/main.go go)
```go
package main
@@ -1371,7 +1658,6 @@ func main() {
See the [question](https://github.com/gin-gonic/gin/issues/346) and try the following example:
-[embedmd]:# (examples/multiple-service/main.go go)
```go
package main
@@ -1436,11 +1722,19 @@ func main() {
}
g.Go(func() error {
- return server01.ListenAndServe()
+ err := server01.ListenAndServe()
+ if err != nil && err != http.ErrServerClosed {
+ log.Fatal(err)
+ }
+ return err
})
g.Go(func() error {
- return server02.ListenAndServe()
+ err := server02.ListenAndServe()
+ if err != nil && err != http.ErrServerClosed {
+ log.Fatal(err)
+ }
+ return err
})
if err := g.Wait(); err != nil {
@@ -1449,12 +1743,13 @@ func main() {
}
```
-### Graceful restart or stop
+### Graceful shutdown or restart
+
+There are a few approaches you can use to perform a graceful shutdown or restart. You can make use of third-party packages specifically built for that, or you can manually do the same with the functions and methods from the built-in packages.
-Do you want to graceful restart or stop your web server?
-There are some ways this can be done.
+#### Third-party packages
-We can use [fvbock/endless](https://github.com/fvbock/endless) to replace the default `ListenAndServe`. Refer issue [#296](https://github.com/gin-gonic/gin/issues/296) for more details.
+We can use [fvbock/endless](https://github.com/fvbock/endless) to replace the default `ListenAndServe`. Refer to issue [#296](https://github.com/gin-gonic/gin/issues/296) for more details.
```go
router := gin.Default()
@@ -1463,15 +1758,16 @@ router.GET("/", handler)
endless.ListenAndServe(":4242", router)
```
-An alternative to endless:
+Alternatives:
* [manners](https://github.com/braintree/manners): A polite Go HTTP server that shuts down gracefully.
* [graceful](https://github.com/tylerb/graceful): Graceful is a Go package enabling graceful shutdown of an http.Handler server.
* [grace](https://github.com/facebookgo/grace): Graceful restart & zero downtime deploy for Go servers.
-If you are using Go 1.8, you may not need to use this library! Consider using http.Server's built-in [Shutdown()](https://golang.org/pkg/net/http/#Server.Shutdown) method for graceful shutdowns. See the full [graceful-shutdown](./examples/graceful-shutdown) example with gin.
+#### Manually
+
+In case you are using Go 1.8 or a later version, you may not need to use those libraries. Consider using `http.Server`'s built-in [Shutdown()](https://golang.org/pkg/net/http/#Server.Shutdown) method for graceful shutdowns. The example below describes its usage, and we've got more examples using gin [here](https://github.com/gin-gonic/examples/tree/master/graceful-shutdown).
-[embedmd]:# (examples/graceful-shutdown/graceful-shutdown/server.go go)
```go
// +build go1.8
@@ -1483,6 +1779,7 @@ import (
"net/http"
"os"
"os/signal"
+ "syscall"
"time"
"github.com/gin-gonic/gin"
@@ -1500,25 +1797,33 @@ func main() {
Handler: router,
}
+ // Initializing the server in a goroutine so that
+ // it won't block the graceful shutdown handling below
go func() {
- // service connections
- if err := srv.ListenAndServe(); err != nil && err != http.ErrServerClosed {
- log.Fatalf("listen: %s\n", err)
+ if err := srv.ListenAndServe(); err != nil && errors.Is(err, http.ErrServerClosed) {
+ log.Printf("listen: %s\n", err)
}
}()
// Wait for interrupt signal to gracefully shutdown the server with
// a timeout of 5 seconds.
quit := make(chan os.Signal)
- signal.Notify(quit, os.Interrupt)
+ // kill (no param) default send syscall.SIGTERM
+ // kill -2 is syscall.SIGINT
+ // kill -9 is syscall.SIGKILL but can't be catch, so don't need add it
+ signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
<-quit
- log.Println("Shutdown Server ...")
+ log.Println("Shutting down server...")
+ // The context is used to inform the server it has 5 seconds to finish
+ // the request it is currently handling
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
+
if err := srv.Shutdown(ctx); err != nil {
- log.Fatal("Server Shutdown:", err)
+ log.Fatal("Server forced to shutdown:", err)
}
+
log.Println("Server exiting")
}
```
@@ -1549,6 +1854,7 @@ func main() {
func loadTemplate() (*template.Template, error) {
t := template.New("")
for name, file := range Assets.Files {
+ defer file.Close()
if file.IsDir() || !strings.HasSuffix(name, ".tmpl") {
continue
}
@@ -1565,7 +1871,7 @@ func loadTemplate() (*template.Template, error) {
}
```
-See a complete example in the `examples/assets-in-binary` directory.
+See a complete example in the `https://github.com/gin-gonic/examples/tree/master/assets-in-binary` directory.
### Bind form-data request with custom struct
@@ -1641,24 +1947,6 @@ $ curl "http://localhost:8080/getd?field_x=hello&field_d=world"
{"d":"world","x":{"FieldX":"hello"}}
```
-**NOTE**: NOT support the follow style struct:
-
-```go
-type StructX struct {
- X struct {} `form:"name_x"` // HERE have form
-}
-
-type StructY struct {
- Y StructX `form:"name_y"` // HERE hava form
-}
-
-type StructZ struct {
- Z *StructZ `form:"name_z"` // HERE hava form
-}
-```
-
-In a word, only support nested custom struct which have no `form` now.
-
### Try to bind body into different structs
The normal methods for binding request body consumes `c.Request.Body` and they
@@ -1721,7 +2009,6 @@ performance (See [#1341](https://github.com/gin-gonic/gin/pull/1341)).
http.Pusher is supported only **go1.8+**. See the [golang blog](https://blog.golang.org/h2push) for detail information.
-[embedmd]:# (examples/http-pusher/main.go go)
```go
package main
@@ -1766,6 +2053,111 @@ func main() {
}
```
+### Define format for the log of routes
+
+The default log of routes is:
+```
+[GIN-debug] POST /foo --> main.main.func1 (3 handlers)
+[GIN-debug] GET /bar --> main.main.func2 (3 handlers)
+[GIN-debug] GET /status --> main.main.func3 (3 handlers)
+```
+
+If you want to log this information in given format (e.g. JSON, key values or something else), then you can define this format with `gin.DebugPrintRouteFunc`.
+In the example below, we log all routes with standard log package but you can use another log tools that suits of your needs.
+```go
+import (
+ "log"
+ "net/http"
+
+ "github.com/gin-gonic/gin"
+)
+
+func main() {
+ r := gin.Default()
+ gin.DebugPrintRouteFunc = func(httpMethod, absolutePath, handlerName string, nuHandlers int) {
+ log.Printf("endpoint %v %v %v %v\n", httpMethod, absolutePath, handlerName, nuHandlers)
+ }
+
+ r.POST("/foo", func(c *gin.Context) {
+ c.JSON(http.StatusOK, "foo")
+ })
+
+ r.GET("/bar", func(c *gin.Context) {
+ c.JSON(http.StatusOK, "bar")
+ })
+
+ r.GET("/status", func(c *gin.Context) {
+ c.JSON(http.StatusOK, "ok")
+ })
+
+ // Listen and Server in http://0.0.0.0:8080
+ r.Run()
+}
+```
+
+### Set and get a cookie
+
+```go
+import (
+ "fmt"
+
+ "github.com/gin-gonic/gin"
+)
+
+func main() {
+
+ router := gin.Default()
+
+ router.GET("/cookie", func(c *gin.Context) {
+
+ cookie, err := c.Cookie("gin_cookie")
+
+ if err != nil {
+ cookie = "NotSet"
+ c.SetCookie("gin_cookie", "test", 3600, "/", "localhost", false, true)
+ }
+
+ fmt.Printf("Cookie value: %s \n", cookie)
+ })
+
+ router.Run()
+}
+```
+
+## Don't trust all proxies
+
+Gin lets you specify which headers to hold the real client IP (if any),
+as well as specifying which proxies (or direct clients) you trust to
+specify one of these headers.
+
+The `TrustedProxies` slice on your `gin.Engine` specifes network addresses or
+network CIDRs from where clients which their request headers related to client
+IP can be trusted. They can be IPv4 addresses, IPv4 CIDRs, IPv6 addresses or
+IPv6 CIDRs.
+
+```go
+import (
+ "fmt"
+
+ "github.com/gin-gonic/gin"
+)
+
+func main() {
+
+ router := gin.Default()
+ router.TrustedProxies = []string{"192.168.1.2"}
+
+ router.GET("/", func(c *gin.Context) {
+ // If the client is 192.168.1.2, use the X-Forwarded-For
+ // header to deduce the original client IP from the trust-
+ // worthy parts of that header.
+ // Otherwise, simply return the direct client IP
+ fmt.Printf("ClientIP: %s\n", c.ClientIP())
+ })
+ router.Run()
+}
+```
+
## Testing
The `net/http/httptest` package is preferable way for HTTP testing.
@@ -1816,5 +2208,10 @@ func TestPingRoute(t *testing.T) {
Awesome project lists using [Gin](https://github.com/gin-gonic/gin) web framework.
-* [drone](https://github.com/drone/drone): Drone is a Continuous Delivery platform built on Docker, written in Go
* [gorush](https://github.com/appleboy/gorush): A push notification server written in Go.
+* [fnproject](https://github.com/fnproject/fn): The container native, cloud agnostic serverless platform.
+* [photoprism](https://github.com/photoprism/photoprism): Personal photo management powered by Go and Google TensorFlow.
+* [krakend](https://github.com/devopsfaith/krakend): Ultra performant API Gateway with middlewares.
+* [picfit](https://github.com/thoas/picfit): An image resizing server written in Go.
+* [brigade](https://github.com/brigadecore/brigade): Event-based Scripting for Kubernetes.
+* [dkron](https://github.com/distribworks/dkron): Distributed, fault tolerant job scheduling system.
diff --git a/vendor/github.com/gin-gonic/gin/auth.go b/vendor/github.com/gin-gonic/gin/auth.go
index 9ed81b5..4d8a6ce 100644
--- a/vendor/github.com/gin-gonic/gin/auth.go
+++ b/vendor/github.com/gin-gonic/gin/auth.go
@@ -9,6 +9,8 @@ import (
"encoding/base64"
"net/http"
"strconv"
+
+ "github.com/gin-gonic/gin/internal/bytesconv"
)
// AuthUserKey is the cookie name for user credential in basic auth.
@@ -29,7 +31,7 @@ func (a authPairs) searchCredential(authValue string) (string, bool) {
return "", false
}
for _, pair := range a {
- if pair.value == authValue {
+ if subtle.ConstantTimeCompare([]byte(pair.value), []byte(authValue)) == 1 {
return pair.user, true
}
}
@@ -69,8 +71,9 @@ func BasicAuth(accounts Accounts) HandlerFunc {
}
func processAccounts(accounts Accounts) authPairs {
- assert1(len(accounts) > 0, "Empty list of authorized credentials")
- pairs := make(authPairs, 0, len(accounts))
+ length := len(accounts)
+ assert1(length > 0, "Empty list of authorized credentials")
+ pairs := make(authPairs, 0, length)
for user, password := range accounts {
assert1(user != "", "User can not be empty")
value := authorizationHeader(user, password)
@@ -84,13 +87,5 @@ func processAccounts(accounts Accounts) authPairs {
func authorizationHeader(user, password string) string {
base := user + ":" + password
- return "Basic " + base64.StdEncoding.EncodeToString([]byte(base))
-}
-
-func secureCompare(given, actual string) bool {
- if subtle.ConstantTimeEq(int32(len(given)), int32(len(actual))) == 1 {
- return subtle.ConstantTimeCompare([]byte(given), []byte(actual)) == 1
- }
- // Securely compare actual to itself to keep constant time, but always return false.
- return subtle.ConstantTimeCompare([]byte(actual), []byte(actual)) == 1 && false
+ return "Basic " + base64.StdEncoding.EncodeToString(bytesconv.StringToBytes(base))
}
diff --git a/vendor/github.com/gin-gonic/gin/binding/binding.go b/vendor/github.com/gin-gonic/gin/binding/binding.go
index 3a2aad9..5caeb58 100644
--- a/vendor/github.com/gin-gonic/gin/binding/binding.go
+++ b/vendor/github.com/gin-gonic/gin/binding/binding.go
@@ -2,6 +2,9 @@
// Use of this source code is governed by a MIT style
// license that can be found in the LICENSE file.
+//go:build !nomsgpack
+// +build !nomsgpack
+
package binding
import "net/http"
@@ -18,6 +21,7 @@ const (
MIMEPROTOBUF = "application/x-protobuf"
MIMEMSGPACK = "application/x-msgpack"
MIMEMSGPACK2 = "application/msgpack"
+ MIMEYAML = "application/x-yaml"
)
// Binding describes the interface which needs to be implemented for binding the
@@ -35,13 +39,21 @@ type BindingBody interface {
BindBody([]byte, interface{}) error
}
+// BindingUri adds BindUri method to Binding. BindUri is similar with Bind,
+// but it read the Params.
+type BindingUri interface {
+ Name() string
+ BindUri(map[string][]string, interface{}) error
+}
+
// StructValidator is the minimal interface which needs to be implemented in
// order for it to be used as the validator engine for ensuring the correctness
-// of the reqest. Gin provides a default implementation for this using
+// of the request. Gin provides a default implementation for this using
// https://github.com/go-playground/validator/tree/v8.18.2.
type StructValidator interface {
// ValidateStruct can receive any kind of type and it should never panic, even if the configuration is not right.
- // If the received type is not a struct, any validation should be skipped and nil must be returned.
+ // If the received type is a slice|array, the validation should be performed travel on every element.
+ // If the received type is not a struct or slice|array, any validation should be skipped and nil must be returned.
// If the received type is a struct or pointer to a struct, the validation should be performed.
// If the struct is not valid or the validation itself fails, a descriptive error should be returned.
// Otherwise nil must be returned.
@@ -68,12 +80,15 @@ var (
FormMultipart = formMultipartBinding{}
ProtoBuf = protobufBinding{}
MsgPack = msgpackBinding{}
+ YAML = yamlBinding{}
+ Uri = uriBinding{}
+ Header = headerBinding{}
)
// Default returns the appropriate Binding instance based on the HTTP method
// and the content type.
func Default(method, contentType string) Binding {
- if method == "GET" {
+ if method == http.MethodGet {
return Form
}
@@ -86,7 +101,11 @@ func Default(method, contentType string) Binding {
return ProtoBuf
case MIMEMSGPACK, MIMEMSGPACK2:
return MsgPack
- default: //case MIMEPOSTForm, MIMEMultipartPOSTForm:
+ case MIMEYAML:
+ return YAML
+ case MIMEMultipartPOSTForm:
+ return FormMultipart
+ default: // case MIMEPOSTForm:
return Form
}
}
diff --git a/vendor/github.com/gin-gonic/gin/binding/default_validator.go b/vendor/github.com/gin-gonic/gin/binding/default_validator.go
index e7a302d..c57a120 100644
--- a/vendor/github.com/gin-gonic/gin/binding/default_validator.go
+++ b/vendor/github.com/gin-gonic/gin/binding/default_validator.go
@@ -5,10 +5,12 @@
package binding
import (
+ "fmt"
"reflect"
+ "strings"
"sync"
- "gopkg.in/go-playground/validator.v8"
+ "github.com/go-playground/validator/v10"
)
type defaultValidator struct {
@@ -16,22 +18,54 @@ type defaultValidator struct {
validate *validator.Validate
}
+type sliceValidateError []error
+
+func (err sliceValidateError) Error() string {
+ var errMsgs []string
+ for i, e := range err {
+ if e == nil {
+ continue
+ }
+ errMsgs = append(errMsgs, fmt.Sprintf("[%d]: %s", i, e.Error()))
+ }
+ return strings.Join(errMsgs, "\n")
+}
+
var _ StructValidator = &defaultValidator{}
// ValidateStruct receives any kind of type, but only performed struct or pointer to struct type.
func (v *defaultValidator) ValidateStruct(obj interface{}) error {
- value := reflect.ValueOf(obj)
- valueType := value.Kind()
- if valueType == reflect.Ptr {
- valueType = value.Elem().Kind()
+ if obj == nil {
+ return nil
}
- if valueType == reflect.Struct {
- v.lazyinit()
- if err := v.validate.Struct(obj); err != nil {
- return err
+
+ value := reflect.ValueOf(obj)
+ switch value.Kind() {
+ case reflect.Ptr:
+ return v.ValidateStruct(value.Elem().Interface())
+ case reflect.Struct:
+ return v.validateStruct(obj)
+ case reflect.Slice, reflect.Array:
+ count := value.Len()
+ validateRet := make(sliceValidateError, 0)
+ for i := 0; i < count; i++ {
+ if err := v.ValidateStruct(value.Index(i).Interface()); err != nil {
+ validateRet = append(validateRet, err)
+ }
+ }
+ if len(validateRet) == 0 {
+ return nil
}
+ return validateRet
+ default:
+ return nil
}
- return nil
+}
+
+// validateStruct receives struct type
+func (v *defaultValidator) validateStruct(obj interface{}) error {
+ v.lazyinit()
+ return v.validate.Struct(obj)
}
// Engine returns the underlying validator engine which powers the default
@@ -45,7 +79,7 @@ func (v *defaultValidator) Engine() interface{} {
func (v *defaultValidator) lazyinit() {
v.once.Do(func() {
- config := &validator.Config{TagName: "binding"}
- v.validate = validator.New(config)
+ v.validate = validator.New()
+ v.validate.SetTagName("binding")
})
}
diff --git a/vendor/github.com/gin-gonic/gin/binding/form.go b/vendor/github.com/gin-gonic/gin/binding/form.go
index 0be5966..b93c34c 100644
--- a/vendor/github.com/gin-gonic/gin/binding/form.go
+++ b/vendor/github.com/gin-gonic/gin/binding/form.go
@@ -4,9 +4,11 @@
package binding
-import "net/http"
+import (
+ "net/http"
+)
-const defaultMemory = 32 * 1024 * 1024
+const defaultMemory = 32 << 20
type formBinding struct{}
type formPostBinding struct{}
@@ -20,7 +22,11 @@ func (formBinding) Bind(req *http.Request, obj interface{}) error {
if err := req.ParseForm(); err != nil {
return err
}
- req.ParseMultipartForm(defaultMemory)
+ if err := req.ParseMultipartForm(defaultMemory); err != nil {
+ if err != http.ErrNotMultipart {
+ return err
+ }
+ }
if err := mapForm(obj, req.Form); err != nil {
return err
}
@@ -49,8 +55,9 @@ func (formMultipartBinding) Bind(req *http.Request, obj interface{}) error {
if err := req.ParseMultipartForm(defaultMemory); err != nil {
return err
}
- if err := mapForm(obj, req.MultipartForm.Value); err != nil {
+ if err := mappingByPtr(obj, (*multipartRequest)(req), "form"); err != nil {
return err
}
+
return validate(obj)
}
diff --git a/vendor/github.com/gin-gonic/gin/binding/form_mapping.go b/vendor/github.com/gin-gonic/gin/binding/form_mapping.go
index 3f6b9bf..2f4e45b 100644
--- a/vendor/github.com/gin-gonic/gin/binding/form_mapping.go
+++ b/vendor/github.com/gin-gonic/gin/binding/form_mapping.go
@@ -6,127 +6,229 @@ package binding
import (
"errors"
+ "fmt"
"reflect"
"strconv"
"strings"
"time"
+
+ "github.com/gin-gonic/gin/internal/bytesconv"
+ "github.com/gin-gonic/gin/internal/json"
)
+var errUnknownType = errors.New("unknown type")
+
+func mapUri(ptr interface{}, m map[string][]string) error {
+ return mapFormByTag(ptr, m, "uri")
+}
+
func mapForm(ptr interface{}, form map[string][]string) error {
- typ := reflect.TypeOf(ptr).Elem()
- val := reflect.ValueOf(ptr).Elem()
- for i := 0; i < typ.NumField(); i++ {
- typeField := typ.Field(i)
- structField := val.Field(i)
- if !structField.CanSet() {
- continue
- }
-
- structFieldKind := structField.Kind()
- inputFieldName := typeField.Tag.Get("form")
- inputFieldNameList := strings.Split(inputFieldName, ",")
- inputFieldName = inputFieldNameList[0]
- var defaultValue string
- if len(inputFieldNameList) > 1 {
- defaultList := strings.SplitN(inputFieldNameList[1], "=", 2)
- if defaultList[0] == "default" {
- defaultValue = defaultList[1]
- }
+ return mapFormByTag(ptr, form, "form")
+}
+
+var emptyField = reflect.StructField{}
+
+func mapFormByTag(ptr interface{}, form map[string][]string, tag string) error {
+ // Check if ptr is a map
+ ptrVal := reflect.ValueOf(ptr)
+ var pointed interface{}
+ if ptrVal.Kind() == reflect.Ptr {
+ ptrVal = ptrVal.Elem()
+ pointed = ptrVal.Interface()
+ }
+ if ptrVal.Kind() == reflect.Map &&
+ ptrVal.Type().Key().Kind() == reflect.String {
+ if pointed != nil {
+ ptr = pointed
}
- if inputFieldName == "" {
- inputFieldName = typeField.Name
-
- // if "form" tag is nil, we inspect if the field is a struct or struct pointer.
- // this would not make sense for JSON parsing but it does for a form
- // since data is flatten
- if structFieldKind == reflect.Ptr {
- if !structField.Elem().IsValid() {
- structField.Set(reflect.New(structField.Type().Elem()))
- }
- structField = structField.Elem()
- structFieldKind = structField.Kind()
- }
- if structFieldKind == reflect.Struct {
- err := mapForm(structField.Addr().Interface(), form)
- if err != nil {
- return err
- }
- continue
- }
+ return setFormMap(ptr, form)
+ }
+
+ return mappingByPtr(ptr, formSource(form), tag)
+}
+
+// setter tries to set value on a walking by fields of a struct
+type setter interface {
+ TrySet(value reflect.Value, field reflect.StructField, key string, opt setOptions) (isSetted bool, err error)
+}
+
+type formSource map[string][]string
+
+var _ setter = formSource(nil)
+
+// TrySet tries to set a value by request's form source (like map[string][]string)
+func (form formSource) TrySet(value reflect.Value, field reflect.StructField, tagValue string, opt setOptions) (isSetted bool, err error) {
+ return setByForm(value, field, form, tagValue, opt)
+}
+
+func mappingByPtr(ptr interface{}, setter setter, tag string) error {
+ _, err := mapping(reflect.ValueOf(ptr), emptyField, setter, tag)
+ return err
+}
+
+func mapping(value reflect.Value, field reflect.StructField, setter setter, tag string) (bool, error) {
+ if field.Tag.Get(tag) == "-" { // just ignoring this field
+ return false, nil
+ }
+
+ var vKind = value.Kind()
+
+ if vKind == reflect.Ptr {
+ var isNew bool
+ vPtr := value
+ if value.IsNil() {
+ isNew = true
+ vPtr = reflect.New(value.Type().Elem())
}
- inputValue, exists := form[inputFieldName]
+ isSetted, err := mapping(vPtr.Elem(), field, setter, tag)
+ if err != nil {
+ return false, err
+ }
+ if isNew && isSetted {
+ value.Set(vPtr)
+ }
+ return isSetted, nil
+ }
- if !exists {
- if defaultValue == "" {
- continue
- }
- inputValue = make([]string, 1)
- inputValue[0] = defaultValue
- }
-
- numElems := len(inputValue)
- if structFieldKind == reflect.Slice && numElems > 0 {
- sliceOf := structField.Type().Elem().Kind()
- slice := reflect.MakeSlice(structField.Type(), numElems, numElems)
- for i := 0; i < numElems; i++ {
- if err := setWithProperType(sliceOf, inputValue[i], slice.Index(i)); err != nil {
- return err
- }
- }
- val.Field(i).Set(slice)
- } else {
- if _, isTime := structField.Interface().(time.Time); isTime {
- if err := setTimeField(inputValue[0], typeField, structField); err != nil {
- return err
- }
+ if vKind != reflect.Struct || !field.Anonymous {
+ ok, err := tryToSetValue(value, field, setter, tag)
+ if err != nil {
+ return false, err
+ }
+ if ok {
+ return true, nil
+ }
+ }
+
+ if vKind == reflect.Struct {
+ tValue := value.Type()
+
+ var isSetted bool
+ for i := 0; i < value.NumField(); i++ {
+ sf := tValue.Field(i)
+ if sf.PkgPath != "" && !sf.Anonymous { // unexported
continue
}
- if err := setWithProperType(typeField.Type.Kind(), inputValue[0], structField); err != nil {
- return err
+ ok, err := mapping(value.Field(i), tValue.Field(i), setter, tag)
+ if err != nil {
+ return false, err
}
+ isSetted = isSetted || ok
}
+ return isSetted, nil
}
- return nil
+ return false, nil
+}
+
+type setOptions struct {
+ isDefaultExists bool
+ defaultValue string
+}
+
+func tryToSetValue(value reflect.Value, field reflect.StructField, setter setter, tag string) (bool, error) {
+ var tagValue string
+ var setOpt setOptions
+
+ tagValue = field.Tag.Get(tag)
+ tagValue, opts := head(tagValue, ",")
+
+ if tagValue == "" { // default value is FieldName
+ tagValue = field.Name
+ }
+ if tagValue == "" { // when field is "emptyField" variable
+ return false, nil
+ }
+
+ var opt string
+ for len(opts) > 0 {
+ opt, opts = head(opts, ",")
+
+ if k, v := head(opt, "="); k == "default" {
+ setOpt.isDefaultExists = true
+ setOpt.defaultValue = v
+ }
+ }
+
+ return setter.TrySet(value, field, tagValue, setOpt)
}
-func setWithProperType(valueKind reflect.Kind, val string, structField reflect.Value) error {
- switch valueKind {
+func setByForm(value reflect.Value, field reflect.StructField, form map[string][]string, tagValue string, opt setOptions) (isSetted bool, err error) {
+ vs, ok := form[tagValue]
+ if !ok && !opt.isDefaultExists {
+ return false, nil
+ }
+
+ switch value.Kind() {
+ case reflect.Slice:
+ if !ok {
+ vs = []string{opt.defaultValue}
+ }
+ return true, setSlice(vs, value, field)
+ case reflect.Array:
+ if !ok {
+ vs = []string{opt.defaultValue}
+ }
+ if len(vs) != value.Len() {
+ return false, fmt.Errorf("%q is not valid value for %s", vs, value.Type().String())
+ }
+ return true, setArray(vs, value, field)
+ default:
+ var val string
+ if !ok {
+ val = opt.defaultValue
+ }
+
+ if len(vs) > 0 {
+ val = vs[0]
+ }
+ return true, setWithProperType(val, value, field)
+ }
+}
+
+func setWithProperType(val string, value reflect.Value, field reflect.StructField) error {
+ switch value.Kind() {
case reflect.Int:
- return setIntField(val, 0, structField)
+ return setIntField(val, 0, value)
case reflect.Int8:
- return setIntField(val, 8, structField)
+ return setIntField(val, 8, value)
case reflect.Int16:
- return setIntField(val, 16, structField)
+ return setIntField(val, 16, value)
case reflect.Int32:
- return setIntField(val, 32, structField)
+ return setIntField(val, 32, value)
case reflect.Int64:
- return setIntField(val, 64, structField)
+ switch value.Interface().(type) {
+ case time.Duration:
+ return setTimeDuration(val, value, field)
+ }
+ return setIntField(val, 64, value)
case reflect.Uint:
- return setUintField(val, 0, structField)
+ return setUintField(val, 0, value)
case reflect.Uint8:
- return setUintField(val, 8, structField)
+ return setUintField(val, 8, value)
case reflect.Uint16:
- return setUintField(val, 16, structField)
+ return setUintField(val, 16, value)
case reflect.Uint32:
- return setUintField(val, 32, structField)
+ return setUintField(val, 32, value)
case reflect.Uint64:
- return setUintField(val, 64, structField)
+ return setUintField(val, 64, value)
case reflect.Bool:
- return setBoolField(val, structField)
+ return setBoolField(val, value)
case reflect.Float32:
- return setFloatField(val, 32, structField)
+ return setFloatField(val, 32, value)
case reflect.Float64:
- return setFloatField(val, 64, structField)
+ return setFloatField(val, 64, value)
case reflect.String:
- structField.SetString(val)
- case reflect.Ptr:
- if !structField.Elem().IsValid() {
- structField.Set(reflect.New(structField.Type().Elem()))
+ value.SetString(val)
+ case reflect.Struct:
+ switch value.Interface().(type) {
+ case time.Time:
+ return setTimeField(val, field, value)
}
- structFieldElem := structField.Elem()
- return setWithProperType(structFieldElem.Kind(), val, structFieldElem)
+ return json.Unmarshal(bytesconv.StringToBytes(val), value.Addr().Interface())
+ case reflect.Map:
+ return json.Unmarshal(bytesconv.StringToBytes(val), value.Addr().Interface())
default:
- return errors.New("Unknown type")
+ return errUnknownType
}
return nil
}
@@ -178,7 +280,25 @@ func setFloatField(val string, bitSize int, field reflect.Value) error {
func setTimeField(val string, structField reflect.StructField, value reflect.Value) error {
timeFormat := structField.Tag.Get("time_format")
if timeFormat == "" {
- return errors.New("Blank time format")
+ timeFormat = time.RFC3339
+ }
+
+ switch tf := strings.ToLower(timeFormat); tf {
+ case "unix", "unixnano":
+ tv, err := strconv.ParseInt(val, 10, 64)
+ if err != nil {
+ return err
+ }
+
+ d := time.Duration(1)
+ if tf == "unixnano" {
+ d = time.Second
+ }
+
+ t := time.Unix(tv/int64(d), tv%int64(d))
+ value.Set(reflect.ValueOf(t))
+ return nil
+
}
if val == "" {
@@ -207,3 +327,66 @@ func setTimeField(val string, structField reflect.StructField, value reflect.Val
value.Set(reflect.ValueOf(t))
return nil
}
+
+func setArray(vals []string, value reflect.Value, field reflect.StructField) error {
+ for i, s := range vals {
+ err := setWithProperType(s, value.Index(i), field)
+ if err != nil {
+ return err
+ }
+ }
+ return nil
+}
+
+func setSlice(vals []string, value reflect.Value, field reflect.StructField) error {
+ slice := reflect.MakeSlice(value.Type(), len(vals), len(vals))
+ err := setArray(vals, slice, field)
+ if err != nil {
+ return err
+ }
+ value.Set(slice)
+ return nil
+}
+
+func setTimeDuration(val string, value reflect.Value, field reflect.StructField) error {
+ d, err := time.ParseDuration(val)
+ if err != nil {
+ return err
+ }
+ value.Set(reflect.ValueOf(d))
+ return nil
+}
+
+func head(str, sep string) (head string, tail string) {
+ idx := strings.Index(str, sep)
+ if idx < 0 {
+ return str, ""
+ }
+ return str[:idx], str[idx+len(sep):]
+}
+
+func setFormMap(ptr interface{}, form map[string][]string) error {
+ el := reflect.TypeOf(ptr).Elem()
+
+ if el.Kind() == reflect.Slice {
+ ptrMap, ok := ptr.(map[string][]string)
+ if !ok {
+ return errors.New("cannot convert to map slices of strings")
+ }
+ for k, v := range form {
+ ptrMap[k] = v
+ }
+
+ return nil
+ }
+
+ ptrMap, ok := ptr.(map[string]string)
+ if !ok {
+ return errors.New("cannot convert to map of strings")
+ }
+ for k, v := range form {
+ ptrMap[k] = v[len(v)-1] // pick last
+ }
+
+ return nil
+}
diff --git a/vendor/github.com/gin-gonic/gin/binding/json.go b/vendor/github.com/gin-gonic/gin/binding/json.go
index fea17bb..d62e070 100644
--- a/vendor/github.com/gin-gonic/gin/binding/json.go
+++ b/vendor/github.com/gin-gonic/gin/binding/json.go
@@ -6,10 +6,11 @@ package binding
import (
"bytes"
+ "fmt"
"io"
"net/http"
- "github.com/gin-gonic/gin/json"
+ "github.com/gin-gonic/gin/internal/json"
)
// EnableDecoderUseNumber is used to call the UseNumber method on the JSON
@@ -17,6 +18,12 @@ import (
// interface{} as a Number instead of as a float64.
var EnableDecoderUseNumber = false
+// EnableDecoderDisallowUnknownFields is used to call the DisallowUnknownFields method
+// on the JSON Decoder instance. DisallowUnknownFields causes the Decoder to
+// return an error when the destination is a struct and the input contains object
+// keys which do not match any non-ignored, exported fields in the destination.
+var EnableDecoderDisallowUnknownFields = false
+
type jsonBinding struct{}
func (jsonBinding) Name() string {
@@ -24,6 +31,9 @@ func (jsonBinding) Name() string {
}
func (jsonBinding) Bind(req *http.Request, obj interface{}) error {
+ if req == nil || req.Body == nil {
+ return fmt.Errorf("invalid request")
+ }
return decodeJSON(req.Body, obj)
}
@@ -36,6 +46,9 @@ func decodeJSON(r io.Reader, obj interface{}) error {
if EnableDecoderUseNumber {
decoder.UseNumber()
}
+ if EnableDecoderDisallowUnknownFields {
+ decoder.DisallowUnknownFields()
+ }
if err := decoder.Decode(obj); err != nil {
return err
}
diff --git a/vendor/github.com/gin-gonic/gin/binding/msgpack.go b/vendor/github.com/gin-gonic/gin/binding/msgpack.go
index b7f7319..2a44299 100644
--- a/vendor/github.com/gin-gonic/gin/binding/msgpack.go
+++ b/vendor/github.com/gin-gonic/gin/binding/msgpack.go
@@ -2,6 +2,9 @@
// Use of this source code is governed by a MIT style
// license that can be found in the LICENSE file.
+//go:build !nomsgpack
+// +build !nomsgpack
+
package binding
import (
diff --git a/vendor/github.com/gin-gonic/gin/binding/protobuf.go b/vendor/github.com/gin-gonic/gin/binding/protobuf.go
index 540e9c1..f9ece92 100644
--- a/vendor/github.com/gin-gonic/gin/binding/protobuf.go
+++ b/vendor/github.com/gin-gonic/gin/binding/protobuf.go
@@ -29,7 +29,7 @@ func (protobufBinding) BindBody(body []byte, obj interface{}) error {
if err := proto.Unmarshal(body, obj.(proto.Message)); err != nil {
return err
}
- // Here it's same to return validate(obj), but util now we cann't add
+ // Here it's same to return validate(obj), but util now we can't add
// `binding:""` to the struct which automatically generate by gen-proto
return nil
// return validate(obj)
diff --git a/vendor/github.com/gin-gonic/gin/context.go b/vendor/github.com/gin-gonic/gin/context.go
index 724ded7..1ba0fa2 100644
--- a/vendor/github.com/gin-gonic/gin/context.go
+++ b/vendor/github.com/gin-gonic/gin/context.go
@@ -6,6 +6,7 @@ package gin
import (
"errors"
+ "fmt"
"io"
"io/ioutil"
"math"
@@ -15,6 +16,7 @@ import (
"net/url"
"os"
"strings"
+ "sync"
"time"
"github.com/gin-contrib/sse"
@@ -31,9 +33,12 @@ const (
MIMEPlain = binding.MIMEPlain
MIMEPOSTForm = binding.MIMEPOSTForm
MIMEMultipartPOSTForm = binding.MIMEMultipartPOSTForm
- BodyBytesKey = "_gin-gonic/gin/bodybyteskey"
+ MIMEYAML = binding.MIMEYAML
)
+// BodyBytesKey indicates a default body bytes key.
+const BodyBytesKey = "_gin-gonic/gin/bodybyteskey"
+
const abortIndex int8 = math.MaxInt8 / 2
// Context is the most important part of gin. It allows us to pass variables between middleware,
@@ -46,8 +51,13 @@ type Context struct {
Params Params
handlers HandlersChain
index int8
+ fullPath string
engine *Engine
+ params *Params
+
+ // This mutex protect Keys map
+ mu sync.RWMutex
// Keys is a key/value pair exclusively for the context of each request.
Keys map[string]interface{}
@@ -57,6 +67,17 @@ type Context struct {
// Accepted defines a list of manually accepted formats for content negotiation.
Accepted []string
+
+ // queryCache use url.ParseQuery cached the param query result from c.Request.URL.Query()
+ queryCache url.Values
+
+ // formCache use url.ParseQuery cached PostForm contains the parsed form data from POST, PATCH,
+ // or PUT body parameters.
+ formCache url.Values
+
+ // SameSite allows a server to define a cookie attribute making it impossible for
+ // the browser to send this cookie along with cross-site requests.
+ sameSite http.SameSite
}
/************************************/
@@ -68,19 +89,36 @@ func (c *Context) reset() {
c.Params = c.Params[0:0]
c.handlers = nil
c.index = -1
+
+ c.fullPath = ""
c.Keys = nil
c.Errors = c.Errors[0:0]
c.Accepted = nil
+ c.queryCache = nil
+ c.formCache = nil
+ *c.params = (*c.params)[0:0]
}
// Copy returns a copy of the current context that can be safely used outside the request's scope.
// This has to be used when the context has to be passed to a goroutine.
func (c *Context) Copy() *Context {
- var cp = *c
+ cp := Context{
+ writermem: c.writermem,
+ Request: c.Request,
+ Params: c.Params,
+ engine: c.engine,
+ }
cp.writermem.ResponseWriter = nil
cp.Writer = &cp.writermem
cp.index = abortIndex
cp.handlers = nil
+ cp.Keys = map[string]interface{}{}
+ for k, v := range c.Keys {
+ cp.Keys[k] = v
+ }
+ paramCopy := make([]Param, len(cp.Params))
+ copy(paramCopy, cp.Params)
+ cp.Params = paramCopy
return &cp
}
@@ -90,11 +128,30 @@ func (c *Context) HandlerName() string {
return nameOfFunction(c.handlers.Last())
}
+// HandlerNames returns a list of all registered handlers for this context in descending order,
+// following the semantics of HandlerName()
+func (c *Context) HandlerNames() []string {
+ hn := make([]string, 0, len(c.handlers))
+ for _, val := range c.handlers {
+ hn = append(hn, nameOfFunction(val))
+ }
+ return hn
+}
+
// Handler returns the main handler.
func (c *Context) Handler() HandlerFunc {
return c.handlers.Last()
}
+// FullPath returns a matched route full path. For not found routes
+// returns an empty string.
+// router.GET("/user/:id", func(c *gin.Context) {
+// c.FullPath() == "/user/:id" // true
+// })
+func (c *Context) FullPath() string {
+ return c.fullPath
+}
+
/************************************/
/*********** FLOW CONTROL ***********/
/************************************/
@@ -104,8 +161,9 @@ func (c *Context) Handler() HandlerFunc {
// See example in GitHub.
func (c *Context) Next() {
c.index++
- for s := int8(len(c.handlers)); c.index < s; c.index++ {
+ for c.index < int8(len(c.handlers)) {
c.handlers[c.index](c)
+ c.index++
}
}
@@ -179,16 +237,21 @@ func (c *Context) Error(err error) *Error {
// Set is used to store a new key/value pair exclusively for this context.
// It also lazy initializes c.Keys if it was not used previously.
func (c *Context) Set(key string, value interface{}) {
+ c.mu.Lock()
if c.Keys == nil {
c.Keys = make(map[string]interface{})
}
+
c.Keys[key] = value
+ c.mu.Unlock()
}
// Get returns the value for the given key, ie: (value, true).
// If the value does not exists it returns (nil, false)
func (c *Context) Get(key string) (value interface{}, exists bool) {
+ c.mu.RLock()
value, exists = c.Keys[key]
+ c.mu.RUnlock()
return
}
@@ -232,6 +295,22 @@ func (c *Context) GetInt64(key string) (i64 int64) {
return
}
+// GetUint returns the value associated with the key as an unsigned integer.
+func (c *Context) GetUint(key string) (ui uint) {
+ if val, ok := c.Get(key); ok && val != nil {
+ ui, _ = val.(uint)
+ }
+ return
+}
+
+// GetUint64 returns the value associated with the key as an unsigned integer.
+func (c *Context) GetUint64(key string) (ui64 uint64) {
+ if val, ok := c.Get(key); ok && val != nil {
+ ui64, _ = val.(uint64)
+ }
+ return
+}
+
// GetFloat64 returns the value associated with the key as a float64.
func (c *Context) GetFloat64(key string) (f64 float64) {
if val, ok := c.Get(key); ok && val != nil {
@@ -351,10 +430,21 @@ func (c *Context) QueryArray(key string) []string {
return values
}
+func (c *Context) initQueryCache() {
+ if c.queryCache == nil {
+ if c.Request != nil {
+ c.queryCache = c.Request.URL.Query()
+ } else {
+ c.queryCache = url.Values{}
+ }
+ }
+}
+
// GetQueryArray returns a slice of strings for a given query key, plus
// a boolean value whether at least one value exists for the given key.
func (c *Context) GetQueryArray(key string) ([]string, bool) {
- if values, ok := c.Request.URL.Query()[key]; ok && len(values) > 0 {
+ c.initQueryCache()
+ if values, ok := c.queryCache[key]; ok && len(values) > 0 {
return values, true
}
return []string{}, false
@@ -369,7 +459,8 @@ func (c *Context) QueryMap(key string) map[string]string {
// GetQueryMap returns a map for a given query key, plus a boolean value
// whether at least one value exists for the given key.
func (c *Context) GetQueryMap(key string) (map[string]string, bool) {
- return c.get(c.Request.URL.Query(), key)
+ c.initQueryCache()
+ return c.get(c.queryCache, key)
}
// PostForm returns the specified key from a POST urlencoded form or multipart form
@@ -410,20 +501,26 @@ func (c *Context) PostFormArray(key string) []string {
return values
}
+func (c *Context) initFormCache() {
+ if c.formCache == nil {
+ c.formCache = make(url.Values)
+ req := c.Request
+ if err := req.ParseMultipartForm(c.engine.MaxMultipartMemory); err != nil {
+ if err != http.ErrNotMultipart {
+ debugPrint("error on parse multipart form array: %v", err)
+ }
+ }
+ c.formCache = req.PostForm
+ }
+}
+
// GetPostFormArray returns a slice of strings for a given form key, plus
// a boolean value whether at least one value exists for the given key.
func (c *Context) GetPostFormArray(key string) ([]string, bool) {
- req := c.Request
- req.ParseForm()
- req.ParseMultipartForm(c.engine.MaxMultipartMemory)
- if values := req.PostForm[key]; len(values) > 0 {
+ c.initFormCache()
+ if values := c.formCache[key]; len(values) > 0 {
return values, true
}
- if req.MultipartForm != nil && req.MultipartForm.File != nil {
- if values := req.MultipartForm.Value[key]; len(values) > 0 {
- return values, true
- }
- }
return []string{}, false
}
@@ -436,16 +533,8 @@ func (c *Context) PostFormMap(key string) map[string]string {
// GetPostFormMap returns a map for a given form key, plus a boolean value
// whether at least one value exists for the given key.
func (c *Context) GetPostFormMap(key string) (map[string]string, bool) {
- req := c.Request
- req.ParseForm()
- req.ParseMultipartForm(c.engine.MaxMultipartMemory)
- dicts, exist := c.get(req.PostForm, key)
-
- if !exist && req.MultipartForm != nil && req.MultipartForm.File != nil {
- dicts, exist = c.get(req.MultipartForm.Value, key)
- }
-
- return dicts, exist
+ c.initFormCache()
+ return c.get(c.formCache, key)
}
// get is an internal method and returns a map which satisfy conditions.
@@ -465,7 +554,16 @@ func (c *Context) get(m map[string][]string, key string) (map[string]string, boo
// FormFile returns the first file for the provided form key.
func (c *Context) FormFile(name string) (*multipart.FileHeader, error) {
- _, fh, err := c.Request.FormFile(name)
+ if c.Request.MultipartForm == nil {
+ if err := c.Request.ParseMultipartForm(c.engine.MaxMultipartMemory); err != nil {
+ return nil, err
+ }
+ }
+ f, fh, err := c.Request.FormFile(name)
+ if err != nil {
+ return nil, err
+ }
+ f.Close()
return fh, err
}
@@ -489,8 +587,8 @@ func (c *Context) SaveUploadedFile(file *multipart.FileHeader, dst string) error
}
defer out.Close()
- io.Copy(out, src)
- return nil
+ _, err = io.Copy(out, src)
+ return err
}
// Bind checks the Content-Type to select a binding engine automatically,
@@ -511,20 +609,45 @@ func (c *Context) BindJSON(obj interface{}) error {
return c.MustBindWith(obj, binding.JSON)
}
+// BindXML is a shortcut for c.MustBindWith(obj, binding.BindXML).
+func (c *Context) BindXML(obj interface{}) error {
+ return c.MustBindWith(obj, binding.XML)
+}
+
// BindQuery is a shortcut for c.MustBindWith(obj, binding.Query).
func (c *Context) BindQuery(obj interface{}) error {
return c.MustBindWith(obj, binding.Query)
}
+// BindYAML is a shortcut for c.MustBindWith(obj, binding.YAML).
+func (c *Context) BindYAML(obj interface{}) error {
+ return c.MustBindWith(obj, binding.YAML)
+}
+
+// BindHeader is a shortcut for c.MustBindWith(obj, binding.Header).
+func (c *Context) BindHeader(obj interface{}) error {
+ return c.MustBindWith(obj, binding.Header)
+}
+
+// BindUri binds the passed struct pointer using binding.Uri.
+// It will abort the request with HTTP 400 if any error occurs.
+func (c *Context) BindUri(obj interface{}) error {
+ if err := c.ShouldBindUri(obj); err != nil {
+ c.AbortWithError(http.StatusBadRequest, err).SetType(ErrorTypeBind) // nolint: errcheck
+ return err
+ }
+ return nil
+}
+
// MustBindWith binds the passed struct pointer using the specified binding engine.
-// It will abort the request with HTTP 400 if any error ocurrs.
+// It will abort the request with HTTP 400 if any error occurs.
// See the binding package.
-func (c *Context) MustBindWith(obj interface{}, b binding.Binding) (err error) {
- if err = c.ShouldBindWith(obj, b); err != nil {
- c.AbortWithError(http.StatusBadRequest, err).SetType(ErrorTypeBind)
+func (c *Context) MustBindWith(obj interface{}, b binding.Binding) error {
+ if err := c.ShouldBindWith(obj, b); err != nil {
+ c.AbortWithError(http.StatusBadRequest, err).SetType(ErrorTypeBind) // nolint: errcheck
+ return err
}
-
- return
+ return nil
}
// ShouldBind checks the Content-Type to select a binding engine automatically,
@@ -545,11 +668,35 @@ func (c *Context) ShouldBindJSON(obj interface{}) error {
return c.ShouldBindWith(obj, binding.JSON)
}
+// ShouldBindXML is a shortcut for c.ShouldBindWith(obj, binding.XML).
+func (c *Context) ShouldBindXML(obj interface{}) error {
+ return c.ShouldBindWith(obj, binding.XML)
+}
+
// ShouldBindQuery is a shortcut for c.ShouldBindWith(obj, binding.Query).
func (c *Context) ShouldBindQuery(obj interface{}) error {
return c.ShouldBindWith(obj, binding.Query)
}
+// ShouldBindYAML is a shortcut for c.ShouldBindWith(obj, binding.YAML).
+func (c *Context) ShouldBindYAML(obj interface{}) error {
+ return c.ShouldBindWith(obj, binding.YAML)
+}
+
+// ShouldBindHeader is a shortcut for c.ShouldBindWith(obj, binding.Header).
+func (c *Context) ShouldBindHeader(obj interface{}) error {
+ return c.ShouldBindWith(obj, binding.Header)
+}
+
+// ShouldBindUri binds the passed struct pointer using the specified binding engine.
+func (c *Context) ShouldBindUri(obj interface{}) error {
+ m := make(map[string][]string)
+ for _, v := range c.Params {
+ m[v.Key] = []string{v.Value}
+ }
+ return binding.Uri.BindUri(m, obj)
+}
+
// ShouldBindWith binds the passed struct pointer using the specified binding engine.
// See the binding package.
func (c *Context) ShouldBindWith(obj interface{}, b binding.Binding) error {
@@ -561,9 +708,7 @@ func (c *Context) ShouldBindWith(obj interface{}, b binding.Binding) error {
//
// NOTE: This method reads the body before binding. So you should use
// ShouldBindWith for better performance if you need to call only once.
-func (c *Context) ShouldBindBodyWith(
- obj interface{}, bb binding.BindingBody,
-) (err error) {
+func (c *Context) ShouldBindBodyWith(obj interface{}, bb binding.BindingBody) (err error) {
var body []byte
if cb, ok := c.Get(BodyBytesKey); ok {
if cbb, ok := cb.([]byte); ok {
@@ -580,32 +725,82 @@ func (c *Context) ShouldBindBodyWith(
return bb.BindBody(body, obj)
}
-// ClientIP implements a best effort algorithm to return the real client IP, it parses
-// X-Real-IP and X-Forwarded-For in order to work properly with reverse-proxies such us: nginx or haproxy.
-// Use X-Forwarded-For before X-Real-Ip as nginx uses X-Real-Ip with the proxy's IP.
+// ClientIP implements a best effort algorithm to return the real client IP.
+// It called c.RemoteIP() under the hood, to check if the remote IP is a trusted proxy or not.
+// If it's it will then try to parse the headers defined in Engine.RemoteIPHeaders (defaulting to [X-Forwarded-For, X-Real-Ip]).
+// If the headers are nots syntactically valid OR the remote IP does not correspong to a trusted proxy,
+// the remote IP (coming form Request.RemoteAddr) is returned.
func (c *Context) ClientIP() string {
- if c.engine.ForwardedByClientIP {
- clientIP := c.requestHeader("X-Forwarded-For")
- clientIP = strings.TrimSpace(strings.Split(clientIP, ",")[0])
- if clientIP == "" {
- clientIP = strings.TrimSpace(c.requestHeader("X-Real-Ip"))
+ if c.engine.AppEngine {
+ if addr := c.requestHeader("X-Appengine-Remote-Addr"); addr != "" {
+ return addr
}
- if clientIP != "" {
- return clientIP
+ }
+
+ remoteIP, trusted := c.RemoteIP()
+ if remoteIP == nil {
+ return ""
+ }
+
+ if trusted && c.engine.ForwardedByClientIP && c.engine.RemoteIPHeaders != nil {
+ for _, headerName := range c.engine.RemoteIPHeaders {
+ ip, valid := validateHeader(c.requestHeader(headerName))
+ if valid {
+ return ip
+ }
}
}
+ return remoteIP.String()
+}
- if c.engine.AppEngine {
- if addr := c.requestHeader("X-Appengine-Remote-Addr"); addr != "" {
- return addr
+// RemoteIP parses the IP from Request.RemoteAddr, normalizes and returns the IP (without the port).
+// It also checks if the remoteIP is a trusted proxy or not.
+// In order to perform this validation, it will see if the IP is contained within at least one of the CIDR blocks
+// defined in Engine.TrustedProxies
+func (c *Context) RemoteIP() (net.IP, bool) {
+ ip, _, err := net.SplitHostPort(strings.TrimSpace(c.Request.RemoteAddr))
+ if err != nil {
+ return nil, false
+ }
+ remoteIP := net.ParseIP(ip)
+ if remoteIP == nil {
+ return nil, false
+ }
+
+ trustedCIDRs, _ := c.engine.prepareTrustedCIDRs()
+ c.engine.trustedCIDRs = trustedCIDRs
+ if c.engine.trustedCIDRs != nil {
+ for _, cidr := range c.engine.trustedCIDRs {
+ if cidr.Contains(remoteIP) {
+ return remoteIP, true
+ }
}
}
- if ip, _, err := net.SplitHostPort(strings.TrimSpace(c.Request.RemoteAddr)); err == nil {
- return ip
+ return remoteIP, false
+}
+
+func validateHeader(header string) (clientIP string, valid bool) {
+ if header == "" {
+ return "", false
}
+ items := strings.Split(header, ",")
+ for i, ipStr := range items {
+ ipStr = strings.TrimSpace(ipStr)
+ ip := net.ParseIP(ipStr)
+ if ip == nil {
+ return "", false
+ }
- return ""
+ // We need to return the first IP in the list, but,
+ // we should not early return since we need to validate that
+ // the rest of the header is syntactically valid
+ if i == 0 {
+ clientIP = ipStr
+ valid = true
+ }
+ }
+ return
}
// ContentType returns the Content-Type header of the request.
@@ -617,7 +812,7 @@ func (c *Context) ContentType() string {
// handshake is being initiated by the client.
func (c *Context) IsWebsocket() bool {
if strings.Contains(strings.ToLower(c.requestHeader("Connection")), "upgrade") &&
- strings.ToLower(c.requestHeader("Upgrade")) == "websocket" {
+ strings.EqualFold(c.requestHeader("Upgrade"), "websocket") {
return true
}
return false
@@ -646,7 +841,7 @@ func bodyAllowedForStatus(status int) bool {
// Status sets the HTTP response code.
func (c *Context) Status(code int) {
- c.writermem.WriteHeader(code)
+ c.Writer.WriteHeader(code)
}
// Header is a intelligent shortcut for c.Writer.Header().Set(key, value).
@@ -655,9 +850,9 @@ func (c *Context) Status(code int) {
func (c *Context) Header(key, value string) {
if value == "" {
c.Writer.Header().Del(key)
- } else {
- c.Writer.Header().Set(key, value)
+ return
}
+ c.Writer.Header().Set(key, value)
}
// GetHeader returns value from request headers.
@@ -670,6 +865,11 @@ func (c *Context) GetRawData() ([]byte, error) {
return ioutil.ReadAll(c.Request.Body)
}
+// SetSameSite with cookie
+func (c *Context) SetSameSite(samesite http.SameSite) {
+ c.sameSite = samesite
+}
+
// SetCookie adds a Set-Cookie header to the ResponseWriter's headers.
// The provided cookie must have a valid Name. Invalid cookies may be
// silently dropped.
@@ -683,6 +883,7 @@ func (c *Context) SetCookie(name, value string, maxAge int, path, domain string,
MaxAge: maxAge,
Path: path,
Domain: domain,
+ SameSite: c.sameSite,
Secure: secure,
HttpOnly: httpOnly,
})
@@ -701,6 +902,7 @@ func (c *Context) Cookie(name string) (string, error) {
return val, nil
}
+// Render writes the response headers and calls render.Render to render data.
func (c *Context) Render(code int, r render.Render) {
c.Status(code)
@@ -735,19 +937,19 @@ func (c *Context) IndentedJSON(code int, obj interface{}) {
// Default prepends "while(1)," to response body if the given struct is array values.
// It also sets the Content-Type as "application/json".
func (c *Context) SecureJSON(code int, obj interface{}) {
- c.Render(code, render.SecureJSON{Prefix: c.engine.secureJsonPrefix, Data: obj})
+ c.Render(code, render.SecureJSON{Prefix: c.engine.secureJSONPrefix, Data: obj})
}
// JSONP serializes the given struct as JSON into the response body.
-// It add padding to response body to request data from a server residing in a different domain than the client.
+// It adds padding to response body to request data from a server residing in a different domain than the client.
// It also sets the Content-Type as "application/javascript".
func (c *Context) JSONP(code int, obj interface{}) {
callback := c.DefaultQuery("callback", "")
if callback == "" {
c.Render(code, render.JSON{Data: obj})
- } else {
- c.Render(code, render.JsonpJSON{Callback: callback, Data: obj})
+ return
}
+ c.Render(code, render.JsonpJSON{Callback: callback, Data: obj})
}
// JSON serializes the given struct as JSON into the response body.
@@ -762,6 +964,12 @@ func (c *Context) AsciiJSON(code int, obj interface{}) {
c.Render(code, render.AsciiJSON{Data: obj})
}
+// PureJSON serializes the given struct as JSON into the response body.
+// PureJSON, unlike JSON, does not replace special html characters with their unicode entities.
+func (c *Context) PureJSON(code int, obj interface{}) {
+ c.Render(code, render.PureJSON{Data: obj})
+}
+
// XML serializes the given struct as XML into the response body.
// It also sets the Content-Type as "application/xml".
func (c *Context) XML(code int, obj interface{}) {
@@ -773,6 +981,11 @@ func (c *Context) YAML(code int, obj interface{}) {
c.Render(code, render.YAML{Data: obj})
}
+// ProtoBuf serializes the given struct as ProtoBuf into the response body.
+func (c *Context) ProtoBuf(code int, obj interface{}) {
+ c.Render(code, render.ProtoBuf{Data: obj})
+}
+
// String writes the given string into the response body.
func (c *Context) String(code int, format string, values ...interface{}) {
c.Render(code, render.String{Format: format, Data: values})
@@ -805,11 +1018,29 @@ func (c *Context) DataFromReader(code int, contentLength int64, contentType stri
})
}
-// File writes the specified file into the body stream in a efficient way.
+// File writes the specified file into the body stream in an efficient way.
func (c *Context) File(filepath string) {
http.ServeFile(c.Writer, c.Request, filepath)
}
+// FileFromFS writes the specified file from http.FileSystem into the body stream in an efficient way.
+func (c *Context) FileFromFS(filepath string, fs http.FileSystem) {
+ defer func(old string) {
+ c.Request.URL.Path = old
+ }(c.Request.URL.Path)
+
+ c.Request.URL.Path = filepath
+
+ http.FileServer(fs).ServeHTTP(c.Writer, c.Request)
+}
+
+// FileAttachment writes the specified file into the body stream in an efficient way
+// On the client side, the file will typically be downloaded with the given filename
+func (c *Context) FileAttachment(filepath, filename string) {
+ c.Writer.Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=\"%s\"", filename))
+ http.ServeFile(c.Writer, c.Request, filepath)
+}
+
// SSEvent writes a Server-Sent Event into the body stream.
func (c *Context) SSEvent(name string, message interface{}) {
c.Render(-1, sse.Event{
@@ -818,18 +1049,20 @@ func (c *Context) SSEvent(name string, message interface{}) {
})
}
-func (c *Context) Stream(step func(w io.Writer) bool) {
+// Stream sends a streaming response and returns a boolean
+// indicates "Is client disconnected in middle of stream"
+func (c *Context) Stream(step func(w io.Writer) bool) bool {
w := c.Writer
clientGone := w.CloseNotify()
for {
select {
case <-clientGone:
- return
+ return true
default:
keepOpen := step(w)
w.Flush()
if !keepOpen {
- return
+ return false
}
}
}
@@ -839,15 +1072,18 @@ func (c *Context) Stream(step func(w io.Writer) bool) {
/******** CONTENT NEGOTIATION *******/
/************************************/
+// Negotiate contains all negotiations data.
type Negotiate struct {
Offered []string
HTMLName string
HTMLData interface{}
JSONData interface{}
XMLData interface{}
+ YAMLData interface{}
Data interface{}
}
+// Negotiate calls different Render according acceptable Accept format.
func (c *Context) Negotiate(code int, config Negotiate) {
switch c.NegotiateFormat(config.Offered...) {
case binding.MIMEJSON:
@@ -862,11 +1098,16 @@ func (c *Context) Negotiate(code int, config Negotiate) {
data := chooseData(config.XMLData, config.Data)
c.XML(code, data)
+ case binding.MIMEYAML:
+ data := chooseData(config.YAMLData, config.Data)
+ c.YAML(code, data)
+
default:
- c.AbortWithError(http.StatusNotAcceptable, errors.New("the accepted formats are not offered by the server"))
+ c.AbortWithError(http.StatusNotAcceptable, errors.New("the accepted formats are not offered by the server")) // nolint: errcheck
}
}
+// NegotiateFormat returns an acceptable Accept format.
func (c *Context) NegotiateFormat(offered ...string) string {
assert1(len(offered) > 0, "you must provide at least one offer")
@@ -877,15 +1118,27 @@ func (c *Context) NegotiateFormat(offered ...string) string {
return offered[0]
}
for _, accepted := range c.Accepted {
- for _, offert := range offered {
- if accepted == offert {
- return offert
+ for _, offer := range offered {
+ // According to RFC 2616 and RFC 2396, non-ASCII characters are not allowed in headers,
+ // therefore we can just iterate over the string without casting it into []rune
+ i := 0
+ for ; i < len(accepted); i++ {
+ if accepted[i] == '*' || offer[i] == '*' {
+ return offer
+ }
+ if accepted[i] != offer[i] {
+ break
+ }
+ }
+ if i == len(accepted) {
+ return offer
}
}
}
return ""
}
+// SetAccepted sets Accept header data.
func (c *Context) SetAccepted(formats ...string) {
c.Accepted = formats
}
@@ -894,26 +1147,20 @@ func (c *Context) SetAccepted(formats ...string) {
/***** GOLANG.ORG/X/NET/CONTEXT *****/
/************************************/
-// Deadline returns the time when work done on behalf of this context
-// should be canceled. Deadline returns ok==false when no deadline is
-// set. Successive calls to Deadline return the same results.
+// Deadline always returns that there is no deadline (ok==false),
+// maybe you want to use Request.Context().Deadline() instead.
func (c *Context) Deadline() (deadline time.Time, ok bool) {
return
}
-// Done returns a channel that's closed when work done on behalf of this
-// context should be canceled. Done may return nil if this context can
-// never be canceled. Successive calls to Done return the same value.
+// Done always returns nil (chan which will wait forever),
+// if you want to abort your work when the connection was closed
+// you should use Request.Context().Done() instead.
func (c *Context) Done() <-chan struct{} {
return nil
}
-// Err returns a non-nil error value after Done is closed,
-// successive calls to Err return the same error.
-// If Done is not yet closed, Err returns nil.
-// If Done is closed, Err returns a non-nil error explaining why:
-// Canceled if the context was canceled
-// or DeadlineExceeded if the context's deadline passed.
+// Err always returns nil, maybe you want to use Request.Context().Err() instead.
func (c *Context) Err() error {
return nil
}
diff --git a/vendor/github.com/gin-gonic/gin/context_appengine.go b/vendor/github.com/gin-gonic/gin/context_appengine.go
index 38c189a..d565843 100644
--- a/vendor/github.com/gin-gonic/gin/context_appengine.go
+++ b/vendor/github.com/gin-gonic/gin/context_appengine.go
@@ -1,9 +1,10 @@
-// +build appengine
-
// Copyright 2017 Manu Martinez-Almeida. All rights reserved.
// Use of this source code is governed by a MIT style
// license that can be found in the LICENSE file.
+//go:build appengine
+// +build appengine
+
package gin
func init() {
diff --git a/vendor/github.com/gin-gonic/gin/coverage.sh b/vendor/github.com/gin-gonic/gin/coverage.sh
deleted file mode 100644
index 4d1ee03..0000000
--- a/vendor/github.com/gin-gonic/gin/coverage.sh
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/usr/bin/env bash
-
-set -e
-
-echo "mode: count" > coverage.out
-
-for d in $(go list ./... | grep -E 'gin$|binding$|render$' | grep -v 'examples'); do
- go test -v -covermode=count -coverprofile=profile.out $d
- if [ -f profile.out ]; then
- cat profile.out | grep -v "mode:" >> coverage.out
- rm profile.out
- fi
-done
diff --git a/vendor/github.com/gin-gonic/gin/debug.go b/vendor/github.com/gin-gonic/gin/debug.go
index f11156b..4c7cd0c 100644
--- a/vendor/github.com/gin-gonic/gin/debug.go
+++ b/vendor/github.com/gin-gonic/gin/debug.go
@@ -5,14 +5,14 @@
package gin
import (
- "bytes"
+ "fmt"
"html/template"
- "log"
+ "runtime"
+ "strconv"
+ "strings"
)
-func init() {
- log.SetFlags(0)
-}
+const ginSupportMinGoVer = 12
// IsDebugging returns true if the framework is running in debug mode.
// Use SetMode(gin.ReleaseMode) to disable debug mode.
@@ -20,17 +20,24 @@ func IsDebugging() bool {
return ginMode == debugCode
}
+// DebugPrintRouteFunc indicates debug log output format.
+var DebugPrintRouteFunc func(httpMethod, absolutePath, handlerName string, nuHandlers int)
+
func debugPrintRoute(httpMethod, absolutePath string, handlers HandlersChain) {
if IsDebugging() {
nuHandlers := len(handlers)
handlerName := nameOfFunction(handlers.Last())
- debugPrint("%-6s %-25s --> %s (%d handlers)\n", httpMethod, absolutePath, handlerName, nuHandlers)
+ if DebugPrintRouteFunc == nil {
+ debugPrint("%-6s %-25s --> %s (%d handlers)\n", httpMethod, absolutePath, handlerName, nuHandlers)
+ } else {
+ DebugPrintRouteFunc(httpMethod, absolutePath, handlerName, nuHandlers)
+ }
}
}
func debugPrintLoadTemplate(tmpl *template.Template) {
if IsDebugging() {
- var buf bytes.Buffer
+ var buf strings.Builder
for _, tmpl := range tmpl.Templates() {
buf.WriteString("\t- ")
buf.WriteString(tmpl.Name())
@@ -42,14 +49,28 @@ func debugPrintLoadTemplate(tmpl *template.Template) {
func debugPrint(format string, values ...interface{}) {
if IsDebugging() {
- log.Printf("[GIN-debug] "+format, values...)
+ if !strings.HasSuffix(format, "\n") {
+ format += "\n"
+ }
+ fmt.Fprintf(DefaultWriter, "[GIN-debug] "+format, values...)
}
}
+func getMinVer(v string) (uint64, error) {
+ first := strings.IndexByte(v, '.')
+ last := strings.LastIndexByte(v, '.')
+ if first == last {
+ return strconv.ParseUint(v[first+1:], 10, 64)
+ }
+ return strconv.ParseUint(v[first+1:last], 10, 64)
+}
+
func debugPrintWARNINGDefault() {
- debugPrint(`[WARNING] Now Gin requires Go 1.6 or later and Go 1.7 will be required soon.
+ if v, e := getMinVer(runtime.Version()); e == nil && v <= ginSupportMinGoVer {
+ debugPrint(`[WARNING] Now Gin requires Go 1.12+.
`)
+ }
debugPrint(`[WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached.
`)
@@ -75,6 +96,8 @@ at initialization. ie. before any route is registered or the router is listening
func debugPrintError(err error) {
if err != nil {
- debugPrint("[ERROR] %v\n", err)
+ if IsDebugging() {
+ fmt.Fprintf(DefaultErrorWriter, "[GIN-debug] [ERROR] %v\n", err)
+ }
}
}
diff --git a/vendor/github.com/gin-gonic/gin/doc.go b/vendor/github.com/gin-gonic/gin/doc.go
index 01ac4a9..1bd0386 100644
--- a/vendor/github.com/gin-gonic/gin/doc.go
+++ b/vendor/github.com/gin-gonic/gin/doc.go
@@ -1,6 +1,6 @@
/*
Package gin implements a HTTP web framework called gin.
-See https://gin-gonic.github.io/gin/ for more information about gin.
+See https://gin-gonic.com/ for more information about gin.
*/
package gin // import "github.com/gin-gonic/gin"
diff --git a/vendor/github.com/gin-gonic/gin/errors.go b/vendor/github.com/gin-gonic/gin/errors.go
index dbfccd8..0f276c1 100644
--- a/vendor/github.com/gin-gonic/gin/errors.go
+++ b/vendor/github.com/gin-gonic/gin/errors.go
@@ -5,25 +5,32 @@
package gin
import (
- "bytes"
"fmt"
"reflect"
+ "strings"
- "github.com/gin-gonic/gin/json"
+ "github.com/gin-gonic/gin/internal/json"
)
+// ErrorType is an unsigned 64-bit error code as defined in the gin spec.
type ErrorType uint64
const (
- ErrorTypeBind ErrorType = 1 << 63 // used when c.Bind() fails
- ErrorTypeRender ErrorType = 1 << 62 // used when c.Render() fails
+ // ErrorTypeBind is used when Context.Bind() fails.
+ ErrorTypeBind ErrorType = 1 << 63
+ // ErrorTypeRender is used when Context.Render() fails.
+ ErrorTypeRender ErrorType = 1 << 62
+ // ErrorTypePrivate indicates a private error.
ErrorTypePrivate ErrorType = 1 << 0
- ErrorTypePublic ErrorType = 1 << 1
-
+ // ErrorTypePublic indicates a public error.
+ ErrorTypePublic ErrorType = 1 << 1
+ // ErrorTypeAny indicates any other error.
ErrorTypeAny ErrorType = 1<<64 - 1
- ErrorTypeNu = 2
+ // ErrorTypeNu indicates any other error.
+ ErrorTypeNu = 2
)
+// Error represents a error's specification.
type Error struct {
Err error
Type ErrorType
@@ -34,18 +41,21 @@ type errorMsgs []*Error
var _ error = &Error{}
+// SetType sets the error's type.
func (msg *Error) SetType(flags ErrorType) *Error {
msg.Type = flags
return msg
}
+// SetMeta sets the error's meta data.
func (msg *Error) SetMeta(data interface{}) *Error {
msg.Meta = data
return msg
}
+// JSON creates a properly formatted JSON
func (msg *Error) JSON() interface{} {
- json := H{}
+ jsonData := H{}
if msg.Meta != nil {
value := reflect.ValueOf(msg.Meta)
switch value.Kind() {
@@ -53,16 +63,16 @@ func (msg *Error) JSON() interface{} {
return msg.Meta
case reflect.Map:
for _, key := range value.MapKeys() {
- json[key.String()] = value.MapIndex(key).Interface()
+ jsonData[key.String()] = value.MapIndex(key).Interface()
}
default:
- json["meta"] = msg.Meta
+ jsonData["meta"] = msg.Meta
}
}
- if _, ok := json["error"]; !ok {
- json["error"] = msg.Error()
+ if _, ok := jsonData["error"]; !ok {
+ jsonData["error"] = msg.Error()
}
- return json
+ return jsonData
}
// MarshalJSON implements the json.Marshaller interface.
@@ -70,15 +80,21 @@ func (msg *Error) MarshalJSON() ([]byte, error) {
return json.Marshal(msg.JSON())
}
-// Error implements the error interface
+// Error implements the error interface.
func (msg Error) Error() string {
return msg.Err.Error()
}
+// IsType judges one error.
func (msg *Error) IsType(flags ErrorType) bool {
return (msg.Type & flags) > 0
}
+// Unwrap returns the wrapped error, to allow interoperability with errors.Is(), errors.As() and errors.Unwrap()
+func (msg *Error) Unwrap() error {
+ return msg.Err
+}
+
// ByType returns a readonly copy filtered the byte.
// ie ByType(gin.ErrorTypePublic) returns a slice of errors with type=ErrorTypePublic.
func (a errorMsgs) ByType(typ ErrorType) errorMsgs {
@@ -124,20 +140,21 @@ func (a errorMsgs) Errors() []string {
}
func (a errorMsgs) JSON() interface{} {
- switch len(a) {
+ switch length := len(a); length {
case 0:
return nil
case 1:
return a.Last().JSON()
default:
- json := make([]interface{}, len(a))
+ jsonData := make([]interface{}, length)
for i, err := range a {
- json[i] = err.JSON()
+ jsonData[i] = err.JSON()
}
- return json
+ return jsonData
}
}
+// MarshalJSON implements the json.Marshaller interface.
func (a errorMsgs) MarshalJSON() ([]byte, error) {
return json.Marshal(a.JSON())
}
@@ -146,7 +163,7 @@ func (a errorMsgs) String() string {
if len(a) == 0 {
return ""
}
- var buffer bytes.Buffer
+ var buffer strings.Builder
for i, msg := range a {
fmt.Fprintf(&buffer, "Error #%02d: %s\n", i+1, msg.Err)
if msg.Meta != nil {
diff --git a/vendor/github.com/gin-gonic/gin/fs.go b/vendor/github.com/gin-gonic/gin/fs.go
index 7a6738a..007d9b7 100644
--- a/vendor/github.com/gin-gonic/gin/fs.go
+++ b/vendor/github.com/gin-gonic/gin/fs.go
@@ -9,7 +9,7 @@ import (
"os"
)
-type onlyfilesFS struct {
+type onlyFilesFS struct {
fs http.FileSystem
}
@@ -26,11 +26,11 @@ func Dir(root string, listDirectory bool) http.FileSystem {
if listDirectory {
return fs
}
- return &onlyfilesFS{fs}
+ return &onlyFilesFS{fs}
}
// Open conforms to http.Filesystem.
-func (fs onlyfilesFS) Open(name string) (http.File, error) {
+func (fs onlyFilesFS) Open(name string) (http.File, error) {
f, err := fs.fs.Open(name)
if err != nil {
return nil, err
diff --git a/vendor/github.com/gin-gonic/gin/gin.go b/vendor/github.com/gin-gonic/gin/gin.go
index aa62e01..03a0e12 100644
--- a/vendor/github.com/gin-gonic/gin/gin.go
+++ b/vendor/github.com/gin-gonic/gin/gin.go
@@ -5,31 +5,35 @@
package gin
import (
+ "fmt"
"html/template"
"net"
"net/http"
"os"
+ "path"
+ "strings"
"sync"
+ "github.com/gin-gonic/gin/internal/bytesconv"
"github.com/gin-gonic/gin/render"
)
-const (
- // Version is Framework's version.
- Version = "v1.3.0"
- defaultMultipartMemory = 32 << 20 // 32 MB
-)
+const defaultMultipartMemory = 32 << 20 // 32 MB
var (
- default404Body = []byte("404 page not found")
- default405Body = []byte("405 method not allowed")
- defaultAppEngine bool
+ default404Body = []byte("404 page not found")
+ default405Body = []byte("405 method not allowed")
)
+var defaultAppEngine bool
+
+// HandlerFunc defines the handler used by gin middleware as return value.
type HandlerFunc func(*Context)
+
+// HandlersChain defines a HandlerFunc array.
type HandlersChain []HandlerFunc
-// Last returns the last handler in the chain. ie. the last handler is the main own.
+// Last returns the last handler in the chain. ie. the last handler is the main one.
func (c HandlersChain) Last() HandlerFunc {
if length := len(c); length > 0 {
return c[length-1]
@@ -37,12 +41,15 @@ func (c HandlersChain) Last() HandlerFunc {
return nil
}
+// RouteInfo represents a request route's specification which contains method and path and its handler.
type RouteInfo struct {
- Method string
- Path string
- Handler string
+ Method string
+ Path string
+ Handler string
+ HandlerFunc HandlerFunc
}
+// RoutesInfo defines a RouteInfo array.
type RoutesInfo []RouteInfo
// Engine is the framework's instance, it contains the muxer, middleware and configuration settings.
@@ -75,9 +82,26 @@ type Engine struct {
// If no other Method is allowed, the request is delegated to the NotFound
// handler.
HandleMethodNotAllowed bool
- ForwardedByClientIP bool
- // #726 #755 If enabled, it will thrust some headers starting with
+ // If enabled, client IP will be parsed from the request's headers that
+ // match those stored at `(*gin.Engine).RemoteIPHeaders`. If no IP was
+ // fetched, it falls back to the IP obtained from
+ // `(*gin.Context).Request.RemoteAddr`.
+ ForwardedByClientIP bool
+
+ // List of headers used to obtain the client IP when
+ // `(*gin.Engine).ForwardedByClientIP` is `true` and
+ // `(*gin.Context).Request.RemoteAddr` is matched by at least one of the
+ // network origins of `(*gin.Engine).TrustedProxies`.
+ RemoteIPHeaders []string
+
+ // List of network origins (IPv4 addresses, IPv4 CIDRs, IPv6 addresses or
+ // IPv6 CIDRs) from which to trust request's headers that contain
+ // alternative client IP when `(*gin.Engine).ForwardedByClientIP` is
+ // `true`.
+ TrustedProxies []string
+
+ // #726 #755 If enabled, it will trust some headers starting with
// 'X-AppEngine...' for better integration with that PaaS.
AppEngine bool
@@ -93,8 +117,12 @@ type Engine struct {
// method call.
MaxMultipartMemory int64
+ // RemoveExtraSlash a parameter can be parsed from the URL even with extra slashes.
+ // See the PR #1817 and issue #1644
+ RemoveExtraSlash bool
+
delims render.Delims
- secureJsonPrefix string
+ secureJSONPrefix string
HTMLRender render.HTMLRender
FuncMap template.FuncMap
allNoRoute HandlersChain
@@ -103,6 +131,8 @@ type Engine struct {
noMethod HandlersChain
pool sync.Pool
trees methodTrees
+ maxParams uint16
+ trustedCIDRs []*net.IPNet
}
var _ IRouter = &Engine{}
@@ -128,13 +158,16 @@ func New() *Engine {
RedirectFixedPath: false,
HandleMethodNotAllowed: false,
ForwardedByClientIP: true,
+ RemoteIPHeaders: []string{"X-Forwarded-For", "X-Real-IP"},
+ TrustedProxies: []string{"0.0.0.0/0"},
AppEngine: defaultAppEngine,
UseRawPath: false,
+ RemoveExtraSlash: false,
UnescapePathValues: true,
MaxMultipartMemory: defaultMultipartMemory,
trees: make(methodTrees, 0, 9),
delims: render.Delims{Left: "{{", Right: "}}"},
- secureJsonPrefix: "while(1);",
+ secureJSONPrefix: "while(1);",
}
engine.RouterGroup.engine = engine
engine.pool.New = func() interface{} {
@@ -152,17 +185,19 @@ func Default() *Engine {
}
func (engine *Engine) allocateContext() *Context {
- return &Context{engine: engine}
+ v := make(Params, 0, engine.maxParams)
+ return &Context{engine: engine, params: &v}
}
+// Delims sets template left and right delims and returns a Engine instance.
func (engine *Engine) Delims(left, right string) *Engine {
engine.delims = render.Delims{Left: left, Right: right}
return engine
}
-// SecureJsonPrefix sets the secureJsonPrefix used in Context.SecureJSON.
+// SecureJsonPrefix sets the secureJSONPrefix used in Context.SecureJSON.
func (engine *Engine) SecureJsonPrefix(prefix string) *Engine {
- engine.secureJsonPrefix = prefix
+ engine.secureJSONPrefix = prefix
return engine
}
@@ -220,7 +255,7 @@ func (engine *Engine) NoMethod(handlers ...HandlerFunc) {
engine.rebuild405Handlers()
}
-// Use attachs a global middleware to the router. ie. the middleware attached though Use() will be
+// Use attaches a global middleware to the router. ie. the middleware attached though Use() will be
// included in the handlers chain for every single request. Even 404, 405, static files...
// For example, this is the right place for a logger or error management middleware.
func (engine *Engine) Use(middleware ...HandlerFunc) IRoutes {
@@ -244,12 +279,19 @@ func (engine *Engine) addRoute(method, path string, handlers HandlersChain) {
assert1(len(handlers) > 0, "there must be at least one handler")
debugPrintRoute(method, path, handlers)
+
root := engine.trees.get(method)
if root == nil {
root = new(node)
+ root.fullPath = "/"
engine.trees = append(engine.trees, methodTree{method: method, root: root})
}
root.addRoute(path, handlers)
+
+ // Update maxParams
+ if paramsCount := countParams(path); paramsCount > engine.maxParams {
+ engine.maxParams = paramsCount
+ }
}
// Routes returns a slice of registered routes, including some useful information, such as:
@@ -264,10 +306,12 @@ func (engine *Engine) Routes() (routes RoutesInfo) {
func iterate(path, method string, routes RoutesInfo, root *node) RoutesInfo {
path += root.path
if len(root.handlers) > 0 {
+ handlerFunc := root.handlers.Last()
routes = append(routes, RouteInfo{
- Method: method,
- Path: path,
- Handler: nameOfFunction(root.handlers.Last()),
+ Method: method,
+ Path: path,
+ Handler: nameOfFunction(handlerFunc),
+ HandlerFunc: handlerFunc,
})
}
for _, child := range root.children {
@@ -282,12 +326,60 @@ func iterate(path, method string, routes RoutesInfo, root *node) RoutesInfo {
func (engine *Engine) Run(addr ...string) (err error) {
defer func() { debugPrintError(err) }()
+ trustedCIDRs, err := engine.prepareTrustedCIDRs()
+ if err != nil {
+ return err
+ }
+ engine.trustedCIDRs = trustedCIDRs
address := resolveAddress(addr)
debugPrint("Listening and serving HTTP on %s\n", address)
err = http.ListenAndServe(address, engine)
return
}
+func (engine *Engine) prepareTrustedCIDRs() ([]*net.IPNet, error) {
+ if engine.TrustedProxies == nil {
+ return nil, nil
+ }
+
+ cidr := make([]*net.IPNet, 0, len(engine.TrustedProxies))
+ for _, trustedProxy := range engine.TrustedProxies {
+ if !strings.Contains(trustedProxy, "/") {
+ ip := parseIP(trustedProxy)
+ if ip == nil {
+ return cidr, &net.ParseError{Type: "IP address", Text: trustedProxy}
+ }
+
+ switch len(ip) {
+ case net.IPv4len:
+ trustedProxy += "/32"
+ case net.IPv6len:
+ trustedProxy += "/128"
+ }
+ }
+ _, cidrNet, err := net.ParseCIDR(trustedProxy)
+ if err != nil {
+ return cidr, err
+ }
+ cidr = append(cidr, cidrNet)
+ }
+ return cidr, nil
+}
+
+// parseIP parse a string representation of an IP and returns a net.IP with the
+// minimum byte representation or nil if input is invalid.
+func parseIP(ip string) net.IP {
+ parsedIP := net.ParseIP(ip)
+
+ if ipv4 := parsedIP.To4(); ipv4 != nil {
+ // return ip in a 4-byte representation
+ return ipv4
+ }
+
+ // return ip in a 16-byte representation or nil
+ return parsedIP
+}
+
// RunTLS attaches the router to a http.Server and starts listening and serving HTTPS (secure) requests.
// It is a shortcut for http.ListenAndServeTLS(addr, certFile, keyFile, router)
// Note: this method will block the calling goroutine indefinitely unless an error happens.
@@ -306,12 +398,39 @@ func (engine *Engine) RunUnix(file string) (err error) {
debugPrint("Listening and serving HTTP on unix:/%s", file)
defer func() { debugPrintError(err) }()
- os.Remove(file)
listener, err := net.Listen("unix", file)
if err != nil {
return
}
defer listener.Close()
+ defer os.Remove(file)
+
+ err = http.Serve(listener, engine)
+ return
+}
+
+// RunFd attaches the router to a http.Server and starts listening and serving HTTP requests
+// through the specified file descriptor.
+// Note: this method will block the calling goroutine indefinitely unless an error happens.
+func (engine *Engine) RunFd(fd int) (err error) {
+ debugPrint("Listening and serving HTTP on fd@%d", fd)
+ defer func() { debugPrintError(err) }()
+
+ f := os.NewFile(uintptr(fd), fmt.Sprintf("fd@%d", fd))
+ listener, err := net.FileListener(f)
+ if err != nil {
+ return
+ }
+ defer listener.Close()
+ err = engine.RunListener(listener)
+ return
+}
+
+// RunListener attaches the router to a http.Server and starts listening and serving HTTP requests
+// through the specified net.Listener
+func (engine *Engine) RunListener(listener net.Listener) (err error) {
+ debugPrint("Listening and serving HTTP on listener what's bind with address@%s", listener.Addr())
+ defer func() { debugPrintError(err) }()
err = http.Serve(listener, engine)
return
}
@@ -332,20 +451,26 @@ func (engine *Engine) ServeHTTP(w http.ResponseWriter, req *http.Request) {
// This can be done by setting c.Request.URL.Path to your new target.
// Disclaimer: You can loop yourself to death with this, use wisely.
func (engine *Engine) HandleContext(c *Context) {
+ oldIndexValue := c.index
c.reset()
engine.handleHTTPRequest(c)
- engine.pool.Put(c)
+
+ c.index = oldIndexValue
}
func (engine *Engine) handleHTTPRequest(c *Context) {
httpMethod := c.Request.Method
- path := c.Request.URL.Path
+ rPath := c.Request.URL.Path
unescape := false
if engine.UseRawPath && len(c.Request.URL.RawPath) > 0 {
- path = c.Request.URL.RawPath
+ rPath = c.Request.URL.RawPath
unescape = engine.UnescapePathValues
}
+ if engine.RemoveExtraSlash {
+ rPath = cleanPath(rPath)
+ }
+
// Find root of the tree for the given HTTP method
t := engine.trees
for i, tl := 0, len(t); i < tl; i++ {
@@ -354,16 +479,19 @@ func (engine *Engine) handleHTTPRequest(c *Context) {
}
root := t[i].root
// Find route in tree
- handlers, params, tsr := root.getValue(path, c.Params, unescape)
- if handlers != nil {
- c.handlers = handlers
- c.Params = params
+ value := root.getValue(rPath, c.params, unescape)
+ if value.params != nil {
+ c.Params = *value.params
+ }
+ if value.handlers != nil {
+ c.handlers = value.handlers
+ c.fullPath = value.fullPath
c.Next()
c.writermem.WriteHeaderNow()
return
}
- if httpMethod != "CONNECT" && path != "/" {
- if tsr && engine.RedirectTrailingSlash {
+ if httpMethod != "CONNECT" && rPath != "/" {
+ if value.tsr && engine.RedirectTrailingSlash {
redirectTrailingSlash(c)
return
}
@@ -379,7 +507,7 @@ func (engine *Engine) handleHTTPRequest(c *Context) {
if tree.method == httpMethod {
continue
}
- if handlers, _, _ := tree.root.getValue(path, nil, unescape); handlers != nil {
+ if value := tree.root.getValue(rPath, nil, unescape); value.handlers != nil {
c.handlers = engine.allNoMethod
serveError(c, http.StatusMethodNotAllowed, default405Body)
return
@@ -400,44 +528,50 @@ func serveError(c *Context, code int, defaultMessage []byte) {
}
if c.writermem.Status() == code {
c.writermem.Header()["Content-Type"] = mimePlain
- c.Writer.Write(defaultMessage)
+ _, err := c.Writer.Write(defaultMessage)
+ if err != nil {
+ debugPrint("cannot write message to writer during serve error: %v", err)
+ }
return
}
c.writermem.WriteHeaderNow()
- return
}
func redirectTrailingSlash(c *Context) {
req := c.Request
- path := req.URL.Path
- code := http.StatusMovedPermanently // Permanent redirect, request with GET method
- if req.Method != "GET" {
- code = http.StatusTemporaryRedirect
+ p := req.URL.Path
+ if prefix := path.Clean(c.Request.Header.Get("X-Forwarded-Prefix")); prefix != "." {
+ p = prefix + "/" + req.URL.Path
}
-
- req.URL.Path = path + "/"
- if length := len(path); length > 1 && path[length-1] == '/' {
- req.URL.Path = path[:length-1]
+ req.URL.Path = p + "/"
+ if length := len(p); length > 1 && p[length-1] == '/' {
+ req.URL.Path = p[:length-1]
}
- debugPrint("redirecting request %d: %s --> %s", code, path, req.URL.String())
- http.Redirect(c.Writer, req, req.URL.String(), code)
- c.writermem.WriteHeaderNow()
+ redirectRequest(c)
}
func redirectFixedPath(c *Context, root *node, trailingSlash bool) bool {
req := c.Request
- path := req.URL.Path
+ rPath := req.URL.Path
- if fixedPath, ok := root.findCaseInsensitivePath(cleanPath(path), trailingSlash); ok {
- code := http.StatusMovedPermanently // Permanent redirect, request with GET method
- if req.Method != "GET" {
- code = http.StatusTemporaryRedirect
- }
- req.URL.Path = string(fixedPath)
- debugPrint("redirecting request %d: %s --> %s", code, path, req.URL.String())
- http.Redirect(c.Writer, req, req.URL.String(), code)
- c.writermem.WriteHeaderNow()
+ if fixedPath, ok := root.findCaseInsensitivePath(cleanPath(rPath), trailingSlash); ok {
+ req.URL.Path = bytesconv.BytesToString(fixedPath)
+ redirectRequest(c)
return true
}
return false
}
+
+func redirectRequest(c *Context) {
+ req := c.Request
+ rPath := req.URL.Path
+ rURL := req.URL.String()
+
+ code := http.StatusMovedPermanently // Permanent redirect, request with GET method
+ if req.Method != http.MethodGet {
+ code = http.StatusTemporaryRedirect
+ }
+ debugPrint("redirecting request %d: %s --> %s", code, rPath, rURL)
+ http.Redirect(c.Writer, req, rURL, code)
+ c.writermem.WriteHeaderNow()
+}
diff --git a/vendor/github.com/gin-gonic/gin/json/json.go b/vendor/github.com/gin-gonic/gin/json/json.go
deleted file mode 100644
index aa76aa3..0000000
--- a/vendor/github.com/gin-gonic/gin/json/json.go
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright 2017 Bo-Yi Wu. All rights reserved.
-// Use of this source code is governed by a MIT style
-// license that can be found in the LICENSE file.
-
-// +build !jsoniter
-
-package json
-
-import "encoding/json"
-
-var (
- Marshal = json.Marshal
- MarshalIndent = json.MarshalIndent
- NewDecoder = json.NewDecoder
-)
diff --git a/vendor/github.com/gin-gonic/gin/json/jsoniter.go b/vendor/github.com/gin-gonic/gin/json/jsoniter.go
deleted file mode 100644
index ffe1424..0000000
--- a/vendor/github.com/gin-gonic/gin/json/jsoniter.go
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright 2017 Bo-Yi Wu. All rights reserved.
-// Use of this source code is governed by a MIT style
-// license that can be found in the LICENSE file.
-
-// +build jsoniter
-
-package json
-
-import "github.com/json-iterator/go"
-
-var (
- json = jsoniter.ConfigCompatibleWithStandardLibrary
- Marshal = json.Marshal
- MarshalIndent = json.MarshalIndent
- NewDecoder = json.NewDecoder
-)
diff --git a/vendor/github.com/gin-gonic/gin/logger.go b/vendor/github.com/gin-gonic/gin/logger.go
index 1a8df60..d361b74 100644
--- a/vendor/github.com/gin-gonic/gin/logger.go
+++ b/vendor/github.com/gin-gonic/gin/logger.go
@@ -14,21 +14,152 @@ import (
"github.com/mattn/go-isatty"
)
-var (
- green = string([]byte{27, 91, 57, 55, 59, 52, 50, 109})
- white = string([]byte{27, 91, 57, 48, 59, 52, 55, 109})
- yellow = string([]byte{27, 91, 57, 55, 59, 52, 51, 109})
- red = string([]byte{27, 91, 57, 55, 59, 52, 49, 109})
- blue = string([]byte{27, 91, 57, 55, 59, 52, 52, 109})
- magenta = string([]byte{27, 91, 57, 55, 59, 52, 53, 109})
- cyan = string([]byte{27, 91, 57, 55, 59, 52, 54, 109})
- reset = string([]byte{27, 91, 48, 109})
- disableColor = false
+type consoleColorModeValue int
+
+const (
+ autoColor consoleColorModeValue = iota
+ disableColor
+ forceColor
+)
+
+const (
+ green = "\033[97;42m"
+ white = "\033[90;47m"
+ yellow = "\033[90;43m"
+ red = "\033[97;41m"
+ blue = "\033[97;44m"
+ magenta = "\033[97;45m"
+ cyan = "\033[97;46m"
+ reset = "\033[0m"
)
+var consoleColorMode = autoColor
+
+// LoggerConfig defines the config for Logger middleware.
+type LoggerConfig struct {
+ // Optional. Default value is gin.defaultLogFormatter
+ Formatter LogFormatter
+
+ // Output is a writer where logs are written.
+ // Optional. Default value is gin.DefaultWriter.
+ Output io.Writer
+
+ // SkipPaths is a url path array which logs are not written.
+ // Optional.
+ SkipPaths []string
+}
+
+// LogFormatter gives the signature of the formatter function passed to LoggerWithFormatter
+type LogFormatter func(params LogFormatterParams) string
+
+// LogFormatterParams is the structure any formatter will be handed when time to log comes
+type LogFormatterParams struct {
+ Request *http.Request
+
+ // TimeStamp shows the time after the server returns a response.
+ TimeStamp time.Time
+ // StatusCode is HTTP response code.
+ StatusCode int
+ // Latency is how much time the server cost to process a certain request.
+ Latency time.Duration
+ // ClientIP equals Context's ClientIP method.
+ ClientIP string
+ // Method is the HTTP method given to the request.
+ Method string
+ // Path is a path the client requests.
+ Path string
+ // ErrorMessage is set if error has occurred in processing the request.
+ ErrorMessage string
+ // isTerm shows whether does gin's output descriptor refers to a terminal.
+ isTerm bool
+ // BodySize is the size of the Response Body
+ BodySize int
+ // Keys are the keys set on the request's context.
+ Keys map[string]interface{}
+}
+
+// StatusCodeColor is the ANSI color for appropriately logging http status code to a terminal.
+func (p *LogFormatterParams) StatusCodeColor() string {
+ code := p.StatusCode
+
+ switch {
+ case code >= http.StatusOK && code < http.StatusMultipleChoices:
+ return green
+ case code >= http.StatusMultipleChoices && code < http.StatusBadRequest:
+ return white
+ case code >= http.StatusBadRequest && code < http.StatusInternalServerError:
+ return yellow
+ default:
+ return red
+ }
+}
+
+// MethodColor is the ANSI color for appropriately logging http method to a terminal.
+func (p *LogFormatterParams) MethodColor() string {
+ method := p.Method
+
+ switch method {
+ case http.MethodGet:
+ return blue
+ case http.MethodPost:
+ return cyan
+ case http.MethodPut:
+ return yellow
+ case http.MethodDelete:
+ return red
+ case http.MethodPatch:
+ return green
+ case http.MethodHead:
+ return magenta
+ case http.MethodOptions:
+ return white
+ default:
+ return reset
+ }
+}
+
+// ResetColor resets all escape attributes.
+func (p *LogFormatterParams) ResetColor() string {
+ return reset
+}
+
+// IsOutputColor indicates whether can colors be outputted to the log.
+func (p *LogFormatterParams) IsOutputColor() bool {
+ return consoleColorMode == forceColor || (consoleColorMode == autoColor && p.isTerm)
+}
+
+// defaultLogFormatter is the default log format function Logger middleware uses.
+var defaultLogFormatter = func(param LogFormatterParams) string {
+ var statusColor, methodColor, resetColor string
+ if param.IsOutputColor() {
+ statusColor = param.StatusCodeColor()
+ methodColor = param.MethodColor()
+ resetColor = param.ResetColor()
+ }
+
+ if param.Latency > time.Minute {
+ // Truncate in a golang < 1.8 safe way
+ param.Latency = param.Latency - param.Latency%time.Second
+ }
+ return fmt.Sprintf("[GIN] %v |%s %3d %s| %13v | %15s |%s %-7s %s %#v\n%s",
+ param.TimeStamp.Format("2006/01/02 - 15:04:05"),
+ statusColor, param.StatusCode, resetColor,
+ param.Latency,
+ param.ClientIP,
+ methodColor, param.Method, resetColor,
+ param.Path,
+ param.ErrorMessage,
+ )
+}
+
// DisableConsoleColor disables color output in the console.
func DisableConsoleColor() {
- disableColor = true
+ consoleColorMode = disableColor
+}
+
+// ForceConsoleColor force color output in the console.
+func ForceConsoleColor() {
+ consoleColorMode = forceColor
}
// ErrorLogger returns a handlerfunc for any error type.
@@ -50,17 +181,43 @@ func ErrorLoggerT(typ ErrorType) HandlerFunc {
// Logger instances a Logger middleware that will write the logs to gin.DefaultWriter.
// By default gin.DefaultWriter = os.Stdout.
func Logger() HandlerFunc {
- return LoggerWithWriter(DefaultWriter)
+ return LoggerWithConfig(LoggerConfig{})
+}
+
+// LoggerWithFormatter instance a Logger middleware with the specified log format function.
+func LoggerWithFormatter(f LogFormatter) HandlerFunc {
+ return LoggerWithConfig(LoggerConfig{
+ Formatter: f,
+ })
}
-// LoggerWithWriter instance a Logger middleware with the specified writter buffer.
+// LoggerWithWriter instance a Logger middleware with the specified writer buffer.
// Example: os.Stdout, a file opened in write mode, a socket...
func LoggerWithWriter(out io.Writer, notlogged ...string) HandlerFunc {
+ return LoggerWithConfig(LoggerConfig{
+ Output: out,
+ SkipPaths: notlogged,
+ })
+}
+
+// LoggerWithConfig instance a Logger middleware with config.
+func LoggerWithConfig(conf LoggerConfig) HandlerFunc {
+ formatter := conf.Formatter
+ if formatter == nil {
+ formatter = defaultLogFormatter
+ }
+
+ out := conf.Output
+ if out == nil {
+ out = DefaultWriter
+ }
+
+ notlogged := conf.SkipPaths
+
isTerm := true
- if w, ok := out.(*os.File); !ok ||
- (os.Getenv("TERM") == "dumb" || (!isatty.IsTerminal(w.Fd()) && !isatty.IsCygwinTerminal(w.Fd()))) ||
- disableColor {
+ if w, ok := out.(*os.File); !ok || os.Getenv("TERM") == "dumb" ||
+ (!isatty.IsTerminal(w.Fd()) && !isatty.IsCygwinTerminal(w.Fd())) {
isTerm = false
}
@@ -85,68 +242,30 @@ func LoggerWithWriter(out io.Writer, notlogged ...string) HandlerFunc {
// Log only when path is not being skipped
if _, ok := skip[path]; !ok {
- // Stop timer
- end := time.Now()
- latency := end.Sub(start)
-
- clientIP := c.ClientIP()
- method := c.Request.Method
- statusCode := c.Writer.Status()
- var statusColor, methodColor, resetColor string
- if isTerm {
- statusColor = colorForStatus(statusCode)
- methodColor = colorForMethod(method)
- resetColor = reset
+ param := LogFormatterParams{
+ Request: c.Request,
+ isTerm: isTerm,
+ Keys: c.Keys,
}
- comment := c.Errors.ByType(ErrorTypePrivate).String()
+
+ // Stop timer
+ param.TimeStamp = time.Now()
+ param.Latency = param.TimeStamp.Sub(start)
+
+ param.ClientIP = c.ClientIP()
+ param.Method = c.Request.Method
+ param.StatusCode = c.Writer.Status()
+ param.ErrorMessage = c.Errors.ByType(ErrorTypePrivate).String()
+
+ param.BodySize = c.Writer.Size()
if raw != "" {
path = path + "?" + raw
}
- fmt.Fprintf(out, "[GIN] %v |%s %3d %s| %13v | %15s |%s %-7s %s %s\n%s",
- end.Format("2006/01/02 - 15:04:05"),
- statusColor, statusCode, resetColor,
- latency,
- clientIP,
- methodColor, method, resetColor,
- path,
- comment,
- )
- }
- }
-}
+ param.Path = path
-func colorForStatus(code int) string {
- switch {
- case code >= http.StatusOK && code < http.StatusMultipleChoices:
- return green
- case code >= http.StatusMultipleChoices && code < http.StatusBadRequest:
- return white
- case code >= http.StatusBadRequest && code < http.StatusInternalServerError:
- return yellow
- default:
- return red
- }
-}
-
-func colorForMethod(method string) string {
- switch method {
- case "GET":
- return blue
- case "POST":
- return cyan
- case "PUT":
- return yellow
- case "DELETE":
- return red
- case "PATCH":
- return green
- case "HEAD":
- return magenta
- case "OPTIONS":
- return white
- default:
- return reset
+ fmt.Fprint(out, formatter(param))
+ }
}
}
diff --git a/vendor/github.com/gin-gonic/gin/mode.go b/vendor/github.com/gin-gonic/gin/mode.go
index 9df4e45..c8813af 100644
--- a/vendor/github.com/gin-gonic/gin/mode.go
+++ b/vendor/github.com/gin-gonic/gin/mode.go
@@ -11,20 +11,25 @@ import (
"github.com/gin-gonic/gin/binding"
)
-const ENV_GIN_MODE = "GIN_MODE"
+// EnvGinMode indicates environment name for gin mode.
+const EnvGinMode = "GIN_MODE"
const (
- DebugMode = "debug"
+ // DebugMode indicates gin mode is debug.
+ DebugMode = "debug"
+ // ReleaseMode indicates gin mode is release.
ReleaseMode = "release"
- TestMode = "test"
+ // TestMode indicates gin mode is test.
+ TestMode = "test"
)
+
const (
debugCode = iota
releaseCode
testCode
)
-// DefaultWriter is the default io.Writer used the Gin for debug output and
+// DefaultWriter is the default io.Writer used by Gin for debug output and
// middleware output like Logger() or Recovery().
// Note that both Logger and Recovery provides custom ways to configure their
// output io.Writer.
@@ -32,41 +37,56 @@ const (
// import "github.com/mattn/go-colorable"
// gin.DefaultWriter = colorable.NewColorableStdout()
var DefaultWriter io.Writer = os.Stdout
+
+// DefaultErrorWriter is the default io.Writer used by Gin to debug errors
var DefaultErrorWriter io.Writer = os.Stderr
var ginMode = debugCode
var modeName = DebugMode
func init() {
- mode := os.Getenv(ENV_GIN_MODE)
+ mode := os.Getenv(EnvGinMode)
SetMode(mode)
}
+// SetMode sets gin mode according to input string.
func SetMode(value string) {
+ if value == "" {
+ value = DebugMode
+ }
+
switch value {
- case DebugMode, "":
+ case DebugMode:
ginMode = debugCode
case ReleaseMode:
ginMode = releaseCode
case TestMode:
ginMode = testCode
default:
- panic("gin mode unknown: " + value)
- }
- if value == "" {
- value = DebugMode
+ panic("gin mode unknown: " + value + " (available mode: debug release test)")
}
+
modeName = value
}
+// DisableBindValidation closes the default validator.
func DisableBindValidation() {
binding.Validator = nil
}
+// EnableJsonDecoderUseNumber sets true for binding.EnableDecoderUseNumber to
+// call the UseNumber method on the JSON Decoder instance.
func EnableJsonDecoderUseNumber() {
binding.EnableDecoderUseNumber = true
}
+// EnableJsonDecoderDisallowUnknownFields sets true for binding.EnableDecoderDisallowUnknownFields to
+// call the DisallowUnknownFields method on the JSON Decoder instance.
+func EnableJsonDecoderDisallowUnknownFields() {
+ binding.EnableDecoderDisallowUnknownFields = true
+}
+
+// Mode returns currently gin mode.
func Mode() string {
return modeName
}
diff --git a/vendor/github.com/gin-gonic/gin/path.go b/vendor/github.com/gin-gonic/gin/path.go
index d1f5962..d42d6b9 100644
--- a/vendor/github.com/gin-gonic/gin/path.go
+++ b/vendor/github.com/gin-gonic/gin/path.go
@@ -19,13 +19,17 @@ package gin
//
// If the result of this process is an empty string, "/" is returned.
func cleanPath(p string) string {
+ const stackBufSize = 128
// Turn empty string into "/"
if p == "" {
return "/"
}
+ // Reasonably sized buffer on stack to avoid allocations in the common case.
+ // If a larger buffer is required, it gets allocated dynamically.
+ buf := make([]byte, 0, stackBufSize)
+
n := len(p)
- var buf []byte
// Invariants:
// reading from path; r is index of next byte to process.
@@ -37,15 +41,21 @@ func cleanPath(p string) string {
if p[0] != '/' {
r = 0
- buf = make([]byte, n+1)
+
+ if n+1 > stackBufSize {
+ buf = make([]byte, n+1)
+ } else {
+ buf = buf[:n+1]
+ }
buf[0] = '/'
}
trailing := n > 1 && p[n-1] == '/'
// A bit more clunky without a 'lazybuf' like the path package, but the loop
- // gets completely inlined (bufApp). So in contrast to the path package this
- // loop has no expensive function calls (except 1x make)
+ // gets completely inlined (bufApp calls).
+ // loop has no expensive function calls (except 1x make) // So in contrast to the path package this loop has no expensive function
+ // calls (except make, if needed).
for r < n {
switch {
@@ -69,7 +79,7 @@ func cleanPath(p string) string {
// can backtrack
w--
- if buf == nil {
+ if len(buf) == 0 {
for w > 1 && p[w] != '/' {
w--
}
@@ -81,14 +91,14 @@ func cleanPath(p string) string {
}
default:
- // real path element.
- // add slash if needed
+ // Real path element.
+ // Add slash if needed
if w > 1 {
bufApp(&buf, p, w, '/')
w++
}
- // copy element
+ // Copy element
for r < n && p[r] != '/' {
bufApp(&buf, p, w, p[r])
w++
@@ -97,27 +107,44 @@ func cleanPath(p string) string {
}
}
- // re-append trailing slash
+ // Re-append trailing slash
if trailing && w > 1 {
bufApp(&buf, p, w, '/')
w++
}
- if buf == nil {
+ // If the original string was not modified (or only shortened at the end),
+ // return the respective substring of the original string.
+ // Otherwise return a new string from the buffer.
+ if len(buf) == 0 {
return p[:w]
}
return string(buf[:w])
}
-// internal helper to lazily create a buffer if necessary.
+// Internal helper to lazily create a buffer if necessary.
+// Calls to this function get inlined.
func bufApp(buf *[]byte, s string, w int, c byte) {
- if *buf == nil {
+ b := *buf
+ if len(b) == 0 {
+ // No modification of the original string so far.
+ // If the next character is the same as in the original string, we do
+ // not yet have to allocate a buffer.
if s[w] == c {
return
}
- *buf = make([]byte, len(s))
- copy(*buf, s[:w])
+ // Otherwise use either the stack buffer, if it is large enough, or
+ // allocate a new buffer on the heap, and copy all previous characters.
+ length := len(s)
+ if length > cap(b) {
+ *buf = make([]byte, length)
+ } else {
+ *buf = (*buf)[:length]
+ }
+ b = *buf
+
+ copy(b, s[:w])
}
- (*buf)[w] = c
+ b[w] = c
}
diff --git a/vendor/github.com/gin-gonic/gin/recovery.go b/vendor/github.com/gin-gonic/gin/recovery.go
index 61c5bd5..563f5aa 100644
--- a/vendor/github.com/gin-gonic/gin/recovery.go
+++ b/vendor/github.com/gin-gonic/gin/recovery.go
@@ -10,9 +10,12 @@ import (
"io"
"io/ioutil"
"log"
+ "net"
"net/http"
"net/http/httputil"
+ "os"
"runtime"
+ "strings"
"time"
)
@@ -23,13 +26,29 @@ var (
slash = []byte("/")
)
+// RecoveryFunc defines the function passable to CustomRecovery.
+type RecoveryFunc func(c *Context, err interface{})
+
// Recovery returns a middleware that recovers from any panics and writes a 500 if there was one.
func Recovery() HandlerFunc {
return RecoveryWithWriter(DefaultErrorWriter)
}
+//CustomRecovery returns a middleware that recovers from any panics and calls the provided handle func to handle it.
+func CustomRecovery(handle RecoveryFunc) HandlerFunc {
+ return RecoveryWithWriter(DefaultErrorWriter, handle)
+}
+
// RecoveryWithWriter returns a middleware for a given writer that recovers from any panics and writes a 500 if there was one.
-func RecoveryWithWriter(out io.Writer) HandlerFunc {
+func RecoveryWithWriter(out io.Writer, recovery ...RecoveryFunc) HandlerFunc {
+ if len(recovery) > 0 {
+ return CustomRecoveryWithWriter(out, recovery[0])
+ }
+ return CustomRecoveryWithWriter(out, defaultHandleRecovery)
+}
+
+// CustomRecoveryWithWriter returns a middleware for a given writer that recovers from any panics and calls the provided handle func to handle it.
+func CustomRecoveryWithWriter(out io.Writer, handle RecoveryFunc) HandlerFunc {
var logger *log.Logger
if out != nil {
logger = log.New(out, "\n\n\x1b[31m", log.LstdFlags)
@@ -37,18 +56,54 @@ func RecoveryWithWriter(out io.Writer) HandlerFunc {
return func(c *Context) {
defer func() {
if err := recover(); err != nil {
+ // Check for a broken connection, as it is not really a
+ // condition that warrants a panic stack trace.
+ var brokenPipe bool
+ if ne, ok := err.(*net.OpError); ok {
+ if se, ok := ne.Err.(*os.SyscallError); ok {
+ if strings.Contains(strings.ToLower(se.Error()), "broken pipe") || strings.Contains(strings.ToLower(se.Error()), "connection reset by peer") {
+ brokenPipe = true
+ }
+ }
+ }
if logger != nil {
stack := stack(3)
- httprequest, _ := httputil.DumpRequest(c.Request, false)
- logger.Printf("[Recovery] %s panic recovered:\n%s\n%s\n%s%s", timeFormat(time.Now()), string(httprequest), err, stack, reset)
+ httpRequest, _ := httputil.DumpRequest(c.Request, false)
+ headers := strings.Split(string(httpRequest), "\r\n")
+ for idx, header := range headers {
+ current := strings.Split(header, ":")
+ if current[0] == "Authorization" {
+ headers[idx] = current[0] + ": *"
+ }
+ }
+ headersToStr := strings.Join(headers, "\r\n")
+ if brokenPipe {
+ logger.Printf("%s\n%s%s", err, headersToStr, reset)
+ } else if IsDebugging() {
+ logger.Printf("[Recovery] %s panic recovered:\n%s\n%s\n%s%s",
+ timeFormat(time.Now()), headersToStr, err, stack, reset)
+ } else {
+ logger.Printf("[Recovery] %s panic recovered:\n%s\n%s%s",
+ timeFormat(time.Now()), err, stack, reset)
+ }
+ }
+ if brokenPipe {
+ // If the connection is dead, we can't write a status to it.
+ c.Error(err.(error)) // nolint: errcheck
+ c.Abort()
+ } else {
+ handle(c, err)
}
- c.AbortWithStatus(http.StatusInternalServerError)
}
}()
c.Next()
}
}
+func defaultHandleRecovery(c *Context, err interface{}) {
+ c.AbortWithStatus(http.StatusInternalServerError)
+}
+
// stack returns a nicely formatted stack frame, skipping skip frames.
func stack(skip int) []byte {
buf := new(bytes.Buffer) // the returned data
@@ -100,8 +155,8 @@ func function(pc uintptr) []byte {
// *T.ptrmethod
// Also the package path might contains dot (e.g. code.google.com/...),
// so first eliminate the path prefix
- if lastslash := bytes.LastIndex(name, slash); lastslash >= 0 {
- name = name[lastslash+1:]
+ if lastSlash := bytes.LastIndex(name, slash); lastSlash >= 0 {
+ name = name[lastSlash+1:]
}
if period := bytes.Index(name, dot); period >= 0 {
name = name[period+1:]
@@ -111,6 +166,6 @@ func function(pc uintptr) []byte {
}
func timeFormat(t time.Time) string {
- var timeString = t.Format("2006/01/02 - 15:04:05")
+ timeString := t.Format("2006/01/02 - 15:04:05")
return timeString
}
diff --git a/vendor/github.com/gin-gonic/gin/render/data.go b/vendor/github.com/gin-gonic/gin/render/data.go
index 3319491..6ba657b 100644
--- a/vendor/github.com/gin-gonic/gin/render/data.go
+++ b/vendor/github.com/gin-gonic/gin/render/data.go
@@ -6,6 +6,7 @@ package render
import "net/http"
+// Data contains ContentType and bytes data.
type Data struct {
ContentType string
Data []byte
@@ -18,6 +19,7 @@ func (r Data) Render(w http.ResponseWriter) (err error) {
return
}
+// WriteContentType (Data) writes custom ContentType.
func (r Data) WriteContentType(w http.ResponseWriter) {
writeContentType(w, []string{r.ContentType})
}
diff --git a/vendor/github.com/gin-gonic/gin/render/html.go b/vendor/github.com/gin-gonic/gin/render/html.go
index 1e3be65..6696ece 100644
--- a/vendor/github.com/gin-gonic/gin/render/html.go
+++ b/vendor/github.com/gin-gonic/gin/render/html.go
@@ -9,20 +9,27 @@ import (
"net/http"
)
+// Delims represents a set of Left and Right delimiters for HTML template rendering.
type Delims struct {
- Left string
+ // Left delimiter, defaults to {{.
+ Left string
+ // Right delimiter, defaults to }}.
Right string
}
+// HTMLRender interface is to be implemented by HTMLProduction and HTMLDebug.
type HTMLRender interface {
+ // Instance returns an HTML instance.
Instance(string, interface{}) Render
}
+// HTMLProduction contains template reference and its delims.
type HTMLProduction struct {
Template *template.Template
Delims Delims
}
+// HTMLDebug contains template delims and pattern and function with file list.
type HTMLDebug struct {
Files []string
Glob string
@@ -30,6 +37,7 @@ type HTMLDebug struct {
FuncMap template.FuncMap
}
+// HTML contains template reference and its name with given interface object.
type HTML struct {
Template *template.Template
Name string
@@ -38,6 +46,7 @@ type HTML struct {
var htmlContentType = []string{"text/html; charset=utf-8"}
+// Instance (HTMLProduction) returns an HTML instance which it realizes Render interface.
func (r HTMLProduction) Instance(name string, data interface{}) Render {
return HTML{
Template: r.Template,
@@ -46,6 +55,7 @@ func (r HTMLProduction) Instance(name string, data interface{}) Render {
}
}
+// Instance (HTMLDebug) returns an HTML instance which it realizes Render interface.
func (r HTMLDebug) Instance(name string, data interface{}) Render {
return HTML{
Template: r.loadTemplate(),
@@ -66,6 +76,7 @@ func (r HTMLDebug) loadTemplate() *template.Template {
panic("the HTML debug render was created without files or glob pattern")
}
+// Render (HTML) executes template and writes its result with custom ContentType for response.
func (r HTML) Render(w http.ResponseWriter) error {
r.WriteContentType(w)
@@ -75,6 +86,7 @@ func (r HTML) Render(w http.ResponseWriter) error {
return r.Template.ExecuteTemplate(w, r.Name, r.Data)
}
+// WriteContentType (HTML) writes HTML ContentType.
func (r HTML) WriteContentType(w http.ResponseWriter) {
writeContentType(w, htmlContentType)
}
diff --git a/vendor/github.com/gin-gonic/gin/render/json.go b/vendor/github.com/gin-gonic/gin/render/json.go
index 6e5089a..4186309 100644
--- a/vendor/github.com/gin-gonic/gin/render/json.go
+++ b/vendor/github.com/gin-gonic/gin/render/json.go
@@ -10,37 +10,47 @@ import (
"html/template"
"net/http"
- "github.com/gin-gonic/gin/json"
+ "github.com/gin-gonic/gin/internal/bytesconv"
+ "github.com/gin-gonic/gin/internal/json"
)
+// JSON contains the given interface object.
type JSON struct {
Data interface{}
}
+// IndentedJSON contains the given interface object.
type IndentedJSON struct {
Data interface{}
}
+// SecureJSON contains the given interface object and its prefix.
type SecureJSON struct {
Prefix string
Data interface{}
}
+// JsonpJSON contains the given interface object its callback.
type JsonpJSON struct {
Callback string
Data interface{}
}
+// AsciiJSON contains the given interface object.
type AsciiJSON struct {
Data interface{}
}
-type SecureJSONPrefix string
+// PureJSON contains the given interface object.
+type PureJSON struct {
+ Data interface{}
+}
var jsonContentType = []string{"application/json; charset=utf-8"}
var jsonpContentType = []string{"application/javascript; charset=utf-8"}
var jsonAsciiContentType = []string{"application/json"}
+// Render (JSON) writes data with custom ContentType.
func (r JSON) Render(w http.ResponseWriter) (err error) {
if err = WriteJSON(w, r.Data); err != nil {
panic(err)
@@ -48,34 +58,39 @@ func (r JSON) Render(w http.ResponseWriter) (err error) {
return
}
+// WriteContentType (JSON) writes JSON ContentType.
func (r JSON) WriteContentType(w http.ResponseWriter) {
writeContentType(w, jsonContentType)
}
+// WriteJSON marshals the given interface object and writes it with custom ContentType.
func WriteJSON(w http.ResponseWriter, obj interface{}) error {
writeContentType(w, jsonContentType)
jsonBytes, err := json.Marshal(obj)
if err != nil {
return err
}
- w.Write(jsonBytes)
- return nil
+ _, err = w.Write(jsonBytes)
+ return err
}
+// Render (IndentedJSON) marshals the given interface object and writes it with custom ContentType.
func (r IndentedJSON) Render(w http.ResponseWriter) error {
r.WriteContentType(w)
jsonBytes, err := json.MarshalIndent(r.Data, "", " ")
if err != nil {
return err
}
- w.Write(jsonBytes)
- return nil
+ _, err = w.Write(jsonBytes)
+ return err
}
+// WriteContentType (IndentedJSON) writes JSON ContentType.
func (r IndentedJSON) WriteContentType(w http.ResponseWriter) {
writeContentType(w, jsonContentType)
}
+// Render (SecureJSON) marshals the given interface object and writes it with custom ContentType.
func (r SecureJSON) Render(w http.ResponseWriter) error {
r.WriteContentType(w)
jsonBytes, err := json.Marshal(r.Data)
@@ -83,17 +98,23 @@ func (r SecureJSON) Render(w http.ResponseWriter) error {
return err
}
// if the jsonBytes is array values
- if bytes.HasPrefix(jsonBytes, []byte("[")) && bytes.HasSuffix(jsonBytes, []byte("]")) {
- w.Write([]byte(r.Prefix))
+ if bytes.HasPrefix(jsonBytes, bytesconv.StringToBytes("[")) && bytes.HasSuffix(jsonBytes,
+ bytesconv.StringToBytes("]")) {
+ _, err = w.Write(bytesconv.StringToBytes(r.Prefix))
+ if err != nil {
+ return err
+ }
}
- w.Write(jsonBytes)
- return nil
+ _, err = w.Write(jsonBytes)
+ return err
}
+// WriteContentType (SecureJSON) writes JSON ContentType.
func (r SecureJSON) WriteContentType(w http.ResponseWriter) {
writeContentType(w, jsonContentType)
}
+// Render (JsonpJSON) marshals the given interface object and writes it and its callback with custom ContentType.
func (r JsonpJSON) Render(w http.ResponseWriter) (err error) {
r.WriteContentType(w)
ret, err := json.Marshal(r.Data)
@@ -102,23 +123,37 @@ func (r JsonpJSON) Render(w http.ResponseWriter) (err error) {
}
if r.Callback == "" {
- w.Write(ret)
- return nil
+ _, err = w.Write(ret)
+ return err
}
callback := template.JSEscapeString(r.Callback)
- w.Write([]byte(callback))
- w.Write([]byte("("))
- w.Write(ret)
- w.Write([]byte(")"))
+ _, err = w.Write(bytesconv.StringToBytes(callback))
+ if err != nil {
+ return err
+ }
+ _, err = w.Write(bytesconv.StringToBytes("("))
+ if err != nil {
+ return err
+ }
+ _, err = w.Write(ret)
+ if err != nil {
+ return err
+ }
+ _, err = w.Write(bytesconv.StringToBytes(");"))
+ if err != nil {
+ return err
+ }
return nil
}
+// WriteContentType (JsonpJSON) writes Javascript ContentType.
func (r JsonpJSON) WriteContentType(w http.ResponseWriter) {
writeContentType(w, jsonpContentType)
}
+// Render (AsciiJSON) marshals the given interface object and writes it with custom ContentType.
func (r AsciiJSON) Render(w http.ResponseWriter) (err error) {
r.WriteContentType(w)
ret, err := json.Marshal(r.Data)
@@ -127,20 +162,32 @@ func (r AsciiJSON) Render(w http.ResponseWriter) (err error) {
}
var buffer bytes.Buffer
- for _, r := range string(ret) {
- cvt := ""
- if r < 128 {
- cvt = string(r)
- } else {
+ for _, r := range bytesconv.BytesToString(ret) {
+ cvt := string(r)
+ if r >= 128 {
cvt = fmt.Sprintf("\\u%04x", int64(r))
}
buffer.WriteString(cvt)
}
- w.Write(buffer.Bytes())
- return nil
+ _, err = w.Write(buffer.Bytes())
+ return err
}
+// WriteContentType (AsciiJSON) writes JSON ContentType.
func (r AsciiJSON) WriteContentType(w http.ResponseWriter) {
writeContentType(w, jsonAsciiContentType)
}
+
+// Render (PureJSON) writes custom ContentType and encodes the given interface object.
+func (r PureJSON) Render(w http.ResponseWriter) error {
+ r.WriteContentType(w)
+ encoder := json.NewEncoder(w)
+ encoder.SetEscapeHTML(false)
+ return encoder.Encode(r.Data)
+}
+
+// WriteContentType (PureJSON) writes custom ContentType.
+func (r PureJSON) WriteContentType(w http.ResponseWriter) {
+ writeContentType(w, jsonContentType)
+}
diff --git a/vendor/github.com/gin-gonic/gin/render/msgpack.go b/vendor/github.com/gin-gonic/gin/render/msgpack.go
index e6c13e5..6ef5b6e 100644
--- a/vendor/github.com/gin-gonic/gin/render/msgpack.go
+++ b/vendor/github.com/gin-gonic/gin/render/msgpack.go
@@ -2,6 +2,9 @@
// Use of this source code is governed by a MIT style
// license that can be found in the LICENSE file.
+//go:build !nomsgpack
+// +build !nomsgpack
+
package render
import (
@@ -10,22 +13,30 @@ import (
"github.com/ugorji/go/codec"
)
+var (
+ _ Render = MsgPack{}
+)
+
+// MsgPack contains the given interface object.
type MsgPack struct {
Data interface{}
}
var msgpackContentType = []string{"application/msgpack; charset=utf-8"}
+// WriteContentType (MsgPack) writes MsgPack ContentType.
func (r MsgPack) WriteContentType(w http.ResponseWriter) {
writeContentType(w, msgpackContentType)
}
+// Render (MsgPack) encodes the given interface object and writes data with custom ContentType.
func (r MsgPack) Render(w http.ResponseWriter) error {
return WriteMsgPack(w, r.Data)
}
+// WriteMsgPack writes MsgPack ContentType and encodes the given interface object.
func WriteMsgPack(w http.ResponseWriter, obj interface{}) error {
writeContentType(w, msgpackContentType)
- var h codec.Handle = new(codec.MsgpackHandle)
- return codec.NewEncoder(w, h).Encode(obj)
+ var mh codec.MsgpackHandle
+ return codec.NewEncoder(w, &mh).Encode(obj)
}
diff --git a/vendor/github.com/gin-gonic/gin/render/reader.go b/vendor/github.com/gin-gonic/gin/render/reader.go
index be2132c..d5282e4 100644
--- a/vendor/github.com/gin-gonic/gin/render/reader.go
+++ b/vendor/github.com/gin-gonic/gin/render/reader.go
@@ -1,3 +1,7 @@
+// Copyright 2018 Gin Core Team. All rights reserved.
+// Use of this source code is governed by a MIT style
+// license that can be found in the LICENSE file.
+
package render
import (
@@ -6,6 +10,7 @@ import (
"strconv"
)
+// Reader contains the IO reader and its length, and custom ContentType and other headers.
type Reader struct {
ContentType string
ContentLength int64
@@ -16,21 +21,28 @@ type Reader struct {
// Render (Reader) writes data with custom ContentType and headers.
func (r Reader) Render(w http.ResponseWriter) (err error) {
r.WriteContentType(w)
- r.Headers["Content-Length"] = strconv.FormatInt(r.ContentLength, 10)
+ if r.ContentLength >= 0 {
+ if r.Headers == nil {
+ r.Headers = map[string]string{}
+ }
+ r.Headers["Content-Length"] = strconv.FormatInt(r.ContentLength, 10)
+ }
r.writeHeaders(w, r.Headers)
_, err = io.Copy(w, r.Reader)
return
}
+// WriteContentType (Reader) writes custom ContentType.
func (r Reader) WriteContentType(w http.ResponseWriter) {
writeContentType(w, []string{r.ContentType})
}
+// writeHeaders writes custom Header.
func (r Reader) writeHeaders(w http.ResponseWriter, headers map[string]string) {
header := w.Header()
for k, v := range headers {
- if val := header[k]; len(val) == 0 {
- header[k] = []string{v}
+ if header.Get(k) == "" {
+ header.Set(k, v)
}
}
}
diff --git a/vendor/github.com/gin-gonic/gin/render/redirect.go b/vendor/github.com/gin-gonic/gin/render/redirect.go
index a0634f5..c006691 100644
--- a/vendor/github.com/gin-gonic/gin/render/redirect.go
+++ b/vendor/github.com/gin-gonic/gin/render/redirect.go
@@ -9,20 +9,21 @@ import (
"net/http"
)
+// Redirect contains the http request reference and redirects status code and location.
type Redirect struct {
Code int
Request *http.Request
Location string
}
+// Render (Redirect) redirects the http request to new location and writes redirect response.
func (r Redirect) Render(w http.ResponseWriter) error {
- // todo(thinkerou): go1.6 not support StatusPermanentRedirect(308)
- // when we upgrade go version we can use http.StatusPermanentRedirect
- if (r.Code < 300 || r.Code > 308) && r.Code != 201 {
+ if (r.Code < http.StatusMultipleChoices || r.Code > http.StatusPermanentRedirect) && r.Code != http.StatusCreated {
panic(fmt.Sprintf("Cannot redirect with status code %d", r.Code))
}
http.Redirect(w, r.Request, r.Location, r.Code)
return nil
}
+// WriteContentType (Redirect) don't write any ContentType.
func (r Redirect) WriteContentType(http.ResponseWriter) {}
diff --git a/vendor/github.com/gin-gonic/gin/render/render.go b/vendor/github.com/gin-gonic/gin/render/render.go
index 4ff1c7b..bcd568b 100644
--- a/vendor/github.com/gin-gonic/gin/render/render.go
+++ b/vendor/github.com/gin-gonic/gin/render/render.go
@@ -6,8 +6,11 @@ package render
import "net/http"
+// Render interface is to be implemented by JSON, XML, HTML, YAML and so on.
type Render interface {
+ // Render writes data with custom ContentType.
Render(http.ResponseWriter) error
+ // WriteContentType writes custom ContentType.
WriteContentType(w http.ResponseWriter)
}
@@ -24,9 +27,9 @@ var (
_ HTMLRender = HTMLDebug{}
_ HTMLRender = HTMLProduction{}
_ Render = YAML{}
- _ Render = MsgPack{}
_ Render = Reader{}
_ Render = AsciiJSON{}
+ _ Render = ProtoBuf{}
)
func writeContentType(w http.ResponseWriter, value []string) {
diff --git a/vendor/github.com/gin-gonic/gin/render/text.go b/vendor/github.com/gin-gonic/gin/render/text.go
index 74cd26b..461b720 100644
--- a/vendor/github.com/gin-gonic/gin/render/text.go
+++ b/vendor/github.com/gin-gonic/gin/render/text.go
@@ -6,10 +6,12 @@ package render
import (
"fmt"
- "io"
"net/http"
+
+ "github.com/gin-gonic/gin/internal/bytesconv"
)
+// String contains the given interface object slice and its format.
type String struct {
Format string
Data []interface{}
@@ -17,20 +19,23 @@ type String struct {
var plainContentType = []string{"text/plain; charset=utf-8"}
+// Render (String) writes data with custom ContentType.
func (r String) Render(w http.ResponseWriter) error {
- WriteString(w, r.Format, r.Data)
- return nil
+ return WriteString(w, r.Format, r.Data)
}
+// WriteContentType (String) writes Plain ContentType.
func (r String) WriteContentType(w http.ResponseWriter) {
writeContentType(w, plainContentType)
}
-func WriteString(w http.ResponseWriter, format string, data []interface{}) {
+// WriteString writes data according to its format and write custom ContentType.
+func WriteString(w http.ResponseWriter, format string, data []interface{}) (err error) {
writeContentType(w, plainContentType)
if len(data) > 0 {
- fmt.Fprintf(w, format, data...)
- } else {
- io.WriteString(w, format)
+ _, err = fmt.Fprintf(w, format, data...)
+ return
}
+ _, err = w.Write(bytesconv.StringToBytes(format))
+ return
}
diff --git a/vendor/github.com/gin-gonic/gin/render/xml.go b/vendor/github.com/gin-gonic/gin/render/xml.go
index cff1ac3..cc5390a 100644
--- a/vendor/github.com/gin-gonic/gin/render/xml.go
+++ b/vendor/github.com/gin-gonic/gin/render/xml.go
@@ -9,17 +9,20 @@ import (
"net/http"
)
+// XML contains the given interface object.
type XML struct {
Data interface{}
}
var xmlContentType = []string{"application/xml; charset=utf-8"}
+// Render (XML) encodes the given interface object and writes data with custom ContentType.
func (r XML) Render(w http.ResponseWriter) error {
r.WriteContentType(w)
return xml.NewEncoder(w).Encode(r.Data)
}
+// WriteContentType (XML) writes XML ContentType for response.
func (r XML) WriteContentType(w http.ResponseWriter) {
writeContentType(w, xmlContentType)
}
diff --git a/vendor/github.com/gin-gonic/gin/render/yaml.go b/vendor/github.com/gin-gonic/gin/render/yaml.go
index 25d0ebd..0df7836 100644
--- a/vendor/github.com/gin-gonic/gin/render/yaml.go
+++ b/vendor/github.com/gin-gonic/gin/render/yaml.go
@@ -10,12 +10,14 @@ import (
"gopkg.in/yaml.v2"
)
+// YAML contains the given interface object.
type YAML struct {
Data interface{}
}
var yamlContentType = []string{"application/x-yaml; charset=utf-8"}
+// Render (YAML) marshals the given interface object and writes data with custom ContentType.
func (r YAML) Render(w http.ResponseWriter) error {
r.WriteContentType(w)
@@ -24,10 +26,11 @@ func (r YAML) Render(w http.ResponseWriter) error {
return err
}
- w.Write(bytes)
- return nil
+ _, err = w.Write(bytes)
+ return err
}
+// WriteContentType (YAML) writes YAML ContentType for response.
func (r YAML) WriteContentType(w http.ResponseWriter) {
writeContentType(w, yamlContentType)
}
diff --git a/vendor/github.com/gin-gonic/gin/response_writer.go b/vendor/github.com/gin-gonic/gin/response_writer.go
index 923b53f..2682668 100644
--- a/vendor/github.com/gin-gonic/gin/response_writer.go
+++ b/vendor/github.com/gin-gonic/gin/response_writer.go
@@ -16,7 +16,8 @@ const (
defaultStatus = http.StatusOK
)
-type responseWriterBase interface {
+// ResponseWriter ...
+type ResponseWriter interface {
http.ResponseWriter
http.Hijacker
http.Flusher
@@ -37,6 +38,9 @@ type responseWriterBase interface {
// Forces to write the http header (status code + headers).
WriteHeaderNow()
+
+ // get the http.Pusher for server push
+ Pusher() http.Pusher
}
type responseWriter struct {
@@ -113,3 +117,10 @@ func (w *responseWriter) Flush() {
w.WriteHeaderNow()
w.ResponseWriter.(http.Flusher).Flush()
}
+
+func (w *responseWriter) Pusher() (pusher http.Pusher) {
+ if pusher, ok := w.ResponseWriter.(http.Pusher); ok {
+ return pusher
+ }
+ return nil
+}
diff --git a/vendor/github.com/gin-gonic/gin/response_writer_1.7.go b/vendor/github.com/gin-gonic/gin/response_writer_1.7.go
deleted file mode 100644
index 801d196..0000000
--- a/vendor/github.com/gin-gonic/gin/response_writer_1.7.go
+++ /dev/null
@@ -1,12 +0,0 @@
-// +build !go1.8
-
-// Copyright 2018 Gin Core Team. All rights reserved.
-// Use of this source code is governed by a MIT style
-// license that can be found in the LICENSE file.
-
-package gin
-
-// ResponseWriter ...
-type ResponseWriter interface {
- responseWriterBase
-}
diff --git a/vendor/github.com/gin-gonic/gin/response_writer_1.8.go b/vendor/github.com/gin-gonic/gin/response_writer_1.8.go
deleted file mode 100644
index 527c003..0000000
--- a/vendor/github.com/gin-gonic/gin/response_writer_1.8.go
+++ /dev/null
@@ -1,25 +0,0 @@
-// +build go1.8
-
-// Copyright 2018 Gin Core Team. All rights reserved.
-// Use of this source code is governed by a MIT style
-// license that can be found in the LICENSE file.
-
-package gin
-
-import (
- "net/http"
-)
-
-// ResponseWriter ...
-type ResponseWriter interface {
- responseWriterBase
- // get the http.Pusher for server push
- Pusher() http.Pusher
-}
-
-func (w *responseWriter) Pusher() (pusher http.Pusher) {
- if pusher, ok := w.ResponseWriter.(http.Pusher); ok {
- return pusher
- }
- return nil
-}
diff --git a/vendor/github.com/gin-gonic/gin/routergroup.go b/vendor/github.com/gin-gonic/gin/routergroup.go
index 876a61b..15d9930 100644
--- a/vendor/github.com/gin-gonic/gin/routergroup.go
+++ b/vendor/github.com/gin-gonic/gin/routergroup.go
@@ -11,11 +11,13 @@ import (
"strings"
)
+// IRouter defines all router handle interface includes single and group router.
type IRouter interface {
IRoutes
Group(string, ...HandlerFunc) *RouterGroup
}
+// IRoutes defines all router handle interface.
type IRoutes interface {
Use(...HandlerFunc) IRoutes
@@ -34,8 +36,8 @@ type IRoutes interface {
StaticFS(string, http.FileSystem) IRoutes
}
-// RouterGroup is used internally to configure router, a RouterGroup is associated with a prefix
-// and an array of handlers (middleware).
+// RouterGroup is used internally to configure router, a RouterGroup is associated with
+// a prefix and an array of handlers (middleware).
type RouterGroup struct {
Handlers HandlersChain
basePath string
@@ -45,14 +47,14 @@ type RouterGroup struct {
var _ IRouter = &RouterGroup{}
-// Use adds middleware to the group, see example code in github.
+// Use adds middleware to the group, see example code in GitHub.
func (group *RouterGroup) Use(middleware ...HandlerFunc) IRoutes {
group.Handlers = append(group.Handlers, middleware...)
return group.returnObj()
}
-// Group creates a new router group. You should add all the routes that have common middlwares or the same path prefix.
-// For example, all the routes that use a common middlware for authorization could be grouped.
+// Group creates a new router group. You should add all the routes that have common middlewares or the same path prefix.
+// For example, all the routes that use a common middleware for authorization could be grouped.
func (group *RouterGroup) Group(relativePath string, handlers ...HandlerFunc) *RouterGroup {
return &RouterGroup{
Handlers: group.combineHandlers(handlers),
@@ -61,6 +63,8 @@ func (group *RouterGroup) Group(relativePath string, handlers ...HandlerFunc) *R
}
}
+// BasePath returns the base path of router group.
+// For example, if v := router.Group("/rest/n/v1/api"), v.BasePath() is "/rest/n/v1/api".
func (group *RouterGroup) BasePath() string {
return group.basePath
}
@@ -74,7 +78,7 @@ func (group *RouterGroup) handle(httpMethod, relativePath string, handlers Handl
// Handle registers a new request handle and middleware with the given path and method.
// The last handler should be the real handler, the other ones should be middleware that can and should be shared among different routes.
-// See the example code in github.
+// See the example code in GitHub.
//
// For GET, POST, PUT, PATCH and DELETE requests the respective shortcut
// functions can be used.
@@ -91,51 +95,51 @@ func (group *RouterGroup) Handle(httpMethod, relativePath string, handlers ...Ha
// POST is a shortcut for router.Handle("POST", path, handle).
func (group *RouterGroup) POST(relativePath string, handlers ...HandlerFunc) IRoutes {
- return group.handle("POST", relativePath, handlers)
+ return group.handle(http.MethodPost, relativePath, handlers)
}
// GET is a shortcut for router.Handle("GET", path, handle).
func (group *RouterGroup) GET(relativePath string, handlers ...HandlerFunc) IRoutes {
- return group.handle("GET", relativePath, handlers)
+ return group.handle(http.MethodGet, relativePath, handlers)
}
// DELETE is a shortcut for router.Handle("DELETE", path, handle).
func (group *RouterGroup) DELETE(relativePath string, handlers ...HandlerFunc) IRoutes {
- return group.handle("DELETE", relativePath, handlers)
+ return group.handle(http.MethodDelete, relativePath, handlers)
}
// PATCH is a shortcut for router.Handle("PATCH", path, handle).
func (group *RouterGroup) PATCH(relativePath string, handlers ...HandlerFunc) IRoutes {
- return group.handle("PATCH", relativePath, handlers)
+ return group.handle(http.MethodPatch, relativePath, handlers)
}
// PUT is a shortcut for router.Handle("PUT", path, handle).
func (group *RouterGroup) PUT(relativePath string, handlers ...HandlerFunc) IRoutes {
- return group.handle("PUT", relativePath, handlers)
+ return group.handle(http.MethodPut, relativePath, handlers)
}
// OPTIONS is a shortcut for router.Handle("OPTIONS", path, handle).
func (group *RouterGroup) OPTIONS(relativePath string, handlers ...HandlerFunc) IRoutes {
- return group.handle("OPTIONS", relativePath, handlers)
+ return group.handle(http.MethodOptions, relativePath, handlers)
}
// HEAD is a shortcut for router.Handle("HEAD", path, handle).
func (group *RouterGroup) HEAD(relativePath string, handlers ...HandlerFunc) IRoutes {
- return group.handle("HEAD", relativePath, handlers)
+ return group.handle(http.MethodHead, relativePath, handlers)
}
// Any registers a route that matches all the HTTP methods.
// GET, POST, PUT, PATCH, HEAD, OPTIONS, DELETE, CONNECT, TRACE.
func (group *RouterGroup) Any(relativePath string, handlers ...HandlerFunc) IRoutes {
- group.handle("GET", relativePath, handlers)
- group.handle("POST", relativePath, handlers)
- group.handle("PUT", relativePath, handlers)
- group.handle("PATCH", relativePath, handlers)
- group.handle("HEAD", relativePath, handlers)
- group.handle("OPTIONS", relativePath, handlers)
- group.handle("DELETE", relativePath, handlers)
- group.handle("CONNECT", relativePath, handlers)
- group.handle("TRACE", relativePath, handlers)
+ group.handle(http.MethodGet, relativePath, handlers)
+ group.handle(http.MethodPost, relativePath, handlers)
+ group.handle(http.MethodPut, relativePath, handlers)
+ group.handle(http.MethodPatch, relativePath, handlers)
+ group.handle(http.MethodHead, relativePath, handlers)
+ group.handle(http.MethodOptions, relativePath, handlers)
+ group.handle(http.MethodDelete, relativePath, handlers)
+ group.handle(http.MethodConnect, relativePath, handlers)
+ group.handle(http.MethodTrace, relativePath, handlers)
return group.returnObj()
}
@@ -181,11 +185,24 @@ func (group *RouterGroup) StaticFS(relativePath string, fs http.FileSystem) IRou
func (group *RouterGroup) createStaticHandler(relativePath string, fs http.FileSystem) HandlerFunc {
absolutePath := group.calculateAbsolutePath(relativePath)
fileServer := http.StripPrefix(absolutePath, http.FileServer(fs))
- _, nolisting := fs.(*onlyfilesFS)
+
return func(c *Context) {
- if nolisting {
+ if _, noListing := fs.(*onlyFilesFS); noListing {
c.Writer.WriteHeader(http.StatusNotFound)
}
+
+ file := c.Param("filepath")
+ // Check if file exists and/or if we have permission to access it
+ f, err := fs.Open(file)
+ if err != nil {
+ c.Writer.WriteHeader(http.StatusNotFound)
+ c.handlers = group.engine.noRoute
+ // Reset index
+ c.index = -1
+ return
+ }
+ f.Close()
+
fileServer.ServeHTTP(c.Writer, c.Request)
}
}
diff --git a/vendor/github.com/gin-gonic/gin/tree.go b/vendor/github.com/gin-gonic/gin/tree.go
index b653066..ca753e6 100644
--- a/vendor/github.com/gin-gonic/gin/tree.go
+++ b/vendor/github.com/gin-gonic/gin/tree.go
@@ -5,9 +5,18 @@
package gin
import (
+ "bytes"
"net/url"
"strings"
"unicode"
+ "unicode/utf8"
+
+ "github.com/gin-gonic/gin/internal/bytesconv"
+)
+
+var (
+ strColon = []byte(":")
+ strStar = []byte("*")
)
// Param is a single URL parameter, consisting of a key and a value.
@@ -62,18 +71,31 @@ func min(a, b int) int {
return b
}
-func countParams(path string) uint8 {
- var n uint
- for i := 0; i < len(path); i++ {
- if path[i] != ':' && path[i] != '*' {
- continue
- }
- n++
+func longestCommonPrefix(a, b string) int {
+ i := 0
+ max := min(len(a), len(b))
+ for i < max && a[i] == b[i] {
+ i++
}
- if n >= 255 {
- return 255
+ return i
+}
+
+// addChild will add a child node, keeping wildcards at the end
+func (n *node) addChild(child *node) {
+ if n.wildChild && len(n.children) > 0 {
+ wildcardChild := n.children[len(n.children)-1]
+ n.children = append(n.children[:len(n.children)-1], child, wildcardChild)
+ } else {
+ n.children = append(n.children, child)
}
- return uint8(n)
+}
+
+func countParams(path string) uint16 {
+ var n uint16
+ s := bytesconv.StringToBytes(path)
+ n += uint16(bytes.Count(s, strColon))
+ n += uint16(bytes.Count(s, strStar))
+ return n
}
type nodeType uint8
@@ -88,33 +110,32 @@ const (
type node struct {
path string
indices string
- children []*node
- handlers HandlersChain
- priority uint32
- nType nodeType
- maxParams uint8
wildChild bool
+ nType nodeType
+ priority uint32
+ children []*node // child nodes, at most 1 :param style node at the end of the array
+ handlers HandlersChain
+ fullPath string
}
-// increments priority of the given child and reorders if necessary.
+// Increments priority of the given child and reorders if necessary
func (n *node) incrementChildPrio(pos int) int {
- n.children[pos].priority++
- prio := n.children[pos].priority
+ cs := n.children
+ cs[pos].priority++
+ prio := cs[pos].priority
- // adjust position (move to front)
+ // Adjust position (move to front)
newPos := pos
- for newPos > 0 && n.children[newPos-1].priority < prio {
- // swap node positions
- n.children[newPos-1], n.children[newPos] = n.children[newPos], n.children[newPos-1]
-
- newPos--
+ for ; newPos > 0 && cs[newPos-1].priority < prio; newPos-- {
+ // Swap node positions
+ cs[newPos-1], cs[newPos] = cs[newPos], cs[newPos-1]
}
- // build new index char string
+ // Build new index char string
if newPos != pos {
- n.indices = n.indices[:newPos] + // unchanged prefix, might be empty
- n.indices[pos:pos+1] + // the index char we move
- n.indices[newPos:pos] + n.indices[pos+1:] // rest without char at 'pos'
+ n.indices = n.indices[:newPos] + // Unchanged prefix, might be empty
+ n.indices[pos:pos+1] + // The index char we move
+ n.indices[newPos:pos] + n.indices[pos+1:] // Rest without char at 'pos'
}
return newPos
@@ -125,294 +146,314 @@ func (n *node) incrementChildPrio(pos int) int {
func (n *node) addRoute(path string, handlers HandlersChain) {
fullPath := path
n.priority++
- numParams := countParams(path)
-
- // non-empty tree
- if len(n.path) > 0 || len(n.children) > 0 {
- walk:
- for {
- // Update maxParams of the current node
- if numParams > n.maxParams {
- n.maxParams = numParams
- }
- // Find the longest common prefix.
- // This also implies that the common prefix contains no ':' or '*'
- // since the existing key can't contain those chars.
- i := 0
- max := min(len(path), len(n.path))
- for i < max && path[i] == n.path[i] {
- i++
- }
-
- // Split edge
- if i < len(n.path) {
- child := node{
- path: n.path[i:],
- wildChild: n.wildChild,
- indices: n.indices,
- children: n.children,
- handlers: n.handlers,
- priority: n.priority - 1,
- }
+ // Empty tree
+ if len(n.path) == 0 && len(n.children) == 0 {
+ n.insertChild(path, fullPath, handlers)
+ n.nType = root
+ return
+ }
- // Update maxParams (max of all children)
- for i := range child.children {
- if child.children[i].maxParams > child.maxParams {
- child.maxParams = child.children[i].maxParams
- }
- }
+ parentFullPathIndex := 0
- n.children = []*node{&child}
- // []byte for proper unicode char conversion, see #65
- n.indices = string([]byte{n.path[i]})
- n.path = path[:i]
- n.handlers = nil
- n.wildChild = false
+walk:
+ for {
+ // Find the longest common prefix.
+ // This also implies that the common prefix contains no ':' or '*'
+ // since the existing key can't contain those chars.
+ i := longestCommonPrefix(path, n.path)
+
+ // Split edge
+ if i < len(n.path) {
+ child := node{
+ path: n.path[i:],
+ wildChild: n.wildChild,
+ indices: n.indices,
+ children: n.children,
+ handlers: n.handlers,
+ priority: n.priority - 1,
+ fullPath: n.fullPath,
}
- // Make new node a child of this node
- if i < len(path) {
- path = path[i:]
-
- if n.wildChild {
- n = n.children[0]
- n.priority++
-
- // Update maxParams of the child node
- if numParams > n.maxParams {
- n.maxParams = numParams
- }
- numParams--
-
- // Check if the wildcard matches
- if len(path) >= len(n.path) && n.path == path[:len(n.path)] {
- // check for longer wildcard, e.g. :name and :names
- if len(n.path) >= len(path) || path[len(n.path)] == '/' {
- continue walk
- }
- }
+ n.children = []*node{&child}
+ // []byte for proper unicode char conversion, see #65
+ n.indices = bytesconv.BytesToString([]byte{n.path[i]})
+ n.path = path[:i]
+ n.handlers = nil
+ n.wildChild = false
+ n.fullPath = fullPath[:parentFullPathIndex+i]
+ }
- panic("path segment '" + path +
- "' conflicts with existing wildcard '" + n.path +
- "' in path '" + fullPath + "'")
- }
+ // Make new node a child of this node
+ if i < len(path) {
+ path = path[i:]
+ c := path[0]
- c := path[0]
+ // '/' after param
+ if n.nType == param && c == '/' && len(n.children) == 1 {
+ parentFullPathIndex += len(n.path)
+ n = n.children[0]
+ n.priority++
+ continue walk
+ }
- // slash after param
- if n.nType == param && c == '/' && len(n.children) == 1 {
- n = n.children[0]
- n.priority++
+ // Check if a child with the next path byte exists
+ for i, max := 0, len(n.indices); i < max; i++ {
+ if c == n.indices[i] {
+ parentFullPathIndex += len(n.path)
+ i = n.incrementChildPrio(i)
+ n = n.children[i]
continue walk
}
+ }
- // Check if a child with the next path byte exists
- for i := 0; i < len(n.indices); i++ {
- if c == n.indices[i] {
- i = n.incrementChildPrio(i)
- n = n.children[i]
- continue walk
- }
+ // Otherwise insert it
+ if c != ':' && c != '*' && n.nType != catchAll {
+ // []byte for proper unicode char conversion, see #65
+ n.indices += bytesconv.BytesToString([]byte{c})
+ child := &node{
+ fullPath: fullPath,
}
-
- // Otherwise insert it
- if c != ':' && c != '*' {
- // []byte for proper unicode char conversion, see #65
- n.indices += string([]byte{c})
- child := &node{
- maxParams: numParams,
- }
- n.children = append(n.children, child)
- n.incrementChildPrio(len(n.indices) - 1)
- n = child
+ n.addChild(child)
+ n.incrementChildPrio(len(n.indices) - 1)
+ n = child
+ } else if n.wildChild {
+ // inserting a wildcard node, need to check if it conflicts with the existing wildcard
+ n = n.children[len(n.children)-1]
+ n.priority++
+
+ // Check if the wildcard matches
+ if len(path) >= len(n.path) && n.path == path[:len(n.path)] &&
+ // Adding a child to a catchAll is not possible
+ n.nType != catchAll &&
+ // Check for longer wildcard, e.g. :name and :names
+ (len(n.path) >= len(path) || path[len(n.path)] == '/') {
+ continue walk
}
- n.insertChild(numParams, path, fullPath, handlers)
- return
- } else if i == len(path) { // Make node a (in-path) leaf
- if n.handlers != nil {
- panic("handlers are already registered for path '" + fullPath + "'")
+ // Wildcard conflict
+ pathSeg := path
+ if n.nType != catchAll {
+ pathSeg = strings.SplitN(pathSeg, "/", 2)[0]
}
- n.handlers = handlers
+ prefix := fullPath[:strings.Index(fullPath, pathSeg)] + n.path
+ panic("'" + pathSeg +
+ "' in new path '" + fullPath +
+ "' conflicts with existing wildcard '" + n.path +
+ "' in existing prefix '" + prefix +
+ "'")
}
+
+ n.insertChild(path, fullPath, handlers)
return
}
- } else { // Empty tree
- n.insertChild(numParams, path, fullPath, handlers)
- n.nType = root
+
+ // Otherwise add handle to current node
+ if n.handlers != nil {
+ panic("handlers are already registered for path '" + fullPath + "'")
+ }
+ n.handlers = handlers
+ n.fullPath = fullPath
+ return
}
}
-func (n *node) insertChild(numParams uint8, path string, fullPath string, handlers HandlersChain) {
- var offset int // already handled bytes of the path
-
- // find prefix until first wildcard (beginning with ':' or '*')
- for i, max := 0, len(path); numParams > 0; i++ {
- c := path[i]
+// Search for a wildcard segment and check the name for invalid characters.
+// Returns -1 as index, if no wildcard was found.
+func findWildcard(path string) (wildcard string, i int, valid bool) {
+ // Find start
+ for start, c := range []byte(path) {
+ // A wildcard starts with ':' (param) or '*' (catch-all)
if c != ':' && c != '*' {
continue
}
- // find wildcard end (either '/' or path end)
- end := i + 1
- for end < max && path[end] != '/' {
- switch path[end] {
- // the wildcard name must not contain ':' and '*'
+ // Find end and check for invalid characters
+ valid = true
+ for end, c := range []byte(path[start+1:]) {
+ switch c {
+ case '/':
+ return path[start : start+1+end], start, valid
case ':', '*':
- panic("only one wildcard per path segment is allowed, has: '" +
- path[i:] + "' in path '" + fullPath + "'")
- default:
- end++
+ valid = false
}
}
+ return path[start:], start, valid
+ }
+ return "", -1, false
+}
+
+func (n *node) insertChild(path string, fullPath string, handlers HandlersChain) {
+ for {
+ // Find prefix until first wildcard
+ wildcard, i, valid := findWildcard(path)
+ if i < 0 { // No wildcard found
+ break
+ }
- // check if this Node existing children which would be
- // unreachable if we insert the wildcard here
- if len(n.children) > 0 {
- panic("wildcard route '" + path[i:end] +
- "' conflicts with existing children in path '" + fullPath + "'")
+ // The wildcard name must not contain ':' and '*'
+ if !valid {
+ panic("only one wildcard per path segment is allowed, has: '" +
+ wildcard + "' in path '" + fullPath + "'")
}
// check if the wildcard has a name
- if end-i < 2 {
+ if len(wildcard) < 2 {
panic("wildcards must be named with a non-empty name in path '" + fullPath + "'")
}
- if c == ':' { // param
- // split path at the beginning of the wildcard
+ if wildcard[0] == ':' { // param
if i > 0 {
- n.path = path[offset:i]
- offset = i
+ // Insert prefix before the current wildcard
+ n.path = path[:i]
+ path = path[i:]
}
child := &node{
- nType: param,
- maxParams: numParams,
+ nType: param,
+ path: wildcard,
+ fullPath: fullPath,
}
- n.children = []*node{child}
+ n.addChild(child)
n.wildChild = true
n = child
n.priority++
- numParams--
// if the path doesn't end with the wildcard, then there
// will be another non-wildcard subpath starting with '/'
- if end < max {
- n.path = path[offset:end]
- offset = end
+ if len(wildcard) < len(path) {
+ path = path[len(wildcard):]
child := &node{
- maxParams: numParams,
- priority: 1,
+ priority: 1,
+ fullPath: fullPath,
}
- n.children = []*node{child}
+ n.addChild(child)
n = child
+ continue
}
- } else { // catchAll
- if end != max || numParams > 1 {
- panic("catch-all routes are only allowed at the end of the path in path '" + fullPath + "'")
- }
+ // Otherwise we're done. Insert the handle in the new leaf
+ n.handlers = handlers
+ return
+ }
- if len(n.path) > 0 && n.path[len(n.path)-1] == '/' {
- panic("catch-all conflicts with existing handle for the path segment root in path '" + fullPath + "'")
- }
+ // catchAll
+ if i+len(wildcard) != len(path) {
+ panic("catch-all routes are only allowed at the end of the path in path '" + fullPath + "'")
+ }
- // currently fixed width 1 for '/'
- i--
- if path[i] != '/' {
- panic("no / before catch-all in path '" + fullPath + "'")
- }
+ if len(n.path) > 0 && n.path[len(n.path)-1] == '/' {
+ panic("catch-all conflicts with existing handle for the path segment root in path '" + fullPath + "'")
+ }
- n.path = path[offset:i]
+ // currently fixed width 1 for '/'
+ i--
+ if path[i] != '/' {
+ panic("no / before catch-all in path '" + fullPath + "'")
+ }
- // first node: catchAll node with empty path
- child := &node{
- wildChild: true,
- nType: catchAll,
- maxParams: 1,
- }
- n.children = []*node{child}
- n.indices = string(path[i])
- n = child
- n.priority++
+ n.path = path[:i]
- // second node: node holding the variable
- child = &node{
- path: path[i:],
- nType: catchAll,
- maxParams: 1,
- handlers: handlers,
- priority: 1,
- }
- n.children = []*node{child}
+ // First node: catchAll node with empty path
+ child := &node{
+ wildChild: true,
+ nType: catchAll,
+ fullPath: fullPath,
+ }
- return
+ n.addChild(child)
+ n.indices = string('/')
+ n = child
+ n.priority++
+
+ // second node: node holding the variable
+ child = &node{
+ path: path[i:],
+ nType: catchAll,
+ handlers: handlers,
+ priority: 1,
+ fullPath: fullPath,
}
+ n.children = []*node{child}
+
+ return
}
- // insert remaining path part and handle to the leaf
- n.path = path[offset:]
+ // If no wildcard was found, simply insert the path and handle
+ n.path = path
n.handlers = handlers
+ n.fullPath = fullPath
+}
+
+// nodeValue holds return values of (*Node).getValue method
+type nodeValue struct {
+ handlers HandlersChain
+ params *Params
+ tsr bool
+ fullPath string
}
-// getValue returns the handle registered with the given path (key). The values of
+// Returns the handle registered with the given path (key). The values of
// wildcards are saved to a map.
// If no handle can be found, a TSR (trailing slash redirect) recommendation is
// made if a handle exists with an extra (without the) trailing slash for the
// given path.
-func (n *node) getValue(path string, po Params, unescape bool) (handlers HandlersChain, p Params, tsr bool) {
- p = po
+func (n *node) getValue(path string, params *Params, unescape bool) (value nodeValue) {
walk: // Outer loop for walking the tree
for {
- if len(path) > len(n.path) {
- if path[:len(n.path)] == n.path {
- path = path[len(n.path):]
- // If this node does not have a wildcard (param or catchAll)
- // child, we can just look up the next child node and continue
- // to walk down the tree
- if !n.wildChild {
- c := path[0]
- for i := 0; i < len(n.indices); i++ {
- if c == n.indices[i] {
- n = n.children[i]
- continue walk
- }
+ prefix := n.path
+ if len(path) > len(prefix) {
+ if path[:len(prefix)] == prefix {
+ path = path[len(prefix):]
+
+ // Try all the non-wildcard children first by matching the indices
+ idxc := path[0]
+ for i, c := range []byte(n.indices) {
+ if c == idxc {
+ n = n.children[i]
+ continue walk
}
+ }
+ // If there is no wildcard pattern, recommend a redirection
+ if !n.wildChild {
// Nothing found.
// We can recommend to redirect to the same URL without a
// trailing slash if a leaf exists for that path.
- tsr = path == "/" && n.handlers != nil
+ value.tsr = (path == "/" && n.handlers != nil)
return
}
- // handle wildcard child
- n = n.children[0]
+ // Handle wildcard child, which is always at the end of the array
+ n = n.children[len(n.children)-1]
+
switch n.nType {
case param:
- // find param end (either '/' or path end)
+ // Find param end (either '/' or path end)
end := 0
for end < len(path) && path[end] != '/' {
end++
}
- // save param value
- if cap(p) < int(n.maxParams) {
- p = make(Params, 0, n.maxParams)
- }
- i := len(p)
- p = p[:i+1] // expand slice within preallocated capacity
- p[i].Key = n.path[1:]
- val := path[:end]
- if unescape {
- var err error
- if p[i].Value, err = url.QueryUnescape(val); err != nil {
- p[i].Value = val // fallback, in case of error
+ // Save param value
+ if params != nil {
+ if value.params == nil {
+ value.params = params
+ }
+ // Expand slice within preallocated capacity
+ i := len(*value.params)
+ *value.params = (*value.params)[:i+1]
+ val := path[:end]
+ if unescape {
+ if v, err := url.QueryUnescape(val); err == nil {
+ val = v
+ }
+ }
+ (*value.params)[i] = Param{
+ Key: n.path[1:],
+ Value: val,
}
- } else {
- p[i].Value = val
}
// we need to go deeper!
@@ -424,64 +465,75 @@ walk: // Outer loop for walking the tree
}
// ... but we can't
- tsr = len(path) == end+1
+ value.tsr = (len(path) == end+1)
return
}
- if handlers = n.handlers; handlers != nil {
+ if value.handlers = n.handlers; value.handlers != nil {
+ value.fullPath = n.fullPath
return
}
if len(n.children) == 1 {
// No handle found. Check if a handle for this path + a
// trailing slash exists for TSR recommendation
n = n.children[0]
- tsr = n.path == "/" && n.handlers != nil
+ value.tsr = (n.path == "/" && n.handlers != nil)
}
-
return
case catchAll:
- // save param value
- if cap(p) < int(n.maxParams) {
- p = make(Params, 0, n.maxParams)
- }
- i := len(p)
- p = p[:i+1] // expand slice within preallocated capacity
- p[i].Key = n.path[2:]
- if unescape {
- var err error
- if p[i].Value, err = url.QueryUnescape(path); err != nil {
- p[i].Value = path // fallback, in case of error
+ // Save param value
+ if params != nil {
+ if value.params == nil {
+ value.params = params
+ }
+ // Expand slice within preallocated capacity
+ i := len(*value.params)
+ *value.params = (*value.params)[:i+1]
+ val := path
+ if unescape {
+ if v, err := url.QueryUnescape(path); err == nil {
+ val = v
+ }
+ }
+ (*value.params)[i] = Param{
+ Key: n.path[2:],
+ Value: val,
}
- } else {
- p[i].Value = path
}
- handlers = n.handlers
+ value.handlers = n.handlers
+ value.fullPath = n.fullPath
return
default:
panic("invalid node type")
}
}
- } else if path == n.path {
+ }
+
+ if path == prefix {
// We should have reached the node containing the handle.
// Check if this node has a handle registered.
- if handlers = n.handlers; handlers != nil {
+ if value.handlers = n.handlers; value.handlers != nil {
+ value.fullPath = n.fullPath
return
}
+ // If there is no handle for this route, but this route has a
+ // wildcard child, there must be a handle for this path with an
+ // additional trailing slash
if path == "/" && n.wildChild && n.nType != root {
- tsr = true
+ value.tsr = true
return
}
// No handle found. Check if a handle for this path + a
// trailing slash exists for trailing slash recommendation
- for i := 0; i < len(n.indices); i++ {
- if n.indices[i] == '/' {
+ for i, c := range []byte(n.indices) {
+ if c == '/' {
n = n.children[i]
- tsr = (len(n.path) == 1 && n.handlers != nil) ||
+ value.tsr = (len(n.path) == 1 && n.handlers != nil) ||
(n.nType == catchAll && n.children[0].handlers != nil)
return
}
@@ -492,115 +544,221 @@ walk: // Outer loop for walking the tree
// Nothing found. We can recommend to redirect to the same URL with an
// extra trailing slash if a leaf exists for that path
- tsr = (path == "/") ||
- (len(n.path) == len(path)+1 && n.path[len(path)] == '/' &&
- path == n.path[:len(n.path)-1] && n.handlers != nil)
+ value.tsr = (path == "/") ||
+ (len(prefix) == len(path)+1 && prefix[len(path)] == '/' &&
+ path == prefix[:len(prefix)-1] && n.handlers != nil)
return
}
}
-// findCaseInsensitivePath makes a case-insensitive lookup of the given path and tries to find a handler.
+// Makes a case-insensitive lookup of the given path and tries to find a handler.
// It can optionally also fix trailing slashes.
// It returns the case-corrected path and a bool indicating whether the lookup
// was successful.
-func (n *node) findCaseInsensitivePath(path string, fixTrailingSlash bool) (ciPath []byte, found bool) {
- ciPath = make([]byte, 0, len(path)+1) // preallocate enough memory
+func (n *node) findCaseInsensitivePath(path string, fixTrailingSlash bool) ([]byte, bool) {
+ const stackBufSize = 128
+
+ // Use a static sized buffer on the stack in the common case.
+ // If the path is too long, allocate a buffer on the heap instead.
+ buf := make([]byte, 0, stackBufSize)
+ if length := len(path) + 1; length > stackBufSize {
+ buf = make([]byte, 0, length)
+ }
- // Outer loop for walking the tree
- for len(path) >= len(n.path) && strings.ToLower(path[:len(n.path)]) == strings.ToLower(n.path) {
- path = path[len(n.path):]
+ ciPath := n.findCaseInsensitivePathRec(
+ path,
+ buf, // Preallocate enough memory for new path
+ [4]byte{}, // Empty rune buffer
+ fixTrailingSlash,
+ )
+
+ return ciPath, ciPath != nil
+}
+
+// Shift bytes in array by n bytes left
+func shiftNRuneBytes(rb [4]byte, n int) [4]byte {
+ switch n {
+ case 0:
+ return rb
+ case 1:
+ return [4]byte{rb[1], rb[2], rb[3], 0}
+ case 2:
+ return [4]byte{rb[2], rb[3]}
+ case 3:
+ return [4]byte{rb[3]}
+ default:
+ return [4]byte{}
+ }
+}
+
+// Recursive case-insensitive lookup function used by n.findCaseInsensitivePath
+func (n *node) findCaseInsensitivePathRec(path string, ciPath []byte, rb [4]byte, fixTrailingSlash bool) []byte {
+ npLen := len(n.path)
+
+walk: // Outer loop for walking the tree
+ for len(path) >= npLen && (npLen == 0 || strings.EqualFold(path[1:npLen], n.path[1:])) {
+ // Add common prefix to result
+ oldPath := path
+ path = path[npLen:]
ciPath = append(ciPath, n.path...)
- if len(path) > 0 {
- // If this node does not have a wildcard (param or catchAll) child,
- // we can just look up the next child node and continue to walk down
- // the tree
- if !n.wildChild {
- r := unicode.ToLower(rune(path[0]))
- for i, index := range n.indices {
- // must use recursive approach since both index and
- // ToLower(index) could exist. We must check both.
- if r == unicode.ToLower(index) {
- out, found := n.children[i].findCaseInsensitivePath(path, fixTrailingSlash)
- if found {
- return append(ciPath, out...), true
+ if len(path) == 0 {
+ // We should have reached the node containing the handle.
+ // Check if this node has a handle registered.
+ if n.handlers != nil {
+ return ciPath
+ }
+
+ // No handle found.
+ // Try to fix the path by adding a trailing slash
+ if fixTrailingSlash {
+ for i, c := range []byte(n.indices) {
+ if c == '/' {
+ n = n.children[i]
+ if (len(n.path) == 1 && n.handlers != nil) ||
+ (n.nType == catchAll && n.children[0].handlers != nil) {
+ return append(ciPath, '/')
}
+ return nil
}
}
-
- // Nothing found. We can recommend to redirect to the same URL
- // without a trailing slash if a leaf exists for that path
- found = fixTrailingSlash && path == "/" && n.handlers != nil
- return
}
+ return nil
+ }
- n = n.children[0]
- switch n.nType {
- case param:
- // find param end (either '/' or path end)
- k := 0
- for k < len(path) && path[k] != '/' {
- k++
+ // If this node does not have a wildcard (param or catchAll) child,
+ // we can just look up the next child node and continue to walk down
+ // the tree
+ if !n.wildChild {
+ // Skip rune bytes already processed
+ rb = shiftNRuneBytes(rb, npLen)
+
+ if rb[0] != 0 {
+ // Old rune not finished
+ idxc := rb[0]
+ for i, c := range []byte(n.indices) {
+ if c == idxc {
+ // continue with child node
+ n = n.children[i]
+ npLen = len(n.path)
+ continue walk
+ }
}
-
- // add param value to case insensitive path
- ciPath = append(ciPath, path[:k]...)
-
- // we need to go deeper!
- if k < len(path) {
- if len(n.children) > 0 {
- path = path[k:]
- n = n.children[0]
- continue
+ } else {
+ // Process a new rune
+ var rv rune
+
+ // Find rune start.
+ // Runes are up to 4 byte long,
+ // -4 would definitely be another rune.
+ var off int
+ for max := min(npLen, 3); off < max; off++ {
+ if i := npLen - off; utf8.RuneStart(oldPath[i]) {
+ // read rune from cached path
+ rv, _ = utf8.DecodeRuneInString(oldPath[i:])
+ break
}
+ }
- // ... but we can't
- if fixTrailingSlash && len(path) == k+1 {
- return ciPath, true
+ // Calculate lowercase bytes of current rune
+ lo := unicode.ToLower(rv)
+ utf8.EncodeRune(rb[:], lo)
+
+ // Skip already processed bytes
+ rb = shiftNRuneBytes(rb, off)
+
+ idxc := rb[0]
+ for i, c := range []byte(n.indices) {
+ // Lowercase matches
+ if c == idxc {
+ // must use a recursive approach since both the
+ // uppercase byte and the lowercase byte might exist
+ // as an index
+ if out := n.children[i].findCaseInsensitivePathRec(
+ path, ciPath, rb, fixTrailingSlash,
+ ); out != nil {
+ return out
+ }
+ break
}
- return
}
- if n.handlers != nil {
- return ciPath, true
- } else if fixTrailingSlash && len(n.children) == 1 {
- // No handle found. Check if a handle for this path + a
- // trailing slash exists
- n = n.children[0]
- if n.path == "/" && n.handlers != nil {
- return append(ciPath, '/'), true
+ // If we found no match, the same for the uppercase rune,
+ // if it differs
+ if up := unicode.ToUpper(rv); up != lo {
+ utf8.EncodeRune(rb[:], up)
+ rb = shiftNRuneBytes(rb, off)
+
+ idxc := rb[0]
+ for i, c := range []byte(n.indices) {
+ // Uppercase matches
+ if c == idxc {
+ // Continue with child node
+ n = n.children[i]
+ npLen = len(n.path)
+ continue walk
+ }
}
}
- return
+ }
- case catchAll:
- return append(ciPath, path...), true
+ // Nothing found. We can recommend to redirect to the same URL
+ // without a trailing slash if a leaf exists for that path
+ if fixTrailingSlash && path == "/" && n.handlers != nil {
+ return ciPath
+ }
+ return nil
+ }
- default:
- panic("invalid node type")
+ n = n.children[0]
+ switch n.nType {
+ case param:
+ // Find param end (either '/' or path end)
+ end := 0
+ for end < len(path) && path[end] != '/' {
+ end++
}
- } else {
- // We should have reached the node containing the handle.
- // Check if this node has a handle registered.
+
+ // Add param value to case insensitive path
+ ciPath = append(ciPath, path[:end]...)
+
+ // We need to go deeper!
+ if end < len(path) {
+ if len(n.children) > 0 {
+ // Continue with child node
+ n = n.children[0]
+ npLen = len(n.path)
+ path = path[end:]
+ continue
+ }
+
+ // ... but we can't
+ if fixTrailingSlash && len(path) == end+1 {
+ return ciPath
+ }
+ return nil
+ }
+
if n.handlers != nil {
- return ciPath, true
+ return ciPath
}
- // No handle found.
- // Try to fix the path by adding a trailing slash
- if fixTrailingSlash {
- for i := 0; i < len(n.indices); i++ {
- if n.indices[i] == '/' {
- n = n.children[i]
- if (len(n.path) == 1 && n.handlers != nil) ||
- (n.nType == catchAll && n.children[0].handlers != nil) {
- return append(ciPath, '/'), true
- }
- return
- }
+ if fixTrailingSlash && len(n.children) == 1 {
+ // No handle found. Check if a handle for this path + a
+ // trailing slash exists
+ n = n.children[0]
+ if n.path == "/" && n.handlers != nil {
+ return append(ciPath, '/')
}
}
- return
+
+ return nil
+
+ case catchAll:
+ return append(ciPath, path...)
+
+ default:
+ panic("invalid node type")
}
}
@@ -608,13 +766,12 @@ func (n *node) findCaseInsensitivePath(path string, fixTrailingSlash bool) (ciPa
// Try to fix the path by adding / removing a trailing slash
if fixTrailingSlash {
if path == "/" {
- return ciPath, true
+ return ciPath
}
- if len(path)+1 == len(n.path) && n.path[len(path)] == '/' &&
- strings.ToLower(path) == strings.ToLower(n.path[:len(path)]) &&
- n.handlers != nil {
- return append(ciPath, n.path...), true
+ if len(path)+1 == npLen && n.path[len(path)] == '/' &&
+ strings.EqualFold(path[1:], n.path[1:len(path)]) && n.handlers != nil {
+ return append(ciPath, n.path...)
}
}
- return
+ return nil
}
diff --git a/vendor/github.com/gin-gonic/gin/utils.go b/vendor/github.com/gin-gonic/gin/utils.go
index bf32c77..c32f0ee 100644
--- a/vendor/github.com/gin-gonic/gin/utils.go
+++ b/vendor/github.com/gin-gonic/gin/utils.go
@@ -14,8 +14,10 @@ import (
"strings"
)
+// BindKey indicates a default bind key.
const BindKey = "_gin-gonic/gin/bindkey"
+// Bind is a helper function for given interface object and returns a Gin middleware.
func Bind(val interface{}) HandlerFunc {
value := reflect.ValueOf(val)
if value.Kind() == reflect.Ptr {
@@ -33,16 +35,14 @@ func Bind(val interface{}) HandlerFunc {
}
}
-// WrapF is a helper function for wrapping http.HandlerFunc
-// Returns a Gin middleware
+// WrapF is a helper function for wrapping http.HandlerFunc and returns a Gin middleware.
func WrapF(f http.HandlerFunc) HandlerFunc {
return func(c *Context) {
f(c.Writer, c.Request)
}
}
-// WrapH is a helper function for wrapping http.Handler
-// Returns a Gin middleware
+// WrapH is a helper function for wrapping http.Handler and returns a Gin middleware.
func WrapH(h http.Handler) HandlerFunc {
return func(c *Context) {
h.ServeHTTP(c.Writer, c.Request)
@@ -90,20 +90,23 @@ func filterFlags(content string) string {
}
func chooseData(custom, wildcard interface{}) interface{} {
- if custom == nil {
- if wildcard == nil {
- panic("negotiation config is invalid")
- }
+ if custom != nil {
+ return custom
+ }
+ if wildcard != nil {
return wildcard
}
- return custom
+ panic("negotiation config is invalid")
}
func parseAccept(acceptHeader string) []string {
parts := strings.Split(acceptHeader, ",")
out := make([]string, 0, len(parts))
for _, part := range parts {
- if part = strings.TrimSpace(strings.Split(part, ";")[0]); part != "" {
+ if i := strings.IndexByte(part, ';'); i > 0 {
+ part = part[:i]
+ }
+ if part = strings.TrimSpace(part); part != "" {
out = append(out, part)
}
}
@@ -127,8 +130,7 @@ func joinPaths(absolutePath, relativePath string) string {
}
finalPath := path.Join(absolutePath, relativePath)
- appendSlash := lastChar(relativePath) == '/' && lastChar(finalPath) != '/'
- if appendSlash {
+ if lastChar(relativePath) == '/' && lastChar(finalPath) != '/' {
return finalPath + "/"
}
return finalPath
@@ -146,6 +148,6 @@ func resolveAddress(addr []string) string {
case 1:
return addr[0]
default:
- panic("too much parameters")
+ panic("too many parameters")
}
}
diff --git a/vendor/github.com/gin-gonic/gin/wercker.yml b/vendor/github.com/gin-gonic/gin/wercker.yml
deleted file mode 100644
index 3ab8084..0000000
--- a/vendor/github.com/gin-gonic/gin/wercker.yml
+++ /dev/null
@@ -1 +0,0 @@
-box: wercker/default
\ No newline at end of file
diff --git a/vendor/github.com/golang/protobuf/proto/lib.go b/vendor/github.com/golang/protobuf/proto/lib.go
index fdd328b..70fbda5 100644
--- a/vendor/github.com/golang/protobuf/proto/lib.go
+++ b/vendor/github.com/golang/protobuf/proto/lib.go
@@ -393,7 +393,7 @@ func (p *Buffer) Bytes() []byte { return p.buf }
// than relying on this API.
//
// If deterministic serialization is requested, map entries will be sorted
-// by keys in lexographical order. This is an implementation detail and
+// by keys in lexicographical order. This is an implementation detail and
// subject to change.
func (p *Buffer) SetDeterministic(deterministic bool) {
p.deterministic = deterministic
diff --git a/vendor/github.com/golang/protobuf/proto/properties.go b/vendor/github.com/golang/protobuf/proto/properties.go
index 79668ff..a4b8c0c 100644
--- a/vendor/github.com/golang/protobuf/proto/properties.go
+++ b/vendor/github.com/golang/protobuf/proto/properties.go
@@ -38,7 +38,6 @@ package proto
import (
"fmt"
"log"
- "os"
"reflect"
"sort"
"strconv"
@@ -194,7 +193,7 @@ func (p *Properties) Parse(s string) {
// "bytes,49,opt,name=foo,def=hello!"
fields := strings.Split(s, ",") // breaks def=, but handled below.
if len(fields) < 2 {
- fmt.Fprintf(os.Stderr, "proto: tag has too few fields: %q\n", s)
+ log.Printf("proto: tag has too few fields: %q", s)
return
}
@@ -214,7 +213,7 @@ func (p *Properties) Parse(s string) {
p.WireType = WireBytes
// no numeric converter for non-numeric types
default:
- fmt.Fprintf(os.Stderr, "proto: tag has unknown wire type: %q\n", s)
+ log.Printf("proto: tag has unknown wire type: %q", s)
return
}
diff --git a/vendor/github.com/golang/protobuf/proto/text.go b/vendor/github.com/golang/protobuf/proto/text.go
index 1aaee72..d97f9b3 100644
--- a/vendor/github.com/golang/protobuf/proto/text.go
+++ b/vendor/github.com/golang/protobuf/proto/text.go
@@ -456,6 +456,8 @@ func (tm *TextMarshaler) writeStruct(w *textWriter, sv reflect.Value) error {
return nil
}
+var textMarshalerType = reflect.TypeOf((*encoding.TextMarshaler)(nil)).Elem()
+
// writeAny writes an arbitrary field.
func (tm *TextMarshaler) writeAny(w *textWriter, v reflect.Value, props *Properties) error {
v = reflect.Indirect(v)
@@ -519,8 +521,8 @@ func (tm *TextMarshaler) writeAny(w *textWriter, v reflect.Value, props *Propert
// mutating this value.
v = v.Addr()
}
- if etm, ok := v.Interface().(encoding.TextMarshaler); ok {
- text, err := etm.MarshalText()
+ if v.Type().Implements(textMarshalerType) {
+ text, err := v.Interface().(encoding.TextMarshaler).MarshalText()
if err != nil {
return err
}
diff --git a/vendor/github.com/json-iterator/go/adapter.go b/vendor/github.com/json-iterator/go/adapter.go
index e674d0f..92d2cc4 100644
--- a/vendor/github.com/json-iterator/go/adapter.go
+++ b/vendor/github.com/json-iterator/go/adapter.go
@@ -16,7 +16,7 @@ func Unmarshal(data []byte, v interface{}) error {
return ConfigDefault.Unmarshal(data, v)
}
-// UnmarshalFromString convenient method to read from string instead of []byte
+// UnmarshalFromString is a convenient method to read from string instead of []byte
func UnmarshalFromString(str string, v interface{}) error {
return ConfigDefault.UnmarshalFromString(str, v)
}
diff --git a/vendor/github.com/json-iterator/go/iter.go b/vendor/github.com/json-iterator/go/iter.go
index 95ae54f..29b31cf 100644
--- a/vendor/github.com/json-iterator/go/iter.go
+++ b/vendor/github.com/json-iterator/go/iter.go
@@ -74,6 +74,7 @@ type Iterator struct {
buf []byte
head int
tail int
+ depth int
captureStartedAt int
captured []byte
Error error
@@ -88,6 +89,7 @@ func NewIterator(cfg API) *Iterator {
buf: nil,
head: 0,
tail: 0,
+ depth: 0,
}
}
@@ -99,6 +101,7 @@ func Parse(cfg API, reader io.Reader, bufSize int) *Iterator {
buf: make([]byte, bufSize),
head: 0,
tail: 0,
+ depth: 0,
}
}
@@ -110,6 +113,7 @@ func ParseBytes(cfg API, input []byte) *Iterator {
buf: input,
head: 0,
tail: len(input),
+ depth: 0,
}
}
@@ -128,6 +132,7 @@ func (iter *Iterator) Reset(reader io.Reader) *Iterator {
iter.reader = reader
iter.head = 0
iter.tail = 0
+ iter.depth = 0
return iter
}
@@ -137,6 +142,7 @@ func (iter *Iterator) ResetBytes(input []byte) *Iterator {
iter.buf = input
iter.head = 0
iter.tail = len(input)
+ iter.depth = 0
return iter
}
@@ -320,3 +326,24 @@ func (iter *Iterator) Read() interface{} {
return nil
}
}
+
+// limit maximum depth of nesting, as allowed by https://tools.ietf.org/html/rfc7159#section-9
+const maxDepth = 10000
+
+func (iter *Iterator) incrementDepth() (success bool) {
+ iter.depth++
+ if iter.depth <= maxDepth {
+ return true
+ }
+ iter.ReportError("incrementDepth", "exceeded max depth")
+ return false
+}
+
+func (iter *Iterator) decrementDepth() (success bool) {
+ iter.depth--
+ if iter.depth >= 0 {
+ return true
+ }
+ iter.ReportError("decrementDepth", "unexpected negative nesting")
+ return false
+}
diff --git a/vendor/github.com/json-iterator/go/iter_array.go b/vendor/github.com/json-iterator/go/iter_array.go
index 6188cb4..204fe0e 100644
--- a/vendor/github.com/json-iterator/go/iter_array.go
+++ b/vendor/github.com/json-iterator/go/iter_array.go
@@ -28,26 +28,32 @@ func (iter *Iterator) ReadArray() (ret bool) {
func (iter *Iterator) ReadArrayCB(callback func(*Iterator) bool) (ret bool) {
c := iter.nextToken()
if c == '[' {
+ if !iter.incrementDepth() {
+ return false
+ }
c = iter.nextToken()
if c != ']' {
iter.unreadByte()
if !callback(iter) {
+ iter.decrementDepth()
return false
}
c = iter.nextToken()
for c == ',' {
if !callback(iter) {
+ iter.decrementDepth()
return false
}
c = iter.nextToken()
}
if c != ']' {
iter.ReportError("ReadArrayCB", "expect ] in the end, but found "+string([]byte{c}))
+ iter.decrementDepth()
return false
}
- return true
+ return iter.decrementDepth()
}
- return true
+ return iter.decrementDepth()
}
if c == 'n' {
iter.skipThreeBytes('u', 'l', 'l')
diff --git a/vendor/github.com/json-iterator/go/iter_object.go b/vendor/github.com/json-iterator/go/iter_object.go
index 1c57576..b651371 100644
--- a/vendor/github.com/json-iterator/go/iter_object.go
+++ b/vendor/github.com/json-iterator/go/iter_object.go
@@ -112,6 +112,9 @@ func (iter *Iterator) ReadObjectCB(callback func(*Iterator, string) bool) bool {
c := iter.nextToken()
var field string
if c == '{' {
+ if !iter.incrementDepth() {
+ return false
+ }
c = iter.nextToken()
if c == '"' {
iter.unreadByte()
@@ -121,6 +124,7 @@ func (iter *Iterator) ReadObjectCB(callback func(*Iterator, string) bool) bool {
iter.ReportError("ReadObject", "expect : after object field, but found "+string([]byte{c}))
}
if !callback(iter, field) {
+ iter.decrementDepth()
return false
}
c = iter.nextToken()
@@ -131,20 +135,23 @@ func (iter *Iterator) ReadObjectCB(callback func(*Iterator, string) bool) bool {
iter.ReportError("ReadObject", "expect : after object field, but found "+string([]byte{c}))
}
if !callback(iter, field) {
+ iter.decrementDepth()
return false
}
c = iter.nextToken()
}
if c != '}' {
iter.ReportError("ReadObjectCB", `object not ended with }`)
+ iter.decrementDepth()
return false
}
- return true
+ return iter.decrementDepth()
}
if c == '}' {
- return true
+ return iter.decrementDepth()
}
iter.ReportError("ReadObjectCB", `expect " after }, but found `+string([]byte{c}))
+ iter.decrementDepth()
return false
}
if c == 'n' {
@@ -159,15 +166,20 @@ func (iter *Iterator) ReadObjectCB(callback func(*Iterator, string) bool) bool {
func (iter *Iterator) ReadMapCB(callback func(*Iterator, string) bool) bool {
c := iter.nextToken()
if c == '{' {
+ if !iter.incrementDepth() {
+ return false
+ }
c = iter.nextToken()
if c == '"' {
iter.unreadByte()
field := iter.ReadString()
if iter.nextToken() != ':' {
iter.ReportError("ReadMapCB", "expect : after object field, but found "+string([]byte{c}))
+ iter.decrementDepth()
return false
}
if !callback(iter, field) {
+ iter.decrementDepth()
return false
}
c = iter.nextToken()
@@ -175,23 +187,27 @@ func (iter *Iterator) ReadMapCB(callback func(*Iterator, string) bool) bool {
field = iter.ReadString()
if iter.nextToken() != ':' {
iter.ReportError("ReadMapCB", "expect : after object field, but found "+string([]byte{c}))
+ iter.decrementDepth()
return false
}
if !callback(iter, field) {
+ iter.decrementDepth()
return false
}
c = iter.nextToken()
}
if c != '}' {
iter.ReportError("ReadMapCB", `object not ended with }`)
+ iter.decrementDepth()
return false
}
- return true
+ return iter.decrementDepth()
}
if c == '}' {
- return true
+ return iter.decrementDepth()
}
iter.ReportError("ReadMapCB", `expect " after }, but found `+string([]byte{c}))
+ iter.decrementDepth()
return false
}
if c == 'n' {
diff --git a/vendor/github.com/json-iterator/go/iter_skip.go b/vendor/github.com/json-iterator/go/iter_skip.go
index f58beb9..e91eefb 100644
--- a/vendor/github.com/json-iterator/go/iter_skip.go
+++ b/vendor/github.com/json-iterator/go/iter_skip.go
@@ -37,17 +37,24 @@ func (iter *Iterator) SkipAndReturnBytes() []byte {
return iter.stopCapture()
}
-type captureBuffer struct {
- startedAt int
- captured []byte
+// SkipAndAppendBytes skips next JSON element and appends its content to
+// buffer, returning the result.
+func (iter *Iterator) SkipAndAppendBytes(buf []byte) []byte {
+ iter.startCaptureTo(buf, iter.head)
+ iter.Skip()
+ return iter.stopCapture()
}
-func (iter *Iterator) startCapture(captureStartedAt int) {
+func (iter *Iterator) startCaptureTo(buf []byte, captureStartedAt int) {
if iter.captured != nil {
panic("already in capture mode")
}
iter.captureStartedAt = captureStartedAt
- iter.captured = make([]byte, 0, 32)
+ iter.captured = buf
+}
+
+func (iter *Iterator) startCapture(captureStartedAt int) {
+ iter.startCaptureTo(make([]byte, 0, 32), captureStartedAt)
}
func (iter *Iterator) stopCapture() []byte {
@@ -58,13 +65,7 @@ func (iter *Iterator) stopCapture() []byte {
remaining := iter.buf[iter.captureStartedAt:iter.head]
iter.captureStartedAt = -1
iter.captured = nil
- if len(captured) == 0 {
- copied := make([]byte, len(remaining))
- copy(copied, remaining)
- return copied
- }
- captured = append(captured, remaining...)
- return captured
+ return append(captured, remaining...)
}
// Skip skips a json object and positions to relatively the next json object
diff --git a/vendor/github.com/json-iterator/go/iter_skip_sloppy.go b/vendor/github.com/json-iterator/go/iter_skip_sloppy.go
index 8fcdc3b..9303de4 100644
--- a/vendor/github.com/json-iterator/go/iter_skip_sloppy.go
+++ b/vendor/github.com/json-iterator/go/iter_skip_sloppy.go
@@ -22,6 +22,9 @@ func (iter *Iterator) skipNumber() {
func (iter *Iterator) skipArray() {
level := 1
+ if !iter.incrementDepth() {
+ return
+ }
for {
for i := iter.head; i < iter.tail; i++ {
switch iter.buf[i] {
@@ -31,8 +34,14 @@ func (iter *Iterator) skipArray() {
i = iter.head - 1 // it will be i++ soon
case '[': // If open symbol, increase level
level++
+ if !iter.incrementDepth() {
+ return
+ }
case ']': // If close symbol, increase level
level--
+ if !iter.decrementDepth() {
+ return
+ }
// If we have returned to the original level, we're done
if level == 0 {
@@ -50,6 +59,10 @@ func (iter *Iterator) skipArray() {
func (iter *Iterator) skipObject() {
level := 1
+ if !iter.incrementDepth() {
+ return
+ }
+
for {
for i := iter.head; i < iter.tail; i++ {
switch iter.buf[i] {
@@ -59,8 +72,14 @@ func (iter *Iterator) skipObject() {
i = iter.head - 1 // it will be i++ soon
case '{': // If open symbol, increase level
level++
+ if !iter.incrementDepth() {
+ return
+ }
case '}': // If close symbol, increase level
level--
+ if !iter.decrementDepth() {
+ return
+ }
// If we have returned to the original level, we're done
if level == 0 {
diff --git a/vendor/github.com/json-iterator/go/reflect.go b/vendor/github.com/json-iterator/go/reflect.go
index 4459e20..74974ba 100644
--- a/vendor/github.com/json-iterator/go/reflect.go
+++ b/vendor/github.com/json-iterator/go/reflect.go
@@ -60,6 +60,7 @@ func (b *ctx) append(prefix string) *ctx {
// ReadVal copy the underlying JSON into go interface, same as json.Unmarshal
func (iter *Iterator) ReadVal(obj interface{}) {
+ depth := iter.depth
cacheKey := reflect2.RTypeOf(obj)
decoder := iter.cfg.getDecoderFromCache(cacheKey)
if decoder == nil {
@@ -76,6 +77,10 @@ func (iter *Iterator) ReadVal(obj interface{}) {
return
}
decoder.Decode(ptr, iter)
+ if iter.depth != depth {
+ iter.ReportError("ReadVal", "unexpected mismatched nesting")
+ return
+ }
}
// WriteVal copy the go interface into underlying JSON, same as json.Marshal
diff --git a/vendor/github.com/json-iterator/go/reflect_extension.go b/vendor/github.com/json-iterator/go/reflect_extension.go
index 05e8fbf..80320cd 100644
--- a/vendor/github.com/json-iterator/go/reflect_extension.go
+++ b/vendor/github.com/json-iterator/go/reflect_extension.go
@@ -341,10 +341,10 @@ func describeStruct(ctx *ctx, typ reflect2.Type) *StructDescriptor {
if ctx.onlyTaggedField && !hastag && !field.Anonymous() {
continue
}
- tagParts := strings.Split(tag, ",")
- if tag == "-" {
+ if tag == "-" || field.Name() == "_" {
continue
}
+ tagParts := strings.Split(tag, ",")
if field.Anonymous() && (tag == "" || tagParts[0] == "") {
if field.Type().Kind() == reflect.Struct {
structDescriptor := describeStruct(ctx, field.Type())
diff --git a/vendor/github.com/json-iterator/go/reflect_map.go b/vendor/github.com/json-iterator/go/reflect_map.go
index 547b442..9e2b623 100644
--- a/vendor/github.com/json-iterator/go/reflect_map.go
+++ b/vendor/github.com/json-iterator/go/reflect_map.go
@@ -249,6 +249,10 @@ type mapEncoder struct {
}
func (encoder *mapEncoder) Encode(ptr unsafe.Pointer, stream *Stream) {
+ if *(*unsafe.Pointer)(ptr) == nil {
+ stream.WriteNil()
+ return
+ }
stream.WriteObjectStart()
iter := encoder.mapType.UnsafeIterate(ptr)
for i := 0; iter.HasNext(); i++ {
@@ -286,16 +290,17 @@ func (encoder *sortKeysMapEncoder) Encode(ptr unsafe.Pointer, stream *Stream) {
stream.WriteObjectStart()
mapIter := encoder.mapType.UnsafeIterate(ptr)
subStream := stream.cfg.BorrowStream(nil)
+ subStream.Attachment = stream.Attachment
subIter := stream.cfg.BorrowIterator(nil)
keyValues := encodedKeyValues{}
for mapIter.HasNext() {
- subStream.buf = make([]byte, 0, 64)
key, elem := mapIter.UnsafeNext()
+ subStreamIndex := subStream.Buffered()
encoder.keyEncoder.Encode(key, subStream)
if subStream.Error != nil && subStream.Error != io.EOF && stream.Error == nil {
stream.Error = subStream.Error
}
- encodedKey := subStream.Buffer()
+ encodedKey := subStream.Buffer()[subStreamIndex:]
subIter.ResetBytes(encodedKey)
decodedKey := subIter.ReadString()
if stream.indention > 0 {
@@ -306,7 +311,7 @@ func (encoder *sortKeysMapEncoder) Encode(ptr unsafe.Pointer, stream *Stream) {
encoder.elemEncoder.Encode(elem, subStream)
keyValues = append(keyValues, encodedKV{
key: decodedKey,
- keyValue: subStream.Buffer(),
+ keyValue: subStream.Buffer()[subStreamIndex:],
})
}
sort.Sort(keyValues)
@@ -316,6 +321,9 @@ func (encoder *sortKeysMapEncoder) Encode(ptr unsafe.Pointer, stream *Stream) {
}
stream.Write(keyValue.keyValue)
}
+ if subStream.Error != nil && stream.Error == nil {
+ stream.Error = subStream.Error
+ }
stream.WriteObjectEnd()
stream.cfg.ReturnStream(subStream)
stream.cfg.ReturnIterator(subIter)
diff --git a/vendor/github.com/json-iterator/go/reflect_marshaler.go b/vendor/github.com/json-iterator/go/reflect_marshaler.go
index fea5071..3e21f37 100644
--- a/vendor/github.com/json-iterator/go/reflect_marshaler.go
+++ b/vendor/github.com/json-iterator/go/reflect_marshaler.go
@@ -3,8 +3,9 @@ package jsoniter
import (
"encoding"
"encoding/json"
- "github.com/modern-go/reflect2"
"unsafe"
+
+ "github.com/modern-go/reflect2"
)
var marshalerType = reflect2.TypeOfPtr((*json.Marshaler)(nil)).Elem()
@@ -93,10 +94,17 @@ func (encoder *marshalerEncoder) Encode(ptr unsafe.Pointer, stream *Stream) {
stream.WriteNil()
return
}
- bytes, err := json.Marshal(obj)
+ marshaler := obj.(json.Marshaler)
+ bytes, err := marshaler.MarshalJSON()
if err != nil {
stream.Error = err
} else {
+ // html escape was already done by jsoniter
+ // but the extra '\n' should be trimed
+ l := len(bytes)
+ if l > 0 && bytes[l-1] == '\n' {
+ bytes = bytes[:l-1]
+ }
stream.Write(bytes)
}
}
diff --git a/vendor/github.com/json-iterator/go/reflect_native.go b/vendor/github.com/json-iterator/go/reflect_native.go
index 9042eb0..f88722d 100644
--- a/vendor/github.com/json-iterator/go/reflect_native.go
+++ b/vendor/github.com/json-iterator/go/reflect_native.go
@@ -432,17 +432,19 @@ func (codec *base64Codec) Decode(ptr unsafe.Pointer, iter *Iterator) {
}
func (codec *base64Codec) Encode(ptr unsafe.Pointer, stream *Stream) {
- src := *((*[]byte)(ptr))
- if len(src) == 0 {
+ if codec.sliceType.UnsafeIsNil(ptr) {
stream.WriteNil()
return
}
+ src := *((*[]byte)(ptr))
encoding := base64.StdEncoding
stream.writeByte('"')
- size := encoding.EncodedLen(len(src))
- buf := make([]byte, size)
- encoding.Encode(buf, src)
- stream.buf = append(stream.buf, buf...)
+ if len(src) != 0 {
+ size := encoding.EncodedLen(len(src))
+ buf := make([]byte, size)
+ encoding.Encode(buf, src)
+ stream.buf = append(stream.buf, buf...)
+ }
stream.writeByte('"')
}
diff --git a/vendor/github.com/json-iterator/go/reflect_struct_decoder.go b/vendor/github.com/json-iterator/go/reflect_struct_decoder.go
index 355d2d1..5ad5cc5 100644
--- a/vendor/github.com/json-iterator/go/reflect_struct_decoder.go
+++ b/vendor/github.com/json-iterator/go/reflect_struct_decoder.go
@@ -500,6 +500,9 @@ func (decoder *generalStructDecoder) Decode(ptr unsafe.Pointer, iter *Iterator)
if !iter.readObjectStart() {
return
}
+ if !iter.incrementDepth() {
+ return
+ }
var c byte
for c = ','; c == ','; c = iter.nextToken() {
decoder.decodeOneField(ptr, iter)
@@ -510,6 +513,7 @@ func (decoder *generalStructDecoder) Decode(ptr unsafe.Pointer, iter *Iterator)
if c != '}' {
iter.ReportError("struct Decode", `expect }, but found `+string([]byte{c}))
}
+ iter.decrementDepth()
}
func (decoder *generalStructDecoder) decodeOneField(ptr unsafe.Pointer, iter *Iterator) {
@@ -530,8 +534,8 @@ func (decoder *generalStructDecoder) decodeOneField(ptr unsafe.Pointer, iter *It
}
}
if fieldDecoder == nil {
- msg := "found unknown field: " + field
if decoder.disallowUnknownFields {
+ msg := "found unknown field: " + field
iter.ReportError("ReadObject", msg)
}
c := iter.nextToken()
@@ -571,6 +575,9 @@ func (decoder *oneFieldStructDecoder) Decode(ptr unsafe.Pointer, iter *Iterator)
if !iter.readObjectStart() {
return
}
+ if !iter.incrementDepth() {
+ return
+ }
for {
if iter.readFieldHash() == decoder.fieldHash {
decoder.fieldDecoder.Decode(ptr, iter)
@@ -584,6 +591,7 @@ func (decoder *oneFieldStructDecoder) Decode(ptr unsafe.Pointer, iter *Iterator)
if iter.Error != nil && iter.Error != io.EOF {
iter.Error = fmt.Errorf("%v.%s", decoder.typ, iter.Error.Error())
}
+ iter.decrementDepth()
}
type twoFieldsStructDecoder struct {
@@ -598,6 +606,9 @@ func (decoder *twoFieldsStructDecoder) Decode(ptr unsafe.Pointer, iter *Iterator
if !iter.readObjectStart() {
return
}
+ if !iter.incrementDepth() {
+ return
+ }
for {
switch iter.readFieldHash() {
case decoder.fieldHash1:
@@ -614,6 +625,7 @@ func (decoder *twoFieldsStructDecoder) Decode(ptr unsafe.Pointer, iter *Iterator
if iter.Error != nil && iter.Error != io.EOF {
iter.Error = fmt.Errorf("%v.%s", decoder.typ, iter.Error.Error())
}
+ iter.decrementDepth()
}
type threeFieldsStructDecoder struct {
@@ -630,6 +642,9 @@ func (decoder *threeFieldsStructDecoder) Decode(ptr unsafe.Pointer, iter *Iterat
if !iter.readObjectStart() {
return
}
+ if !iter.incrementDepth() {
+ return
+ }
for {
switch iter.readFieldHash() {
case decoder.fieldHash1:
@@ -648,6 +663,7 @@ func (decoder *threeFieldsStructDecoder) Decode(ptr unsafe.Pointer, iter *Iterat
if iter.Error != nil && iter.Error != io.EOF {
iter.Error = fmt.Errorf("%v.%s", decoder.typ, iter.Error.Error())
}
+ iter.decrementDepth()
}
type fourFieldsStructDecoder struct {
@@ -666,6 +682,9 @@ func (decoder *fourFieldsStructDecoder) Decode(ptr unsafe.Pointer, iter *Iterato
if !iter.readObjectStart() {
return
}
+ if !iter.incrementDepth() {
+ return
+ }
for {
switch iter.readFieldHash() {
case decoder.fieldHash1:
@@ -686,6 +705,7 @@ func (decoder *fourFieldsStructDecoder) Decode(ptr unsafe.Pointer, iter *Iterato
if iter.Error != nil && iter.Error != io.EOF {
iter.Error = fmt.Errorf("%v.%s", decoder.typ, iter.Error.Error())
}
+ iter.decrementDepth()
}
type fiveFieldsStructDecoder struct {
@@ -706,6 +726,9 @@ func (decoder *fiveFieldsStructDecoder) Decode(ptr unsafe.Pointer, iter *Iterato
if !iter.readObjectStart() {
return
}
+ if !iter.incrementDepth() {
+ return
+ }
for {
switch iter.readFieldHash() {
case decoder.fieldHash1:
@@ -728,6 +751,7 @@ func (decoder *fiveFieldsStructDecoder) Decode(ptr unsafe.Pointer, iter *Iterato
if iter.Error != nil && iter.Error != io.EOF {
iter.Error = fmt.Errorf("%v.%s", decoder.typ, iter.Error.Error())
}
+ iter.decrementDepth()
}
type sixFieldsStructDecoder struct {
@@ -750,6 +774,9 @@ func (decoder *sixFieldsStructDecoder) Decode(ptr unsafe.Pointer, iter *Iterator
if !iter.readObjectStart() {
return
}
+ if !iter.incrementDepth() {
+ return
+ }
for {
switch iter.readFieldHash() {
case decoder.fieldHash1:
@@ -774,6 +801,7 @@ func (decoder *sixFieldsStructDecoder) Decode(ptr unsafe.Pointer, iter *Iterator
if iter.Error != nil && iter.Error != io.EOF {
iter.Error = fmt.Errorf("%v.%s", decoder.typ, iter.Error.Error())
}
+ iter.decrementDepth()
}
type sevenFieldsStructDecoder struct {
@@ -798,6 +826,9 @@ func (decoder *sevenFieldsStructDecoder) Decode(ptr unsafe.Pointer, iter *Iterat
if !iter.readObjectStart() {
return
}
+ if !iter.incrementDepth() {
+ return
+ }
for {
switch iter.readFieldHash() {
case decoder.fieldHash1:
@@ -824,6 +855,7 @@ func (decoder *sevenFieldsStructDecoder) Decode(ptr unsafe.Pointer, iter *Iterat
if iter.Error != nil && iter.Error != io.EOF {
iter.Error = fmt.Errorf("%v.%s", decoder.typ, iter.Error.Error())
}
+ iter.decrementDepth()
}
type eightFieldsStructDecoder struct {
@@ -850,6 +882,9 @@ func (decoder *eightFieldsStructDecoder) Decode(ptr unsafe.Pointer, iter *Iterat
if !iter.readObjectStart() {
return
}
+ if !iter.incrementDepth() {
+ return
+ }
for {
switch iter.readFieldHash() {
case decoder.fieldHash1:
@@ -878,6 +913,7 @@ func (decoder *eightFieldsStructDecoder) Decode(ptr unsafe.Pointer, iter *Iterat
if iter.Error != nil && iter.Error != io.EOF {
iter.Error = fmt.Errorf("%v.%s", decoder.typ, iter.Error.Error())
}
+ iter.decrementDepth()
}
type nineFieldsStructDecoder struct {
@@ -906,6 +942,9 @@ func (decoder *nineFieldsStructDecoder) Decode(ptr unsafe.Pointer, iter *Iterato
if !iter.readObjectStart() {
return
}
+ if !iter.incrementDepth() {
+ return
+ }
for {
switch iter.readFieldHash() {
case decoder.fieldHash1:
@@ -936,6 +975,7 @@ func (decoder *nineFieldsStructDecoder) Decode(ptr unsafe.Pointer, iter *Iterato
if iter.Error != nil && iter.Error != io.EOF {
iter.Error = fmt.Errorf("%v.%s", decoder.typ, iter.Error.Error())
}
+ iter.decrementDepth()
}
type tenFieldsStructDecoder struct {
@@ -966,6 +1006,9 @@ func (decoder *tenFieldsStructDecoder) Decode(ptr unsafe.Pointer, iter *Iterator
if !iter.readObjectStart() {
return
}
+ if !iter.incrementDepth() {
+ return
+ }
for {
switch iter.readFieldHash() {
case decoder.fieldHash1:
@@ -998,6 +1041,7 @@ func (decoder *tenFieldsStructDecoder) Decode(ptr unsafe.Pointer, iter *Iterator
if iter.Error != nil && iter.Error != io.EOF {
iter.Error = fmt.Errorf("%v.%s", decoder.typ, iter.Error.Error())
}
+ iter.decrementDepth()
}
type structFieldDecoder struct {
diff --git a/vendor/github.com/json-iterator/go/reflect_struct_encoder.go b/vendor/github.com/json-iterator/go/reflect_struct_encoder.go
index d0759cf..152e3ef 100644
--- a/vendor/github.com/json-iterator/go/reflect_struct_encoder.go
+++ b/vendor/github.com/json-iterator/go/reflect_struct_encoder.go
@@ -200,6 +200,7 @@ type stringModeStringEncoder struct {
func (encoder *stringModeStringEncoder) Encode(ptr unsafe.Pointer, stream *Stream) {
tempStream := encoder.cfg.BorrowStream(nil)
+ tempStream.Attachment = stream.Attachment
defer encoder.cfg.ReturnStream(tempStream)
encoder.elemEncoder.Encode(ptr, tempStream)
stream.WriteString(string(tempStream.Buffer()))
diff --git a/vendor/github.com/json-iterator/go/stream_float.go b/vendor/github.com/json-iterator/go/stream_float.go
index f318d2c..826aa59 100644
--- a/vendor/github.com/json-iterator/go/stream_float.go
+++ b/vendor/github.com/json-iterator/go/stream_float.go
@@ -1,6 +1,7 @@
package jsoniter
import (
+ "fmt"
"math"
"strconv"
)
@@ -13,6 +14,10 @@ func init() {
// WriteFloat32 write float32 to stream
func (stream *Stream) WriteFloat32(val float32) {
+ if math.IsInf(float64(val), 0) || math.IsNaN(float64(val)) {
+ stream.Error = fmt.Errorf("unsupported value: %f", val)
+ return
+ }
abs := math.Abs(float64(val))
fmt := byte('f')
// Note: Must use float32 comparisons for underlying float32 value to get precise cutoffs right.
@@ -26,6 +31,10 @@ func (stream *Stream) WriteFloat32(val float32) {
// WriteFloat32Lossy write float32 to stream with ONLY 6 digits precision although much much faster
func (stream *Stream) WriteFloat32Lossy(val float32) {
+ if math.IsInf(float64(val), 0) || math.IsNaN(float64(val)) {
+ stream.Error = fmt.Errorf("unsupported value: %f", val)
+ return
+ }
if val < 0 {
stream.writeByte('-')
val = -val
@@ -54,6 +63,10 @@ func (stream *Stream) WriteFloat32Lossy(val float32) {
// WriteFloat64 write float64 to stream
func (stream *Stream) WriteFloat64(val float64) {
+ if math.IsInf(val, 0) || math.IsNaN(val) {
+ stream.Error = fmt.Errorf("unsupported value: %f", val)
+ return
+ }
abs := math.Abs(val)
fmt := byte('f')
// Note: Must use float32 comparisons for underlying float32 value to get precise cutoffs right.
@@ -67,6 +80,10 @@ func (stream *Stream) WriteFloat64(val float64) {
// WriteFloat64Lossy write float64 to stream with ONLY 6 digits precision although much much faster
func (stream *Stream) WriteFloat64Lossy(val float64) {
+ if math.IsInf(val, 0) || math.IsNaN(val) {
+ stream.Error = fmt.Errorf("unsupported value: %f", val)
+ return
+ }
if val < 0 {
stream.writeByte('-')
val = -val
diff --git a/vendor/github.com/mattn/go-isatty/.travis.yml b/vendor/github.com/mattn/go-isatty/.travis.yml
index 5597e02..604314d 100644
--- a/vendor/github.com/mattn/go-isatty/.travis.yml
+++ b/vendor/github.com/mattn/go-isatty/.travis.yml
@@ -1,13 +1,14 @@
language: go
+sudo: false
go:
+ - 1.13.x
- tip
-os:
- - linux
- - osx
-
before_install:
- - go get github.com/mattn/goveralls
- - go get golang.org/x/tools/cmd/cover
+ - go get -t -v ./...
+
script:
- - $HOME/gopath/bin/goveralls -repotoken 3gHdORO5k5ziZcWMBxnd9LrMZaJs8m9x5
+ - ./go.test.sh
+
+after_success:
+ - bash <(curl -s https://codecov.io/bash)
diff --git a/vendor/github.com/mattn/go-isatty/README.md b/vendor/github.com/mattn/go-isatty/README.md
index 1e69004..3841835 100644
--- a/vendor/github.com/mattn/go-isatty/README.md
+++ b/vendor/github.com/mattn/go-isatty/README.md
@@ -1,7 +1,7 @@
# go-isatty
[](http://godoc.org/github.com/mattn/go-isatty)
-[](https://travis-ci.org/mattn/go-isatty)
+[](https://codecov.io/gh/mattn/go-isatty)
[](https://coveralls.io/github/mattn/go-isatty?branch=master)
[](https://goreportcard.com/report/mattn/go-isatty)
diff --git a/vendor/github.com/mattn/go-isatty/go.mod b/vendor/github.com/mattn/go-isatty/go.mod
deleted file mode 100644
index f310320..0000000
--- a/vendor/github.com/mattn/go-isatty/go.mod
+++ /dev/null
@@ -1,3 +0,0 @@
-module github.com/mattn/go-isatty
-
-require golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223
diff --git a/vendor/github.com/mattn/go-isatty/go.sum b/vendor/github.com/mattn/go-isatty/go.sum
deleted file mode 100644
index 426c897..0000000
--- a/vendor/github.com/mattn/go-isatty/go.sum
+++ /dev/null
@@ -1,2 +0,0 @@
-golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223 h1:DH4skfRX4EBpamg7iV4ZlCpblAHI6s6TDM39bFZumv8=
-golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
diff --git a/vendor/github.com/mattn/go-isatty/isatty_android.go b/vendor/github.com/mattn/go-isatty/isatty_android.go
deleted file mode 100644
index d3567cb..0000000
--- a/vendor/github.com/mattn/go-isatty/isatty_android.go
+++ /dev/null
@@ -1,23 +0,0 @@
-// +build android
-
-package isatty
-
-import (
- "syscall"
- "unsafe"
-)
-
-const ioctlReadTermios = syscall.TCGETS
-
-// IsTerminal return true if the file descriptor is terminal.
-func IsTerminal(fd uintptr) bool {
- var termios syscall.Termios
- _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0)
- return err == 0
-}
-
-// IsCygwinTerminal return true if the file descriptor is a cygwin or msys2
-// terminal. This is also always false on this environment.
-func IsCygwinTerminal(fd uintptr) bool {
- return false
-}
diff --git a/vendor/github.com/mattn/go-isatty/isatty_bsd.go b/vendor/github.com/mattn/go-isatty/isatty_bsd.go
index 07e9303..711f288 100644
--- a/vendor/github.com/mattn/go-isatty/isatty_bsd.go
+++ b/vendor/github.com/mattn/go-isatty/isatty_bsd.go
@@ -3,18 +3,12 @@
package isatty
-import (
- "syscall"
- "unsafe"
-)
-
-const ioctlReadTermios = syscall.TIOCGETA
+import "golang.org/x/sys/unix"
// IsTerminal return true if the file descriptor is terminal.
func IsTerminal(fd uintptr) bool {
- var termios syscall.Termios
- _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0)
- return err == 0
+ _, err := unix.IoctlGetTermios(int(fd), unix.TIOCGETA)
+ return err == nil
}
// IsCygwinTerminal return true if the file descriptor is a cygwin or msys2
diff --git a/vendor/github.com/mattn/go-isatty/isatty_linux.go b/vendor/github.com/mattn/go-isatty/isatty_linux.go
deleted file mode 100644
index 4f8af46..0000000
--- a/vendor/github.com/mattn/go-isatty/isatty_linux.go
+++ /dev/null
@@ -1,19 +0,0 @@
-// +build linux
-// +build !appengine
-// +build !android
-
-package isatty
-
-import "golang.org/x/sys/unix"
-
-// IsTerminal return true if the file descriptor is terminal.
-func IsTerminal(fd uintptr) bool {
- _, err := unix.IoctlGetTermios(int(fd), unix.TCGETS)
- return err == nil
-}
-
-// IsCygwinTerminal return true if the file descriptor is a cygwin or msys2
-// terminal. This is also always false on this environment.
-func IsCygwinTerminal(fd uintptr) bool {
- return false
-}
diff --git a/vendor/github.com/mattn/go-isatty/isatty_others.go b/vendor/github.com/mattn/go-isatty/isatty_others.go
index f02849c..ff714a3 100644
--- a/vendor/github.com/mattn/go-isatty/isatty_others.go
+++ b/vendor/github.com/mattn/go-isatty/isatty_others.go
@@ -1,4 +1,4 @@
-// +build appengine js
+// +build appengine js nacl
package isatty
diff --git a/vendor/github.com/mattn/go-isatty/isatty_windows.go b/vendor/github.com/mattn/go-isatty/isatty_windows.go
index af51cbc..1fa8691 100644
--- a/vendor/github.com/mattn/go-isatty/isatty_windows.go
+++ b/vendor/github.com/mattn/go-isatty/isatty_windows.go
@@ -4,6 +4,7 @@
package isatty
import (
+ "errors"
"strings"
"syscall"
"unicode/utf16"
@@ -11,15 +12,18 @@ import (
)
const (
- fileNameInfo uintptr = 2
- fileTypePipe = 3
+ objectNameInfo uintptr = 1
+ fileNameInfo = 2
+ fileTypePipe = 3
)
var (
kernel32 = syscall.NewLazyDLL("kernel32.dll")
+ ntdll = syscall.NewLazyDLL("ntdll.dll")
procGetConsoleMode = kernel32.NewProc("GetConsoleMode")
procGetFileInformationByHandleEx = kernel32.NewProc("GetFileInformationByHandleEx")
procGetFileType = kernel32.NewProc("GetFileType")
+ procNtQueryObject = ntdll.NewProc("NtQueryObject")
)
func init() {
@@ -45,7 +49,10 @@ func isCygwinPipeName(name string) bool {
return false
}
- if token[0] != `\msys` && token[0] != `\cygwin` {
+ if token[0] != `\msys` &&
+ token[0] != `\cygwin` &&
+ token[0] != `\Device\NamedPipe\msys` &&
+ token[0] != `\Device\NamedPipe\cygwin` {
return false
}
@@ -68,11 +75,35 @@ func isCygwinPipeName(name string) bool {
return true
}
+// getFileNameByHandle use the undocomented ntdll NtQueryObject to get file full name from file handler
+// since GetFileInformationByHandleEx is not avilable under windows Vista and still some old fashion
+// guys are using Windows XP, this is a workaround for those guys, it will also work on system from
+// Windows vista to 10
+// see https://stackoverflow.com/a/18792477 for details
+func getFileNameByHandle(fd uintptr) (string, error) {
+ if procNtQueryObject == nil {
+ return "", errors.New("ntdll.dll: NtQueryObject not supported")
+ }
+
+ var buf [4 + syscall.MAX_PATH]uint16
+ var result int
+ r, _, e := syscall.Syscall6(procNtQueryObject.Addr(), 5,
+ fd, objectNameInfo, uintptr(unsafe.Pointer(&buf)), uintptr(2*len(buf)), uintptr(unsafe.Pointer(&result)), 0)
+ if r != 0 {
+ return "", e
+ }
+ return string(utf16.Decode(buf[4 : 4+buf[0]/2])), nil
+}
+
// IsCygwinTerminal() return true if the file descriptor is a cygwin or msys2
// terminal.
func IsCygwinTerminal(fd uintptr) bool {
if procGetFileInformationByHandleEx == nil {
- return false
+ name, err := getFileNameByHandle(fd)
+ if err != nil {
+ return false
+ }
+ return isCygwinPipeName(name)
}
// Cygwin/msys's pty is a pipe.
diff --git a/vendor/github.com/ugorji/go/codec/0doc.go b/vendor/github.com/ugorji/go/codec/0doc.go
deleted file mode 100644
index 9c8ce86..0000000
--- a/vendor/github.com/ugorji/go/codec/0doc.go
+++ /dev/null
@@ -1,227 +0,0 @@
-// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved.
-// Use of this source code is governed by a MIT license found in the LICENSE file.
-
-/*
-Package codec provides a
-High Performance, Feature-Rich Idiomatic Go 1.4+ codec/encoding library
-for binc, msgpack, cbor, json.
-
-Supported Serialization formats are:
-
- - msgpack: https://github.com/msgpack/msgpack
- - binc: http://github.com/ugorji/binc
- - cbor: http://cbor.io http://tools.ietf.org/html/rfc7049
- - json: http://json.org http://tools.ietf.org/html/rfc7159
- - simple:
-
-To install:
-
- go get github.com/ugorji/go/codec
-
-This package will carefully use 'unsafe' for performance reasons in specific places.
-You can build without unsafe use by passing the safe or appengine tag
-i.e. 'go install -tags=safe ...'. Note that unsafe is only supported for the last 3
-go sdk versions e.g. current go release is go 1.9, so we support unsafe use only from
-go 1.7+ . This is because supporting unsafe requires knowledge of implementation details.
-
-For detailed usage information, read the primer at http://ugorji.net/blog/go-codec-primer .
-
-The idiomatic Go support is as seen in other encoding packages in
-the standard library (ie json, xml, gob, etc).
-
-Rich Feature Set includes:
-
- - Simple but extremely powerful and feature-rich API
- - Support for go1.4 and above, while selectively using newer APIs for later releases
- - Excellent code coverage ( > 90% )
- - Very High Performance.
- Our extensive benchmarks show us outperforming Gob, Json, Bson, etc by 2-4X.
- - Careful selected use of 'unsafe' for targeted performance gains.
- 100% mode exists where 'unsafe' is not used at all.
- - Lock-free (sans mutex) concurrency for scaling to 100's of cores
- - In-place updates during decode, with option to zero value in maps and slices prior to decode
- - Coerce types where appropriate
- e.g. decode an int in the stream into a float, decode numbers from formatted strings, etc
- - Corner Cases:
- Overflows, nil maps/slices, nil values in streams are handled correctly
- - Standard field renaming via tags
- - Support for omitting empty fields during an encoding
- - Encoding from any value and decoding into pointer to any value
- (struct, slice, map, primitives, pointers, interface{}, etc)
- - Extensions to support efficient encoding/decoding of any named types
- - Support encoding.(Binary|Text)(M|Unm)arshaler interfaces
- - Support IsZero() bool to determine if a value is a zero value.
- Analogous to time.Time.IsZero() bool.
- - Decoding without a schema (into a interface{}).
- Includes Options to configure what specific map or slice type to use
- when decoding an encoded list or map into a nil interface{}
- - Mapping a non-interface type to an interface, so we can decode appropriately
- into any interface type with a correctly configured non-interface value.
- - Encode a struct as an array, and decode struct from an array in the data stream
- - Option to encode struct keys as numbers (instead of strings)
- (to support structured streams with fields encoded as numeric codes)
- - Comprehensive support for anonymous fields
- - Fast (no-reflection) encoding/decoding of common maps and slices
- - Code-generation for faster performance.
- - Support binary (e.g. messagepack, cbor) and text (e.g. json) formats
- - Support indefinite-length formats to enable true streaming
- (for formats which support it e.g. json, cbor)
- - Support canonical encoding, where a value is ALWAYS encoded as same sequence of bytes.
- This mostly applies to maps, where iteration order is non-deterministic.
- - NIL in data stream decoded as zero value
- - Never silently skip data when decoding.
- User decides whether to return an error or silently skip data when keys or indexes
- in the data stream do not map to fields in the struct.
- - Detect and error when encoding a cyclic reference (instead of stack overflow shutdown)
- - Encode/Decode from/to chan types (for iterative streaming support)
- - Drop-in replacement for encoding/json. `json:` key in struct tag supported.
- - Provides a RPC Server and Client Codec for net/rpc communication protocol.
- - Handle unique idiosyncrasies of codecs e.g.
- - For messagepack, configure how ambiguities in handling raw bytes are resolved
- - For messagepack, provide rpc server/client codec to support
- msgpack-rpc protocol defined at:
- https://github.com/msgpack-rpc/msgpack-rpc/blob/master/spec.md
-
-Extension Support
-
-Users can register a function to handle the encoding or decoding of
-their custom types.
-
-There are no restrictions on what the custom type can be. Some examples:
-
- type BisSet []int
- type BitSet64 uint64
- type UUID string
- type MyStructWithUnexportedFields struct { a int; b bool; c []int; }
- type GifImage struct { ... }
-
-As an illustration, MyStructWithUnexportedFields would normally be
-encoded as an empty map because it has no exported fields, while UUID
-would be encoded as a string. However, with extension support, you can
-encode any of these however you like.
-
-Custom Encoding and Decoding
-
-This package maintains symmetry in the encoding and decoding halfs.
-We determine how to encode or decode by walking this decision tree
-
- - is type a codec.Selfer?
- - is there an extension registered for the type?
- - is format binary, and is type a encoding.BinaryMarshaler and BinaryUnmarshaler?
- - is format specifically json, and is type a encoding/json.Marshaler and Unmarshaler?
- - is format text-based, and type an encoding.TextMarshaler?
- - else we use a pair of functions based on the "kind" of the type e.g. map, slice, int64, etc
-
-This symmetry is important to reduce chances of issues happening because the
-encoding and decoding sides are out of sync e.g. decoded via very specific
-encoding.TextUnmarshaler but encoded via kind-specific generalized mode.
-
-Consequently, if a type only defines one-half of the symmetry
-(e.g. it implements UnmarshalJSON() but not MarshalJSON() ),
-then that type doesn't satisfy the check and we will continue walking down the
-decision tree.
-
-RPC
-
-RPC Client and Server Codecs are implemented, so the codecs can be used
-with the standard net/rpc package.
-
-Usage
-
-The Handle is SAFE for concurrent READ, but NOT SAFE for concurrent modification.
-
-The Encoder and Decoder are NOT safe for concurrent use.
-
-Consequently, the usage model is basically:
-
- - Create and initialize the Handle before any use.
- Once created, DO NOT modify it.
- - Multiple Encoders or Decoders can now use the Handle concurrently.
- They only read information off the Handle (never write).
- - However, each Encoder or Decoder MUST not be used concurrently
- - To re-use an Encoder/Decoder, call Reset(...) on it first.
- This allows you use state maintained on the Encoder/Decoder.
-
-Sample usage model:
-
- // create and configure Handle
- var (
- bh codec.BincHandle
- mh codec.MsgpackHandle
- ch codec.CborHandle
- )
-
- mh.MapType = reflect.TypeOf(map[string]interface{}(nil))
-
- // configure extensions
- // e.g. for msgpack, define functions and enable Time support for tag 1
- // mh.SetExt(reflect.TypeOf(time.Time{}), 1, myExt)
-
- // create and use decoder/encoder
- var (
- r io.Reader
- w io.Writer
- b []byte
- h = &bh // or mh to use msgpack
- )
-
- dec = codec.NewDecoder(r, h)
- dec = codec.NewDecoderBytes(b, h)
- err = dec.Decode(&v)
-
- enc = codec.NewEncoder(w, h)
- enc = codec.NewEncoderBytes(&b, h)
- err = enc.Encode(v)
-
- //RPC Server
- go func() {
- for {
- conn, err := listener.Accept()
- rpcCodec := codec.GoRpc.ServerCodec(conn, h)
- //OR rpcCodec := codec.MsgpackSpecRpc.ServerCodec(conn, h)
- rpc.ServeCodec(rpcCodec)
- }
- }()
-
- //RPC Communication (client side)
- conn, err = net.Dial("tcp", "localhost:5555")
- rpcCodec := codec.GoRpc.ClientCodec(conn, h)
- //OR rpcCodec := codec.MsgpackSpecRpc.ClientCodec(conn, h)
- client := rpc.NewClientWithCodec(rpcCodec)
-
-Running Tests
-
-To run tests, use the following:
-
- go test
-
-To run the full suite of tests, use the following:
-
- go test -tags alltests -run Suite
-
-You can run the tag 'safe' to run tests or build in safe mode. e.g.
-
- go test -tags safe -run Json
- go test -tags "alltests safe" -run Suite
-
-Running Benchmarks
-
-Please see http://github.com/ugorji/go-codec-bench .
-
-Caveats
-
-Struct fields matching the following are ignored during encoding and decoding
- - struct tag value set to -
- - func, complex numbers, unsafe pointers
- - unexported and not embedded
- - unexported and embedded and not struct kind
- - unexported and embedded pointers (from go1.10)
-
-Every other field in a struct will be encoded/decoded.
-
-Embedded fields are encoded as if they exist in the top-level struct,
-with some caveats. See Encode documentation.
-
-*/
-package codec
-
diff --git a/vendor/github.com/ugorji/go/codec/README.md b/vendor/github.com/ugorji/go/codec/README.md
deleted file mode 100644
index c942478..0000000
--- a/vendor/github.com/ugorji/go/codec/README.md
+++ /dev/null
@@ -1,207 +0,0 @@
-# Codec
-
-High Performance, Feature-Rich Idiomatic Go codec/encoding library for
-binc, msgpack, cbor, json.
-
-Supported Serialization formats are:
-
- - msgpack: https://github.com/msgpack/msgpack
- - binc: http://github.com/ugorji/binc
- - cbor: http://cbor.io http://tools.ietf.org/html/rfc7049
- - json: http://json.org http://tools.ietf.org/html/rfc7159
- - simple:
-
-To install:
-
- go get github.com/ugorji/go/codec
-
-This package will carefully use 'unsafe' for performance reasons in specific places.
-You can build without unsafe use by passing the safe or appengine tag
-i.e. 'go install -tags=safe ...'. Note that unsafe is only supported for the last 3
-go sdk versions e.g. current go release is go 1.9, so we support unsafe use only from
-go 1.7+ . This is because supporting unsafe requires knowledge of implementation details.
-
-Online documentation: http://godoc.org/github.com/ugorji/go/codec
-Detailed Usage/How-to Primer: http://ugorji.net/blog/go-codec-primer
-
-The idiomatic Go support is as seen in other encoding packages in
-the standard library (ie json, xml, gob, etc).
-
-Rich Feature Set includes:
-
- - Simple but extremely powerful and feature-rich API
- - Support for go1.4 and above, while selectively using newer APIs for later releases
- - Excellent code coverage ( > 90% )
- - Very High Performance.
- Our extensive benchmarks show us outperforming Gob, Json, Bson, etc by 2-4X.
- - Careful selected use of 'unsafe' for targeted performance gains.
- 100% mode exists where 'unsafe' is not used at all.
- - Lock-free (sans mutex) concurrency for scaling to 100's of cores
- - In-place updates during decode, with option to zero the value in maps and slices prior to decode
- - Coerce types where appropriate
- e.g. decode an int in the stream into a float, decode numbers from formatted strings, etc
- - Corner Cases:
- Overflows, nil maps/slices, nil values in streams are handled correctly
- - Standard field renaming via tags
- - Support for omitting empty fields during an encoding
- - Encoding from any value and decoding into pointer to any value
- (struct, slice, map, primitives, pointers, interface{}, etc)
- - Extensions to support efficient encoding/decoding of any named types
- - Support encoding.(Binary|Text)(M|Unm)arshaler interfaces
- - Support IsZero() bool to determine if a value is a zero value.
- Analogous to time.Time.IsZero() bool.
- - Decoding without a schema (into a interface{}).
- Includes Options to configure what specific map or slice type to use
- when decoding an encoded list or map into a nil interface{}
- - Mapping a non-interface type to an interface, so we can decode appropriately
- into any interface type with a correctly configured non-interface value.
- - Encode a struct as an array, and decode struct from an array in the data stream
- - Option to encode struct keys as numbers (instead of strings)
- (to support structured streams with fields encoded as numeric codes)
- - Comprehensive support for anonymous fields
- - Fast (no-reflection) encoding/decoding of common maps and slices
- - Code-generation for faster performance.
- - Support binary (e.g. messagepack, cbor) and text (e.g. json) formats
- - Support indefinite-length formats to enable true streaming
- (for formats which support it e.g. json, cbor)
- - Support canonical encoding, where a value is ALWAYS encoded as same sequence of bytes.
- This mostly applies to maps, where iteration order is non-deterministic.
- - NIL in data stream decoded as zero value
- - Never silently skip data when decoding.
- User decides whether to return an error or silently skip data when keys or indexes
- in the data stream do not map to fields in the struct.
- - Encode/Decode from/to chan types (for iterative streaming support)
- - Drop-in replacement for encoding/json. `json:` key in struct tag supported.
- - Provides a RPC Server and Client Codec for net/rpc communication protocol.
- - Handle unique idiosyncrasies of codecs e.g.
- - For messagepack, configure how ambiguities in handling raw bytes are resolved
- - For messagepack, provide rpc server/client codec to support
- msgpack-rpc protocol defined at:
- https://github.com/msgpack-rpc/msgpack-rpc/blob/master/spec.md
-
-## Extension Support
-
-Users can register a function to handle the encoding or decoding of
-their custom types.
-
-There are no restrictions on what the custom type can be. Some examples:
-
- type BisSet []int
- type BitSet64 uint64
- type UUID string
- type MyStructWithUnexportedFields struct { a int; b bool; c []int; }
- type GifImage struct { ... }
-
-As an illustration, MyStructWithUnexportedFields would normally be
-encoded as an empty map because it has no exported fields, while UUID
-would be encoded as a string. However, with extension support, you can
-encode any of these however you like.
-
-## Custom Encoding and Decoding
-
-This package maintains symmetry in the encoding and decoding halfs.
-We determine how to encode or decode by walking this decision tree
-
- - is type a codec.Selfer?
- - is there an extension registered for the type?
- - is format binary, and is type a encoding.BinaryMarshaler and BinaryUnmarshaler?
- - is format specifically json, and is type a encoding/json.Marshaler and Unmarshaler?
- - is format text-based, and type an encoding.TextMarshaler?
- - else we use a pair of functions based on the "kind" of the type e.g. map, slice, int64, etc
-
-This symmetry is important to reduce chances of issues happening because the
-encoding and decoding sides are out of sync e.g. decoded via very specific
-encoding.TextUnmarshaler but encoded via kind-specific generalized mode.
-
-Consequently, if a type only defines one-half of the symmetry
-(e.g. it implements UnmarshalJSON() but not MarshalJSON() ),
-then that type doesn't satisfy the check and we will continue walking down the
-decision tree.
-
-## RPC
-
-RPC Client and Server Codecs are implemented, so the codecs can be used
-with the standard net/rpc package.
-
-## Usage
-
-Typical usage model:
-
- // create and configure Handle
- var (
- bh codec.BincHandle
- mh codec.MsgpackHandle
- ch codec.CborHandle
- )
-
- mh.MapType = reflect.TypeOf(map[string]interface{}(nil))
-
- // configure extensions
- // e.g. for msgpack, define functions and enable Time support for tag 1
- // mh.SetExt(reflect.TypeOf(time.Time{}), 1, myExt)
-
- // create and use decoder/encoder
- var (
- r io.Reader
- w io.Writer
- b []byte
- h = &bh // or mh to use msgpack
- )
-
- dec = codec.NewDecoder(r, h)
- dec = codec.NewDecoderBytes(b, h)
- err = dec.Decode(&v)
-
- enc = codec.NewEncoder(w, h)
- enc = codec.NewEncoderBytes(&b, h)
- err = enc.Encode(v)
-
- //RPC Server
- go func() {
- for {
- conn, err := listener.Accept()
- rpcCodec := codec.GoRpc.ServerCodec(conn, h)
- //OR rpcCodec := codec.MsgpackSpecRpc.ServerCodec(conn, h)
- rpc.ServeCodec(rpcCodec)
- }
- }()
-
- //RPC Communication (client side)
- conn, err = net.Dial("tcp", "localhost:5555")
- rpcCodec := codec.GoRpc.ClientCodec(conn, h)
- //OR rpcCodec := codec.MsgpackSpecRpc.ClientCodec(conn, h)
- client := rpc.NewClientWithCodec(rpcCodec)
-
-## Running Tests
-
-To run tests, use the following:
-
- go test
-
-To run the full suite of tests, use the following:
-
- go test -tags alltests -run Suite
-
-You can run the tag 'safe' to run tests or build in safe mode. e.g.
-
- go test -tags safe -run Json
- go test -tags "alltests safe" -run Suite
-
-## Running Benchmarks
-
-Please see http://github.com/ugorji/go-codec-bench .
-
-## Caveats
-
-Struct fields matching the following are ignored during encoding and decoding
-
- - struct tag value set to -
- - func, complex numbers, unsafe pointers
- - unexported and not embedded
- - unexported and embedded and not struct kind
- - unexported and embedded pointers (from go1.10)
-
-Every other field in a struct will be encoded/decoded.
-
-Embedded fields are encoded as if they exist in the top-level struct,
-with some caveats. See Encode documentation.
diff --git a/vendor/github.com/ugorji/go/codec/binc.go b/vendor/github.com/ugorji/go/codec/binc.go
index e6f3f49..802b32c 100644
--- a/vendor/github.com/ugorji/go/codec/binc.go
+++ b/vendor/github.com/ugorji/go/codec/binc.go
@@ -5,7 +5,6 @@ package codec
import (
"math"
- "reflect"
"time"
)
@@ -100,21 +99,22 @@ func bincdesc(vd, vs byte) string {
}
type bincEncDriver struct {
- e *Encoder
+ noBuiltInTypes
+ encDriverNoopContainerWriter
h *BincHandle
- w *encWriterSwitch
m map[string]uint16 // symbols
- b [16]byte // scratch, used for encoding numbers - bigendian style
+ b [8]byte // scratch, used for encoding numbers - bigendian style
s uint16 // symbols sequencer
- // c containerState
- encDriverTrackContainerWriter
- noBuiltInTypes
- // encNoSeparator
- _ [1]uint64 // padding
+ _ [4]uint64 // padding
+ e Encoder
+}
+
+func (e *bincEncDriver) encoder() *Encoder {
+ return &e.e
}
func (e *bincEncDriver) EncodeNil() {
- e.w.writen1(bincVdSpecial<<4 | bincSpNil)
+ e.e.encWr.writen1(bincVdSpecial<<4 | bincSpNil)
}
func (e *bincEncDriver) EncodeTime(t time.Time) {
@@ -122,31 +122,31 @@ func (e *bincEncDriver) EncodeTime(t time.Time) {
e.EncodeNil()
} else {
bs := bincEncodeTime(t)
- e.w.writen1(bincVdTimestamp<<4 | uint8(len(bs)))
- e.w.writeb(bs)
+ e.e.encWr.writen1(bincVdTimestamp<<4 | uint8(len(bs)))
+ e.e.encWr.writeb(bs)
}
}
func (e *bincEncDriver) EncodeBool(b bool) {
if b {
- e.w.writen1(bincVdSpecial<<4 | bincSpTrue)
+ e.e.encWr.writen1(bincVdSpecial<<4 | bincSpTrue)
} else {
- e.w.writen1(bincVdSpecial<<4 | bincSpFalse)
+ e.e.encWr.writen1(bincVdSpecial<<4 | bincSpFalse)
}
}
func (e *bincEncDriver) EncodeFloat32(f float32) {
if f == 0 {
- e.w.writen1(bincVdSpecial<<4 | bincSpZeroFloat)
+ e.e.encWr.writen1(bincVdSpecial<<4 | bincSpZeroFloat)
return
}
- e.w.writen1(bincVdFloat<<4 | bincFlBin32)
- bigenHelper{e.b[:4], e.w}.writeUint32(math.Float32bits(f))
+ e.e.encWr.writen1(bincVdFloat<<4 | bincFlBin32)
+ bigenHelper{e.b[:4], e.e.w()}.writeUint32(math.Float32bits(f))
}
func (e *bincEncDriver) EncodeFloat64(f float64) {
if f == 0 {
- e.w.writen1(bincVdSpecial<<4 | bincSpZeroFloat)
+ e.e.encWr.writen1(bincVdSpecial<<4 | bincSpZeroFloat)
return
}
bigen.PutUint64(e.b[:8], math.Float64bits(f))
@@ -156,14 +156,14 @@ func (e *bincEncDriver) EncodeFloat64(f float64) {
}
i++
if i <= 6 {
- e.w.writen1(bincVdFloat<<4 | 0x8 | bincFlBin64)
- e.w.writen1(byte(i))
- e.w.writeb(e.b[:i])
+ e.e.encWr.writen1(bincVdFloat<<4 | 0x8 | bincFlBin64)
+ e.e.encWr.writen1(byte(i))
+ e.e.encWr.writeb(e.b[:i])
return
}
}
- e.w.writen1(bincVdFloat<<4 | bincFlBin64)
- e.w.writeb(e.b[:8])
+ e.e.encWr.writen1(bincVdFloat<<4 | bincFlBin64)
+ e.e.encWr.writeb(e.b[:8])
}
func (e *bincEncDriver) encIntegerPrune(bd byte, pos bool, v uint64, lim uint8) {
@@ -174,11 +174,11 @@ func (e *bincEncDriver) encIntegerPrune(bd byte, pos bool, v uint64, lim uint8)
}
if bincDoPrune {
i := pruneSignExt(e.b[:lim], pos)
- e.w.writen1(bd | lim - 1 - byte(i))
- e.w.writeb(e.b[i:lim])
+ e.e.encWr.writen1(bd | lim - 1 - byte(i))
+ e.e.encWr.writeb(e.b[i:lim])
} else {
- e.w.writen1(bd | lim - 1)
- e.w.writeb(e.b[:lim])
+ e.e.encWr.writen1(bd | lim - 1)
+ e.e.encWr.writeb(e.b[:lim])
}
}
@@ -187,7 +187,7 @@ func (e *bincEncDriver) EncodeInt(v int64) {
if v >= 0 {
e.encUint(bincVdPosInt<<4, true, uint64(v))
} else if v == -1 {
- e.w.writen1(bincVdSpecial<<4 | bincSpNegOne)
+ e.e.encWr.writen1(bincVdSpecial<<4 | bincSpNegOne)
} else {
e.encUint(bincVdNegInt<<4, false, uint64(-v))
}
@@ -199,14 +199,14 @@ func (e *bincEncDriver) EncodeUint(v uint64) {
func (e *bincEncDriver) encUint(bd byte, pos bool, v uint64) {
if v == 0 {
- e.w.writen1(bincVdSpecial<<4 | bincSpZero)
+ e.e.encWr.writen1(bincVdSpecial<<4 | bincSpZero)
} else if pos && v >= 1 && v <= 16 {
- e.w.writen1(bincVdSmallInt<<4 | byte(v-1))
+ e.e.encWr.writen1(bincVdSmallInt<<4 | byte(v-1))
} else if v <= math.MaxUint8 {
- e.w.writen2(bd|0x0, byte(v))
+ e.e.encWr.writen2(bd|0x0, byte(v))
} else if v <= math.MaxUint16 {
- e.w.writen1(bd | 0x01)
- bigenHelper{e.b[:2], e.w}.writeUint16(uint16(v))
+ e.e.encWr.writen1(bd | 0x01)
+ bigenHelper{e.b[:2], e.e.w()}.writeUint16(uint16(v))
} else if v <= math.MaxUint32 {
e.encIntegerPrune(bd, pos, v, 4)
} else {
@@ -214,34 +214,41 @@ func (e *bincEncDriver) encUint(bd byte, pos bool, v uint64) {
}
}
-func (e *bincEncDriver) EncodeExt(rv interface{}, xtag uint64, ext Ext, _ *Encoder) {
- bs := ext.WriteExt(rv)
+func (e *bincEncDriver) EncodeExt(v interface{}, xtag uint64, ext Ext) {
+ var bs []byte
+ if ext == SelfExt {
+ bs = e.e.blist.get(1024)[:0]
+ e.e.sideEncode(v, &bs)
+ } else {
+ bs = ext.WriteExt(v)
+ }
if bs == nil {
e.EncodeNil()
return
}
e.encodeExtPreamble(uint8(xtag), len(bs))
- e.w.writeb(bs)
+ e.e.encWr.writeb(bs)
+ if ext == SelfExt {
+ e.e.blist.put(bs)
+ }
}
-func (e *bincEncDriver) EncodeRawExt(re *RawExt, _ *Encoder) {
+func (e *bincEncDriver) EncodeRawExt(re *RawExt) {
e.encodeExtPreamble(uint8(re.Tag), len(re.Data))
- e.w.writeb(re.Data)
+ e.e.encWr.writeb(re.Data)
}
func (e *bincEncDriver) encodeExtPreamble(xtag byte, length int) {
e.encLen(bincVdCustomExt<<4, uint64(length))
- e.w.writen1(xtag)
+ e.e.encWr.writen1(xtag)
}
func (e *bincEncDriver) WriteArrayStart(length int) {
e.encLen(bincVdArray<<4, uint64(length))
- e.c = containerArrayStart
}
func (e *bincEncDriver) WriteMapStart(length int) {
e.encLen(bincVdMap<<4, uint64(length))
- e.c = containerMapStart
}
func (e *bincEncDriver) EncodeSymbol(v string) {
@@ -260,7 +267,7 @@ func (e *bincEncDriver) EncodeSymbol(v string) {
return
} else if l == 1 {
e.encBytesLen(cUTF8, 1)
- e.w.writen1(v[0])
+ e.e.encWr.writen1(v[0])
return
}
if e.m == nil {
@@ -269,10 +276,10 @@ func (e *bincEncDriver) EncodeSymbol(v string) {
ui, ok := e.m[v]
if ok {
if ui <= math.MaxUint8 {
- e.w.writen2(bincVdSymbol<<4, byte(ui))
+ e.e.encWr.writen2(bincVdSymbol<<4, byte(ui))
} else {
- e.w.writen1(bincVdSymbol<<4 | 0x8)
- bigenHelper{e.b[:2], e.w}.writeUint16(ui)
+ e.e.encWr.writen1(bincVdSymbol<<4 | 0x8)
+ bigenHelper{e.b[:2], e.e.w()}.writeUint16(ui)
}
} else {
e.s++
@@ -290,58 +297,43 @@ func (e *bincEncDriver) EncodeSymbol(v string) {
lenprec = 3
}
if ui <= math.MaxUint8 {
- e.w.writen2(bincVdSymbol<<4|0x0|0x4|lenprec, byte(ui))
+ e.e.encWr.writen2(bincVdSymbol<<4|0x0|0x4|lenprec, byte(ui))
} else {
- e.w.writen1(bincVdSymbol<<4 | 0x8 | 0x4 | lenprec)
- bigenHelper{e.b[:2], e.w}.writeUint16(ui)
+ e.e.encWr.writen1(bincVdSymbol<<4 | 0x8 | 0x4 | lenprec)
+ bigenHelper{e.b[:2], e.e.w()}.writeUint16(ui)
}
if lenprec == 0 {
- e.w.writen1(byte(l))
+ e.e.encWr.writen1(byte(l))
} else if lenprec == 1 {
- bigenHelper{e.b[:2], e.w}.writeUint16(uint16(l))
+ bigenHelper{e.b[:2], e.e.w()}.writeUint16(uint16(l))
} else if lenprec == 2 {
- bigenHelper{e.b[:4], e.w}.writeUint32(uint32(l))
+ bigenHelper{e.b[:4], e.e.w()}.writeUint32(uint32(l))
} else {
- bigenHelper{e.b[:8], e.w}.writeUint64(uint64(l))
+ bigenHelper{e.b[:8], e.e.w()}.writeUint64(uint64(l))
}
- e.w.writestr(v)
+ e.e.encWr.writestr(v)
}
}
-func (e *bincEncDriver) EncodeString(c charEncoding, v string) {
- if e.c == containerMapKey && c == cUTF8 && (e.h.AsSymbols == 0 || e.h.AsSymbols == 1) {
- e.EncodeSymbol(v)
+func (e *bincEncDriver) EncodeString(v string) {
+ if e.h.StringToRaw {
+ e.encLen(bincVdByteArray<<4, uint64(len(v))) // e.encBytesLen(c, l)
+ if len(v) > 0 {
+ e.e.encWr.writestr(v)
+ }
return
}
- l := uint64(len(v))
- e.encBytesLen(c, l)
- if l > 0 {
- e.w.writestr(v)
- }
+ e.EncodeStringEnc(cUTF8, v)
}
func (e *bincEncDriver) EncodeStringEnc(c charEncoding, v string) {
- if e.c == containerMapKey && c == cUTF8 && (e.h.AsSymbols == 0 || e.h.AsSymbols == 1) {
+ if e.e.c == containerMapKey && c == cUTF8 && (e.h.AsSymbols == 1) {
e.EncodeSymbol(v)
return
}
- l := uint64(len(v))
- e.encLen(bincVdString<<4, l) // e.encBytesLen(c, l)
- if l > 0 {
- e.w.writestr(v)
- }
-
-}
-
-func (e *bincEncDriver) EncodeStringBytes(c charEncoding, v []byte) {
- if v == nil {
- e.EncodeNil()
- return
- }
- l := uint64(len(v))
- e.encBytesLen(c, l)
- if l > 0 {
- e.w.writeb(v)
+ e.encLen(bincVdString<<4, uint64(len(v))) // e.encBytesLen(c, l)
+ if len(v) > 0 {
+ e.e.encWr.writestr(v)
}
}
@@ -350,15 +342,16 @@ func (e *bincEncDriver) EncodeStringBytesRaw(v []byte) {
e.EncodeNil()
return
}
- l := uint64(len(v))
- e.encLen(bincVdByteArray<<4, l) // e.encBytesLen(c, l)
- if l > 0 {
- e.w.writeb(v)
+ e.encLen(bincVdByteArray<<4, uint64(len(v))) // e.encBytesLen(c, l)
+ if len(v) > 0 {
+ e.e.encWr.writeb(v)
}
}
func (e *bincEncDriver) encBytesLen(c charEncoding, length uint64) {
- //TODO: support bincUnicodeOther (for now, just use string or bytearray)
+ // NOTE: we currently only support UTF-8 (string) and RAW (bytearray).
+ // We should consider supporting bincUnicodeOther.
+
if c == cRAW {
e.encLen(bincVdByteArray<<4, length)
} else {
@@ -368,7 +361,7 @@ func (e *bincEncDriver) encBytesLen(c charEncoding, length uint64) {
func (e *bincEncDriver) encLen(bd byte, l uint64) {
if l < 12 {
- e.w.writen1(bd | uint8(l+4))
+ e.e.encWr.writen1(bd | uint8(l+4))
} else {
e.encLenNumber(bd, l)
}
@@ -376,52 +369,49 @@ func (e *bincEncDriver) encLen(bd byte, l uint64) {
func (e *bincEncDriver) encLenNumber(bd byte, v uint64) {
if v <= math.MaxUint8 {
- e.w.writen2(bd, byte(v))
+ e.e.encWr.writen2(bd, byte(v))
} else if v <= math.MaxUint16 {
- e.w.writen1(bd | 0x01)
- bigenHelper{e.b[:2], e.w}.writeUint16(uint16(v))
+ e.e.encWr.writen1(bd | 0x01)
+ bigenHelper{e.b[:2], e.e.w()}.writeUint16(uint16(v))
} else if v <= math.MaxUint32 {
- e.w.writen1(bd | 0x02)
- bigenHelper{e.b[:4], e.w}.writeUint32(uint32(v))
+ e.e.encWr.writen1(bd | 0x02)
+ bigenHelper{e.b[:4], e.e.w()}.writeUint32(uint32(v))
} else {
- e.w.writen1(bd | 0x03)
- bigenHelper{e.b[:8], e.w}.writeUint64(uint64(v))
+ e.e.encWr.writen1(bd | 0x03)
+ bigenHelper{e.b[:8], e.e.w()}.writeUint64(uint64(v))
}
}
//------------------------------------
-type bincDecSymbol struct {
- s string
- b []byte
- i uint16
-}
-
type bincDecDriver struct {
decDriverNoopContainerReader
noBuiltInTypes
- d *Decoder
h *BincHandle
- r *decReaderSwitch
- br bool // bytes reader
bdRead bool
bd byte
vd byte
vs byte
- _ [3]byte // padding
+
+ fnil bool
+ // _ [3]byte // padding
// linear searching on this slice is ok,
// because we typically expect < 32 symbols in each stream.
- s []bincDecSymbol
+ s map[uint16][]byte // []bincDecSymbol
+
+ b [8]byte // scratch for decoding numbers - big endian style
+ _ [4]uint64 // padding cache-aligned
- // noStreamingCodec
- // decNoSeparator
+ d Decoder
+}
- b [(8 + 1) * 8]byte // scratch
+func (d *bincDecDriver) decoder() *Decoder {
+ return &d.d
}
func (d *bincDecDriver) readNextBd() {
- d.bd = d.r.readn1()
+ d.bd = d.d.decRd.readn1()
d.vd = d.bd >> 4
d.vs = d.bd & 0x0f
d.bdRead = true
@@ -429,16 +419,41 @@ func (d *bincDecDriver) readNextBd() {
func (d *bincDecDriver) uncacheRead() {
if d.bdRead {
- d.r.unreadn1()
+ d.d.decRd.unreadn1()
+ d.bdRead = false
+ }
+}
+
+func (d *bincDecDriver) advanceNil() (null bool) {
+ d.fnil = false
+ if !d.bdRead {
+ d.readNextBd()
+ }
+ if d.bd == bincVdSpecial<<4|bincSpNil {
d.bdRead = false
+ d.fnil = true
+ null = true
}
+ return
+}
+
+func (d *bincDecDriver) Nil() bool {
+ return d.fnil
+}
+
+func (d *bincDecDriver) TryNil() bool {
+ return d.advanceNil()
}
func (d *bincDecDriver) ContainerType() (vt valueType) {
if !d.bdRead {
d.readNextBd()
}
- if d.vd == bincVdSpecial && d.vs == bincSpNil {
+ d.fnil = false
+ // if d.vd == bincVdSpecial && d.vs == bincSpNil {
+ if d.bd == bincVdSpecial<<4|bincSpNil {
+ d.bdRead = false
+ d.fnil = true
return valueTypeNil
} else if d.vd == bincVdByteArray {
return valueTypeBytes
@@ -449,36 +464,18 @@ func (d *bincDecDriver) ContainerType() (vt valueType) {
} else if d.vd == bincVdMap {
return valueTypeMap
}
- // else {
- // d.d.errorf("isContainerType: unsupported parameter: %v", vt)
- // }
return valueTypeUnset
}
-func (d *bincDecDriver) TryDecodeAsNil() bool {
- if !d.bdRead {
- d.readNextBd()
- }
- if d.bd == bincVdSpecial<<4|bincSpNil {
- d.bdRead = false
- return true
- }
- return false
-}
-
func (d *bincDecDriver) DecodeTime() (t time.Time) {
- if !d.bdRead {
- d.readNextBd()
- }
- if d.bd == bincVdSpecial<<4|bincSpNil {
- d.bdRead = false
+ if d.advanceNil() {
return
}
if d.vd != bincVdTimestamp {
d.d.errorf("cannot decode time - %s %x-%x/%s", msgBadDesc, d.vd, d.vs, bincdesc(d.vd, d.vs))
return
}
- t, err := bincDecodeTime(d.r.readx(uint(d.vs)))
+ t, err := bincDecodeTime(d.d.decRd.readx(uint(d.vs)))
if err != nil {
panic(err)
}
@@ -488,9 +485,9 @@ func (d *bincDecDriver) DecodeTime() (t time.Time) {
func (d *bincDecDriver) decFloatPre(vs, defaultLen byte) {
if vs&0x8 == 0 {
- d.r.readb(d.b[0:defaultLen])
+ d.d.decRd.readb(d.b[0:defaultLen])
} else {
- l := d.r.readn1()
+ l := d.d.decRd.readn1()
if l > 8 {
d.d.errorf("cannot read float - at most 8 bytes used to represent float - received %v bytes", l)
return
@@ -498,12 +495,12 @@ func (d *bincDecDriver) decFloatPre(vs, defaultLen byte) {
for i := l; i < 8; i++ {
d.b[i] = 0
}
- d.r.readb(d.b[0:l])
+ d.d.decRd.readb(d.b[0:l])
}
}
func (d *bincDecDriver) decFloat() (f float64) {
- //if true { f = math.Float64frombits(bigen.Uint64(d.r.readx(8))); break; }
+ //if true { f = math.Float64frombits(bigen.Uint64(d.d.decRd.readx(8))); break; }
if x := d.vs & 0x7; x == bincFlBin32 {
d.decFloatPre(d.vs, 4)
f = float64(math.Float32frombits(bigen.Uint32(d.b[0:4])))
@@ -522,26 +519,26 @@ func (d *bincDecDriver) decUint() (v uint64) {
// need to inline the code (interface conversion and type assertion expensive)
switch d.vs {
case 0:
- v = uint64(d.r.readn1())
+ v = uint64(d.d.decRd.readn1())
case 1:
- d.r.readb(d.b[6:8])
+ d.d.decRd.readb(d.b[6:8])
v = uint64(bigen.Uint16(d.b[6:8]))
case 2:
d.b[4] = 0
- d.r.readb(d.b[5:8])
+ d.d.decRd.readb(d.b[5:8])
v = uint64(bigen.Uint32(d.b[4:8]))
case 3:
- d.r.readb(d.b[4:8])
+ d.d.decRd.readb(d.b[4:8])
v = uint64(bigen.Uint32(d.b[4:8]))
case 4, 5, 6:
lim := 7 - d.vs
- d.r.readb(d.b[lim:8])
+ d.d.decRd.readb(d.b[lim:8])
for i := uint8(0); i < lim; i++ {
d.b[i] = 0
}
v = uint64(bigen.Uint64(d.b[:8]))
case 7:
- d.r.readb(d.b[:8])
+ d.d.decRd.readb(d.b[:8])
v = uint64(bigen.Uint64(d.b[:8]))
default:
d.d.errorf("unsigned integers with greater than 64 bits of precision not supported")
@@ -551,9 +548,6 @@ func (d *bincDecDriver) decUint() (v uint64) {
}
func (d *bincDecDriver) decCheckInteger() (ui uint64, neg bool) {
- if !d.bdRead {
- d.readNextBd()
- }
vd, vs := d.vd, d.vs
if vd == bincVdPosInt {
ui = d.decUint()
@@ -581,6 +575,9 @@ func (d *bincDecDriver) decCheckInteger() (ui uint64, neg bool) {
}
func (d *bincDecDriver) DecodeInt64() (i int64) {
+ if d.advanceNil() {
+ return
+ }
ui, neg := d.decCheckInteger()
i = chkOvf.SignedIntV(ui)
if neg {
@@ -591,6 +588,9 @@ func (d *bincDecDriver) DecodeInt64() (i int64) {
}
func (d *bincDecDriver) DecodeUint64() (ui uint64) {
+ if d.advanceNil() {
+ return
+ }
ui, neg := d.decCheckInteger()
if neg {
d.d.errorf("assigning negative signed value to unsigned integer type")
@@ -601,8 +601,8 @@ func (d *bincDecDriver) DecodeUint64() (ui uint64) {
}
func (d *bincDecDriver) DecodeFloat64() (f float64) {
- if !d.bdRead {
- d.readNextBd()
+ if d.advanceNil() {
+ return
}
vd, vs := d.vd, d.vs
if vd == bincVdSpecial {
@@ -631,12 +631,12 @@ func (d *bincDecDriver) DecodeFloat64() (f float64) {
// bool can be decoded from bool only (single byte).
func (d *bincDecDriver) DecodeBool() (b bool) {
- if !d.bdRead {
- d.readNextBd()
+ if d.advanceNil() {
+ return
}
- if bd := d.bd; bd == (bincVdSpecial | bincSpFalse) {
+ if d.bd == (bincVdSpecial | bincSpFalse) {
// b = false
- } else if bd == (bincVdSpecial | bincSpTrue) {
+ } else if d.bd == (bincVdSpecial | bincSpTrue) {
b = true
} else {
d.d.errorf("bool - %s %x-%x/%s", msgBadDesc, d.vd, d.vs, bincdesc(d.vd, d.vs))
@@ -647,8 +647,8 @@ func (d *bincDecDriver) DecodeBool() (b bool) {
}
func (d *bincDecDriver) ReadMapStart() (length int) {
- if !d.bdRead {
- d.readNextBd()
+ if d.advanceNil() {
+ return decContainerLenNil
}
if d.vd != bincVdMap {
d.d.errorf("map - %s %x-%x/%s", msgBadDesc, d.vd, d.vs, bincdesc(d.vd, d.vs))
@@ -660,8 +660,8 @@ func (d *bincDecDriver) ReadMapStart() (length int) {
}
func (d *bincDecDriver) ReadArrayStart() (length int) {
- if !d.bdRead {
- d.readNextBd()
+ if d.advanceNil() {
+ return decContainerLenNil
}
if d.vd != bincVdArray {
d.d.errorf("array - %s %x-%x/%s", msgBadDesc, d.vd, d.vs, bincdesc(d.vd, d.vs))
@@ -681,27 +681,22 @@ func (d *bincDecDriver) decLen() int {
func (d *bincDecDriver) decLenNumber() (v uint64) {
if x := d.vs; x == 0 {
- v = uint64(d.r.readn1())
+ v = uint64(d.d.decRd.readn1())
} else if x == 1 {
- d.r.readb(d.b[6:8])
+ d.d.decRd.readb(d.b[6:8])
v = uint64(bigen.Uint16(d.b[6:8]))
} else if x == 2 {
- d.r.readb(d.b[4:8])
+ d.d.decRd.readb(d.b[4:8])
v = uint64(bigen.Uint32(d.b[4:8]))
} else {
- d.r.readb(d.b[:8])
+ d.d.decRd.readb(d.b[:8])
v = bigen.Uint64(d.b[:8])
}
return
}
-func (d *bincDecDriver) decStringAndBytes(bs []byte, withString, zerocopy bool) (
- bs2 []byte, s string) {
- if !d.bdRead {
- d.readNextBd()
- }
- if d.bd == bincVdSpecial<<4|bincSpNil {
- d.bdRead = false
+func (d *bincDecDriver) decStringBytes(bs []byte, zerocopy bool) (bs2 []byte) {
+ if d.advanceNil() {
return
}
var slen = -1
@@ -710,18 +705,15 @@ func (d *bincDecDriver) decStringAndBytes(bs []byte, withString, zerocopy bool)
case bincVdString, bincVdByteArray:
slen = d.decLen()
if zerocopy {
- if d.br {
- bs2 = d.r.readx(uint(slen))
+ if d.d.bytes {
+ bs2 = d.d.decRd.readx(uint(slen))
} else if len(bs) == 0 {
- bs2 = decByteSlice(d.r, slen, d.d.h.MaxInitLen, d.b[:])
+ bs2 = decByteSlice(d.d.r(), slen, d.d.h.MaxInitLen, d.d.b[:])
} else {
- bs2 = decByteSlice(d.r, slen, d.d.h.MaxInitLen, bs)
+ bs2 = decByteSlice(d.d.r(), slen, d.d.h.MaxInitLen, bs)
}
} else {
- bs2 = decByteSlice(d.r, slen, d.d.h.MaxInitLen, bs)
- }
- if withString {
- s = string(bs2)
+ bs2 = decByteSlice(d.d.r(), slen, d.d.h.MaxInitLen, bs)
}
case bincVdSymbol:
// zerocopy doesn't apply for symbols,
@@ -734,47 +726,34 @@ func (d *bincDecDriver) decStringAndBytes(bs []byte, withString, zerocopy bool)
var symbol uint16
vs := d.vs
if vs&0x8 == 0 {
- symbol = uint16(d.r.readn1())
+ symbol = uint16(d.d.decRd.readn1())
} else {
- symbol = uint16(bigen.Uint16(d.r.readx(2)))
+ symbol = uint16(bigen.Uint16(d.d.decRd.readx(2)))
}
if d.s == nil {
- d.s = make([]bincDecSymbol, 0, 16)
+ // d.s = pool4mapU16Bytes.Get().(map[uint16][]byte) // make([]bincDecSymbol, 0, 16)
+ d.s = make(map[uint16][]byte, 16)
}
if vs&0x4 == 0 {
- for i := range d.s {
- j := &d.s[i]
- if j.i == symbol {
- bs2 = j.b
- if withString {
- if j.s == "" && bs2 != nil {
- j.s = string(bs2)
- }
- s = j.s
- }
- break
- }
- }
+ bs2 = d.s[symbol]
} else {
switch vs & 0x3 {
case 0:
- slen = int(d.r.readn1())
+ slen = int(d.d.decRd.readn1())
case 1:
- slen = int(bigen.Uint16(d.r.readx(2)))
+ slen = int(bigen.Uint16(d.d.decRd.readx(2)))
case 2:
- slen = int(bigen.Uint32(d.r.readx(4)))
+ slen = int(bigen.Uint32(d.d.decRd.readx(4)))
case 3:
- slen = int(bigen.Uint64(d.r.readx(8)))
+ slen = int(bigen.Uint64(d.d.decRd.readx(8)))
}
// since using symbols, do not store any part of
// the parameter bs in the map, as it might be a shared buffer.
- // bs2 = decByteSlice(d.r, slen, bs)
- bs2 = decByteSlice(d.r, slen, d.d.h.MaxInitLen, nil)
- if withString {
- s = string(bs2)
- }
- d.s = append(d.s, bincDecSymbol{i: symbol, s: s, b: bs2})
+ // bs2 = decByteSlice(d.d.r(), slen, bs)
+ bs2 = decByteSlice(d.d.r(), slen, d.d.h.MaxInitLen, nil)
+ d.s[symbol] = bs2
+ // d.s = append(d.s, bincDecSymbol{i: symbol, s: s, b: bs2})
}
default:
d.d.errorf("string/bytes - %s %x-%x/%s", msgBadDesc, d.vd, d.vs, bincdesc(d.vd, d.vs))
@@ -784,31 +763,26 @@ func (d *bincDecDriver) decStringAndBytes(bs []byte, withString, zerocopy bool)
return
}
-func (d *bincDecDriver) DecodeString() (s string) {
- // DecodeBytes does not accommodate symbols, whose impl stores string version in map.
- // Use decStringAndBytes directly.
- // return string(d.DecodeBytes(d.b[:], true, true))
- _, s = d.decStringAndBytes(d.b[:], true, true)
- return
-}
-
func (d *bincDecDriver) DecodeStringAsBytes() (s []byte) {
- s, _ = d.decStringAndBytes(d.b[:], false, true)
- return
+ return d.decStringBytes(d.d.b[:], true)
}
func (d *bincDecDriver) DecodeBytes(bs []byte, zerocopy bool) (bsOut []byte) {
- if !d.bdRead {
- d.readNextBd()
- }
- if d.bd == bincVdSpecial<<4|bincSpNil {
- d.bdRead = false
- return nil
+ if d.advanceNil() {
+ return
}
// check if an "array" of uint8's (see ContainerType for how to infer if an array)
if d.vd == bincVdArray {
- bsOut, _ = fastpathTV.DecSliceUint8V(bs, true, d.d)
- return
+ if zerocopy && len(bs) == 0 {
+ bs = d.d.b[:]
+ }
+ // bsOut, _ = fastpathTV.DecSliceUint8V(bs, true, d.d)
+ slen := d.ReadArrayStart()
+ bs = usableByteSlice(bs, slen)
+ for i := 0; i < slen; i++ {
+ bs[i] = uint8(chkOvf.UintV(d.DecodeUint64(), 8))
+ }
+ return bs
}
var clen int
if d.vd == bincVdString || d.vd == bincVdByteArray {
@@ -819,47 +793,48 @@ func (d *bincDecDriver) DecodeBytes(bs []byte, zerocopy bool) (bsOut []byte) {
}
d.bdRead = false
if zerocopy {
- if d.br {
- return d.r.readx(uint(clen))
+ if d.d.bytes {
+ return d.d.decRd.readx(uint(clen))
} else if len(bs) == 0 {
- bs = d.b[:]
+ bs = d.d.b[:]
}
}
- return decByteSlice(d.r, clen, d.d.h.MaxInitLen, bs)
+ return decByteSlice(d.d.r(), clen, d.d.h.MaxInitLen, bs)
}
-func (d *bincDecDriver) DecodeExt(rv interface{}, xtag uint64, ext Ext) (realxtag uint64) {
+func (d *bincDecDriver) DecodeExt(rv interface{}, xtag uint64, ext Ext) {
if xtag > 0xff {
d.d.errorf("ext: tag must be <= 0xff; got: %v", xtag)
return
}
+ if d.advanceNil() {
+ return
+ }
realxtag1, xbs := d.decodeExtV(ext != nil, uint8(xtag))
- realxtag = uint64(realxtag1)
+ realxtag := uint64(realxtag1)
if ext == nil {
re := rv.(*RawExt)
re.Tag = realxtag
- re.Data = detachZeroCopyBytes(d.br, re.Data, xbs)
+ re.Data = detachZeroCopyBytes(d.d.bytes, re.Data, xbs)
+ } else if ext == SelfExt {
+ d.d.sideDecode(rv, xbs)
} else {
ext.ReadExt(rv, xbs)
}
- return
}
func (d *bincDecDriver) decodeExtV(verifyTag bool, tag byte) (xtag byte, xbs []byte) {
- if !d.bdRead {
- d.readNextBd()
- }
if d.vd == bincVdCustomExt {
l := d.decLen()
- xtag = d.r.readn1()
+ xtag = d.d.decRd.readn1()
if verifyTag && xtag != tag {
d.d.errorf("wrong extension tag - got %b, expecting: %v", xtag, tag)
return
}
- if d.br {
- xbs = d.r.readx(uint(l))
+ if d.d.bytes {
+ xbs = d.d.decRd.readx(uint(l))
} else {
- xbs = decByteSlice(d.r, l, d.d.h.MaxInitLen, d.d.b[:])
+ xbs = decByteSlice(d.d.r(), l, d.d.h.MaxInitLen, d.d.b[:])
}
} else if d.vd == bincVdByteArray {
xbs = d.DecodeBytes(nil, true)
@@ -877,6 +852,7 @@ func (d *bincDecDriver) DecodeNaked() {
d.readNextBd()
}
+ d.fnil = false
n := d.d.naked()
var decodeFurther bool
@@ -885,6 +861,7 @@ func (d *bincDecDriver) DecodeNaked() {
switch d.vs {
case bincSpNil:
n.v = valueTypeNil
+ d.fnil = true
case bincSpFalse:
n.v = valueTypeBool
n.b = false
@@ -927,16 +904,15 @@ func (d *bincDecDriver) DecodeNaked() {
n.f = d.decFloat()
case bincVdSymbol:
n.v = valueTypeSymbol
- n.s = d.DecodeString()
+ n.s = string(d.DecodeStringAsBytes())
case bincVdString:
n.v = valueTypeString
- n.s = d.DecodeString()
+ n.s = string(d.DecodeStringAsBytes())
case bincVdByteArray:
- n.v = valueTypeBytes
- n.l = d.DecodeBytes(nil, false)
+ decNakedReadRawBytes(d, &d.d, n, d.h.RawToString)
case bincVdTimestamp:
n.v = valueTypeTime
- tt, err := bincDecodeTime(d.r.readx(uint(d.vs)))
+ tt, err := bincDecodeTime(d.d.decRd.readx(uint(d.vs)))
if err != nil {
panic(err)
}
@@ -944,11 +920,11 @@ func (d *bincDecDriver) DecodeNaked() {
case bincVdCustomExt:
n.v = valueTypeExt
l := d.decLen()
- n.u = uint64(d.r.readn1())
- if d.br {
- n.l = d.r.readx(uint(l))
+ n.u = uint64(d.d.decRd.readn1())
+ if d.d.bytes {
+ n.l = d.d.decRd.readx(uint(l))
} else {
- n.l = decByteSlice(d.r, l, d.d.h.MaxInitLen, d.d.b[:])
+ n.l = decByteSlice(d.d.r(), l, d.d.h.MaxInitLen, d.d.b[:])
}
case bincVdArray:
n.v = valueTypeArray
@@ -986,7 +962,7 @@ func (d *bincDecDriver) DecodeNaked() {
type BincHandle struct {
BasicHandle
binaryEncodingType
- noElemSeparators
+ // noElemSeparators
// AsSymbols defines what should be encoded as symbols.
//
@@ -1008,36 +984,53 @@ type BincHandle struct {
// - n: none
// - a: all: same as m, s, ...
- // _ [1]uint64 // padding
+ _ [7]uint64 // padding (cache-aligned)
}
// Name returns the name of the handle: binc
func (h *BincHandle) Name() string { return "binc" }
-// SetBytesExt sets an extension
-func (h *BincHandle) SetBytesExt(rt reflect.Type, tag uint64, ext BytesExt) (err error) {
- return h.SetExt(rt, tag, &extWrapper{ext, interfaceExtFailer{}})
-}
-
-func (h *BincHandle) newEncDriver(e *Encoder) encDriver {
- return &bincEncDriver{e: e, h: h, w: e.w}
+func (h *BincHandle) newEncDriver() encDriver {
+ var e = &bincEncDriver{h: h}
+ e.e.e = e
+ e.e.init(h)
+ e.reset()
+ return e
}
-func (h *BincHandle) newDecDriver(d *Decoder) decDriver {
- return &bincDecDriver{d: d, h: h, r: d.r, br: d.bytes}
+func (h *BincHandle) newDecDriver() decDriver {
+ d := &bincDecDriver{h: h}
+ d.d.d = d
+ d.d.init(h)
+ d.reset()
+ return d
}
func (e *bincEncDriver) reset() {
- e.w = e.e.w
e.s = 0
- e.c = 0
e.m = nil
}
+func (e *bincEncDriver) atEndOfEncode() {
+ if e.m != nil {
+ for k := range e.m {
+ delete(e.m, k)
+ }
+ }
+}
+
func (d *bincDecDriver) reset() {
- d.r, d.br = d.d.r, d.d.bytes
d.s = nil
d.bd, d.bdRead, d.vd, d.vs = 0, false, 0, 0
+ d.fnil = false
+}
+
+func (d *bincDecDriver) atEndOfDecode() {
+ if d.s != nil {
+ for k := range d.s {
+ delete(d.s, k)
+ }
+ }
}
// var timeDigits = [...]byte{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'}
@@ -1092,7 +1085,7 @@ func (d *bincDecDriver) reset() {
// Bits 13..0 = timezone offset in minutes. It is a signed integer in Big Endian format.
//
func bincEncodeTime(t time.Time) []byte {
- //t := rv.Interface().(time.Time)
+ // t := rv2i(rv).(time.Time)
tsecs, tnsecs := t.Unix(), t.Nanosecond()
var (
bd byte
@@ -1124,7 +1117,7 @@ func bincEncodeTime(t time.Time) []byte {
bd = bd | 0x20
// Note that Go Libs do not give access to dst flag.
_, zoneOffset := t.Zone()
- //zoneName, zoneOffset := t.Zone()
+ // zoneName, zoneOffset := t.Zone()
zoneOffset /= 60
z := uint16(zoneOffset)
bigen.PutUint16(btmp[:2], z)
@@ -1153,10 +1146,10 @@ func bincDecodeTime(bs []byte) (tt time.Time, err error) {
n = ((bd >> 2) & 0x7) + 1
i2 = i + n
copy(btmp[8-n:], bs[i:i2])
- //if first bit of bs[i] is set, then fill btmp[0..8-n] with 0xff (ie sign extend it)
+ // if first bit of bs[i] is set, then fill btmp[0..8-n] with 0xff (ie sign extend it)
if bs[i]&(1<<7) != 0 {
copy(btmp[0:8-n], bsAll0xff)
- //for j,k := byte(0), 8-n; j < k; j++ { btmp[j] = 0xff }
+ // for j,k := byte(0), 8-n; j < k; j++ { btmp[j] = 0xff }
}
i = i2
tsec = int64(bigen.Uint64(btmp[:]))
@@ -1174,7 +1167,7 @@ func bincDecodeTime(bs []byte) (tt time.Time, err error) {
return
}
// In stdlib time.Parse, when a date is parsed without a zone name, it uses "" as zone name.
- // However, we need name here, so it can be shown when time is printed.
+ // However, we need name here, so it can be shown when time is printf.d.
// Zone name is in form: UTC-08:00.
// Note that Go Libs do not give access to dst flag, so we ignore dst bits
@@ -1200,5 +1193,27 @@ func bincDecodeTime(bs []byte) (tt time.Time, err error) {
return
}
+// func timeLocUTCName(tzint int16) string {
+// if tzint == 0 {
+// return "UTC"
+// }
+// var tzname = []byte("UTC+00:00")
+// //tzname := fmt.Sprintf("UTC%s%02d:%02d", tzsign, tz/60, tz%60) //perf issue using Sprintf.. inline below.
+// //tzhr, tzmin := tz/60, tz%60 //faster if u convert to int first
+// var tzhr, tzmin int16
+// if tzint < 0 {
+// tzname[3] = '-'
+// tzhr, tzmin = -tzint/60, (-tzint)%60
+// } else {
+// tzhr, tzmin = tzint/60, tzint%60
+// }
+// tzname[4] = timeDigits[tzhr/10]
+// tzname[5] = timeDigits[tzhr%10]
+// tzname[7] = timeDigits[tzmin/10]
+// tzname[8] = timeDigits[tzmin%10]
+// return string(tzname)
+// //return time.FixedZone(string(tzname), int(tzint)*60)
+// }
+
var _ decDriver = (*bincDecDriver)(nil)
var _ encDriver = (*bincEncDriver)(nil)
diff --git a/vendor/github.com/ugorji/go/codec/build.sh b/vendor/github.com/ugorji/go/codec/build.sh
index bcab12a..a71227f 100644
--- a/vendor/github.com/ugorji/go/codec/build.sh
+++ b/vendor/github.com/ugorji/go/codec/build.sh
@@ -4,6 +4,7 @@
# This helps ensure that nothing gets broken.
_tests() {
+ local vet="" # TODO: make it off
local gover=$( go version | cut -f 3 -d ' ' )
# note that codecgen requires fastpath, so you cannot do "codecgen notfastpath"
local a=( "" "safe" "notfastpath" "notfastpath safe" "codecgen" "codecgen safe" )
@@ -12,10 +13,9 @@ _tests() {
echo ">>>> TAGS: $i"
local i2=${i:-default}
case $gover in
- go1.[0-6]*) go vet -printfuncs "errorf" "$@" &&
- go test ${zargs[*]} -vet off -tags "$i" "$@" ;;
+ go1.[0-6]*) go test ${zargs[*]} -tags "$i" "$@" ;;
*) go vet -printfuncs "errorf" "$@" &&
- go test ${zargs[*]} -vet off -tags "alltests $i" -run "Suite" -coverprofile "${i2// /-}.cov.out" "$@" ;;
+ go test ${zargs[*]} -vet "$vet" -tags "alltests $i" -run "Suite" -coverprofile "${i2// /-}.cov.out" "$@" ;;
esac
if [[ "$?" != 0 ]]; then return 1; fi
done
@@ -116,57 +116,67 @@ run("fast-path.go.tmpl", "fast-path.generated.go")
run("gen-helper.go.tmpl", "gen-helper.generated.go")
run("mammoth-test.go.tmpl", "mammoth_generated_test.go")
run("mammoth2-test.go.tmpl", "mammoth2_generated_test.go")
+// run("sort-slice.go.tmpl", "sort-slice.generated.go")
}
EOF
+ sed -e 's+// __DO_NOT_REMOVE__NEEDED_FOR_REPLACING__IMPORT_PATH__FOR_CODEC_BENCH__+import . "github.com/ugorji/go/codec"+' \
+ shared_test.go > bench/shared_test.go
+
# explicitly return 0 if this passes, else return 1
- go run -tags "notfastpath safe codecgen.exec" gen-from-tmpl.generated.go &&
- rm -f gen-from-tmpl.*generated.go &&
- return 0
- return 1
+ go run -tags "prebuild" prebuild.go || return 1
+ go run -tags "notfastpath safe codecgen.exec" gen-from-tmpl.generated.go || return 1
+ rm -f gen-from-tmpl.*generated.go
+ return 0
}
_codegenerators() {
- if ! [[ $zforce ||
- $(_ng "values_codecgen${zsfx}") ]]; then return 0; fi
-
- # Note: ensure you run the codecgen for this codebase (using $zgobase/bin/codecgen)
+ local c5="_generated_test.go"
+ local c7="$PWD/codecgen"
+ local c8="$c7/__codecgen"
local c9="codecgen-scratch.go"
+
+ if ! [[ $zforce || $(_ng "values_codecgen${c5}") ]]; then return 0; fi
+
+ # Note: ensure you run the codecgen for this codebase/directory i.e. ./codecgen/codecgen
true &&
echo "codecgen ... " &&
- $zgobase/bin/codecgen -rt codecgen -t 'codecgen generated' -o values_codecgen${zsfx} -d 19780 $zfin $zfin2 &&
+ if [[ $zforce || ! -f "$c8" || "$c7/gen.go" -nt "$c8" ]]; then
+ echo "rebuilding codecgen ... " && ( cd codecgen && go build -o $c8 ${zargs[*]} . )
+ fi &&
+ $c8 -rt codecgen -t 'codecgen generated' -o values_codecgen${c5} -d 19780 $zfin $zfin2 &&
cp mammoth2_generated_test.go $c9 &&
- $zgobase/bin/codecgen -t '!notfastpath' -o mammoth2_codecgen${zsfx} -d 19781 mammoth2_generated_test.go &&
+ $c8 -t 'codecgen,!notfastpath generated,!notfastpath' -o mammoth2_codecgen${c5} -d 19781 mammoth2_generated_test.go &&
rm -f $c9 &&
echo "generators done!"
}
_prebuild() {
- echo "prebuild: zforce: $zforce , zexternal: $zexternal"
- zmydir=`pwd`
- zfin="test_values.generated.go"
- zfin2="test_values_flex.generated.go"
- zsfx="_generated_test.go"
- # zpkg="ugorji.net/codec"
- zpkg=${zmydir##*/src/}
- zgobase=${zmydir%%/src/*}
+ echo "prebuild: zforce: $zforce"
+ local d="$PWD"
+ local zfin="test_values.generated.go"
+ local zfin2="test_values_flex.generated.go"
+ local zpkg="github.com/ugorji/go/codec"
+ # zpkg=${d##*/src/}
+ # zgobase=${d%%/src/*}
# rm -f *_generated_test.go
rm -f codecgen-*.go &&
_build &&
- cp $zmydir/values_test.go $zmydir/$zfin &&
- cp $zmydir/values_flex_test.go $zmydir/$zfin2 &&
+ cp $d/values_test.go $d/$zfin &&
+ cp $d/values_flex_test.go $d/$zfin2 &&
_codegenerators &&
if [[ "$(type -t _codegenerators_external )" = "function" ]]; then _codegenerators_external ; fi &&
if [[ $zforce ]]; then go install ${zargs[*]} .; fi &&
echo "prebuild done successfully"
- rm -f $zmydir/$zfin $zmydir/$zfin2
+ rm -f $d/$zfin $d/$zfin2
+ # unset zfin zfin2 zpkg
}
_make() {
+ local makeforce=${zforce}
zforce=1
- zexternal=1
- ( cd codecgen && go install ${zargs[*]} . ) && _prebuild && go install ${zargs[*]} .
- unset zforce zexternal
+ (cd codecgen && go install ${zargs[*]} .) && _prebuild && go install ${zargs[*]} .
+ zforce=${makeforce}
}
_clean() {
@@ -175,6 +185,43 @@ _clean() {
test_values.generated.go test_values_flex.generated.go
}
+_release() {
+ local reply
+ read -p "Pre-release validation takes a few minutes and MUST be run from within GOPATH/src. Confirm y/n? " -n 1 -r reply
+ echo
+ if [[ ! $reply =~ ^[Yy]$ ]]; then return 1; fi
+
+ # expects GOROOT, GOROOT_BOOTSTRAP to have been set.
+ if [[ -z "${GOROOT// }" || -z "${GOROOT_BOOTSTRAP// }" ]]; then return 1; fi
+ # (cd $GOROOT && git checkout -f master && git pull && git reset --hard)
+ (cd $GOROOT && git pull)
+ local f=`pwd`/make.release.out
+ cat > $f <>$f
+ if [[ "$i" != "master" ]]; then i="release-branch.go$i"; fi
+ (false ||
+ (echo "===== BUILDING GO SDK for branch: $i ... =====" &&
+ cd $GOROOT &&
+ git checkout -f $i && git reset --hard && git clean -f . &&
+ cd src && ./make.bash >>$f 2>&1 && sleep 1 ) ) &&
+ echo "===== GO SDK BUILD DONE =====" &&
+ _prebuild &&
+ echo "===== PREBUILD DONE with exit: $? =====" &&
+ _tests "$@"
+ if [[ "$?" != 0 ]]; then return 1; fi
+ done
+ zforce=${makeforce}
+ echo "++++++++ RELEASE TEST SUITES ALL PASSED ++++++++"
+}
+
_usage() {
cat <= cborBaseUint && bd < cborBaseNegInt:
- return "(u)int"
- case bd >= cborBaseNegInt && bd < cborBaseBytes:
- return "int"
- case bd >= cborBaseBytes && bd < cborBaseString:
- return "bytes"
- case bd >= cborBaseString && bd < cborBaseArray:
- return "string"
- case bd >= cborBaseArray && bd < cborBaseMap:
- return "array"
- case bd >= cborBaseMap && bd < cborBaseTag:
- return "map"
- case bd >= cborBaseTag && bd < cborBaseSimple:
- return "ext"
+ switch bd >> 5 {
+ case cborMajorUint:
+ return "(u)int"
+ case cborMajorNegInt:
+ return "int"
+ case cborMajorBytes:
+ return "bytes"
+ case cborMajorString:
+ return "string"
+ case cborMajorArray:
+ return "array"
+ case cborMajorMap:
+ return "map"
+ case cborMajorTag:
+ return "tag"
+ case cborMajorSimpleOrFloat: // default
+ switch bd {
+ case cborBdNil:
+ return "nil"
+ case cborBdFalse:
+ return "false"
+ case cborBdTrue:
+ return "true"
+ case cborBdFloat16, cborBdFloat32, cborBdFloat64:
+ return "float"
+ case cborBdIndefiniteBytes:
+ return "bytes*"
+ case cborBdIndefiniteString:
+ return "string*"
+ case cborBdIndefiniteArray:
+ return "array*"
+ case cborBdIndefiniteMap:
+ return "map*"
default:
- return "unknown"
+ return "unknown(simple)"
}
}
+ return "unknown"
}
// -------------------
@@ -105,49 +115,52 @@ func cbordesc(bd byte) string {
type cborEncDriver struct {
noBuiltInTypes
encDriverNoopContainerWriter
- e *Encoder
- w *encWriterSwitch
h *CborHandle
x [8]byte
- // _ [3]uint64 // padding
+ _ [6]uint64 // padding
+ e Encoder
+}
+
+func (e *cborEncDriver) encoder() *Encoder {
+ return &e.e
}
func (e *cborEncDriver) EncodeNil() {
- e.w.writen1(cborBdNil)
+ e.e.encWr.writen1(cborBdNil)
}
func (e *cborEncDriver) EncodeBool(b bool) {
if b {
- e.w.writen1(cborBdTrue)
+ e.e.encWr.writen1(cborBdTrue)
} else {
- e.w.writen1(cborBdFalse)
+ e.e.encWr.writen1(cborBdFalse)
}
}
func (e *cborEncDriver) EncodeFloat32(f float32) {
- e.w.writen1(cborBdFloat32)
- bigenHelper{e.x[:4], e.w}.writeUint32(math.Float32bits(f))
+ e.e.encWr.writen1(cborBdFloat32)
+ bigenHelper{e.x[:4], e.e.w()}.writeUint32(math.Float32bits(f))
}
func (e *cborEncDriver) EncodeFloat64(f float64) {
- e.w.writen1(cborBdFloat64)
- bigenHelper{e.x[:8], e.w}.writeUint64(math.Float64bits(f))
+ e.e.encWr.writen1(cborBdFloat64)
+ bigenHelper{e.x[:8], e.e.w()}.writeUint64(math.Float64bits(f))
}
func (e *cborEncDriver) encUint(v uint64, bd byte) {
if v <= 0x17 {
- e.w.writen1(byte(v) + bd)
+ e.e.encWr.writen1(byte(v) + bd)
} else if v <= math.MaxUint8 {
- e.w.writen2(bd+0x18, uint8(v))
+ e.e.encWr.writen2(bd+0x18, uint8(v))
} else if v <= math.MaxUint16 {
- e.w.writen1(bd + 0x19)
- bigenHelper{e.x[:2], e.w}.writeUint16(uint16(v))
+ e.e.encWr.writen1(bd + 0x19)
+ bigenHelper{e.x[:2], e.e.w()}.writeUint16(uint16(v))
} else if v <= math.MaxUint32 {
- e.w.writen1(bd + 0x1a)
- bigenHelper{e.x[:4], e.w}.writeUint32(uint32(v))
+ e.e.encWr.writen1(bd + 0x1a)
+ bigenHelper{e.x[:4], e.e.w()}.writeUint32(uint32(v))
} else { // if v <= math.MaxUint64 {
- e.w.writen1(bd + 0x1b)
- bigenHelper{e.x[:8], e.w}.writeUint64(v)
+ e.e.encWr.writen1(bd + 0x1b)
+ bigenHelper{e.x[:8], e.e.w()}.writeUint64(v)
}
}
@@ -172,7 +185,7 @@ func (e *cborEncDriver) EncodeTime(t time.Time) {
e.EncodeNil()
} else if e.h.TimeRFC3339 {
e.encUint(0, cborBaseTag)
- e.EncodeStringEnc(cUTF8, t.Format(time.RFC3339Nano))
+ e.encStringBytesS(cborBaseString, t.Format(time.RFC3339Nano))
} else {
e.encUint(1, cborBaseTag)
t = t.UTC().Round(time.Microsecond)
@@ -185,23 +198,23 @@ func (e *cborEncDriver) EncodeTime(t time.Time) {
}
}
-func (e *cborEncDriver) EncodeExt(rv interface{}, xtag uint64, ext Ext, en *Encoder) {
+func (e *cborEncDriver) EncodeExt(rv interface{}, xtag uint64, ext Ext) {
e.encUint(uint64(xtag), cborBaseTag)
- if v := ext.ConvertExt(rv); v == nil {
+ if ext == SelfExt {
+ rv2 := baseRV(rv)
+ e.e.encodeValue(rv2, e.h.fnNoExt(rv2.Type()))
+ } else if v := ext.ConvertExt(rv); v == nil {
e.EncodeNil()
} else {
- en.encode(v)
+ e.e.encode(v)
}
}
-func (e *cborEncDriver) EncodeRawExt(re *RawExt, en *Encoder) {
+func (e *cborEncDriver) EncodeRawExt(re *RawExt) {
e.encUint(uint64(re.Tag), cborBaseTag)
// only encodes re.Value (never re.Data)
- // if false && re.Data != nil {
- // en.encode(re.Data)
- // } else if re.Value != nil {
if re.Value != nil {
- en.encode(re.Value)
+ e.e.encode(re.Value)
} else {
e.EncodeNil()
}
@@ -209,7 +222,7 @@ func (e *cborEncDriver) EncodeRawExt(re *RawExt, en *Encoder) {
func (e *cborEncDriver) WriteArrayStart(length int) {
if e.h.IndefiniteLength {
- e.w.writen1(cborBdIndefiniteArray)
+ e.e.encWr.writen1(cborBdIndefiniteArray)
} else {
e.encLen(cborBaseArray, length)
}
@@ -217,7 +230,7 @@ func (e *cborEncDriver) WriteArrayStart(length int) {
func (e *cborEncDriver) WriteMapStart(length int) {
if e.h.IndefiniteLength {
- e.w.writen1(cborBdIndefiniteMap)
+ e.e.encWr.writen1(cborBdIndefiniteMap)
} else {
e.encLen(cborBaseMap, length)
}
@@ -225,32 +238,22 @@ func (e *cborEncDriver) WriteMapStart(length int) {
func (e *cborEncDriver) WriteMapEnd() {
if e.h.IndefiniteLength {
- e.w.writen1(cborBdBreak)
+ e.e.encWr.writen1(cborBdBreak)
}
}
func (e *cborEncDriver) WriteArrayEnd() {
if e.h.IndefiniteLength {
- e.w.writen1(cborBdBreak)
+ e.e.encWr.writen1(cborBdBreak)
}
}
-func (e *cborEncDriver) EncodeString(c charEncoding, v string) {
- e.encStringBytesS(cborBaseString, v)
-}
-
-func (e *cborEncDriver) EncodeStringEnc(c charEncoding, v string) {
- e.encStringBytesS(cborBaseString, v)
-}
-
-func (e *cborEncDriver) EncodeStringBytes(c charEncoding, v []byte) {
- if v == nil {
- e.EncodeNil()
- } else if c == cRAW {
- e.encStringBytesS(cborBaseBytes, stringView(v))
- } else {
- e.encStringBytesS(cborBaseString, stringView(v))
+func (e *cborEncDriver) EncodeString(v string) {
+ if e.h.StringToRaw {
+ e.EncodeStringBytesRaw(bytesView(v))
+ return
}
+ e.encStringBytesS(cborBaseString, v)
}
func (e *cborEncDriver) EncodeStringBytesRaw(v []byte) {
@@ -264,9 +267,9 @@ func (e *cborEncDriver) EncodeStringBytesRaw(v []byte) {
func (e *cborEncDriver) encStringBytesS(bb byte, v string) {
if e.h.IndefiniteLength {
if bb == cborBaseBytes {
- e.w.writen1(cborBdIndefiniteBytes)
+ e.e.encWr.writen1(cborBdIndefiniteBytes)
} else {
- e.w.writen1(cborBdIndefiniteString)
+ e.e.encWr.writen1(cborBdIndefiniteString)
}
var vlen uint = uint(len(v))
blen := vlen / 4
@@ -278,91 +281,120 @@ func (e *cborEncDriver) encStringBytesS(bb byte, v string) {
for i := uint(0); i < vlen; {
var v2 string
i2 := i + blen
- if i2 < vlen {
+ if i2 >= i && i2 < vlen {
v2 = v[i:i2]
} else {
v2 = v[i:]
}
e.encLen(bb, len(v2))
- e.w.writestr(v2)
+ e.e.encWr.writestr(v2)
i = i2
}
- e.w.writen1(cborBdBreak)
+ e.e.encWr.writen1(cborBdBreak)
} else {
e.encLen(bb, len(v))
- e.w.writestr(v)
+ e.e.encWr.writestr(v)
}
}
// ----------------------
type cborDecDriver struct {
- d *Decoder
+ decDriverNoopContainerReader
h *CborHandle
- r *decReaderSwitch
- br bool // bytes reader
bdRead bool
bd byte
+ st bool // skip tags
+ fnil bool // found nil
noBuiltInTypes
- // decNoSeparator
- decDriverNoopContainerReader
- // _ [3]uint64 // padding
+ _ [6]uint64 // padding cache-aligned
+ d Decoder
+}
+
+func (d *cborDecDriver) decoder() *Decoder {
+ return &d.d
}
func (d *cborDecDriver) readNextBd() {
- d.bd = d.r.readn1()
+ d.bd = d.d.decRd.readn1()
d.bdRead = true
}
+func (d *cborDecDriver) advanceNil() (null bool) {
+ d.fnil = false
+ if !d.bdRead {
+ d.readNextBd()
+ }
+ if d.bd == cborBdNil || d.bd == cborBdUndefined {
+ d.bdRead = false
+ d.fnil = true
+ null = true
+ }
+ return
+}
+
+// skipTags is called to skip any tags in the stream.
+//
+// Since any value can be tagged, then we should call skipTags
+// before any value is decoded.
+//
+// By definition, skipTags should not be called before
+// checking for break, or nil or undefined.
+func (d *cborDecDriver) skipTags() {
+ for d.bd>>5 == cborMajorTag {
+ d.decUint()
+ d.bd = d.d.decRd.readn1()
+ }
+}
+
func (d *cborDecDriver) uncacheRead() {
if d.bdRead {
- d.r.unreadn1()
+ d.d.decRd.unreadn1()
d.bdRead = false
}
}
func (d *cborDecDriver) ContainerType() (vt valueType) {
+ d.fnil = false
if !d.bdRead {
d.readNextBd()
}
+ if d.st {
+ d.skipTags()
+ }
if d.bd == cborBdNil {
+ d.bdRead = false // always consume nil after seeing it in container type
+ d.fnil = true
return valueTypeNil
- } else if d.bd == cborBdIndefiniteBytes || (d.bd >= cborBaseBytes && d.bd < cborBaseString) {
+ } else if d.bd == cborBdIndefiniteBytes || (d.bd>>5 == cborMajorBytes) {
return valueTypeBytes
- } else if d.bd == cborBdIndefiniteString || (d.bd >= cborBaseString && d.bd < cborBaseArray) {
+ } else if d.bd == cborBdIndefiniteString || (d.bd>>5 == cborMajorString) {
return valueTypeString
- } else if d.bd == cborBdIndefiniteArray || (d.bd >= cborBaseArray && d.bd < cborBaseMap) {
+ } else if d.bd == cborBdIndefiniteArray || (d.bd>>5 == cborMajorArray) {
return valueTypeArray
- } else if d.bd == cborBdIndefiniteMap || (d.bd >= cborBaseMap && d.bd < cborBaseTag) {
+ } else if d.bd == cborBdIndefiniteMap || (d.bd>>5 == cborMajorMap) {
return valueTypeMap
}
- // else {
- // d.d.errorf("isContainerType: unsupported parameter: %v", vt)
- // }
return valueTypeUnset
}
-func (d *cborDecDriver) TryDecodeAsNil() bool {
- if !d.bdRead {
- d.readNextBd()
- }
- // treat Nil and Undefined as nil values
- if d.bd == cborBdNil || d.bd == cborBdUndefined {
- d.bdRead = false
- return true
- }
- return false
+func (d *cborDecDriver) Nil() bool {
+ return d.fnil
+}
+
+func (d *cborDecDriver) TryNil() bool {
+ return d.advanceNil()
}
-func (d *cborDecDriver) CheckBreak() bool {
+func (d *cborDecDriver) CheckBreak() (v bool) {
if !d.bdRead {
d.readNextBd()
}
if d.bd == cborBdBreak {
d.bdRead = false
- return true
+ v = true
}
- return false
+ return
}
func (d *cborDecDriver) decUint() (ui uint64) {
@@ -371,13 +403,13 @@ func (d *cborDecDriver) decUint() (ui uint64) {
ui = uint64(v)
} else {
if v == 0x18 {
- ui = uint64(d.r.readn1())
+ ui = uint64(d.d.decRd.readn1())
} else if v == 0x19 {
- ui = uint64(bigen.Uint16(d.r.readx(2)))
+ ui = uint64(bigen.Uint16(d.d.decRd.readx(2)))
} else if v == 0x1a {
- ui = uint64(bigen.Uint32(d.r.readx(4)))
+ ui = uint64(bigen.Uint32(d.d.decRd.readx(4)))
} else if v == 0x1b {
- ui = uint64(bigen.Uint64(d.r.readx(8)))
+ ui = uint64(bigen.Uint64(d.d.decRd.readx(8)))
} else {
d.d.errorf("invalid descriptor decoding uint: %x/%s", d.bd, cbordesc(d.bd))
return
@@ -387,72 +419,121 @@ func (d *cborDecDriver) decUint() (ui uint64) {
}
func (d *cborDecDriver) decCheckInteger() (neg bool) {
- if !d.bdRead {
- d.readNextBd()
+ if d.st {
+ d.skipTags()
}
major := d.bd >> 5
if major == cborMajorUint {
} else if major == cborMajorNegInt {
neg = true
} else {
- d.d.errorf("not an integer - invalid major %v from descriptor %x/%s",
- major, d.bd, cbordesc(d.bd))
- return
+ d.d.errorf("invalid integer; got major %v from descriptor %x/%s, expected %v or %v",
+ major, d.bd, cbordesc(d.bd), cborMajorUint, cborMajorNegInt)
}
return
}
-func (d *cborDecDriver) DecodeInt64() (i int64) {
- neg := d.decCheckInteger()
- ui := d.decUint()
+func cborDecInt64(ui uint64, neg bool) (i int64) {
// check if this number can be converted to an int without overflow
if neg {
i = -(chkOvf.SignedIntV(ui + 1))
} else {
i = chkOvf.SignedIntV(ui)
}
- d.bdRead = false
return
}
+func (d *cborDecDriver) decLen() int {
+ return int(d.decUint())
+}
+
+func (d *cborDecDriver) decAppendIndefiniteBytes(bs []byte) []byte {
+ d.bdRead = false
+ for !d.CheckBreak() {
+ if major := d.bd >> 5; major != cborMajorBytes && major != cborMajorString {
+ d.d.errorf("invalid indefinite string/bytes; got major %v, expected %x/%s",
+ major, d.bd, cbordesc(d.bd))
+ }
+ n := uint(d.decLen())
+ oldLen := uint(len(bs))
+ newLen := oldLen + n
+ if newLen > uint(cap(bs)) {
+ bs2 := make([]byte, newLen, 2*uint(cap(bs))+n)
+ copy(bs2, bs)
+ bs = bs2
+ } else {
+ bs = bs[:newLen]
+ }
+ d.d.decRd.readb(bs[oldLen:newLen])
+ // bs = append(bs, d.d.decRd.readn()...)
+ d.bdRead = false
+ }
+ d.bdRead = false
+ return bs
+}
+
+func (d *cborDecDriver) DecodeInt64() (i int64) {
+ if d.advanceNil() {
+ return
+ }
+ neg := d.decCheckInteger()
+ ui := d.decUint()
+ d.bdRead = false
+ return cborDecInt64(ui, neg)
+}
+
func (d *cborDecDriver) DecodeUint64() (ui uint64) {
- if d.decCheckInteger() {
- d.d.errorf("assigning negative signed value to unsigned type")
+ if d.advanceNil() {
return
}
+ if d.decCheckInteger() {
+ d.d.errorf("cannot assign negative signed value to unsigned type")
+ }
ui = d.decUint()
d.bdRead = false
return
}
func (d *cborDecDriver) DecodeFloat64() (f float64) {
- if !d.bdRead {
- d.readNextBd()
- }
- if bd := d.bd; bd == cborBdFloat16 {
- f = float64(math.Float32frombits(halfFloatToFloatBits(bigen.Uint16(d.r.readx(2)))))
- } else if bd == cborBdFloat32 {
- f = float64(math.Float32frombits(bigen.Uint32(d.r.readx(4))))
- } else if bd == cborBdFloat64 {
- f = math.Float64frombits(bigen.Uint64(d.r.readx(8)))
- } else if bd >= cborBaseUint && bd < cborBaseBytes {
- f = float64(d.DecodeInt64())
- } else {
- d.d.errorf("float only valid from float16/32/64 - invalid descriptor %x/%s", bd, cbordesc(bd))
+ if d.advanceNil() {
return
}
+ if d.st {
+ d.skipTags()
+ }
+ switch d.bd {
+ case cborBdFloat16:
+ f = float64(math.Float32frombits(halfFloatToFloatBits(bigen.Uint16(d.d.decRd.readx(2)))))
+ case cborBdFloat32:
+ f = float64(math.Float32frombits(bigen.Uint32(d.d.decRd.readx(4))))
+ case cborBdFloat64:
+ f = math.Float64frombits(bigen.Uint64(d.d.decRd.readx(8)))
+ default:
+ major := d.bd >> 5
+ if major == cborMajorUint {
+ f = float64(cborDecInt64(d.decUint(), false))
+ } else if major == cborMajorNegInt {
+ f = float64(cborDecInt64(d.decUint(), true))
+ } else {
+ d.d.errorf("invalid float descriptor; got %d/%s, expected float16/32/64 or (-)int",
+ d.bd, cbordesc(d.bd))
+ }
+ }
d.bdRead = false
return
}
// bool can be decoded from bool only (single byte).
func (d *cborDecDriver) DecodeBool() (b bool) {
- if !d.bdRead {
- d.readNextBd()
+ if d.advanceNil() {
+ return
+ }
+ if d.st {
+ d.skipTags()
}
- if bd := d.bd; bd == cborBdTrue {
+ if d.bd == cborBdTrue {
b = true
- } else if bd == cborBdFalse {
+ } else if d.bd == cborBdFalse {
} else {
d.d.errorf("not bool - %s %x/%s", msgBadDesc, d.bd, cbordesc(d.bd))
return
@@ -462,67 +543,47 @@ func (d *cborDecDriver) DecodeBool() (b bool) {
}
func (d *cborDecDriver) ReadMapStart() (length int) {
- if !d.bdRead {
- d.readNextBd()
+ if d.advanceNil() {
+ return decContainerLenNil
+ }
+ if d.st {
+ d.skipTags()
}
d.bdRead = false
if d.bd == cborBdIndefiniteMap {
- return -1
+ return decContainerLenUnknown
+ }
+ if d.bd>>5 != cborMajorMap {
+ d.d.errorf("error reading map; got major type: %x, expected %x/%s",
+ d.bd>>5, cborMajorMap, cbordesc(d.bd))
}
return d.decLen()
}
func (d *cborDecDriver) ReadArrayStart() (length int) {
- if !d.bdRead {
- d.readNextBd()
+ if d.advanceNil() {
+ return decContainerLenNil
+ }
+ if d.st {
+ d.skipTags()
}
d.bdRead = false
if d.bd == cborBdIndefiniteArray {
- return -1
+ return decContainerLenUnknown
}
- return d.decLen()
-}
-
-func (d *cborDecDriver) decLen() int {
- return int(d.decUint())
-}
-
-func (d *cborDecDriver) decAppendIndefiniteBytes(bs []byte) []byte {
- d.bdRead = false
- for {
- if d.CheckBreak() {
- break
- }
- if major := d.bd >> 5; major != cborMajorBytes && major != cborMajorText {
- d.d.errorf("expect bytes/string major type in indefinite string/bytes;"+
- " got major %v from descriptor %x/%x", major, d.bd, cbordesc(d.bd))
- return nil
- }
- n := d.decLen()
- oldLen := len(bs)
- newLen := oldLen + n
- if newLen > cap(bs) {
- bs2 := make([]byte, newLen, 2*cap(bs)+n)
- copy(bs2, bs)
- bs = bs2
- } else {
- bs = bs[:newLen]
- }
- d.r.readb(bs[oldLen:newLen])
- // bs = append(bs, d.r.readn()...)
- d.bdRead = false
+ if d.bd>>5 != cborMajorArray {
+ d.d.errorf("invalid array; got major type: %x, expect: %x/%s",
+ d.bd>>5, cborMajorArray, cbordesc(d.bd))
}
- d.bdRead = false
- return bs
+ return d.decLen()
}
func (d *cborDecDriver) DecodeBytes(bs []byte, zerocopy bool) (bsOut []byte) {
- if !d.bdRead {
- d.readNextBd()
+ if d.advanceNil() {
+ return
}
- if d.bd == cborBdNil || d.bd == cborBdUndefined {
- d.bdRead = false
- return nil
+ if d.st {
+ d.skipTags()
}
if d.bd == cborBdIndefiniteBytes || d.bd == cborBdIndefiniteString {
d.bdRead = false
@@ -534,25 +595,43 @@ func (d *cborDecDriver) DecodeBytes(bs []byte, zerocopy bool) (bsOut []byte) {
}
return d.decAppendIndefiniteBytes(bs[:0])
}
- // check if an "array" of uint8's (see ContainerType for how to infer if an array)
- if d.bd == cborBdIndefiniteArray || (d.bd >= cborBaseArray && d.bd < cborBaseMap) {
- bsOut, _ = fastpathTV.DecSliceUint8V(bs, true, d.d)
- return
+ if d.bd == cborBdIndefiniteArray {
+ d.bdRead = false
+ if zerocopy && len(bs) == 0 {
+ bs = d.d.b[:]
+ }
+ if bs == nil {
+ bs = []byte{}
+ } else {
+ bs = bs[:0]
+ }
+ for !d.CheckBreak() {
+ bs = append(bs, uint8(chkOvf.UintV(d.DecodeUint64(), 8)))
+ }
+ return bs
+ }
+ if d.bd>>5 == cborMajorArray {
+ d.bdRead = false
+ if zerocopy && len(bs) == 0 {
+ bs = d.d.b[:]
+ }
+ slen := d.decLen()
+ bs = usableByteSlice(bs, slen)
+ for i := 0; i < len(bs); i++ {
+ bs[i] = uint8(chkOvf.UintV(d.DecodeUint64(), 8))
+ }
+ return bs
}
clen := d.decLen()
d.bdRead = false
if zerocopy {
- if d.br {
- return d.r.readx(uint(clen))
+ if d.d.bytes {
+ return d.d.decRd.readx(uint(clen))
} else if len(bs) == 0 {
bs = d.d.b[:]
}
}
- return decByteSlice(d.r, clen, d.h.MaxInitLen, bs)
-}
-
-func (d *cborDecDriver) DecodeString() (s string) {
- return string(d.DecodeBytes(d.d.b[:], true))
+ return decByteSlice(d.d.r(), clen, d.h.MaxInitLen, bs)
}
func (d *cborDecDriver) DecodeStringAsBytes() (s []byte) {
@@ -560,22 +639,18 @@ func (d *cborDecDriver) DecodeStringAsBytes() (s []byte) {
}
func (d *cborDecDriver) DecodeTime() (t time.Time) {
- if !d.bdRead {
- d.readNextBd()
- }
- if d.bd == cborBdNil || d.bd == cborBdUndefined {
- d.bdRead = false
+ if d.advanceNil() {
return
}
+ if d.bd>>5 != cborMajorTag {
+ d.d.errorf("error reading tag; expected major type: %x, got: %x", cborMajorTag, d.bd>>5)
+ }
xtag := d.decUint()
d.bdRead = false
return d.decodeTime(xtag)
}
func (d *cborDecDriver) decodeTime(xtag uint64) (t time.Time) {
- if !d.bdRead {
- d.readNextBd()
- }
switch xtag {
case 0:
var err error
@@ -583,21 +658,8 @@ func (d *cborDecDriver) decodeTime(xtag uint64) (t time.Time) {
d.d.errorv(err)
}
case 1:
- // decode an int64 or a float, and infer time.Time from there.
- // for floats, round to microseconds, as that is what is guaranteed to fit well.
- switch {
- case d.bd == cborBdFloat16, d.bd == cborBdFloat32:
- f1, f2 := math.Modf(d.DecodeFloat64())
- t = time.Unix(int64(f1), int64(f2*1e9))
- case d.bd == cborBdFloat64:
- f1, f2 := math.Modf(d.DecodeFloat64())
- t = time.Unix(int64(f1), int64(f2*1e9))
- case d.bd >= cborBaseUint && d.bd < cborBaseNegInt,
- d.bd >= cborBaseNegInt && d.bd < cborBaseBytes:
- t = time.Unix(d.DecodeInt64(), 0)
- default:
- d.d.errorf("time.Time can only be decoded from a number (or RFC3339 string)")
- }
+ f1, f2 := math.Modf(d.DecodeFloat64())
+ t = time.Unix(int64(f1), int64(f2*1e9))
default:
d.d.errorf("invalid tag for time.Time - expecting 0 or 1, got 0x%x", xtag)
}
@@ -605,13 +667,15 @@ func (d *cborDecDriver) decodeTime(xtag uint64) (t time.Time) {
return
}
-func (d *cborDecDriver) DecodeExt(rv interface{}, xtag uint64, ext Ext) (realxtag uint64) {
- if !d.bdRead {
- d.readNextBd()
+func (d *cborDecDriver) DecodeExt(rv interface{}, xtag uint64, ext Ext) {
+ if d.advanceNil() {
+ return
+ }
+ if d.bd>>5 != cborMajorTag {
+ d.d.errorf("error reading tag; expected major type: %x, got: %x", cborMajorTag, d.bd>>5)
}
- u := d.decUint()
+ realxtag := d.decUint()
d.bdRead = false
- realxtag = u
if ext == nil {
re := rv.(*RawExt)
re.Tag = realxtag
@@ -619,13 +683,13 @@ func (d *cborDecDriver) DecodeExt(rv interface{}, xtag uint64, ext Ext) (realxta
} else if xtag != realxtag {
d.d.errorf("Wrong extension tag. Got %b. Expecting: %v", realxtag, xtag)
return
+ } else if ext == SelfExt {
+ rv2 := baseRV(rv)
+ d.d.decodeValue(rv2, d.h.fnNoExt(rv2.Type()))
} else {
- var v interface{}
- d.d.decode(&v)
- ext.UpdateExt(rv, v)
+ d.d.interfaceExtConvertAndDecode(rv, ext)
}
d.bdRead = false
- return
}
func (d *cborDecDriver) DecodeNaked() {
@@ -633,76 +697,78 @@ func (d *cborDecDriver) DecodeNaked() {
d.readNextBd()
}
+ d.fnil = false
n := d.d.naked()
var decodeFurther bool
- switch d.bd {
- case cborBdNil:
- n.v = valueTypeNil
- case cborBdFalse:
- n.v = valueTypeBool
- n.b = false
- case cborBdTrue:
- n.v = valueTypeBool
- n.b = true
- case cborBdFloat16, cborBdFloat32, cborBdFloat64:
- n.v = valueTypeFloat
- n.f = d.DecodeFloat64()
- case cborBdIndefiniteBytes:
- n.v = valueTypeBytes
- n.l = d.DecodeBytes(nil, false)
- case cborBdIndefiniteString:
+ switch d.bd >> 5 {
+ case cborMajorUint:
+ if d.h.SignedInteger {
+ n.v = valueTypeInt
+ n.i = d.DecodeInt64()
+ } else {
+ n.v = valueTypeUint
+ n.u = d.DecodeUint64()
+ }
+ case cborMajorNegInt:
+ n.v = valueTypeInt
+ n.i = d.DecodeInt64()
+ case cborMajorBytes:
+ decNakedReadRawBytes(d, &d.d, n, d.h.RawToString)
+ case cborMajorString:
n.v = valueTypeString
- n.s = d.DecodeString()
- case cborBdIndefiniteArray:
+ n.s = string(d.DecodeStringAsBytes())
+ case cborMajorArray:
n.v = valueTypeArray
decodeFurther = true
- case cborBdIndefiniteMap:
+ case cborMajorMap:
n.v = valueTypeMap
decodeFurther = true
- default:
- switch {
- case d.bd >= cborBaseUint && d.bd < cborBaseNegInt:
- if d.h.SignedInteger {
- n.v = valueTypeInt
- n.i = d.DecodeInt64()
- } else {
- n.v = valueTypeUint
- n.u = d.DecodeUint64()
- }
- case d.bd >= cborBaseNegInt && d.bd < cborBaseBytes:
- n.v = valueTypeInt
- n.i = d.DecodeInt64()
- case d.bd >= cborBaseBytes && d.bd < cborBaseString:
- n.v = valueTypeBytes
- n.l = d.DecodeBytes(nil, false)
- case d.bd >= cborBaseString && d.bd < cborBaseArray:
+ case cborMajorTag:
+ n.v = valueTypeExt
+ n.u = d.decUint()
+ n.l = nil
+ if n.u == 0 || n.u == 1 {
+ d.bdRead = false
+ n.v = valueTypeTime
+ n.t = d.decodeTime(n.u)
+ } else if d.st && d.h.getExtForTag(n.u) == nil {
+ // d.skipTags() // no need to call this - tags already skipped
+ d.bdRead = false
+ d.DecodeNaked()
+ return // return when done (as true recursive function)
+ }
+ case cborMajorSimpleOrFloat:
+ switch d.bd {
+ case cborBdNil, cborBdUndefined:
+ n.v = valueTypeNil
+ d.fnil = true
+ case cborBdFalse:
+ n.v = valueTypeBool
+ n.b = false
+ case cborBdTrue:
+ n.v = valueTypeBool
+ n.b = true
+ case cborBdFloat16, cborBdFloat32, cborBdFloat64:
+ n.v = valueTypeFloat
+ n.f = d.DecodeFloat64()
+ case cborBdIndefiniteBytes:
+ decNakedReadRawBytes(d, &d.d, n, d.h.RawToString)
+ case cborBdIndefiniteString:
n.v = valueTypeString
- n.s = d.DecodeString()
- case d.bd >= cborBaseArray && d.bd < cborBaseMap:
+ n.s = string(d.DecodeStringAsBytes())
+ case cborBdIndefiniteArray:
n.v = valueTypeArray
decodeFurther = true
- case d.bd >= cborBaseMap && d.bd < cborBaseTag:
+ case cborBdIndefiniteMap:
n.v = valueTypeMap
decodeFurther = true
- case d.bd >= cborBaseTag && d.bd < cborBaseSimple:
- n.v = valueTypeExt
- n.u = d.decUint()
- n.l = nil
- if n.u == 0 || n.u == 1 {
- d.bdRead = false
- n.v = valueTypeTime
- n.t = d.decodeTime(n.u)
- }
- // d.bdRead = false
- // d.d.decode(&re.Value) // handled by decode itself.
- // decodeFurther = true
default:
d.d.errorf("decodeNaked: Unrecognized d.bd: 0x%x", d.bd)
- return
}
+ default: // should never happen
+ d.d.errorf("decodeNaked: Unrecognized d.bd: 0x%x", d.bd)
}
-
if !decodeFurther {
d.bdRead = false
}
@@ -727,7 +793,7 @@ func (d *cborDecDriver) DecodeNaked() {
// - Encoded Text (e.g. URL, regexp, base64, MIME Message), etc.
type CborHandle struct {
binaryEncodingType
- noElemSeparators
+ // noElemSeparators
BasicHandle
// IndefiniteLength=true, means that we encode using indefinitelength
@@ -737,32 +803,43 @@ type CborHandle struct {
// If unset, we encode time.Time using seconds past epoch.
TimeRFC3339 bool
- // _ [1]uint64 // padding
+ // SkipUnexpectedTags says to skip over any tags for which extensions are
+ // not defined. This is in keeping with the cbor spec on "Optional Tagging of Items".
+ //
+ // Furthermore, this allows the skipping over of the Self Describing Tag 0xd9d9f7.
+ SkipUnexpectedTags bool
+
+ _ [7]uint64 // padding (cache-aligned)
}
// Name returns the name of the handle: cbor
func (h *CborHandle) Name() string { return "cbor" }
-// SetInterfaceExt sets an extension
-func (h *CborHandle) SetInterfaceExt(rt reflect.Type, tag uint64, ext InterfaceExt) (err error) {
- return h.SetExt(rt, tag, &extWrapper{bytesExtFailer{}, ext})
+func (h *CborHandle) newEncDriver() encDriver {
+ var e = &cborEncDriver{h: h}
+ e.e.e = e
+ e.e.init(h)
+ e.reset()
+ return e
}
-func (h *CborHandle) newEncDriver(e *Encoder) encDriver {
- return &cborEncDriver{e: e, w: e.w, h: h}
-}
-
-func (h *CborHandle) newDecDriver(d *Decoder) decDriver {
- return &cborDecDriver{d: d, h: h, r: d.r, br: d.bytes}
+func (h *CborHandle) newDecDriver() decDriver {
+ d := &cborDecDriver{h: h, st: h.SkipUnexpectedTags}
+ d.d.d = d
+ d.d.cbor = true
+ d.d.init(h)
+ d.reset()
+ return d
}
func (e *cborEncDriver) reset() {
- e.w = e.e.w
}
func (d *cborDecDriver) reset() {
- d.r, d.br = d.d.r, d.d.bytes
- d.bd, d.bdRead = 0, false
+ d.bd = 0
+ d.bdRead = false
+ d.fnil = false
+ d.st = d.h.SkipUnexpectedTags
}
var _ decDriver = (*cborDecDriver)(nil)
diff --git a/vendor/github.com/ugorji/go/codec/decode.go b/vendor/github.com/ugorji/go/codec/decode.go
index b2bb0e8..a33252b 100644
--- a/vendor/github.com/ugorji/go/codec/decode.go
+++ b/vendor/github.com/ugorji/go/codec/decode.go
@@ -8,8 +8,8 @@ import (
"errors"
"fmt"
"io"
+ "math"
"reflect"
- "runtime"
"strconv"
"time"
)
@@ -23,15 +23,37 @@ const (
const (
decDefMaxDepth = 1024 // maximum depth
decDefSliceCap = 8
- decDefChanCap = 64 // should be large, as cap cannot be expanded
- decScratchByteArrayLen = cacheLineSize // + (8 * 2) // - (8 * 1)
+ decDefChanCap = 64 // should be large, as cap cannot be expanded
+ decScratchByteArrayLen = (6 * 8) // ??? cacheLineSize +
+
+ // decContainerLenUnknown is length returned from Read(Map|Array)Len
+ // when a format doesn't know apiori.
+ // For example, json doesn't pre-determine the length of a container (sequence/map).
+ decContainerLenUnknown = -1
+
+ // decContainerLenNil is length returned from Read(Map|Array)Len
+ // when a 'nil' was encountered in the stream.
+ decContainerLenNil = math.MinInt32
+
+ // decFailNonEmptyIntf configures whether we error
+ // when decoding naked into a non-empty interface.
+ //
+ // Typically, we cannot decode non-nil stream value into
+ // nil interface with methods (e.g. io.Reader).
+ // However, in some scenarios, this should be allowed:
+ // - MapType
+ // - SliceType
+ // - Extensions
+ //
+ // Consequently, we should relax this. Put it behind a const flag for now.
+ decFailNonEmptyIntf = false
)
var (
errstrOnlyMapOrArrayCanDecodeIntoStruct = "only encoded map or array can be decoded into a struct"
errstrCannotDecodeIntoNil = "cannot decode into nil"
- errmsgExpandSliceOverflow = "expand slice: slice overflow"
+ // errmsgExpandSliceOverflow = "expand slice: slice overflow"
errmsgExpandSliceCannotChange = "expand slice: cannot change"
errDecoderNotInitialized = errors.New("Decoder not initialized")
@@ -40,48 +62,23 @@ var (
errDecUnreadByteLastByteNotRead = errors.New("cannot unread - last byte has not been read")
errDecUnreadByteUnknown = errors.New("cannot unread - reason unknown")
errMaxDepthExceeded = errors.New("maximum decoding depth exceeded")
-)
-
-/*
-// decReader abstracts the reading source, allowing implementations that can
-// read from an io.Reader or directly off a byte slice with zero-copying.
-//
-// Deprecated: Use decReaderSwitch instead.
-type decReader interface {
- unreadn1()
- // readx will use the implementation scratch buffer if possible i.e. n < len(scratchbuf), OR
- // just return a view of the []byte being decoded from.
- // Ensure you call detachZeroCopyBytes later if this needs to be sent outside codec control.
- readx(n int) []byte
- readb([]byte)
- readn1() uint8
- numread() uint // number of bytes read
- track()
- stopTrack() []byte
-
- // skip will skip any byte that matches, and return the first non-matching byte
- skip(accept *bitset256) (token byte)
- // readTo will read any byte that matches, stopping once no-longer matching.
- readTo(in []byte, accept *bitset256) (out []byte)
- // readUntil will read, only stopping once it matches the 'stop' byte.
- readUntil(in []byte, stop byte) (out []byte)
-}
-
-*/
+ errBytesDecReaderCannotUnread = errors.New("cannot unread last byte read")
+)
type decDriver interface {
// this will check if the next token is a break.
CheckBreak() bool
- // TryDecodeAsNil tries to decode as nil.
- // Note: TryDecodeAsNil should be careful not to share any temporary []byte with
- // the rest of the decDriver. This is because sometimes, we optimize by holding onto
- // a transient []byte, and ensuring the only other call we make to the decDriver
- // during that time is maybe a TryDecodeAsNil() call.
- TryDecodeAsNil() bool
- // ContainerType returns one of: Bytes, String, Nil, Slice or Map. Return unSet if not known.
+
+ // TryNil tries to decode as nil.
+ TryNil() bool
+
+ // ContainerType returns one of: Bytes, String, Nil, Slice or Map.
+ //
+ // Return unSet if not known.
+ //
+ // Note: Implementations MUST fully consume sentinel container types, specifically Nil.
ContainerType() (vt valueType)
- // IsBuiltinType(rt uintptr) bool
// DecodeNaked will decode primitives (number, bool, string, []byte) and RawExt.
// For maps and arrays, it will not do the decoding in-band, but will signal
@@ -96,21 +93,18 @@ type decDriver interface {
// kInterface will extract the detached byte slice if it has to pass it outside its realm.
DecodeNaked()
- // Deprecated: use DecodeInt64 and DecodeUint64 instead
- // DecodeInt(bitsize uint8) (i int64)
- // DecodeUint(bitsize uint8) (ui uint64)
-
DecodeInt64() (i int64)
DecodeUint64() (ui uint64)
DecodeFloat64() (f float64)
DecodeBool() (b bool)
- // DecodeString can also decode symbols.
- // It looks redundant as DecodeBytes is available.
- // However, some codecs (e.g. binc) support symbols and can
- // return a pre-stored string value, meaning that it can bypass
- // the cost of []byte->string conversion.
- DecodeString() (s string)
+
+ // DecodeStringAsBytes returns the bytes representing a string.
+ // By definition, it will return a view into a scratch buffer.
+ //
+ // Note: This can also decode symbols, if supported.
+ //
+ // Users should consume it right away and not store it for later use.
DecodeStringAsBytes() (v []byte)
// DecodeBytes may be called directly, without going through reflection.
@@ -118,22 +112,35 @@ type decDriver interface {
DecodeBytes(bs []byte, zerocopy bool) (bsOut []byte)
// DecodeBytes(bs []byte, isstring, zerocopy bool) (bsOut []byte)
- // decodeExt will decode into a *RawExt or into an extension.
- DecodeExt(v interface{}, xtag uint64, ext Ext) (realxtag uint64)
+ // DecodeExt will decode into a *RawExt or into an extension.
+ DecodeExt(v interface{}, xtag uint64, ext Ext)
// decodeExt(verifyTag bool, tag byte) (xtag byte, xbs []byte)
DecodeTime() (t time.Time)
+ // ReadArrayStart will return the length of the array.
+ // If the format doesn't prefix the length, it returns decContainerLenUnknown.
+ // If the expected array was a nil in the stream, it returns decContainerLenNil.
ReadArrayStart() int
- ReadArrayElem()
ReadArrayEnd()
+
+ // ReadMapStart will return the length of the array.
+ // If the format doesn't prefix the length, it returns decContainerLenUnknown.
+ // If the expected array was a nil in the stream, it returns decContainerLenNil.
ReadMapStart() int
- ReadMapElemKey()
- ReadMapElemValue()
ReadMapEnd()
reset()
+ atEndOfDecode()
uncacheRead()
+
+ decoder() *Decoder
+}
+
+type decDriverContainerTracker interface {
+ ReadArrayElem()
+ ReadMapElemKey()
+ ReadMapElemValue()
}
type decodeError struct {
@@ -148,15 +155,11 @@ func (d decodeError) Error() string {
type decDriverNoopContainerReader struct{}
func (x decDriverNoopContainerReader) ReadArrayStart() (v int) { return }
-func (x decDriverNoopContainerReader) ReadArrayElem() {}
func (x decDriverNoopContainerReader) ReadArrayEnd() {}
func (x decDriverNoopContainerReader) ReadMapStart() (v int) { return }
-func (x decDriverNoopContainerReader) ReadMapElemKey() {}
-func (x decDriverNoopContainerReader) ReadMapElemValue() {}
func (x decDriverNoopContainerReader) ReadMapEnd() {}
func (x decDriverNoopContainerReader) CheckBreak() (v bool) { return }
-
-// func (x decNoSeparator) uncacheRead() {}
+func (x decDriverNoopContainerReader) atEndOfDecode() {}
// DecodeOptions captures configuration options during decode.
type DecodeOptions struct {
@@ -246,6 +249,7 @@ type DecodeOptions struct {
// PreferArrayOverSlice controls whether to decode to an array or a slice.
//
// This only impacts decoding into a nil interface{}.
+ //
// Consequently, it has no effect on codecgen.
//
// *Note*: This only applies if using go1.5 and above,
@@ -256,989 +260,147 @@ type DecodeOptions struct {
//
// If true, we will delete the mapping of the key.
// Else, just set the mapping to the zero value of the type.
+ //
+ // Deprecated: This does NOTHING and is left behind for compiling compatibility.
+ // This change is necessitated because 'nil' in a stream now consistently
+ // means the zero value (ie reset the value to its zero state).
DeleteOnNilMapValue bool
-}
-
-// ------------------------------------------------
-
-type unreadByteStatus uint8
-
-// unreadByteStatus goes from
-// undefined (when initialized) -- (read) --> canUnread -- (unread) --> canRead ...
-const (
- unreadByteUndefined unreadByteStatus = iota
- unreadByteCanRead
- unreadByteCanUnread
-)
-
-type ioDecReaderCommon struct {
- r io.Reader // the reader passed in
-
- n uint // num read
-
- l byte // last byte
- ls unreadByteStatus // last byte status
- trb bool // tracking bytes turned on
- _ bool
- b [4]byte // tiny buffer for reading single bytes
-
- tr []byte // tracking bytes read
-}
-
-func (z *ioDecReaderCommon) reset(r io.Reader) {
- z.r = r
- z.ls = unreadByteUndefined
- z.l, z.n = 0, 0
- z.trb = false
- if z.tr != nil {
- z.tr = z.tr[:0]
- }
-}
-
-func (z *ioDecReaderCommon) numread() uint {
- return z.n
-}
-
-func (z *ioDecReaderCommon) track() {
- if z.tr != nil {
- z.tr = z.tr[:0]
- }
- z.trb = true
-}
-func (z *ioDecReaderCommon) stopTrack() (bs []byte) {
- z.trb = false
- return z.tr
+ // RawToString controls how raw bytes in a stream are decoded into a nil interface{}.
+ // By default, they are decoded as []byte, but can be decoded as string (if configured).
+ RawToString bool
}
-// ------------------------------------------
-
-// ioDecReader is a decReader that reads off an io.Reader.
-//
-// It also has a fallback implementation of ByteScanner if needed.
-type ioDecReader struct {
- ioDecReaderCommon
-
- rr io.Reader
- br io.ByteScanner
-
- x [scratchByteArrayLen]byte // for: get struct field name, swallow valueTypeBytes, etc
- _ [1]uint64 // padding
-}
-
-func (z *ioDecReader) reset(r io.Reader) {
- z.ioDecReaderCommon.reset(r)
-
- var ok bool
- z.rr = r
- z.br, ok = r.(io.ByteScanner)
- if !ok {
- z.br = z
- z.rr = z
- }
-}
-
-func (z *ioDecReader) Read(p []byte) (n int, err error) {
- if len(p) == 0 {
- return
- }
- var firstByte bool
- if z.ls == unreadByteCanRead {
- z.ls = unreadByteCanUnread
- p[0] = z.l
- if len(p) == 1 {
- n = 1
- return
- }
- firstByte = true
- p = p[1:]
- }
- n, err = z.r.Read(p)
- if n > 0 {
- if err == io.EOF && n == len(p) {
- err = nil // read was successful, so postpone EOF (till next time)
- }
- z.l = p[n-1]
- z.ls = unreadByteCanUnread
- }
- if firstByte {
- n++
- }
- return
-}
-
-func (z *ioDecReader) ReadByte() (c byte, err error) {
- n, err := z.Read(z.b[:1])
- if n == 1 {
- c = z.b[0]
- if err == io.EOF {
- err = nil // read was successful, so postpone EOF (till next time)
- }
- }
- return
-}
-
-func (z *ioDecReader) UnreadByte() (err error) {
- switch z.ls {
- case unreadByteCanUnread:
- z.ls = unreadByteCanRead
- case unreadByteCanRead:
- err = errDecUnreadByteLastByteNotRead
- case unreadByteUndefined:
- err = errDecUnreadByteNothingToRead
- default:
- err = errDecUnreadByteUnknown
- }
- return
-}
-
-func (z *ioDecReader) readx(n uint) (bs []byte) {
- if n == 0 {
- return
- }
- if n < uint(len(z.x)) {
- bs = z.x[:n]
- } else {
- bs = make([]byte, n)
- }
- if _, err := decReadFull(z.rr, bs); err != nil {
- panic(err)
- }
- z.n += uint(len(bs))
- if z.trb {
- z.tr = append(z.tr, bs...)
- }
- return
-}
-
-func (z *ioDecReader) readb(bs []byte) {
- if len(bs) == 0 {
- return
- }
- if _, err := decReadFull(z.rr, bs); err != nil {
- panic(err)
- }
- z.n += uint(len(bs))
- if z.trb {
- z.tr = append(z.tr, bs...)
- }
-}
+// ----------------------------------------
-func (z *ioDecReader) readn1eof() (b uint8, eof bool) {
- b, err := z.br.ReadByte()
- if err == nil {
- z.n++
- if z.trb {
- z.tr = append(z.tr, b)
- }
- } else if err == io.EOF {
- eof = true
- } else {
- panic(err)
- }
- return
+func (d *Decoder) rawExt(f *codecFnInfo, rv reflect.Value) {
+ d.d.DecodeExt(rv2i(rv), 0, nil)
}
-func (z *ioDecReader) readn1() (b uint8) {
- b, err := z.br.ReadByte()
- if err == nil {
- z.n++
- if z.trb {
- z.tr = append(z.tr, b)
- }
- return
- }
- panic(err)
-}
-
-func (z *ioDecReader) skip(accept *bitset256) (token byte) {
- var eof bool
- // for {
- // token, eof = z.readn1eof()
- // if eof {
- // return
- // }
- // if accept.isset(token) {
- // continue
- // }
- // return
- // }
-LOOP:
- token, eof = z.readn1eof()
- if eof {
- return
- }
- if accept.isset(token) {
- goto LOOP
- }
- return
+func (d *Decoder) ext(f *codecFnInfo, rv reflect.Value) {
+ d.d.DecodeExt(rv2i(rv), f.xfTag, f.xfFn)
}
-func (z *ioDecReader) readTo(in []byte, accept *bitset256) []byte {
- // out = in
-
- // for {
- // token, eof := z.readn1eof()
- // if eof {
- // return
- // }
- // if accept.isset(token) {
- // out = append(out, token)
- // } else {
- // z.unreadn1()
- // return
- // }
- // }
-LOOP:
- token, eof := z.readn1eof()
- if eof {
- return in
- }
- if accept.isset(token) {
- // out = append(out, token)
- in = append(in, token)
- goto LOOP
- }
- z.unreadn1()
- return in
+func (d *Decoder) selferUnmarshal(f *codecFnInfo, rv reflect.Value) {
+ rv2i(rv).(Selfer).CodecDecodeSelf(d)
}
-func (z *ioDecReader) readUntil(in []byte, stop byte) (out []byte) {
- out = in
- // for {
- // token, eof := z.readn1eof()
- // if eof {
- // panic(io.EOF)
- // }
- // out = append(out, token)
- // if token == stop {
- // return
- // }
- // }
-LOOP:
- token, eof := z.readn1eof()
- if eof {
- panic(io.EOF)
- }
- out = append(out, token)
- if token == stop {
- return
+func (d *Decoder) binaryUnmarshal(f *codecFnInfo, rv reflect.Value) {
+ bm := rv2i(rv).(encoding.BinaryUnmarshaler)
+ xbs := d.d.DecodeBytes(nil, true)
+ if fnerr := bm.UnmarshalBinary(xbs); fnerr != nil {
+ panic(fnerr)
}
- goto LOOP
}
-//go:noinline
-func (z *ioDecReader) unreadn1() {
- err := z.br.UnreadByte()
- if err != nil {
- panic(err)
- }
- z.n--
- if z.trb {
- if l := len(z.tr) - 1; l >= 0 {
- z.tr = z.tr[:l]
- }
+func (d *Decoder) textUnmarshal(f *codecFnInfo, rv reflect.Value) {
+ tm := rv2i(rv).(encoding.TextUnmarshaler)
+ fnerr := tm.UnmarshalText(d.d.DecodeStringAsBytes())
+ if fnerr != nil {
+ panic(fnerr)
}
}
-// ------------------------------------
-
-type bufioDecReader struct {
- ioDecReaderCommon
-
- c uint // cursor
- buf []byte
-
- bytesBufPooler
-
- // err error
-
- // Extensions can call Decode() within a current Decode() call.
- // We need to know when the top level Decode() call returns,
- // so we can decide whether to Release() or not.
- calls uint16 // what depth in mustDecode are we in now.
-
- _ [6]uint8 // padding
-
- _ [1]uint64 // padding
-}
-
-func (z *bufioDecReader) reset(r io.Reader, bufsize int) {
- z.ioDecReaderCommon.reset(r)
- z.c = 0
- z.calls = 0
- if cap(z.buf) >= bufsize {
- z.buf = z.buf[:0]
- } else {
- z.buf = z.bytesBufPooler.get(bufsize)[:0]
- // z.buf = make([]byte, 0, bufsize)
+func (d *Decoder) jsonUnmarshal(f *codecFnInfo, rv reflect.Value) {
+ tm := rv2i(rv).(jsonUnmarshaler)
+ // bs := d.d.DecodeBytes(d.b[:], true, true)
+ // grab the bytes to be read, as UnmarshalJSON needs the full JSON so as to unmarshal it itself.
+ fnerr := tm.UnmarshalJSON(d.nextValueBytes())
+ if fnerr != nil {
+ panic(fnerr)
}
}
-func (z *bufioDecReader) release() {
- z.buf = nil
- z.bytesBufPooler.end()
+func (d *Decoder) kErr(f *codecFnInfo, rv reflect.Value) {
+ d.errorf("no decoding function defined for kind %v", rv.Kind())
}
-func (z *bufioDecReader) readb(p []byte) {
- var n = uint(copy(p, z.buf[z.c:]))
- z.n += n
- z.c += n
- if len(p) == int(n) {
- if z.trb {
- z.tr = append(z.tr, p...) // cost=9
- }
- } else {
- z.readbFill(p, n)
- }
+func (d *Decoder) raw(f *codecFnInfo, rv reflect.Value) {
+ rvSetBytes(rv, d.rawBytes())
}
-//go:noinline - fallback when z.buf is consumed
-func (z *bufioDecReader) readbFill(p0 []byte, n uint) {
- // at this point, there's nothing in z.buf to read (z.buf is fully consumed)
- p := p0[n:]
- var n2 uint
- var err error
- if len(p) > cap(z.buf) {
- n2, err = decReadFull(z.r, p)
- if err != nil {
- panic(err)
- }
- n += n2
- z.n += n2
- // always keep last byte in z.buf
- z.buf = z.buf[:1]
- z.buf[0] = p[len(p)-1]
- z.c = 1
- if z.trb {
- z.tr = append(z.tr, p0[:n]...)
- }
- return
- }
- // z.c is now 0, and len(p) <= cap(z.buf)
-LOOP:
- // for len(p) > 0 && z.err == nil {
- if len(p) > 0 {
- z.buf = z.buf[0:cap(z.buf)]
- var n1 int
- n1, err = z.r.Read(z.buf)
- n2 = uint(n1)
- if n2 == 0 && err != nil {
- panic(err)
- }
- z.buf = z.buf[:n2]
- n2 = uint(copy(p, z.buf))
- z.c = n2
- n += n2
- z.n += n2
- p = p[n2:]
- goto LOOP
- }
- if z.c == 0 {
- z.buf = z.buf[:1]
- z.buf[0] = p[len(p)-1]
- z.c = 1
- }
- if z.trb {
- z.tr = append(z.tr, p0[:n]...)
- }
-}
-
-func (z *bufioDecReader) readn1() (b byte) {
- // fast-path, so we elide calling into Read() most of the time
- if z.c < uint(len(z.buf)) {
- b = z.buf[z.c]
- z.c++
- z.n++
- if z.trb {
- z.tr = append(z.tr, b)
- }
- } else { // meaning z.c == len(z.buf) or greater ... so need to fill
- z.readbFill(z.b[:1], 0)
- b = z.b[0]
- }
- return
+func (d *Decoder) kString(f *codecFnInfo, rv reflect.Value) {
+ rvSetString(rv, string(d.d.DecodeStringAsBytes()))
}
-func (z *bufioDecReader) unreadn1() {
- if z.c == 0 {
- panic(errDecUnreadByteNothingToRead)
- }
- z.c--
- z.n--
- if z.trb {
- z.tr = z.tr[:len(z.tr)-1]
- }
+func (d *Decoder) kBool(f *codecFnInfo, rv reflect.Value) {
+ rvSetBool(rv, d.d.DecodeBool())
}
-func (z *bufioDecReader) readx(n uint) (bs []byte) {
- if n == 0 {
- // return
- } else if z.c+n <= uint(len(z.buf)) {
- bs = z.buf[z.c : z.c+n]
- z.n += n
- z.c += n
- if z.trb {
- z.tr = append(z.tr, bs...)
- }
- } else {
- bs = make([]byte, n)
- // n no longer used - can reuse
- n = uint(copy(bs, z.buf[z.c:]))
- z.n += n
- z.c += n
- z.readbFill(bs, n)
- }
- return
+func (d *Decoder) kTime(f *codecFnInfo, rv reflect.Value) {
+ rvSetTime(rv, d.d.DecodeTime())
}
-//go:noinline - track called by Decoder.nextValueBytes() (called by jsonUnmarshal,rawBytes)
-func (z *bufioDecReader) doTrack(y uint) {
- z.tr = append(z.tr, z.buf[z.c:y]...) // cost=14???
+func (d *Decoder) kFloat32(f *codecFnInfo, rv reflect.Value) {
+ rvSetFloat32(rv, d.decodeFloat32())
}
-func (z *bufioDecReader) skipLoopFn(i uint) {
- z.n += (i - z.c) - 1
- i++
- if z.trb {
- // z.tr = append(z.tr, z.buf[z.c:i]...)
- z.doTrack(i)
- }
- z.c = i
+func (d *Decoder) kFloat64(f *codecFnInfo, rv reflect.Value) {
+ rvSetFloat64(rv, d.d.DecodeFloat64())
}
-func (z *bufioDecReader) skip(accept *bitset256) (token byte) {
- // token, _ = z.search(nil, accept, 0, 1); return
-
- // for i := z.c; i < len(z.buf); i++ {
- // if token = z.buf[i]; !accept.isset(token) {
- // z.skipLoopFn(i)
- // return
- // }
- // }
-
- i := z.c
-LOOP:
- if i < uint(len(z.buf)) {
- // inline z.skipLoopFn(i) and refactor, so cost is within inline budget
- token = z.buf[i]
- i++
- if accept.isset(token) {
- goto LOOP
- }
- z.n += i - 2 - z.c
- if z.trb {
- z.doTrack(i)
- }
- z.c = i
- return
- }
- return z.skipFill(accept)
+func (d *Decoder) kInt(f *codecFnInfo, rv reflect.Value) {
+ rvSetInt(rv, int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize)))
}
-func (z *bufioDecReader) skipFill(accept *bitset256) (token byte) {
- z.n += uint(len(z.buf)) - z.c
- if z.trb {
- z.tr = append(z.tr, z.buf[z.c:]...)
- }
- var n2 int
- var err error
- for {
- z.c = 0
- z.buf = z.buf[0:cap(z.buf)]
- n2, err = z.r.Read(z.buf)
- if n2 == 0 && err != nil {
- panic(err)
- }
- z.buf = z.buf[:n2]
- var i int
- for i, token = range z.buf {
- if !accept.isset(token) {
- z.skipLoopFn(uint(i))
- return
- }
- }
- // for i := 0; i < n2; i++ {
- // if token = z.buf[i]; !accept.isset(token) {
- // z.skipLoopFn(i)
- // return
- // }
- // }
- z.n += uint(n2)
- if z.trb {
- z.tr = append(z.tr, z.buf...)
- }
- }
+func (d *Decoder) kInt8(f *codecFnInfo, rv reflect.Value) {
+ rvSetInt8(rv, int8(chkOvf.IntV(d.d.DecodeInt64(), 8)))
}
-func (z *bufioDecReader) readToLoopFn(i uint, out0 []byte) (out []byte) {
- // out0 is never nil
- z.n += (i - z.c) - 1
- out = append(out0, z.buf[z.c:i]...)
- if z.trb {
- z.doTrack(i)
- }
- z.c = i
- return
+func (d *Decoder) kInt16(f *codecFnInfo, rv reflect.Value) {
+ rvSetInt16(rv, int16(chkOvf.IntV(d.d.DecodeInt64(), 16)))
}
-func (z *bufioDecReader) readTo(in []byte, accept *bitset256) (out []byte) {
- // _, out = z.search(in, accept, 0, 2); return
-
- // for i := z.c; i < len(z.buf); i++ {
- // if !accept.isset(z.buf[i]) {
- // return z.readToLoopFn(i, nil)
- // }
- // }
-
- i := z.c
-LOOP:
- if i < uint(len(z.buf)) {
- if !accept.isset(z.buf[i]) {
- // return z.readToLoopFn(i, nil)
- // inline readToLoopFn here (for performance)
- z.n += (i - z.c) - 1
- out = z.buf[z.c:i]
- if z.trb {
- z.doTrack(i)
- }
- z.c = i
- return
- }
- i++
- goto LOOP
- }
- return z.readToFill(in, accept)
+func (d *Decoder) kInt32(f *codecFnInfo, rv reflect.Value) {
+ rvSetInt32(rv, int32(chkOvf.IntV(d.d.DecodeInt64(), 32)))
}
-func (z *bufioDecReader) readToFill(in []byte, accept *bitset256) (out []byte) {
- z.n += uint(len(z.buf)) - z.c
- out = append(in, z.buf[z.c:]...)
- if z.trb {
- z.tr = append(z.tr, z.buf[z.c:]...)
- }
- var n2 int
- var err error
- for {
- z.c = 0
- z.buf = z.buf[0:cap(z.buf)]
- n2, err = z.r.Read(z.buf)
- if n2 == 0 && err != nil {
- if err == io.EOF {
- return // readTo should read until it matches or end is reached
- }
- panic(err)
- }
- z.buf = z.buf[:n2]
- for i, token := range z.buf {
- if !accept.isset(token) {
- return z.readToLoopFn(uint(i), out)
- }
- }
- // for i := 0; i < n2; i++ {
- // if !accept.isset(z.buf[i]) {
- // return z.readToLoopFn(i, out)
- // }
- // }
- out = append(out, z.buf...)
- z.n += uint(n2)
- if z.trb {
- z.tr = append(z.tr, z.buf...)
- }
- }
+func (d *Decoder) kInt64(f *codecFnInfo, rv reflect.Value) {
+ rvSetInt64(rv, d.d.DecodeInt64())
}
-func (z *bufioDecReader) readUntilLoopFn(i uint, out0 []byte) (out []byte) {
- z.n += (i - z.c) - 1
- i++
- out = append(out0, z.buf[z.c:i]...)
- if z.trb {
- // z.tr = append(z.tr, z.buf[z.c:i]...)
- z.doTrack(i)
- }
- z.c = i
- return
+func (d *Decoder) kUint(f *codecFnInfo, rv reflect.Value) {
+ rvSetUint(rv, uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize)))
}
-func (z *bufioDecReader) readUntil(in []byte, stop byte) (out []byte) {
- // _, out = z.search(in, nil, stop, 4); return
-
- // for i := z.c; i < len(z.buf); i++ {
- // if z.buf[i] == stop {
- // return z.readUntilLoopFn(i, nil)
- // }
- // }
-
- i := z.c
-LOOP:
- if i < uint(len(z.buf)) {
- if z.buf[i] == stop {
- // inline readUntilLoopFn
- // return z.readUntilLoopFn(i, nil)
- z.n += (i - z.c) - 1
- i++
- out = z.buf[z.c:i]
- if z.trb {
- z.doTrack(i)
- }
- z.c = i
- return
- }
- i++
- goto LOOP
- }
- return z.readUntilFill(in, stop)
-}
-
-func (z *bufioDecReader) readUntilFill(in []byte, stop byte) (out []byte) {
- z.n += uint(len(z.buf)) - z.c
- out = append(in, z.buf[z.c:]...)
- if z.trb {
- z.tr = append(z.tr, z.buf[z.c:]...)
- }
- var n1 int
- var n2 uint
- var err error
- for {
- z.c = 0
- z.buf = z.buf[0:cap(z.buf)]
- n1, err = z.r.Read(z.buf)
- n2 = uint(n1)
- if n2 == 0 && err != nil {
- panic(err)
- }
- z.buf = z.buf[:n2]
- for i, token := range z.buf {
- if token == stop {
- return z.readUntilLoopFn(uint(i), out)
- }
- }
- // for i := 0; i < n2; i++ {
- // if z.buf[i] == stop {
- // return z.readUntilLoopFn(i, out)
- // }
- // }
- out = append(out, z.buf...)
- z.n += n2
- if z.trb {
- z.tr = append(z.tr, z.buf...)
- }
- }
+func (d *Decoder) kUintptr(f *codecFnInfo, rv reflect.Value) {
+ rvSetUintptr(rv, uintptr(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize)))
}
-// ------------------------------------
-
-var errBytesDecReaderCannotUnread = errors.New("cannot unread last byte read")
-
-// bytesDecReader is a decReader that reads off a byte slice with zero copying
-type bytesDecReader struct {
- b []byte // data
- c uint // cursor
- t uint // track start
- // a int // available
+func (d *Decoder) kUint8(f *codecFnInfo, rv reflect.Value) {
+ rvSetUint8(rv, uint8(chkOvf.UintV(d.d.DecodeUint64(), 8)))
}
-func (z *bytesDecReader) reset(in []byte) {
- z.b = in
- // z.a = len(in)
- z.c = 0
- z.t = 0
+func (d *Decoder) kUint16(f *codecFnInfo, rv reflect.Value) {
+ rvSetUint16(rv, uint16(chkOvf.UintV(d.d.DecodeUint64(), 16)))
}
-func (z *bytesDecReader) numread() uint {
- return z.c
+func (d *Decoder) kUint32(f *codecFnInfo, rv reflect.Value) {
+ rvSetUint32(rv, uint32(chkOvf.UintV(d.d.DecodeUint64(), 32)))
}
-func (z *bytesDecReader) unreadn1() {
- if z.c == 0 || len(z.b) == 0 {
- panic(errBytesDecReaderCannotUnread)
- }
- z.c--
- // z.a++
+func (d *Decoder) kUint64(f *codecFnInfo, rv reflect.Value) {
+ rvSetUint64(rv, d.d.DecodeUint64())
}
-func (z *bytesDecReader) readx(n uint) (bs []byte) {
- // slicing from a non-constant start position is more expensive,
- // as more computation is required to decipher the pointer start position.
- // However, we do it only once, and it's better than reslicing both z.b and return value.
-
- // if n <= 0 {
- // } else if z.a == 0 {
- // panic(io.EOF)
- // } else if n > z.a {
- // panic(io.ErrUnexpectedEOF)
- // } else {
- // c0 := z.c
- // z.c = c0 + n
- // z.a = z.a - n
- // bs = z.b[c0:z.c]
- // }
- // return
-
- if n != 0 {
- z.c += n
- if z.c > uint(len(z.b)) {
- z.c = uint(len(z.b))
- panic(io.EOF)
- }
- bs = z.b[z.c-n : z.c]
- }
- return
-
- // if n == 0 {
- // } else if z.c+n > uint(len(z.b)) {
- // z.c = uint(len(z.b))
- // panic(io.EOF)
- // } else {
- // z.c += n
- // bs = z.b[z.c-n : z.c]
- // }
- // return
-
- // if n == 0 {
- // return
- // }
- // if z.c == uint(len(z.b)) {
- // panic(io.EOF)
- // }
- // if z.c+n > uint(len(z.b)) {
- // panic(io.ErrUnexpectedEOF)
- // }
- // // z.a -= n
- // z.c += n
- // return z.b[z.c-n : z.c]
-}
-
-func (z *bytesDecReader) readb(bs []byte) {
- copy(bs, z.readx(uint(len(bs))))
-}
-
-func (z *bytesDecReader) readn1() (v uint8) {
- if z.c == uint(len(z.b)) {
- panic(io.EOF)
- }
- v = z.b[z.c]
- z.c++
- // z.a--
- return
-}
-
-// func (z *bytesDecReader) readn1eof() (v uint8, eof bool) {
-// if z.a == 0 {
-// eof = true
-// return
-// }
-// v = z.b[z.c]
-// z.c++
-// z.a--
-// return
-// }
-
-func (z *bytesDecReader) skip(accept *bitset256) (token byte) {
- i := z.c
- // if i == len(z.b) {
- // goto END
- // // panic(io.EOF)
- // }
-
- // Replace loop with goto construct, so that this can be inlined
- // for i := z.c; i < blen; i++ {
- // if !accept.isset(z.b[i]) {
- // token = z.b[i]
- // i++
- // z.a -= (i - z.c)
- // z.c = i
- // return
- // }
- // }
-
- // i := z.c
-LOOP:
- if i < uint(len(z.b)) {
- token = z.b[i]
- i++
- if accept.isset(token) {
- goto LOOP
- }
- // z.a -= (i - z.c)
- z.c = i
- return
- }
- // END:
- panic(io.EOF)
- // // z.a = 0
- // z.c = blen
- // return
-}
-
-func (z *bytesDecReader) readTo(_ []byte, accept *bitset256) (out []byte) {
- return z.readToNoInput(accept)
-}
-
-func (z *bytesDecReader) readToNoInput(accept *bitset256) (out []byte) {
- i := z.c
- if i == uint(len(z.b)) {
- panic(io.EOF)
- }
-
- // Replace loop with goto construct, so that this can be inlined
- // for i := z.c; i < blen; i++ {
- // if !accept.isset(z.b[i]) {
- // out = z.b[z.c:i]
- // z.a -= (i - z.c)
- // z.c = i
- // return
- // }
- // }
- // out = z.b[z.c:]
- // z.a, z.c = 0, blen
- // return
-
- // i := z.c
- // LOOP:
- // if i < blen {
- // if accept.isset(z.b[i]) {
- // i++
- // goto LOOP
- // }
- // out = z.b[z.c:i]
- // z.a -= (i - z.c)
- // z.c = i
- // return
- // }
- // out = z.b[z.c:]
- // // z.a, z.c = 0, blen
- // z.a = 0
- // z.c = blen
- // return
-
- // c := i
-LOOP:
- if i < uint(len(z.b)) {
- if accept.isset(z.b[i]) {
- i++
- goto LOOP
- }
- }
-
- out = z.b[z.c:i]
- // z.a -= (i - z.c)
- z.c = i
- return // z.b[c:i]
- // z.c, i = i, z.c
- // return z.b[i:z.c]
-}
-
-func (z *bytesDecReader) readUntil(_ []byte, stop byte) (out []byte) {
- return z.readUntilNoInput(stop)
-}
-
-func (z *bytesDecReader) readUntilNoInput(stop byte) (out []byte) {
- i := z.c
- // if i == len(z.b) {
- // panic(io.EOF)
- // }
-
- // Replace loop with goto construct, so that this can be inlined
- // for i := z.c; i < blen; i++ {
- // if z.b[i] == stop {
- // i++
- // out = z.b[z.c:i]
- // z.a -= (i - z.c)
- // z.c = i
- // return
- // }
- // }
-LOOP:
- if i < uint(len(z.b)) {
- if z.b[i] == stop {
- i++
- out = z.b[z.c:i]
- // z.a -= (i - z.c)
- z.c = i
- return
- }
- i++
- goto LOOP
- }
- // z.a = 0
- // z.c = blen
- panic(io.EOF)
-}
-
-func (z *bytesDecReader) track() {
- z.t = z.c
-}
-
-func (z *bytesDecReader) stopTrack() (bs []byte) {
- return z.b[z.t:z.c]
-}
-
-// ----------------------------------------
-
-// func (d *Decoder) builtin(f *codecFnInfo, rv reflect.Value) {
-// d.d.DecodeBuiltin(f.ti.rtid, rv2i(rv))
-// }
-
-func (d *Decoder) rawExt(f *codecFnInfo, rv reflect.Value) {
- d.d.DecodeExt(rv2i(rv), 0, nil)
-}
-
-func (d *Decoder) ext(f *codecFnInfo, rv reflect.Value) {
- d.d.DecodeExt(rv2i(rv), f.xfTag, f.xfFn)
-}
-
-func (d *Decoder) selferUnmarshal(f *codecFnInfo, rv reflect.Value) {
- rv2i(rv).(Selfer).CodecDecodeSelf(d)
-}
-
-func (d *Decoder) binaryUnmarshal(f *codecFnInfo, rv reflect.Value) {
- bm := rv2i(rv).(encoding.BinaryUnmarshaler)
- xbs := d.d.DecodeBytes(nil, true)
- if fnerr := bm.UnmarshalBinary(xbs); fnerr != nil {
- panic(fnerr)
- }
-}
-
-func (d *Decoder) textUnmarshal(f *codecFnInfo, rv reflect.Value) {
- tm := rv2i(rv).(encoding.TextUnmarshaler)
- fnerr := tm.UnmarshalText(d.d.DecodeStringAsBytes())
- if fnerr != nil {
- panic(fnerr)
- }
-}
-
-func (d *Decoder) jsonUnmarshal(f *codecFnInfo, rv reflect.Value) {
- tm := rv2i(rv).(jsonUnmarshaler)
- // bs := d.d.DecodeBytes(d.b[:], true, true)
- // grab the bytes to be read, as UnmarshalJSON needs the full JSON so as to unmarshal it itself.
- fnerr := tm.UnmarshalJSON(d.nextValueBytes())
- if fnerr != nil {
- panic(fnerr)
- }
-}
-
-func (d *Decoder) kErr(f *codecFnInfo, rv reflect.Value) {
- d.errorf("no decoding function defined for kind %v", rv.Kind())
-}
-
-// var kIntfCtr uint64
-
func (d *Decoder) kInterfaceNaked(f *codecFnInfo) (rvn reflect.Value) {
// nil interface:
// use some hieristics to decode it appropriately
// based on the detected next value in the stream.
n := d.naked()
d.d.DecodeNaked()
- if n.v == valueTypeNil {
- return
- }
+
// We cannot decode non-nil stream value into nil interface with methods (e.g. io.Reader).
- if f.ti.numMeth > 0 {
+ // Howver, it is possible that the user has ways to pass in a type for a given interface
+ // - MapType
+ // - SliceType
+ // - Extensions
+ //
+ // Consequently, we should relax this. Put it behind a const flag for now.
+ if decFailNonEmptyIntf && f.ti.numMeth > 0 {
d.errorf("cannot decode non-nil codec value into nil %v (%v methods)", f.ti.rt, f.ti.numMeth)
return
}
- // var useRvn bool
switch n.v {
case valueTypeMap:
// if json, default to a map type with string keys
@@ -1253,64 +415,76 @@ func (d *Decoder) kInterfaceNaked(f *codecFnInfo) (rvn reflect.Value) {
if mtid == mapIntfIntfTypId {
var v2 map[interface{}]interface{}
d.decode(&v2)
- rvn = reflect.ValueOf(&v2).Elem()
+ rvn = rv4i(&v2).Elem()
} else if mtid == mapStrIntfTypId { // for json performance
var v2 map[string]interface{}
d.decode(&v2)
- rvn = reflect.ValueOf(&v2).Elem()
+ rvn = rv4i(&v2).Elem()
} else {
if d.mtr {
rvn = reflect.New(d.h.MapType)
d.decode(rv2i(rvn))
rvn = rvn.Elem()
} else {
- rvn = reflect.New(d.h.MapType).Elem()
- d.decodeValue(rvn, nil, true)
+ rvn = rvZeroAddrK(d.h.MapType, reflect.Map)
+ d.decodeValue(rvn, nil)
}
}
case valueTypeArray:
if d.stid == 0 || d.stid == intfSliceTypId {
var v2 []interface{}
d.decode(&v2)
- rvn = reflect.ValueOf(&v2).Elem()
- if reflectArrayOfSupported && d.stid == 0 && d.h.PreferArrayOverSlice {
- rvn2 := reflect.New(reflectArrayOf(rvn.Len(), intfTyp)).Elem()
- reflect.Copy(rvn2, rvn)
- rvn = rvn2
- }
+ rvn = rv4i(&v2).Elem()
} else {
if d.str {
rvn = reflect.New(d.h.SliceType)
d.decode(rv2i(rvn))
rvn = rvn.Elem()
} else {
- rvn = reflect.New(d.h.SliceType).Elem()
- d.decodeValue(rvn, nil, true)
+ rvn = rvZeroAddrK(d.h.SliceType, reflect.Slice)
+ d.decodeValue(rvn, nil)
}
}
+ if reflectArrayOfSupported && d.h.PreferArrayOverSlice {
+ rvn = rvGetArray4Slice(rvn)
+ }
case valueTypeExt:
- var v interface{}
tag, bytes := n.u, n.l // calling decode below might taint the values
- if bytes == nil {
- d.decode(&v)
- }
bfn := d.h.getExtForTag(tag)
- if bfn == nil {
- var re RawExt
- re.Tag = tag
- re.Data = detachZeroCopyBytes(d.bytes, nil, bytes)
- re.Value = v
- rvn = reflect.ValueOf(&re).Elem()
+ var re = RawExt{Tag: tag}
+ if bytes == nil {
+ // it is one of the InterfaceExt ones: json and cbor.
+ // most likely cbor, as json decoding never reveals valueTypeExt (no tagging support)
+ if bfn == nil {
+ d.decode(&re.Value)
+ rvn = rv4i(&re).Elem()
+ } else {
+ if bfn.ext == SelfExt {
+ rvn = rvZeroAddrK(bfn.rt, bfn.rt.Kind())
+ d.decodeValue(rvn, d.h.fnNoExt(bfn.rt))
+ } else {
+ rvn = reflect.New(bfn.rt)
+ d.interfaceExtConvertAndDecode(rv2i(rvn), bfn.ext)
+ rvn = rvn.Elem()
+ }
+ }
} else {
- rvnA := reflect.New(bfn.rt)
- if bytes != nil {
- bfn.ext.ReadExt(rv2i(rvnA), bytes)
+ // one of the BytesExt ones: binc, msgpack, simple
+ if bfn == nil {
+ re.Data = detachZeroCopyBytes(d.bytes, nil, bytes)
+ rvn = rv4i(&re).Elem()
} else {
- bfn.ext.UpdateExt(rv2i(rvnA), v)
+ rvn = reflect.New(bfn.rt)
+ if bfn.ext == SelfExt {
+ d.sideDecode(rv2i(rvn), bytes)
+ } else {
+ bfn.ext.ReadExt(rv2i(rvn), bytes)
+ }
+ rvn = rvn.Elem()
}
- rvn = rvnA.Elem()
}
case valueTypeNil:
+ // rvn = reflect.Zero(f.ti.rt)
// no-op
case valueTypeInt:
rvn = n.ri()
@@ -1341,18 +515,21 @@ func (d *Decoder) kInterface(f *codecFnInfo, rv reflect.Value) {
// every interface passed here MUST be settable.
var rvn reflect.Value
- if rv.IsNil() || d.h.InterfaceReset {
+ if rvIsNil(rv) || d.h.InterfaceReset {
// check if mapping to a type: if so, initialize it and move on
rvn = d.h.intf2impl(f.ti.rtid)
if rvn.IsValid() {
rv.Set(rvn)
} else {
rvn = d.kInterfaceNaked(f)
+ // xdebugf("kInterface: %v", rvn)
if rvn.IsValid() {
rv.Set(rvn)
} else if d.h.InterfaceReset {
// reset to zero value based on current type in there.
- rv.Set(reflect.Zero(rv.Elem().Type()))
+ if rvelem := rv.Elem(); rvelem.IsValid() {
+ rv.Set(reflect.Zero(rvelem.Type()))
+ }
}
return
}
@@ -1360,25 +537,20 @@ func (d *Decoder) kInterface(f *codecFnInfo, rv reflect.Value) {
// now we have a non-nil interface value, meaning it contains a type
rvn = rv.Elem()
}
- if d.d.TryDecodeAsNil() {
- rv.Set(reflect.Zero(rvn.Type()))
- return
- }
// Note: interface{} is settable, but underlying type may not be.
// Consequently, we MAY have to create a decodable value out of the underlying value,
// decode into it, and reset the interface itself.
// fmt.Printf(">>>> kInterface: rvn type: %v, rv type: %v\n", rvn.Type(), rv.Type())
- rvn2, canDecode := isDecodeable(rvn)
- if canDecode {
- d.decodeValue(rvn2, nil, true)
+ if isDecodeable(rvn) {
+ d.decodeValue(rvn, nil)
return
}
- rvn2 = reflect.New(rvn.Type()).Elem()
- rvn2.Set(rvn)
- d.decodeValue(rvn2, nil, true)
+ rvn2 := rvZeroAddrK(rvn.Type(), rvn.Kind())
+ rvSetDirect(rvn2, rvn)
+ d.decodeValue(rvn2, nil)
rv.Set(rvn2)
}
@@ -1397,47 +569,39 @@ func decStructFieldKey(dd decDriver, keyType valueType, b *[decScratchByteArrayL
} else {
rvkencname = dd.DecodeStringAsBytes()
}
- return rvkencname
+ return
}
func (d *Decoder) kStruct(f *codecFnInfo, rv reflect.Value) {
- fti := f.ti
- dd := d.d
- elemsep := d.esep
sfn := structFieldNode{v: rv, update: true}
- ctyp := dd.ContainerType()
+ ctyp := d.d.ContainerType()
+ if ctyp == valueTypeNil {
+ rvSetDirect(rv, f.ti.rv0)
+ return
+ }
var mf MissingFielder
- if fti.mf {
+ if f.ti.isFlag(tiflagMissingFielder) {
mf = rv2i(rv).(MissingFielder)
- } else if fti.mfp {
+ } else if f.ti.isFlag(tiflagMissingFielderPtr) {
mf = rv2i(rv.Addr()).(MissingFielder)
}
if ctyp == valueTypeMap {
- containerLen := dd.ReadMapStart()
+ containerLen := d.mapStart()
if containerLen == 0 {
- dd.ReadMapEnd()
+ d.mapEnd()
return
}
- d.depthIncr()
- tisfi := fti.sfiSort
+ tisfi := f.ti.sfiSort
hasLen := containerLen >= 0
var rvkencname []byte
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if elemsep {
- dd.ReadMapElemKey()
- }
- rvkencname = decStructFieldKey(dd, fti.keyType, &d.b)
- if elemsep {
- dd.ReadMapElemValue()
- }
- if k := fti.indexForEncName(rvkencname); k > -1 {
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
+ rvkencname = decStructFieldKey(d.d, f.ti.keyType, &d.b)
+ d.mapElemValue()
+ if k := f.ti.indexForEncName(rvkencname); k > -1 {
si := tisfi[k]
- if dd.TryDecodeAsNil() {
- si.setToZeroValue(rv)
- } else {
- d.decodeValue(sfn.field(si), nil, true)
- }
+ d.decodeValue(sfn.field(si), nil)
} else if mf != nil {
// store rvkencname in new []byte, as it previously shares Decoder.b, which is used in decode
name2 := rvkencname
@@ -1445,9 +609,7 @@ func (d *Decoder) kStruct(f *codecFnInfo, rv reflect.Value) {
copy(rvkencname, name2)
var f interface{}
- // xdebugf("kStruct: mf != nil: before decode: rvkencname: %s", rvkencname)
d.decode(&f)
- // xdebugf("kStruct: mf != nil: after decode: rvkencname: %s", rvkencname)
if !mf.CodecMissingField(rvkencname, f) && d.h.ErrorIfNoField {
d.errorf("no matching struct field found when decoding stream map with key: %s ",
stringView(rvkencname))
@@ -1457,50 +619,39 @@ func (d *Decoder) kStruct(f *codecFnInfo, rv reflect.Value) {
}
// keepAlive4StringView(rvkencnameB) // not needed, as reference is outside loop
}
- dd.ReadMapEnd()
- d.depthDecr()
+ d.mapEnd()
} else if ctyp == valueTypeArray {
- containerLen := dd.ReadArrayStart()
+ containerLen := d.arrayStart()
if containerLen == 0 {
- dd.ReadArrayEnd()
+ d.arrayEnd()
return
}
- d.depthIncr()
// Not much gain from doing it two ways for array.
// Arrays are not used as much for structs.
hasLen := containerLen >= 0
var checkbreak bool
- for j, si := range fti.sfiSrc {
+ for j, si := range f.ti.sfiSrc {
if hasLen && j == containerLen {
break
}
- if !hasLen && dd.CheckBreak() {
+ if !hasLen && d.checkBreak() {
checkbreak = true
break
}
- if elemsep {
- dd.ReadArrayElem()
- }
- if dd.TryDecodeAsNil() {
- si.setToZeroValue(rv)
- } else {
- d.decodeValue(sfn.field(si), nil, true)
- }
+ d.arrayElem()
+ d.decodeValue(sfn.field(si), nil)
}
- if (hasLen && containerLen > len(fti.sfiSrc)) || (!hasLen && !checkbreak) {
+ if (hasLen && containerLen > len(f.ti.sfiSrc)) || (!hasLen && !checkbreak) {
// read remaining values and throw away
- for j := len(fti.sfiSrc); ; j++ {
- if (hasLen && j == containerLen) || (!hasLen && dd.CheckBreak()) {
+ for j := len(f.ti.sfiSrc); ; j++ {
+ if (hasLen && j == containerLen) || (!hasLen && d.checkBreak()) {
break
}
- if elemsep {
- dd.ReadArrayElem()
- }
+ d.arrayElem()
d.structFieldNotFound(j, "")
}
}
- dd.ReadArrayEnd()
- d.depthDecr()
+ d.arrayEnd()
} else {
d.errorstr(errstrOnlyMapOrArrayCanDecodeIntoStruct)
return
@@ -1510,68 +661,50 @@ func (d *Decoder) kStruct(f *codecFnInfo, rv reflect.Value) {
func (d *Decoder) kSlice(f *codecFnInfo, rv reflect.Value) {
// A slice can be set from a map or array in stream.
// This way, the order can be kept (as order is lost with map).
- ti := f.ti
- if f.seq == seqTypeChan && ti.chandir&uint8(reflect.SendDir) == 0 {
- d.errorf("receive-only channel cannot be decoded")
+
+ // Note: rv is a slice type here - guaranteed
+
+ rtelem0 := f.ti.elem
+ ctyp := d.d.ContainerType()
+ if ctyp == valueTypeNil {
+ if rv.CanSet() {
+ rvSetDirect(rv, f.ti.rv0)
+ }
+ return
}
- dd := d.d
- rtelem0 := ti.elem
- ctyp := dd.ContainerType()
if ctyp == valueTypeBytes || ctyp == valueTypeString {
// you can only decode bytes or string in the stream into a slice or array of bytes
- if !(ti.rtid == uint8SliceTypId || rtelem0.Kind() == reflect.Uint8) {
- d.errorf("bytes/string in stream must decode into slice/array of bytes, not %v", ti.rt)
+ if !(f.ti.rtid == uint8SliceTypId || rtelem0.Kind() == reflect.Uint8) {
+ d.errorf("bytes/string in stream must decode into slice/array of bytes, not %v", f.ti.rt)
}
- if f.seq == seqTypeChan {
- bs2 := dd.DecodeBytes(nil, true)
- irv := rv2i(rv)
- ch, ok := irv.(chan<- byte)
- if !ok {
- ch = irv.(chan byte)
- }
- for _, b := range bs2 {
- ch <- b
- }
- } else {
- rvbs := rv.Bytes()
- bs2 := dd.DecodeBytes(rvbs, false)
- // if rvbs == nil && bs2 != nil || rvbs != nil && bs2 == nil || len(bs2) != len(rvbs) {
- if !(len(bs2) > 0 && len(bs2) == len(rvbs) && &bs2[0] == &rvbs[0]) {
- if rv.CanSet() {
- rv.SetBytes(bs2)
- } else if len(rvbs) > 0 && len(bs2) > 0 {
- copy(rvbs, bs2)
- }
+ rvbs := rvGetBytes(rv)
+ bs2 := d.d.DecodeBytes(rvbs, false)
+ // if rvbs == nil && bs2 != nil || rvbs != nil && bs2 == nil || len(bs2) != len(rvbs) {
+ if !(len(bs2) > 0 && len(bs2) == len(rvbs) && &bs2[0] == &rvbs[0]) {
+ if rv.CanSet() {
+ rvSetBytes(rv, bs2)
+ } else if len(rvbs) > 0 && len(bs2) > 0 {
+ copy(rvbs, bs2)
}
}
return
}
- // array := f.seq == seqTypeChan
-
- slh, containerLenS := d.decSliceHelperStart() // only expects valueType(Array|Map)
+ slh, containerLenS := d.decSliceHelperStart() // only expects valueType(Array|Map) - never Nil
// an array can never return a nil slice. so no need to check f.array here.
if containerLenS == 0 {
if rv.CanSet() {
- if f.seq == seqTypeSlice {
- if rv.IsNil() {
- rv.Set(reflect.MakeSlice(ti.rt, 0, 0))
- } else {
- rv.SetLen(0)
- }
- } else if f.seq == seqTypeChan {
- if rv.IsNil() {
- rv.Set(reflect.MakeChan(ti.rt, 0))
- }
+ if rvIsNil(rv) {
+ rvSetDirect(rv, reflect.MakeSlice(f.ti.rt, 0, 0))
+ } else {
+ rvSetSliceLen(rv, 0)
}
}
slh.End()
return
}
- d.depthIncr()
-
rtelem0Size := int(rtelem0.Size())
rtElem0Kind := rtelem0.Kind()
rtelem0Mut := !isImmutableKind(rtElem0Kind)
@@ -1584,149 +717,227 @@ func (d *Decoder) kSlice(f *codecFnInfo, rv reflect.Value) {
var fn *codecFn
- var rvCanset = rv.CanSet()
- var rvChanged bool
var rv0 = rv
+ var rvChanged bool
+ var rvCanset = rv.CanSet()
var rv9 reflect.Value
- rvlen := rv.Len()
- rvcap := rv.Cap()
+ rvlen := rvGetSliceLen(rv)
+ rvcap := rvGetSliceCap(rv)
hasLen := containerLenS > 0
- if hasLen && f.seq == seqTypeSlice {
+ if hasLen {
if containerLenS > rvcap {
oldRvlenGtZero := rvlen > 0
rvlen = decInferLen(containerLenS, d.h.MaxInitLen, int(rtelem0.Size()))
if rvlen <= rvcap {
if rvCanset {
- rv.SetLen(rvlen)
+ rvSetSliceLen(rv, rvlen)
}
} else if rvCanset {
- rv = reflect.MakeSlice(ti.rt, rvlen, rvlen)
+ rv = reflect.MakeSlice(f.ti.rt, rvlen, rvlen)
rvcap = rvlen
rvChanged = true
} else {
d.errorf("cannot decode into non-settable slice")
}
- if rvChanged && oldRvlenGtZero && !isImmutableKind(rtelem0.Kind()) {
- reflect.Copy(rv, rv0) // only copy up to length NOT cap i.e. rv0.Slice(0, rvcap)
+ if rvChanged && oldRvlenGtZero && rtelem0Mut { // !isImmutableKind(rtelem0.Kind()) {
+ rvCopySlice(rv, rv0) // only copy up to length NOT cap i.e. rv0.Slice(0, rvcap)
}
} else if containerLenS != rvlen {
rvlen = containerLenS
if rvCanset {
- rv.SetLen(rvlen)
+ rvSetSliceLen(rv, rvlen)
}
- // else {
- // rv = rv.Slice(0, rvlen)
- // rvChanged = true
- // d.errorf("cannot decode into non-settable slice")
- // }
}
}
// consider creating new element once, and just decoding into it.
var rtelem0Zero reflect.Value
var rtelem0ZeroValid bool
- var decodeAsNil bool
var j int
- for ; (hasLen && j < containerLenS) || !(hasLen || dd.CheckBreak()); j++ {
- if j == 0 && (f.seq == seqTypeSlice || f.seq == seqTypeChan) && rv.IsNil() {
+ for ; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ {
+ if j == 0 && f.seq == seqTypeSlice && rvIsNil(rv) {
if hasLen {
rvlen = decInferLen(containerLenS, d.h.MaxInitLen, rtelem0Size)
- } else if f.seq == seqTypeSlice {
- rvlen = decDefSliceCap
} else {
- rvlen = decDefChanCap
+ rvlen = decDefSliceCap
}
if rvCanset {
- if f.seq == seqTypeSlice {
- rv = reflect.MakeSlice(ti.rt, rvlen, rvlen)
- rvChanged = true
- } else { // chan
- rv = reflect.MakeChan(ti.rt, rvlen)
- rvChanged = true
- }
+ rv = reflect.MakeSlice(f.ti.rt, rvlen, rvlen)
+ rvcap = rvlen
+ rvChanged = true
} else {
d.errorf("cannot decode into non-settable slice")
}
}
slh.ElemContainerState(j)
- decodeAsNil = dd.TryDecodeAsNil()
- if f.seq == seqTypeChan {
- if decodeAsNil {
- rv.Send(reflect.Zero(rtelem0))
- continue
- }
- if rtelem0Mut || !rv9.IsValid() { // || (rtElem0Kind == reflect.Ptr && rv9.IsNil()) {
- rv9 = reflect.New(rtelem0).Elem()
- }
- if fn == nil {
- fn = d.h.fn(rtelem, true, true)
- }
- d.decodeValue(rv9, fn, true)
- rv.Send(rv9)
- } else {
- // if indefinite, etc, then expand the slice if necessary
- var decodeIntoBlank bool
- if j >= rvlen {
- if f.seq == seqTypeArray {
- d.arrayCannotExpand(rvlen, j+1)
- decodeIntoBlank = true
- } else { // if f.seq == seqTypeSlice
- // rv = reflect.Append(rv, reflect.Zero(rtelem0)) // append logic + varargs
- var rvcap2 int
- var rvErrmsg2 string
- rv9, rvcap2, rvChanged, rvErrmsg2 =
- expandSliceRV(rv, ti.rt, rvCanset, rtelem0Size, 1, rvlen, rvcap)
- if rvErrmsg2 != "" {
- d.errorf(rvErrmsg2)
- }
- rvlen++
- if rvChanged {
- rv = rv9
- rvcap = rvcap2
- }
+ // if indefinite, etc, then expand the slice if necessary
+ if j >= rvlen {
+ if f.seq == seqTypeArray {
+ d.arrayCannotExpand(rvlen, j+1)
+ // drain completely and return
+ d.swallow()
+ j++
+ for ; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ {
+ slh.ElemContainerState(j)
+ d.swallow()
}
+ slh.End()
+ return
}
- if decodeIntoBlank {
- if !decodeAsNil {
- d.swallow()
+ // rv = reflect.Append(rv, reflect.Zero(rtelem0)) // append logic + varargs
+
+ // expand the slice up to the cap.
+ // Note that we did, so we have to reset it later.
+
+ if rvlen < rvcap {
+ if rv.CanSet() {
+ rvSetSliceLen(rv, rvcap)
+ } else if rvCanset {
+ rv = rvSlice(rv, rvcap)
+ rvChanged = true
+ } else {
+ d.errorf(errmsgExpandSliceCannotChange)
+ return
}
+ rvlen = rvcap
} else {
- rv9 = rv.Index(j)
- if d.h.SliceElementReset || decodeAsNil {
- if !rtelem0ZeroValid {
- rtelem0ZeroValid = true
- rtelem0Zero = reflect.Zero(rtelem0)
- }
- rv9.Set(rtelem0Zero)
- if decodeAsNil {
- continue
- }
+ if !rvCanset {
+ d.errorf(errmsgExpandSliceCannotChange)
+ return
}
-
- if fn == nil {
- fn = d.h.fn(rtelem, true, true)
- }
- d.decodeValue(rv9, fn, true)
+ rvcap = growCap(rvcap, rtelem0Size, rvcap)
+ rv9 = reflect.MakeSlice(f.ti.rt, rvcap, rvcap)
+ rvCopySlice(rv9, rv)
+ rv = rv9
+ rvChanged = true
+ rvlen = rvcap
}
}
+ rv9 = rvSliceIndex(rv, j, f.ti)
+ if d.h.SliceElementReset {
+ if !rtelem0ZeroValid {
+ rtelem0ZeroValid = true
+ rtelem0Zero = reflect.Zero(rtelem0)
+ }
+ rv9.Set(rtelem0Zero)
+ }
+
+ if fn == nil {
+ fn = d.h.fn(rtelem)
+ }
+ d.decodeValue(rv9, fn)
}
- if f.seq == seqTypeSlice {
- if j < rvlen {
- if rv.CanSet() {
- rv.SetLen(j)
- } else if rvCanset {
- rv = rv.Slice(0, j)
- rvChanged = true
- } // else { d.errorf("kSlice: cannot change non-settable slice") }
- rvlen = j
- } else if j == 0 && rv.IsNil() {
+ if j < rvlen {
+ if rv.CanSet() {
+ rvSetSliceLen(rv, j)
+ } else if rvCanset {
+ rv = rvSlice(rv, j)
+ rvChanged = true
+ }
+ rvlen = j
+ } else if j == 0 && rvIsNil(rv) {
+ if rvCanset {
+ rv = reflect.MakeSlice(f.ti.rt, 0, 0)
+ rvChanged = true
+ }
+ }
+ slh.End()
+
+ if rvChanged { // infers rvCanset=true, so it can be reset
+ rv0.Set(rv)
+ }
+
+}
+
+func (d *Decoder) kSliceForChan(f *codecFnInfo, rv reflect.Value) {
+ // A slice can be set from a map or array in stream.
+ // This way, the order can be kept (as order is lost with map).
+
+ if f.ti.chandir&uint8(reflect.SendDir) == 0 {
+ d.errorf("receive-only channel cannot be decoded")
+ }
+ rtelem0 := f.ti.elem
+ ctyp := d.d.ContainerType()
+ if ctyp == valueTypeNil {
+ rvSetDirect(rv, f.ti.rv0)
+ return
+ }
+ if ctyp == valueTypeBytes || ctyp == valueTypeString {
+ // you can only decode bytes or string in the stream into a slice or array of bytes
+ if !(f.ti.rtid == uint8SliceTypId || rtelem0.Kind() == reflect.Uint8) {
+ d.errorf("bytes/string in stream must decode into slice/array of bytes, not %v", f.ti.rt)
+ }
+ bs2 := d.d.DecodeBytes(nil, true)
+ irv := rv2i(rv)
+ ch, ok := irv.(chan<- byte)
+ if !ok {
+ ch = irv.(chan byte)
+ }
+ for _, b := range bs2 {
+ ch <- b
+ }
+ return
+ }
+
+ // only expects valueType(Array|Map - nil handled above)
+ slh, containerLenS := d.decSliceHelperStart()
+
+ // an array can never return a nil slice. so no need to check f.array here.
+ if containerLenS == 0 {
+ if rv.CanSet() && rvIsNil(rv) {
+ rvSetDirect(rv, reflect.MakeChan(f.ti.rt, 0))
+ }
+ slh.End()
+ return
+ }
+
+ rtelem0Size := int(rtelem0.Size())
+ rtElem0Kind := rtelem0.Kind()
+ rtelem0Mut := !isImmutableKind(rtElem0Kind)
+ rtelem := rtelem0
+ rtelemkind := rtelem.Kind()
+ for rtelemkind == reflect.Ptr {
+ rtelem = rtelem.Elem()
+ rtelemkind = rtelem.Kind()
+ }
+
+ var fn *codecFn
+
+ var rvCanset = rv.CanSet()
+ var rvChanged bool
+ var rv0 = rv
+ var rv9 reflect.Value
+
+ var rvlen int // := rv.Len()
+ hasLen := containerLenS > 0
+
+ var j int
+
+ for ; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ {
+ if j == 0 && rvIsNil(rv) {
+ if hasLen {
+ rvlen = decInferLen(containerLenS, d.h.MaxInitLen, rtelem0Size)
+ } else {
+ rvlen = decDefChanCap
+ }
if rvCanset {
- rv = reflect.MakeSlice(ti.rt, 0, 0)
+ rv = reflect.MakeChan(f.ti.rt, rvlen)
rvChanged = true
- } // else { d.errorf("kSlice: cannot change non-settable slice") }
+ } else {
+ d.errorf("cannot decode into non-settable chan")
+ }
+ }
+ slh.ElemContainerState(j)
+ if rtelem0Mut || !rv9.IsValid() { // || (rtElem0Kind == reflect.Ptr && rvIsNil(rv9)) {
+ rv9 = rvZeroAddrK(rtelem0, rtElem0Kind)
}
+ if fn == nil {
+ fn = d.h.fn(rtelem)
+ }
+ d.decodeValue(rv9, fn)
+ rv.Send(rv9)
}
slh.End()
@@ -1734,34 +945,31 @@ func (d *Decoder) kSlice(f *codecFnInfo, rv reflect.Value) {
rv0.Set(rv)
}
- d.depthDecr()
}
-// func (d *Decoder) kArray(f *codecFnInfo, rv reflect.Value) {
-// // d.decodeValueFn(rv.Slice(0, rv.Len()))
-// f.kSlice(rv.Slice(0, rv.Len()))
-// }
-
func (d *Decoder) kMap(f *codecFnInfo, rv reflect.Value) {
- dd := d.d
- containerLen := dd.ReadMapStart()
- elemsep := d.esep
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ rvSetDirect(rv, f.ti.rv0)
+ return
+ }
ti := f.ti
- if rv.IsNil() {
+ if rvIsNil(rv) {
rvlen := decInferLen(containerLen, d.h.MaxInitLen, int(ti.key.Size()+ti.elem.Size()))
- rv.Set(makeMapReflect(ti.rt, rvlen))
+ rvSetDirect(rv, makeMapReflect(ti.rt, rvlen))
}
if containerLen == 0 {
- dd.ReadMapEnd()
+ d.mapEnd()
return
}
- d.depthIncr()
-
ktype, vtype := ti.key, ti.elem
ktypeId := rt2id(ktype)
vtypeKind := vtype.Kind()
+ ktypeKind := ktype.Kind()
+
+ var vtypeElem reflect.Type
var keyFn, valFn *codecFn
var ktypeLo, vtypeLo reflect.Type
@@ -1772,137 +980,116 @@ func (d *Decoder) kMap(f *codecFnInfo, rv reflect.Value) {
for vtypeLo = vtype; vtypeLo.Kind() == reflect.Ptr; vtypeLo = vtypeLo.Elem() {
}
- var mapGet, mapSet bool
- rvvImmut := isImmutableKind(vtypeKind)
+ rvvMut := !isImmutableKind(vtypeKind)
+
+ // we do a doMapGet if kind is mutable, and InterfaceReset=true if interface
+ var doMapGet, doMapSet bool
if !d.h.MapValueReset {
- // if pointer, mapGet = true
- // if interface, mapGet = true if !DecodeNakedAlways (else false)
- // if builtin, mapGet = false
- // else mapGet = true
- if vtypeKind == reflect.Ptr {
- mapGet = true
- } else if vtypeKind == reflect.Interface {
- if !d.h.InterfaceReset {
- mapGet = true
+ if rvvMut {
+ if vtypeKind == reflect.Interface {
+ if !d.h.InterfaceReset {
+ doMapGet = true
+ }
+ } else {
+ doMapGet = true
}
- } else if !rvvImmut {
- mapGet = true
}
}
- var rvk, rvkp, rvv, rvz reflect.Value
+ var rvk, rvkn, rvv, rvvn, rvva reflect.Value
+ var rvvaSet bool
rvkMut := !isImmutableKind(ktype.Kind()) // if ktype is immutable, then re-use the same rvk.
ktypeIsString := ktypeId == stringTypId
ktypeIsIntf := ktypeId == intfTypId
hasLen := containerLen > 0
var kstrbs []byte
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if rvkMut || !rvkp.IsValid() {
- rvkp = reflect.New(ktype)
- rvk = rvkp.Elem()
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ if j == 0 {
+ if !rvkMut {
+ rvkn = rvZeroAddrK(ktype, ktypeKind)
+ }
+ if !rvvMut {
+ rvvn = rvZeroAddrK(vtype, vtypeKind)
+ }
}
- if elemsep {
- dd.ReadMapElemKey()
+
+ if rvkMut {
+ rvk = rvZeroAddrK(ktype, ktypeKind)
+ } else {
+ rvk = rvkn
}
- // if false && dd.TryDecodeAsNil() { // nil cannot be a map key, so disregard this block
- // // Previously, if a nil key, we just ignored the mapped value and continued.
- // // However, that makes the result of encoding and then decoding map[intf]intf{nil:nil}
- // // to be an empty map.
- // // Instead, we treat a nil key as the zero value of the type.
- // rvk.Set(reflect.Zero(ktype))
- // } else if ktypeIsString {
+
+ d.mapElemKey()
+
if ktypeIsString {
- kstrbs = dd.DecodeStringAsBytes()
- rvk.SetString(stringView(kstrbs))
- // NOTE: if doing an insert, you MUST use a real string (not stringview)
+ kstrbs = d.d.DecodeStringAsBytes()
+ rvk.SetString(stringView(kstrbs)) // NOTE: if doing an insert, use real string (not stringview)
} else {
if keyFn == nil {
- keyFn = d.h.fn(ktypeLo, true, true)
+ keyFn = d.h.fn(ktypeLo)
}
- d.decodeValue(rvk, keyFn, true)
+ d.decodeValue(rvk, keyFn)
}
- // special case if a byte array.
+
+ // special case if interface wrapping a byte array.
if ktypeIsIntf {
- if rvk2 := rvk.Elem(); rvk2.IsValid() {
- if rvk2.Type() == uint8SliceTyp {
- rvk = reflect.ValueOf(d.string(rvk2.Bytes()))
- } else {
- rvk = rvk2
- }
+ if rvk2 := rvk.Elem(); rvk2.IsValid() && rvk2.Type() == uint8SliceTyp {
+ rvk.Set(rv4i(d.string(rvGetBytes(rvk2))))
}
+ // NOTE: consider failing early if map/slice/func
}
- if elemsep {
- dd.ReadMapElemValue()
- }
+ d.mapElemValue()
- // Brittle, but OK per TryDecodeAsNil() contract.
- // i.e. TryDecodeAsNil never shares slices with other decDriver procedures
- if dd.TryDecodeAsNil() {
- if ktypeIsString {
- rvk.SetString(d.string(kstrbs))
- }
- if d.h.DeleteOnNilMapValue {
- rv.SetMapIndex(rvk, reflect.Value{})
- } else {
- rv.SetMapIndex(rvk, reflect.Zero(vtype))
+ doMapSet = true // set to false if u do a get, and its a non-nil pointer
+ if doMapGet {
+ if !rvvaSet {
+ rvva = mapAddressableRV(vtype, vtypeKind)
+ rvvaSet = true
}
- continue
- }
-
- mapSet = true // set to false if u do a get, and its a non-nil pointer
- if mapGet {
- // mapGet true only in case where kind=Ptr|Interface or kind is otherwise mutable.
- rvv = rv.MapIndex(rvk)
- if !rvv.IsValid() {
- rvv = reflect.New(vtype).Elem()
- } else if vtypeKind == reflect.Ptr {
- if rvv.IsNil() {
- rvv = reflect.New(vtype).Elem()
+ rvv = mapGet(rv, rvk, rvva) // reflect.Value{})
+ if vtypeKind == reflect.Ptr {
+ if rvv.IsValid() && !rvIsNil(rvv) {
+ doMapSet = false
} else {
- mapSet = false
- }
- } else if vtypeKind == reflect.Interface {
- // not addressable, and thus not settable.
- // e MUST create a settable/addressable variant
- rvv2 := reflect.New(rvv.Type()).Elem()
- if !rvv.IsNil() {
- rvv2.Set(rvv)
+ if vtypeElem == nil {
+ vtypeElem = vtype.Elem()
+ }
+ rvv = reflect.New(vtypeElem)
}
- rvv = rvv2
- }
- // else it is ~mutable, and we can just decode into it directly
- } else if rvvImmut {
- if !rvz.IsValid() {
- rvz = reflect.New(vtype).Elem()
+ } else if rvv.IsValid() && vtypeKind == reflect.Interface && !rvIsNil(rvv) {
+ rvvn = rvZeroAddrK(vtype, vtypeKind)
+ rvvn.Set(rvv)
+ rvv = rvvn
+ } else if rvvMut {
+ rvv = rvZeroAddrK(vtype, vtypeKind)
+ } else {
+ rvv = rvvn
}
- rvv = rvz
+ } else if rvvMut {
+ rvv = rvZeroAddrK(vtype, vtypeKind)
} else {
- rvv = reflect.New(vtype).Elem()
+ rvv = rvvn
}
- // We MUST be done with the stringview of the key, before decoding the value
- // so that we don't bastardize the reused byte array.
- if mapSet && ktypeIsString {
- rvk.SetString(d.string(kstrbs))
- }
if valFn == nil {
- valFn = d.h.fn(vtypeLo, true, true)
+ valFn = d.h.fn(vtypeLo)
+ }
+
+ // We MUST be done with the stringview of the key, BEFORE decoding the value (rvv)
+ // so that we don't unknowingly reuse the rvk backing buffer during rvv decode.
+ if doMapSet && ktypeIsString { // set to a real string (not string view)
+ rvk.SetString(d.string(kstrbs))
}
- d.decodeValue(rvv, valFn, true)
- // d.decodeValueFn(rvv, valFn)
- if mapSet {
- rv.SetMapIndex(rvk, rvv)
+ d.decodeValue(rvv, valFn)
+ if doMapSet {
+ mapSet(rv, rvk, rvv)
}
- // if ktypeIsString {
- // // keepAlive4StringView(kstrbs) // not needed, as reference is outside loop
- // }
}
- dd.ReadMapEnd()
+ d.mapEnd()
- d.depthDecr()
}
// decNaked is used to keep track of the primitives decoded.
@@ -1940,331 +1127,6 @@ type decNaked struct {
// state
v valueType
- _ [6]bool // padding
-
- // ru, ri, rf, rl, rs, rb, rt reflect.Value // mapping to the primitives above
- //
- // _ [3]uint64 // padding
-}
-
-// func (n *decNaked) init() {
-// n.ru = reflect.ValueOf(&n.u).Elem()
-// n.ri = reflect.ValueOf(&n.i).Elem()
-// n.rf = reflect.ValueOf(&n.f).Elem()
-// n.rl = reflect.ValueOf(&n.l).Elem()
-// n.rs = reflect.ValueOf(&n.s).Elem()
-// n.rt = reflect.ValueOf(&n.t).Elem()
-// n.rb = reflect.ValueOf(&n.b).Elem()
-// // n.rr[] = reflect.ValueOf(&n.)
-// }
-
-// type decNakedPooler struct {
-// n *decNaked
-// nsp *sync.Pool
-// }
-
-// // naked must be called before each call to .DecodeNaked, as they will use it.
-// func (d *decNakedPooler) naked() *decNaked {
-// if d.n == nil {
-// // consider one of:
-// // - get from sync.Pool (if GC is frequent, there's no value here)
-// // - new alloc (safest. only init'ed if it a naked decode will be done)
-// // - field in Decoder (makes the Decoder struct very big)
-// // To support using a decoder where a DecodeNaked is not needed,
-// // we prefer #1 or #2.
-// // d.n = new(decNaked) // &d.nv // new(decNaked) // grab from a sync.Pool
-// // d.n.init()
-// var v interface{}
-// d.nsp, v = pool.decNaked()
-// d.n = v.(*decNaked)
-// }
-// return d.n
-// }
-
-// func (d *decNakedPooler) end() {
-// if d.n != nil {
-// // if n != nil, then nsp != nil (they are always set together)
-// d.nsp.Put(d.n)
-// d.n, d.nsp = nil, nil
-// }
-// }
-
-// type rtid2rv struct {
-// rtid uintptr
-// rv reflect.Value
-// }
-
-// --------------
-
-type decReaderSwitch struct {
- rb bytesDecReader
- // ---- cpu cache line boundary?
- ri *ioDecReader
- bi *bufioDecReader
-
- mtr, str bool // whether maptype or slicetype are known types
-
- be bool // is binary encoding
- js bool // is json handle
- jsms bool // is json handle, and MapKeyAsString
- esep bool // has elem separators
-
- // typ entryType
- bytes bool // is bytes reader
- bufio bool // is this a bufioDecReader?
-}
-
-// numread, track and stopTrack are always inlined, as they just check int fields, etc.
-
-/*
-func (z *decReaderSwitch) numread() int {
- switch z.typ {
- case entryTypeBytes:
- return z.rb.numread()
- case entryTypeIo:
- return z.ri.numread()
- default:
- return z.bi.numread()
- }
-}
-func (z *decReaderSwitch) track() {
- switch z.typ {
- case entryTypeBytes:
- z.rb.track()
- case entryTypeIo:
- z.ri.track()
- default:
- z.bi.track()
- }
-}
-func (z *decReaderSwitch) stopTrack() []byte {
- switch z.typ {
- case entryTypeBytes:
- return z.rb.stopTrack()
- case entryTypeIo:
- return z.ri.stopTrack()
- default:
- return z.bi.stopTrack()
- }
-}
-
-func (z *decReaderSwitch) unreadn1() {
- switch z.typ {
- case entryTypeBytes:
- z.rb.unreadn1()
- case entryTypeIo:
- z.ri.unreadn1()
- default:
- z.bi.unreadn1()
- }
-}
-func (z *decReaderSwitch) readx(n int) []byte {
- switch z.typ {
- case entryTypeBytes:
- return z.rb.readx(n)
- case entryTypeIo:
- return z.ri.readx(n)
- default:
- return z.bi.readx(n)
- }
-}
-func (z *decReaderSwitch) readb(s []byte) {
- switch z.typ {
- case entryTypeBytes:
- z.rb.readb(s)
- case entryTypeIo:
- z.ri.readb(s)
- default:
- z.bi.readb(s)
- }
-}
-func (z *decReaderSwitch) readn1() uint8 {
- switch z.typ {
- case entryTypeBytes:
- return z.rb.readn1()
- case entryTypeIo:
- return z.ri.readn1()
- default:
- return z.bi.readn1()
- }
-}
-func (z *decReaderSwitch) skip(accept *bitset256) (token byte) {
- switch z.typ {
- case entryTypeBytes:
- return z.rb.skip(accept)
- case entryTypeIo:
- return z.ri.skip(accept)
- default:
- return z.bi.skip(accept)
- }
-}
-func (z *decReaderSwitch) readTo(in []byte, accept *bitset256) (out []byte) {
- switch z.typ {
- case entryTypeBytes:
- return z.rb.readTo(in, accept)
- case entryTypeIo:
- return z.ri.readTo(in, accept)
- default:
- return z.bi.readTo(in, accept)
- }
-}
-func (z *decReaderSwitch) readUntil(in []byte, stop byte) (out []byte) {
- switch z.typ {
- case entryTypeBytes:
- return z.rb.readUntil(in, stop)
- case entryTypeIo:
- return z.ri.readUntil(in, stop)
- default:
- return z.bi.readUntil(in, stop)
- }
-}
-
-*/
-
-// the if/else-if/else block is expensive to inline.
-// Each node of this construct costs a lot and dominates the budget.
-// Best to only do an if fast-path else block (so fast-path is inlined).
-// This is irrespective of inlineExtraCallCost set in $GOROOT/src/cmd/compile/internal/gc/inl.go
-//
-// In decReaderSwitch methods below, we delegate all IO functions into their own methods.
-// This allows for the inlining of the common path when z.bytes=true.
-// Go 1.12+ supports inlining methods with up to 1 inlined function (or 2 if no other constructs).
-
-func (z *decReaderSwitch) numread() uint {
- if z.bytes {
- return z.rb.numread()
- } else if z.bufio {
- return z.bi.numread()
- } else {
- return z.ri.numread()
- }
-}
-func (z *decReaderSwitch) track() {
- if z.bytes {
- z.rb.track()
- } else if z.bufio {
- z.bi.track()
- } else {
- z.ri.track()
- }
-}
-func (z *decReaderSwitch) stopTrack() []byte {
- if z.bytes {
- return z.rb.stopTrack()
- } else if z.bufio {
- return z.bi.stopTrack()
- } else {
- return z.ri.stopTrack()
- }
-}
-
-// func (z *decReaderSwitch) unreadn1() {
-// if z.bytes {
-// z.rb.unreadn1()
-// } else {
-// z.unreadn1IO()
-// }
-// }
-// func (z *decReaderSwitch) unreadn1IO() {
-// if z.bufio {
-// z.bi.unreadn1()
-// } else {
-// z.ri.unreadn1()
-// }
-// }
-
-func (z *decReaderSwitch) unreadn1() {
- if z.bytes {
- z.rb.unreadn1()
- } else if z.bufio {
- z.bi.unreadn1()
- } else {
- z.ri.unreadn1() // not inlined
- }
-}
-
-func (z *decReaderSwitch) readx(n uint) []byte {
- if z.bytes {
- return z.rb.readx(n)
- }
- return z.readxIO(n)
-}
-func (z *decReaderSwitch) readxIO(n uint) []byte {
- if z.bufio {
- return z.bi.readx(n)
- }
- return z.ri.readx(n)
-}
-
-func (z *decReaderSwitch) readb(s []byte) {
- if z.bytes {
- z.rb.readb(s)
- } else {
- z.readbIO(s)
- }
-}
-
-//go:noinline - fallback for io, ensures z.bytes path is inlined
-func (z *decReaderSwitch) readbIO(s []byte) {
- if z.bufio {
- z.bi.readb(s)
- } else {
- z.ri.readb(s)
- }
-}
-
-func (z *decReaderSwitch) readn1() uint8 {
- if z.bytes {
- return z.rb.readn1()
- }
- return z.readn1IO()
-}
-func (z *decReaderSwitch) readn1IO() uint8 {
- if z.bufio {
- return z.bi.readn1()
- }
- return z.ri.readn1()
-}
-
-func (z *decReaderSwitch) skip(accept *bitset256) (token byte) {
- if z.bytes {
- return z.rb.skip(accept)
- }
- return z.skipIO(accept)
-}
-func (z *decReaderSwitch) skipIO(accept *bitset256) (token byte) {
- if z.bufio {
- return z.bi.skip(accept)
- }
- return z.ri.skip(accept)
-}
-
-func (z *decReaderSwitch) readTo(in []byte, accept *bitset256) (out []byte) {
- if z.bytes {
- return z.rb.readToNoInput(accept) // z.rb.readTo(in, accept)
- }
- return z.readToIO(in, accept)
-}
-
-//go:noinline - fallback for io, ensures z.bytes path is inlined
-func (z *decReaderSwitch) readToIO(in []byte, accept *bitset256) (out []byte) {
- if z.bufio {
- return z.bi.readTo(in, accept)
- }
- return z.ri.readTo(in, accept)
-}
-func (z *decReaderSwitch) readUntil(in []byte, stop byte) (out []byte) {
- if z.bytes {
- return z.rb.readUntilNoInput(stop)
- }
- return z.readUntilIO(in, stop)
-}
-
-func (z *decReaderSwitch) readUntilIO(in []byte, stop byte) (out []byte) {
- if z.bufio {
- return z.bi.readUntil(in, stop)
- }
- return z.ri.readUntil(in, stop)
}
// Decoder reads and decodes an object from an input stream in a supported format.
@@ -2282,39 +1144,44 @@ type Decoder struct {
d decDriver
- // NOTE: Decoder shouldn't call it's read methods,
- // as the handler MAY need to do some coordination.
- r *decReaderSwitch
-
- // bi *bufioDecReader
// cache the mapTypeId and sliceTypeId for faster comparisons
mtid uintptr
stid uintptr
- hh Handle
- h *BasicHandle
+ h *BasicHandle
+
+ blist bytesFreelist
// ---- cpu cache line boundary?
- decReaderSwitch
+ decRd
// ---- cpu cache line boundary?
n decNaked
- // cr containerStateRecv
+ hh Handle
err error
- depth int16
+ // ---- cpu cache line boundary?
+ is map[string]string // used for interning strings
+
+ // ---- writable fields during execution --- *try* to keep in sep cache line
maxdepth int16
+ depth int16
- _ [4]uint8 // padding
+ // Extensions can call Decode() within a current Decode() call.
+ // We need to know when the top level Decode() call returns,
+ // so we can decide whether to Release() or not.
+ calls uint16 // what depth in mustDecode are we in now.
- is map[string]string // used for interning strings
+ c containerState
+ _ [1]byte // padding
// ---- cpu cache line boundary?
- b [decScratchByteArrayLen]byte // scratch buffer, used by Decoder and xxxEncDrivers
- // padding - false sharing help // modify 232 if Decoder struct changes.
- // _ [cacheLineSize - 232%cacheLineSize]byte
+ // b is an always-available scratch buffer used by Decoder and decDrivers.
+ // By being always-available, it can be used for one-off things without
+ // having to get from freelist, use, and return back to freelist.
+ b [decScratchByteArrayLen]byte
}
// NewDecoder returns a Decoder for decoding a stream of bytes from an io.Reader.
@@ -2322,7 +1189,7 @@ type Decoder struct {
// For efficiency, Users are encouraged to configure ReaderBufferSize on the handle
// OR pass in a memory buffered reader (eg bufio.Reader, bytes.Buffer).
func NewDecoder(r io.Reader, h Handle) *Decoder {
- d := newDecoder(h)
+ d := h.newDecDriver().decoder()
d.Reset(r)
return d
}
@@ -2330,43 +1197,32 @@ func NewDecoder(r io.Reader, h Handle) *Decoder {
// NewDecoderBytes returns a Decoder which efficiently decodes directly
// from a byte slice with zero copying.
func NewDecoderBytes(in []byte, h Handle) *Decoder {
- d := newDecoder(h)
+ d := h.newDecDriver().decoder()
d.ResetBytes(in)
return d
}
-// var defaultDecNaked decNaked
+func (d *Decoder) r() *decRd {
+ return &d.decRd
+}
-func newDecoder(h Handle) *Decoder {
- d := &Decoder{h: basicHandle(h), err: errDecoderNotInitialized}
+func (d *Decoder) init(h Handle) {
d.bytes = true
- if useFinalizers {
- runtime.SetFinalizer(d, (*Decoder).finalize)
- // xdebugf(">>>> new(Decoder) with finalizer")
- }
- d.r = &d.decReaderSwitch
+ d.err = errDecoderNotInitialized
+ d.h = basicHandle(h)
d.hh = h
d.be = h.isBinary()
// NOTE: do not initialize d.n here. It is lazily initialized in d.naked()
- var jh *JsonHandle
- jh, d.js = h.(*JsonHandle)
- if d.js {
- d.jsms = jh.MapKeyAsString
- }
- d.esep = d.hh.hasElemSeparators()
if d.h.InternString {
d.is = make(map[string]string, 32)
}
- d.d = h.newDecDriver(d)
- // d.cr, _ = d.d.(containerStateRecv)
- return d
}
func (d *Decoder) resetCommon() {
- // d.r = &d.decReaderSwitch
d.d.reset()
d.err = nil
d.depth = 0
+ d.calls = 0
d.maxdepth = d.h.MaxDepth
if d.maxdepth <= 0 {
d.maxdepth = decDefMaxDepth
@@ -2391,24 +1247,17 @@ func (d *Decoder) Reset(r io.Reader) {
return
}
d.bytes = false
- // d.typ = entryTypeUnset
if d.h.ReaderBufferSize > 0 {
if d.bi == nil {
d.bi = new(bufioDecReader)
}
- d.bi.reset(r, d.h.ReaderBufferSize)
- // d.r = d.bi
- // d.typ = entryTypeBufio
+ d.bi.reset(r, d.h.ReaderBufferSize, &d.blist)
d.bufio = true
} else {
- // d.ri.x = &d.b
- // d.s = d.sa[:0]
if d.ri == nil {
d.ri = new(ioDecReader)
}
- d.ri.reset(r)
- // d.r = d.ri
- // d.typ = entryTypeIo
+ d.ri.reset(r, &d.blist)
d.bufio = false
}
d.resetCommon()
@@ -2422,9 +1271,7 @@ func (d *Decoder) ResetBytes(in []byte) {
}
d.bytes = true
d.bufio = false
- // d.typ = entryTypeBytes
d.rb.reset(in)
- // d.r = &d.rb
d.resetCommon()
}
@@ -2506,7 +1353,9 @@ func (d *Decoder) Decode(v interface{}) (err error) {
defer func() {
if x := recover(); x != nil {
panicValToErr(d, x, &d.err)
- err = d.err
+ if d.err != err {
+ err = d.err
+ }
}
}()
}
@@ -2528,105 +1377,58 @@ func (d *Decoder) MustDecode(v interface{}) {
// MustDecode is like Decode, but panics if unable to Decode.
// This provides insight to the code location that triggered the error.
func (d *Decoder) mustDecode(v interface{}) {
- // TODO: Top-level: ensure that v is a pointer and not nil.
- if d.d.TryDecodeAsNil() {
- setZero(v)
- return
- }
- if d.bi == nil {
- d.decode(v)
- return
- }
+ // Top-level: v is a pointer and not nil.
- d.bi.calls++
+ d.calls++
d.decode(v)
- // xprintf(">>>>>>>> >>>>>>>> num decFns: %v\n", d.cf.sn)
- d.bi.calls--
- if !d.h.ExplicitRelease && d.bi.calls == 0 {
- d.bi.release()
+ d.calls--
+ if d.calls == 0 {
+ d.d.atEndOfDecode()
}
}
-// func (d *Decoder) deferred(err1 *error) {
-// if recoverPanicToErr {
-// if x := recover(); x != nil {
-// panicValToErr(d, x, err1)
-// panicValToErr(d, x, &d.err)
-// }
-// }
-// }
-
-//go:noinline -- as it is run by finalizer
-func (d *Decoder) finalize() {
- // xdebugf("finalizing Decoder")
- d.Release()
-}
-
// Release releases shared (pooled) resources.
//
// It is important to call Release() when done with a Decoder, so those resources
// are released instantly for use by subsequently created Decoders.
//
// By default, Release() is automatically called unless the option ExplicitRelease is set.
+//
+// Deprecated: Release is a no-op as pooled resources are not used with an Decoder.
+// This method is kept for compatibility reasons only.
func (d *Decoder) Release() {
- if d.bi != nil {
- d.bi.release()
- }
- // d.decNakedPooler.end()
}
-// // this is not a smart swallow, as it allocates objects and does unnecessary work.
-// func (d *Decoder) swallowViaHammer() {
-// var blank interface{}
-// d.decodeValueNoFn(reflect.ValueOf(&blank).Elem())
-// }
-
func (d *Decoder) swallow() {
- // smarter decode that just swallows the content
- dd := d.d
- if dd.TryDecodeAsNil() {
- return
- }
- elemsep := d.esep
- switch dd.ContainerType() {
+ switch d.d.ContainerType() {
+ case valueTypeNil:
case valueTypeMap:
- containerLen := dd.ReadMapStart()
- d.depthIncr()
+ containerLen := d.mapStart()
hasLen := containerLen >= 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- // if clenGtEqualZero {if j >= containerLen {break} } else if dd.CheckBreak() {break}
- if elemsep {
- dd.ReadMapElemKey()
- }
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
d.swallow()
- if elemsep {
- dd.ReadMapElemValue()
- }
+ d.mapElemValue()
d.swallow()
}
- dd.ReadMapEnd()
- d.depthDecr()
+ d.mapEnd()
case valueTypeArray:
- containerLen := dd.ReadArrayStart()
- d.depthIncr()
+ containerLen := d.arrayStart()
hasLen := containerLen >= 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if elemsep {
- dd.ReadArrayElem()
- }
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.arrayElem()
d.swallow()
}
- dd.ReadArrayEnd()
- d.depthDecr()
+ d.arrayEnd()
case valueTypeBytes:
- dd.DecodeBytes(d.b[:], true)
+ d.d.DecodeBytes(d.b[:], true)
case valueTypeString:
- dd.DecodeStringAsBytes()
+ d.d.DecodeStringAsBytes()
default:
// these are all primitives, which we can get from decodeNaked
// if RawExt using Value, complete the processing.
n := d.naked()
- dd.DecodeNaked()
+ d.d.DecodeNaked()
if n.v == valueTypeExt && n.l == nil {
var v2 interface{}
d.decode(&v2)
@@ -2635,10 +1437,13 @@ func (d *Decoder) swallow() {
}
func setZero(iv interface{}) {
- if iv == nil || definitelyNil(iv) {
+ if iv == nil {
+ return
+ }
+ if _, ok := isNil(iv); ok {
return
}
- var canDecode bool
+ // var canDecode bool
switch v := iv.(type) {
case *string:
*v = ""
@@ -2675,15 +1480,29 @@ func setZero(iv interface{}) {
case *time.Time:
*v = time.Time{}
case reflect.Value:
- if v, canDecode = isDecodeable(v); canDecode && v.CanSet() {
- v.Set(reflect.Zero(v.Type()))
- } // TODO: else drain if chan, clear if map, set all to nil if slice???
+ setZeroRV(v)
default:
if !fastpathDecodeSetZeroTypeSwitch(iv) {
- v := reflect.ValueOf(iv)
- if v, canDecode = isDecodeable(v); canDecode && v.CanSet() {
- v.Set(reflect.Zero(v.Type()))
- } // TODO: else drain if chan, clear if map, set all to nil if slice???
+ setZeroRV(rv4i(iv))
+ }
+ }
+}
+
+func setZeroRV(v reflect.Value) {
+ // It not decodeable, we do not touch it.
+ // We considered empty'ing it if not decodeable e.g.
+ // - if chan, drain it
+ // - if map, clear it
+ // - if slice or array, zero all elements up to len
+ //
+ // However, we decided instead that we either will set the
+ // whole value to the zero value, or leave AS IS.
+ if isDecodeable(v) {
+ if v.Kind() == reflect.Ptr {
+ v = v.Elem()
+ }
+ if v.CanSet() {
+ v.Set(reflect.Zero(v.Type()))
}
}
}
@@ -2701,11 +1520,11 @@ func (d *Decoder) decode(iv interface{}) {
// case nil:
// case Selfer:
case reflect.Value:
- v = d.ensureDecodeable(v)
- d.decodeValue(v, nil, true)
+ d.ensureDecodeable(v)
+ d.decodeValue(v, nil)
case *string:
- *v = d.d.DecodeString()
+ *v = string(d.d.DecodeStringAsBytes())
case *bool:
*v = d.d.DecodeBool()
case *int:
@@ -2729,11 +1548,7 @@ func (d *Decoder) decode(iv interface{}) {
case *uint64:
*v = d.d.DecodeUint64()
case *float32:
- f64 := d.d.DecodeFloat64()
- if chkOvf.Float32(f64) {
- d.errorf("float32 overflow: %v", f64)
- }
- *v = float32(f64)
+ *v = float32(d.decodeFloat32())
case *float64:
*v = d.d.DecodeFloat64()
case *[]uint8:
@@ -2749,43 +1564,48 @@ func (d *Decoder) decode(iv interface{}) {
*v = d.rawBytes()
case *interface{}:
- d.decodeValue(reflect.ValueOf(iv).Elem(), nil, true)
- // d.decodeValueNotNil(reflect.ValueOf(iv).Elem())
+ d.decodeValue(rv4i(iv), nil)
default:
if v, ok := iv.(Selfer); ok {
v.CodecDecodeSelf(d)
} else if !fastpathDecodeTypeSwitch(iv, d) {
- v := reflect.ValueOf(iv)
- v = d.ensureDecodeable(v)
- d.decodeValue(v, nil, false)
- // d.decodeValueFallback(v)
+ v := rv4i(iv)
+ d.ensureDecodeable(v)
+ d.decodeValue(v, nil)
}
}
}
-func (d *Decoder) decodeValue(rv reflect.Value, fn *codecFn, chkAll bool) {
+// decodeValue MUST be called by the actual value we want to decode into,
+// not its addr or a reference to it.
+//
+// This way, we know if it is itself a pointer, and can handle nil in
+// the stream effectively.
+func (d *Decoder) decodeValue(rv reflect.Value, fn *codecFn) {
// If stream is not containing a nil value, then we can deref to the base
// non-pointer value, and decode into that.
var rvp reflect.Value
var rvpValid bool
if rv.Kind() == reflect.Ptr {
+ if d.d.TryNil() {
+ if rvelem := rv.Elem(); rvelem.CanSet() {
+ rvelem.Set(reflect.Zero(rvelem.Type()))
+ }
+ return
+ }
rvpValid = true
- for {
- if rv.IsNil() {
- rv.Set(reflect.New(rv.Type().Elem()))
+ for rv.Kind() == reflect.Ptr {
+ if rvIsNil(rv) {
+ rvSetDirect(rv, reflect.New(rv.Type().Elem()))
}
rvp = rv
rv = rv.Elem()
- if rv.Kind() != reflect.Ptr {
- break
- }
}
}
if fn == nil {
- // always pass checkCodecSelfer=true, in case T or ****T is passed, where *T is a Selfer
- fn = d.h.fn(rv.Type(), chkAll, true) // chkAll, chkAll)
+ fn = d.h.fn(rv.Type())
}
if fn.i.addrD {
if rvpValid {
@@ -2800,7 +1620,6 @@ func (d *Decoder) decodeValue(rv reflect.Value, fn *codecFn, chkAll bool) {
} else {
fn.fd(d, &fn.i, rv)
}
- // return rv
}
func (d *Decoder) structFieldNotFound(index int, rvkencname string) {
@@ -2823,31 +1642,30 @@ func (d *Decoder) arrayCannotExpand(sliceLen, streamLen int) {
}
}
-func isDecodeable(rv reflect.Value) (rv2 reflect.Value, canDecode bool) {
+func isDecodeable(rv reflect.Value) (canDecode bool) {
switch rv.Kind() {
case reflect.Array:
- return rv, rv.CanAddr()
+ return rv.CanAddr()
case reflect.Ptr:
- if !rv.IsNil() {
- return rv.Elem(), true
+ if !rvIsNil(rv) {
+ return true
}
case reflect.Slice, reflect.Chan, reflect.Map:
- if !rv.IsNil() {
- return rv, true
+ if !rvIsNil(rv) {
+ return true
}
}
return
}
-func (d *Decoder) ensureDecodeable(rv reflect.Value) (rv2 reflect.Value) {
+func (d *Decoder) ensureDecodeable(rv reflect.Value) {
// decode can take any reflect.Value that is a inherently addressable i.e.
// - array
// - non-nil chan (we will SEND to it)
// - non-nil slice (we will set its elements)
// - non-nil map (we will put into it)
// - non-nil pointer (we can "update" it)
- rv2, canDecode := isDecodeable(rv)
- if canDecode {
+ if isDecodeable(rv) {
return
}
if !rv.IsValid() {
@@ -2860,8 +1678,7 @@ func (d *Decoder) ensureDecodeable(rv reflect.Value) (rv2 reflect.Value) {
}
rvi := rv2i(rv)
rvk := rv.Kind()
- d.errorf("cannot decode into value of kind: %v, type: %T, %v", rvk, rvi, rvi)
- return
+ d.errorf("cannot decode into value of kind: %v, type: %T, %#v", rvk, rvi, rvi)
}
func (d *Decoder) depthIncr() {
@@ -2880,6 +1697,9 @@ func (d *Decoder) depthDecr() {
// This should mostly be used for map keys, where the key type is string.
// This is because keys of a map/struct are typically reused across many objects.
func (d *Decoder) string(v []byte) (s string) {
+ if v == nil {
+ return
+ }
if d.is == nil {
return string(v) // don't return stringView, as we need a real string here.
}
@@ -2888,15 +1708,15 @@ func (d *Decoder) string(v []byte) (s string) {
s = string(v) // new allocation here
d.is[s] = s
}
- return s
+ return
}
// nextValueBytes returns the next value in the stream as a set of bytes.
func (d *Decoder) nextValueBytes() (bs []byte) {
d.d.uncacheRead()
- d.r.track()
+ d.r().track()
d.swallow()
- bs = d.r.stopTrack()
+ bs = d.r().stopTrack()
return
}
@@ -2910,60 +1730,180 @@ func (d *Decoder) rawBytes() []byte {
}
func (d *Decoder) wrapErr(v interface{}, err *error) {
- *err = decodeError{codecError: codecError{name: d.hh.Name(), err: v}, pos: int(d.r.numread())}
+ *err = decodeError{codecError: codecError{name: d.hh.Name(), err: v}, pos: d.NumBytesRead()}
}
// NumBytesRead returns the number of bytes read
func (d *Decoder) NumBytesRead() int {
- return int(d.r.numread())
+ return int(d.r().numread())
+}
+
+// decodeFloat32 will delegate to an appropriate DecodeFloat32 implementation (if exists),
+// else if will call DecodeFloat64 and ensure the value doesn't overflow.
+//
+// Note that we return float64 to reduce unnecessary conversions
+func (d *Decoder) decodeFloat32() float32 {
+ if d.js {
+ return d.jsondriver().DecodeFloat32() // custom implementation for 32-bit
+ }
+ return float32(chkOvf.Float32V(d.d.DecodeFloat64()))
+}
+
+// ---- container tracking
+// Note: We update the .c after calling the callback.
+// This way, the callback can know what the last status was.
+
+// Note: if you call mapStart and it returns decContainerLenNil,
+// then do NOT call mapEnd.
+
+func (d *Decoder) mapStart() (v int) {
+ v = d.d.ReadMapStart()
+ if v != decContainerLenNil {
+ d.depthIncr()
+ d.c = containerMapStart
+ }
+ return
+}
+
+func (d *Decoder) mapElemKey() {
+ if d.js {
+ d.jsondriver().ReadMapElemKey()
+ }
+ d.c = containerMapKey
+}
+
+func (d *Decoder) mapElemValue() {
+ if d.js {
+ d.jsondriver().ReadMapElemValue()
+ }
+ d.c = containerMapValue
+}
+
+func (d *Decoder) mapEnd() {
+ d.d.ReadMapEnd()
+ d.depthDecr()
+ // d.c = containerMapEnd
+ d.c = 0
+}
+
+func (d *Decoder) arrayStart() (v int) {
+ v = d.d.ReadArrayStart()
+ if v != decContainerLenNil {
+ d.depthIncr()
+ d.c = containerArrayStart
+ }
+ return
+}
+
+func (d *Decoder) arrayElem() {
+ if d.js {
+ d.jsondriver().ReadArrayElem()
+ }
+ d.c = containerArrayElem
+}
+
+func (d *Decoder) arrayEnd() {
+ d.d.ReadArrayEnd()
+ d.depthDecr()
+ // d.c = containerArrayEnd
+ d.c = 0
+}
+
+func (d *Decoder) interfaceExtConvertAndDecode(v interface{}, ext Ext) {
+ // var v interface{} = ext.ConvertExt(rv)
+ // d.d.decode(&v)
+ // ext.UpdateExt(rv, v)
+
+ // assume v is a pointer:
+ // - if struct|array, pass as is to ConvertExt
+ // - else make it non-addressable and pass to ConvertExt
+ // - make return value from ConvertExt addressable
+ // - decode into it
+ // - return the interface for passing into UpdateExt.
+ // - interface should be a pointer if struct|array, else a value
+
+ var s interface{}
+ rv := rv4i(v)
+ rv2 := rv.Elem()
+ rvk := rv2.Kind()
+ if rvk == reflect.Struct || rvk == reflect.Array {
+ s = ext.ConvertExt(v)
+ } else {
+ s = ext.ConvertExt(rv2i(rv2))
+ }
+ rv = rv4i(s)
+ if !rv.CanAddr() {
+ if rv.Kind() == reflect.Ptr {
+ rv2 = reflect.New(rv.Type().Elem())
+ } else {
+ rv2 = rvZeroAddrK(rv.Type(), rv.Kind())
+ }
+ rvSetDirect(rv2, rv)
+ rv = rv2
+ }
+ d.decodeValue(rv, nil)
+ ext.UpdateExt(v, rv2i(rv))
+}
+
+func (d *Decoder) sideDecode(v interface{}, bs []byte) {
+ rv := baseRV(v)
+ NewDecoderBytes(bs, d.hh).decodeValue(rv, d.h.fnNoExt(rv.Type()))
}
// --------------------------------------------------
// decSliceHelper assists when decoding into a slice, from a map or an array in the stream.
// A slice can be set from a map or array in stream. This supports the MapBySlice interface.
+//
+// Note: if IsNil, do not call ElemContainerState.
type decSliceHelper struct {
- d *Decoder
- // ct valueType
- array bool
+ d *Decoder
+ ct valueType
+ Array bool
+ IsNil bool
}
func (d *Decoder) decSliceHelperStart() (x decSliceHelper, clen int) {
- dd := d.d
- ctyp := dd.ContainerType()
- switch ctyp {
+ x.ct = d.d.ContainerType()
+ x.d = d
+ switch x.ct {
+ case valueTypeNil:
+ x.IsNil = true
case valueTypeArray:
- x.array = true
- clen = dd.ReadArrayStart()
+ x.Array = true
+ clen = d.arrayStart()
case valueTypeMap:
- clen = dd.ReadMapStart() * 2
+ clen = d.mapStart() * 2
default:
- d.errorf("only encoded map or array can be decoded into a slice (%d)", ctyp)
+ d.errorf("only encoded map or array can be decoded into a slice (%d)", x.ct)
}
- // x.ct = ctyp
- x.d = d
return
}
func (x decSliceHelper) End() {
- if x.array {
- x.d.d.ReadArrayEnd()
+ if x.IsNil {
+ } else if x.Array {
+ x.d.arrayEnd()
} else {
- x.d.d.ReadMapEnd()
+ x.d.mapEnd()
}
}
func (x decSliceHelper) ElemContainerState(index int) {
- if x.array {
- x.d.d.ReadArrayElem()
- } else if index%2 == 0 {
- x.d.d.ReadMapElemKey()
+ // Note: if isnil, clen=0, so we never call into ElemContainerState
+
+ if x.Array {
+ x.d.arrayElem()
} else {
- x.d.d.ReadMapElemValue()
+ if index%2 == 0 {
+ x.d.mapElemKey()
+ } else {
+ x.d.mapElemValue()
+ }
}
}
-func decByteSlice(r *decReaderSwitch, clen, maxInitLen int, bs []byte) (bsOut []byte) {
+func decByteSlice(r *decRd, clen, maxInitLen int, bs []byte) (bsOut []byte) {
if clen == 0 {
return zeroByteSlice
}
@@ -2974,7 +1914,6 @@ func decByteSlice(r *decReaderSwitch, clen, maxInitLen int, bs []byte) (bsOut []
bsOut = bs[:clen]
r.readb(bsOut)
} else {
- // bsOut = make([]byte, clen)
len2 := decInferLen(clen, maxInitLen, 1)
bsOut = make([]byte, len2)
r.readb(bsOut)
@@ -2990,24 +1929,29 @@ func decByteSlice(r *decReaderSwitch, clen, maxInitLen int, bs []byte) (bsOut []
return
}
-// func decByteSliceZeroCopy(r decReader, clen, maxInitLen int, bs []byte) (bsOut []byte) {
-// if _, ok := r.(*bytesDecReader); ok && clen <= maxInitLen {
-// return r.readx(clen)
-// }
-// return decByteSlice(r, clen, maxInitLen, bs)
-// }
-
+// detachZeroCopyBytes will copy the in bytes into dest,
+// or create a new one if not large enough.
+//
+// It is used to ensure that the []byte returned is not
+// part of the input stream or input stream buffers.
func detachZeroCopyBytes(isBytesReader bool, dest []byte, in []byte) (out []byte) {
- if xlen := len(in); xlen > 0 {
- if isBytesReader || xlen <= scratchByteArrayLen {
- if cap(dest) >= xlen {
- out = dest[:xlen]
- } else {
- out = make([]byte, xlen)
- }
- copy(out, in)
- return
+ if len(in) > 0 {
+ // if isBytesReader || len(in) <= scratchByteArrayLen {
+ // if cap(dest) >= len(in) {
+ // out = dest[:len(in)]
+ // } else {
+ // out = make([]byte, len(in))
+ // }
+ // copy(out, in)
+ // return
+ // }
+ if cap(dest) >= len(in) {
+ out = dest[:len(in)]
+ } else {
+ out = make([]byte, len(in))
}
+ copy(out, in)
+ return
}
return in
}
@@ -3018,10 +1962,24 @@ func detachZeroCopyBytes(isBytesReader bool, dest []byte, in []byte) (out []byte
// if <= 0, it is unset, and we infer it based on the unit size
// - unit: number of bytes for each element of the collection
func decInferLen(clen, maxlen, unit int) (rvlen int) {
+ const maxLenIfUnset = 8 // 64
// handle when maxlen is not set i.e. <= 0
- if clen <= 0 {
+
+ // clen==0: use 0
+ // maxlen<=0, clen<0: use default
+ // maxlen> 0, clen<0: use default
+ // maxlen<=0, clen>0: infer maxlen, and cap on it
+ // maxlen> 0, clen>0: cap at maxlen
+
+ if clen == 0 {
return
}
+ if clen < 0 {
+ if clen == decContainerLenNil {
+ return 0
+ }
+ return maxLenIfUnset
+ }
if unit == 0 {
return clen
}
@@ -3036,6 +1994,9 @@ func decInferLen(clen, maxlen, unit int) (rvlen int) {
} else {
maxlen = 4 * 1024
}
+ // if maxlen > maxLenIfUnset {
+ // maxlen = maxLenIfUnset
+ // }
}
if clen > maxlen {
rvlen = maxlen
@@ -3045,37 +2006,6 @@ func decInferLen(clen, maxlen, unit int) (rvlen int) {
return
}
-func expandSliceRV(s reflect.Value, st reflect.Type, canChange bool, stElemSize, num, slen, scap int) (
- s2 reflect.Value, scap2 int, changed bool, err string) {
- l1 := slen + num // new slice length
- if l1 < slen {
- err = errmsgExpandSliceOverflow
- return
- }
- if l1 <= scap {
- if s.CanSet() {
- s.SetLen(l1)
- } else if canChange {
- s2 = s.Slice(0, l1)
- scap2 = scap
- changed = true
- } else {
- err = errmsgExpandSliceCannotChange
- return
- }
- return
- }
- if !canChange {
- err = errmsgExpandSliceCannotChange
- return
- }
- scap2 = growCap(scap, stElemSize, num)
- s2 = reflect.MakeSlice(st, l1, scap2)
- changed = true
- reflect.Copy(s2, s)
- return
-}
-
func decReadFull(r io.Reader, bs []byte) (n uint, err error) {
var nn int
for n < uint(len(bs)) && err == nil {
@@ -3088,8 +2018,17 @@ func decReadFull(r io.Reader, bs []byte) (n uint, err error) {
n += uint(nn)
}
}
- // xdebugf("decReadFull: len(bs): %v, n: %v, err: %v", len(bs), n, err)
// do not do this - it serves no purpose
// if n != len(bs) && err == io.EOF { err = io.ErrUnexpectedEOF }
return
}
+
+func decNakedReadRawBytes(dr decDriver, d *Decoder, n *decNaked, rawToString bool) {
+ if rawToString {
+ n.v = valueTypeString
+ n.s = string(dr.DecodeBytes(d.b[:], true))
+ } else {
+ n.v = valueTypeBytes
+ n.l = dr.DecodeBytes(nil, false)
+ }
+}
diff --git a/vendor/github.com/ugorji/go/codec/encode.go b/vendor/github.com/ugorji/go/codec/encode.go
index 4723a21..351dd2d 100644
--- a/vendor/github.com/ugorji/go/codec/encode.go
+++ b/vendor/github.com/ugorji/go/codec/encode.go
@@ -9,7 +9,6 @@ import (
"fmt"
"io"
"reflect"
- "runtime"
"sort"
"strconv"
"time"
@@ -21,22 +20,6 @@ const defEncByteBufSize = 1 << 10 // 4:16, 6:64, 8:256, 10:1024
var errEncoderNotInitialized = errors.New("Encoder not initialized")
-/*
-
-// encWriter abstracts writing to a byte array or to an io.Writer.
-//
-//
-// Deprecated: Use encWriterSwitch instead.
-type encWriter interface {
- writeb([]byte)
- writestr(string)
- writen1(byte)
- writen2(byte, byte)
- end()
-}
-
-*/
-
// encDriver abstracts the actual codec (binc vs msgpack, etc)
type encDriver interface {
EncodeNil()
@@ -45,34 +28,26 @@ type encDriver interface {
EncodeBool(b bool)
EncodeFloat32(f float32)
EncodeFloat64(f float64)
- // encodeExtPreamble(xtag byte, length int)
- EncodeRawExt(re *RawExt, e *Encoder)
- EncodeExt(v interface{}, xtag uint64, ext Ext, e *Encoder)
- // Deprecated: try to use EncodeStringEnc instead
- EncodeString(c charEncoding, v string)
- // c cannot be cRAW
- EncodeStringEnc(c charEncoding, v string)
- // EncodeSymbol(v string)
- // Deprecated: try to use EncodeStringBytesRaw instead
- EncodeStringBytes(c charEncoding, v []byte)
+ EncodeRawExt(re *RawExt)
+ EncodeExt(v interface{}, xtag uint64, ext Ext)
+ // EncodeString using cUTF8, honor'ing StringToRaw flag
+ EncodeString(v string)
EncodeStringBytesRaw(v []byte)
EncodeTime(time.Time)
- //encBignum(f *big.Int)
- //encStringRunes(c charEncoding, v []rune)
WriteArrayStart(length int)
- WriteArrayElem()
WriteArrayEnd()
WriteMapStart(length int)
- WriteMapElemKey()
- WriteMapElemValue()
WriteMapEnd()
reset()
atEndOfEncode()
+ encoder() *Encoder
}
-type encDriverAsis interface {
- EncodeAsis(v []byte)
+type encDriverContainerTracker interface {
+ WriteArrayElem()
+ WriteMapElemKey()
+ WriteMapElemValue()
}
type encodeError struct {
@@ -86,33 +61,11 @@ func (e encodeError) Error() string {
type encDriverNoopContainerWriter struct{}
func (encDriverNoopContainerWriter) WriteArrayStart(length int) {}
-func (encDriverNoopContainerWriter) WriteArrayElem() {}
func (encDriverNoopContainerWriter) WriteArrayEnd() {}
func (encDriverNoopContainerWriter) WriteMapStart(length int) {}
-func (encDriverNoopContainerWriter) WriteMapElemKey() {}
-func (encDriverNoopContainerWriter) WriteMapElemValue() {}
func (encDriverNoopContainerWriter) WriteMapEnd() {}
func (encDriverNoopContainerWriter) atEndOfEncode() {}
-type encDriverTrackContainerWriter struct {
- c containerState
-}
-
-func (e *encDriverTrackContainerWriter) WriteArrayStart(length int) { e.c = containerArrayStart }
-func (e *encDriverTrackContainerWriter) WriteArrayElem() { e.c = containerArrayElem }
-func (e *encDriverTrackContainerWriter) WriteArrayEnd() { e.c = containerArrayEnd }
-func (e *encDriverTrackContainerWriter) WriteMapStart(length int) { e.c = containerMapStart }
-func (e *encDriverTrackContainerWriter) WriteMapElemKey() { e.c = containerMapKey }
-func (e *encDriverTrackContainerWriter) WriteMapElemValue() { e.c = containerMapValue }
-func (e *encDriverTrackContainerWriter) WriteMapEnd() { e.c = containerMapEnd }
-func (e *encDriverTrackContainerWriter) atEndOfEncode() {}
-
-// type ioEncWriterWriter interface {
-// WriteByte(c byte) error
-// WriteString(s string) (n int, err error)
-// Write(p []byte) (n int, err error)
-// }
-
// EncodeOptions captures configuration options during encode.
type EncodeOptions struct {
// WriterBufferSize is the size of the buffer used when writing.
@@ -169,6 +122,19 @@ type EncodeOptions struct {
// If unset, we error out.
Raw bool
+ // StringToRaw controls how strings are encoded.
+ //
+ // As a go string is just an (immutable) sequence of bytes,
+ // it can be encoded either as raw bytes or as a UTF string.
+ //
+ // By default, strings are encoded as UTF-8.
+ // but can be treated as []byte during an encode.
+ //
+ // Note that things which we know (by definition) to be UTF-8
+ // are ALWAYS encoded as UTF-8 strings.
+ // These include encoding.TextMarshaler, time.Format calls, struct field names, etc.
+ StringToRaw bool
+
// // AsSymbols defines what should be encoded as symbols.
// //
// // Encoding as symbols can reduce the encoded size significantly.
@@ -187,264 +153,99 @@ type EncodeOptions struct {
// ---------------------------------------------
-/*
-
-type ioEncStringWriter interface {
- WriteString(s string) (n int, err error)
-}
-
-// ioEncWriter implements encWriter and can write to an io.Writer implementation
-type ioEncWriter struct {
- w io.Writer
- ww io.Writer
- bw io.ByteWriter
- sw ioEncStringWriter
- fw ioFlusher
- b [8]byte
-}
-
-func (z *ioEncWriter) reset(w io.Writer) {
- z.w = w
- var ok bool
- if z.bw, ok = w.(io.ByteWriter); !ok {
- z.bw = z
- }
- if z.sw, ok = w.(ioEncStringWriter); !ok {
- z.sw = z
- }
- z.fw, _ = w.(ioFlusher)
- z.ww = w
-}
-
-func (z *ioEncWriter) WriteByte(b byte) (err error) {
- z.b[0] = b
- _, err = z.w.Write(z.b[:1])
- return
-}
-
-func (z *ioEncWriter) WriteString(s string) (n int, err error) {
- return z.w.Write(bytesView(s))
-}
-
-func (z *ioEncWriter) writeb(bs []byte) {
- if _, err := z.ww.Write(bs); err != nil {
- panic(err)
- }
+func (e *Encoder) rawExt(f *codecFnInfo, rv reflect.Value) {
+ e.e.EncodeRawExt(rv2i(rv).(*RawExt))
}
-func (z *ioEncWriter) writestr(s string) {
- if _, err := z.sw.WriteString(s); err != nil {
- panic(err)
- }
+func (e *Encoder) ext(f *codecFnInfo, rv reflect.Value) {
+ e.e.EncodeExt(rv2i(rv), f.xfTag, f.xfFn)
}
-func (z *ioEncWriter) writen1(b byte) {
- if err := z.bw.WriteByte(b); err != nil {
- panic(err)
- }
+func (e *Encoder) selferMarshal(f *codecFnInfo, rv reflect.Value) {
+ rv2i(rv).(Selfer).CodecEncodeSelf(e)
}
-func (z *ioEncWriter) writen2(b1, b2 byte) {
- var err error
- if err = z.bw.WriteByte(b1); err == nil {
- if err = z.bw.WriteByte(b2); err == nil {
- return
- }
- }
- panic(err)
+func (e *Encoder) binaryMarshal(f *codecFnInfo, rv reflect.Value) {
+ bs, fnerr := rv2i(rv).(encoding.BinaryMarshaler).MarshalBinary()
+ e.marshalRaw(bs, fnerr)
}
-// func (z *ioEncWriter) writen5(b1, b2, b3, b4, b5 byte) {
-// z.b[0], z.b[1], z.b[2], z.b[3], z.b[4] = b1, b2, b3, b4, b5
-// if _, err := z.ww.Write(z.b[:5]); err != nil {
-// panic(err)
-// }
-// }
-
-//go:noinline - so *encWriterSwitch.XXX has the bytesEncAppender.XXX inlined
-func (z *ioEncWriter) end() {
- if z.fw != nil {
- if err := z.fw.Flush(); err != nil {
- panic(err)
- }
- }
+func (e *Encoder) textMarshal(f *codecFnInfo, rv reflect.Value) {
+ bs, fnerr := rv2i(rv).(encoding.TextMarshaler).MarshalText()
+ e.marshalUtf8(bs, fnerr)
}
-*/
-
-// ---------------------------------------------
-
-// bufioEncWriter
-type bufioEncWriter struct {
- buf []byte
- w io.Writer
- n int
- sz int // buf size
-
- // Extensions can call Encode() within a current Encode() call.
- // We need to know when the top level Encode() call returns,
- // so we can decide whether to Release() or not.
- calls uint16 // what depth in mustDecode are we in now.
-
- _ [6]uint8 // padding
-
- bytesBufPooler
-
- _ [1]uint64 // padding
- // a int
- // b [4]byte
- // err
+func (e *Encoder) jsonMarshal(f *codecFnInfo, rv reflect.Value) {
+ bs, fnerr := rv2i(rv).(jsonMarshaler).MarshalJSON()
+ e.marshalAsis(bs, fnerr)
}
-func (z *bufioEncWriter) reset(w io.Writer, bufsize int) {
- z.w = w
- z.n = 0
- z.calls = 0
- if bufsize <= 0 {
- bufsize = defEncByteBufSize
- }
- z.sz = bufsize
- if cap(z.buf) >= bufsize {
- z.buf = z.buf[:cap(z.buf)]
- } else {
- z.buf = z.bytesBufPooler.get(bufsize)
- // z.buf = make([]byte, bufsize)
- }
+func (e *Encoder) raw(f *codecFnInfo, rv reflect.Value) {
+ e.rawBytes(rv2i(rv).(Raw))
}
-func (z *bufioEncWriter) release() {
- z.buf = nil
- z.bytesBufPooler.end()
+func (e *Encoder) kBool(f *codecFnInfo, rv reflect.Value) {
+ e.e.EncodeBool(rvGetBool(rv))
}
-//go:noinline - flush only called intermittently
-func (z *bufioEncWriter) flushErr() (err error) {
- n, err := z.w.Write(z.buf[:z.n])
- z.n -= n
- if z.n > 0 && err == nil {
- err = io.ErrShortWrite
- }
- if n > 0 && z.n > 0 {
- copy(z.buf, z.buf[n:z.n+n])
- }
- return err
+func (e *Encoder) kTime(f *codecFnInfo, rv reflect.Value) {
+ e.e.EncodeTime(rvGetTime(rv))
}
-func (z *bufioEncWriter) flush() {
- if err := z.flushErr(); err != nil {
- panic(err)
- }
+func (e *Encoder) kString(f *codecFnInfo, rv reflect.Value) {
+ e.e.EncodeString(rvGetString(rv))
}
-func (z *bufioEncWriter) writeb(s []byte) {
-LOOP:
- a := len(z.buf) - z.n
- if len(s) > a {
- z.n += copy(z.buf[z.n:], s[:a])
- s = s[a:]
- z.flush()
- goto LOOP
- }
- z.n += copy(z.buf[z.n:], s)
-}
-
-func (z *bufioEncWriter) writestr(s string) {
- // z.writeb(bytesView(s)) // inlined below
-LOOP:
- a := len(z.buf) - z.n
- if len(s) > a {
- z.n += copy(z.buf[z.n:], s[:a])
- s = s[a:]
- z.flush()
- goto LOOP
- }
- z.n += copy(z.buf[z.n:], s)
+func (e *Encoder) kFloat64(f *codecFnInfo, rv reflect.Value) {
+ e.e.EncodeFloat64(rvGetFloat64(rv))
}
-func (z *bufioEncWriter) writen1(b1 byte) {
- if 1 > len(z.buf)-z.n {
- z.flush()
- }
- z.buf[z.n] = b1
- z.n++
+func (e *Encoder) kFloat32(f *codecFnInfo, rv reflect.Value) {
+ e.e.EncodeFloat32(rvGetFloat32(rv))
}
-func (z *bufioEncWriter) writen2(b1, b2 byte) {
- if 2 > len(z.buf)-z.n {
- z.flush()
- }
- z.buf[z.n+1] = b2
- z.buf[z.n] = b1
- z.n += 2
+func (e *Encoder) kInt(f *codecFnInfo, rv reflect.Value) {
+ e.e.EncodeInt(int64(rvGetInt(rv)))
}
-func (z *bufioEncWriter) endErr() (err error) {
- if z.n > 0 {
- err = z.flushErr()
- }
- return
+func (e *Encoder) kInt8(f *codecFnInfo, rv reflect.Value) {
+ e.e.EncodeInt(int64(rvGetInt8(rv)))
}
-// ---------------------------------------------
-
-// bytesEncAppender implements encWriter and can write to an byte slice.
-type bytesEncAppender struct {
- b []byte
- out *[]byte
+func (e *Encoder) kInt16(f *codecFnInfo, rv reflect.Value) {
+ e.e.EncodeInt(int64(rvGetInt16(rv)))
}
-func (z *bytesEncAppender) writeb(s []byte) {
- z.b = append(z.b, s...)
-}
-func (z *bytesEncAppender) writestr(s string) {
- z.b = append(z.b, s...)
-}
-func (z *bytesEncAppender) writen1(b1 byte) {
- z.b = append(z.b, b1)
-}
-func (z *bytesEncAppender) writen2(b1, b2 byte) {
- z.b = append(z.b, b1, b2)
-}
-func (z *bytesEncAppender) endErr() error {
- *(z.out) = z.b
- return nil
-}
-func (z *bytesEncAppender) reset(in []byte, out *[]byte) {
- z.b = in[:0]
- z.out = out
+func (e *Encoder) kInt32(f *codecFnInfo, rv reflect.Value) {
+ e.e.EncodeInt(int64(rvGetInt32(rv)))
}
-// ---------------------------------------------
-
-func (e *Encoder) rawExt(f *codecFnInfo, rv reflect.Value) {
- e.e.EncodeRawExt(rv2i(rv).(*RawExt), e)
+func (e *Encoder) kInt64(f *codecFnInfo, rv reflect.Value) {
+ e.e.EncodeInt(int64(rvGetInt64(rv)))
}
-func (e *Encoder) ext(f *codecFnInfo, rv reflect.Value) {
- e.e.EncodeExt(rv2i(rv), f.xfTag, f.xfFn, e)
+func (e *Encoder) kUint(f *codecFnInfo, rv reflect.Value) {
+ e.e.EncodeUint(uint64(rvGetUint(rv)))
}
-func (e *Encoder) selferMarshal(f *codecFnInfo, rv reflect.Value) {
- rv2i(rv).(Selfer).CodecEncodeSelf(e)
+func (e *Encoder) kUint8(f *codecFnInfo, rv reflect.Value) {
+ e.e.EncodeUint(uint64(rvGetUint8(rv)))
}
-func (e *Encoder) binaryMarshal(f *codecFnInfo, rv reflect.Value) {
- bs, fnerr := rv2i(rv).(encoding.BinaryMarshaler).MarshalBinary()
- e.marshalRaw(bs, fnerr)
+func (e *Encoder) kUint16(f *codecFnInfo, rv reflect.Value) {
+ e.e.EncodeUint(uint64(rvGetUint16(rv)))
}
-func (e *Encoder) textMarshal(f *codecFnInfo, rv reflect.Value) {
- bs, fnerr := rv2i(rv).(encoding.TextMarshaler).MarshalText()
- e.marshalUtf8(bs, fnerr)
+func (e *Encoder) kUint32(f *codecFnInfo, rv reflect.Value) {
+ e.e.EncodeUint(uint64(rvGetUint32(rv)))
}
-func (e *Encoder) jsonMarshal(f *codecFnInfo, rv reflect.Value) {
- bs, fnerr := rv2i(rv).(jsonMarshaler).MarshalJSON()
- e.marshalAsis(bs, fnerr)
+func (e *Encoder) kUint64(f *codecFnInfo, rv reflect.Value) {
+ e.e.EncodeUint(uint64(rvGetUint64(rv)))
}
-func (e *Encoder) raw(f *codecFnInfo, rv reflect.Value) {
- e.rawBytes(rv2i(rv).(Raw))
+func (e *Encoder) kUintptr(f *codecFnInfo, rv reflect.Value) {
+ e.e.EncodeUint(uint64(rvGetUintptr(rv)))
}
func (e *Encoder) kInvalid(f *codecFnInfo, rv reflect.Value) {
@@ -455,409 +256,354 @@ func (e *Encoder) kErr(f *codecFnInfo, rv reflect.Value) {
e.errorf("unsupported kind %s, for %#v", rv.Kind(), rv)
}
-func (e *Encoder) kSlice(f *codecFnInfo, rv reflect.Value) {
- ti := f.ti
- ee := e.e
- // array may be non-addressable, so we have to manage with care
- // (don't call rv.Bytes, rv.Slice, etc).
- // E.g. type struct S{B [2]byte};
- // Encode(S{}) will bomb on "panic: slice of unaddressable array".
- if f.seq != seqTypeArray {
- if rv.IsNil() {
- ee.EncodeNil()
- return
+func chanToSlice(rv reflect.Value, rtslice reflect.Type, timeout time.Duration) (rvcs reflect.Value) {
+ rvcs = reflect.Zero(rtslice)
+ if timeout < 0 { // consume until close
+ for {
+ recv, recvOk := rv.Recv()
+ if !recvOk {
+ break
+ }
+ rvcs = reflect.Append(rvcs, recv)
}
- // If in this method, then there was no extension function defined.
- // So it's okay to treat as []byte.
- if ti.rtid == uint8SliceTypId {
- ee.EncodeStringBytesRaw(rv.Bytes())
- return
+ } else {
+ cases := make([]reflect.SelectCase, 2)
+ cases[0] = reflect.SelectCase{Dir: reflect.SelectRecv, Chan: rv}
+ if timeout == 0 {
+ cases[1] = reflect.SelectCase{Dir: reflect.SelectDefault}
+ } else {
+ tt := time.NewTimer(timeout)
+ cases[1] = reflect.SelectCase{Dir: reflect.SelectRecv, Chan: rv4i(tt.C)}
}
- }
- if f.seq == seqTypeChan && ti.chandir&uint8(reflect.RecvDir) == 0 {
- e.errorf("send-only channel cannot be encoded")
- }
- elemsep := e.esep
- rtelem := ti.elem
- rtelemIsByte := uint8TypId == rt2id(rtelem) // NOT rtelem.Kind() == reflect.Uint8
- var l int
- // if a slice, array or chan of bytes, treat specially
- if rtelemIsByte {
- switch f.seq {
- case seqTypeSlice:
- ee.EncodeStringBytesRaw(rv.Bytes())
- case seqTypeArray:
- l = rv.Len()
- if rv.CanAddr() {
- ee.EncodeStringBytesRaw(rv.Slice(0, l).Bytes())
- } else {
- var bs []byte
- if l <= cap(e.b) {
- bs = e.b[:l]
- } else {
- bs = make([]byte, l)
- }
- reflect.Copy(reflect.ValueOf(bs), rv)
- ee.EncodeStringBytesRaw(bs)
- }
- case seqTypeChan:
- // do not use range, so that the number of elements encoded
- // does not change, and encoding does not hang waiting on someone to close chan.
- // for b := range rv2i(rv).(<-chan byte) { bs = append(bs, b) }
- // ch := rv2i(rv).(<-chan byte) // fix error - that this is a chan byte, not a <-chan byte.
-
- if rv.IsNil() {
- ee.EncodeNil()
+ for {
+ chosen, recv, recvOk := reflect.Select(cases)
+ if chosen == 1 || !recvOk {
break
}
- bs := e.b[:0]
- irv := rv2i(rv)
- ch, ok := irv.(<-chan byte)
- if !ok {
- ch = irv.(chan byte)
- }
-
- L1:
- switch timeout := e.h.ChanRecvTimeout; {
- case timeout == 0: // only consume available
- for {
- select {
- case b := <-ch:
- bs = append(bs, b)
- default:
- break L1
- }
- }
- case timeout > 0: // consume until timeout
- tt := time.NewTimer(timeout)
- for {
- select {
- case b := <-ch:
- bs = append(bs, b)
- case <-tt.C:
- // close(tt.C)
- break L1
- }
- }
- default: // consume until close
- for b := range ch {
- bs = append(bs, b)
- }
- }
-
- ee.EncodeStringBytesRaw(bs)
+ rvcs = reflect.Append(rvcs, recv)
}
- return
}
+ return
+}
- // if chan, consume chan into a slice, and work off that slice.
- if f.seq == seqTypeChan {
- rvcs := reflect.Zero(reflect.SliceOf(rtelem))
- timeout := e.h.ChanRecvTimeout
- if timeout < 0 { // consume until close
- for {
- recv, recvOk := rv.Recv()
- if !recvOk {
- break
- }
- rvcs = reflect.Append(rvcs, recv)
- }
- } else {
- cases := make([]reflect.SelectCase, 2)
- cases[0] = reflect.SelectCase{Dir: reflect.SelectRecv, Chan: rv}
- if timeout == 0 {
- cases[1] = reflect.SelectCase{Dir: reflect.SelectDefault}
- } else {
- tt := time.NewTimer(timeout)
- cases[1] = reflect.SelectCase{Dir: reflect.SelectRecv, Chan: reflect.ValueOf(tt.C)}
- }
- for {
- chosen, recv, recvOk := reflect.Select(cases)
- if chosen == 1 || !recvOk {
- break
- }
- rvcs = reflect.Append(rvcs, recv)
- }
- }
- rv = rvcs // TODO: ensure this doesn't mess up anywhere that rv of kind chan is expected
+func (e *Encoder) kSeqFn(rtelem reflect.Type) (fn *codecFn) {
+ for rtelem.Kind() == reflect.Ptr {
+ rtelem = rtelem.Elem()
+ }
+ // if kind is reflect.Interface, do not pre-determine the
+ // encoding type, because preEncodeValue may break it down to
+ // a concrete type and kInterface will bomb.
+ if rtelem.Kind() != reflect.Interface {
+ fn = e.h.fn(rtelem)
}
+ return
+}
- l = rv.Len()
- if ti.mbs {
+func (e *Encoder) kSliceWMbs(rv reflect.Value, ti *typeInfo) {
+ var l = rvGetSliceLen(rv)
+ if l == 0 {
+ e.mapStart(0)
+ } else {
if l%2 == 1 {
e.errorf("mapBySlice requires even slice length, but got %v", l)
return
}
- ee.WriteMapStart(l / 2)
- } else {
- ee.WriteArrayStart(l)
+ e.mapStart(l / 2)
+ fn := e.kSeqFn(ti.elem)
+ for j := 0; j < l; j++ {
+ if j%2 == 0 {
+ e.mapElemKey()
+ } else {
+ e.mapElemValue()
+ }
+ e.encodeValue(rvSliceIndex(rv, j, ti), fn)
+ }
}
+ e.mapEnd()
+}
+func (e *Encoder) kSliceW(rv reflect.Value, ti *typeInfo) {
+ var l = rvGetSliceLen(rv)
+ e.arrayStart(l)
if l > 0 {
- var fn *codecFn
- for rtelem.Kind() == reflect.Ptr {
- rtelem = rtelem.Elem()
+ fn := e.kSeqFn(ti.elem)
+ for j := 0; j < l; j++ {
+ e.arrayElem()
+ e.encodeValue(rvSliceIndex(rv, j, ti), fn)
}
- // if kind is reflect.Interface, do not pre-determine the
- // encoding type, because preEncodeValue may break it down to
- // a concrete type and kInterface will bomb.
- if rtelem.Kind() != reflect.Interface {
- fn = e.h.fn(rtelem, true, true)
+ }
+ e.arrayEnd()
+}
+
+func (e *Encoder) kSeqWMbs(rv reflect.Value, ti *typeInfo) {
+ var l = rv.Len()
+ if l == 0 {
+ e.mapStart(0)
+ } else {
+ if l%2 == 1 {
+ e.errorf("mapBySlice requires even slice length, but got %v", l)
+ return
}
+ e.mapStart(l / 2)
+ fn := e.kSeqFn(ti.elem)
for j := 0; j < l; j++ {
- if elemsep {
- if ti.mbs {
- if j%2 == 0 {
- ee.WriteMapElemKey()
- } else {
- ee.WriteMapElemValue()
- }
- } else {
- ee.WriteArrayElem()
- }
+ if j%2 == 0 {
+ e.mapElemKey()
+ } else {
+ e.mapElemValue()
}
- e.encodeValue(rv.Index(j), fn, true)
+ e.encodeValue(rv.Index(j), fn)
}
}
+ e.mapEnd()
+}
- if ti.mbs {
- ee.WriteMapEnd()
- } else {
- ee.WriteArrayEnd()
+func (e *Encoder) kSeqW(rv reflect.Value, ti *typeInfo) {
+ var l = rv.Len()
+ e.arrayStart(l)
+ if l > 0 {
+ fn := e.kSeqFn(ti.elem)
+ for j := 0; j < l; j++ {
+ e.arrayElem()
+ e.encodeValue(rv.Index(j), fn)
+ }
}
+ e.arrayEnd()
}
-func (e *Encoder) kStructNoOmitempty(f *codecFnInfo, rv reflect.Value) {
- fti := f.ti
- tisfi := fti.sfiSrc
- toMap := !(fti.toArray || e.h.StructToArray)
- if toMap {
- tisfi = fti.sfiSort
+func (e *Encoder) kChan(f *codecFnInfo, rv reflect.Value) {
+ if rvIsNil(rv) {
+ e.e.EncodeNil()
+ return
}
+ if f.ti.chandir&uint8(reflect.RecvDir) == 0 {
+ e.errorf("send-only channel cannot be encoded")
+ return
+ }
+ if !f.ti.mbs && uint8TypId == rt2id(f.ti.elem) {
+ e.kSliceBytesChan(rv)
+ return
+ }
+ rtslice := reflect.SliceOf(f.ti.elem)
+ rv = chanToSlice(rv, rtslice, e.h.ChanRecvTimeout)
+ ti := e.h.getTypeInfo(rt2id(rtslice), rtslice)
+ if f.ti.mbs {
+ e.kSliceWMbs(rv, ti)
+ } else {
+ e.kSliceW(rv, ti)
+ }
+}
- ee := e.e
-
- sfn := structFieldNode{v: rv, update: false}
- if toMap {
- ee.WriteMapStart(len(tisfi))
- if e.esep {
- for _, si := range tisfi {
- ee.WriteMapElemKey()
- // ee.EncodeStringEnc(cUTF8, si.encName)
- e.kStructFieldKey(fti.keyType, si)
- ee.WriteMapElemValue()
- e.encodeValue(sfn.field(si), nil, true)
- }
+func (e *Encoder) kSlice(f *codecFnInfo, rv reflect.Value) {
+ if rvIsNil(rv) {
+ e.e.EncodeNil()
+ return
+ }
+ if f.ti.mbs {
+ e.kSliceWMbs(rv, f.ti)
+ } else {
+ if f.ti.rtid == uint8SliceTypId || uint8TypId == rt2id(f.ti.elem) {
+ e.e.EncodeStringBytesRaw(rvGetBytes(rv))
} else {
- for _, si := range tisfi {
- // ee.EncodeStringEnc(cUTF8, si.encName)
- e.kStructFieldKey(fti.keyType, si)
- e.encodeValue(sfn.field(si), nil, true)
- }
+ e.kSliceW(rv, f.ti)
}
- ee.WriteMapEnd()
+ }
+}
+
+func (e *Encoder) kArray(f *codecFnInfo, rv reflect.Value) {
+ if f.ti.mbs {
+ e.kSeqWMbs(rv, f.ti)
} else {
- ee.WriteArrayStart(len(tisfi))
- if e.esep {
- for _, si := range tisfi {
- ee.WriteArrayElem()
- e.encodeValue(sfn.field(si), nil, true)
- }
+ if uint8TypId == rt2id(f.ti.elem) {
+ e.e.EncodeStringBytesRaw(rvGetArrayBytesRO(rv, e.b[:]))
} else {
- for _, si := range tisfi {
- e.encodeValue(sfn.field(si), nil, true)
- }
+ e.kSeqW(rv, f.ti)
}
- ee.WriteArrayEnd()
}
}
-func (e *Encoder) kStructFieldKey(keyType valueType, s *structFieldInfo) {
- var m must
- // use if-else-if, not switch (which compiles to binary-search)
- // since keyType is typically valueTypeString, branch prediction is pretty good.
- if keyType == valueTypeString {
- if e.js && s.encNameAsciiAlphaNum { // keyType == valueTypeString
- e.w.writen1('"')
- e.w.writestr(s.encName)
- e.w.writen1('"')
- } else { // keyType == valueTypeString
- e.e.EncodeStringEnc(cUTF8, s.encName)
+func (e *Encoder) kSliceBytesChan(rv reflect.Value) {
+ // do not use range, so that the number of elements encoded
+ // does not change, and encoding does not hang waiting on someone to close chan.
+
+ // for b := range rv2i(rv).(<-chan byte) { bs = append(bs, b) }
+ // ch := rv2i(rv).(<-chan byte) // fix error - that this is a chan byte, not a <-chan byte.
+
+ bs := e.b[:0]
+ irv := rv2i(rv)
+ ch, ok := irv.(<-chan byte)
+ if !ok {
+ ch = irv.(chan byte)
+ }
+
+L1:
+ switch timeout := e.h.ChanRecvTimeout; {
+ case timeout == 0: // only consume available
+ for {
+ select {
+ case b := <-ch:
+ bs = append(bs, b)
+ default:
+ break L1
+ }
+ }
+ case timeout > 0: // consume until timeout
+ tt := time.NewTimer(timeout)
+ for {
+ select {
+ case b := <-ch:
+ bs = append(bs, b)
+ case <-tt.C:
+ // close(tt.C)
+ break L1
+ }
+ }
+ default: // consume until close
+ for b := range ch {
+ bs = append(bs, b)
}
- } else if keyType == valueTypeInt {
- e.e.EncodeInt(m.Int(strconv.ParseInt(s.encName, 10, 64)))
- } else if keyType == valueTypeUint {
- e.e.EncodeUint(m.Uint(strconv.ParseUint(s.encName, 10, 64)))
- } else if keyType == valueTypeFloat {
- e.e.EncodeFloat64(m.Float(strconv.ParseFloat(s.encName, 64)))
}
+
+ e.e.EncodeStringBytesRaw(bs)
}
-func (e *Encoder) kStructFieldKeyName(keyType valueType, encName string) {
- var m must
- // use if-else-if, not switch (which compiles to binary-search)
- // since keyType is typically valueTypeString, branch prediction is pretty good.
- if keyType == valueTypeString {
- e.e.EncodeStringEnc(cUTF8, encName)
- } else if keyType == valueTypeInt {
- e.e.EncodeInt(m.Int(strconv.ParseInt(encName, 10, 64)))
- } else if keyType == valueTypeUint {
- e.e.EncodeUint(m.Uint(strconv.ParseUint(encName, 10, 64)))
- } else if keyType == valueTypeFloat {
- e.e.EncodeFloat64(m.Float(strconv.ParseFloat(encName, 64)))
+func (e *Encoder) kStructNoOmitempty(f *codecFnInfo, rv reflect.Value) {
+ sfn := structFieldNode{v: rv, update: false}
+ if f.ti.toArray || e.h.StructToArray { // toArray
+ e.arrayStart(len(f.ti.sfiSrc))
+ for _, si := range f.ti.sfiSrc {
+ e.arrayElem()
+ e.encodeValue(sfn.field(si), nil)
+ }
+ e.arrayEnd()
+ } else {
+ e.mapStart(len(f.ti.sfiSort))
+ for _, si := range f.ti.sfiSort {
+ e.mapElemKey()
+ e.kStructFieldKey(f.ti.keyType, si.encNameAsciiAlphaNum, si.encName)
+ e.mapElemValue()
+ e.encodeValue(sfn.field(si), nil)
+ }
+ e.mapEnd()
}
}
+func (e *Encoder) kStructFieldKey(keyType valueType, encNameAsciiAlphaNum bool, encName string) {
+ encStructFieldKey(encName, e.e, e.w(), keyType, encNameAsciiAlphaNum, e.js)
+}
+
func (e *Encoder) kStruct(f *codecFnInfo, rv reflect.Value) {
- fti := f.ti
- elemsep := e.esep
- tisfi := fti.sfiSrc
var newlen int
- toMap := !(fti.toArray || e.h.StructToArray)
+ toMap := !(f.ti.toArray || e.h.StructToArray)
var mf map[string]interface{}
- if f.ti.mf {
+ if f.ti.isFlag(tiflagMissingFielder) {
mf = rv2i(rv).(MissingFielder).CodecMissingFields()
toMap = true
newlen += len(mf)
- } else if f.ti.mfp {
+ } else if f.ti.isFlag(tiflagMissingFielderPtr) {
if rv.CanAddr() {
mf = rv2i(rv.Addr()).(MissingFielder).CodecMissingFields()
} else {
// make a new addressable value of same one, and use it
rv2 := reflect.New(rv.Type())
- rv2.Elem().Set(rv)
+ rvSetDirect(rv2.Elem(), rv)
mf = rv2i(rv2).(MissingFielder).CodecMissingFields()
}
toMap = true
newlen += len(mf)
}
- // if toMap, use the sorted array. If toArray, use unsorted array (to match sequence in struct)
- if toMap {
- tisfi = fti.sfiSort
- }
- newlen += len(tisfi)
- ee := e.e
+ newlen += len(f.ti.sfiSrc)
- // Use sync.Pool to reduce allocating slices unnecessarily.
- // The cost of sync.Pool is less than the cost of new allocation.
- //
- // Each element of the array pools one of encStructPool(8|16|32|64).
- // It allows the re-use of slices up to 64 in length.
- // A performance cost of encoding structs was collecting
- // which values were empty and should be omitted.
- // We needed slices of reflect.Value and string to collect them.
- // This shared pool reduces the amount of unnecessary creation we do.
- // The cost is that of locking sometimes, but sync.Pool is efficient
- // enough to reduce thread contention.
-
- // fmt.Printf(">>>>>>>>>>>>>> encode.kStruct: newlen: %d\n", newlen)
- var spool sfiRvPooler
- var fkvs = spool.get(newlen)
+ var fkvs = e.slist.get(newlen)
- var kv sfiRv
recur := e.h.RecursiveEmptyCheck
sfn := structFieldNode{v: rv, update: false}
- newlen = 0
- for _, si := range tisfi {
- // kv.r = si.field(rv, false)
- kv.r = sfn.field(si)
- if toMap {
+
+ var kv sfiRv
+ var j int
+ if toMap {
+ newlen = 0
+ for _, si := range f.ti.sfiSort { // use sorted array
+ kv.r = sfn.field(si)
if si.omitEmpty() && isEmptyValue(kv.r, e.h.TypeInfos, recur, recur) {
continue
}
kv.v = si // si.encName
- } else {
- // use the zero value.
- // if a reference or struct, set to nil (so you do not output too much)
- if si.omitEmpty() && isEmptyValue(kv.r, e.h.TypeInfos, recur, recur) {
- switch kv.r.Kind() {
- case reflect.Struct, reflect.Interface, reflect.Ptr,
- reflect.Array, reflect.Map, reflect.Slice:
- kv.r = reflect.Value{} //encode as nil
- }
- }
+ fkvs[newlen] = kv
+ newlen++
}
- fkvs[newlen] = kv
- newlen++
- }
- fkvs = fkvs[:newlen]
-
- var mflen int
- for k, v := range mf {
- if k == "" {
- delete(mf, k)
- continue
- }
- if fti.infoFieldOmitempty && isEmptyValue(reflect.ValueOf(v), e.h.TypeInfos, recur, recur) {
- delete(mf, k)
- continue
- }
- mflen++
- }
-
- var j int
- if toMap {
- ee.WriteMapStart(newlen + mflen)
- if elemsep {
- for j = 0; j < len(fkvs); j++ {
- kv = fkvs[j]
- ee.WriteMapElemKey()
- // ee.EncodeStringEnc(cUTF8, kv.v)
- e.kStructFieldKey(fti.keyType, kv.v)
- ee.WriteMapElemValue()
- e.encodeValue(kv.r, nil, true)
+ var mflen int
+ for k, v := range mf {
+ if k == "" {
+ delete(mf, k)
+ continue
}
- } else {
- for j = 0; j < len(fkvs); j++ {
- kv = fkvs[j]
- // ee.EncodeStringEnc(cUTF8, kv.v)
- e.kStructFieldKey(fti.keyType, kv.v)
- e.encodeValue(kv.r, nil, true)
+ if f.ti.infoFieldOmitempty && isEmptyValue(rv4i(v), e.h.TypeInfos, recur, recur) {
+ delete(mf, k)
+ continue
}
+ mflen++
+ }
+ // encode it all
+ e.mapStart(newlen + mflen)
+ for j = 0; j < newlen; j++ {
+ kv = fkvs[j]
+ e.mapElemKey()
+ e.kStructFieldKey(f.ti.keyType, kv.v.encNameAsciiAlphaNum, kv.v.encName)
+ e.mapElemValue()
+ e.encodeValue(kv.r, nil)
}
// now, add the others
for k, v := range mf {
- ee.WriteMapElemKey()
- e.kStructFieldKeyName(fti.keyType, k)
- ee.WriteMapElemValue()
+ e.mapElemKey()
+ e.kStructFieldKey(f.ti.keyType, false, k)
+ e.mapElemValue()
e.encode(v)
}
- ee.WriteMapEnd()
+ e.mapEnd()
} else {
- ee.WriteArrayStart(newlen)
- if elemsep {
- for j = 0; j < len(fkvs); j++ {
- ee.WriteArrayElem()
- e.encodeValue(fkvs[j].r, nil, true)
- }
- } else {
- for j = 0; j < len(fkvs); j++ {
- e.encodeValue(fkvs[j].r, nil, true)
+ newlen = len(f.ti.sfiSrc)
+ for i, si := range f.ti.sfiSrc { // use unsorted array (to match sequence in struct)
+ kv.r = sfn.field(si)
+ // use the zero value.
+ // if a reference or struct, set to nil (so you do not output too much)
+ if si.omitEmpty() && isEmptyValue(kv.r, e.h.TypeInfos, recur, recur) {
+ switch kv.r.Kind() {
+ case reflect.Struct, reflect.Interface, reflect.Ptr, reflect.Array, reflect.Map, reflect.Slice:
+ kv.r = reflect.Value{} //encode as nil
+ }
}
+ fkvs[i] = kv
+ }
+ // encode it all
+ e.arrayStart(newlen)
+ for j = 0; j < newlen; j++ {
+ e.arrayElem()
+ e.encodeValue(fkvs[j].r, nil)
}
- ee.WriteArrayEnd()
+ e.arrayEnd()
}
// do not use defer. Instead, use explicit pool return at end of function.
// defer has a cost we are trying to avoid.
// If there is a panic and these slices are not returned, it is ok.
- spool.end()
+ // spool.end()
+ e.slist.put(fkvs)
}
func (e *Encoder) kMap(f *codecFnInfo, rv reflect.Value) {
- ee := e.e
- if rv.IsNil() {
- ee.EncodeNil()
+ if rvIsNil(rv) {
+ e.e.EncodeNil()
return
}
l := rv.Len()
- ee.WriteMapStart(l)
+ e.mapStart(l)
if l == 0 {
- ee.WriteMapEnd()
+ e.mapEnd()
return
}
- // var asSymbols bool
+
// determine the underlying key and val encFn's for the map.
// This eliminates some work which is done for each loop iteration i.e.
// rv.Type(), ref.ValueOf(rt).Pointer(), then check map/list for fn.
@@ -865,63 +611,77 @@ func (e *Encoder) kMap(f *codecFnInfo, rv reflect.Value) {
// However, if kind is reflect.Interface, do not pre-determine the
// encoding type, because preEncodeValue may break it down to
// a concrete type and kInterface will bomb.
+
var keyFn, valFn *codecFn
- ti := f.ti
- rtkey0 := ti.key
- rtkey := rtkey0
- rtval0 := ti.elem
- rtval := rtval0
- // rtkeyid := rt2id(rtkey0)
- for rtval.Kind() == reflect.Ptr {
+
+ ktypeKind := f.ti.key.Kind()
+ vtypeKind := f.ti.elem.Kind()
+
+ rtval := f.ti.elem
+ rtvalkind := vtypeKind
+ for rtvalkind == reflect.Ptr {
rtval = rtval.Elem()
+ rtvalkind = rtval.Kind()
}
- if rtval.Kind() != reflect.Interface {
- valFn = e.h.fn(rtval, true, true)
+ if rtvalkind != reflect.Interface {
+ valFn = e.h.fn(rtval)
}
- mks := rv.MapKeys()
+
+ var rvv = mapAddressableRV(f.ti.elem, vtypeKind)
if e.h.Canonical {
- e.kMapCanonical(rtkey, rv, mks, valFn)
- ee.WriteMapEnd()
+ e.kMapCanonical(f.ti.key, f.ti.elem, rv, rvv, valFn)
+ e.mapEnd()
return
}
- var keyTypeIsString = stringTypId == rt2id(rtkey0) // rtkeyid
+ rtkey := f.ti.key
+ var keyTypeIsString = stringTypId == rt2id(rtkey) // rtkeyid
if !keyTypeIsString {
for rtkey.Kind() == reflect.Ptr {
rtkey = rtkey.Elem()
}
if rtkey.Kind() != reflect.Interface {
- // rtkeyid = rt2id(rtkey)
- keyFn = e.h.fn(rtkey, true, true)
+ keyFn = e.h.fn(rtkey)
}
}
- // for j, lmks := 0, len(mks); j < lmks; j++ {
- for j := range mks {
- if e.esep {
- ee.WriteMapElemKey()
+ var rvk = mapAddressableRV(f.ti.key, ktypeKind)
+
+ var it mapIter
+ mapRange(&it, rv, rvk, rvv, true)
+ validKV := it.ValidKV()
+ var vx reflect.Value
+ for it.Next() {
+ e.mapElemKey()
+ if validKV {
+ vx = it.Key()
+ } else {
+ vx = rvk
}
if keyTypeIsString {
- ee.EncodeStringEnc(cUTF8, mks[j].String())
+ e.e.EncodeString(vx.String())
} else {
- e.encodeValue(mks[j], keyFn, true)
+ e.encodeValue(vx, keyFn)
}
- if e.esep {
- ee.WriteMapElemValue()
+ e.mapElemValue()
+ if validKV {
+ vx = it.Value()
+ } else {
+ vx = rvv
}
- e.encodeValue(rv.MapIndex(mks[j]), valFn, true)
-
+ e.encodeValue(vx, valFn)
}
- ee.WriteMapEnd()
+ it.Done()
+
+ e.mapEnd()
}
-func (e *Encoder) kMapCanonical(rtkey reflect.Type, rv reflect.Value, mks []reflect.Value, valFn *codecFn) {
- ee := e.e
- elemsep := e.esep
+func (e *Encoder) kMapCanonical(rtkey, rtval reflect.Type, rv, rvv reflect.Value, valFn *codecFn) {
// we previously did out-of-band if an extension was registered.
// This is not necessary, as the natural kind is sufficient for ordering.
+ mks := rv.MapKeys()
switch rtkey.Kind() {
case reflect.Bool:
mksv := make([]boolRv, len(mks))
@@ -932,14 +692,10 @@ func (e *Encoder) kMapCanonical(rtkey reflect.Type, rv reflect.Value, mks []refl
}
sort.Sort(boolRvSlice(mksv))
for i := range mksv {
- if elemsep {
- ee.WriteMapElemKey()
- }
- ee.EncodeBool(mksv[i].v)
- if elemsep {
- ee.WriteMapElemValue()
- }
- e.encodeValue(rv.MapIndex(mksv[i].r), valFn, true)
+ e.mapElemKey()
+ e.e.EncodeBool(mksv[i].v)
+ e.mapElemValue()
+ e.encodeValue(mapGet(rv, mksv[i].r, rvv), valFn)
}
case reflect.String:
mksv := make([]stringRv, len(mks))
@@ -950,89 +706,69 @@ func (e *Encoder) kMapCanonical(rtkey reflect.Type, rv reflect.Value, mks []refl
}
sort.Sort(stringRvSlice(mksv))
for i := range mksv {
- if elemsep {
- ee.WriteMapElemKey()
- }
- ee.EncodeStringEnc(cUTF8, mksv[i].v)
- if elemsep {
- ee.WriteMapElemValue()
- }
- e.encodeValue(rv.MapIndex(mksv[i].r), valFn, true)
+ e.mapElemKey()
+ e.e.EncodeString(mksv[i].v)
+ e.mapElemValue()
+ e.encodeValue(mapGet(rv, mksv[i].r, rvv), valFn)
}
case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint, reflect.Uintptr:
- mksv := make([]uintRv, len(mks))
+ mksv := make([]uint64Rv, len(mks))
for i, k := range mks {
v := &mksv[i]
v.r = k
v.v = k.Uint()
}
- sort.Sort(uintRvSlice(mksv))
+ sort.Sort(uint64RvSlice(mksv))
for i := range mksv {
- if elemsep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(mksv[i].v)
- if elemsep {
- ee.WriteMapElemValue()
- }
- e.encodeValue(rv.MapIndex(mksv[i].r), valFn, true)
+ e.mapElemKey()
+ e.e.EncodeUint(mksv[i].v)
+ e.mapElemValue()
+ e.encodeValue(mapGet(rv, mksv[i].r, rvv), valFn)
}
case reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int:
- mksv := make([]intRv, len(mks))
+ mksv := make([]int64Rv, len(mks))
for i, k := range mks {
v := &mksv[i]
v.r = k
v.v = k.Int()
}
- sort.Sort(intRvSlice(mksv))
+ sort.Sort(int64RvSlice(mksv))
for i := range mksv {
- if elemsep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(mksv[i].v)
- if elemsep {
- ee.WriteMapElemValue()
- }
- e.encodeValue(rv.MapIndex(mksv[i].r), valFn, true)
+ e.mapElemKey()
+ e.e.EncodeInt(mksv[i].v)
+ e.mapElemValue()
+ e.encodeValue(mapGet(rv, mksv[i].r, rvv), valFn)
}
case reflect.Float32:
- mksv := make([]floatRv, len(mks))
+ mksv := make([]float64Rv, len(mks))
for i, k := range mks {
v := &mksv[i]
v.r = k
v.v = k.Float()
}
- sort.Sort(floatRvSlice(mksv))
+ sort.Sort(float64RvSlice(mksv))
for i := range mksv {
- if elemsep {
- ee.WriteMapElemKey()
- }
- ee.EncodeFloat32(float32(mksv[i].v))
- if elemsep {
- ee.WriteMapElemValue()
- }
- e.encodeValue(rv.MapIndex(mksv[i].r), valFn, true)
+ e.mapElemKey()
+ e.e.EncodeFloat32(float32(mksv[i].v))
+ e.mapElemValue()
+ e.encodeValue(mapGet(rv, mksv[i].r, rvv), valFn)
}
case reflect.Float64:
- mksv := make([]floatRv, len(mks))
+ mksv := make([]float64Rv, len(mks))
for i, k := range mks {
v := &mksv[i]
v.r = k
v.v = k.Float()
}
- sort.Sort(floatRvSlice(mksv))
+ sort.Sort(float64RvSlice(mksv))
for i := range mksv {
- if elemsep {
- ee.WriteMapElemKey()
- }
- ee.EncodeFloat64(mksv[i].v)
- if elemsep {
- ee.WriteMapElemValue()
- }
- e.encodeValue(rv.MapIndex(mksv[i].r), valFn, true)
+ e.mapElemKey()
+ e.e.EncodeFloat64(mksv[i].v)
+ e.mapElemValue()
+ e.encodeValue(mapGet(rv, mksv[i].r, rvv), valFn)
}
case reflect.Struct:
- if rv.Type() == timeTyp {
+ if rtkey == timeTyp {
mksv := make([]timeRv, len(mks))
for i, k := range mks {
v := &mksv[i]
@@ -1041,14 +777,10 @@ func (e *Encoder) kMapCanonical(rtkey reflect.Type, rv reflect.Value, mks []refl
}
sort.Sort(timeRvSlice(mksv))
for i := range mksv {
- if elemsep {
- ee.WriteMapElemKey()
- }
- ee.EncodeTime(mksv[i].v)
- if elemsep {
- ee.WriteMapElemValue()
- }
- e.encodeValue(rv.MapIndex(mksv[i].r), valFn, true)
+ e.mapElemKey()
+ e.e.EncodeTime(mksv[i].v)
+ e.mapElemValue()
+ e.encodeValue(mapGet(rv, mksv[i].r, rvv), valFn)
}
break
}
@@ -1056,7 +788,7 @@ func (e *Encoder) kMapCanonical(rtkey reflect.Type, rv reflect.Value, mks []refl
default:
// out-of-band
// first encode each key to a []byte first, then sort them, then record
- var mksv []byte = make([]byte, 0, len(mks)*16) // temporary byte slice for the encoding
+ var mksv []byte = e.blist.get(len(mks) * 16)[:0]
e2 := NewEncoderBytes(&mksv, e.hh)
mksbv := make([]bytesRv, len(mks))
for i, k := range mks {
@@ -1068,169 +800,15 @@ func (e *Encoder) kMapCanonical(rtkey reflect.Type, rv reflect.Value, mks []refl
}
sort.Sort(bytesRvSlice(mksbv))
for j := range mksbv {
- if elemsep {
- ee.WriteMapElemKey()
- }
- e.asis(mksbv[j].v)
- if elemsep {
- ee.WriteMapElemValue()
- }
- e.encodeValue(rv.MapIndex(mksbv[j].r), valFn, true)
+ e.mapElemKey()
+ e.encWr.writeb(mksbv[j].v) // e.asis(mksbv[j].v)
+ e.mapElemValue()
+ e.encodeValue(mapGet(rv, mksbv[j].r, rvv), valFn)
}
+ e.blist.put(mksv)
}
}
-// // --------------------------------------------------
-
-type encWriterSwitch struct {
- // wi *ioEncWriter
- wb bytesEncAppender
- wf *bufioEncWriter
- // typ entryType
- bytes bool // encoding to []byte
- esep bool // whether it has elem separators
- isas bool // whether e.as != nil
- js bool // is json encoder?
- be bool // is binary encoder?
- _ [2]byte // padding
- // _ [2]uint64 // padding
- // _ uint64 // padding
-}
-
-func (z *encWriterSwitch) writeb(s []byte) {
- if z.bytes {
- z.wb.writeb(s)
- } else {
- z.wf.writeb(s)
- }
-}
-func (z *encWriterSwitch) writestr(s string) {
- if z.bytes {
- z.wb.writestr(s)
- } else {
- z.wf.writestr(s)
- }
-}
-func (z *encWriterSwitch) writen1(b1 byte) {
- if z.bytes {
- z.wb.writen1(b1)
- } else {
- z.wf.writen1(b1)
- }
-}
-func (z *encWriterSwitch) writen2(b1, b2 byte) {
- if z.bytes {
- z.wb.writen2(b1, b2)
- } else {
- z.wf.writen2(b1, b2)
- }
-}
-func (z *encWriterSwitch) endErr() error {
- if z.bytes {
- return z.wb.endErr()
- }
- return z.wf.endErr()
-}
-
-func (z *encWriterSwitch) end() {
- if err := z.endErr(); err != nil {
- panic(err)
- }
-}
-
-/*
-
-// ------------------------------------------
-func (z *encWriterSwitch) writeb(s []byte) {
- switch z.typ {
- case entryTypeBytes:
- z.wb.writeb(s)
- case entryTypeIo:
- z.wi.writeb(s)
- default:
- z.wf.writeb(s)
- }
-}
-func (z *encWriterSwitch) writestr(s string) {
- switch z.typ {
- case entryTypeBytes:
- z.wb.writestr(s)
- case entryTypeIo:
- z.wi.writestr(s)
- default:
- z.wf.writestr(s)
- }
-}
-func (z *encWriterSwitch) writen1(b1 byte) {
- switch z.typ {
- case entryTypeBytes:
- z.wb.writen1(b1)
- case entryTypeIo:
- z.wi.writen1(b1)
- default:
- z.wf.writen1(b1)
- }
-}
-func (z *encWriterSwitch) writen2(b1, b2 byte) {
- switch z.typ {
- case entryTypeBytes:
- z.wb.writen2(b1, b2)
- case entryTypeIo:
- z.wi.writen2(b1, b2)
- default:
- z.wf.writen2(b1, b2)
- }
-}
-func (z *encWriterSwitch) end() {
- switch z.typ {
- case entryTypeBytes:
- z.wb.end()
- case entryTypeIo:
- z.wi.end()
- default:
- z.wf.end()
- }
-}
-
-// ------------------------------------------
-func (z *encWriterSwitch) writeb(s []byte) {
- if z.bytes {
- z.wb.writeb(s)
- } else {
- z.wi.writeb(s)
- }
-}
-func (z *encWriterSwitch) writestr(s string) {
- if z.bytes {
- z.wb.writestr(s)
- } else {
- z.wi.writestr(s)
- }
-}
-func (z *encWriterSwitch) writen1(b1 byte) {
- if z.bytes {
- z.wb.writen1(b1)
- } else {
- z.wi.writen1(b1)
- }
-}
-func (z *encWriterSwitch) writen2(b1, b2 byte) {
- if z.bytes {
- z.wb.writen2(b1, b2)
- } else {
- z.wi.writen2(b1, b2)
- }
-}
-func (z *encWriterSwitch) end() {
- if z.bytes {
- z.wb.end()
- } else {
- z.wi.end()
- }
-}
-
-*/
-
// Encoder writes an object to an output stream in a supported format.
//
// Encoder is NOT safe for concurrent use i.e. a Encoder cannot be used
@@ -1241,33 +819,30 @@ func (z *encWriterSwitch) end() {
// This is the idiomatic way to use.
type Encoder struct {
panicHdl
- // hopefully, reduce derefencing cost by laying the encWriter inside the Encoder
- e encDriver
- // NOTE: Encoder shouldn't call it's write methods,
- // as the handler MAY need to do some coordination.
- w *encWriterSwitch
+ e encDriver
- // bw *bufio.Writer
- as encDriverAsis
+ h *BasicHandle
- err error
+ // hopefully, reduce derefencing cost by laying the encWriter inside the Encoder
+ encWr
- h *BasicHandle
+ // ---- cpu cache line boundary
hh Handle
- // ---- cpu cache line boundary? + 3
- encWriterSwitch
- ci set
+ blist bytesFreelist
+ err error
- b [(5 * 8)]byte // for encoding chan or (non-addressable) [N]byte
+ // ---- cpu cache line boundary
// ---- writable fields during execution --- *try* to keep in sep cache line
+ ci set // holds set of addresses found during an encoding (if CheckCircularRef=true)
+
+ slist sfiRvFreelist
+
+ b [(2 * 8)]byte // for encoding chan byte, (non-addressable) [N]byte, etc
// ---- cpu cache line boundary?
- // b [scratchByteArrayLen]byte
- // _ [cacheLineSize - scratchByteArrayLen]byte // padding
- // b [cacheLineSize - (8 * 0)]byte // used for encoding a chan or (non-addressable) array of bytes
}
// NewEncoder returns an Encoder for encoding into an io.Writer.
@@ -1275,7 +850,7 @@ type Encoder struct {
// For efficiency, Users are encouraged to configure WriterBufferSize on the handle
// OR pass in a memory buffered writer (eg bufio.Writer, bytes.Buffer).
func NewEncoder(w io.Writer, h Handle) *Encoder {
- e := newEncoder(h)
+ e := h.newEncDriver().encoder()
e.Reset(w)
return e
}
@@ -1286,35 +861,31 @@ func NewEncoder(w io.Writer, h Handle) *Encoder {
// It will potentially replace the output byte slice pointed to.
// After encoding, the out parameter contains the encoded contents.
func NewEncoderBytes(out *[]byte, h Handle) *Encoder {
- e := newEncoder(h)
+ e := h.newEncDriver().encoder()
e.ResetBytes(out)
return e
}
-func newEncoder(h Handle) *Encoder {
- e := &Encoder{h: basicHandle(h), err: errEncoderNotInitialized}
+func (e *Encoder) init(h Handle) {
+ e.err = errEncoderNotInitialized
e.bytes = true
- if useFinalizers {
- runtime.SetFinalizer(e, (*Encoder).finalize)
- // xdebugf(">>>> new(Encoder) with finalizer")
- }
- e.w = &e.encWriterSwitch
e.hh = h
- e.esep = h.hasElemSeparators()
+ e.h = basicHandle(h)
+ e.be = e.hh.isBinary()
+}
- return e
+func (e *Encoder) w() *encWr {
+ return &e.encWr
}
func (e *Encoder) resetCommon() {
- // e.w = &e.encWriterSwitch
- if e.e == nil || e.hh.recreateEncDriver(e.e) {
- e.e = e.hh.newEncDriver(e)
- e.as, e.isas = e.e.(encDriverAsis)
- // e.cr, _ = e.e.(containerStateRecv)
- }
- e.be = e.hh.isBinary()
- _, e.js = e.hh.(*JsonHandle)
e.e.reset()
+ if e.ci == nil {
+ // e.ci = (set)(e.cidef[:0])
+ } else {
+ e.ci = e.ci[:0]
+ }
+ e.c = 0
e.err = nil
}
@@ -1326,34 +897,11 @@ func (e *Encoder) Reset(w io.Writer) {
if w == nil {
return
}
- // var ok bool
e.bytes = false
if e.wf == nil {
e.wf = new(bufioEncWriter)
}
- // e.typ = entryTypeUnset
- // if e.h.WriterBufferSize > 0 {
- // // bw := bufio.NewWriterSize(w, e.h.WriterBufferSize)
- // // e.wi.bw = bw
- // // e.wi.sw = bw
- // // e.wi.fw = bw
- // // e.wi.ww = bw
- // if e.wf == nil {
- // e.wf = new(bufioEncWriter)
- // }
- // e.wf.reset(w, e.h.WriterBufferSize)
- // e.typ = entryTypeBufio
- // } else {
- // if e.wi == nil {
- // e.wi = new(ioEncWriter)
- // }
- // e.wi.reset(w)
- // e.typ = entryTypeIo
- // }
- e.wf.reset(w, e.h.WriterBufferSize)
- // e.typ = entryTypeBufio
-
- // e.w = e.wi
+ e.wf.reset(w, e.h.WriterBufferSize, &e.blist)
e.resetCommon()
}
@@ -1367,9 +915,7 @@ func (e *Encoder) ResetBytes(out *[]byte) {
in = make([]byte, defEncByteBufSize)
}
e.bytes = true
- // e.typ = entryTypeBytes
e.wb.reset(in, out)
- // e.w = &e.wb
e.resetCommon()
}
@@ -1462,6 +1008,7 @@ func (e *Encoder) Encode(v interface{}) (err error) {
// Also, see https://github.com/golang/go/issues/14939#issuecomment-417836139
// defer func() { e.deferred(&err) }() }
// { x, y := e, &err; defer func() { x.deferred(y) }() }
+
if e.err != nil {
return e.err
}
@@ -1469,13 +1016,17 @@ func (e *Encoder) Encode(v interface{}) (err error) {
defer func() {
// if error occurred during encoding, return that error;
// else if error occurred on end'ing (i.e. during flush), return that error.
- err = e.w.endErr()
+ err = e.w().endErr()
x := recover()
if x == nil {
- e.err = err
+ if e.err != err {
+ e.err = err
+ }
} else {
panicValToErr(e, x, &e.err)
- err = e.err
+ if e.err != err {
+ err = e.err
+ }
}
}()
}
@@ -1495,74 +1046,52 @@ func (e *Encoder) MustEncode(v interface{}) {
}
func (e *Encoder) mustEncode(v interface{}) {
- if e.wf == nil {
- e.encode(v)
- e.e.atEndOfEncode()
- e.w.end()
- return
- }
-
- if e.wf.buf == nil {
- e.wf.buf = e.wf.bytesBufPooler.get(e.wf.sz)
- }
- e.wf.calls++
-
+ e.calls++
e.encode(v)
- e.e.atEndOfEncode()
- e.w.end()
-
- e.wf.calls--
-
- if !e.h.ExplicitRelease && e.wf.calls == 0 {
- e.wf.release()
+ e.calls--
+ if e.calls == 0 {
+ e.e.atEndOfEncode()
+ e.w().end()
}
}
-// func (e *Encoder) deferred(err1 *error) {
-// e.w.end()
-// if recoverPanicToErr {
-// if x := recover(); x != nil {
-// panicValToErr(e, x, err1)
-// panicValToErr(e, x, &e.err)
-// }
-// }
-// }
-
-//go:noinline -- as it is run by finalizer
-func (e *Encoder) finalize() {
- // xdebugf("finalizing Encoder")
- e.Release()
-}
-
// Release releases shared (pooled) resources.
//
// It is important to call Release() when done with an Encoder, so those resources
// are released instantly for use by subsequently created Encoders.
+//
+// Deprecated: Release is a no-op as pooled resources are not used with an Encoder.
+// This method is kept for compatibility reasons only.
func (e *Encoder) Release() {
- if e.wf != nil {
- e.wf.release()
- }
}
func (e *Encoder) encode(iv interface{}) {
// a switch with only concrete types can be optimized.
// consequently, we deal with nil and interfaces outside the switch.
- if iv == nil || definitelyNil(iv) {
+ if iv == nil {
+ e.e.EncodeNil()
+ return
+ }
+
+ rv, ok := isNil(iv)
+ if ok {
e.e.EncodeNil()
return
}
+ var vself Selfer
+
switch v := iv.(type) {
// case nil:
// case Selfer:
case Raw:
e.rawBytes(v)
case reflect.Value:
- e.encodeValue(v, nil, true)
+ e.encodeValue(v, nil)
case string:
- e.e.EncodeStringEnc(cUTF8, v)
+ e.e.EncodeString(v)
case bool:
e.e.EncodeBool(v)
case int:
@@ -1595,12 +1124,10 @@ func (e *Encoder) encode(iv interface{}) {
e.e.EncodeTime(v)
case []uint8:
e.e.EncodeStringBytesRaw(v)
-
case *Raw:
e.rawBytes(*v)
-
case *string:
- e.e.EncodeStringEnc(cUTF8, *v)
+ e.e.EncodeString(*v)
case *bool:
e.e.EncodeBool(*v)
case *int:
@@ -1631,29 +1158,39 @@ func (e *Encoder) encode(iv interface{}) {
e.e.EncodeFloat64(*v)
case *time.Time:
e.e.EncodeTime(*v)
-
case *[]uint8:
- e.e.EncodeStringBytesRaw(*v)
-
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ e.e.EncodeStringBytesRaw(*v)
+ }
default:
- if v, ok := iv.(Selfer); ok {
- v.CodecEncodeSelf(e)
+ if vself, ok = iv.(Selfer); ok {
+ vself.CodecEncodeSelf(e)
} else if !fastpathEncodeTypeSwitch(iv, e) {
- // checkfastpath=true (not false), as underlying slice/map type may be fast-path
- e.encodeValue(reflect.ValueOf(iv), nil, true)
+ if !rv.IsValid() {
+ rv = rv4i(iv)
+ }
+ e.encodeValue(rv, nil)
}
}
}
-func (e *Encoder) encodeValue(rv reflect.Value, fn *codecFn, checkFastpath bool) {
+func (e *Encoder) encodeValue(rv reflect.Value, fn *codecFn) {
// if a valid fn is passed, it MUST BE for the dereferenced type of rv
- var sptr uintptr
+
+ // We considered using a uintptr (a pointer) retrievable via rv.UnsafeAddr.
+ // However, it is possible for the same pointer to point to 2 different types e.g.
+ // type T struct { tHelper }
+ // Here, for var v T; &v and &v.tHelper are the same pointer.
+ // Consequently, we need a tuple of type and pointer, which interface{} natively provides.
+ var sptr interface{} // uintptr
var rvp reflect.Value
var rvpValid bool
TOP:
switch rv.Kind() {
case reflect.Ptr:
- if rv.IsNil() {
+ if rvIsNil(rv) {
e.e.EncodeNil()
return
}
@@ -1661,20 +1198,19 @@ TOP:
rvp = rv
rv = rv.Elem()
if e.h.CheckCircularRef && rv.Kind() == reflect.Struct {
- // TODO: Movable pointers will be an issue here. Future problem.
- sptr = rv.UnsafeAddr()
+ sptr = rv2i(rvp) // rv.UnsafeAddr()
break TOP
}
goto TOP
case reflect.Interface:
- if rv.IsNil() {
+ if rvIsNil(rv) {
e.e.EncodeNil()
return
}
rv = rv.Elem()
goto TOP
case reflect.Slice, reflect.Map:
- if rv.IsNil() {
+ if rvIsNil(rv) {
e.e.EncodeNil()
return
}
@@ -1683,14 +1219,14 @@ TOP:
return
}
- if sptr != 0 && (&e.ci).add(sptr) {
- e.errorf("circular reference found: # %d", sptr)
+ if sptr != nil && (&e.ci).add(sptr) {
+ e.errorf("circular reference found: # %p, %T", sptr, sptr)
}
+ var rt reflect.Type
if fn == nil {
- rt := rv.Type()
- // always pass checkCodecSelfer=true, in case T or ****T is passed, where *T is a Selfer
- fn = e.h.fn(rt, checkFastpath, true)
+ rt = rv.Type()
+ fn = e.h.fn(rt)
}
if fn.i.addrE {
if rvpValid {
@@ -1698,8 +1234,11 @@ TOP:
} else if rv.CanAddr() {
fn.fe(e, &fn.i, rv.Addr())
} else {
- rv2 := reflect.New(rv.Type())
- rv2.Elem().Set(rv)
+ if rt == nil {
+ rt = rv.Type()
+ }
+ rv2 := reflect.New(rt)
+ rvSetDirect(rv2.Elem(), rv)
fn.fe(e, &fn.i, rv2)
}
} else {
@@ -1710,19 +1249,6 @@ TOP:
}
}
-// func (e *Encoder) marshal(bs []byte, fnerr error, asis bool, c charEncoding) {
-// if fnerr != nil {
-// panic(fnerr)
-// }
-// if bs == nil {
-// e.e.EncodeNil()
-// } else if asis {
-// e.asis(bs)
-// } else {
-// e.e.EncodeStringBytes(c, bs)
-// }
-// }
-
func (e *Encoder) marshalUtf8(bs []byte, fnerr error) {
if fnerr != nil {
panic(fnerr)
@@ -1730,7 +1256,8 @@ func (e *Encoder) marshalUtf8(bs []byte, fnerr error) {
if bs == nil {
e.e.EncodeNil()
} else {
- e.e.EncodeStringEnc(cUTF8, stringView(bs))
+ e.e.EncodeString(stringView(bs))
+ // e.e.EncodeStringEnc(cUTF8, stringView(bs))
}
}
@@ -1741,7 +1268,7 @@ func (e *Encoder) marshalAsis(bs []byte, fnerr error) {
if bs == nil {
e.e.EncodeNil()
} else {
- e.asis(bs)
+ e.encWr.writeb(bs) // e.asis(bs)
}
}
@@ -1756,22 +1283,91 @@ func (e *Encoder) marshalRaw(bs []byte, fnerr error) {
}
}
-func (e *Encoder) asis(v []byte) {
- if e.isas {
- e.as.EncodeAsis(v)
- } else {
- e.w.writeb(v)
- }
-}
-
func (e *Encoder) rawBytes(vv Raw) {
v := []byte(vv)
if !e.h.Raw {
e.errorf("Raw values cannot be encoded: %v", v)
}
- e.asis(v)
+ e.encWr.writeb(v) // e.asis(v)
}
func (e *Encoder) wrapErr(v interface{}, err *error) {
*err = encodeError{codecError{name: e.hh.Name(), err: v}}
}
+
+// ---- container tracker methods
+// Note: We update the .c after calling the callback.
+// This way, the callback can know what the last status was.
+
+func (e *Encoder) mapStart(length int) {
+ e.e.WriteMapStart(length)
+ e.c = containerMapStart
+}
+
+func (e *Encoder) mapElemKey() {
+ if e.js {
+ e.jsondriver().WriteMapElemKey()
+ }
+ e.c = containerMapKey
+}
+
+func (e *Encoder) mapElemValue() {
+ if e.js {
+ e.jsondriver().WriteMapElemValue()
+ }
+ e.c = containerMapValue
+}
+
+func (e *Encoder) mapEnd() {
+ e.e.WriteMapEnd()
+ // e.c = containerMapEnd
+ e.c = 0
+}
+
+func (e *Encoder) arrayStart(length int) {
+ e.e.WriteArrayStart(length)
+ e.c = containerArrayStart
+}
+
+func (e *Encoder) arrayElem() {
+ if e.js {
+ e.jsondriver().WriteArrayElem()
+ }
+ e.c = containerArrayElem
+}
+
+func (e *Encoder) arrayEnd() {
+ e.e.WriteArrayEnd()
+ e.c = 0
+ // e.c = containerArrayEnd
+}
+
+// ----------
+
+func (e *Encoder) sideEncode(v interface{}, bs *[]byte) {
+ rv := baseRV(v)
+ e2 := NewEncoderBytes(bs, e.hh)
+ e2.encodeValue(rv, e.h.fnNoExt(rv.Type()))
+ e2.e.atEndOfEncode()
+ e2.w().end()
+}
+
+func encStructFieldKey(encName string, ee encDriver, w *encWr,
+ keyType valueType, encNameAsciiAlphaNum bool, js bool) {
+ var m must
+ // use if-else-if, not switch (which compiles to binary-search)
+ // since keyType is typically valueTypeString, branch prediction is pretty good.
+ if keyType == valueTypeString {
+ if js && encNameAsciiAlphaNum { // keyType == valueTypeString
+ w.writeqstr(encName)
+ } else { // keyType == valueTypeString
+ ee.EncodeString(encName)
+ }
+ } else if keyType == valueTypeInt {
+ ee.EncodeInt(m.Int(strconv.ParseInt(encName, 10, 64)))
+ } else if keyType == valueTypeUint {
+ ee.EncodeUint(m.Uint(strconv.ParseUint(encName, 10, 64)))
+ } else if keyType == valueTypeFloat {
+ ee.EncodeFloat64(m.Float(strconv.ParseFloat(encName, 64)))
+ }
+}
diff --git a/vendor/github.com/ugorji/go/codec/fast-path.generated.go b/vendor/github.com/ugorji/go/codec/fast-path.generated.go
index 45137af..e9b7f23 100644
--- a/vendor/github.com/ugorji/go/codec/fast-path.generated.go
+++ b/vendor/github.com/ugorji/go/codec/fast-path.generated.go
@@ -10,7 +10,7 @@ package codec
// Fast path functions try to create a fast path encode or decode implementation
// for common maps and slices.
//
-// We define the functions and register then in this single file
+// We define the functions and register them in this single file
// so as not to pollute the encode.go and decode.go, and create a dependency in there.
// This file can be omitted without causing a build failure.
//
@@ -18,9 +18,10 @@ package codec
// - Many calls bypass reflection altogether
//
// Currently support
-// - slice of all builtin types,
-// - map of all builtin types to string or interface value
-// - symmetrical maps of all builtin types (e.g. str-str, uint8-uint8)
+// - slice of all builtin types (numeric, bool, string, []byte)
+// - maps of builtin types to builtin or interface{} type, EXCEPT FOR
+// keys of type uintptr, int8/16/32, uint16/32, float32/64, bool, interface{}
+// AND values of type type int8/16/32, uint16/32
// This should provide adequate "typical" implementations.
//
// Note that fast track decode functions must handle values for which an address cannot be obtained.
@@ -50,7 +51,7 @@ type fastpathE struct {
decfn func(*Decoder, *codecFnInfo, reflect.Value)
}
-type fastpathA [271]fastpathE
+type fastpathA [81]fastpathE
func (x *fastpathA) index(rtid uintptr) int {
// use binary search to grab the index (adapted from sort/search.go)
@@ -96,13 +97,13 @@ func init() {
fn([]interface{}(nil), (*Encoder).fastpathEncSliceIntfR, (*Decoder).fastpathDecSliceIntfR)
fn([]string(nil), (*Encoder).fastpathEncSliceStringR, (*Decoder).fastpathDecSliceStringR)
+ fn([][]byte(nil), (*Encoder).fastpathEncSliceBytesR, (*Decoder).fastpathDecSliceBytesR)
fn([]float32(nil), (*Encoder).fastpathEncSliceFloat32R, (*Decoder).fastpathDecSliceFloat32R)
fn([]float64(nil), (*Encoder).fastpathEncSliceFloat64R, (*Decoder).fastpathDecSliceFloat64R)
fn([]uint(nil), (*Encoder).fastpathEncSliceUintR, (*Decoder).fastpathDecSliceUintR)
fn([]uint16(nil), (*Encoder).fastpathEncSliceUint16R, (*Decoder).fastpathDecSliceUint16R)
fn([]uint32(nil), (*Encoder).fastpathEncSliceUint32R, (*Decoder).fastpathDecSliceUint32R)
fn([]uint64(nil), (*Encoder).fastpathEncSliceUint64R, (*Decoder).fastpathDecSliceUint64R)
- fn([]uintptr(nil), (*Encoder).fastpathEncSliceUintptrR, (*Decoder).fastpathDecSliceUintptrR)
fn([]int(nil), (*Encoder).fastpathEncSliceIntR, (*Decoder).fastpathDecSliceIntR)
fn([]int8(nil), (*Encoder).fastpathEncSliceInt8R, (*Decoder).fastpathDecSliceInt8R)
fn([]int16(nil), (*Encoder).fastpathEncSliceInt16R, (*Decoder).fastpathDecSliceInt16R)
@@ -110,262 +111,72 @@ func init() {
fn([]int64(nil), (*Encoder).fastpathEncSliceInt64R, (*Decoder).fastpathDecSliceInt64R)
fn([]bool(nil), (*Encoder).fastpathEncSliceBoolR, (*Decoder).fastpathDecSliceBoolR)
- fn(map[interface{}]interface{}(nil), (*Encoder).fastpathEncMapIntfIntfR, (*Decoder).fastpathDecMapIntfIntfR)
- fn(map[interface{}]string(nil), (*Encoder).fastpathEncMapIntfStringR, (*Decoder).fastpathDecMapIntfStringR)
- fn(map[interface{}]uint(nil), (*Encoder).fastpathEncMapIntfUintR, (*Decoder).fastpathDecMapIntfUintR)
- fn(map[interface{}]uint8(nil), (*Encoder).fastpathEncMapIntfUint8R, (*Decoder).fastpathDecMapIntfUint8R)
- fn(map[interface{}]uint16(nil), (*Encoder).fastpathEncMapIntfUint16R, (*Decoder).fastpathDecMapIntfUint16R)
- fn(map[interface{}]uint32(nil), (*Encoder).fastpathEncMapIntfUint32R, (*Decoder).fastpathDecMapIntfUint32R)
- fn(map[interface{}]uint64(nil), (*Encoder).fastpathEncMapIntfUint64R, (*Decoder).fastpathDecMapIntfUint64R)
- fn(map[interface{}]uintptr(nil), (*Encoder).fastpathEncMapIntfUintptrR, (*Decoder).fastpathDecMapIntfUintptrR)
- fn(map[interface{}]int(nil), (*Encoder).fastpathEncMapIntfIntR, (*Decoder).fastpathDecMapIntfIntR)
- fn(map[interface{}]int8(nil), (*Encoder).fastpathEncMapIntfInt8R, (*Decoder).fastpathDecMapIntfInt8R)
- fn(map[interface{}]int16(nil), (*Encoder).fastpathEncMapIntfInt16R, (*Decoder).fastpathDecMapIntfInt16R)
- fn(map[interface{}]int32(nil), (*Encoder).fastpathEncMapIntfInt32R, (*Decoder).fastpathDecMapIntfInt32R)
- fn(map[interface{}]int64(nil), (*Encoder).fastpathEncMapIntfInt64R, (*Decoder).fastpathDecMapIntfInt64R)
- fn(map[interface{}]float32(nil), (*Encoder).fastpathEncMapIntfFloat32R, (*Decoder).fastpathDecMapIntfFloat32R)
- fn(map[interface{}]float64(nil), (*Encoder).fastpathEncMapIntfFloat64R, (*Decoder).fastpathDecMapIntfFloat64R)
- fn(map[interface{}]bool(nil), (*Encoder).fastpathEncMapIntfBoolR, (*Decoder).fastpathDecMapIntfBoolR)
fn(map[string]interface{}(nil), (*Encoder).fastpathEncMapStringIntfR, (*Decoder).fastpathDecMapStringIntfR)
fn(map[string]string(nil), (*Encoder).fastpathEncMapStringStringR, (*Decoder).fastpathDecMapStringStringR)
+ fn(map[string][]byte(nil), (*Encoder).fastpathEncMapStringBytesR, (*Decoder).fastpathDecMapStringBytesR)
fn(map[string]uint(nil), (*Encoder).fastpathEncMapStringUintR, (*Decoder).fastpathDecMapStringUintR)
fn(map[string]uint8(nil), (*Encoder).fastpathEncMapStringUint8R, (*Decoder).fastpathDecMapStringUint8R)
- fn(map[string]uint16(nil), (*Encoder).fastpathEncMapStringUint16R, (*Decoder).fastpathDecMapStringUint16R)
- fn(map[string]uint32(nil), (*Encoder).fastpathEncMapStringUint32R, (*Decoder).fastpathDecMapStringUint32R)
fn(map[string]uint64(nil), (*Encoder).fastpathEncMapStringUint64R, (*Decoder).fastpathDecMapStringUint64R)
- fn(map[string]uintptr(nil), (*Encoder).fastpathEncMapStringUintptrR, (*Decoder).fastpathDecMapStringUintptrR)
fn(map[string]int(nil), (*Encoder).fastpathEncMapStringIntR, (*Decoder).fastpathDecMapStringIntR)
- fn(map[string]int8(nil), (*Encoder).fastpathEncMapStringInt8R, (*Decoder).fastpathDecMapStringInt8R)
- fn(map[string]int16(nil), (*Encoder).fastpathEncMapStringInt16R, (*Decoder).fastpathDecMapStringInt16R)
- fn(map[string]int32(nil), (*Encoder).fastpathEncMapStringInt32R, (*Decoder).fastpathDecMapStringInt32R)
fn(map[string]int64(nil), (*Encoder).fastpathEncMapStringInt64R, (*Decoder).fastpathDecMapStringInt64R)
fn(map[string]float32(nil), (*Encoder).fastpathEncMapStringFloat32R, (*Decoder).fastpathDecMapStringFloat32R)
fn(map[string]float64(nil), (*Encoder).fastpathEncMapStringFloat64R, (*Decoder).fastpathDecMapStringFloat64R)
fn(map[string]bool(nil), (*Encoder).fastpathEncMapStringBoolR, (*Decoder).fastpathDecMapStringBoolR)
- fn(map[float32]interface{}(nil), (*Encoder).fastpathEncMapFloat32IntfR, (*Decoder).fastpathDecMapFloat32IntfR)
- fn(map[float32]string(nil), (*Encoder).fastpathEncMapFloat32StringR, (*Decoder).fastpathDecMapFloat32StringR)
- fn(map[float32]uint(nil), (*Encoder).fastpathEncMapFloat32UintR, (*Decoder).fastpathDecMapFloat32UintR)
- fn(map[float32]uint8(nil), (*Encoder).fastpathEncMapFloat32Uint8R, (*Decoder).fastpathDecMapFloat32Uint8R)
- fn(map[float32]uint16(nil), (*Encoder).fastpathEncMapFloat32Uint16R, (*Decoder).fastpathDecMapFloat32Uint16R)
- fn(map[float32]uint32(nil), (*Encoder).fastpathEncMapFloat32Uint32R, (*Decoder).fastpathDecMapFloat32Uint32R)
- fn(map[float32]uint64(nil), (*Encoder).fastpathEncMapFloat32Uint64R, (*Decoder).fastpathDecMapFloat32Uint64R)
- fn(map[float32]uintptr(nil), (*Encoder).fastpathEncMapFloat32UintptrR, (*Decoder).fastpathDecMapFloat32UintptrR)
- fn(map[float32]int(nil), (*Encoder).fastpathEncMapFloat32IntR, (*Decoder).fastpathDecMapFloat32IntR)
- fn(map[float32]int8(nil), (*Encoder).fastpathEncMapFloat32Int8R, (*Decoder).fastpathDecMapFloat32Int8R)
- fn(map[float32]int16(nil), (*Encoder).fastpathEncMapFloat32Int16R, (*Decoder).fastpathDecMapFloat32Int16R)
- fn(map[float32]int32(nil), (*Encoder).fastpathEncMapFloat32Int32R, (*Decoder).fastpathDecMapFloat32Int32R)
- fn(map[float32]int64(nil), (*Encoder).fastpathEncMapFloat32Int64R, (*Decoder).fastpathDecMapFloat32Int64R)
- fn(map[float32]float32(nil), (*Encoder).fastpathEncMapFloat32Float32R, (*Decoder).fastpathDecMapFloat32Float32R)
- fn(map[float32]float64(nil), (*Encoder).fastpathEncMapFloat32Float64R, (*Decoder).fastpathDecMapFloat32Float64R)
- fn(map[float32]bool(nil), (*Encoder).fastpathEncMapFloat32BoolR, (*Decoder).fastpathDecMapFloat32BoolR)
- fn(map[float64]interface{}(nil), (*Encoder).fastpathEncMapFloat64IntfR, (*Decoder).fastpathDecMapFloat64IntfR)
- fn(map[float64]string(nil), (*Encoder).fastpathEncMapFloat64StringR, (*Decoder).fastpathDecMapFloat64StringR)
- fn(map[float64]uint(nil), (*Encoder).fastpathEncMapFloat64UintR, (*Decoder).fastpathDecMapFloat64UintR)
- fn(map[float64]uint8(nil), (*Encoder).fastpathEncMapFloat64Uint8R, (*Decoder).fastpathDecMapFloat64Uint8R)
- fn(map[float64]uint16(nil), (*Encoder).fastpathEncMapFloat64Uint16R, (*Decoder).fastpathDecMapFloat64Uint16R)
- fn(map[float64]uint32(nil), (*Encoder).fastpathEncMapFloat64Uint32R, (*Decoder).fastpathDecMapFloat64Uint32R)
- fn(map[float64]uint64(nil), (*Encoder).fastpathEncMapFloat64Uint64R, (*Decoder).fastpathDecMapFloat64Uint64R)
- fn(map[float64]uintptr(nil), (*Encoder).fastpathEncMapFloat64UintptrR, (*Decoder).fastpathDecMapFloat64UintptrR)
- fn(map[float64]int(nil), (*Encoder).fastpathEncMapFloat64IntR, (*Decoder).fastpathDecMapFloat64IntR)
- fn(map[float64]int8(nil), (*Encoder).fastpathEncMapFloat64Int8R, (*Decoder).fastpathDecMapFloat64Int8R)
- fn(map[float64]int16(nil), (*Encoder).fastpathEncMapFloat64Int16R, (*Decoder).fastpathDecMapFloat64Int16R)
- fn(map[float64]int32(nil), (*Encoder).fastpathEncMapFloat64Int32R, (*Decoder).fastpathDecMapFloat64Int32R)
- fn(map[float64]int64(nil), (*Encoder).fastpathEncMapFloat64Int64R, (*Decoder).fastpathDecMapFloat64Int64R)
- fn(map[float64]float32(nil), (*Encoder).fastpathEncMapFloat64Float32R, (*Decoder).fastpathDecMapFloat64Float32R)
- fn(map[float64]float64(nil), (*Encoder).fastpathEncMapFloat64Float64R, (*Decoder).fastpathDecMapFloat64Float64R)
- fn(map[float64]bool(nil), (*Encoder).fastpathEncMapFloat64BoolR, (*Decoder).fastpathDecMapFloat64BoolR)
fn(map[uint]interface{}(nil), (*Encoder).fastpathEncMapUintIntfR, (*Decoder).fastpathDecMapUintIntfR)
fn(map[uint]string(nil), (*Encoder).fastpathEncMapUintStringR, (*Decoder).fastpathDecMapUintStringR)
+ fn(map[uint][]byte(nil), (*Encoder).fastpathEncMapUintBytesR, (*Decoder).fastpathDecMapUintBytesR)
fn(map[uint]uint(nil), (*Encoder).fastpathEncMapUintUintR, (*Decoder).fastpathDecMapUintUintR)
fn(map[uint]uint8(nil), (*Encoder).fastpathEncMapUintUint8R, (*Decoder).fastpathDecMapUintUint8R)
- fn(map[uint]uint16(nil), (*Encoder).fastpathEncMapUintUint16R, (*Decoder).fastpathDecMapUintUint16R)
- fn(map[uint]uint32(nil), (*Encoder).fastpathEncMapUintUint32R, (*Decoder).fastpathDecMapUintUint32R)
fn(map[uint]uint64(nil), (*Encoder).fastpathEncMapUintUint64R, (*Decoder).fastpathDecMapUintUint64R)
- fn(map[uint]uintptr(nil), (*Encoder).fastpathEncMapUintUintptrR, (*Decoder).fastpathDecMapUintUintptrR)
fn(map[uint]int(nil), (*Encoder).fastpathEncMapUintIntR, (*Decoder).fastpathDecMapUintIntR)
- fn(map[uint]int8(nil), (*Encoder).fastpathEncMapUintInt8R, (*Decoder).fastpathDecMapUintInt8R)
- fn(map[uint]int16(nil), (*Encoder).fastpathEncMapUintInt16R, (*Decoder).fastpathDecMapUintInt16R)
- fn(map[uint]int32(nil), (*Encoder).fastpathEncMapUintInt32R, (*Decoder).fastpathDecMapUintInt32R)
fn(map[uint]int64(nil), (*Encoder).fastpathEncMapUintInt64R, (*Decoder).fastpathDecMapUintInt64R)
fn(map[uint]float32(nil), (*Encoder).fastpathEncMapUintFloat32R, (*Decoder).fastpathDecMapUintFloat32R)
fn(map[uint]float64(nil), (*Encoder).fastpathEncMapUintFloat64R, (*Decoder).fastpathDecMapUintFloat64R)
fn(map[uint]bool(nil), (*Encoder).fastpathEncMapUintBoolR, (*Decoder).fastpathDecMapUintBoolR)
fn(map[uint8]interface{}(nil), (*Encoder).fastpathEncMapUint8IntfR, (*Decoder).fastpathDecMapUint8IntfR)
fn(map[uint8]string(nil), (*Encoder).fastpathEncMapUint8StringR, (*Decoder).fastpathDecMapUint8StringR)
+ fn(map[uint8][]byte(nil), (*Encoder).fastpathEncMapUint8BytesR, (*Decoder).fastpathDecMapUint8BytesR)
fn(map[uint8]uint(nil), (*Encoder).fastpathEncMapUint8UintR, (*Decoder).fastpathDecMapUint8UintR)
fn(map[uint8]uint8(nil), (*Encoder).fastpathEncMapUint8Uint8R, (*Decoder).fastpathDecMapUint8Uint8R)
- fn(map[uint8]uint16(nil), (*Encoder).fastpathEncMapUint8Uint16R, (*Decoder).fastpathDecMapUint8Uint16R)
- fn(map[uint8]uint32(nil), (*Encoder).fastpathEncMapUint8Uint32R, (*Decoder).fastpathDecMapUint8Uint32R)
fn(map[uint8]uint64(nil), (*Encoder).fastpathEncMapUint8Uint64R, (*Decoder).fastpathDecMapUint8Uint64R)
- fn(map[uint8]uintptr(nil), (*Encoder).fastpathEncMapUint8UintptrR, (*Decoder).fastpathDecMapUint8UintptrR)
fn(map[uint8]int(nil), (*Encoder).fastpathEncMapUint8IntR, (*Decoder).fastpathDecMapUint8IntR)
- fn(map[uint8]int8(nil), (*Encoder).fastpathEncMapUint8Int8R, (*Decoder).fastpathDecMapUint8Int8R)
- fn(map[uint8]int16(nil), (*Encoder).fastpathEncMapUint8Int16R, (*Decoder).fastpathDecMapUint8Int16R)
- fn(map[uint8]int32(nil), (*Encoder).fastpathEncMapUint8Int32R, (*Decoder).fastpathDecMapUint8Int32R)
fn(map[uint8]int64(nil), (*Encoder).fastpathEncMapUint8Int64R, (*Decoder).fastpathDecMapUint8Int64R)
fn(map[uint8]float32(nil), (*Encoder).fastpathEncMapUint8Float32R, (*Decoder).fastpathDecMapUint8Float32R)
fn(map[uint8]float64(nil), (*Encoder).fastpathEncMapUint8Float64R, (*Decoder).fastpathDecMapUint8Float64R)
fn(map[uint8]bool(nil), (*Encoder).fastpathEncMapUint8BoolR, (*Decoder).fastpathDecMapUint8BoolR)
- fn(map[uint16]interface{}(nil), (*Encoder).fastpathEncMapUint16IntfR, (*Decoder).fastpathDecMapUint16IntfR)
- fn(map[uint16]string(nil), (*Encoder).fastpathEncMapUint16StringR, (*Decoder).fastpathDecMapUint16StringR)
- fn(map[uint16]uint(nil), (*Encoder).fastpathEncMapUint16UintR, (*Decoder).fastpathDecMapUint16UintR)
- fn(map[uint16]uint8(nil), (*Encoder).fastpathEncMapUint16Uint8R, (*Decoder).fastpathDecMapUint16Uint8R)
- fn(map[uint16]uint16(nil), (*Encoder).fastpathEncMapUint16Uint16R, (*Decoder).fastpathDecMapUint16Uint16R)
- fn(map[uint16]uint32(nil), (*Encoder).fastpathEncMapUint16Uint32R, (*Decoder).fastpathDecMapUint16Uint32R)
- fn(map[uint16]uint64(nil), (*Encoder).fastpathEncMapUint16Uint64R, (*Decoder).fastpathDecMapUint16Uint64R)
- fn(map[uint16]uintptr(nil), (*Encoder).fastpathEncMapUint16UintptrR, (*Decoder).fastpathDecMapUint16UintptrR)
- fn(map[uint16]int(nil), (*Encoder).fastpathEncMapUint16IntR, (*Decoder).fastpathDecMapUint16IntR)
- fn(map[uint16]int8(nil), (*Encoder).fastpathEncMapUint16Int8R, (*Decoder).fastpathDecMapUint16Int8R)
- fn(map[uint16]int16(nil), (*Encoder).fastpathEncMapUint16Int16R, (*Decoder).fastpathDecMapUint16Int16R)
- fn(map[uint16]int32(nil), (*Encoder).fastpathEncMapUint16Int32R, (*Decoder).fastpathDecMapUint16Int32R)
- fn(map[uint16]int64(nil), (*Encoder).fastpathEncMapUint16Int64R, (*Decoder).fastpathDecMapUint16Int64R)
- fn(map[uint16]float32(nil), (*Encoder).fastpathEncMapUint16Float32R, (*Decoder).fastpathDecMapUint16Float32R)
- fn(map[uint16]float64(nil), (*Encoder).fastpathEncMapUint16Float64R, (*Decoder).fastpathDecMapUint16Float64R)
- fn(map[uint16]bool(nil), (*Encoder).fastpathEncMapUint16BoolR, (*Decoder).fastpathDecMapUint16BoolR)
- fn(map[uint32]interface{}(nil), (*Encoder).fastpathEncMapUint32IntfR, (*Decoder).fastpathDecMapUint32IntfR)
- fn(map[uint32]string(nil), (*Encoder).fastpathEncMapUint32StringR, (*Decoder).fastpathDecMapUint32StringR)
- fn(map[uint32]uint(nil), (*Encoder).fastpathEncMapUint32UintR, (*Decoder).fastpathDecMapUint32UintR)
- fn(map[uint32]uint8(nil), (*Encoder).fastpathEncMapUint32Uint8R, (*Decoder).fastpathDecMapUint32Uint8R)
- fn(map[uint32]uint16(nil), (*Encoder).fastpathEncMapUint32Uint16R, (*Decoder).fastpathDecMapUint32Uint16R)
- fn(map[uint32]uint32(nil), (*Encoder).fastpathEncMapUint32Uint32R, (*Decoder).fastpathDecMapUint32Uint32R)
- fn(map[uint32]uint64(nil), (*Encoder).fastpathEncMapUint32Uint64R, (*Decoder).fastpathDecMapUint32Uint64R)
- fn(map[uint32]uintptr(nil), (*Encoder).fastpathEncMapUint32UintptrR, (*Decoder).fastpathDecMapUint32UintptrR)
- fn(map[uint32]int(nil), (*Encoder).fastpathEncMapUint32IntR, (*Decoder).fastpathDecMapUint32IntR)
- fn(map[uint32]int8(nil), (*Encoder).fastpathEncMapUint32Int8R, (*Decoder).fastpathDecMapUint32Int8R)
- fn(map[uint32]int16(nil), (*Encoder).fastpathEncMapUint32Int16R, (*Decoder).fastpathDecMapUint32Int16R)
- fn(map[uint32]int32(nil), (*Encoder).fastpathEncMapUint32Int32R, (*Decoder).fastpathDecMapUint32Int32R)
- fn(map[uint32]int64(nil), (*Encoder).fastpathEncMapUint32Int64R, (*Decoder).fastpathDecMapUint32Int64R)
- fn(map[uint32]float32(nil), (*Encoder).fastpathEncMapUint32Float32R, (*Decoder).fastpathDecMapUint32Float32R)
- fn(map[uint32]float64(nil), (*Encoder).fastpathEncMapUint32Float64R, (*Decoder).fastpathDecMapUint32Float64R)
- fn(map[uint32]bool(nil), (*Encoder).fastpathEncMapUint32BoolR, (*Decoder).fastpathDecMapUint32BoolR)
fn(map[uint64]interface{}(nil), (*Encoder).fastpathEncMapUint64IntfR, (*Decoder).fastpathDecMapUint64IntfR)
fn(map[uint64]string(nil), (*Encoder).fastpathEncMapUint64StringR, (*Decoder).fastpathDecMapUint64StringR)
+ fn(map[uint64][]byte(nil), (*Encoder).fastpathEncMapUint64BytesR, (*Decoder).fastpathDecMapUint64BytesR)
fn(map[uint64]uint(nil), (*Encoder).fastpathEncMapUint64UintR, (*Decoder).fastpathDecMapUint64UintR)
fn(map[uint64]uint8(nil), (*Encoder).fastpathEncMapUint64Uint8R, (*Decoder).fastpathDecMapUint64Uint8R)
- fn(map[uint64]uint16(nil), (*Encoder).fastpathEncMapUint64Uint16R, (*Decoder).fastpathDecMapUint64Uint16R)
- fn(map[uint64]uint32(nil), (*Encoder).fastpathEncMapUint64Uint32R, (*Decoder).fastpathDecMapUint64Uint32R)
fn(map[uint64]uint64(nil), (*Encoder).fastpathEncMapUint64Uint64R, (*Decoder).fastpathDecMapUint64Uint64R)
- fn(map[uint64]uintptr(nil), (*Encoder).fastpathEncMapUint64UintptrR, (*Decoder).fastpathDecMapUint64UintptrR)
fn(map[uint64]int(nil), (*Encoder).fastpathEncMapUint64IntR, (*Decoder).fastpathDecMapUint64IntR)
- fn(map[uint64]int8(nil), (*Encoder).fastpathEncMapUint64Int8R, (*Decoder).fastpathDecMapUint64Int8R)
- fn(map[uint64]int16(nil), (*Encoder).fastpathEncMapUint64Int16R, (*Decoder).fastpathDecMapUint64Int16R)
- fn(map[uint64]int32(nil), (*Encoder).fastpathEncMapUint64Int32R, (*Decoder).fastpathDecMapUint64Int32R)
fn(map[uint64]int64(nil), (*Encoder).fastpathEncMapUint64Int64R, (*Decoder).fastpathDecMapUint64Int64R)
fn(map[uint64]float32(nil), (*Encoder).fastpathEncMapUint64Float32R, (*Decoder).fastpathDecMapUint64Float32R)
fn(map[uint64]float64(nil), (*Encoder).fastpathEncMapUint64Float64R, (*Decoder).fastpathDecMapUint64Float64R)
fn(map[uint64]bool(nil), (*Encoder).fastpathEncMapUint64BoolR, (*Decoder).fastpathDecMapUint64BoolR)
- fn(map[uintptr]interface{}(nil), (*Encoder).fastpathEncMapUintptrIntfR, (*Decoder).fastpathDecMapUintptrIntfR)
- fn(map[uintptr]string(nil), (*Encoder).fastpathEncMapUintptrStringR, (*Decoder).fastpathDecMapUintptrStringR)
- fn(map[uintptr]uint(nil), (*Encoder).fastpathEncMapUintptrUintR, (*Decoder).fastpathDecMapUintptrUintR)
- fn(map[uintptr]uint8(nil), (*Encoder).fastpathEncMapUintptrUint8R, (*Decoder).fastpathDecMapUintptrUint8R)
- fn(map[uintptr]uint16(nil), (*Encoder).fastpathEncMapUintptrUint16R, (*Decoder).fastpathDecMapUintptrUint16R)
- fn(map[uintptr]uint32(nil), (*Encoder).fastpathEncMapUintptrUint32R, (*Decoder).fastpathDecMapUintptrUint32R)
- fn(map[uintptr]uint64(nil), (*Encoder).fastpathEncMapUintptrUint64R, (*Decoder).fastpathDecMapUintptrUint64R)
- fn(map[uintptr]uintptr(nil), (*Encoder).fastpathEncMapUintptrUintptrR, (*Decoder).fastpathDecMapUintptrUintptrR)
- fn(map[uintptr]int(nil), (*Encoder).fastpathEncMapUintptrIntR, (*Decoder).fastpathDecMapUintptrIntR)
- fn(map[uintptr]int8(nil), (*Encoder).fastpathEncMapUintptrInt8R, (*Decoder).fastpathDecMapUintptrInt8R)
- fn(map[uintptr]int16(nil), (*Encoder).fastpathEncMapUintptrInt16R, (*Decoder).fastpathDecMapUintptrInt16R)
- fn(map[uintptr]int32(nil), (*Encoder).fastpathEncMapUintptrInt32R, (*Decoder).fastpathDecMapUintptrInt32R)
- fn(map[uintptr]int64(nil), (*Encoder).fastpathEncMapUintptrInt64R, (*Decoder).fastpathDecMapUintptrInt64R)
- fn(map[uintptr]float32(nil), (*Encoder).fastpathEncMapUintptrFloat32R, (*Decoder).fastpathDecMapUintptrFloat32R)
- fn(map[uintptr]float64(nil), (*Encoder).fastpathEncMapUintptrFloat64R, (*Decoder).fastpathDecMapUintptrFloat64R)
- fn(map[uintptr]bool(nil), (*Encoder).fastpathEncMapUintptrBoolR, (*Decoder).fastpathDecMapUintptrBoolR)
fn(map[int]interface{}(nil), (*Encoder).fastpathEncMapIntIntfR, (*Decoder).fastpathDecMapIntIntfR)
fn(map[int]string(nil), (*Encoder).fastpathEncMapIntStringR, (*Decoder).fastpathDecMapIntStringR)
+ fn(map[int][]byte(nil), (*Encoder).fastpathEncMapIntBytesR, (*Decoder).fastpathDecMapIntBytesR)
fn(map[int]uint(nil), (*Encoder).fastpathEncMapIntUintR, (*Decoder).fastpathDecMapIntUintR)
fn(map[int]uint8(nil), (*Encoder).fastpathEncMapIntUint8R, (*Decoder).fastpathDecMapIntUint8R)
- fn(map[int]uint16(nil), (*Encoder).fastpathEncMapIntUint16R, (*Decoder).fastpathDecMapIntUint16R)
- fn(map[int]uint32(nil), (*Encoder).fastpathEncMapIntUint32R, (*Decoder).fastpathDecMapIntUint32R)
fn(map[int]uint64(nil), (*Encoder).fastpathEncMapIntUint64R, (*Decoder).fastpathDecMapIntUint64R)
- fn(map[int]uintptr(nil), (*Encoder).fastpathEncMapIntUintptrR, (*Decoder).fastpathDecMapIntUintptrR)
fn(map[int]int(nil), (*Encoder).fastpathEncMapIntIntR, (*Decoder).fastpathDecMapIntIntR)
- fn(map[int]int8(nil), (*Encoder).fastpathEncMapIntInt8R, (*Decoder).fastpathDecMapIntInt8R)
- fn(map[int]int16(nil), (*Encoder).fastpathEncMapIntInt16R, (*Decoder).fastpathDecMapIntInt16R)
- fn(map[int]int32(nil), (*Encoder).fastpathEncMapIntInt32R, (*Decoder).fastpathDecMapIntInt32R)
fn(map[int]int64(nil), (*Encoder).fastpathEncMapIntInt64R, (*Decoder).fastpathDecMapIntInt64R)
fn(map[int]float32(nil), (*Encoder).fastpathEncMapIntFloat32R, (*Decoder).fastpathDecMapIntFloat32R)
fn(map[int]float64(nil), (*Encoder).fastpathEncMapIntFloat64R, (*Decoder).fastpathDecMapIntFloat64R)
fn(map[int]bool(nil), (*Encoder).fastpathEncMapIntBoolR, (*Decoder).fastpathDecMapIntBoolR)
- fn(map[int8]interface{}(nil), (*Encoder).fastpathEncMapInt8IntfR, (*Decoder).fastpathDecMapInt8IntfR)
- fn(map[int8]string(nil), (*Encoder).fastpathEncMapInt8StringR, (*Decoder).fastpathDecMapInt8StringR)
- fn(map[int8]uint(nil), (*Encoder).fastpathEncMapInt8UintR, (*Decoder).fastpathDecMapInt8UintR)
- fn(map[int8]uint8(nil), (*Encoder).fastpathEncMapInt8Uint8R, (*Decoder).fastpathDecMapInt8Uint8R)
- fn(map[int8]uint16(nil), (*Encoder).fastpathEncMapInt8Uint16R, (*Decoder).fastpathDecMapInt8Uint16R)
- fn(map[int8]uint32(nil), (*Encoder).fastpathEncMapInt8Uint32R, (*Decoder).fastpathDecMapInt8Uint32R)
- fn(map[int8]uint64(nil), (*Encoder).fastpathEncMapInt8Uint64R, (*Decoder).fastpathDecMapInt8Uint64R)
- fn(map[int8]uintptr(nil), (*Encoder).fastpathEncMapInt8UintptrR, (*Decoder).fastpathDecMapInt8UintptrR)
- fn(map[int8]int(nil), (*Encoder).fastpathEncMapInt8IntR, (*Decoder).fastpathDecMapInt8IntR)
- fn(map[int8]int8(nil), (*Encoder).fastpathEncMapInt8Int8R, (*Decoder).fastpathDecMapInt8Int8R)
- fn(map[int8]int16(nil), (*Encoder).fastpathEncMapInt8Int16R, (*Decoder).fastpathDecMapInt8Int16R)
- fn(map[int8]int32(nil), (*Encoder).fastpathEncMapInt8Int32R, (*Decoder).fastpathDecMapInt8Int32R)
- fn(map[int8]int64(nil), (*Encoder).fastpathEncMapInt8Int64R, (*Decoder).fastpathDecMapInt8Int64R)
- fn(map[int8]float32(nil), (*Encoder).fastpathEncMapInt8Float32R, (*Decoder).fastpathDecMapInt8Float32R)
- fn(map[int8]float64(nil), (*Encoder).fastpathEncMapInt8Float64R, (*Decoder).fastpathDecMapInt8Float64R)
- fn(map[int8]bool(nil), (*Encoder).fastpathEncMapInt8BoolR, (*Decoder).fastpathDecMapInt8BoolR)
- fn(map[int16]interface{}(nil), (*Encoder).fastpathEncMapInt16IntfR, (*Decoder).fastpathDecMapInt16IntfR)
- fn(map[int16]string(nil), (*Encoder).fastpathEncMapInt16StringR, (*Decoder).fastpathDecMapInt16StringR)
- fn(map[int16]uint(nil), (*Encoder).fastpathEncMapInt16UintR, (*Decoder).fastpathDecMapInt16UintR)
- fn(map[int16]uint8(nil), (*Encoder).fastpathEncMapInt16Uint8R, (*Decoder).fastpathDecMapInt16Uint8R)
- fn(map[int16]uint16(nil), (*Encoder).fastpathEncMapInt16Uint16R, (*Decoder).fastpathDecMapInt16Uint16R)
- fn(map[int16]uint32(nil), (*Encoder).fastpathEncMapInt16Uint32R, (*Decoder).fastpathDecMapInt16Uint32R)
- fn(map[int16]uint64(nil), (*Encoder).fastpathEncMapInt16Uint64R, (*Decoder).fastpathDecMapInt16Uint64R)
- fn(map[int16]uintptr(nil), (*Encoder).fastpathEncMapInt16UintptrR, (*Decoder).fastpathDecMapInt16UintptrR)
- fn(map[int16]int(nil), (*Encoder).fastpathEncMapInt16IntR, (*Decoder).fastpathDecMapInt16IntR)
- fn(map[int16]int8(nil), (*Encoder).fastpathEncMapInt16Int8R, (*Decoder).fastpathDecMapInt16Int8R)
- fn(map[int16]int16(nil), (*Encoder).fastpathEncMapInt16Int16R, (*Decoder).fastpathDecMapInt16Int16R)
- fn(map[int16]int32(nil), (*Encoder).fastpathEncMapInt16Int32R, (*Decoder).fastpathDecMapInt16Int32R)
- fn(map[int16]int64(nil), (*Encoder).fastpathEncMapInt16Int64R, (*Decoder).fastpathDecMapInt16Int64R)
- fn(map[int16]float32(nil), (*Encoder).fastpathEncMapInt16Float32R, (*Decoder).fastpathDecMapInt16Float32R)
- fn(map[int16]float64(nil), (*Encoder).fastpathEncMapInt16Float64R, (*Decoder).fastpathDecMapInt16Float64R)
- fn(map[int16]bool(nil), (*Encoder).fastpathEncMapInt16BoolR, (*Decoder).fastpathDecMapInt16BoolR)
- fn(map[int32]interface{}(nil), (*Encoder).fastpathEncMapInt32IntfR, (*Decoder).fastpathDecMapInt32IntfR)
- fn(map[int32]string(nil), (*Encoder).fastpathEncMapInt32StringR, (*Decoder).fastpathDecMapInt32StringR)
- fn(map[int32]uint(nil), (*Encoder).fastpathEncMapInt32UintR, (*Decoder).fastpathDecMapInt32UintR)
- fn(map[int32]uint8(nil), (*Encoder).fastpathEncMapInt32Uint8R, (*Decoder).fastpathDecMapInt32Uint8R)
- fn(map[int32]uint16(nil), (*Encoder).fastpathEncMapInt32Uint16R, (*Decoder).fastpathDecMapInt32Uint16R)
- fn(map[int32]uint32(nil), (*Encoder).fastpathEncMapInt32Uint32R, (*Decoder).fastpathDecMapInt32Uint32R)
- fn(map[int32]uint64(nil), (*Encoder).fastpathEncMapInt32Uint64R, (*Decoder).fastpathDecMapInt32Uint64R)
- fn(map[int32]uintptr(nil), (*Encoder).fastpathEncMapInt32UintptrR, (*Decoder).fastpathDecMapInt32UintptrR)
- fn(map[int32]int(nil), (*Encoder).fastpathEncMapInt32IntR, (*Decoder).fastpathDecMapInt32IntR)
- fn(map[int32]int8(nil), (*Encoder).fastpathEncMapInt32Int8R, (*Decoder).fastpathDecMapInt32Int8R)
- fn(map[int32]int16(nil), (*Encoder).fastpathEncMapInt32Int16R, (*Decoder).fastpathDecMapInt32Int16R)
- fn(map[int32]int32(nil), (*Encoder).fastpathEncMapInt32Int32R, (*Decoder).fastpathDecMapInt32Int32R)
- fn(map[int32]int64(nil), (*Encoder).fastpathEncMapInt32Int64R, (*Decoder).fastpathDecMapInt32Int64R)
- fn(map[int32]float32(nil), (*Encoder).fastpathEncMapInt32Float32R, (*Decoder).fastpathDecMapInt32Float32R)
- fn(map[int32]float64(nil), (*Encoder).fastpathEncMapInt32Float64R, (*Decoder).fastpathDecMapInt32Float64R)
- fn(map[int32]bool(nil), (*Encoder).fastpathEncMapInt32BoolR, (*Decoder).fastpathDecMapInt32BoolR)
fn(map[int64]interface{}(nil), (*Encoder).fastpathEncMapInt64IntfR, (*Decoder).fastpathDecMapInt64IntfR)
fn(map[int64]string(nil), (*Encoder).fastpathEncMapInt64StringR, (*Decoder).fastpathDecMapInt64StringR)
+ fn(map[int64][]byte(nil), (*Encoder).fastpathEncMapInt64BytesR, (*Decoder).fastpathDecMapInt64BytesR)
fn(map[int64]uint(nil), (*Encoder).fastpathEncMapInt64UintR, (*Decoder).fastpathDecMapInt64UintR)
fn(map[int64]uint8(nil), (*Encoder).fastpathEncMapInt64Uint8R, (*Decoder).fastpathDecMapInt64Uint8R)
- fn(map[int64]uint16(nil), (*Encoder).fastpathEncMapInt64Uint16R, (*Decoder).fastpathDecMapInt64Uint16R)
- fn(map[int64]uint32(nil), (*Encoder).fastpathEncMapInt64Uint32R, (*Decoder).fastpathDecMapInt64Uint32R)
fn(map[int64]uint64(nil), (*Encoder).fastpathEncMapInt64Uint64R, (*Decoder).fastpathDecMapInt64Uint64R)
- fn(map[int64]uintptr(nil), (*Encoder).fastpathEncMapInt64UintptrR, (*Decoder).fastpathDecMapInt64UintptrR)
fn(map[int64]int(nil), (*Encoder).fastpathEncMapInt64IntR, (*Decoder).fastpathDecMapInt64IntR)
- fn(map[int64]int8(nil), (*Encoder).fastpathEncMapInt64Int8R, (*Decoder).fastpathDecMapInt64Int8R)
- fn(map[int64]int16(nil), (*Encoder).fastpathEncMapInt64Int16R, (*Decoder).fastpathDecMapInt64Int16R)
- fn(map[int64]int32(nil), (*Encoder).fastpathEncMapInt64Int32R, (*Decoder).fastpathDecMapInt64Int32R)
fn(map[int64]int64(nil), (*Encoder).fastpathEncMapInt64Int64R, (*Decoder).fastpathDecMapInt64Int64R)
fn(map[int64]float32(nil), (*Encoder).fastpathEncMapInt64Float32R, (*Decoder).fastpathDecMapInt64Float32R)
fn(map[int64]float64(nil), (*Encoder).fastpathEncMapInt64Float64R, (*Decoder).fastpathDecMapInt64Float64R)
fn(map[int64]bool(nil), (*Encoder).fastpathEncMapInt64BoolR, (*Decoder).fastpathDecMapInt64BoolR)
- fn(map[bool]interface{}(nil), (*Encoder).fastpathEncMapBoolIntfR, (*Decoder).fastpathDecMapBoolIntfR)
- fn(map[bool]string(nil), (*Encoder).fastpathEncMapBoolStringR, (*Decoder).fastpathDecMapBoolStringR)
- fn(map[bool]uint(nil), (*Encoder).fastpathEncMapBoolUintR, (*Decoder).fastpathDecMapBoolUintR)
- fn(map[bool]uint8(nil), (*Encoder).fastpathEncMapBoolUint8R, (*Decoder).fastpathDecMapBoolUint8R)
- fn(map[bool]uint16(nil), (*Encoder).fastpathEncMapBoolUint16R, (*Decoder).fastpathDecMapBoolUint16R)
- fn(map[bool]uint32(nil), (*Encoder).fastpathEncMapBoolUint32R, (*Decoder).fastpathDecMapBoolUint32R)
- fn(map[bool]uint64(nil), (*Encoder).fastpathEncMapBoolUint64R, (*Decoder).fastpathDecMapBoolUint64R)
- fn(map[bool]uintptr(nil), (*Encoder).fastpathEncMapBoolUintptrR, (*Decoder).fastpathDecMapBoolUintptrR)
- fn(map[bool]int(nil), (*Encoder).fastpathEncMapBoolIntR, (*Decoder).fastpathDecMapBoolIntR)
- fn(map[bool]int8(nil), (*Encoder).fastpathEncMapBoolInt8R, (*Decoder).fastpathDecMapBoolInt8R)
- fn(map[bool]int16(nil), (*Encoder).fastpathEncMapBoolInt16R, (*Decoder).fastpathDecMapBoolInt16R)
- fn(map[bool]int32(nil), (*Encoder).fastpathEncMapBoolInt32R, (*Decoder).fastpathDecMapBoolInt32R)
- fn(map[bool]int64(nil), (*Encoder).fastpathEncMapBoolInt64R, (*Decoder).fastpathDecMapBoolInt64R)
- fn(map[bool]float32(nil), (*Encoder).fastpathEncMapBoolFloat32R, (*Decoder).fastpathDecMapBoolFloat32R)
- fn(map[bool]float64(nil), (*Encoder).fastpathEncMapBoolFloat64R, (*Decoder).fastpathDecMapBoolFloat64R)
- fn(map[bool]bool(nil), (*Encoder).fastpathEncMapBoolBoolR, (*Decoder).fastpathDecMapBoolBoolR)
sort.Sort(fastpathAslice(fastpathAV[:]))
}
@@ -375,1093 +186,654 @@ func init() {
// -- -- fast path type switch
func fastpathEncodeTypeSwitch(iv interface{}, e *Encoder) bool {
switch v := iv.(type) {
-
case []interface{}:
fastpathTV.EncSliceIntfV(v, e)
case *[]interface{}:
- fastpathTV.EncSliceIntfV(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncSliceIntfV(*v, e)
+ }
case []string:
fastpathTV.EncSliceStringV(v, e)
case *[]string:
- fastpathTV.EncSliceStringV(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncSliceStringV(*v, e)
+ }
+ case [][]byte:
+ fastpathTV.EncSliceBytesV(v, e)
+ case *[][]byte:
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncSliceBytesV(*v, e)
+ }
case []float32:
fastpathTV.EncSliceFloat32V(v, e)
case *[]float32:
- fastpathTV.EncSliceFloat32V(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncSliceFloat32V(*v, e)
+ }
case []float64:
fastpathTV.EncSliceFloat64V(v, e)
case *[]float64:
- fastpathTV.EncSliceFloat64V(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncSliceFloat64V(*v, e)
+ }
case []uint:
fastpathTV.EncSliceUintV(v, e)
case *[]uint:
- fastpathTV.EncSliceUintV(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncSliceUintV(*v, e)
+ }
case []uint16:
fastpathTV.EncSliceUint16V(v, e)
case *[]uint16:
- fastpathTV.EncSliceUint16V(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncSliceUint16V(*v, e)
+ }
case []uint32:
fastpathTV.EncSliceUint32V(v, e)
case *[]uint32:
- fastpathTV.EncSliceUint32V(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncSliceUint32V(*v, e)
+ }
case []uint64:
fastpathTV.EncSliceUint64V(v, e)
case *[]uint64:
- fastpathTV.EncSliceUint64V(*v, e)
- case []uintptr:
- fastpathTV.EncSliceUintptrV(v, e)
- case *[]uintptr:
- fastpathTV.EncSliceUintptrV(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncSliceUint64V(*v, e)
+ }
case []int:
fastpathTV.EncSliceIntV(v, e)
case *[]int:
- fastpathTV.EncSliceIntV(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncSliceIntV(*v, e)
+ }
case []int8:
fastpathTV.EncSliceInt8V(v, e)
case *[]int8:
- fastpathTV.EncSliceInt8V(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncSliceInt8V(*v, e)
+ }
case []int16:
fastpathTV.EncSliceInt16V(v, e)
case *[]int16:
- fastpathTV.EncSliceInt16V(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncSliceInt16V(*v, e)
+ }
case []int32:
fastpathTV.EncSliceInt32V(v, e)
case *[]int32:
- fastpathTV.EncSliceInt32V(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncSliceInt32V(*v, e)
+ }
case []int64:
fastpathTV.EncSliceInt64V(v, e)
case *[]int64:
- fastpathTV.EncSliceInt64V(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncSliceInt64V(*v, e)
+ }
case []bool:
fastpathTV.EncSliceBoolV(v, e)
case *[]bool:
- fastpathTV.EncSliceBoolV(*v, e)
-
- case map[interface{}]interface{}:
- fastpathTV.EncMapIntfIntfV(v, e)
- case *map[interface{}]interface{}:
- fastpathTV.EncMapIntfIntfV(*v, e)
- case map[interface{}]string:
- fastpathTV.EncMapIntfStringV(v, e)
- case *map[interface{}]string:
- fastpathTV.EncMapIntfStringV(*v, e)
- case map[interface{}]uint:
- fastpathTV.EncMapIntfUintV(v, e)
- case *map[interface{}]uint:
- fastpathTV.EncMapIntfUintV(*v, e)
- case map[interface{}]uint8:
- fastpathTV.EncMapIntfUint8V(v, e)
- case *map[interface{}]uint8:
- fastpathTV.EncMapIntfUint8V(*v, e)
- case map[interface{}]uint16:
- fastpathTV.EncMapIntfUint16V(v, e)
- case *map[interface{}]uint16:
- fastpathTV.EncMapIntfUint16V(*v, e)
- case map[interface{}]uint32:
- fastpathTV.EncMapIntfUint32V(v, e)
- case *map[interface{}]uint32:
- fastpathTV.EncMapIntfUint32V(*v, e)
- case map[interface{}]uint64:
- fastpathTV.EncMapIntfUint64V(v, e)
- case *map[interface{}]uint64:
- fastpathTV.EncMapIntfUint64V(*v, e)
- case map[interface{}]uintptr:
- fastpathTV.EncMapIntfUintptrV(v, e)
- case *map[interface{}]uintptr:
- fastpathTV.EncMapIntfUintptrV(*v, e)
- case map[interface{}]int:
- fastpathTV.EncMapIntfIntV(v, e)
- case *map[interface{}]int:
- fastpathTV.EncMapIntfIntV(*v, e)
- case map[interface{}]int8:
- fastpathTV.EncMapIntfInt8V(v, e)
- case *map[interface{}]int8:
- fastpathTV.EncMapIntfInt8V(*v, e)
- case map[interface{}]int16:
- fastpathTV.EncMapIntfInt16V(v, e)
- case *map[interface{}]int16:
- fastpathTV.EncMapIntfInt16V(*v, e)
- case map[interface{}]int32:
- fastpathTV.EncMapIntfInt32V(v, e)
- case *map[interface{}]int32:
- fastpathTV.EncMapIntfInt32V(*v, e)
- case map[interface{}]int64:
- fastpathTV.EncMapIntfInt64V(v, e)
- case *map[interface{}]int64:
- fastpathTV.EncMapIntfInt64V(*v, e)
- case map[interface{}]float32:
- fastpathTV.EncMapIntfFloat32V(v, e)
- case *map[interface{}]float32:
- fastpathTV.EncMapIntfFloat32V(*v, e)
- case map[interface{}]float64:
- fastpathTV.EncMapIntfFloat64V(v, e)
- case *map[interface{}]float64:
- fastpathTV.EncMapIntfFloat64V(*v, e)
- case map[interface{}]bool:
- fastpathTV.EncMapIntfBoolV(v, e)
- case *map[interface{}]bool:
- fastpathTV.EncMapIntfBoolV(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncSliceBoolV(*v, e)
+ }
case map[string]interface{}:
fastpathTV.EncMapStringIntfV(v, e)
case *map[string]interface{}:
- fastpathTV.EncMapStringIntfV(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncMapStringIntfV(*v, e)
+ }
case map[string]string:
fastpathTV.EncMapStringStringV(v, e)
case *map[string]string:
- fastpathTV.EncMapStringStringV(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncMapStringStringV(*v, e)
+ }
+ case map[string][]byte:
+ fastpathTV.EncMapStringBytesV(v, e)
+ case *map[string][]byte:
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncMapStringBytesV(*v, e)
+ }
case map[string]uint:
fastpathTV.EncMapStringUintV(v, e)
case *map[string]uint:
- fastpathTV.EncMapStringUintV(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncMapStringUintV(*v, e)
+ }
case map[string]uint8:
fastpathTV.EncMapStringUint8V(v, e)
case *map[string]uint8:
- fastpathTV.EncMapStringUint8V(*v, e)
- case map[string]uint16:
- fastpathTV.EncMapStringUint16V(v, e)
- case *map[string]uint16:
- fastpathTV.EncMapStringUint16V(*v, e)
- case map[string]uint32:
- fastpathTV.EncMapStringUint32V(v, e)
- case *map[string]uint32:
- fastpathTV.EncMapStringUint32V(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncMapStringUint8V(*v, e)
+ }
case map[string]uint64:
fastpathTV.EncMapStringUint64V(v, e)
case *map[string]uint64:
- fastpathTV.EncMapStringUint64V(*v, e)
- case map[string]uintptr:
- fastpathTV.EncMapStringUintptrV(v, e)
- case *map[string]uintptr:
- fastpathTV.EncMapStringUintptrV(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncMapStringUint64V(*v, e)
+ }
case map[string]int:
fastpathTV.EncMapStringIntV(v, e)
case *map[string]int:
- fastpathTV.EncMapStringIntV(*v, e)
- case map[string]int8:
- fastpathTV.EncMapStringInt8V(v, e)
- case *map[string]int8:
- fastpathTV.EncMapStringInt8V(*v, e)
- case map[string]int16:
- fastpathTV.EncMapStringInt16V(v, e)
- case *map[string]int16:
- fastpathTV.EncMapStringInt16V(*v, e)
- case map[string]int32:
- fastpathTV.EncMapStringInt32V(v, e)
- case *map[string]int32:
- fastpathTV.EncMapStringInt32V(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncMapStringIntV(*v, e)
+ }
case map[string]int64:
fastpathTV.EncMapStringInt64V(v, e)
case *map[string]int64:
- fastpathTV.EncMapStringInt64V(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncMapStringInt64V(*v, e)
+ }
case map[string]float32:
fastpathTV.EncMapStringFloat32V(v, e)
case *map[string]float32:
- fastpathTV.EncMapStringFloat32V(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncMapStringFloat32V(*v, e)
+ }
case map[string]float64:
fastpathTV.EncMapStringFloat64V(v, e)
case *map[string]float64:
- fastpathTV.EncMapStringFloat64V(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncMapStringFloat64V(*v, e)
+ }
case map[string]bool:
fastpathTV.EncMapStringBoolV(v, e)
case *map[string]bool:
- fastpathTV.EncMapStringBoolV(*v, e)
- case map[float32]interface{}:
- fastpathTV.EncMapFloat32IntfV(v, e)
- case *map[float32]interface{}:
- fastpathTV.EncMapFloat32IntfV(*v, e)
- case map[float32]string:
- fastpathTV.EncMapFloat32StringV(v, e)
- case *map[float32]string:
- fastpathTV.EncMapFloat32StringV(*v, e)
- case map[float32]uint:
- fastpathTV.EncMapFloat32UintV(v, e)
- case *map[float32]uint:
- fastpathTV.EncMapFloat32UintV(*v, e)
- case map[float32]uint8:
- fastpathTV.EncMapFloat32Uint8V(v, e)
- case *map[float32]uint8:
- fastpathTV.EncMapFloat32Uint8V(*v, e)
- case map[float32]uint16:
- fastpathTV.EncMapFloat32Uint16V(v, e)
- case *map[float32]uint16:
- fastpathTV.EncMapFloat32Uint16V(*v, e)
- case map[float32]uint32:
- fastpathTV.EncMapFloat32Uint32V(v, e)
- case *map[float32]uint32:
- fastpathTV.EncMapFloat32Uint32V(*v, e)
- case map[float32]uint64:
- fastpathTV.EncMapFloat32Uint64V(v, e)
- case *map[float32]uint64:
- fastpathTV.EncMapFloat32Uint64V(*v, e)
- case map[float32]uintptr:
- fastpathTV.EncMapFloat32UintptrV(v, e)
- case *map[float32]uintptr:
- fastpathTV.EncMapFloat32UintptrV(*v, e)
- case map[float32]int:
- fastpathTV.EncMapFloat32IntV(v, e)
- case *map[float32]int:
- fastpathTV.EncMapFloat32IntV(*v, e)
- case map[float32]int8:
- fastpathTV.EncMapFloat32Int8V(v, e)
- case *map[float32]int8:
- fastpathTV.EncMapFloat32Int8V(*v, e)
- case map[float32]int16:
- fastpathTV.EncMapFloat32Int16V(v, e)
- case *map[float32]int16:
- fastpathTV.EncMapFloat32Int16V(*v, e)
- case map[float32]int32:
- fastpathTV.EncMapFloat32Int32V(v, e)
- case *map[float32]int32:
- fastpathTV.EncMapFloat32Int32V(*v, e)
- case map[float32]int64:
- fastpathTV.EncMapFloat32Int64V(v, e)
- case *map[float32]int64:
- fastpathTV.EncMapFloat32Int64V(*v, e)
- case map[float32]float32:
- fastpathTV.EncMapFloat32Float32V(v, e)
- case *map[float32]float32:
- fastpathTV.EncMapFloat32Float32V(*v, e)
- case map[float32]float64:
- fastpathTV.EncMapFloat32Float64V(v, e)
- case *map[float32]float64:
- fastpathTV.EncMapFloat32Float64V(*v, e)
- case map[float32]bool:
- fastpathTV.EncMapFloat32BoolV(v, e)
- case *map[float32]bool:
- fastpathTV.EncMapFloat32BoolV(*v, e)
- case map[float64]interface{}:
- fastpathTV.EncMapFloat64IntfV(v, e)
- case *map[float64]interface{}:
- fastpathTV.EncMapFloat64IntfV(*v, e)
- case map[float64]string:
- fastpathTV.EncMapFloat64StringV(v, e)
- case *map[float64]string:
- fastpathTV.EncMapFloat64StringV(*v, e)
- case map[float64]uint:
- fastpathTV.EncMapFloat64UintV(v, e)
- case *map[float64]uint:
- fastpathTV.EncMapFloat64UintV(*v, e)
- case map[float64]uint8:
- fastpathTV.EncMapFloat64Uint8V(v, e)
- case *map[float64]uint8:
- fastpathTV.EncMapFloat64Uint8V(*v, e)
- case map[float64]uint16:
- fastpathTV.EncMapFloat64Uint16V(v, e)
- case *map[float64]uint16:
- fastpathTV.EncMapFloat64Uint16V(*v, e)
- case map[float64]uint32:
- fastpathTV.EncMapFloat64Uint32V(v, e)
- case *map[float64]uint32:
- fastpathTV.EncMapFloat64Uint32V(*v, e)
- case map[float64]uint64:
- fastpathTV.EncMapFloat64Uint64V(v, e)
- case *map[float64]uint64:
- fastpathTV.EncMapFloat64Uint64V(*v, e)
- case map[float64]uintptr:
- fastpathTV.EncMapFloat64UintptrV(v, e)
- case *map[float64]uintptr:
- fastpathTV.EncMapFloat64UintptrV(*v, e)
- case map[float64]int:
- fastpathTV.EncMapFloat64IntV(v, e)
- case *map[float64]int:
- fastpathTV.EncMapFloat64IntV(*v, e)
- case map[float64]int8:
- fastpathTV.EncMapFloat64Int8V(v, e)
- case *map[float64]int8:
- fastpathTV.EncMapFloat64Int8V(*v, e)
- case map[float64]int16:
- fastpathTV.EncMapFloat64Int16V(v, e)
- case *map[float64]int16:
- fastpathTV.EncMapFloat64Int16V(*v, e)
- case map[float64]int32:
- fastpathTV.EncMapFloat64Int32V(v, e)
- case *map[float64]int32:
- fastpathTV.EncMapFloat64Int32V(*v, e)
- case map[float64]int64:
- fastpathTV.EncMapFloat64Int64V(v, e)
- case *map[float64]int64:
- fastpathTV.EncMapFloat64Int64V(*v, e)
- case map[float64]float32:
- fastpathTV.EncMapFloat64Float32V(v, e)
- case *map[float64]float32:
- fastpathTV.EncMapFloat64Float32V(*v, e)
- case map[float64]float64:
- fastpathTV.EncMapFloat64Float64V(v, e)
- case *map[float64]float64:
- fastpathTV.EncMapFloat64Float64V(*v, e)
- case map[float64]bool:
- fastpathTV.EncMapFloat64BoolV(v, e)
- case *map[float64]bool:
- fastpathTV.EncMapFloat64BoolV(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncMapStringBoolV(*v, e)
+ }
case map[uint]interface{}:
fastpathTV.EncMapUintIntfV(v, e)
case *map[uint]interface{}:
- fastpathTV.EncMapUintIntfV(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncMapUintIntfV(*v, e)
+ }
case map[uint]string:
fastpathTV.EncMapUintStringV(v, e)
case *map[uint]string:
- fastpathTV.EncMapUintStringV(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncMapUintStringV(*v, e)
+ }
+ case map[uint][]byte:
+ fastpathTV.EncMapUintBytesV(v, e)
+ case *map[uint][]byte:
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncMapUintBytesV(*v, e)
+ }
case map[uint]uint:
fastpathTV.EncMapUintUintV(v, e)
case *map[uint]uint:
- fastpathTV.EncMapUintUintV(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncMapUintUintV(*v, e)
+ }
case map[uint]uint8:
fastpathTV.EncMapUintUint8V(v, e)
case *map[uint]uint8:
- fastpathTV.EncMapUintUint8V(*v, e)
- case map[uint]uint16:
- fastpathTV.EncMapUintUint16V(v, e)
- case *map[uint]uint16:
- fastpathTV.EncMapUintUint16V(*v, e)
- case map[uint]uint32:
- fastpathTV.EncMapUintUint32V(v, e)
- case *map[uint]uint32:
- fastpathTV.EncMapUintUint32V(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncMapUintUint8V(*v, e)
+ }
case map[uint]uint64:
fastpathTV.EncMapUintUint64V(v, e)
case *map[uint]uint64:
- fastpathTV.EncMapUintUint64V(*v, e)
- case map[uint]uintptr:
- fastpathTV.EncMapUintUintptrV(v, e)
- case *map[uint]uintptr:
- fastpathTV.EncMapUintUintptrV(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncMapUintUint64V(*v, e)
+ }
case map[uint]int:
fastpathTV.EncMapUintIntV(v, e)
case *map[uint]int:
- fastpathTV.EncMapUintIntV(*v, e)
- case map[uint]int8:
- fastpathTV.EncMapUintInt8V(v, e)
- case *map[uint]int8:
- fastpathTV.EncMapUintInt8V(*v, e)
- case map[uint]int16:
- fastpathTV.EncMapUintInt16V(v, e)
- case *map[uint]int16:
- fastpathTV.EncMapUintInt16V(*v, e)
- case map[uint]int32:
- fastpathTV.EncMapUintInt32V(v, e)
- case *map[uint]int32:
- fastpathTV.EncMapUintInt32V(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncMapUintIntV(*v, e)
+ }
case map[uint]int64:
fastpathTV.EncMapUintInt64V(v, e)
case *map[uint]int64:
- fastpathTV.EncMapUintInt64V(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncMapUintInt64V(*v, e)
+ }
case map[uint]float32:
fastpathTV.EncMapUintFloat32V(v, e)
case *map[uint]float32:
- fastpathTV.EncMapUintFloat32V(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncMapUintFloat32V(*v, e)
+ }
case map[uint]float64:
fastpathTV.EncMapUintFloat64V(v, e)
case *map[uint]float64:
- fastpathTV.EncMapUintFloat64V(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncMapUintFloat64V(*v, e)
+ }
case map[uint]bool:
fastpathTV.EncMapUintBoolV(v, e)
case *map[uint]bool:
- fastpathTV.EncMapUintBoolV(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncMapUintBoolV(*v, e)
+ }
case map[uint8]interface{}:
fastpathTV.EncMapUint8IntfV(v, e)
case *map[uint8]interface{}:
- fastpathTV.EncMapUint8IntfV(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncMapUint8IntfV(*v, e)
+ }
case map[uint8]string:
fastpathTV.EncMapUint8StringV(v, e)
case *map[uint8]string:
- fastpathTV.EncMapUint8StringV(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncMapUint8StringV(*v, e)
+ }
+ case map[uint8][]byte:
+ fastpathTV.EncMapUint8BytesV(v, e)
+ case *map[uint8][]byte:
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncMapUint8BytesV(*v, e)
+ }
case map[uint8]uint:
fastpathTV.EncMapUint8UintV(v, e)
case *map[uint8]uint:
- fastpathTV.EncMapUint8UintV(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncMapUint8UintV(*v, e)
+ }
case map[uint8]uint8:
fastpathTV.EncMapUint8Uint8V(v, e)
case *map[uint8]uint8:
- fastpathTV.EncMapUint8Uint8V(*v, e)
- case map[uint8]uint16:
- fastpathTV.EncMapUint8Uint16V(v, e)
- case *map[uint8]uint16:
- fastpathTV.EncMapUint8Uint16V(*v, e)
- case map[uint8]uint32:
- fastpathTV.EncMapUint8Uint32V(v, e)
- case *map[uint8]uint32:
- fastpathTV.EncMapUint8Uint32V(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncMapUint8Uint8V(*v, e)
+ }
case map[uint8]uint64:
fastpathTV.EncMapUint8Uint64V(v, e)
case *map[uint8]uint64:
- fastpathTV.EncMapUint8Uint64V(*v, e)
- case map[uint8]uintptr:
- fastpathTV.EncMapUint8UintptrV(v, e)
- case *map[uint8]uintptr:
- fastpathTV.EncMapUint8UintptrV(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncMapUint8Uint64V(*v, e)
+ }
case map[uint8]int:
fastpathTV.EncMapUint8IntV(v, e)
case *map[uint8]int:
- fastpathTV.EncMapUint8IntV(*v, e)
- case map[uint8]int8:
- fastpathTV.EncMapUint8Int8V(v, e)
- case *map[uint8]int8:
- fastpathTV.EncMapUint8Int8V(*v, e)
- case map[uint8]int16:
- fastpathTV.EncMapUint8Int16V(v, e)
- case *map[uint8]int16:
- fastpathTV.EncMapUint8Int16V(*v, e)
- case map[uint8]int32:
- fastpathTV.EncMapUint8Int32V(v, e)
- case *map[uint8]int32:
- fastpathTV.EncMapUint8Int32V(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncMapUint8IntV(*v, e)
+ }
case map[uint8]int64:
fastpathTV.EncMapUint8Int64V(v, e)
case *map[uint8]int64:
- fastpathTV.EncMapUint8Int64V(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncMapUint8Int64V(*v, e)
+ }
case map[uint8]float32:
fastpathTV.EncMapUint8Float32V(v, e)
case *map[uint8]float32:
- fastpathTV.EncMapUint8Float32V(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncMapUint8Float32V(*v, e)
+ }
case map[uint8]float64:
fastpathTV.EncMapUint8Float64V(v, e)
case *map[uint8]float64:
- fastpathTV.EncMapUint8Float64V(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncMapUint8Float64V(*v, e)
+ }
case map[uint8]bool:
fastpathTV.EncMapUint8BoolV(v, e)
case *map[uint8]bool:
- fastpathTV.EncMapUint8BoolV(*v, e)
- case map[uint16]interface{}:
- fastpathTV.EncMapUint16IntfV(v, e)
- case *map[uint16]interface{}:
- fastpathTV.EncMapUint16IntfV(*v, e)
- case map[uint16]string:
- fastpathTV.EncMapUint16StringV(v, e)
- case *map[uint16]string:
- fastpathTV.EncMapUint16StringV(*v, e)
- case map[uint16]uint:
- fastpathTV.EncMapUint16UintV(v, e)
- case *map[uint16]uint:
- fastpathTV.EncMapUint16UintV(*v, e)
- case map[uint16]uint8:
- fastpathTV.EncMapUint16Uint8V(v, e)
- case *map[uint16]uint8:
- fastpathTV.EncMapUint16Uint8V(*v, e)
- case map[uint16]uint16:
- fastpathTV.EncMapUint16Uint16V(v, e)
- case *map[uint16]uint16:
- fastpathTV.EncMapUint16Uint16V(*v, e)
- case map[uint16]uint32:
- fastpathTV.EncMapUint16Uint32V(v, e)
- case *map[uint16]uint32:
- fastpathTV.EncMapUint16Uint32V(*v, e)
- case map[uint16]uint64:
- fastpathTV.EncMapUint16Uint64V(v, e)
- case *map[uint16]uint64:
- fastpathTV.EncMapUint16Uint64V(*v, e)
- case map[uint16]uintptr:
- fastpathTV.EncMapUint16UintptrV(v, e)
- case *map[uint16]uintptr:
- fastpathTV.EncMapUint16UintptrV(*v, e)
- case map[uint16]int:
- fastpathTV.EncMapUint16IntV(v, e)
- case *map[uint16]int:
- fastpathTV.EncMapUint16IntV(*v, e)
- case map[uint16]int8:
- fastpathTV.EncMapUint16Int8V(v, e)
- case *map[uint16]int8:
- fastpathTV.EncMapUint16Int8V(*v, e)
- case map[uint16]int16:
- fastpathTV.EncMapUint16Int16V(v, e)
- case *map[uint16]int16:
- fastpathTV.EncMapUint16Int16V(*v, e)
- case map[uint16]int32:
- fastpathTV.EncMapUint16Int32V(v, e)
- case *map[uint16]int32:
- fastpathTV.EncMapUint16Int32V(*v, e)
- case map[uint16]int64:
- fastpathTV.EncMapUint16Int64V(v, e)
- case *map[uint16]int64:
- fastpathTV.EncMapUint16Int64V(*v, e)
- case map[uint16]float32:
- fastpathTV.EncMapUint16Float32V(v, e)
- case *map[uint16]float32:
- fastpathTV.EncMapUint16Float32V(*v, e)
- case map[uint16]float64:
- fastpathTV.EncMapUint16Float64V(v, e)
- case *map[uint16]float64:
- fastpathTV.EncMapUint16Float64V(*v, e)
- case map[uint16]bool:
- fastpathTV.EncMapUint16BoolV(v, e)
- case *map[uint16]bool:
- fastpathTV.EncMapUint16BoolV(*v, e)
- case map[uint32]interface{}:
- fastpathTV.EncMapUint32IntfV(v, e)
- case *map[uint32]interface{}:
- fastpathTV.EncMapUint32IntfV(*v, e)
- case map[uint32]string:
- fastpathTV.EncMapUint32StringV(v, e)
- case *map[uint32]string:
- fastpathTV.EncMapUint32StringV(*v, e)
- case map[uint32]uint:
- fastpathTV.EncMapUint32UintV(v, e)
- case *map[uint32]uint:
- fastpathTV.EncMapUint32UintV(*v, e)
- case map[uint32]uint8:
- fastpathTV.EncMapUint32Uint8V(v, e)
- case *map[uint32]uint8:
- fastpathTV.EncMapUint32Uint8V(*v, e)
- case map[uint32]uint16:
- fastpathTV.EncMapUint32Uint16V(v, e)
- case *map[uint32]uint16:
- fastpathTV.EncMapUint32Uint16V(*v, e)
- case map[uint32]uint32:
- fastpathTV.EncMapUint32Uint32V(v, e)
- case *map[uint32]uint32:
- fastpathTV.EncMapUint32Uint32V(*v, e)
- case map[uint32]uint64:
- fastpathTV.EncMapUint32Uint64V(v, e)
- case *map[uint32]uint64:
- fastpathTV.EncMapUint32Uint64V(*v, e)
- case map[uint32]uintptr:
- fastpathTV.EncMapUint32UintptrV(v, e)
- case *map[uint32]uintptr:
- fastpathTV.EncMapUint32UintptrV(*v, e)
- case map[uint32]int:
- fastpathTV.EncMapUint32IntV(v, e)
- case *map[uint32]int:
- fastpathTV.EncMapUint32IntV(*v, e)
- case map[uint32]int8:
- fastpathTV.EncMapUint32Int8V(v, e)
- case *map[uint32]int8:
- fastpathTV.EncMapUint32Int8V(*v, e)
- case map[uint32]int16:
- fastpathTV.EncMapUint32Int16V(v, e)
- case *map[uint32]int16:
- fastpathTV.EncMapUint32Int16V(*v, e)
- case map[uint32]int32:
- fastpathTV.EncMapUint32Int32V(v, e)
- case *map[uint32]int32:
- fastpathTV.EncMapUint32Int32V(*v, e)
- case map[uint32]int64:
- fastpathTV.EncMapUint32Int64V(v, e)
- case *map[uint32]int64:
- fastpathTV.EncMapUint32Int64V(*v, e)
- case map[uint32]float32:
- fastpathTV.EncMapUint32Float32V(v, e)
- case *map[uint32]float32:
- fastpathTV.EncMapUint32Float32V(*v, e)
- case map[uint32]float64:
- fastpathTV.EncMapUint32Float64V(v, e)
- case *map[uint32]float64:
- fastpathTV.EncMapUint32Float64V(*v, e)
- case map[uint32]bool:
- fastpathTV.EncMapUint32BoolV(v, e)
- case *map[uint32]bool:
- fastpathTV.EncMapUint32BoolV(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncMapUint8BoolV(*v, e)
+ }
case map[uint64]interface{}:
fastpathTV.EncMapUint64IntfV(v, e)
case *map[uint64]interface{}:
- fastpathTV.EncMapUint64IntfV(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncMapUint64IntfV(*v, e)
+ }
case map[uint64]string:
fastpathTV.EncMapUint64StringV(v, e)
case *map[uint64]string:
- fastpathTV.EncMapUint64StringV(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncMapUint64StringV(*v, e)
+ }
+ case map[uint64][]byte:
+ fastpathTV.EncMapUint64BytesV(v, e)
+ case *map[uint64][]byte:
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncMapUint64BytesV(*v, e)
+ }
case map[uint64]uint:
fastpathTV.EncMapUint64UintV(v, e)
case *map[uint64]uint:
- fastpathTV.EncMapUint64UintV(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncMapUint64UintV(*v, e)
+ }
case map[uint64]uint8:
fastpathTV.EncMapUint64Uint8V(v, e)
case *map[uint64]uint8:
- fastpathTV.EncMapUint64Uint8V(*v, e)
- case map[uint64]uint16:
- fastpathTV.EncMapUint64Uint16V(v, e)
- case *map[uint64]uint16:
- fastpathTV.EncMapUint64Uint16V(*v, e)
- case map[uint64]uint32:
- fastpathTV.EncMapUint64Uint32V(v, e)
- case *map[uint64]uint32:
- fastpathTV.EncMapUint64Uint32V(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncMapUint64Uint8V(*v, e)
+ }
case map[uint64]uint64:
fastpathTV.EncMapUint64Uint64V(v, e)
case *map[uint64]uint64:
- fastpathTV.EncMapUint64Uint64V(*v, e)
- case map[uint64]uintptr:
- fastpathTV.EncMapUint64UintptrV(v, e)
- case *map[uint64]uintptr:
- fastpathTV.EncMapUint64UintptrV(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncMapUint64Uint64V(*v, e)
+ }
case map[uint64]int:
fastpathTV.EncMapUint64IntV(v, e)
case *map[uint64]int:
- fastpathTV.EncMapUint64IntV(*v, e)
- case map[uint64]int8:
- fastpathTV.EncMapUint64Int8V(v, e)
- case *map[uint64]int8:
- fastpathTV.EncMapUint64Int8V(*v, e)
- case map[uint64]int16:
- fastpathTV.EncMapUint64Int16V(v, e)
- case *map[uint64]int16:
- fastpathTV.EncMapUint64Int16V(*v, e)
- case map[uint64]int32:
- fastpathTV.EncMapUint64Int32V(v, e)
- case *map[uint64]int32:
- fastpathTV.EncMapUint64Int32V(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncMapUint64IntV(*v, e)
+ }
case map[uint64]int64:
fastpathTV.EncMapUint64Int64V(v, e)
case *map[uint64]int64:
- fastpathTV.EncMapUint64Int64V(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncMapUint64Int64V(*v, e)
+ }
case map[uint64]float32:
fastpathTV.EncMapUint64Float32V(v, e)
case *map[uint64]float32:
- fastpathTV.EncMapUint64Float32V(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncMapUint64Float32V(*v, e)
+ }
case map[uint64]float64:
fastpathTV.EncMapUint64Float64V(v, e)
case *map[uint64]float64:
- fastpathTV.EncMapUint64Float64V(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncMapUint64Float64V(*v, e)
+ }
case map[uint64]bool:
fastpathTV.EncMapUint64BoolV(v, e)
case *map[uint64]bool:
- fastpathTV.EncMapUint64BoolV(*v, e)
- case map[uintptr]interface{}:
- fastpathTV.EncMapUintptrIntfV(v, e)
- case *map[uintptr]interface{}:
- fastpathTV.EncMapUintptrIntfV(*v, e)
- case map[uintptr]string:
- fastpathTV.EncMapUintptrStringV(v, e)
- case *map[uintptr]string:
- fastpathTV.EncMapUintptrStringV(*v, e)
- case map[uintptr]uint:
- fastpathTV.EncMapUintptrUintV(v, e)
- case *map[uintptr]uint:
- fastpathTV.EncMapUintptrUintV(*v, e)
- case map[uintptr]uint8:
- fastpathTV.EncMapUintptrUint8V(v, e)
- case *map[uintptr]uint8:
- fastpathTV.EncMapUintptrUint8V(*v, e)
- case map[uintptr]uint16:
- fastpathTV.EncMapUintptrUint16V(v, e)
- case *map[uintptr]uint16:
- fastpathTV.EncMapUintptrUint16V(*v, e)
- case map[uintptr]uint32:
- fastpathTV.EncMapUintptrUint32V(v, e)
- case *map[uintptr]uint32:
- fastpathTV.EncMapUintptrUint32V(*v, e)
- case map[uintptr]uint64:
- fastpathTV.EncMapUintptrUint64V(v, e)
- case *map[uintptr]uint64:
- fastpathTV.EncMapUintptrUint64V(*v, e)
- case map[uintptr]uintptr:
- fastpathTV.EncMapUintptrUintptrV(v, e)
- case *map[uintptr]uintptr:
- fastpathTV.EncMapUintptrUintptrV(*v, e)
- case map[uintptr]int:
- fastpathTV.EncMapUintptrIntV(v, e)
- case *map[uintptr]int:
- fastpathTV.EncMapUintptrIntV(*v, e)
- case map[uintptr]int8:
- fastpathTV.EncMapUintptrInt8V(v, e)
- case *map[uintptr]int8:
- fastpathTV.EncMapUintptrInt8V(*v, e)
- case map[uintptr]int16:
- fastpathTV.EncMapUintptrInt16V(v, e)
- case *map[uintptr]int16:
- fastpathTV.EncMapUintptrInt16V(*v, e)
- case map[uintptr]int32:
- fastpathTV.EncMapUintptrInt32V(v, e)
- case *map[uintptr]int32:
- fastpathTV.EncMapUintptrInt32V(*v, e)
- case map[uintptr]int64:
- fastpathTV.EncMapUintptrInt64V(v, e)
- case *map[uintptr]int64:
- fastpathTV.EncMapUintptrInt64V(*v, e)
- case map[uintptr]float32:
- fastpathTV.EncMapUintptrFloat32V(v, e)
- case *map[uintptr]float32:
- fastpathTV.EncMapUintptrFloat32V(*v, e)
- case map[uintptr]float64:
- fastpathTV.EncMapUintptrFloat64V(v, e)
- case *map[uintptr]float64:
- fastpathTV.EncMapUintptrFloat64V(*v, e)
- case map[uintptr]bool:
- fastpathTV.EncMapUintptrBoolV(v, e)
- case *map[uintptr]bool:
- fastpathTV.EncMapUintptrBoolV(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncMapUint64BoolV(*v, e)
+ }
case map[int]interface{}:
fastpathTV.EncMapIntIntfV(v, e)
case *map[int]interface{}:
- fastpathTV.EncMapIntIntfV(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncMapIntIntfV(*v, e)
+ }
case map[int]string:
fastpathTV.EncMapIntStringV(v, e)
case *map[int]string:
- fastpathTV.EncMapIntStringV(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncMapIntStringV(*v, e)
+ }
+ case map[int][]byte:
+ fastpathTV.EncMapIntBytesV(v, e)
+ case *map[int][]byte:
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncMapIntBytesV(*v, e)
+ }
case map[int]uint:
fastpathTV.EncMapIntUintV(v, e)
case *map[int]uint:
- fastpathTV.EncMapIntUintV(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncMapIntUintV(*v, e)
+ }
case map[int]uint8:
fastpathTV.EncMapIntUint8V(v, e)
case *map[int]uint8:
- fastpathTV.EncMapIntUint8V(*v, e)
- case map[int]uint16:
- fastpathTV.EncMapIntUint16V(v, e)
- case *map[int]uint16:
- fastpathTV.EncMapIntUint16V(*v, e)
- case map[int]uint32:
- fastpathTV.EncMapIntUint32V(v, e)
- case *map[int]uint32:
- fastpathTV.EncMapIntUint32V(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncMapIntUint8V(*v, e)
+ }
case map[int]uint64:
fastpathTV.EncMapIntUint64V(v, e)
case *map[int]uint64:
- fastpathTV.EncMapIntUint64V(*v, e)
- case map[int]uintptr:
- fastpathTV.EncMapIntUintptrV(v, e)
- case *map[int]uintptr:
- fastpathTV.EncMapIntUintptrV(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncMapIntUint64V(*v, e)
+ }
case map[int]int:
fastpathTV.EncMapIntIntV(v, e)
case *map[int]int:
- fastpathTV.EncMapIntIntV(*v, e)
- case map[int]int8:
- fastpathTV.EncMapIntInt8V(v, e)
- case *map[int]int8:
- fastpathTV.EncMapIntInt8V(*v, e)
- case map[int]int16:
- fastpathTV.EncMapIntInt16V(v, e)
- case *map[int]int16:
- fastpathTV.EncMapIntInt16V(*v, e)
- case map[int]int32:
- fastpathTV.EncMapIntInt32V(v, e)
- case *map[int]int32:
- fastpathTV.EncMapIntInt32V(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncMapIntIntV(*v, e)
+ }
case map[int]int64:
fastpathTV.EncMapIntInt64V(v, e)
case *map[int]int64:
- fastpathTV.EncMapIntInt64V(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncMapIntInt64V(*v, e)
+ }
case map[int]float32:
fastpathTV.EncMapIntFloat32V(v, e)
case *map[int]float32:
- fastpathTV.EncMapIntFloat32V(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncMapIntFloat32V(*v, e)
+ }
case map[int]float64:
fastpathTV.EncMapIntFloat64V(v, e)
case *map[int]float64:
- fastpathTV.EncMapIntFloat64V(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncMapIntFloat64V(*v, e)
+ }
case map[int]bool:
fastpathTV.EncMapIntBoolV(v, e)
case *map[int]bool:
- fastpathTV.EncMapIntBoolV(*v, e)
- case map[int8]interface{}:
- fastpathTV.EncMapInt8IntfV(v, e)
- case *map[int8]interface{}:
- fastpathTV.EncMapInt8IntfV(*v, e)
- case map[int8]string:
- fastpathTV.EncMapInt8StringV(v, e)
- case *map[int8]string:
- fastpathTV.EncMapInt8StringV(*v, e)
- case map[int8]uint:
- fastpathTV.EncMapInt8UintV(v, e)
- case *map[int8]uint:
- fastpathTV.EncMapInt8UintV(*v, e)
- case map[int8]uint8:
- fastpathTV.EncMapInt8Uint8V(v, e)
- case *map[int8]uint8:
- fastpathTV.EncMapInt8Uint8V(*v, e)
- case map[int8]uint16:
- fastpathTV.EncMapInt8Uint16V(v, e)
- case *map[int8]uint16:
- fastpathTV.EncMapInt8Uint16V(*v, e)
- case map[int8]uint32:
- fastpathTV.EncMapInt8Uint32V(v, e)
- case *map[int8]uint32:
- fastpathTV.EncMapInt8Uint32V(*v, e)
- case map[int8]uint64:
- fastpathTV.EncMapInt8Uint64V(v, e)
- case *map[int8]uint64:
- fastpathTV.EncMapInt8Uint64V(*v, e)
- case map[int8]uintptr:
- fastpathTV.EncMapInt8UintptrV(v, e)
- case *map[int8]uintptr:
- fastpathTV.EncMapInt8UintptrV(*v, e)
- case map[int8]int:
- fastpathTV.EncMapInt8IntV(v, e)
- case *map[int8]int:
- fastpathTV.EncMapInt8IntV(*v, e)
- case map[int8]int8:
- fastpathTV.EncMapInt8Int8V(v, e)
- case *map[int8]int8:
- fastpathTV.EncMapInt8Int8V(*v, e)
- case map[int8]int16:
- fastpathTV.EncMapInt8Int16V(v, e)
- case *map[int8]int16:
- fastpathTV.EncMapInt8Int16V(*v, e)
- case map[int8]int32:
- fastpathTV.EncMapInt8Int32V(v, e)
- case *map[int8]int32:
- fastpathTV.EncMapInt8Int32V(*v, e)
- case map[int8]int64:
- fastpathTV.EncMapInt8Int64V(v, e)
- case *map[int8]int64:
- fastpathTV.EncMapInt8Int64V(*v, e)
- case map[int8]float32:
- fastpathTV.EncMapInt8Float32V(v, e)
- case *map[int8]float32:
- fastpathTV.EncMapInt8Float32V(*v, e)
- case map[int8]float64:
- fastpathTV.EncMapInt8Float64V(v, e)
- case *map[int8]float64:
- fastpathTV.EncMapInt8Float64V(*v, e)
- case map[int8]bool:
- fastpathTV.EncMapInt8BoolV(v, e)
- case *map[int8]bool:
- fastpathTV.EncMapInt8BoolV(*v, e)
- case map[int16]interface{}:
- fastpathTV.EncMapInt16IntfV(v, e)
- case *map[int16]interface{}:
- fastpathTV.EncMapInt16IntfV(*v, e)
- case map[int16]string:
- fastpathTV.EncMapInt16StringV(v, e)
- case *map[int16]string:
- fastpathTV.EncMapInt16StringV(*v, e)
- case map[int16]uint:
- fastpathTV.EncMapInt16UintV(v, e)
- case *map[int16]uint:
- fastpathTV.EncMapInt16UintV(*v, e)
- case map[int16]uint8:
- fastpathTV.EncMapInt16Uint8V(v, e)
- case *map[int16]uint8:
- fastpathTV.EncMapInt16Uint8V(*v, e)
- case map[int16]uint16:
- fastpathTV.EncMapInt16Uint16V(v, e)
- case *map[int16]uint16:
- fastpathTV.EncMapInt16Uint16V(*v, e)
- case map[int16]uint32:
- fastpathTV.EncMapInt16Uint32V(v, e)
- case *map[int16]uint32:
- fastpathTV.EncMapInt16Uint32V(*v, e)
- case map[int16]uint64:
- fastpathTV.EncMapInt16Uint64V(v, e)
- case *map[int16]uint64:
- fastpathTV.EncMapInt16Uint64V(*v, e)
- case map[int16]uintptr:
- fastpathTV.EncMapInt16UintptrV(v, e)
- case *map[int16]uintptr:
- fastpathTV.EncMapInt16UintptrV(*v, e)
- case map[int16]int:
- fastpathTV.EncMapInt16IntV(v, e)
- case *map[int16]int:
- fastpathTV.EncMapInt16IntV(*v, e)
- case map[int16]int8:
- fastpathTV.EncMapInt16Int8V(v, e)
- case *map[int16]int8:
- fastpathTV.EncMapInt16Int8V(*v, e)
- case map[int16]int16:
- fastpathTV.EncMapInt16Int16V(v, e)
- case *map[int16]int16:
- fastpathTV.EncMapInt16Int16V(*v, e)
- case map[int16]int32:
- fastpathTV.EncMapInt16Int32V(v, e)
- case *map[int16]int32:
- fastpathTV.EncMapInt16Int32V(*v, e)
- case map[int16]int64:
- fastpathTV.EncMapInt16Int64V(v, e)
- case *map[int16]int64:
- fastpathTV.EncMapInt16Int64V(*v, e)
- case map[int16]float32:
- fastpathTV.EncMapInt16Float32V(v, e)
- case *map[int16]float32:
- fastpathTV.EncMapInt16Float32V(*v, e)
- case map[int16]float64:
- fastpathTV.EncMapInt16Float64V(v, e)
- case *map[int16]float64:
- fastpathTV.EncMapInt16Float64V(*v, e)
- case map[int16]bool:
- fastpathTV.EncMapInt16BoolV(v, e)
- case *map[int16]bool:
- fastpathTV.EncMapInt16BoolV(*v, e)
- case map[int32]interface{}:
- fastpathTV.EncMapInt32IntfV(v, e)
- case *map[int32]interface{}:
- fastpathTV.EncMapInt32IntfV(*v, e)
- case map[int32]string:
- fastpathTV.EncMapInt32StringV(v, e)
- case *map[int32]string:
- fastpathTV.EncMapInt32StringV(*v, e)
- case map[int32]uint:
- fastpathTV.EncMapInt32UintV(v, e)
- case *map[int32]uint:
- fastpathTV.EncMapInt32UintV(*v, e)
- case map[int32]uint8:
- fastpathTV.EncMapInt32Uint8V(v, e)
- case *map[int32]uint8:
- fastpathTV.EncMapInt32Uint8V(*v, e)
- case map[int32]uint16:
- fastpathTV.EncMapInt32Uint16V(v, e)
- case *map[int32]uint16:
- fastpathTV.EncMapInt32Uint16V(*v, e)
- case map[int32]uint32:
- fastpathTV.EncMapInt32Uint32V(v, e)
- case *map[int32]uint32:
- fastpathTV.EncMapInt32Uint32V(*v, e)
- case map[int32]uint64:
- fastpathTV.EncMapInt32Uint64V(v, e)
- case *map[int32]uint64:
- fastpathTV.EncMapInt32Uint64V(*v, e)
- case map[int32]uintptr:
- fastpathTV.EncMapInt32UintptrV(v, e)
- case *map[int32]uintptr:
- fastpathTV.EncMapInt32UintptrV(*v, e)
- case map[int32]int:
- fastpathTV.EncMapInt32IntV(v, e)
- case *map[int32]int:
- fastpathTV.EncMapInt32IntV(*v, e)
- case map[int32]int8:
- fastpathTV.EncMapInt32Int8V(v, e)
- case *map[int32]int8:
- fastpathTV.EncMapInt32Int8V(*v, e)
- case map[int32]int16:
- fastpathTV.EncMapInt32Int16V(v, e)
- case *map[int32]int16:
- fastpathTV.EncMapInt32Int16V(*v, e)
- case map[int32]int32:
- fastpathTV.EncMapInt32Int32V(v, e)
- case *map[int32]int32:
- fastpathTV.EncMapInt32Int32V(*v, e)
- case map[int32]int64:
- fastpathTV.EncMapInt32Int64V(v, e)
- case *map[int32]int64:
- fastpathTV.EncMapInt32Int64V(*v, e)
- case map[int32]float32:
- fastpathTV.EncMapInt32Float32V(v, e)
- case *map[int32]float32:
- fastpathTV.EncMapInt32Float32V(*v, e)
- case map[int32]float64:
- fastpathTV.EncMapInt32Float64V(v, e)
- case *map[int32]float64:
- fastpathTV.EncMapInt32Float64V(*v, e)
- case map[int32]bool:
- fastpathTV.EncMapInt32BoolV(v, e)
- case *map[int32]bool:
- fastpathTV.EncMapInt32BoolV(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncMapIntBoolV(*v, e)
+ }
case map[int64]interface{}:
fastpathTV.EncMapInt64IntfV(v, e)
case *map[int64]interface{}:
- fastpathTV.EncMapInt64IntfV(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncMapInt64IntfV(*v, e)
+ }
case map[int64]string:
fastpathTV.EncMapInt64StringV(v, e)
case *map[int64]string:
- fastpathTV.EncMapInt64StringV(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncMapInt64StringV(*v, e)
+ }
+ case map[int64][]byte:
+ fastpathTV.EncMapInt64BytesV(v, e)
+ case *map[int64][]byte:
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncMapInt64BytesV(*v, e)
+ }
case map[int64]uint:
fastpathTV.EncMapInt64UintV(v, e)
case *map[int64]uint:
- fastpathTV.EncMapInt64UintV(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncMapInt64UintV(*v, e)
+ }
case map[int64]uint8:
fastpathTV.EncMapInt64Uint8V(v, e)
case *map[int64]uint8:
- fastpathTV.EncMapInt64Uint8V(*v, e)
- case map[int64]uint16:
- fastpathTV.EncMapInt64Uint16V(v, e)
- case *map[int64]uint16:
- fastpathTV.EncMapInt64Uint16V(*v, e)
- case map[int64]uint32:
- fastpathTV.EncMapInt64Uint32V(v, e)
- case *map[int64]uint32:
- fastpathTV.EncMapInt64Uint32V(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncMapInt64Uint8V(*v, e)
+ }
case map[int64]uint64:
fastpathTV.EncMapInt64Uint64V(v, e)
case *map[int64]uint64:
- fastpathTV.EncMapInt64Uint64V(*v, e)
- case map[int64]uintptr:
- fastpathTV.EncMapInt64UintptrV(v, e)
- case *map[int64]uintptr:
- fastpathTV.EncMapInt64UintptrV(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncMapInt64Uint64V(*v, e)
+ }
case map[int64]int:
fastpathTV.EncMapInt64IntV(v, e)
case *map[int64]int:
- fastpathTV.EncMapInt64IntV(*v, e)
- case map[int64]int8:
- fastpathTV.EncMapInt64Int8V(v, e)
- case *map[int64]int8:
- fastpathTV.EncMapInt64Int8V(*v, e)
- case map[int64]int16:
- fastpathTV.EncMapInt64Int16V(v, e)
- case *map[int64]int16:
- fastpathTV.EncMapInt64Int16V(*v, e)
- case map[int64]int32:
- fastpathTV.EncMapInt64Int32V(v, e)
- case *map[int64]int32:
- fastpathTV.EncMapInt64Int32V(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncMapInt64IntV(*v, e)
+ }
case map[int64]int64:
fastpathTV.EncMapInt64Int64V(v, e)
case *map[int64]int64:
- fastpathTV.EncMapInt64Int64V(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncMapInt64Int64V(*v, e)
+ }
case map[int64]float32:
fastpathTV.EncMapInt64Float32V(v, e)
case *map[int64]float32:
- fastpathTV.EncMapInt64Float32V(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncMapInt64Float32V(*v, e)
+ }
case map[int64]float64:
fastpathTV.EncMapInt64Float64V(v, e)
case *map[int64]float64:
- fastpathTV.EncMapInt64Float64V(*v, e)
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncMapInt64Float64V(*v, e)
+ }
case map[int64]bool:
fastpathTV.EncMapInt64BoolV(v, e)
case *map[int64]bool:
- fastpathTV.EncMapInt64BoolV(*v, e)
- case map[bool]interface{}:
- fastpathTV.EncMapBoolIntfV(v, e)
- case *map[bool]interface{}:
- fastpathTV.EncMapBoolIntfV(*v, e)
- case map[bool]string:
- fastpathTV.EncMapBoolStringV(v, e)
- case *map[bool]string:
- fastpathTV.EncMapBoolStringV(*v, e)
- case map[bool]uint:
- fastpathTV.EncMapBoolUintV(v, e)
- case *map[bool]uint:
- fastpathTV.EncMapBoolUintV(*v, e)
- case map[bool]uint8:
- fastpathTV.EncMapBoolUint8V(v, e)
- case *map[bool]uint8:
- fastpathTV.EncMapBoolUint8V(*v, e)
- case map[bool]uint16:
- fastpathTV.EncMapBoolUint16V(v, e)
- case *map[bool]uint16:
- fastpathTV.EncMapBoolUint16V(*v, e)
- case map[bool]uint32:
- fastpathTV.EncMapBoolUint32V(v, e)
- case *map[bool]uint32:
- fastpathTV.EncMapBoolUint32V(*v, e)
- case map[bool]uint64:
- fastpathTV.EncMapBoolUint64V(v, e)
- case *map[bool]uint64:
- fastpathTV.EncMapBoolUint64V(*v, e)
- case map[bool]uintptr:
- fastpathTV.EncMapBoolUintptrV(v, e)
- case *map[bool]uintptr:
- fastpathTV.EncMapBoolUintptrV(*v, e)
- case map[bool]int:
- fastpathTV.EncMapBoolIntV(v, e)
- case *map[bool]int:
- fastpathTV.EncMapBoolIntV(*v, e)
- case map[bool]int8:
- fastpathTV.EncMapBoolInt8V(v, e)
- case *map[bool]int8:
- fastpathTV.EncMapBoolInt8V(*v, e)
- case map[bool]int16:
- fastpathTV.EncMapBoolInt16V(v, e)
- case *map[bool]int16:
- fastpathTV.EncMapBoolInt16V(*v, e)
- case map[bool]int32:
- fastpathTV.EncMapBoolInt32V(v, e)
- case *map[bool]int32:
- fastpathTV.EncMapBoolInt32V(*v, e)
- case map[bool]int64:
- fastpathTV.EncMapBoolInt64V(v, e)
- case *map[bool]int64:
- fastpathTV.EncMapBoolInt64V(*v, e)
- case map[bool]float32:
- fastpathTV.EncMapBoolFloat32V(v, e)
- case *map[bool]float32:
- fastpathTV.EncMapBoolFloat32V(*v, e)
- case map[bool]float64:
- fastpathTV.EncMapBoolFloat64V(v, e)
- case *map[bool]float64:
- fastpathTV.EncMapBoolFloat64V(*v, e)
- case map[bool]bool:
- fastpathTV.EncMapBoolBoolV(v, e)
- case *map[bool]bool:
- fastpathTV.EncMapBoolBoolV(*v, e)
-
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.EncMapInt64BoolV(*v, e)
+ }
default:
_ = v // workaround https://github.com/golang/go/issues/12927 seen in go1.4
return false
@@ -1470,7 +842,6 @@ func fastpathEncodeTypeSwitch(iv interface{}, e *Encoder) bool {
}
// -- -- fast path functions
-
func (e *Encoder) fastpathEncSliceIntfR(f *codecFnInfo, rv reflect.Value) {
if f.ti.mbs {
fastpathTV.EncAsMapSliceIntfV(rv2i(rv).([]interface{}), e)
@@ -1478,49 +849,30 @@ func (e *Encoder) fastpathEncSliceIntfR(f *codecFnInfo, rv reflect.Value) {
fastpathTV.EncSliceIntfV(rv2i(rv).([]interface{}), e)
}
}
-func (_ fastpathT) EncSliceIntfV(v []interface{}, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteArrayStart(len(v))
- if esep {
- for _, v2 := range v {
- ee.WriteArrayElem()
- e.encode(v2)
- }
- } else {
- for _, v2 := range v {
- e.encode(v2)
- }
+func (fastpathT) EncSliceIntfV(v []interface{}, e *Encoder) {
+ e.arrayStart(len(v))
+ for j := range v {
+ e.arrayElem()
+ e.encode(v[j])
}
- ee.WriteArrayEnd()
+ e.arrayEnd()
}
-func (_ fastpathT) EncAsMapSliceIntfV(v []interface{}, e *Encoder) {
- ee, esep := e.e, e.hh.hasElemSeparators()
+func (fastpathT) EncAsMapSliceIntfV(v []interface{}, e *Encoder) {
if len(v)%2 == 1 {
e.errorf(fastpathMapBySliceErrMsg, len(v))
- return
- }
- ee.WriteMapStart(len(v) / 2)
- if esep {
- for j, v2 := range v {
+ } else {
+ e.mapStart(len(v) / 2)
+ for j := range v {
if j%2 == 0 {
- ee.WriteMapElemKey()
+ e.mapElemKey()
} else {
- ee.WriteMapElemValue()
+ e.mapElemValue()
}
- e.encode(v2)
- }
- } else {
- for _, v2 := range v {
- e.encode(v2)
+ e.encode(v[j])
}
+ e.mapEnd()
}
- ee.WriteMapEnd()
}
-
func (e *Encoder) fastpathEncSliceStringR(f *codecFnInfo, rv reflect.Value) {
if f.ti.mbs {
fastpathTV.EncAsMapSliceStringV(rv2i(rv).([]string), e)
@@ -1528,49 +880,61 @@ func (e *Encoder) fastpathEncSliceStringR(f *codecFnInfo, rv reflect.Value) {
fastpathTV.EncSliceStringV(rv2i(rv).([]string), e)
}
}
-func (_ fastpathT) EncSliceStringV(v []string, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
+func (fastpathT) EncSliceStringV(v []string, e *Encoder) {
+ e.arrayStart(len(v))
+ for j := range v {
+ e.arrayElem()
+ e.e.EncodeString(v[j])
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteArrayStart(len(v))
- if esep {
- for _, v2 := range v {
- ee.WriteArrayElem()
- ee.EncodeStringEnc(cUTF8, v2)
- }
+ e.arrayEnd()
+}
+func (fastpathT) EncAsMapSliceStringV(v []string, e *Encoder) {
+ if len(v)%2 == 1 {
+ e.errorf(fastpathMapBySliceErrMsg, len(v))
} else {
- for _, v2 := range v {
- ee.EncodeStringEnc(cUTF8, v2)
+ e.mapStart(len(v) / 2)
+ for j := range v {
+ if j%2 == 0 {
+ e.mapElemKey()
+ } else {
+ e.mapElemValue()
+ }
+ e.e.EncodeString(v[j])
}
+ e.mapEnd()
+ }
+}
+func (e *Encoder) fastpathEncSliceBytesR(f *codecFnInfo, rv reflect.Value) {
+ if f.ti.mbs {
+ fastpathTV.EncAsMapSliceBytesV(rv2i(rv).([][]byte), e)
+ } else {
+ fastpathTV.EncSliceBytesV(rv2i(rv).([][]byte), e)
+ }
+}
+func (fastpathT) EncSliceBytesV(v [][]byte, e *Encoder) {
+ e.arrayStart(len(v))
+ for j := range v {
+ e.arrayElem()
+ e.e.EncodeStringBytesRaw(v[j])
}
- ee.WriteArrayEnd()
+ e.arrayEnd()
}
-func (_ fastpathT) EncAsMapSliceStringV(v []string, e *Encoder) {
- ee, esep := e.e, e.hh.hasElemSeparators()
+func (fastpathT) EncAsMapSliceBytesV(v [][]byte, e *Encoder) {
if len(v)%2 == 1 {
e.errorf(fastpathMapBySliceErrMsg, len(v))
- return
- }
- ee.WriteMapStart(len(v) / 2)
- if esep {
- for j, v2 := range v {
+ } else {
+ e.mapStart(len(v) / 2)
+ for j := range v {
if j%2 == 0 {
- ee.WriteMapElemKey()
+ e.mapElemKey()
} else {
- ee.WriteMapElemValue()
+ e.mapElemValue()
}
- ee.EncodeStringEnc(cUTF8, v2)
- }
- } else {
- for _, v2 := range v {
- ee.EncodeStringEnc(cUTF8, v2)
+ e.e.EncodeStringBytesRaw(v[j])
}
+ e.mapEnd()
}
- ee.WriteMapEnd()
}
-
func (e *Encoder) fastpathEncSliceFloat32R(f *codecFnInfo, rv reflect.Value) {
if f.ti.mbs {
fastpathTV.EncAsMapSliceFloat32V(rv2i(rv).([]float32), e)
@@ -1578,49 +942,30 @@ func (e *Encoder) fastpathEncSliceFloat32R(f *codecFnInfo, rv reflect.Value) {
fastpathTV.EncSliceFloat32V(rv2i(rv).([]float32), e)
}
}
-func (_ fastpathT) EncSliceFloat32V(v []float32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteArrayStart(len(v))
- if esep {
- for _, v2 := range v {
- ee.WriteArrayElem()
- ee.EncodeFloat32(v2)
- }
- } else {
- for _, v2 := range v {
- ee.EncodeFloat32(v2)
- }
+func (fastpathT) EncSliceFloat32V(v []float32, e *Encoder) {
+ e.arrayStart(len(v))
+ for j := range v {
+ e.arrayElem()
+ e.e.EncodeFloat32(v[j])
}
- ee.WriteArrayEnd()
+ e.arrayEnd()
}
-func (_ fastpathT) EncAsMapSliceFloat32V(v []float32, e *Encoder) {
- ee, esep := e.e, e.hh.hasElemSeparators()
+func (fastpathT) EncAsMapSliceFloat32V(v []float32, e *Encoder) {
if len(v)%2 == 1 {
e.errorf(fastpathMapBySliceErrMsg, len(v))
- return
- }
- ee.WriteMapStart(len(v) / 2)
- if esep {
- for j, v2 := range v {
+ } else {
+ e.mapStart(len(v) / 2)
+ for j := range v {
if j%2 == 0 {
- ee.WriteMapElemKey()
+ e.mapElemKey()
} else {
- ee.WriteMapElemValue()
+ e.mapElemValue()
}
- ee.EncodeFloat32(v2)
- }
- } else {
- for _, v2 := range v {
- ee.EncodeFloat32(v2)
+ e.e.EncodeFloat32(v[j])
}
+ e.mapEnd()
}
- ee.WriteMapEnd()
}
-
func (e *Encoder) fastpathEncSliceFloat64R(f *codecFnInfo, rv reflect.Value) {
if f.ti.mbs {
fastpathTV.EncAsMapSliceFloat64V(rv2i(rv).([]float64), e)
@@ -1628,49 +973,30 @@ func (e *Encoder) fastpathEncSliceFloat64R(f *codecFnInfo, rv reflect.Value) {
fastpathTV.EncSliceFloat64V(rv2i(rv).([]float64), e)
}
}
-func (_ fastpathT) EncSliceFloat64V(v []float64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteArrayStart(len(v))
- if esep {
- for _, v2 := range v {
- ee.WriteArrayElem()
- ee.EncodeFloat64(v2)
- }
- } else {
- for _, v2 := range v {
- ee.EncodeFloat64(v2)
- }
+func (fastpathT) EncSliceFloat64V(v []float64, e *Encoder) {
+ e.arrayStart(len(v))
+ for j := range v {
+ e.arrayElem()
+ e.e.EncodeFloat64(v[j])
}
- ee.WriteArrayEnd()
+ e.arrayEnd()
}
-func (_ fastpathT) EncAsMapSliceFloat64V(v []float64, e *Encoder) {
- ee, esep := e.e, e.hh.hasElemSeparators()
+func (fastpathT) EncAsMapSliceFloat64V(v []float64, e *Encoder) {
if len(v)%2 == 1 {
e.errorf(fastpathMapBySliceErrMsg, len(v))
- return
- }
- ee.WriteMapStart(len(v) / 2)
- if esep {
- for j, v2 := range v {
+ } else {
+ e.mapStart(len(v) / 2)
+ for j := range v {
if j%2 == 0 {
- ee.WriteMapElemKey()
+ e.mapElemKey()
} else {
- ee.WriteMapElemValue()
+ e.mapElemValue()
}
- ee.EncodeFloat64(v2)
- }
- } else {
- for _, v2 := range v {
- ee.EncodeFloat64(v2)
+ e.e.EncodeFloat64(v[j])
}
+ e.mapEnd()
}
- ee.WriteMapEnd()
}
-
func (e *Encoder) fastpathEncSliceUintR(f *codecFnInfo, rv reflect.Value) {
if f.ti.mbs {
fastpathTV.EncAsMapSliceUintV(rv2i(rv).([]uint), e)
@@ -1678,199 +1004,92 @@ func (e *Encoder) fastpathEncSliceUintR(f *codecFnInfo, rv reflect.Value) {
fastpathTV.EncSliceUintV(rv2i(rv).([]uint), e)
}
}
-func (_ fastpathT) EncSliceUintV(v []uint, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
+func (fastpathT) EncSliceUintV(v []uint, e *Encoder) {
+ e.arrayStart(len(v))
+ for j := range v {
+ e.arrayElem()
+ e.e.EncodeUint(uint64(v[j]))
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteArrayStart(len(v))
- if esep {
- for _, v2 := range v {
- ee.WriteArrayElem()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for _, v2 := range v {
- ee.EncodeUint(uint64(v2))
- }
- }
- ee.WriteArrayEnd()
+ e.arrayEnd()
}
-func (_ fastpathT) EncAsMapSliceUintV(v []uint, e *Encoder) {
- ee, esep := e.e, e.hh.hasElemSeparators()
+func (fastpathT) EncAsMapSliceUintV(v []uint, e *Encoder) {
if len(v)%2 == 1 {
e.errorf(fastpathMapBySliceErrMsg, len(v))
- return
- }
- ee.WriteMapStart(len(v) / 2)
- if esep {
- for j, v2 := range v {
+ } else {
+ e.mapStart(len(v) / 2)
+ for j := range v {
if j%2 == 0 {
- ee.WriteMapElemKey()
+ e.mapElemKey()
} else {
- ee.WriteMapElemValue()
+ e.mapElemValue()
}
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for _, v2 := range v {
- ee.EncodeUint(uint64(v2))
+ e.e.EncodeUint(uint64(v[j]))
}
+ e.mapEnd()
}
- ee.WriteMapEnd()
}
-
-func (e *Encoder) fastpathEncSliceUint8R(f *codecFnInfo, rv reflect.Value) {
+func (e *Encoder) fastpathEncSliceUint16R(f *codecFnInfo, rv reflect.Value) {
if f.ti.mbs {
- fastpathTV.EncAsMapSliceUint8V(rv2i(rv).([]uint8), e)
+ fastpathTV.EncAsMapSliceUint16V(rv2i(rv).([]uint16), e)
} else {
- fastpathTV.EncSliceUint8V(rv2i(rv).([]uint8), e)
+ fastpathTV.EncSliceUint16V(rv2i(rv).([]uint16), e)
}
}
-func (_ fastpathT) EncSliceUint8V(v []uint8, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteArrayStart(len(v))
- if esep {
- for _, v2 := range v {
- ee.WriteArrayElem()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for _, v2 := range v {
- ee.EncodeUint(uint64(v2))
- }
+func (fastpathT) EncSliceUint16V(v []uint16, e *Encoder) {
+ e.arrayStart(len(v))
+ for j := range v {
+ e.arrayElem()
+ e.e.EncodeUint(uint64(v[j]))
}
- ee.WriteArrayEnd()
+ e.arrayEnd()
}
-func (_ fastpathT) EncAsMapSliceUint8V(v []uint8, e *Encoder) {
- ee, esep := e.e, e.hh.hasElemSeparators()
+func (fastpathT) EncAsMapSliceUint16V(v []uint16, e *Encoder) {
if len(v)%2 == 1 {
e.errorf(fastpathMapBySliceErrMsg, len(v))
- return
- }
- ee.WriteMapStart(len(v) / 2)
- if esep {
- for j, v2 := range v {
+ } else {
+ e.mapStart(len(v) / 2)
+ for j := range v {
if j%2 == 0 {
- ee.WriteMapElemKey()
+ e.mapElemKey()
} else {
- ee.WriteMapElemValue()
+ e.mapElemValue()
}
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for _, v2 := range v {
- ee.EncodeUint(uint64(v2))
+ e.e.EncodeUint(uint64(v[j]))
}
+ e.mapEnd()
}
- ee.WriteMapEnd()
}
-
-func (e *Encoder) fastpathEncSliceUint16R(f *codecFnInfo, rv reflect.Value) {
+func (e *Encoder) fastpathEncSliceUint32R(f *codecFnInfo, rv reflect.Value) {
if f.ti.mbs {
- fastpathTV.EncAsMapSliceUint16V(rv2i(rv).([]uint16), e)
+ fastpathTV.EncAsMapSliceUint32V(rv2i(rv).([]uint32), e)
} else {
- fastpathTV.EncSliceUint16V(rv2i(rv).([]uint16), e)
+ fastpathTV.EncSliceUint32V(rv2i(rv).([]uint32), e)
}
}
-func (_ fastpathT) EncSliceUint16V(v []uint16, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
+func (fastpathT) EncSliceUint32V(v []uint32, e *Encoder) {
+ e.arrayStart(len(v))
+ for j := range v {
+ e.arrayElem()
+ e.e.EncodeUint(uint64(v[j]))
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteArrayStart(len(v))
- if esep {
- for _, v2 := range v {
- ee.WriteArrayElem()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for _, v2 := range v {
- ee.EncodeUint(uint64(v2))
- }
- }
- ee.WriteArrayEnd()
+ e.arrayEnd()
}
-func (_ fastpathT) EncAsMapSliceUint16V(v []uint16, e *Encoder) {
- ee, esep := e.e, e.hh.hasElemSeparators()
+func (fastpathT) EncAsMapSliceUint32V(v []uint32, e *Encoder) {
if len(v)%2 == 1 {
e.errorf(fastpathMapBySliceErrMsg, len(v))
- return
- }
- ee.WriteMapStart(len(v) / 2)
- if esep {
- for j, v2 := range v {
- if j%2 == 0 {
- ee.WriteMapElemKey()
- } else {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for _, v2 := range v {
- ee.EncodeUint(uint64(v2))
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncSliceUint32R(f *codecFnInfo, rv reflect.Value) {
- if f.ti.mbs {
- fastpathTV.EncAsMapSliceUint32V(rv2i(rv).([]uint32), e)
- } else {
- fastpathTV.EncSliceUint32V(rv2i(rv).([]uint32), e)
- }
-}
-func (_ fastpathT) EncSliceUint32V(v []uint32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteArrayStart(len(v))
- if esep {
- for _, v2 := range v {
- ee.WriteArrayElem()
- ee.EncodeUint(uint64(v2))
- }
} else {
- for _, v2 := range v {
- ee.EncodeUint(uint64(v2))
- }
- }
- ee.WriteArrayEnd()
-}
-func (_ fastpathT) EncAsMapSliceUint32V(v []uint32, e *Encoder) {
- ee, esep := e.e, e.hh.hasElemSeparators()
- if len(v)%2 == 1 {
- e.errorf(fastpathMapBySliceErrMsg, len(v))
- return
- }
- ee.WriteMapStart(len(v) / 2)
- if esep {
- for j, v2 := range v {
+ e.mapStart(len(v) / 2)
+ for j := range v {
if j%2 == 0 {
- ee.WriteMapElemKey()
+ e.mapElemKey()
} else {
- ee.WriteMapElemValue()
+ e.mapElemValue()
}
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for _, v2 := range v {
- ee.EncodeUint(uint64(v2))
+ e.e.EncodeUint(uint64(v[j]))
}
+ e.mapEnd()
}
- ee.WriteMapEnd()
}
-
func (e *Encoder) fastpathEncSliceUint64R(f *codecFnInfo, rv reflect.Value) {
if f.ti.mbs {
fastpathTV.EncAsMapSliceUint64V(rv2i(rv).([]uint64), e)
@@ -1878,99 +1097,30 @@ func (e *Encoder) fastpathEncSliceUint64R(f *codecFnInfo, rv reflect.Value) {
fastpathTV.EncSliceUint64V(rv2i(rv).([]uint64), e)
}
}
-func (_ fastpathT) EncSliceUint64V(v []uint64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteArrayStart(len(v))
- if esep {
- for _, v2 := range v {
- ee.WriteArrayElem()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for _, v2 := range v {
- ee.EncodeUint(uint64(v2))
- }
+func (fastpathT) EncSliceUint64V(v []uint64, e *Encoder) {
+ e.arrayStart(len(v))
+ for j := range v {
+ e.arrayElem()
+ e.e.EncodeUint(v[j])
}
- ee.WriteArrayEnd()
+ e.arrayEnd()
}
-func (_ fastpathT) EncAsMapSliceUint64V(v []uint64, e *Encoder) {
- ee, esep := e.e, e.hh.hasElemSeparators()
+func (fastpathT) EncAsMapSliceUint64V(v []uint64, e *Encoder) {
if len(v)%2 == 1 {
e.errorf(fastpathMapBySliceErrMsg, len(v))
- return
- }
- ee.WriteMapStart(len(v) / 2)
- if esep {
- for j, v2 := range v {
- if j%2 == 0 {
- ee.WriteMapElemKey()
- } else {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for _, v2 := range v {
- ee.EncodeUint(uint64(v2))
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncSliceUintptrR(f *codecFnInfo, rv reflect.Value) {
- if f.ti.mbs {
- fastpathTV.EncAsMapSliceUintptrV(rv2i(rv).([]uintptr), e)
- } else {
- fastpathTV.EncSliceUintptrV(rv2i(rv).([]uintptr), e)
- }
-}
-func (_ fastpathT) EncSliceUintptrV(v []uintptr, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteArrayStart(len(v))
- if esep {
- for _, v2 := range v {
- ee.WriteArrayElem()
- e.encode(v2)
- }
} else {
- for _, v2 := range v {
- e.encode(v2)
- }
- }
- ee.WriteArrayEnd()
-}
-func (_ fastpathT) EncAsMapSliceUintptrV(v []uintptr, e *Encoder) {
- ee, esep := e.e, e.hh.hasElemSeparators()
- if len(v)%2 == 1 {
- e.errorf(fastpathMapBySliceErrMsg, len(v))
- return
- }
- ee.WriteMapStart(len(v) / 2)
- if esep {
- for j, v2 := range v {
+ e.mapStart(len(v) / 2)
+ for j := range v {
if j%2 == 0 {
- ee.WriteMapElemKey()
+ e.mapElemKey()
} else {
- ee.WriteMapElemValue()
+ e.mapElemValue()
}
- e.encode(v2)
- }
- } else {
- for _, v2 := range v {
- e.encode(v2)
+ e.e.EncodeUint(v[j])
}
+ e.mapEnd()
}
- ee.WriteMapEnd()
}
-
func (e *Encoder) fastpathEncSliceIntR(f *codecFnInfo, rv reflect.Value) {
if f.ti.mbs {
fastpathTV.EncAsMapSliceIntV(rv2i(rv).([]int), e)
@@ -1978,49 +1128,30 @@ func (e *Encoder) fastpathEncSliceIntR(f *codecFnInfo, rv reflect.Value) {
fastpathTV.EncSliceIntV(rv2i(rv).([]int), e)
}
}
-func (_ fastpathT) EncSliceIntV(v []int, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
+func (fastpathT) EncSliceIntV(v []int, e *Encoder) {
+ e.arrayStart(len(v))
+ for j := range v {
+ e.arrayElem()
+ e.e.EncodeInt(int64(v[j]))
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteArrayStart(len(v))
- if esep {
- for _, v2 := range v {
- ee.WriteArrayElem()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for _, v2 := range v {
- ee.EncodeInt(int64(v2))
- }
- }
- ee.WriteArrayEnd()
+ e.arrayEnd()
}
-func (_ fastpathT) EncAsMapSliceIntV(v []int, e *Encoder) {
- ee, esep := e.e, e.hh.hasElemSeparators()
+func (fastpathT) EncAsMapSliceIntV(v []int, e *Encoder) {
if len(v)%2 == 1 {
e.errorf(fastpathMapBySliceErrMsg, len(v))
- return
- }
- ee.WriteMapStart(len(v) / 2)
- if esep {
- for j, v2 := range v {
+ } else {
+ e.mapStart(len(v) / 2)
+ for j := range v {
if j%2 == 0 {
- ee.WriteMapElemKey()
+ e.mapElemKey()
} else {
- ee.WriteMapElemValue()
+ e.mapElemValue()
}
- ee.EncodeInt(int64(v2))
- }
- } else {
- for _, v2 := range v {
- ee.EncodeInt(int64(v2))
+ e.e.EncodeInt(int64(v[j]))
}
+ e.mapEnd()
}
- ee.WriteMapEnd()
}
-
func (e *Encoder) fastpathEncSliceInt8R(f *codecFnInfo, rv reflect.Value) {
if f.ti.mbs {
fastpathTV.EncAsMapSliceInt8V(rv2i(rv).([]int8), e)
@@ -2028,49 +1159,30 @@ func (e *Encoder) fastpathEncSliceInt8R(f *codecFnInfo, rv reflect.Value) {
fastpathTV.EncSliceInt8V(rv2i(rv).([]int8), e)
}
}
-func (_ fastpathT) EncSliceInt8V(v []int8, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteArrayStart(len(v))
- if esep {
- for _, v2 := range v {
- ee.WriteArrayElem()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for _, v2 := range v {
- ee.EncodeInt(int64(v2))
- }
+func (fastpathT) EncSliceInt8V(v []int8, e *Encoder) {
+ e.arrayStart(len(v))
+ for j := range v {
+ e.arrayElem()
+ e.e.EncodeInt(int64(v[j]))
}
- ee.WriteArrayEnd()
+ e.arrayEnd()
}
-func (_ fastpathT) EncAsMapSliceInt8V(v []int8, e *Encoder) {
- ee, esep := e.e, e.hh.hasElemSeparators()
+func (fastpathT) EncAsMapSliceInt8V(v []int8, e *Encoder) {
if len(v)%2 == 1 {
e.errorf(fastpathMapBySliceErrMsg, len(v))
- return
- }
- ee.WriteMapStart(len(v) / 2)
- if esep {
- for j, v2 := range v {
+ } else {
+ e.mapStart(len(v) / 2)
+ for j := range v {
if j%2 == 0 {
- ee.WriteMapElemKey()
+ e.mapElemKey()
} else {
- ee.WriteMapElemValue()
+ e.mapElemValue()
}
- ee.EncodeInt(int64(v2))
- }
- } else {
- for _, v2 := range v {
- ee.EncodeInt(int64(v2))
+ e.e.EncodeInt(int64(v[j]))
}
+ e.mapEnd()
}
- ee.WriteMapEnd()
}
-
func (e *Encoder) fastpathEncSliceInt16R(f *codecFnInfo, rv reflect.Value) {
if f.ti.mbs {
fastpathTV.EncAsMapSliceInt16V(rv2i(rv).([]int16), e)
@@ -2078,49 +1190,30 @@ func (e *Encoder) fastpathEncSliceInt16R(f *codecFnInfo, rv reflect.Value) {
fastpathTV.EncSliceInt16V(rv2i(rv).([]int16), e)
}
}
-func (_ fastpathT) EncSliceInt16V(v []int16, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteArrayStart(len(v))
- if esep {
- for _, v2 := range v {
- ee.WriteArrayElem()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for _, v2 := range v {
- ee.EncodeInt(int64(v2))
- }
+func (fastpathT) EncSliceInt16V(v []int16, e *Encoder) {
+ e.arrayStart(len(v))
+ for j := range v {
+ e.arrayElem()
+ e.e.EncodeInt(int64(v[j]))
}
- ee.WriteArrayEnd()
+ e.arrayEnd()
}
-func (_ fastpathT) EncAsMapSliceInt16V(v []int16, e *Encoder) {
- ee, esep := e.e, e.hh.hasElemSeparators()
+func (fastpathT) EncAsMapSliceInt16V(v []int16, e *Encoder) {
if len(v)%2 == 1 {
e.errorf(fastpathMapBySliceErrMsg, len(v))
- return
- }
- ee.WriteMapStart(len(v) / 2)
- if esep {
- for j, v2 := range v {
+ } else {
+ e.mapStart(len(v) / 2)
+ for j := range v {
if j%2 == 0 {
- ee.WriteMapElemKey()
+ e.mapElemKey()
} else {
- ee.WriteMapElemValue()
+ e.mapElemValue()
}
- ee.EncodeInt(int64(v2))
- }
- } else {
- for _, v2 := range v {
- ee.EncodeInt(int64(v2))
+ e.e.EncodeInt(int64(v[j]))
}
+ e.mapEnd()
}
- ee.WriteMapEnd()
}
-
func (e *Encoder) fastpathEncSliceInt32R(f *codecFnInfo, rv reflect.Value) {
if f.ti.mbs {
fastpathTV.EncAsMapSliceInt32V(rv2i(rv).([]int32), e)
@@ -2128,49 +1221,30 @@ func (e *Encoder) fastpathEncSliceInt32R(f *codecFnInfo, rv reflect.Value) {
fastpathTV.EncSliceInt32V(rv2i(rv).([]int32), e)
}
}
-func (_ fastpathT) EncSliceInt32V(v []int32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteArrayStart(len(v))
- if esep {
- for _, v2 := range v {
- ee.WriteArrayElem()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for _, v2 := range v {
- ee.EncodeInt(int64(v2))
- }
+func (fastpathT) EncSliceInt32V(v []int32, e *Encoder) {
+ e.arrayStart(len(v))
+ for j := range v {
+ e.arrayElem()
+ e.e.EncodeInt(int64(v[j]))
}
- ee.WriteArrayEnd()
+ e.arrayEnd()
}
-func (_ fastpathT) EncAsMapSliceInt32V(v []int32, e *Encoder) {
- ee, esep := e.e, e.hh.hasElemSeparators()
+func (fastpathT) EncAsMapSliceInt32V(v []int32, e *Encoder) {
if len(v)%2 == 1 {
e.errorf(fastpathMapBySliceErrMsg, len(v))
- return
- }
- ee.WriteMapStart(len(v) / 2)
- if esep {
- for j, v2 := range v {
+ } else {
+ e.mapStart(len(v) / 2)
+ for j := range v {
if j%2 == 0 {
- ee.WriteMapElemKey()
+ e.mapElemKey()
} else {
- ee.WriteMapElemValue()
+ e.mapElemValue()
}
- ee.EncodeInt(int64(v2))
- }
- } else {
- for _, v2 := range v {
- ee.EncodeInt(int64(v2))
+ e.e.EncodeInt(int64(v[j]))
}
+ e.mapEnd()
}
- ee.WriteMapEnd()
}
-
func (e *Encoder) fastpathEncSliceInt64R(f *codecFnInfo, rv reflect.Value) {
if f.ti.mbs {
fastpathTV.EncAsMapSliceInt64V(rv2i(rv).([]int64), e)
@@ -2178,49 +1252,30 @@ func (e *Encoder) fastpathEncSliceInt64R(f *codecFnInfo, rv reflect.Value) {
fastpathTV.EncSliceInt64V(rv2i(rv).([]int64), e)
}
}
-func (_ fastpathT) EncSliceInt64V(v []int64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteArrayStart(len(v))
- if esep {
- for _, v2 := range v {
- ee.WriteArrayElem()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for _, v2 := range v {
- ee.EncodeInt(int64(v2))
- }
+func (fastpathT) EncSliceInt64V(v []int64, e *Encoder) {
+ e.arrayStart(len(v))
+ for j := range v {
+ e.arrayElem()
+ e.e.EncodeInt(v[j])
}
- ee.WriteArrayEnd()
+ e.arrayEnd()
}
-func (_ fastpathT) EncAsMapSliceInt64V(v []int64, e *Encoder) {
- ee, esep := e.e, e.hh.hasElemSeparators()
+func (fastpathT) EncAsMapSliceInt64V(v []int64, e *Encoder) {
if len(v)%2 == 1 {
e.errorf(fastpathMapBySliceErrMsg, len(v))
- return
- }
- ee.WriteMapStart(len(v) / 2)
- if esep {
- for j, v2 := range v {
+ } else {
+ e.mapStart(len(v) / 2)
+ for j := range v {
if j%2 == 0 {
- ee.WriteMapElemKey()
+ e.mapElemKey()
} else {
- ee.WriteMapElemValue()
+ e.mapElemValue()
}
- ee.EncodeInt(int64(v2))
- }
- } else {
- for _, v2 := range v {
- ee.EncodeInt(int64(v2))
+ e.e.EncodeInt(v[j])
}
+ e.mapEnd()
}
- ee.WriteMapEnd()
}
-
func (e *Encoder) fastpathEncSliceBoolR(f *codecFnInfo, rv reflect.Value) {
if f.ti.mbs {
fastpathTV.EncAsMapSliceBoolV(rv2i(rv).([]bool), e)
@@ -2228,28973 +1283,4409 @@ func (e *Encoder) fastpathEncSliceBoolR(f *codecFnInfo, rv reflect.Value) {
fastpathTV.EncSliceBoolV(rv2i(rv).([]bool), e)
}
}
-func (_ fastpathT) EncSliceBoolV(v []bool, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteArrayStart(len(v))
- if esep {
- for _, v2 := range v {
- ee.WriteArrayElem()
- ee.EncodeBool(v2)
- }
- } else {
- for _, v2 := range v {
- ee.EncodeBool(v2)
- }
+func (fastpathT) EncSliceBoolV(v []bool, e *Encoder) {
+ e.arrayStart(len(v))
+ for j := range v {
+ e.arrayElem()
+ e.e.EncodeBool(v[j])
}
- ee.WriteArrayEnd()
+ e.arrayEnd()
}
-func (_ fastpathT) EncAsMapSliceBoolV(v []bool, e *Encoder) {
- ee, esep := e.e, e.hh.hasElemSeparators()
+func (fastpathT) EncAsMapSliceBoolV(v []bool, e *Encoder) {
if len(v)%2 == 1 {
e.errorf(fastpathMapBySliceErrMsg, len(v))
- return
- }
- ee.WriteMapStart(len(v) / 2)
- if esep {
- for j, v2 := range v {
+ } else {
+ e.mapStart(len(v) / 2)
+ for j := range v {
if j%2 == 0 {
- ee.WriteMapElemKey()
+ e.mapElemKey()
} else {
- ee.WriteMapElemValue()
+ e.mapElemValue()
}
- ee.EncodeBool(v2)
- }
- } else {
- for _, v2 := range v {
- ee.EncodeBool(v2)
+ e.e.EncodeBool(v[j])
}
+ e.mapEnd()
}
- ee.WriteMapEnd()
}
-
-func (e *Encoder) fastpathEncMapIntfIntfR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapIntfIntfV(rv2i(rv).(map[interface{}]interface{}), e)
+func (e *Encoder) fastpathEncMapStringIntfR(f *codecFnInfo, rv reflect.Value) {
+ fastpathTV.EncMapStringIntfV(rv2i(rv).(map[string]interface{}), e)
}
-func (_ fastpathT) EncMapIntfIntfV(v map[interface{}]interface{}, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+func (fastpathT) EncMapStringIntfV(v map[string]interface{}, e *Encoder) {
+ e.mapStart(len(v))
if e.h.Canonical {
- var mksv []byte = make([]byte, 0, len(v)*16) // temporary byte slice for the encoding
- e2 := NewEncoderBytes(&mksv, e.hh)
- v2 := make([]bytesI, len(v))
- var i, l uint
- var vp *bytesI
- for k2 := range v {
- l = uint(len(mksv))
- e2.MustEncode(k2)
- vp = &v2[i]
- vp.v = mksv[l:]
- vp.i = k2
+ v2 := make([]string, len(v))
+ var i uint
+ for k := range v {
+ v2[i] = k
i++
}
- sort.Sort(bytesISlice(v2))
- if esep {
- for j := range v2 {
- ee.WriteMapElemKey()
- e.asis(v2[j].v)
- ee.WriteMapElemValue()
- e.encode(v[v2[j].i])
- }
- } else {
- for j := range v2 {
- e.asis(v2[j].v)
- e.encode(v[v2[j].i])
- }
+ sort.Sort(stringSlice(v2))
+ for _, k2 := range v2 {
+ e.mapElemKey()
+ e.e.EncodeString(k2)
+ e.mapElemValue()
+ e.encode(v[k2])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- e.encode(k2)
- ee.WriteMapElemValue()
- e.encode(v2)
- }
- } else {
- for k2, v2 := range v {
- e.encode(k2)
- e.encode(v2)
- }
+ for k2, v2 := range v {
+ e.mapElemKey()
+ e.e.EncodeString(k2)
+ e.mapElemValue()
+ e.encode(v2)
}
}
- ee.WriteMapEnd()
+ e.mapEnd()
}
-
-func (e *Encoder) fastpathEncMapIntfStringR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapIntfStringV(rv2i(rv).(map[interface{}]string), e)
+func (e *Encoder) fastpathEncMapStringStringR(f *codecFnInfo, rv reflect.Value) {
+ fastpathTV.EncMapStringStringV(rv2i(rv).(map[string]string), e)
}
-func (_ fastpathT) EncMapIntfStringV(v map[interface{}]string, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+func (fastpathT) EncMapStringStringV(v map[string]string, e *Encoder) {
+ e.mapStart(len(v))
if e.h.Canonical {
- var mksv []byte = make([]byte, 0, len(v)*16) // temporary byte slice for the encoding
- e2 := NewEncoderBytes(&mksv, e.hh)
- v2 := make([]bytesI, len(v))
- var i, l uint
- var vp *bytesI
- for k2 := range v {
- l = uint(len(mksv))
- e2.MustEncode(k2)
- vp = &v2[i]
- vp.v = mksv[l:]
- vp.i = k2
+ v2 := make([]string, len(v))
+ var i uint
+ for k := range v {
+ v2[i] = k
i++
}
- sort.Sort(bytesISlice(v2))
- if esep {
- for j := range v2 {
- ee.WriteMapElemKey()
- e.asis(v2[j].v)
- ee.WriteMapElemValue()
- e.encode(v[v2[j].i])
- }
- } else {
- for j := range v2 {
- e.asis(v2[j].v)
- e.encode(v[v2[j].i])
- }
+ sort.Sort(stringSlice(v2))
+ for _, k2 := range v2 {
+ e.mapElemKey()
+ e.e.EncodeString(k2)
+ e.mapElemValue()
+ e.e.EncodeString(v[k2])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- e.encode(k2)
- ee.WriteMapElemValue()
- ee.EncodeStringEnc(cUTF8, v2)
- }
- } else {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeStringEnc(cUTF8, v2)
- }
+ for k2, v2 := range v {
+ e.mapElemKey()
+ e.e.EncodeString(k2)
+ e.mapElemValue()
+ e.e.EncodeString(v2)
}
}
- ee.WriteMapEnd()
+ e.mapEnd()
}
-
-func (e *Encoder) fastpathEncMapIntfUintR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapIntfUintV(rv2i(rv).(map[interface{}]uint), e)
+func (e *Encoder) fastpathEncMapStringBytesR(f *codecFnInfo, rv reflect.Value) {
+ fastpathTV.EncMapStringBytesV(rv2i(rv).(map[string][]byte), e)
}
-func (_ fastpathT) EncMapIntfUintV(v map[interface{}]uint, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+func (fastpathT) EncMapStringBytesV(v map[string][]byte, e *Encoder) {
+ e.mapStart(len(v))
if e.h.Canonical {
- var mksv []byte = make([]byte, 0, len(v)*16) // temporary byte slice for the encoding
- e2 := NewEncoderBytes(&mksv, e.hh)
- v2 := make([]bytesI, len(v))
- var i, l uint
- var vp *bytesI
- for k2 := range v {
- l = uint(len(mksv))
- e2.MustEncode(k2)
- vp = &v2[i]
- vp.v = mksv[l:]
- vp.i = k2
+ v2 := make([]string, len(v))
+ var i uint
+ for k := range v {
+ v2[i] = k
i++
}
- sort.Sort(bytesISlice(v2))
- if esep {
- for j := range v2 {
- ee.WriteMapElemKey()
- e.asis(v2[j].v)
- ee.WriteMapElemValue()
- e.encode(v[v2[j].i])
- }
- } else {
- for j := range v2 {
- e.asis(v2[j].v)
- e.encode(v[v2[j].i])
- }
+ sort.Sort(stringSlice(v2))
+ for _, k2 := range v2 {
+ e.mapElemKey()
+ e.e.EncodeString(k2)
+ e.mapElemValue()
+ e.e.EncodeStringBytesRaw(v[k2])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- e.encode(k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeUint(uint64(v2))
- }
+ for k2, v2 := range v {
+ e.mapElemKey()
+ e.e.EncodeString(k2)
+ e.mapElemValue()
+ e.e.EncodeStringBytesRaw(v2)
}
}
- ee.WriteMapEnd()
+ e.mapEnd()
}
-
-func (e *Encoder) fastpathEncMapIntfUint8R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapIntfUint8V(rv2i(rv).(map[interface{}]uint8), e)
+func (e *Encoder) fastpathEncMapStringUintR(f *codecFnInfo, rv reflect.Value) {
+ fastpathTV.EncMapStringUintV(rv2i(rv).(map[string]uint), e)
}
-func (_ fastpathT) EncMapIntfUint8V(v map[interface{}]uint8, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+func (fastpathT) EncMapStringUintV(v map[string]uint, e *Encoder) {
+ e.mapStart(len(v))
if e.h.Canonical {
- var mksv []byte = make([]byte, 0, len(v)*16) // temporary byte slice for the encoding
- e2 := NewEncoderBytes(&mksv, e.hh)
- v2 := make([]bytesI, len(v))
- var i, l uint
- var vp *bytesI
- for k2 := range v {
- l = uint(len(mksv))
- e2.MustEncode(k2)
- vp = &v2[i]
- vp.v = mksv[l:]
- vp.i = k2
+ v2 := make([]string, len(v))
+ var i uint
+ for k := range v {
+ v2[i] = k
i++
}
- sort.Sort(bytesISlice(v2))
- if esep {
- for j := range v2 {
- ee.WriteMapElemKey()
- e.asis(v2[j].v)
- ee.WriteMapElemValue()
- e.encode(v[v2[j].i])
- }
- } else {
- for j := range v2 {
- e.asis(v2[j].v)
- e.encode(v[v2[j].i])
- }
+ sort.Sort(stringSlice(v2))
+ for _, k2 := range v2 {
+ e.mapElemKey()
+ e.e.EncodeString(k2)
+ e.mapElemValue()
+ e.e.EncodeUint(uint64(v[k2]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- e.encode(k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeUint(uint64(v2))
- }
+ for k2, v2 := range v {
+ e.mapElemKey()
+ e.e.EncodeString(k2)
+ e.mapElemValue()
+ e.e.EncodeUint(uint64(v2))
}
}
- ee.WriteMapEnd()
+ e.mapEnd()
}
-
-func (e *Encoder) fastpathEncMapIntfUint16R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapIntfUint16V(rv2i(rv).(map[interface{}]uint16), e)
+func (e *Encoder) fastpathEncMapStringUint8R(f *codecFnInfo, rv reflect.Value) {
+ fastpathTV.EncMapStringUint8V(rv2i(rv).(map[string]uint8), e)
}
-func (_ fastpathT) EncMapIntfUint16V(v map[interface{}]uint16, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+func (fastpathT) EncMapStringUint8V(v map[string]uint8, e *Encoder) {
+ e.mapStart(len(v))
if e.h.Canonical {
- var mksv []byte = make([]byte, 0, len(v)*16) // temporary byte slice for the encoding
- e2 := NewEncoderBytes(&mksv, e.hh)
- v2 := make([]bytesI, len(v))
- var i, l uint
- var vp *bytesI
- for k2 := range v {
- l = uint(len(mksv))
- e2.MustEncode(k2)
- vp = &v2[i]
- vp.v = mksv[l:]
- vp.i = k2
+ v2 := make([]string, len(v))
+ var i uint
+ for k := range v {
+ v2[i] = k
i++
}
- sort.Sort(bytesISlice(v2))
- if esep {
- for j := range v2 {
- ee.WriteMapElemKey()
- e.asis(v2[j].v)
- ee.WriteMapElemValue()
- e.encode(v[v2[j].i])
- }
- } else {
- for j := range v2 {
- e.asis(v2[j].v)
- e.encode(v[v2[j].i])
- }
+ sort.Sort(stringSlice(v2))
+ for _, k2 := range v2 {
+ e.mapElemKey()
+ e.e.EncodeString(k2)
+ e.mapElemValue()
+ e.e.EncodeUint(uint64(v[k2]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- e.encode(k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeUint(uint64(v2))
- }
+ for k2, v2 := range v {
+ e.mapElemKey()
+ e.e.EncodeString(k2)
+ e.mapElemValue()
+ e.e.EncodeUint(uint64(v2))
}
}
- ee.WriteMapEnd()
+ e.mapEnd()
}
-
-func (e *Encoder) fastpathEncMapIntfUint32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapIntfUint32V(rv2i(rv).(map[interface{}]uint32), e)
+func (e *Encoder) fastpathEncMapStringUint64R(f *codecFnInfo, rv reflect.Value) {
+ fastpathTV.EncMapStringUint64V(rv2i(rv).(map[string]uint64), e)
}
-func (_ fastpathT) EncMapIntfUint32V(v map[interface{}]uint32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+func (fastpathT) EncMapStringUint64V(v map[string]uint64, e *Encoder) {
+ e.mapStart(len(v))
if e.h.Canonical {
- var mksv []byte = make([]byte, 0, len(v)*16) // temporary byte slice for the encoding
- e2 := NewEncoderBytes(&mksv, e.hh)
- v2 := make([]bytesI, len(v))
- var i, l uint
- var vp *bytesI
- for k2 := range v {
- l = uint(len(mksv))
- e2.MustEncode(k2)
- vp = &v2[i]
- vp.v = mksv[l:]
- vp.i = k2
+ v2 := make([]string, len(v))
+ var i uint
+ for k := range v {
+ v2[i] = k
i++
}
- sort.Sort(bytesISlice(v2))
- if esep {
- for j := range v2 {
- ee.WriteMapElemKey()
- e.asis(v2[j].v)
- ee.WriteMapElemValue()
- e.encode(v[v2[j].i])
- }
- } else {
- for j := range v2 {
- e.asis(v2[j].v)
- e.encode(v[v2[j].i])
- }
+ sort.Sort(stringSlice(v2))
+ for _, k2 := range v2 {
+ e.mapElemKey()
+ e.e.EncodeString(k2)
+ e.mapElemValue()
+ e.e.EncodeUint(v[k2])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- e.encode(k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeUint(uint64(v2))
- }
+ for k2, v2 := range v {
+ e.mapElemKey()
+ e.e.EncodeString(k2)
+ e.mapElemValue()
+ e.e.EncodeUint(v2)
}
}
- ee.WriteMapEnd()
+ e.mapEnd()
}
-
-func (e *Encoder) fastpathEncMapIntfUint64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapIntfUint64V(rv2i(rv).(map[interface{}]uint64), e)
+func (e *Encoder) fastpathEncMapStringIntR(f *codecFnInfo, rv reflect.Value) {
+ fastpathTV.EncMapStringIntV(rv2i(rv).(map[string]int), e)
}
-func (_ fastpathT) EncMapIntfUint64V(v map[interface{}]uint64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+func (fastpathT) EncMapStringIntV(v map[string]int, e *Encoder) {
+ e.mapStart(len(v))
if e.h.Canonical {
- var mksv []byte = make([]byte, 0, len(v)*16) // temporary byte slice for the encoding
- e2 := NewEncoderBytes(&mksv, e.hh)
- v2 := make([]bytesI, len(v))
- var i, l uint
- var vp *bytesI
- for k2 := range v {
- l = uint(len(mksv))
- e2.MustEncode(k2)
- vp = &v2[i]
- vp.v = mksv[l:]
- vp.i = k2
+ v2 := make([]string, len(v))
+ var i uint
+ for k := range v {
+ v2[i] = k
i++
}
- sort.Sort(bytesISlice(v2))
- if esep {
- for j := range v2 {
- ee.WriteMapElemKey()
- e.asis(v2[j].v)
- ee.WriteMapElemValue()
- e.encode(v[v2[j].i])
- }
- } else {
- for j := range v2 {
- e.asis(v2[j].v)
- e.encode(v[v2[j].i])
- }
+ sort.Sort(stringSlice(v2))
+ for _, k2 := range v2 {
+ e.mapElemKey()
+ e.e.EncodeString(k2)
+ e.mapElemValue()
+ e.e.EncodeInt(int64(v[k2]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- e.encode(k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeUint(uint64(v2))
- }
+ for k2, v2 := range v {
+ e.mapElemKey()
+ e.e.EncodeString(k2)
+ e.mapElemValue()
+ e.e.EncodeInt(int64(v2))
}
}
- ee.WriteMapEnd()
+ e.mapEnd()
}
-
-func (e *Encoder) fastpathEncMapIntfUintptrR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapIntfUintptrV(rv2i(rv).(map[interface{}]uintptr), e)
+func (e *Encoder) fastpathEncMapStringInt64R(f *codecFnInfo, rv reflect.Value) {
+ fastpathTV.EncMapStringInt64V(rv2i(rv).(map[string]int64), e)
}
-func (_ fastpathT) EncMapIntfUintptrV(v map[interface{}]uintptr, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+func (fastpathT) EncMapStringInt64V(v map[string]int64, e *Encoder) {
+ e.mapStart(len(v))
if e.h.Canonical {
- var mksv []byte = make([]byte, 0, len(v)*16) // temporary byte slice for the encoding
- e2 := NewEncoderBytes(&mksv, e.hh)
- v2 := make([]bytesI, len(v))
- var i, l uint
- var vp *bytesI
- for k2 := range v {
- l = uint(len(mksv))
- e2.MustEncode(k2)
- vp = &v2[i]
- vp.v = mksv[l:]
- vp.i = k2
+ v2 := make([]string, len(v))
+ var i uint
+ for k := range v {
+ v2[i] = k
i++
}
- sort.Sort(bytesISlice(v2))
- if esep {
- for j := range v2 {
- ee.WriteMapElemKey()
- e.asis(v2[j].v)
- ee.WriteMapElemValue()
- e.encode(v[v2[j].i])
- }
- } else {
- for j := range v2 {
- e.asis(v2[j].v)
- e.encode(v[v2[j].i])
- }
+ sort.Sort(stringSlice(v2))
+ for _, k2 := range v2 {
+ e.mapElemKey()
+ e.e.EncodeString(k2)
+ e.mapElemValue()
+ e.e.EncodeInt(v[k2])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- e.encode(k2)
- ee.WriteMapElemValue()
- e.encode(v2)
- }
- } else {
- for k2, v2 := range v {
- e.encode(k2)
- e.encode(v2)
- }
+ for k2, v2 := range v {
+ e.mapElemKey()
+ e.e.EncodeString(k2)
+ e.mapElemValue()
+ e.e.EncodeInt(v2)
}
}
- ee.WriteMapEnd()
+ e.mapEnd()
}
-
-func (e *Encoder) fastpathEncMapIntfIntR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapIntfIntV(rv2i(rv).(map[interface{}]int), e)
+func (e *Encoder) fastpathEncMapStringFloat32R(f *codecFnInfo, rv reflect.Value) {
+ fastpathTV.EncMapStringFloat32V(rv2i(rv).(map[string]float32), e)
}
-func (_ fastpathT) EncMapIntfIntV(v map[interface{}]int, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+func (fastpathT) EncMapStringFloat32V(v map[string]float32, e *Encoder) {
+ e.mapStart(len(v))
if e.h.Canonical {
- var mksv []byte = make([]byte, 0, len(v)*16) // temporary byte slice for the encoding
- e2 := NewEncoderBytes(&mksv, e.hh)
- v2 := make([]bytesI, len(v))
- var i, l uint
- var vp *bytesI
- for k2 := range v {
- l = uint(len(mksv))
- e2.MustEncode(k2)
- vp = &v2[i]
- vp.v = mksv[l:]
- vp.i = k2
+ v2 := make([]string, len(v))
+ var i uint
+ for k := range v {
+ v2[i] = k
i++
}
- sort.Sort(bytesISlice(v2))
- if esep {
- for j := range v2 {
- ee.WriteMapElemKey()
- e.asis(v2[j].v)
- ee.WriteMapElemValue()
- e.encode(v[v2[j].i])
- }
- } else {
- for j := range v2 {
- e.asis(v2[j].v)
- e.encode(v[v2[j].i])
- }
+ sort.Sort(stringSlice(v2))
+ for _, k2 := range v2 {
+ e.mapElemKey()
+ e.e.EncodeString(k2)
+ e.mapElemValue()
+ e.e.EncodeFloat32(v[k2])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- e.encode(k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeInt(int64(v2))
- }
+ for k2, v2 := range v {
+ e.mapElemKey()
+ e.e.EncodeString(k2)
+ e.mapElemValue()
+ e.e.EncodeFloat32(v2)
}
}
- ee.WriteMapEnd()
+ e.mapEnd()
}
-
-func (e *Encoder) fastpathEncMapIntfInt8R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapIntfInt8V(rv2i(rv).(map[interface{}]int8), e)
+func (e *Encoder) fastpathEncMapStringFloat64R(f *codecFnInfo, rv reflect.Value) {
+ fastpathTV.EncMapStringFloat64V(rv2i(rv).(map[string]float64), e)
}
-func (_ fastpathT) EncMapIntfInt8V(v map[interface{}]int8, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+func (fastpathT) EncMapStringFloat64V(v map[string]float64, e *Encoder) {
+ e.mapStart(len(v))
if e.h.Canonical {
- var mksv []byte = make([]byte, 0, len(v)*16) // temporary byte slice for the encoding
- e2 := NewEncoderBytes(&mksv, e.hh)
- v2 := make([]bytesI, len(v))
- var i, l uint
- var vp *bytesI
- for k2 := range v {
- l = uint(len(mksv))
- e2.MustEncode(k2)
- vp = &v2[i]
- vp.v = mksv[l:]
- vp.i = k2
+ v2 := make([]string, len(v))
+ var i uint
+ for k := range v {
+ v2[i] = k
i++
}
- sort.Sort(bytesISlice(v2))
- if esep {
- for j := range v2 {
- ee.WriteMapElemKey()
- e.asis(v2[j].v)
- ee.WriteMapElemValue()
- e.encode(v[v2[j].i])
- }
- } else {
- for j := range v2 {
- e.asis(v2[j].v)
- e.encode(v[v2[j].i])
- }
+ sort.Sort(stringSlice(v2))
+ for _, k2 := range v2 {
+ e.mapElemKey()
+ e.e.EncodeString(k2)
+ e.mapElemValue()
+ e.e.EncodeFloat64(v[k2])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- e.encode(k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeInt(int64(v2))
- }
+ for k2, v2 := range v {
+ e.mapElemKey()
+ e.e.EncodeString(k2)
+ e.mapElemValue()
+ e.e.EncodeFloat64(v2)
}
}
- ee.WriteMapEnd()
+ e.mapEnd()
}
-
-func (e *Encoder) fastpathEncMapIntfInt16R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapIntfInt16V(rv2i(rv).(map[interface{}]int16), e)
+func (e *Encoder) fastpathEncMapStringBoolR(f *codecFnInfo, rv reflect.Value) {
+ fastpathTV.EncMapStringBoolV(rv2i(rv).(map[string]bool), e)
}
-func (_ fastpathT) EncMapIntfInt16V(v map[interface{}]int16, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+func (fastpathT) EncMapStringBoolV(v map[string]bool, e *Encoder) {
+ e.mapStart(len(v))
if e.h.Canonical {
- var mksv []byte = make([]byte, 0, len(v)*16) // temporary byte slice for the encoding
- e2 := NewEncoderBytes(&mksv, e.hh)
- v2 := make([]bytesI, len(v))
- var i, l uint
- var vp *bytesI
- for k2 := range v {
- l = uint(len(mksv))
- e2.MustEncode(k2)
- vp = &v2[i]
- vp.v = mksv[l:]
- vp.i = k2
+ v2 := make([]string, len(v))
+ var i uint
+ for k := range v {
+ v2[i] = k
i++
}
- sort.Sort(bytesISlice(v2))
- if esep {
- for j := range v2 {
- ee.WriteMapElemKey()
- e.asis(v2[j].v)
- ee.WriteMapElemValue()
- e.encode(v[v2[j].i])
- }
- } else {
- for j := range v2 {
- e.asis(v2[j].v)
- e.encode(v[v2[j].i])
- }
+ sort.Sort(stringSlice(v2))
+ for _, k2 := range v2 {
+ e.mapElemKey()
+ e.e.EncodeString(k2)
+ e.mapElemValue()
+ e.e.EncodeBool(v[k2])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- e.encode(k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeInt(int64(v2))
- }
+ for k2, v2 := range v {
+ e.mapElemKey()
+ e.e.EncodeString(k2)
+ e.mapElemValue()
+ e.e.EncodeBool(v2)
}
}
- ee.WriteMapEnd()
+ e.mapEnd()
}
-
-func (e *Encoder) fastpathEncMapIntfInt32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapIntfInt32V(rv2i(rv).(map[interface{}]int32), e)
+func (e *Encoder) fastpathEncMapUintIntfR(f *codecFnInfo, rv reflect.Value) {
+ fastpathTV.EncMapUintIntfV(rv2i(rv).(map[uint]interface{}), e)
}
-func (_ fastpathT) EncMapIntfInt32V(v map[interface{}]int32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+func (fastpathT) EncMapUintIntfV(v map[uint]interface{}, e *Encoder) {
+ e.mapStart(len(v))
if e.h.Canonical {
- var mksv []byte = make([]byte, 0, len(v)*16) // temporary byte slice for the encoding
- e2 := NewEncoderBytes(&mksv, e.hh)
- v2 := make([]bytesI, len(v))
- var i, l uint
- var vp *bytesI
- for k2 := range v {
- l = uint(len(mksv))
- e2.MustEncode(k2)
- vp = &v2[i]
- vp.v = mksv[l:]
- vp.i = k2
+ v2 := make([]uint64, len(v))
+ var i uint
+ for k := range v {
+ v2[i] = uint64(k)
i++
}
- sort.Sort(bytesISlice(v2))
- if esep {
- for j := range v2 {
- ee.WriteMapElemKey()
- e.asis(v2[j].v)
- ee.WriteMapElemValue()
- e.encode(v[v2[j].i])
- }
- } else {
- for j := range v2 {
- e.asis(v2[j].v)
- e.encode(v[v2[j].i])
- }
+ sort.Sort(uint64Slice(v2))
+ for _, k2 := range v2 {
+ e.mapElemKey()
+ e.e.EncodeUint(uint64(uint(k2)))
+ e.mapElemValue()
+ e.encode(v[uint(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- e.encode(k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeInt(int64(v2))
- }
+ for k2, v2 := range v {
+ e.mapElemKey()
+ e.e.EncodeUint(uint64(k2))
+ e.mapElemValue()
+ e.encode(v2)
}
}
- ee.WriteMapEnd()
+ e.mapEnd()
}
-
-func (e *Encoder) fastpathEncMapIntfInt64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapIntfInt64V(rv2i(rv).(map[interface{}]int64), e)
+func (e *Encoder) fastpathEncMapUintStringR(f *codecFnInfo, rv reflect.Value) {
+ fastpathTV.EncMapUintStringV(rv2i(rv).(map[uint]string), e)
}
-func (_ fastpathT) EncMapIntfInt64V(v map[interface{}]int64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+func (fastpathT) EncMapUintStringV(v map[uint]string, e *Encoder) {
+ e.mapStart(len(v))
if e.h.Canonical {
- var mksv []byte = make([]byte, 0, len(v)*16) // temporary byte slice for the encoding
- e2 := NewEncoderBytes(&mksv, e.hh)
- v2 := make([]bytesI, len(v))
- var i, l uint
- var vp *bytesI
- for k2 := range v {
- l = uint(len(mksv))
- e2.MustEncode(k2)
- vp = &v2[i]
- vp.v = mksv[l:]
- vp.i = k2
+ v2 := make([]uint64, len(v))
+ var i uint
+ for k := range v {
+ v2[i] = uint64(k)
i++
}
- sort.Sort(bytesISlice(v2))
- if esep {
- for j := range v2 {
- ee.WriteMapElemKey()
- e.asis(v2[j].v)
- ee.WriteMapElemValue()
- e.encode(v[v2[j].i])
- }
- } else {
- for j := range v2 {
- e.asis(v2[j].v)
- e.encode(v[v2[j].i])
- }
+ sort.Sort(uint64Slice(v2))
+ for _, k2 := range v2 {
+ e.mapElemKey()
+ e.e.EncodeUint(uint64(uint(k2)))
+ e.mapElemValue()
+ e.e.EncodeString(v[uint(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- e.encode(k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeInt(int64(v2))
- }
+ for k2, v2 := range v {
+ e.mapElemKey()
+ e.e.EncodeUint(uint64(k2))
+ e.mapElemValue()
+ e.e.EncodeString(v2)
}
}
- ee.WriteMapEnd()
+ e.mapEnd()
}
-
-func (e *Encoder) fastpathEncMapIntfFloat32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapIntfFloat32V(rv2i(rv).(map[interface{}]float32), e)
+func (e *Encoder) fastpathEncMapUintBytesR(f *codecFnInfo, rv reflect.Value) {
+ fastpathTV.EncMapUintBytesV(rv2i(rv).(map[uint][]byte), e)
}
-func (_ fastpathT) EncMapIntfFloat32V(v map[interface{}]float32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+func (fastpathT) EncMapUintBytesV(v map[uint][]byte, e *Encoder) {
+ e.mapStart(len(v))
if e.h.Canonical {
- var mksv []byte = make([]byte, 0, len(v)*16) // temporary byte slice for the encoding
- e2 := NewEncoderBytes(&mksv, e.hh)
- v2 := make([]bytesI, len(v))
- var i, l uint
- var vp *bytesI
- for k2 := range v {
- l = uint(len(mksv))
- e2.MustEncode(k2)
- vp = &v2[i]
- vp.v = mksv[l:]
- vp.i = k2
+ v2 := make([]uint64, len(v))
+ var i uint
+ for k := range v {
+ v2[i] = uint64(k)
i++
}
- sort.Sort(bytesISlice(v2))
- if esep {
- for j := range v2 {
- ee.WriteMapElemKey()
- e.asis(v2[j].v)
- ee.WriteMapElemValue()
- e.encode(v[v2[j].i])
- }
- } else {
- for j := range v2 {
- e.asis(v2[j].v)
- e.encode(v[v2[j].i])
- }
+ sort.Sort(uint64Slice(v2))
+ for _, k2 := range v2 {
+ e.mapElemKey()
+ e.e.EncodeUint(uint64(uint(k2)))
+ e.mapElemValue()
+ e.e.EncodeStringBytesRaw(v[uint(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- e.encode(k2)
- ee.WriteMapElemValue()
- ee.EncodeFloat32(v2)
- }
- } else {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeFloat32(v2)
- }
+ for k2, v2 := range v {
+ e.mapElemKey()
+ e.e.EncodeUint(uint64(k2))
+ e.mapElemValue()
+ e.e.EncodeStringBytesRaw(v2)
}
}
- ee.WriteMapEnd()
+ e.mapEnd()
}
-
-func (e *Encoder) fastpathEncMapIntfFloat64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapIntfFloat64V(rv2i(rv).(map[interface{}]float64), e)
+func (e *Encoder) fastpathEncMapUintUintR(f *codecFnInfo, rv reflect.Value) {
+ fastpathTV.EncMapUintUintV(rv2i(rv).(map[uint]uint), e)
}
-func (_ fastpathT) EncMapIntfFloat64V(v map[interface{}]float64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+func (fastpathT) EncMapUintUintV(v map[uint]uint, e *Encoder) {
+ e.mapStart(len(v))
if e.h.Canonical {
- var mksv []byte = make([]byte, 0, len(v)*16) // temporary byte slice for the encoding
- e2 := NewEncoderBytes(&mksv, e.hh)
- v2 := make([]bytesI, len(v))
- var i, l uint
- var vp *bytesI
- for k2 := range v {
- l = uint(len(mksv))
- e2.MustEncode(k2)
- vp = &v2[i]
- vp.v = mksv[l:]
- vp.i = k2
+ v2 := make([]uint64, len(v))
+ var i uint
+ for k := range v {
+ v2[i] = uint64(k)
i++
}
- sort.Sort(bytesISlice(v2))
- if esep {
- for j := range v2 {
- ee.WriteMapElemKey()
- e.asis(v2[j].v)
- ee.WriteMapElemValue()
- e.encode(v[v2[j].i])
- }
- } else {
- for j := range v2 {
- e.asis(v2[j].v)
- e.encode(v[v2[j].i])
- }
+ sort.Sort(uint64Slice(v2))
+ for _, k2 := range v2 {
+ e.mapElemKey()
+ e.e.EncodeUint(uint64(uint(k2)))
+ e.mapElemValue()
+ e.e.EncodeUint(uint64(v[uint(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- e.encode(k2)
- ee.WriteMapElemValue()
- ee.EncodeFloat64(v2)
- }
- } else {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeFloat64(v2)
- }
+ for k2, v2 := range v {
+ e.mapElemKey()
+ e.e.EncodeUint(uint64(k2))
+ e.mapElemValue()
+ e.e.EncodeUint(uint64(v2))
}
}
- ee.WriteMapEnd()
+ e.mapEnd()
}
-
-func (e *Encoder) fastpathEncMapIntfBoolR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapIntfBoolV(rv2i(rv).(map[interface{}]bool), e)
+func (e *Encoder) fastpathEncMapUintUint8R(f *codecFnInfo, rv reflect.Value) {
+ fastpathTV.EncMapUintUint8V(rv2i(rv).(map[uint]uint8), e)
}
-func (_ fastpathT) EncMapIntfBoolV(v map[interface{}]bool, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+func (fastpathT) EncMapUintUint8V(v map[uint]uint8, e *Encoder) {
+ e.mapStart(len(v))
if e.h.Canonical {
- var mksv []byte = make([]byte, 0, len(v)*16) // temporary byte slice for the encoding
- e2 := NewEncoderBytes(&mksv, e.hh)
- v2 := make([]bytesI, len(v))
- var i, l uint
- var vp *bytesI
- for k2 := range v {
- l = uint(len(mksv))
- e2.MustEncode(k2)
- vp = &v2[i]
- vp.v = mksv[l:]
- vp.i = k2
+ v2 := make([]uint64, len(v))
+ var i uint
+ for k := range v {
+ v2[i] = uint64(k)
i++
}
- sort.Sort(bytesISlice(v2))
- if esep {
- for j := range v2 {
- ee.WriteMapElemKey()
- e.asis(v2[j].v)
- ee.WriteMapElemValue()
- e.encode(v[v2[j].i])
- }
- } else {
- for j := range v2 {
- e.asis(v2[j].v)
- e.encode(v[v2[j].i])
- }
+ sort.Sort(uint64Slice(v2))
+ for _, k2 := range v2 {
+ e.mapElemKey()
+ e.e.EncodeUint(uint64(uint(k2)))
+ e.mapElemValue()
+ e.e.EncodeUint(uint64(v[uint(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- e.encode(k2)
- ee.WriteMapElemValue()
- ee.EncodeBool(v2)
- }
- } else {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeBool(v2)
- }
+ for k2, v2 := range v {
+ e.mapElemKey()
+ e.e.EncodeUint(uint64(k2))
+ e.mapElemValue()
+ e.e.EncodeUint(uint64(v2))
}
}
- ee.WriteMapEnd()
+ e.mapEnd()
}
-
-func (e *Encoder) fastpathEncMapStringIntfR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapStringIntfV(rv2i(rv).(map[string]interface{}), e)
+func (e *Encoder) fastpathEncMapUintUint64R(f *codecFnInfo, rv reflect.Value) {
+ fastpathTV.EncMapUintUint64V(rv2i(rv).(map[uint]uint64), e)
}
-func (_ fastpathT) EncMapStringIntfV(v map[string]interface{}, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+func (fastpathT) EncMapUintUint64V(v map[uint]uint64, e *Encoder) {
+ e.mapStart(len(v))
if e.h.Canonical {
- v2 := make([]string, len(v))
+ v2 := make([]uint64, len(v))
var i uint
for k := range v {
- v2[i] = string(k)
+ v2[i] = uint64(k)
i++
}
- sort.Sort(stringSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeStringEnc(cUTF8, k2)
- ee.WriteMapElemValue()
- e.encode(v[string(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeStringEnc(cUTF8, k2)
- e.encode(v[string(k2)])
- }
+ sort.Sort(uint64Slice(v2))
+ for _, k2 := range v2 {
+ e.mapElemKey()
+ e.e.EncodeUint(uint64(uint(k2)))
+ e.mapElemValue()
+ e.e.EncodeUint(v[uint(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeStringEnc(cUTF8, k2)
- ee.WriteMapElemValue()
- e.encode(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeStringEnc(cUTF8, k2)
- e.encode(v2)
- }
+ for k2, v2 := range v {
+ e.mapElemKey()
+ e.e.EncodeUint(uint64(k2))
+ e.mapElemValue()
+ e.e.EncodeUint(v2)
}
}
- ee.WriteMapEnd()
+ e.mapEnd()
}
-
-func (e *Encoder) fastpathEncMapStringStringR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapStringStringV(rv2i(rv).(map[string]string), e)
+func (e *Encoder) fastpathEncMapUintIntR(f *codecFnInfo, rv reflect.Value) {
+ fastpathTV.EncMapUintIntV(rv2i(rv).(map[uint]int), e)
}
-func (_ fastpathT) EncMapStringStringV(v map[string]string, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+func (fastpathT) EncMapUintIntV(v map[uint]int, e *Encoder) {
+ e.mapStart(len(v))
if e.h.Canonical {
- v2 := make([]string, len(v))
+ v2 := make([]uint64, len(v))
var i uint
for k := range v {
- v2[i] = string(k)
+ v2[i] = uint64(k)
i++
}
- sort.Sort(stringSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeStringEnc(cUTF8, k2)
- ee.WriteMapElemValue()
- ee.EncodeStringEnc(cUTF8, v[string(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeStringEnc(cUTF8, k2)
- ee.EncodeStringEnc(cUTF8, v[string(k2)])
- }
+ sort.Sort(uint64Slice(v2))
+ for _, k2 := range v2 {
+ e.mapElemKey()
+ e.e.EncodeUint(uint64(uint(k2)))
+ e.mapElemValue()
+ e.e.EncodeInt(int64(v[uint(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeStringEnc(cUTF8, k2)
- ee.WriteMapElemValue()
- ee.EncodeStringEnc(cUTF8, v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeStringEnc(cUTF8, k2)
- ee.EncodeStringEnc(cUTF8, v2)
- }
+ for k2, v2 := range v {
+ e.mapElemKey()
+ e.e.EncodeUint(uint64(k2))
+ e.mapElemValue()
+ e.e.EncodeInt(int64(v2))
}
}
- ee.WriteMapEnd()
+ e.mapEnd()
}
-
-func (e *Encoder) fastpathEncMapStringUintR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapStringUintV(rv2i(rv).(map[string]uint), e)
+func (e *Encoder) fastpathEncMapUintInt64R(f *codecFnInfo, rv reflect.Value) {
+ fastpathTV.EncMapUintInt64V(rv2i(rv).(map[uint]int64), e)
}
-func (_ fastpathT) EncMapStringUintV(v map[string]uint, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+func (fastpathT) EncMapUintInt64V(v map[uint]int64, e *Encoder) {
+ e.mapStart(len(v))
if e.h.Canonical {
- v2 := make([]string, len(v))
+ v2 := make([]uint64, len(v))
var i uint
for k := range v {
- v2[i] = string(k)
+ v2[i] = uint64(k)
i++
}
- sort.Sort(stringSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeStringEnc(cUTF8, k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[string(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeStringEnc(cUTF8, k2)
- ee.EncodeUint(uint64(v[string(k2)]))
- }
+ sort.Sort(uint64Slice(v2))
+ for _, k2 := range v2 {
+ e.mapElemKey()
+ e.e.EncodeUint(uint64(uint(k2)))
+ e.mapElemValue()
+ e.e.EncodeInt(v[uint(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeStringEnc(cUTF8, k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeStringEnc(cUTF8, k2)
- ee.EncodeUint(uint64(v2))
- }
+ for k2, v2 := range v {
+ e.mapElemKey()
+ e.e.EncodeUint(uint64(k2))
+ e.mapElemValue()
+ e.e.EncodeInt(v2)
}
}
- ee.WriteMapEnd()
+ e.mapEnd()
}
-
-func (e *Encoder) fastpathEncMapStringUint8R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapStringUint8V(rv2i(rv).(map[string]uint8), e)
+func (e *Encoder) fastpathEncMapUintFloat32R(f *codecFnInfo, rv reflect.Value) {
+ fastpathTV.EncMapUintFloat32V(rv2i(rv).(map[uint]float32), e)
}
-func (_ fastpathT) EncMapStringUint8V(v map[string]uint8, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+func (fastpathT) EncMapUintFloat32V(v map[uint]float32, e *Encoder) {
+ e.mapStart(len(v))
if e.h.Canonical {
- v2 := make([]string, len(v))
+ v2 := make([]uint64, len(v))
var i uint
for k := range v {
- v2[i] = string(k)
+ v2[i] = uint64(k)
i++
}
- sort.Sort(stringSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeStringEnc(cUTF8, k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[string(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeStringEnc(cUTF8, k2)
- ee.EncodeUint(uint64(v[string(k2)]))
- }
+ sort.Sort(uint64Slice(v2))
+ for _, k2 := range v2 {
+ e.mapElemKey()
+ e.e.EncodeUint(uint64(uint(k2)))
+ e.mapElemValue()
+ e.e.EncodeFloat32(v[uint(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeStringEnc(cUTF8, k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeStringEnc(cUTF8, k2)
- ee.EncodeUint(uint64(v2))
- }
+ for k2, v2 := range v {
+ e.mapElemKey()
+ e.e.EncodeUint(uint64(k2))
+ e.mapElemValue()
+ e.e.EncodeFloat32(v2)
}
}
- ee.WriteMapEnd()
+ e.mapEnd()
}
-
-func (e *Encoder) fastpathEncMapStringUint16R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapStringUint16V(rv2i(rv).(map[string]uint16), e)
+func (e *Encoder) fastpathEncMapUintFloat64R(f *codecFnInfo, rv reflect.Value) {
+ fastpathTV.EncMapUintFloat64V(rv2i(rv).(map[uint]float64), e)
}
-func (_ fastpathT) EncMapStringUint16V(v map[string]uint16, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+func (fastpathT) EncMapUintFloat64V(v map[uint]float64, e *Encoder) {
+ e.mapStart(len(v))
if e.h.Canonical {
- v2 := make([]string, len(v))
+ v2 := make([]uint64, len(v))
var i uint
for k := range v {
- v2[i] = string(k)
+ v2[i] = uint64(k)
i++
}
- sort.Sort(stringSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeStringEnc(cUTF8, k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[string(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeStringEnc(cUTF8, k2)
- ee.EncodeUint(uint64(v[string(k2)]))
- }
+ sort.Sort(uint64Slice(v2))
+ for _, k2 := range v2 {
+ e.mapElemKey()
+ e.e.EncodeUint(uint64(uint(k2)))
+ e.mapElemValue()
+ e.e.EncodeFloat64(v[uint(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeStringEnc(cUTF8, k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeStringEnc(cUTF8, k2)
- ee.EncodeUint(uint64(v2))
- }
+ for k2, v2 := range v {
+ e.mapElemKey()
+ e.e.EncodeUint(uint64(k2))
+ e.mapElemValue()
+ e.e.EncodeFloat64(v2)
}
}
- ee.WriteMapEnd()
+ e.mapEnd()
}
-
-func (e *Encoder) fastpathEncMapStringUint32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapStringUint32V(rv2i(rv).(map[string]uint32), e)
+func (e *Encoder) fastpathEncMapUintBoolR(f *codecFnInfo, rv reflect.Value) {
+ fastpathTV.EncMapUintBoolV(rv2i(rv).(map[uint]bool), e)
}
-func (_ fastpathT) EncMapStringUint32V(v map[string]uint32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+func (fastpathT) EncMapUintBoolV(v map[uint]bool, e *Encoder) {
+ e.mapStart(len(v))
if e.h.Canonical {
- v2 := make([]string, len(v))
+ v2 := make([]uint64, len(v))
var i uint
for k := range v {
- v2[i] = string(k)
+ v2[i] = uint64(k)
i++
}
- sort.Sort(stringSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeStringEnc(cUTF8, k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[string(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeStringEnc(cUTF8, k2)
- ee.EncodeUint(uint64(v[string(k2)]))
- }
+ sort.Sort(uint64Slice(v2))
+ for _, k2 := range v2 {
+ e.mapElemKey()
+ e.e.EncodeUint(uint64(uint(k2)))
+ e.mapElemValue()
+ e.e.EncodeBool(v[uint(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeStringEnc(cUTF8, k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeStringEnc(cUTF8, k2)
- ee.EncodeUint(uint64(v2))
- }
+ for k2, v2 := range v {
+ e.mapElemKey()
+ e.e.EncodeUint(uint64(k2))
+ e.mapElemValue()
+ e.e.EncodeBool(v2)
}
}
- ee.WriteMapEnd()
+ e.mapEnd()
}
-
-func (e *Encoder) fastpathEncMapStringUint64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapStringUint64V(rv2i(rv).(map[string]uint64), e)
+func (e *Encoder) fastpathEncMapUint8IntfR(f *codecFnInfo, rv reflect.Value) {
+ fastpathTV.EncMapUint8IntfV(rv2i(rv).(map[uint8]interface{}), e)
}
-func (_ fastpathT) EncMapStringUint64V(v map[string]uint64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+func (fastpathT) EncMapUint8IntfV(v map[uint8]interface{}, e *Encoder) {
+ e.mapStart(len(v))
if e.h.Canonical {
- v2 := make([]string, len(v))
+ v2 := make([]uint64, len(v))
var i uint
for k := range v {
- v2[i] = string(k)
+ v2[i] = uint64(k)
i++
}
- sort.Sort(stringSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeStringEnc(cUTF8, k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[string(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeStringEnc(cUTF8, k2)
- ee.EncodeUint(uint64(v[string(k2)]))
- }
+ sort.Sort(uint64Slice(v2))
+ for _, k2 := range v2 {
+ e.mapElemKey()
+ e.e.EncodeUint(uint64(uint8(k2)))
+ e.mapElemValue()
+ e.encode(v[uint8(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeStringEnc(cUTF8, k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeStringEnc(cUTF8, k2)
- ee.EncodeUint(uint64(v2))
- }
+ for k2, v2 := range v {
+ e.mapElemKey()
+ e.e.EncodeUint(uint64(k2))
+ e.mapElemValue()
+ e.encode(v2)
}
}
- ee.WriteMapEnd()
+ e.mapEnd()
}
-
-func (e *Encoder) fastpathEncMapStringUintptrR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapStringUintptrV(rv2i(rv).(map[string]uintptr), e)
+func (e *Encoder) fastpathEncMapUint8StringR(f *codecFnInfo, rv reflect.Value) {
+ fastpathTV.EncMapUint8StringV(rv2i(rv).(map[uint8]string), e)
}
-func (_ fastpathT) EncMapStringUintptrV(v map[string]uintptr, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+func (fastpathT) EncMapUint8StringV(v map[uint8]string, e *Encoder) {
+ e.mapStart(len(v))
if e.h.Canonical {
- v2 := make([]string, len(v))
+ v2 := make([]uint64, len(v))
var i uint
for k := range v {
- v2[i] = string(k)
+ v2[i] = uint64(k)
i++
}
- sort.Sort(stringSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeStringEnc(cUTF8, k2)
- ee.WriteMapElemValue()
- e.encode(v[string(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeStringEnc(cUTF8, k2)
- e.encode(v[string(k2)])
- }
+ sort.Sort(uint64Slice(v2))
+ for _, k2 := range v2 {
+ e.mapElemKey()
+ e.e.EncodeUint(uint64(uint8(k2)))
+ e.mapElemValue()
+ e.e.EncodeString(v[uint8(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeStringEnc(cUTF8, k2)
- ee.WriteMapElemValue()
- e.encode(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeStringEnc(cUTF8, k2)
- e.encode(v2)
- }
+ for k2, v2 := range v {
+ e.mapElemKey()
+ e.e.EncodeUint(uint64(k2))
+ e.mapElemValue()
+ e.e.EncodeString(v2)
}
}
- ee.WriteMapEnd()
+ e.mapEnd()
}
-
-func (e *Encoder) fastpathEncMapStringIntR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapStringIntV(rv2i(rv).(map[string]int), e)
+func (e *Encoder) fastpathEncMapUint8BytesR(f *codecFnInfo, rv reflect.Value) {
+ fastpathTV.EncMapUint8BytesV(rv2i(rv).(map[uint8][]byte), e)
}
-func (_ fastpathT) EncMapStringIntV(v map[string]int, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+func (fastpathT) EncMapUint8BytesV(v map[uint8][]byte, e *Encoder) {
+ e.mapStart(len(v))
if e.h.Canonical {
- v2 := make([]string, len(v))
+ v2 := make([]uint64, len(v))
var i uint
for k := range v {
- v2[i] = string(k)
+ v2[i] = uint64(k)
i++
}
- sort.Sort(stringSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeStringEnc(cUTF8, k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[string(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeStringEnc(cUTF8, k2)
- ee.EncodeInt(int64(v[string(k2)]))
- }
+ sort.Sort(uint64Slice(v2))
+ for _, k2 := range v2 {
+ e.mapElemKey()
+ e.e.EncodeUint(uint64(uint8(k2)))
+ e.mapElemValue()
+ e.e.EncodeStringBytesRaw(v[uint8(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeStringEnc(cUTF8, k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeStringEnc(cUTF8, k2)
- ee.EncodeInt(int64(v2))
- }
+ for k2, v2 := range v {
+ e.mapElemKey()
+ e.e.EncodeUint(uint64(k2))
+ e.mapElemValue()
+ e.e.EncodeStringBytesRaw(v2)
}
}
- ee.WriteMapEnd()
+ e.mapEnd()
}
-
-func (e *Encoder) fastpathEncMapStringInt8R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapStringInt8V(rv2i(rv).(map[string]int8), e)
+func (e *Encoder) fastpathEncMapUint8UintR(f *codecFnInfo, rv reflect.Value) {
+ fastpathTV.EncMapUint8UintV(rv2i(rv).(map[uint8]uint), e)
}
-func (_ fastpathT) EncMapStringInt8V(v map[string]int8, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+func (fastpathT) EncMapUint8UintV(v map[uint8]uint, e *Encoder) {
+ e.mapStart(len(v))
if e.h.Canonical {
- v2 := make([]string, len(v))
+ v2 := make([]uint64, len(v))
var i uint
for k := range v {
- v2[i] = string(k)
+ v2[i] = uint64(k)
i++
}
- sort.Sort(stringSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeStringEnc(cUTF8, k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[string(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeStringEnc(cUTF8, k2)
- ee.EncodeInt(int64(v[string(k2)]))
- }
+ sort.Sort(uint64Slice(v2))
+ for _, k2 := range v2 {
+ e.mapElemKey()
+ e.e.EncodeUint(uint64(uint8(k2)))
+ e.mapElemValue()
+ e.e.EncodeUint(uint64(v[uint8(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeStringEnc(cUTF8, k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeStringEnc(cUTF8, k2)
- ee.EncodeInt(int64(v2))
- }
+ for k2, v2 := range v {
+ e.mapElemKey()
+ e.e.EncodeUint(uint64(k2))
+ e.mapElemValue()
+ e.e.EncodeUint(uint64(v2))
}
}
- ee.WriteMapEnd()
+ e.mapEnd()
}
-
-func (e *Encoder) fastpathEncMapStringInt16R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapStringInt16V(rv2i(rv).(map[string]int16), e)
+func (e *Encoder) fastpathEncMapUint8Uint8R(f *codecFnInfo, rv reflect.Value) {
+ fastpathTV.EncMapUint8Uint8V(rv2i(rv).(map[uint8]uint8), e)
}
-func (_ fastpathT) EncMapStringInt16V(v map[string]int16, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+func (fastpathT) EncMapUint8Uint8V(v map[uint8]uint8, e *Encoder) {
+ e.mapStart(len(v))
if e.h.Canonical {
- v2 := make([]string, len(v))
+ v2 := make([]uint64, len(v))
var i uint
for k := range v {
- v2[i] = string(k)
+ v2[i] = uint64(k)
i++
}
- sort.Sort(stringSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeStringEnc(cUTF8, k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[string(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeStringEnc(cUTF8, k2)
- ee.EncodeInt(int64(v[string(k2)]))
- }
+ sort.Sort(uint64Slice(v2))
+ for _, k2 := range v2 {
+ e.mapElemKey()
+ e.e.EncodeUint(uint64(uint8(k2)))
+ e.mapElemValue()
+ e.e.EncodeUint(uint64(v[uint8(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeStringEnc(cUTF8, k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeStringEnc(cUTF8, k2)
- ee.EncodeInt(int64(v2))
- }
+ for k2, v2 := range v {
+ e.mapElemKey()
+ e.e.EncodeUint(uint64(k2))
+ e.mapElemValue()
+ e.e.EncodeUint(uint64(v2))
}
}
- ee.WriteMapEnd()
+ e.mapEnd()
}
-
-func (e *Encoder) fastpathEncMapStringInt32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapStringInt32V(rv2i(rv).(map[string]int32), e)
+func (e *Encoder) fastpathEncMapUint8Uint64R(f *codecFnInfo, rv reflect.Value) {
+ fastpathTV.EncMapUint8Uint64V(rv2i(rv).(map[uint8]uint64), e)
}
-func (_ fastpathT) EncMapStringInt32V(v map[string]int32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+func (fastpathT) EncMapUint8Uint64V(v map[uint8]uint64, e *Encoder) {
+ e.mapStart(len(v))
if e.h.Canonical {
- v2 := make([]string, len(v))
+ v2 := make([]uint64, len(v))
var i uint
for k := range v {
- v2[i] = string(k)
+ v2[i] = uint64(k)
i++
}
- sort.Sort(stringSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeStringEnc(cUTF8, k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[string(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeStringEnc(cUTF8, k2)
- ee.EncodeInt(int64(v[string(k2)]))
- }
+ sort.Sort(uint64Slice(v2))
+ for _, k2 := range v2 {
+ e.mapElemKey()
+ e.e.EncodeUint(uint64(uint8(k2)))
+ e.mapElemValue()
+ e.e.EncodeUint(v[uint8(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeStringEnc(cUTF8, k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeStringEnc(cUTF8, k2)
- ee.EncodeInt(int64(v2))
- }
+ for k2, v2 := range v {
+ e.mapElemKey()
+ e.e.EncodeUint(uint64(k2))
+ e.mapElemValue()
+ e.e.EncodeUint(v2)
}
}
- ee.WriteMapEnd()
+ e.mapEnd()
}
-
-func (e *Encoder) fastpathEncMapStringInt64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapStringInt64V(rv2i(rv).(map[string]int64), e)
+func (e *Encoder) fastpathEncMapUint8IntR(f *codecFnInfo, rv reflect.Value) {
+ fastpathTV.EncMapUint8IntV(rv2i(rv).(map[uint8]int), e)
}
-func (_ fastpathT) EncMapStringInt64V(v map[string]int64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+func (fastpathT) EncMapUint8IntV(v map[uint8]int, e *Encoder) {
+ e.mapStart(len(v))
if e.h.Canonical {
- v2 := make([]string, len(v))
+ v2 := make([]uint64, len(v))
var i uint
for k := range v {
- v2[i] = string(k)
+ v2[i] = uint64(k)
i++
}
- sort.Sort(stringSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeStringEnc(cUTF8, k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[string(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeStringEnc(cUTF8, k2)
- ee.EncodeInt(int64(v[string(k2)]))
- }
+ sort.Sort(uint64Slice(v2))
+ for _, k2 := range v2 {
+ e.mapElemKey()
+ e.e.EncodeUint(uint64(uint8(k2)))
+ e.mapElemValue()
+ e.e.EncodeInt(int64(v[uint8(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeStringEnc(cUTF8, k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeStringEnc(cUTF8, k2)
- ee.EncodeInt(int64(v2))
- }
+ for k2, v2 := range v {
+ e.mapElemKey()
+ e.e.EncodeUint(uint64(k2))
+ e.mapElemValue()
+ e.e.EncodeInt(int64(v2))
}
}
- ee.WriteMapEnd()
+ e.mapEnd()
}
-
-func (e *Encoder) fastpathEncMapStringFloat32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapStringFloat32V(rv2i(rv).(map[string]float32), e)
+func (e *Encoder) fastpathEncMapUint8Int64R(f *codecFnInfo, rv reflect.Value) {
+ fastpathTV.EncMapUint8Int64V(rv2i(rv).(map[uint8]int64), e)
}
-func (_ fastpathT) EncMapStringFloat32V(v map[string]float32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+func (fastpathT) EncMapUint8Int64V(v map[uint8]int64, e *Encoder) {
+ e.mapStart(len(v))
if e.h.Canonical {
- v2 := make([]string, len(v))
+ v2 := make([]uint64, len(v))
var i uint
for k := range v {
- v2[i] = string(k)
+ v2[i] = uint64(k)
i++
}
- sort.Sort(stringSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeStringEnc(cUTF8, k2)
- ee.WriteMapElemValue()
- ee.EncodeFloat32(v[string(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeStringEnc(cUTF8, k2)
- ee.EncodeFloat32(v[string(k2)])
- }
+ sort.Sort(uint64Slice(v2))
+ for _, k2 := range v2 {
+ e.mapElemKey()
+ e.e.EncodeUint(uint64(uint8(k2)))
+ e.mapElemValue()
+ e.e.EncodeInt(v[uint8(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeStringEnc(cUTF8, k2)
- ee.WriteMapElemValue()
- ee.EncodeFloat32(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeStringEnc(cUTF8, k2)
- ee.EncodeFloat32(v2)
- }
+ for k2, v2 := range v {
+ e.mapElemKey()
+ e.e.EncodeUint(uint64(k2))
+ e.mapElemValue()
+ e.e.EncodeInt(v2)
}
}
- ee.WriteMapEnd()
+ e.mapEnd()
}
-
-func (e *Encoder) fastpathEncMapStringFloat64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapStringFloat64V(rv2i(rv).(map[string]float64), e)
+func (e *Encoder) fastpathEncMapUint8Float32R(f *codecFnInfo, rv reflect.Value) {
+ fastpathTV.EncMapUint8Float32V(rv2i(rv).(map[uint8]float32), e)
}
-func (_ fastpathT) EncMapStringFloat64V(v map[string]float64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+func (fastpathT) EncMapUint8Float32V(v map[uint8]float32, e *Encoder) {
+ e.mapStart(len(v))
if e.h.Canonical {
- v2 := make([]string, len(v))
+ v2 := make([]uint64, len(v))
var i uint
for k := range v {
- v2[i] = string(k)
+ v2[i] = uint64(k)
i++
}
- sort.Sort(stringSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeStringEnc(cUTF8, k2)
- ee.WriteMapElemValue()
- ee.EncodeFloat64(v[string(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeStringEnc(cUTF8, k2)
- ee.EncodeFloat64(v[string(k2)])
- }
+ sort.Sort(uint64Slice(v2))
+ for _, k2 := range v2 {
+ e.mapElemKey()
+ e.e.EncodeUint(uint64(uint8(k2)))
+ e.mapElemValue()
+ e.e.EncodeFloat32(v[uint8(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeStringEnc(cUTF8, k2)
- ee.WriteMapElemValue()
- ee.EncodeFloat64(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeStringEnc(cUTF8, k2)
- ee.EncodeFloat64(v2)
- }
+ for k2, v2 := range v {
+ e.mapElemKey()
+ e.e.EncodeUint(uint64(k2))
+ e.mapElemValue()
+ e.e.EncodeFloat32(v2)
}
}
- ee.WriteMapEnd()
+ e.mapEnd()
}
-
-func (e *Encoder) fastpathEncMapStringBoolR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapStringBoolV(rv2i(rv).(map[string]bool), e)
+func (e *Encoder) fastpathEncMapUint8Float64R(f *codecFnInfo, rv reflect.Value) {
+ fastpathTV.EncMapUint8Float64V(rv2i(rv).(map[uint8]float64), e)
}
-func (_ fastpathT) EncMapStringBoolV(v map[string]bool, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+func (fastpathT) EncMapUint8Float64V(v map[uint8]float64, e *Encoder) {
+ e.mapStart(len(v))
if e.h.Canonical {
- v2 := make([]string, len(v))
+ v2 := make([]uint64, len(v))
var i uint
for k := range v {
- v2[i] = string(k)
+ v2[i] = uint64(k)
i++
}
- sort.Sort(stringSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeStringEnc(cUTF8, k2)
- ee.WriteMapElemValue()
- ee.EncodeBool(v[string(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeStringEnc(cUTF8, k2)
- ee.EncodeBool(v[string(k2)])
- }
+ sort.Sort(uint64Slice(v2))
+ for _, k2 := range v2 {
+ e.mapElemKey()
+ e.e.EncodeUint(uint64(uint8(k2)))
+ e.mapElemValue()
+ e.e.EncodeFloat64(v[uint8(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeStringEnc(cUTF8, k2)
- ee.WriteMapElemValue()
- ee.EncodeBool(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeStringEnc(cUTF8, k2)
- ee.EncodeBool(v2)
- }
+ for k2, v2 := range v {
+ e.mapElemKey()
+ e.e.EncodeUint(uint64(k2))
+ e.mapElemValue()
+ e.e.EncodeFloat64(v2)
}
}
- ee.WriteMapEnd()
+ e.mapEnd()
}
-
-func (e *Encoder) fastpathEncMapFloat32IntfR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapFloat32IntfV(rv2i(rv).(map[float32]interface{}), e)
+func (e *Encoder) fastpathEncMapUint8BoolR(f *codecFnInfo, rv reflect.Value) {
+ fastpathTV.EncMapUint8BoolV(rv2i(rv).(map[uint8]bool), e)
}
-func (_ fastpathT) EncMapFloat32IntfV(v map[float32]interface{}, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+func (fastpathT) EncMapUint8BoolV(v map[uint8]bool, e *Encoder) {
+ e.mapStart(len(v))
if e.h.Canonical {
- v2 := make([]float64, len(v))
+ v2 := make([]uint64, len(v))
var i uint
for k := range v {
- v2[i] = float64(k)
+ v2[i] = uint64(k)
i++
}
- sort.Sort(floatSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeFloat32(float32(k2))
- ee.WriteMapElemValue()
- e.encode(v[float32(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeFloat32(float32(k2))
- e.encode(v[float32(k2)])
- }
+ sort.Sort(uint64Slice(v2))
+ for _, k2 := range v2 {
+ e.mapElemKey()
+ e.e.EncodeUint(uint64(uint8(k2)))
+ e.mapElemValue()
+ e.e.EncodeBool(v[uint8(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeFloat32(k2)
- ee.WriteMapElemValue()
- e.encode(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeFloat32(k2)
- e.encode(v2)
- }
+ for k2, v2 := range v {
+ e.mapElemKey()
+ e.e.EncodeUint(uint64(k2))
+ e.mapElemValue()
+ e.e.EncodeBool(v2)
}
}
- ee.WriteMapEnd()
+ e.mapEnd()
}
-
-func (e *Encoder) fastpathEncMapFloat32StringR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapFloat32StringV(rv2i(rv).(map[float32]string), e)
+func (e *Encoder) fastpathEncMapUint64IntfR(f *codecFnInfo, rv reflect.Value) {
+ fastpathTV.EncMapUint64IntfV(rv2i(rv).(map[uint64]interface{}), e)
}
-func (_ fastpathT) EncMapFloat32StringV(v map[float32]string, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+func (fastpathT) EncMapUint64IntfV(v map[uint64]interface{}, e *Encoder) {
+ e.mapStart(len(v))
if e.h.Canonical {
- v2 := make([]float64, len(v))
+ v2 := make([]uint64, len(v))
var i uint
for k := range v {
- v2[i] = float64(k)
+ v2[i] = k
i++
}
- sort.Sort(floatSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeFloat32(float32(k2))
- ee.WriteMapElemValue()
- ee.EncodeStringEnc(cUTF8, v[float32(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeFloat32(float32(k2))
- ee.EncodeStringEnc(cUTF8, v[float32(k2)])
- }
+ sort.Sort(uint64Slice(v2))
+ for _, k2 := range v2 {
+ e.mapElemKey()
+ e.e.EncodeUint(k2)
+ e.mapElemValue()
+ e.encode(v[k2])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeFloat32(k2)
- ee.WriteMapElemValue()
- ee.EncodeStringEnc(cUTF8, v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeFloat32(k2)
- ee.EncodeStringEnc(cUTF8, v2)
- }
+ for k2, v2 := range v {
+ e.mapElemKey()
+ e.e.EncodeUint(k2)
+ e.mapElemValue()
+ e.encode(v2)
}
}
- ee.WriteMapEnd()
+ e.mapEnd()
}
-
-func (e *Encoder) fastpathEncMapFloat32UintR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapFloat32UintV(rv2i(rv).(map[float32]uint), e)
+func (e *Encoder) fastpathEncMapUint64StringR(f *codecFnInfo, rv reflect.Value) {
+ fastpathTV.EncMapUint64StringV(rv2i(rv).(map[uint64]string), e)
}
-func (_ fastpathT) EncMapFloat32UintV(v map[float32]uint, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+func (fastpathT) EncMapUint64StringV(v map[uint64]string, e *Encoder) {
+ e.mapStart(len(v))
if e.h.Canonical {
- v2 := make([]float64, len(v))
+ v2 := make([]uint64, len(v))
var i uint
for k := range v {
- v2[i] = float64(k)
+ v2[i] = k
i++
}
- sort.Sort(floatSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeFloat32(float32(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[float32(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeFloat32(float32(k2))
- ee.EncodeUint(uint64(v[float32(k2)]))
- }
+ sort.Sort(uint64Slice(v2))
+ for _, k2 := range v2 {
+ e.mapElemKey()
+ e.e.EncodeUint(k2)
+ e.mapElemValue()
+ e.e.EncodeString(v[k2])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeFloat32(k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeFloat32(k2)
- ee.EncodeUint(uint64(v2))
- }
+ for k2, v2 := range v {
+ e.mapElemKey()
+ e.e.EncodeUint(k2)
+ e.mapElemValue()
+ e.e.EncodeString(v2)
}
}
- ee.WriteMapEnd()
+ e.mapEnd()
}
-
-func (e *Encoder) fastpathEncMapFloat32Uint8R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapFloat32Uint8V(rv2i(rv).(map[float32]uint8), e)
+func (e *Encoder) fastpathEncMapUint64BytesR(f *codecFnInfo, rv reflect.Value) {
+ fastpathTV.EncMapUint64BytesV(rv2i(rv).(map[uint64][]byte), e)
}
-func (_ fastpathT) EncMapFloat32Uint8V(v map[float32]uint8, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+func (fastpathT) EncMapUint64BytesV(v map[uint64][]byte, e *Encoder) {
+ e.mapStart(len(v))
if e.h.Canonical {
- v2 := make([]float64, len(v))
+ v2 := make([]uint64, len(v))
var i uint
for k := range v {
- v2[i] = float64(k)
+ v2[i] = k
i++
}
- sort.Sort(floatSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeFloat32(float32(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[float32(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeFloat32(float32(k2))
- ee.EncodeUint(uint64(v[float32(k2)]))
- }
+ sort.Sort(uint64Slice(v2))
+ for _, k2 := range v2 {
+ e.mapElemKey()
+ e.e.EncodeUint(k2)
+ e.mapElemValue()
+ e.e.EncodeStringBytesRaw(v[k2])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeFloat32(k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeFloat32(k2)
- ee.EncodeUint(uint64(v2))
- }
+ for k2, v2 := range v {
+ e.mapElemKey()
+ e.e.EncodeUint(k2)
+ e.mapElemValue()
+ e.e.EncodeStringBytesRaw(v2)
}
}
- ee.WriteMapEnd()
+ e.mapEnd()
}
-
-func (e *Encoder) fastpathEncMapFloat32Uint16R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapFloat32Uint16V(rv2i(rv).(map[float32]uint16), e)
+func (e *Encoder) fastpathEncMapUint64UintR(f *codecFnInfo, rv reflect.Value) {
+ fastpathTV.EncMapUint64UintV(rv2i(rv).(map[uint64]uint), e)
}
-func (_ fastpathT) EncMapFloat32Uint16V(v map[float32]uint16, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+func (fastpathT) EncMapUint64UintV(v map[uint64]uint, e *Encoder) {
+ e.mapStart(len(v))
if e.h.Canonical {
- v2 := make([]float64, len(v))
+ v2 := make([]uint64, len(v))
var i uint
for k := range v {
- v2[i] = float64(k)
+ v2[i] = k
i++
}
- sort.Sort(floatSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeFloat32(float32(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[float32(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeFloat32(float32(k2))
- ee.EncodeUint(uint64(v[float32(k2)]))
- }
+ sort.Sort(uint64Slice(v2))
+ for _, k2 := range v2 {
+ e.mapElemKey()
+ e.e.EncodeUint(k2)
+ e.mapElemValue()
+ e.e.EncodeUint(uint64(v[k2]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeFloat32(k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeFloat32(k2)
- ee.EncodeUint(uint64(v2))
- }
+ for k2, v2 := range v {
+ e.mapElemKey()
+ e.e.EncodeUint(k2)
+ e.mapElemValue()
+ e.e.EncodeUint(uint64(v2))
}
}
- ee.WriteMapEnd()
+ e.mapEnd()
}
-
-func (e *Encoder) fastpathEncMapFloat32Uint32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapFloat32Uint32V(rv2i(rv).(map[float32]uint32), e)
+func (e *Encoder) fastpathEncMapUint64Uint8R(f *codecFnInfo, rv reflect.Value) {
+ fastpathTV.EncMapUint64Uint8V(rv2i(rv).(map[uint64]uint8), e)
}
-func (_ fastpathT) EncMapFloat32Uint32V(v map[float32]uint32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+func (fastpathT) EncMapUint64Uint8V(v map[uint64]uint8, e *Encoder) {
+ e.mapStart(len(v))
if e.h.Canonical {
- v2 := make([]float64, len(v))
+ v2 := make([]uint64, len(v))
var i uint
for k := range v {
- v2[i] = float64(k)
+ v2[i] = k
i++
}
- sort.Sort(floatSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeFloat32(float32(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[float32(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeFloat32(float32(k2))
- ee.EncodeUint(uint64(v[float32(k2)]))
- }
+ sort.Sort(uint64Slice(v2))
+ for _, k2 := range v2 {
+ e.mapElemKey()
+ e.e.EncodeUint(k2)
+ e.mapElemValue()
+ e.e.EncodeUint(uint64(v[k2]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeFloat32(k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeFloat32(k2)
- ee.EncodeUint(uint64(v2))
- }
+ for k2, v2 := range v {
+ e.mapElemKey()
+ e.e.EncodeUint(k2)
+ e.mapElemValue()
+ e.e.EncodeUint(uint64(v2))
}
}
- ee.WriteMapEnd()
+ e.mapEnd()
}
-
-func (e *Encoder) fastpathEncMapFloat32Uint64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapFloat32Uint64V(rv2i(rv).(map[float32]uint64), e)
+func (e *Encoder) fastpathEncMapUint64Uint64R(f *codecFnInfo, rv reflect.Value) {
+ fastpathTV.EncMapUint64Uint64V(rv2i(rv).(map[uint64]uint64), e)
}
-func (_ fastpathT) EncMapFloat32Uint64V(v map[float32]uint64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+func (fastpathT) EncMapUint64Uint64V(v map[uint64]uint64, e *Encoder) {
+ e.mapStart(len(v))
if e.h.Canonical {
- v2 := make([]float64, len(v))
+ v2 := make([]uint64, len(v))
var i uint
for k := range v {
- v2[i] = float64(k)
+ v2[i] = k
i++
}
- sort.Sort(floatSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeFloat32(float32(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[float32(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeFloat32(float32(k2))
- ee.EncodeUint(uint64(v[float32(k2)]))
- }
+ sort.Sort(uint64Slice(v2))
+ for _, k2 := range v2 {
+ e.mapElemKey()
+ e.e.EncodeUint(k2)
+ e.mapElemValue()
+ e.e.EncodeUint(v[k2])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeFloat32(k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeFloat32(k2)
- ee.EncodeUint(uint64(v2))
- }
+ for k2, v2 := range v {
+ e.mapElemKey()
+ e.e.EncodeUint(k2)
+ e.mapElemValue()
+ e.e.EncodeUint(v2)
}
}
- ee.WriteMapEnd()
+ e.mapEnd()
}
-
-func (e *Encoder) fastpathEncMapFloat32UintptrR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapFloat32UintptrV(rv2i(rv).(map[float32]uintptr), e)
+func (e *Encoder) fastpathEncMapUint64IntR(f *codecFnInfo, rv reflect.Value) {
+ fastpathTV.EncMapUint64IntV(rv2i(rv).(map[uint64]int), e)
}
-func (_ fastpathT) EncMapFloat32UintptrV(v map[float32]uintptr, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+func (fastpathT) EncMapUint64IntV(v map[uint64]int, e *Encoder) {
+ e.mapStart(len(v))
if e.h.Canonical {
- v2 := make([]float64, len(v))
+ v2 := make([]uint64, len(v))
var i uint
for k := range v {
- v2[i] = float64(k)
+ v2[i] = k
i++
}
- sort.Sort(floatSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeFloat32(float32(k2))
- ee.WriteMapElemValue()
- e.encode(v[float32(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeFloat32(float32(k2))
- e.encode(v[float32(k2)])
- }
+ sort.Sort(uint64Slice(v2))
+ for _, k2 := range v2 {
+ e.mapElemKey()
+ e.e.EncodeUint(k2)
+ e.mapElemValue()
+ e.e.EncodeInt(int64(v[k2]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeFloat32(k2)
- ee.WriteMapElemValue()
- e.encode(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeFloat32(k2)
- e.encode(v2)
- }
+ for k2, v2 := range v {
+ e.mapElemKey()
+ e.e.EncodeUint(k2)
+ e.mapElemValue()
+ e.e.EncodeInt(int64(v2))
}
}
- ee.WriteMapEnd()
+ e.mapEnd()
}
-
-func (e *Encoder) fastpathEncMapFloat32IntR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapFloat32IntV(rv2i(rv).(map[float32]int), e)
+func (e *Encoder) fastpathEncMapUint64Int64R(f *codecFnInfo, rv reflect.Value) {
+ fastpathTV.EncMapUint64Int64V(rv2i(rv).(map[uint64]int64), e)
}
-func (_ fastpathT) EncMapFloat32IntV(v map[float32]int, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+func (fastpathT) EncMapUint64Int64V(v map[uint64]int64, e *Encoder) {
+ e.mapStart(len(v))
if e.h.Canonical {
- v2 := make([]float64, len(v))
+ v2 := make([]uint64, len(v))
var i uint
for k := range v {
- v2[i] = float64(k)
+ v2[i] = k
i++
}
- sort.Sort(floatSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeFloat32(float32(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[float32(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeFloat32(float32(k2))
- ee.EncodeInt(int64(v[float32(k2)]))
- }
+ sort.Sort(uint64Slice(v2))
+ for _, k2 := range v2 {
+ e.mapElemKey()
+ e.e.EncodeUint(k2)
+ e.mapElemValue()
+ e.e.EncodeInt(v[k2])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeFloat32(k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeFloat32(k2)
- ee.EncodeInt(int64(v2))
- }
+ for k2, v2 := range v {
+ e.mapElemKey()
+ e.e.EncodeUint(k2)
+ e.mapElemValue()
+ e.e.EncodeInt(v2)
}
}
- ee.WriteMapEnd()
+ e.mapEnd()
}
-
-func (e *Encoder) fastpathEncMapFloat32Int8R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapFloat32Int8V(rv2i(rv).(map[float32]int8), e)
+func (e *Encoder) fastpathEncMapUint64Float32R(f *codecFnInfo, rv reflect.Value) {
+ fastpathTV.EncMapUint64Float32V(rv2i(rv).(map[uint64]float32), e)
}
-func (_ fastpathT) EncMapFloat32Int8V(v map[float32]int8, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+func (fastpathT) EncMapUint64Float32V(v map[uint64]float32, e *Encoder) {
+ e.mapStart(len(v))
if e.h.Canonical {
- v2 := make([]float64, len(v))
+ v2 := make([]uint64, len(v))
var i uint
for k := range v {
- v2[i] = float64(k)
+ v2[i] = k
i++
}
- sort.Sort(floatSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeFloat32(float32(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[float32(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeFloat32(float32(k2))
- ee.EncodeInt(int64(v[float32(k2)]))
- }
+ sort.Sort(uint64Slice(v2))
+ for _, k2 := range v2 {
+ e.mapElemKey()
+ e.e.EncodeUint(k2)
+ e.mapElemValue()
+ e.e.EncodeFloat32(v[k2])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeFloat32(k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeFloat32(k2)
- ee.EncodeInt(int64(v2))
- }
+ for k2, v2 := range v {
+ e.mapElemKey()
+ e.e.EncodeUint(k2)
+ e.mapElemValue()
+ e.e.EncodeFloat32(v2)
}
}
- ee.WriteMapEnd()
+ e.mapEnd()
}
-
-func (e *Encoder) fastpathEncMapFloat32Int16R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapFloat32Int16V(rv2i(rv).(map[float32]int16), e)
+func (e *Encoder) fastpathEncMapUint64Float64R(f *codecFnInfo, rv reflect.Value) {
+ fastpathTV.EncMapUint64Float64V(rv2i(rv).(map[uint64]float64), e)
}
-func (_ fastpathT) EncMapFloat32Int16V(v map[float32]int16, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+func (fastpathT) EncMapUint64Float64V(v map[uint64]float64, e *Encoder) {
+ e.mapStart(len(v))
if e.h.Canonical {
- v2 := make([]float64, len(v))
+ v2 := make([]uint64, len(v))
var i uint
for k := range v {
- v2[i] = float64(k)
+ v2[i] = k
i++
}
- sort.Sort(floatSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeFloat32(float32(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[float32(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeFloat32(float32(k2))
- ee.EncodeInt(int64(v[float32(k2)]))
- }
+ sort.Sort(uint64Slice(v2))
+ for _, k2 := range v2 {
+ e.mapElemKey()
+ e.e.EncodeUint(k2)
+ e.mapElemValue()
+ e.e.EncodeFloat64(v[k2])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeFloat32(k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeFloat32(k2)
- ee.EncodeInt(int64(v2))
- }
+ for k2, v2 := range v {
+ e.mapElemKey()
+ e.e.EncodeUint(k2)
+ e.mapElemValue()
+ e.e.EncodeFloat64(v2)
}
}
- ee.WriteMapEnd()
+ e.mapEnd()
}
-
-func (e *Encoder) fastpathEncMapFloat32Int32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapFloat32Int32V(rv2i(rv).(map[float32]int32), e)
+func (e *Encoder) fastpathEncMapUint64BoolR(f *codecFnInfo, rv reflect.Value) {
+ fastpathTV.EncMapUint64BoolV(rv2i(rv).(map[uint64]bool), e)
}
-func (_ fastpathT) EncMapFloat32Int32V(v map[float32]int32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+func (fastpathT) EncMapUint64BoolV(v map[uint64]bool, e *Encoder) {
+ e.mapStart(len(v))
if e.h.Canonical {
- v2 := make([]float64, len(v))
+ v2 := make([]uint64, len(v))
var i uint
for k := range v {
- v2[i] = float64(k)
+ v2[i] = k
i++
}
- sort.Sort(floatSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeFloat32(float32(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[float32(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeFloat32(float32(k2))
- ee.EncodeInt(int64(v[float32(k2)]))
- }
+ sort.Sort(uint64Slice(v2))
+ for _, k2 := range v2 {
+ e.mapElemKey()
+ e.e.EncodeUint(k2)
+ e.mapElemValue()
+ e.e.EncodeBool(v[k2])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeFloat32(k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeFloat32(k2)
- ee.EncodeInt(int64(v2))
- }
+ for k2, v2 := range v {
+ e.mapElemKey()
+ e.e.EncodeUint(k2)
+ e.mapElemValue()
+ e.e.EncodeBool(v2)
}
}
- ee.WriteMapEnd()
+ e.mapEnd()
}
-
-func (e *Encoder) fastpathEncMapFloat32Int64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapFloat32Int64V(rv2i(rv).(map[float32]int64), e)
+func (e *Encoder) fastpathEncMapIntIntfR(f *codecFnInfo, rv reflect.Value) {
+ fastpathTV.EncMapIntIntfV(rv2i(rv).(map[int]interface{}), e)
}
-func (_ fastpathT) EncMapFloat32Int64V(v map[float32]int64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+func (fastpathT) EncMapIntIntfV(v map[int]interface{}, e *Encoder) {
+ e.mapStart(len(v))
if e.h.Canonical {
- v2 := make([]float64, len(v))
+ v2 := make([]int64, len(v))
var i uint
for k := range v {
- v2[i] = float64(k)
+ v2[i] = int64(k)
i++
}
- sort.Sort(floatSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeFloat32(float32(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[float32(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeFloat32(float32(k2))
- ee.EncodeInt(int64(v[float32(k2)]))
- }
+ sort.Sort(int64Slice(v2))
+ for _, k2 := range v2 {
+ e.mapElemKey()
+ e.e.EncodeInt(int64(int(k2)))
+ e.mapElemValue()
+ e.encode(v[int(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeFloat32(k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeFloat32(k2)
- ee.EncodeInt(int64(v2))
- }
+ for k2, v2 := range v {
+ e.mapElemKey()
+ e.e.EncodeInt(int64(k2))
+ e.mapElemValue()
+ e.encode(v2)
}
}
- ee.WriteMapEnd()
+ e.mapEnd()
}
-
-func (e *Encoder) fastpathEncMapFloat32Float32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapFloat32Float32V(rv2i(rv).(map[float32]float32), e)
+func (e *Encoder) fastpathEncMapIntStringR(f *codecFnInfo, rv reflect.Value) {
+ fastpathTV.EncMapIntStringV(rv2i(rv).(map[int]string), e)
}
-func (_ fastpathT) EncMapFloat32Float32V(v map[float32]float32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+func (fastpathT) EncMapIntStringV(v map[int]string, e *Encoder) {
+ e.mapStart(len(v))
if e.h.Canonical {
- v2 := make([]float64, len(v))
+ v2 := make([]int64, len(v))
var i uint
for k := range v {
- v2[i] = float64(k)
+ v2[i] = int64(k)
i++
}
- sort.Sort(floatSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeFloat32(float32(k2))
- ee.WriteMapElemValue()
- ee.EncodeFloat32(v[float32(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeFloat32(float32(k2))
- ee.EncodeFloat32(v[float32(k2)])
- }
+ sort.Sort(int64Slice(v2))
+ for _, k2 := range v2 {
+ e.mapElemKey()
+ e.e.EncodeInt(int64(int(k2)))
+ e.mapElemValue()
+ e.e.EncodeString(v[int(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeFloat32(k2)
- ee.WriteMapElemValue()
- ee.EncodeFloat32(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeFloat32(k2)
- ee.EncodeFloat32(v2)
- }
+ for k2, v2 := range v {
+ e.mapElemKey()
+ e.e.EncodeInt(int64(k2))
+ e.mapElemValue()
+ e.e.EncodeString(v2)
}
}
- ee.WriteMapEnd()
+ e.mapEnd()
}
-
-func (e *Encoder) fastpathEncMapFloat32Float64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapFloat32Float64V(rv2i(rv).(map[float32]float64), e)
+func (e *Encoder) fastpathEncMapIntBytesR(f *codecFnInfo, rv reflect.Value) {
+ fastpathTV.EncMapIntBytesV(rv2i(rv).(map[int][]byte), e)
}
-func (_ fastpathT) EncMapFloat32Float64V(v map[float32]float64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+func (fastpathT) EncMapIntBytesV(v map[int][]byte, e *Encoder) {
+ e.mapStart(len(v))
if e.h.Canonical {
- v2 := make([]float64, len(v))
+ v2 := make([]int64, len(v))
var i uint
for k := range v {
- v2[i] = float64(k)
+ v2[i] = int64(k)
i++
}
- sort.Sort(floatSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeFloat32(float32(k2))
- ee.WriteMapElemValue()
- ee.EncodeFloat64(v[float32(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeFloat32(float32(k2))
- ee.EncodeFloat64(v[float32(k2)])
- }
+ sort.Sort(int64Slice(v2))
+ for _, k2 := range v2 {
+ e.mapElemKey()
+ e.e.EncodeInt(int64(int(k2)))
+ e.mapElemValue()
+ e.e.EncodeStringBytesRaw(v[int(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeFloat32(k2)
- ee.WriteMapElemValue()
- ee.EncodeFloat64(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeFloat32(k2)
- ee.EncodeFloat64(v2)
- }
+ for k2, v2 := range v {
+ e.mapElemKey()
+ e.e.EncodeInt(int64(k2))
+ e.mapElemValue()
+ e.e.EncodeStringBytesRaw(v2)
}
}
- ee.WriteMapEnd()
+ e.mapEnd()
}
-
-func (e *Encoder) fastpathEncMapFloat32BoolR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapFloat32BoolV(rv2i(rv).(map[float32]bool), e)
+func (e *Encoder) fastpathEncMapIntUintR(f *codecFnInfo, rv reflect.Value) {
+ fastpathTV.EncMapIntUintV(rv2i(rv).(map[int]uint), e)
}
-func (_ fastpathT) EncMapFloat32BoolV(v map[float32]bool, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+func (fastpathT) EncMapIntUintV(v map[int]uint, e *Encoder) {
+ e.mapStart(len(v))
if e.h.Canonical {
- v2 := make([]float64, len(v))
+ v2 := make([]int64, len(v))
var i uint
for k := range v {
- v2[i] = float64(k)
+ v2[i] = int64(k)
i++
}
- sort.Sort(floatSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeFloat32(float32(k2))
- ee.WriteMapElemValue()
- ee.EncodeBool(v[float32(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeFloat32(float32(k2))
- ee.EncodeBool(v[float32(k2)])
- }
+ sort.Sort(int64Slice(v2))
+ for _, k2 := range v2 {
+ e.mapElemKey()
+ e.e.EncodeInt(int64(int(k2)))
+ e.mapElemValue()
+ e.e.EncodeUint(uint64(v[int(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeFloat32(k2)
- ee.WriteMapElemValue()
- ee.EncodeBool(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeFloat32(k2)
- ee.EncodeBool(v2)
- }
+ for k2, v2 := range v {
+ e.mapElemKey()
+ e.e.EncodeInt(int64(k2))
+ e.mapElemValue()
+ e.e.EncodeUint(uint64(v2))
}
}
- ee.WriteMapEnd()
+ e.mapEnd()
}
-
-func (e *Encoder) fastpathEncMapFloat64IntfR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapFloat64IntfV(rv2i(rv).(map[float64]interface{}), e)
+func (e *Encoder) fastpathEncMapIntUint8R(f *codecFnInfo, rv reflect.Value) {
+ fastpathTV.EncMapIntUint8V(rv2i(rv).(map[int]uint8), e)
}
-func (_ fastpathT) EncMapFloat64IntfV(v map[float64]interface{}, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+func (fastpathT) EncMapIntUint8V(v map[int]uint8, e *Encoder) {
+ e.mapStart(len(v))
if e.h.Canonical {
- v2 := make([]float64, len(v))
+ v2 := make([]int64, len(v))
var i uint
for k := range v {
- v2[i] = float64(k)
+ v2[i] = int64(k)
i++
}
- sort.Sort(floatSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeFloat64(float64(k2))
- ee.WriteMapElemValue()
- e.encode(v[float64(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeFloat64(float64(k2))
- e.encode(v[float64(k2)])
- }
+ sort.Sort(int64Slice(v2))
+ for _, k2 := range v2 {
+ e.mapElemKey()
+ e.e.EncodeInt(int64(int(k2)))
+ e.mapElemValue()
+ e.e.EncodeUint(uint64(v[int(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeFloat64(k2)
- ee.WriteMapElemValue()
- e.encode(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeFloat64(k2)
- e.encode(v2)
- }
+ for k2, v2 := range v {
+ e.mapElemKey()
+ e.e.EncodeInt(int64(k2))
+ e.mapElemValue()
+ e.e.EncodeUint(uint64(v2))
}
}
- ee.WriteMapEnd()
+ e.mapEnd()
}
-
-func (e *Encoder) fastpathEncMapFloat64StringR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapFloat64StringV(rv2i(rv).(map[float64]string), e)
+func (e *Encoder) fastpathEncMapIntUint64R(f *codecFnInfo, rv reflect.Value) {
+ fastpathTV.EncMapIntUint64V(rv2i(rv).(map[int]uint64), e)
}
-func (_ fastpathT) EncMapFloat64StringV(v map[float64]string, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+func (fastpathT) EncMapIntUint64V(v map[int]uint64, e *Encoder) {
+ e.mapStart(len(v))
if e.h.Canonical {
- v2 := make([]float64, len(v))
+ v2 := make([]int64, len(v))
var i uint
for k := range v {
- v2[i] = float64(k)
+ v2[i] = int64(k)
i++
}
- sort.Sort(floatSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeFloat64(float64(k2))
- ee.WriteMapElemValue()
- ee.EncodeStringEnc(cUTF8, v[float64(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeFloat64(float64(k2))
- ee.EncodeStringEnc(cUTF8, v[float64(k2)])
- }
+ sort.Sort(int64Slice(v2))
+ for _, k2 := range v2 {
+ e.mapElemKey()
+ e.e.EncodeInt(int64(int(k2)))
+ e.mapElemValue()
+ e.e.EncodeUint(v[int(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeFloat64(k2)
- ee.WriteMapElemValue()
- ee.EncodeStringEnc(cUTF8, v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeFloat64(k2)
- ee.EncodeStringEnc(cUTF8, v2)
- }
+ for k2, v2 := range v {
+ e.mapElemKey()
+ e.e.EncodeInt(int64(k2))
+ e.mapElemValue()
+ e.e.EncodeUint(v2)
}
}
- ee.WriteMapEnd()
+ e.mapEnd()
}
-
-func (e *Encoder) fastpathEncMapFloat64UintR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapFloat64UintV(rv2i(rv).(map[float64]uint), e)
+func (e *Encoder) fastpathEncMapIntIntR(f *codecFnInfo, rv reflect.Value) {
+ fastpathTV.EncMapIntIntV(rv2i(rv).(map[int]int), e)
}
-func (_ fastpathT) EncMapFloat64UintV(v map[float64]uint, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+func (fastpathT) EncMapIntIntV(v map[int]int, e *Encoder) {
+ e.mapStart(len(v))
if e.h.Canonical {
- v2 := make([]float64, len(v))
+ v2 := make([]int64, len(v))
var i uint
for k := range v {
- v2[i] = float64(k)
+ v2[i] = int64(k)
i++
}
- sort.Sort(floatSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeFloat64(float64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[float64(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeFloat64(float64(k2))
- ee.EncodeUint(uint64(v[float64(k2)]))
- }
+ sort.Sort(int64Slice(v2))
+ for _, k2 := range v2 {
+ e.mapElemKey()
+ e.e.EncodeInt(int64(int(k2)))
+ e.mapElemValue()
+ e.e.EncodeInt(int64(v[int(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeFloat64(k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeFloat64(k2)
- ee.EncodeUint(uint64(v2))
- }
+ for k2, v2 := range v {
+ e.mapElemKey()
+ e.e.EncodeInt(int64(k2))
+ e.mapElemValue()
+ e.e.EncodeInt(int64(v2))
}
}
- ee.WriteMapEnd()
+ e.mapEnd()
}
-
-func (e *Encoder) fastpathEncMapFloat64Uint8R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapFloat64Uint8V(rv2i(rv).(map[float64]uint8), e)
+func (e *Encoder) fastpathEncMapIntInt64R(f *codecFnInfo, rv reflect.Value) {
+ fastpathTV.EncMapIntInt64V(rv2i(rv).(map[int]int64), e)
}
-func (_ fastpathT) EncMapFloat64Uint8V(v map[float64]uint8, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+func (fastpathT) EncMapIntInt64V(v map[int]int64, e *Encoder) {
+ e.mapStart(len(v))
if e.h.Canonical {
- v2 := make([]float64, len(v))
+ v2 := make([]int64, len(v))
var i uint
for k := range v {
- v2[i] = float64(k)
+ v2[i] = int64(k)
i++
}
- sort.Sort(floatSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeFloat64(float64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[float64(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeFloat64(float64(k2))
- ee.EncodeUint(uint64(v[float64(k2)]))
- }
+ sort.Sort(int64Slice(v2))
+ for _, k2 := range v2 {
+ e.mapElemKey()
+ e.e.EncodeInt(int64(int(k2)))
+ e.mapElemValue()
+ e.e.EncodeInt(v[int(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeFloat64(k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeFloat64(k2)
- ee.EncodeUint(uint64(v2))
- }
+ for k2, v2 := range v {
+ e.mapElemKey()
+ e.e.EncodeInt(int64(k2))
+ e.mapElemValue()
+ e.e.EncodeInt(v2)
}
}
- ee.WriteMapEnd()
+ e.mapEnd()
}
-
-func (e *Encoder) fastpathEncMapFloat64Uint16R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapFloat64Uint16V(rv2i(rv).(map[float64]uint16), e)
+func (e *Encoder) fastpathEncMapIntFloat32R(f *codecFnInfo, rv reflect.Value) {
+ fastpathTV.EncMapIntFloat32V(rv2i(rv).(map[int]float32), e)
}
-func (_ fastpathT) EncMapFloat64Uint16V(v map[float64]uint16, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+func (fastpathT) EncMapIntFloat32V(v map[int]float32, e *Encoder) {
+ e.mapStart(len(v))
if e.h.Canonical {
- v2 := make([]float64, len(v))
+ v2 := make([]int64, len(v))
var i uint
for k := range v {
- v2[i] = float64(k)
+ v2[i] = int64(k)
i++
}
- sort.Sort(floatSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeFloat64(float64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[float64(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeFloat64(float64(k2))
- ee.EncodeUint(uint64(v[float64(k2)]))
- }
+ sort.Sort(int64Slice(v2))
+ for _, k2 := range v2 {
+ e.mapElemKey()
+ e.e.EncodeInt(int64(int(k2)))
+ e.mapElemValue()
+ e.e.EncodeFloat32(v[int(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeFloat64(k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeFloat64(k2)
- ee.EncodeUint(uint64(v2))
- }
+ for k2, v2 := range v {
+ e.mapElemKey()
+ e.e.EncodeInt(int64(k2))
+ e.mapElemValue()
+ e.e.EncodeFloat32(v2)
}
}
- ee.WriteMapEnd()
+ e.mapEnd()
}
-
-func (e *Encoder) fastpathEncMapFloat64Uint32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapFloat64Uint32V(rv2i(rv).(map[float64]uint32), e)
+func (e *Encoder) fastpathEncMapIntFloat64R(f *codecFnInfo, rv reflect.Value) {
+ fastpathTV.EncMapIntFloat64V(rv2i(rv).(map[int]float64), e)
}
-func (_ fastpathT) EncMapFloat64Uint32V(v map[float64]uint32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+func (fastpathT) EncMapIntFloat64V(v map[int]float64, e *Encoder) {
+ e.mapStart(len(v))
if e.h.Canonical {
- v2 := make([]float64, len(v))
+ v2 := make([]int64, len(v))
var i uint
for k := range v {
- v2[i] = float64(k)
+ v2[i] = int64(k)
i++
}
- sort.Sort(floatSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeFloat64(float64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[float64(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeFloat64(float64(k2))
- ee.EncodeUint(uint64(v[float64(k2)]))
- }
+ sort.Sort(int64Slice(v2))
+ for _, k2 := range v2 {
+ e.mapElemKey()
+ e.e.EncodeInt(int64(int(k2)))
+ e.mapElemValue()
+ e.e.EncodeFloat64(v[int(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeFloat64(k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeFloat64(k2)
- ee.EncodeUint(uint64(v2))
- }
+ for k2, v2 := range v {
+ e.mapElemKey()
+ e.e.EncodeInt(int64(k2))
+ e.mapElemValue()
+ e.e.EncodeFloat64(v2)
}
}
- ee.WriteMapEnd()
+ e.mapEnd()
}
-
-func (e *Encoder) fastpathEncMapFloat64Uint64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapFloat64Uint64V(rv2i(rv).(map[float64]uint64), e)
+func (e *Encoder) fastpathEncMapIntBoolR(f *codecFnInfo, rv reflect.Value) {
+ fastpathTV.EncMapIntBoolV(rv2i(rv).(map[int]bool), e)
}
-func (_ fastpathT) EncMapFloat64Uint64V(v map[float64]uint64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+func (fastpathT) EncMapIntBoolV(v map[int]bool, e *Encoder) {
+ e.mapStart(len(v))
if e.h.Canonical {
- v2 := make([]float64, len(v))
+ v2 := make([]int64, len(v))
var i uint
for k := range v {
- v2[i] = float64(k)
+ v2[i] = int64(k)
i++
}
- sort.Sort(floatSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeFloat64(float64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[float64(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeFloat64(float64(k2))
- ee.EncodeUint(uint64(v[float64(k2)]))
- }
+ sort.Sort(int64Slice(v2))
+ for _, k2 := range v2 {
+ e.mapElemKey()
+ e.e.EncodeInt(int64(int(k2)))
+ e.mapElemValue()
+ e.e.EncodeBool(v[int(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeFloat64(k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeFloat64(k2)
- ee.EncodeUint(uint64(v2))
- }
+ for k2, v2 := range v {
+ e.mapElemKey()
+ e.e.EncodeInt(int64(k2))
+ e.mapElemValue()
+ e.e.EncodeBool(v2)
}
}
- ee.WriteMapEnd()
+ e.mapEnd()
}
-
-func (e *Encoder) fastpathEncMapFloat64UintptrR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapFloat64UintptrV(rv2i(rv).(map[float64]uintptr), e)
+func (e *Encoder) fastpathEncMapInt64IntfR(f *codecFnInfo, rv reflect.Value) {
+ fastpathTV.EncMapInt64IntfV(rv2i(rv).(map[int64]interface{}), e)
}
-func (_ fastpathT) EncMapFloat64UintptrV(v map[float64]uintptr, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+func (fastpathT) EncMapInt64IntfV(v map[int64]interface{}, e *Encoder) {
+ e.mapStart(len(v))
if e.h.Canonical {
- v2 := make([]float64, len(v))
+ v2 := make([]int64, len(v))
var i uint
for k := range v {
- v2[i] = float64(k)
+ v2[i] = k
i++
}
- sort.Sort(floatSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeFloat64(float64(k2))
- ee.WriteMapElemValue()
- e.encode(v[float64(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeFloat64(float64(k2))
- e.encode(v[float64(k2)])
- }
+ sort.Sort(int64Slice(v2))
+ for _, k2 := range v2 {
+ e.mapElemKey()
+ e.e.EncodeInt(k2)
+ e.mapElemValue()
+ e.encode(v[k2])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeFloat64(k2)
- ee.WriteMapElemValue()
- e.encode(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeFloat64(k2)
- e.encode(v2)
- }
+ for k2, v2 := range v {
+ e.mapElemKey()
+ e.e.EncodeInt(k2)
+ e.mapElemValue()
+ e.encode(v2)
}
}
- ee.WriteMapEnd()
+ e.mapEnd()
}
-
-func (e *Encoder) fastpathEncMapFloat64IntR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapFloat64IntV(rv2i(rv).(map[float64]int), e)
+func (e *Encoder) fastpathEncMapInt64StringR(f *codecFnInfo, rv reflect.Value) {
+ fastpathTV.EncMapInt64StringV(rv2i(rv).(map[int64]string), e)
}
-func (_ fastpathT) EncMapFloat64IntV(v map[float64]int, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+func (fastpathT) EncMapInt64StringV(v map[int64]string, e *Encoder) {
+ e.mapStart(len(v))
if e.h.Canonical {
- v2 := make([]float64, len(v))
+ v2 := make([]int64, len(v))
var i uint
for k := range v {
- v2[i] = float64(k)
+ v2[i] = k
i++
}
- sort.Sort(floatSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeFloat64(float64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[float64(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeFloat64(float64(k2))
- ee.EncodeInt(int64(v[float64(k2)]))
- }
+ sort.Sort(int64Slice(v2))
+ for _, k2 := range v2 {
+ e.mapElemKey()
+ e.e.EncodeInt(k2)
+ e.mapElemValue()
+ e.e.EncodeString(v[k2])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeFloat64(k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeFloat64(k2)
- ee.EncodeInt(int64(v2))
- }
+ for k2, v2 := range v {
+ e.mapElemKey()
+ e.e.EncodeInt(k2)
+ e.mapElemValue()
+ e.e.EncodeString(v2)
}
}
- ee.WriteMapEnd()
+ e.mapEnd()
}
-
-func (e *Encoder) fastpathEncMapFloat64Int8R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapFloat64Int8V(rv2i(rv).(map[float64]int8), e)
+func (e *Encoder) fastpathEncMapInt64BytesR(f *codecFnInfo, rv reflect.Value) {
+ fastpathTV.EncMapInt64BytesV(rv2i(rv).(map[int64][]byte), e)
}
-func (_ fastpathT) EncMapFloat64Int8V(v map[float64]int8, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+func (fastpathT) EncMapInt64BytesV(v map[int64][]byte, e *Encoder) {
+ e.mapStart(len(v))
if e.h.Canonical {
- v2 := make([]float64, len(v))
+ v2 := make([]int64, len(v))
var i uint
for k := range v {
- v2[i] = float64(k)
+ v2[i] = k
i++
}
- sort.Sort(floatSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeFloat64(float64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[float64(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeFloat64(float64(k2))
- ee.EncodeInt(int64(v[float64(k2)]))
- }
+ sort.Sort(int64Slice(v2))
+ for _, k2 := range v2 {
+ e.mapElemKey()
+ e.e.EncodeInt(k2)
+ e.mapElemValue()
+ e.e.EncodeStringBytesRaw(v[k2])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeFloat64(k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeFloat64(k2)
- ee.EncodeInt(int64(v2))
- }
+ for k2, v2 := range v {
+ e.mapElemKey()
+ e.e.EncodeInt(k2)
+ e.mapElemValue()
+ e.e.EncodeStringBytesRaw(v2)
}
}
- ee.WriteMapEnd()
+ e.mapEnd()
}
-
-func (e *Encoder) fastpathEncMapFloat64Int16R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapFloat64Int16V(rv2i(rv).(map[float64]int16), e)
+func (e *Encoder) fastpathEncMapInt64UintR(f *codecFnInfo, rv reflect.Value) {
+ fastpathTV.EncMapInt64UintV(rv2i(rv).(map[int64]uint), e)
}
-func (_ fastpathT) EncMapFloat64Int16V(v map[float64]int16, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+func (fastpathT) EncMapInt64UintV(v map[int64]uint, e *Encoder) {
+ e.mapStart(len(v))
if e.h.Canonical {
- v2 := make([]float64, len(v))
+ v2 := make([]int64, len(v))
var i uint
for k := range v {
- v2[i] = float64(k)
+ v2[i] = k
i++
}
- sort.Sort(floatSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeFloat64(float64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[float64(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeFloat64(float64(k2))
- ee.EncodeInt(int64(v[float64(k2)]))
- }
+ sort.Sort(int64Slice(v2))
+ for _, k2 := range v2 {
+ e.mapElemKey()
+ e.e.EncodeInt(k2)
+ e.mapElemValue()
+ e.e.EncodeUint(uint64(v[k2]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeFloat64(k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeFloat64(k2)
- ee.EncodeInt(int64(v2))
- }
+ for k2, v2 := range v {
+ e.mapElemKey()
+ e.e.EncodeInt(k2)
+ e.mapElemValue()
+ e.e.EncodeUint(uint64(v2))
}
}
- ee.WriteMapEnd()
+ e.mapEnd()
}
-
-func (e *Encoder) fastpathEncMapFloat64Int32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapFloat64Int32V(rv2i(rv).(map[float64]int32), e)
+func (e *Encoder) fastpathEncMapInt64Uint8R(f *codecFnInfo, rv reflect.Value) {
+ fastpathTV.EncMapInt64Uint8V(rv2i(rv).(map[int64]uint8), e)
}
-func (_ fastpathT) EncMapFloat64Int32V(v map[float64]int32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+func (fastpathT) EncMapInt64Uint8V(v map[int64]uint8, e *Encoder) {
+ e.mapStart(len(v))
if e.h.Canonical {
- v2 := make([]float64, len(v))
+ v2 := make([]int64, len(v))
var i uint
for k := range v {
- v2[i] = float64(k)
+ v2[i] = k
i++
}
- sort.Sort(floatSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeFloat64(float64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[float64(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeFloat64(float64(k2))
- ee.EncodeInt(int64(v[float64(k2)]))
- }
+ sort.Sort(int64Slice(v2))
+ for _, k2 := range v2 {
+ e.mapElemKey()
+ e.e.EncodeInt(k2)
+ e.mapElemValue()
+ e.e.EncodeUint(uint64(v[k2]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeFloat64(k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeFloat64(k2)
- ee.EncodeInt(int64(v2))
- }
+ for k2, v2 := range v {
+ e.mapElemKey()
+ e.e.EncodeInt(k2)
+ e.mapElemValue()
+ e.e.EncodeUint(uint64(v2))
}
}
- ee.WriteMapEnd()
+ e.mapEnd()
}
-
-func (e *Encoder) fastpathEncMapFloat64Int64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapFloat64Int64V(rv2i(rv).(map[float64]int64), e)
+func (e *Encoder) fastpathEncMapInt64Uint64R(f *codecFnInfo, rv reflect.Value) {
+ fastpathTV.EncMapInt64Uint64V(rv2i(rv).(map[int64]uint64), e)
}
-func (_ fastpathT) EncMapFloat64Int64V(v map[float64]int64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+func (fastpathT) EncMapInt64Uint64V(v map[int64]uint64, e *Encoder) {
+ e.mapStart(len(v))
if e.h.Canonical {
- v2 := make([]float64, len(v))
+ v2 := make([]int64, len(v))
var i uint
for k := range v {
- v2[i] = float64(k)
+ v2[i] = k
i++
}
- sort.Sort(floatSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeFloat64(float64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[float64(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeFloat64(float64(k2))
- ee.EncodeInt(int64(v[float64(k2)]))
- }
+ sort.Sort(int64Slice(v2))
+ for _, k2 := range v2 {
+ e.mapElemKey()
+ e.e.EncodeInt(k2)
+ e.mapElemValue()
+ e.e.EncodeUint(v[k2])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeFloat64(k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeFloat64(k2)
- ee.EncodeInt(int64(v2))
- }
+ for k2, v2 := range v {
+ e.mapElemKey()
+ e.e.EncodeInt(k2)
+ e.mapElemValue()
+ e.e.EncodeUint(v2)
}
}
- ee.WriteMapEnd()
+ e.mapEnd()
}
-
-func (e *Encoder) fastpathEncMapFloat64Float32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapFloat64Float32V(rv2i(rv).(map[float64]float32), e)
+func (e *Encoder) fastpathEncMapInt64IntR(f *codecFnInfo, rv reflect.Value) {
+ fastpathTV.EncMapInt64IntV(rv2i(rv).(map[int64]int), e)
}
-func (_ fastpathT) EncMapFloat64Float32V(v map[float64]float32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+func (fastpathT) EncMapInt64IntV(v map[int64]int, e *Encoder) {
+ e.mapStart(len(v))
if e.h.Canonical {
- v2 := make([]float64, len(v))
+ v2 := make([]int64, len(v))
var i uint
for k := range v {
- v2[i] = float64(k)
+ v2[i] = k
i++
}
- sort.Sort(floatSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeFloat64(float64(k2))
- ee.WriteMapElemValue()
- ee.EncodeFloat32(v[float64(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeFloat64(float64(k2))
- ee.EncodeFloat32(v[float64(k2)])
- }
+ sort.Sort(int64Slice(v2))
+ for _, k2 := range v2 {
+ e.mapElemKey()
+ e.e.EncodeInt(k2)
+ e.mapElemValue()
+ e.e.EncodeInt(int64(v[k2]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeFloat64(k2)
- ee.WriteMapElemValue()
- ee.EncodeFloat32(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeFloat64(k2)
- ee.EncodeFloat32(v2)
- }
+ for k2, v2 := range v {
+ e.mapElemKey()
+ e.e.EncodeInt(k2)
+ e.mapElemValue()
+ e.e.EncodeInt(int64(v2))
}
}
- ee.WriteMapEnd()
+ e.mapEnd()
}
-
-func (e *Encoder) fastpathEncMapFloat64Float64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapFloat64Float64V(rv2i(rv).(map[float64]float64), e)
+func (e *Encoder) fastpathEncMapInt64Int64R(f *codecFnInfo, rv reflect.Value) {
+ fastpathTV.EncMapInt64Int64V(rv2i(rv).(map[int64]int64), e)
}
-func (_ fastpathT) EncMapFloat64Float64V(v map[float64]float64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+func (fastpathT) EncMapInt64Int64V(v map[int64]int64, e *Encoder) {
+ e.mapStart(len(v))
if e.h.Canonical {
- v2 := make([]float64, len(v))
+ v2 := make([]int64, len(v))
var i uint
for k := range v {
- v2[i] = float64(k)
+ v2[i] = k
i++
}
- sort.Sort(floatSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeFloat64(float64(k2))
- ee.WriteMapElemValue()
- ee.EncodeFloat64(v[float64(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeFloat64(float64(k2))
- ee.EncodeFloat64(v[float64(k2)])
- }
+ sort.Sort(int64Slice(v2))
+ for _, k2 := range v2 {
+ e.mapElemKey()
+ e.e.EncodeInt(k2)
+ e.mapElemValue()
+ e.e.EncodeInt(v[k2])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeFloat64(k2)
- ee.WriteMapElemValue()
- ee.EncodeFloat64(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeFloat64(k2)
- ee.EncodeFloat64(v2)
- }
+ for k2, v2 := range v {
+ e.mapElemKey()
+ e.e.EncodeInt(k2)
+ e.mapElemValue()
+ e.e.EncodeInt(v2)
}
}
- ee.WriteMapEnd()
+ e.mapEnd()
}
-
-func (e *Encoder) fastpathEncMapFloat64BoolR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapFloat64BoolV(rv2i(rv).(map[float64]bool), e)
+func (e *Encoder) fastpathEncMapInt64Float32R(f *codecFnInfo, rv reflect.Value) {
+ fastpathTV.EncMapInt64Float32V(rv2i(rv).(map[int64]float32), e)
}
-func (_ fastpathT) EncMapFloat64BoolV(v map[float64]bool, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+func (fastpathT) EncMapInt64Float32V(v map[int64]float32, e *Encoder) {
+ e.mapStart(len(v))
if e.h.Canonical {
- v2 := make([]float64, len(v))
+ v2 := make([]int64, len(v))
var i uint
for k := range v {
- v2[i] = float64(k)
+ v2[i] = k
i++
}
- sort.Sort(floatSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeFloat64(float64(k2))
- ee.WriteMapElemValue()
- ee.EncodeBool(v[float64(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeFloat64(float64(k2))
- ee.EncodeBool(v[float64(k2)])
- }
+ sort.Sort(int64Slice(v2))
+ for _, k2 := range v2 {
+ e.mapElemKey()
+ e.e.EncodeInt(k2)
+ e.mapElemValue()
+ e.e.EncodeFloat32(v[k2])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeFloat64(k2)
- ee.WriteMapElemValue()
- ee.EncodeBool(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeFloat64(k2)
- ee.EncodeBool(v2)
- }
+ for k2, v2 := range v {
+ e.mapElemKey()
+ e.e.EncodeInt(k2)
+ e.mapElemValue()
+ e.e.EncodeFloat32(v2)
}
}
- ee.WriteMapEnd()
+ e.mapEnd()
}
-
-func (e *Encoder) fastpathEncMapUintIntfR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUintIntfV(rv2i(rv).(map[uint]interface{}), e)
+func (e *Encoder) fastpathEncMapInt64Float64R(f *codecFnInfo, rv reflect.Value) {
+ fastpathTV.EncMapInt64Float64V(rv2i(rv).(map[int64]float64), e)
}
-func (_ fastpathT) EncMapUintIntfV(v map[uint]interface{}, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+func (fastpathT) EncMapInt64Float64V(v map[int64]float64, e *Encoder) {
+ e.mapStart(len(v))
if e.h.Canonical {
- v2 := make([]uint64, len(v))
+ v2 := make([]int64, len(v))
var i uint
for k := range v {
- v2[i] = uint64(k)
+ v2[i] = k
i++
}
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint(k2)))
- ee.WriteMapElemValue()
- e.encode(v[uint(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint(k2)))
- e.encode(v[uint(k2)])
- }
+ sort.Sort(int64Slice(v2))
+ for _, k2 := range v2 {
+ e.mapElemKey()
+ e.e.EncodeInt(k2)
+ e.mapElemValue()
+ e.e.EncodeFloat64(v[k2])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- e.encode(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- e.encode(v2)
- }
+ for k2, v2 := range v {
+ e.mapElemKey()
+ e.e.EncodeInt(k2)
+ e.mapElemValue()
+ e.e.EncodeFloat64(v2)
}
}
- ee.WriteMapEnd()
+ e.mapEnd()
}
-
-func (e *Encoder) fastpathEncMapUintStringR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUintStringV(rv2i(rv).(map[uint]string), e)
+func (e *Encoder) fastpathEncMapInt64BoolR(f *codecFnInfo, rv reflect.Value) {
+ fastpathTV.EncMapInt64BoolV(rv2i(rv).(map[int64]bool), e)
}
-func (_ fastpathT) EncMapUintStringV(v map[uint]string, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+func (fastpathT) EncMapInt64BoolV(v map[int64]bool, e *Encoder) {
+ e.mapStart(len(v))
if e.h.Canonical {
- v2 := make([]uint64, len(v))
+ v2 := make([]int64, len(v))
var i uint
for k := range v {
- v2[i] = uint64(k)
+ v2[i] = k
i++
}
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint(k2)))
- ee.WriteMapElemValue()
- ee.EncodeStringEnc(cUTF8, v[uint(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint(k2)))
- ee.EncodeStringEnc(cUTF8, v[uint(k2)])
- }
+ sort.Sort(int64Slice(v2))
+ for _, k2 := range v2 {
+ e.mapElemKey()
+ e.e.EncodeInt(k2)
+ e.mapElemValue()
+ e.e.EncodeBool(v[k2])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeStringEnc(cUTF8, v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeStringEnc(cUTF8, v2)
- }
+ for k2, v2 := range v {
+ e.mapElemKey()
+ e.e.EncodeInt(k2)
+ e.mapElemValue()
+ e.e.EncodeBool(v2)
}
}
- ee.WriteMapEnd()
+ e.mapEnd()
}
-func (e *Encoder) fastpathEncMapUintUintR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUintUintV(rv2i(rv).(map[uint]uint), e)
-}
-func (_ fastpathT) EncMapUintUintV(v map[uint]uint, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
+// -- decode
+
+// -- -- fast path type switch
+func fastpathDecodeTypeSwitch(iv interface{}, d *Decoder) bool {
+ var changed bool
+ var containerLen int
+ switch v := iv.(type) {
+ case []interface{}:
+ fastpathTV.DecSliceIntfN(v, d)
+ case *[]interface{}:
+ var v2 []interface{}
+ if v2, changed = fastpathTV.DecSliceIntfY(*v, d); changed {
+ *v = v2
}
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[uint(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint(k2)))
- ee.EncodeUint(uint64(v[uint(k2)]))
- }
+ case []string:
+ fastpathTV.DecSliceStringN(v, d)
+ case *[]string:
+ var v2 []string
+ if v2, changed = fastpathTV.DecSliceStringY(*v, d); changed {
+ *v = v2
}
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
- }
+ case [][]byte:
+ fastpathTV.DecSliceBytesN(v, d)
+ case *[][]byte:
+ var v2 [][]byte
+ if v2, changed = fastpathTV.DecSliceBytesY(*v, d); changed {
+ *v = v2
}
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUintUint8R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUintUint8V(rv2i(rv).(map[uint]uint8), e)
-}
-func (_ fastpathT) EncMapUintUint8V(v map[uint]uint8, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
+ case []float32:
+ fastpathTV.DecSliceFloat32N(v, d)
+ case *[]float32:
+ var v2 []float32
+ if v2, changed = fastpathTV.DecSliceFloat32Y(*v, d); changed {
+ *v = v2
}
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[uint(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint(k2)))
- ee.EncodeUint(uint64(v[uint(k2)]))
- }
+ case []float64:
+ fastpathTV.DecSliceFloat64N(v, d)
+ case *[]float64:
+ var v2 []float64
+ if v2, changed = fastpathTV.DecSliceFloat64Y(*v, d); changed {
+ *v = v2
}
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
+ case []uint:
+ fastpathTV.DecSliceUintN(v, d)
+ case *[]uint:
+ var v2 []uint
+ if v2, changed = fastpathTV.DecSliceUintY(*v, d); changed {
+ *v = v2
+ }
+ case []uint16:
+ fastpathTV.DecSliceUint16N(v, d)
+ case *[]uint16:
+ var v2 []uint16
+ if v2, changed = fastpathTV.DecSliceUint16Y(*v, d); changed {
+ *v = v2
+ }
+ case []uint32:
+ fastpathTV.DecSliceUint32N(v, d)
+ case *[]uint32:
+ var v2 []uint32
+ if v2, changed = fastpathTV.DecSliceUint32Y(*v, d); changed {
+ *v = v2
+ }
+ case []uint64:
+ fastpathTV.DecSliceUint64N(v, d)
+ case *[]uint64:
+ var v2 []uint64
+ if v2, changed = fastpathTV.DecSliceUint64Y(*v, d); changed {
+ *v = v2
+ }
+ case []int:
+ fastpathTV.DecSliceIntN(v, d)
+ case *[]int:
+ var v2 []int
+ if v2, changed = fastpathTV.DecSliceIntY(*v, d); changed {
+ *v = v2
+ }
+ case []int8:
+ fastpathTV.DecSliceInt8N(v, d)
+ case *[]int8:
+ var v2 []int8
+ if v2, changed = fastpathTV.DecSliceInt8Y(*v, d); changed {
+ *v = v2
+ }
+ case []int16:
+ fastpathTV.DecSliceInt16N(v, d)
+ case *[]int16:
+ var v2 []int16
+ if v2, changed = fastpathTV.DecSliceInt16Y(*v, d); changed {
+ *v = v2
+ }
+ case []int32:
+ fastpathTV.DecSliceInt32N(v, d)
+ case *[]int32:
+ var v2 []int32
+ if v2, changed = fastpathTV.DecSliceInt32Y(*v, d); changed {
+ *v = v2
+ }
+ case []int64:
+ fastpathTV.DecSliceInt64N(v, d)
+ case *[]int64:
+ var v2 []int64
+ if v2, changed = fastpathTV.DecSliceInt64Y(*v, d); changed {
+ *v = v2
+ }
+ case []bool:
+ fastpathTV.DecSliceBoolN(v, d)
+ case *[]bool:
+ var v2 []bool
+ if v2, changed = fastpathTV.DecSliceBoolY(*v, d); changed {
+ *v = v2
+ }
+ case map[string]interface{}:
+ containerLen = d.mapStart()
+ if containerLen != decContainerLenNil {
+ if containerLen != 0 {
+ fastpathTV.DecMapStringIntfL(v, containerLen, d)
}
+ d.mapEnd()
}
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUintUint16R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUintUint16V(rv2i(rv).(map[uint]uint16), e)
-}
-func (_ fastpathT) EncMapUintUint16V(v map[uint]uint16, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
+ case *map[string]interface{}:
+ fastpathTV.DecMapStringIntfX(v, d)
+ case map[string]string:
+ containerLen = d.mapStart()
+ if containerLen != decContainerLenNil {
+ if containerLen != 0 {
+ fastpathTV.DecMapStringStringL(v, containerLen, d)
+ }
+ d.mapEnd()
}
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[uint(k2)]))
+ case *map[string]string:
+ fastpathTV.DecMapStringStringX(v, d)
+ case map[string][]byte:
+ containerLen = d.mapStart()
+ if containerLen != decContainerLenNil {
+ if containerLen != 0 {
+ fastpathTV.DecMapStringBytesL(v, containerLen, d)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint(k2)))
- ee.EncodeUint(uint64(v[uint(k2)]))
+ d.mapEnd()
+ }
+ case *map[string][]byte:
+ fastpathTV.DecMapStringBytesX(v, d)
+ case map[string]uint:
+ containerLen = d.mapStart()
+ if containerLen != decContainerLenNil {
+ if containerLen != 0 {
+ fastpathTV.DecMapStringUintL(v, containerLen, d)
}
+ d.mapEnd()
}
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
+ case *map[string]uint:
+ fastpathTV.DecMapStringUintX(v, d)
+ case map[string]uint8:
+ containerLen = d.mapStart()
+ if containerLen != decContainerLenNil {
+ if containerLen != 0 {
+ fastpathTV.DecMapStringUint8L(v, containerLen, d)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
+ d.mapEnd()
+ }
+ case *map[string]uint8:
+ fastpathTV.DecMapStringUint8X(v, d)
+ case map[string]uint64:
+ containerLen = d.mapStart()
+ if containerLen != decContainerLenNil {
+ if containerLen != 0 {
+ fastpathTV.DecMapStringUint64L(v, containerLen, d)
}
+ d.mapEnd()
}
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUintUint32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUintUint32V(rv2i(rv).(map[uint]uint32), e)
-}
-func (_ fastpathT) EncMapUintUint32V(v map[uint]uint32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
+ case *map[string]uint64:
+ fastpathTV.DecMapStringUint64X(v, d)
+ case map[string]int:
+ containerLen = d.mapStart()
+ if containerLen != decContainerLenNil {
+ if containerLen != 0 {
+ fastpathTV.DecMapStringIntL(v, containerLen, d)
+ }
+ d.mapEnd()
}
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[uint(k2)]))
+ case *map[string]int:
+ fastpathTV.DecMapStringIntX(v, d)
+ case map[string]int64:
+ containerLen = d.mapStart()
+ if containerLen != decContainerLenNil {
+ if containerLen != 0 {
+ fastpathTV.DecMapStringInt64L(v, containerLen, d)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint(k2)))
- ee.EncodeUint(uint64(v[uint(k2)]))
+ d.mapEnd()
+ }
+ case *map[string]int64:
+ fastpathTV.DecMapStringInt64X(v, d)
+ case map[string]float32:
+ containerLen = d.mapStart()
+ if containerLen != decContainerLenNil {
+ if containerLen != 0 {
+ fastpathTV.DecMapStringFloat32L(v, containerLen, d)
}
+ d.mapEnd()
}
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
+ case *map[string]float32:
+ fastpathTV.DecMapStringFloat32X(v, d)
+ case map[string]float64:
+ containerLen = d.mapStart()
+ if containerLen != decContainerLenNil {
+ if containerLen != 0 {
+ fastpathTV.DecMapStringFloat64L(v, containerLen, d)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
+ d.mapEnd()
+ }
+ case *map[string]float64:
+ fastpathTV.DecMapStringFloat64X(v, d)
+ case map[string]bool:
+ containerLen = d.mapStart()
+ if containerLen != decContainerLenNil {
+ if containerLen != 0 {
+ fastpathTV.DecMapStringBoolL(v, containerLen, d)
}
+ d.mapEnd()
}
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUintUint64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUintUint64V(rv2i(rv).(map[uint]uint64), e)
-}
-func (_ fastpathT) EncMapUintUint64V(v map[uint]uint64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
+ case *map[string]bool:
+ fastpathTV.DecMapStringBoolX(v, d)
+ case map[uint]interface{}:
+ containerLen = d.mapStart()
+ if containerLen != decContainerLenNil {
+ if containerLen != 0 {
+ fastpathTV.DecMapUintIntfL(v, containerLen, d)
+ }
+ d.mapEnd()
}
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[uint(k2)]))
+ case *map[uint]interface{}:
+ fastpathTV.DecMapUintIntfX(v, d)
+ case map[uint]string:
+ containerLen = d.mapStart()
+ if containerLen != decContainerLenNil {
+ if containerLen != 0 {
+ fastpathTV.DecMapUintStringL(v, containerLen, d)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint(k2)))
- ee.EncodeUint(uint64(v[uint(k2)]))
+ d.mapEnd()
+ }
+ case *map[uint]string:
+ fastpathTV.DecMapUintStringX(v, d)
+ case map[uint][]byte:
+ containerLen = d.mapStart()
+ if containerLen != decContainerLenNil {
+ if containerLen != 0 {
+ fastpathTV.DecMapUintBytesL(v, containerLen, d)
}
+ d.mapEnd()
}
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
+ case *map[uint][]byte:
+ fastpathTV.DecMapUintBytesX(v, d)
+ case map[uint]uint:
+ containerLen = d.mapStart()
+ if containerLen != decContainerLenNil {
+ if containerLen != 0 {
+ fastpathTV.DecMapUintUintL(v, containerLen, d)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
+ d.mapEnd()
+ }
+ case *map[uint]uint:
+ fastpathTV.DecMapUintUintX(v, d)
+ case map[uint]uint8:
+ containerLen = d.mapStart()
+ if containerLen != decContainerLenNil {
+ if containerLen != 0 {
+ fastpathTV.DecMapUintUint8L(v, containerLen, d)
}
+ d.mapEnd()
}
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUintUintptrR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUintUintptrV(rv2i(rv).(map[uint]uintptr), e)
-}
-func (_ fastpathT) EncMapUintUintptrV(v map[uint]uintptr, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
+ case *map[uint]uint8:
+ fastpathTV.DecMapUintUint8X(v, d)
+ case map[uint]uint64:
+ containerLen = d.mapStart()
+ if containerLen != decContainerLenNil {
+ if containerLen != 0 {
+ fastpathTV.DecMapUintUint64L(v, containerLen, d)
+ }
+ d.mapEnd()
}
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint(k2)))
- ee.WriteMapElemValue()
- e.encode(v[uint(k2)])
+ case *map[uint]uint64:
+ fastpathTV.DecMapUintUint64X(v, d)
+ case map[uint]int:
+ containerLen = d.mapStart()
+ if containerLen != decContainerLenNil {
+ if containerLen != 0 {
+ fastpathTV.DecMapUintIntL(v, containerLen, d)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint(k2)))
- e.encode(v[uint(k2)])
+ d.mapEnd()
+ }
+ case *map[uint]int:
+ fastpathTV.DecMapUintIntX(v, d)
+ case map[uint]int64:
+ containerLen = d.mapStart()
+ if containerLen != decContainerLenNil {
+ if containerLen != 0 {
+ fastpathTV.DecMapUintInt64L(v, containerLen, d)
}
+ d.mapEnd()
}
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- e.encode(v2)
+ case *map[uint]int64:
+ fastpathTV.DecMapUintInt64X(v, d)
+ case map[uint]float32:
+ containerLen = d.mapStart()
+ if containerLen != decContainerLenNil {
+ if containerLen != 0 {
+ fastpathTV.DecMapUintFloat32L(v, containerLen, d)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- e.encode(v2)
+ d.mapEnd()
+ }
+ case *map[uint]float32:
+ fastpathTV.DecMapUintFloat32X(v, d)
+ case map[uint]float64:
+ containerLen = d.mapStart()
+ if containerLen != decContainerLenNil {
+ if containerLen != 0 {
+ fastpathTV.DecMapUintFloat64L(v, containerLen, d)
}
+ d.mapEnd()
}
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUintIntR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUintIntV(rv2i(rv).(map[uint]int), e)
-}
-func (_ fastpathT) EncMapUintIntV(v map[uint]int, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
+ case *map[uint]float64:
+ fastpathTV.DecMapUintFloat64X(v, d)
+ case map[uint]bool:
+ containerLen = d.mapStart()
+ if containerLen != decContainerLenNil {
+ if containerLen != 0 {
+ fastpathTV.DecMapUintBoolL(v, containerLen, d)
+ }
+ d.mapEnd()
}
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[uint(k2)]))
+ case *map[uint]bool:
+ fastpathTV.DecMapUintBoolX(v, d)
+ case map[uint8]interface{}:
+ containerLen = d.mapStart()
+ if containerLen != decContainerLenNil {
+ if containerLen != 0 {
+ fastpathTV.DecMapUint8IntfL(v, containerLen, d)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint(k2)))
- ee.EncodeInt(int64(v[uint(k2)]))
+ d.mapEnd()
+ }
+ case *map[uint8]interface{}:
+ fastpathTV.DecMapUint8IntfX(v, d)
+ case map[uint8]string:
+ containerLen = d.mapStart()
+ if containerLen != decContainerLenNil {
+ if containerLen != 0 {
+ fastpathTV.DecMapUint8StringL(v, containerLen, d)
}
+ d.mapEnd()
}
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
+ case *map[uint8]string:
+ fastpathTV.DecMapUint8StringX(v, d)
+ case map[uint8][]byte:
+ containerLen = d.mapStart()
+ if containerLen != decContainerLenNil {
+ if containerLen != 0 {
+ fastpathTV.DecMapUint8BytesL(v, containerLen, d)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
+ d.mapEnd()
+ }
+ case *map[uint8][]byte:
+ fastpathTV.DecMapUint8BytesX(v, d)
+ case map[uint8]uint:
+ containerLen = d.mapStart()
+ if containerLen != decContainerLenNil {
+ if containerLen != 0 {
+ fastpathTV.DecMapUint8UintL(v, containerLen, d)
}
+ d.mapEnd()
}
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUintInt8R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUintInt8V(rv2i(rv).(map[uint]int8), e)
-}
-func (_ fastpathT) EncMapUintInt8V(v map[uint]int8, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
+ case *map[uint8]uint:
+ fastpathTV.DecMapUint8UintX(v, d)
+ case map[uint8]uint8:
+ containerLen = d.mapStart()
+ if containerLen != decContainerLenNil {
+ if containerLen != 0 {
+ fastpathTV.DecMapUint8Uint8L(v, containerLen, d)
+ }
+ d.mapEnd()
}
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[uint(k2)]))
+ case *map[uint8]uint8:
+ fastpathTV.DecMapUint8Uint8X(v, d)
+ case map[uint8]uint64:
+ containerLen = d.mapStart()
+ if containerLen != decContainerLenNil {
+ if containerLen != 0 {
+ fastpathTV.DecMapUint8Uint64L(v, containerLen, d)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint(k2)))
- ee.EncodeInt(int64(v[uint(k2)]))
+ d.mapEnd()
+ }
+ case *map[uint8]uint64:
+ fastpathTV.DecMapUint8Uint64X(v, d)
+ case map[uint8]int:
+ containerLen = d.mapStart()
+ if containerLen != decContainerLenNil {
+ if containerLen != 0 {
+ fastpathTV.DecMapUint8IntL(v, containerLen, d)
}
+ d.mapEnd()
}
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
+ case *map[uint8]int:
+ fastpathTV.DecMapUint8IntX(v, d)
+ case map[uint8]int64:
+ containerLen = d.mapStart()
+ if containerLen != decContainerLenNil {
+ if containerLen != 0 {
+ fastpathTV.DecMapUint8Int64L(v, containerLen, d)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
+ d.mapEnd()
+ }
+ case *map[uint8]int64:
+ fastpathTV.DecMapUint8Int64X(v, d)
+ case map[uint8]float32:
+ containerLen = d.mapStart()
+ if containerLen != decContainerLenNil {
+ if containerLen != 0 {
+ fastpathTV.DecMapUint8Float32L(v, containerLen, d)
}
+ d.mapEnd()
}
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUintInt16R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUintInt16V(rv2i(rv).(map[uint]int16), e)
-}
-func (_ fastpathT) EncMapUintInt16V(v map[uint]int16, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
+ case *map[uint8]float32:
+ fastpathTV.DecMapUint8Float32X(v, d)
+ case map[uint8]float64:
+ containerLen = d.mapStart()
+ if containerLen != decContainerLenNil {
+ if containerLen != 0 {
+ fastpathTV.DecMapUint8Float64L(v, containerLen, d)
+ }
+ d.mapEnd()
}
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[uint(k2)]))
+ case *map[uint8]float64:
+ fastpathTV.DecMapUint8Float64X(v, d)
+ case map[uint8]bool:
+ containerLen = d.mapStart()
+ if containerLen != decContainerLenNil {
+ if containerLen != 0 {
+ fastpathTV.DecMapUint8BoolL(v, containerLen, d)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint(k2)))
- ee.EncodeInt(int64(v[uint(k2)]))
+ d.mapEnd()
+ }
+ case *map[uint8]bool:
+ fastpathTV.DecMapUint8BoolX(v, d)
+ case map[uint64]interface{}:
+ containerLen = d.mapStart()
+ if containerLen != decContainerLenNil {
+ if containerLen != 0 {
+ fastpathTV.DecMapUint64IntfL(v, containerLen, d)
}
+ d.mapEnd()
}
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
+ case *map[uint64]interface{}:
+ fastpathTV.DecMapUint64IntfX(v, d)
+ case map[uint64]string:
+ containerLen = d.mapStart()
+ if containerLen != decContainerLenNil {
+ if containerLen != 0 {
+ fastpathTV.DecMapUint64StringL(v, containerLen, d)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
+ d.mapEnd()
+ }
+ case *map[uint64]string:
+ fastpathTV.DecMapUint64StringX(v, d)
+ case map[uint64][]byte:
+ containerLen = d.mapStart()
+ if containerLen != decContainerLenNil {
+ if containerLen != 0 {
+ fastpathTV.DecMapUint64BytesL(v, containerLen, d)
}
+ d.mapEnd()
}
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUintInt32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUintInt32V(rv2i(rv).(map[uint]int32), e)
-}
-func (_ fastpathT) EncMapUintInt32V(v map[uint]int32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
+ case *map[uint64][]byte:
+ fastpathTV.DecMapUint64BytesX(v, d)
+ case map[uint64]uint:
+ containerLen = d.mapStart()
+ if containerLen != decContainerLenNil {
+ if containerLen != 0 {
+ fastpathTV.DecMapUint64UintL(v, containerLen, d)
+ }
+ d.mapEnd()
}
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[uint(k2)]))
+ case *map[uint64]uint:
+ fastpathTV.DecMapUint64UintX(v, d)
+ case map[uint64]uint8:
+ containerLen = d.mapStart()
+ if containerLen != decContainerLenNil {
+ if containerLen != 0 {
+ fastpathTV.DecMapUint64Uint8L(v, containerLen, d)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint(k2)))
- ee.EncodeInt(int64(v[uint(k2)]))
+ d.mapEnd()
+ }
+ case *map[uint64]uint8:
+ fastpathTV.DecMapUint64Uint8X(v, d)
+ case map[uint64]uint64:
+ containerLen = d.mapStart()
+ if containerLen != decContainerLenNil {
+ if containerLen != 0 {
+ fastpathTV.DecMapUint64Uint64L(v, containerLen, d)
}
+ d.mapEnd()
}
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
+ case *map[uint64]uint64:
+ fastpathTV.DecMapUint64Uint64X(v, d)
+ case map[uint64]int:
+ containerLen = d.mapStart()
+ if containerLen != decContainerLenNil {
+ if containerLen != 0 {
+ fastpathTV.DecMapUint64IntL(v, containerLen, d)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
+ d.mapEnd()
+ }
+ case *map[uint64]int:
+ fastpathTV.DecMapUint64IntX(v, d)
+ case map[uint64]int64:
+ containerLen = d.mapStart()
+ if containerLen != decContainerLenNil {
+ if containerLen != 0 {
+ fastpathTV.DecMapUint64Int64L(v, containerLen, d)
}
+ d.mapEnd()
}
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUintInt64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUintInt64V(rv2i(rv).(map[uint]int64), e)
-}
-func (_ fastpathT) EncMapUintInt64V(v map[uint]int64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
+ case *map[uint64]int64:
+ fastpathTV.DecMapUint64Int64X(v, d)
+ case map[uint64]float32:
+ containerLen = d.mapStart()
+ if containerLen != decContainerLenNil {
+ if containerLen != 0 {
+ fastpathTV.DecMapUint64Float32L(v, containerLen, d)
+ }
+ d.mapEnd()
}
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[uint(k2)]))
+ case *map[uint64]float32:
+ fastpathTV.DecMapUint64Float32X(v, d)
+ case map[uint64]float64:
+ containerLen = d.mapStart()
+ if containerLen != decContainerLenNil {
+ if containerLen != 0 {
+ fastpathTV.DecMapUint64Float64L(v, containerLen, d)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint(k2)))
- ee.EncodeInt(int64(v[uint(k2)]))
+ d.mapEnd()
+ }
+ case *map[uint64]float64:
+ fastpathTV.DecMapUint64Float64X(v, d)
+ case map[uint64]bool:
+ containerLen = d.mapStart()
+ if containerLen != decContainerLenNil {
+ if containerLen != 0 {
+ fastpathTV.DecMapUint64BoolL(v, containerLen, d)
}
+ d.mapEnd()
}
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
+ case *map[uint64]bool:
+ fastpathTV.DecMapUint64BoolX(v, d)
+ case map[int]interface{}:
+ containerLen = d.mapStart()
+ if containerLen != decContainerLenNil {
+ if containerLen != 0 {
+ fastpathTV.DecMapIntIntfL(v, containerLen, d)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
+ d.mapEnd()
+ }
+ case *map[int]interface{}:
+ fastpathTV.DecMapIntIntfX(v, d)
+ case map[int]string:
+ containerLen = d.mapStart()
+ if containerLen != decContainerLenNil {
+ if containerLen != 0 {
+ fastpathTV.DecMapIntStringL(v, containerLen, d)
}
+ d.mapEnd()
}
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUintFloat32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUintFloat32V(rv2i(rv).(map[uint]float32), e)
-}
-func (_ fastpathT) EncMapUintFloat32V(v map[uint]float32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
+ case *map[int]string:
+ fastpathTV.DecMapIntStringX(v, d)
+ case map[int][]byte:
+ containerLen = d.mapStart()
+ if containerLen != decContainerLenNil {
+ if containerLen != 0 {
+ fastpathTV.DecMapIntBytesL(v, containerLen, d)
+ }
+ d.mapEnd()
}
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint(k2)))
- ee.WriteMapElemValue()
- ee.EncodeFloat32(v[uint(k2)])
+ case *map[int][]byte:
+ fastpathTV.DecMapIntBytesX(v, d)
+ case map[int]uint:
+ containerLen = d.mapStart()
+ if containerLen != decContainerLenNil {
+ if containerLen != 0 {
+ fastpathTV.DecMapIntUintL(v, containerLen, d)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint(k2)))
- ee.EncodeFloat32(v[uint(k2)])
+ d.mapEnd()
+ }
+ case *map[int]uint:
+ fastpathTV.DecMapIntUintX(v, d)
+ case map[int]uint8:
+ containerLen = d.mapStart()
+ if containerLen != decContainerLenNil {
+ if containerLen != 0 {
+ fastpathTV.DecMapIntUint8L(v, containerLen, d)
}
+ d.mapEnd()
}
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeFloat32(v2)
+ case *map[int]uint8:
+ fastpathTV.DecMapIntUint8X(v, d)
+ case map[int]uint64:
+ containerLen = d.mapStart()
+ if containerLen != decContainerLenNil {
+ if containerLen != 0 {
+ fastpathTV.DecMapIntUint64L(v, containerLen, d)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeFloat32(v2)
+ d.mapEnd()
+ }
+ case *map[int]uint64:
+ fastpathTV.DecMapIntUint64X(v, d)
+ case map[int]int:
+ containerLen = d.mapStart()
+ if containerLen != decContainerLenNil {
+ if containerLen != 0 {
+ fastpathTV.DecMapIntIntL(v, containerLen, d)
}
+ d.mapEnd()
}
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUintFloat64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUintFloat64V(rv2i(rv).(map[uint]float64), e)
-}
-func (_ fastpathT) EncMapUintFloat64V(v map[uint]float64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
+ case *map[int]int:
+ fastpathTV.DecMapIntIntX(v, d)
+ case map[int]int64:
+ containerLen = d.mapStart()
+ if containerLen != decContainerLenNil {
+ if containerLen != 0 {
+ fastpathTV.DecMapIntInt64L(v, containerLen, d)
+ }
+ d.mapEnd()
}
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint(k2)))
- ee.WriteMapElemValue()
- ee.EncodeFloat64(v[uint(k2)])
+ case *map[int]int64:
+ fastpathTV.DecMapIntInt64X(v, d)
+ case map[int]float32:
+ containerLen = d.mapStart()
+ if containerLen != decContainerLenNil {
+ if containerLen != 0 {
+ fastpathTV.DecMapIntFloat32L(v, containerLen, d)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint(k2)))
- ee.EncodeFloat64(v[uint(k2)])
+ d.mapEnd()
+ }
+ case *map[int]float32:
+ fastpathTV.DecMapIntFloat32X(v, d)
+ case map[int]float64:
+ containerLen = d.mapStart()
+ if containerLen != decContainerLenNil {
+ if containerLen != 0 {
+ fastpathTV.DecMapIntFloat64L(v, containerLen, d)
}
+ d.mapEnd()
}
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeFloat64(v2)
+ case *map[int]float64:
+ fastpathTV.DecMapIntFloat64X(v, d)
+ case map[int]bool:
+ containerLen = d.mapStart()
+ if containerLen != decContainerLenNil {
+ if containerLen != 0 {
+ fastpathTV.DecMapIntBoolL(v, containerLen, d)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeFloat64(v2)
+ d.mapEnd()
+ }
+ case *map[int]bool:
+ fastpathTV.DecMapIntBoolX(v, d)
+ case map[int64]interface{}:
+ containerLen = d.mapStart()
+ if containerLen != decContainerLenNil {
+ if containerLen != 0 {
+ fastpathTV.DecMapInt64IntfL(v, containerLen, d)
}
+ d.mapEnd()
}
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUintBoolR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUintBoolV(rv2i(rv).(map[uint]bool), e)
-}
-func (_ fastpathT) EncMapUintBoolV(v map[uint]bool, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
+ case *map[int64]interface{}:
+ fastpathTV.DecMapInt64IntfX(v, d)
+ case map[int64]string:
+ containerLen = d.mapStart()
+ if containerLen != decContainerLenNil {
+ if containerLen != 0 {
+ fastpathTV.DecMapInt64StringL(v, containerLen, d)
+ }
+ d.mapEnd()
}
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint(k2)))
- ee.WriteMapElemValue()
- ee.EncodeBool(v[uint(k2)])
+ case *map[int64]string:
+ fastpathTV.DecMapInt64StringX(v, d)
+ case map[int64][]byte:
+ containerLen = d.mapStart()
+ if containerLen != decContainerLenNil {
+ if containerLen != 0 {
+ fastpathTV.DecMapInt64BytesL(v, containerLen, d)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint(k2)))
- ee.EncodeBool(v[uint(k2)])
+ d.mapEnd()
+ }
+ case *map[int64][]byte:
+ fastpathTV.DecMapInt64BytesX(v, d)
+ case map[int64]uint:
+ containerLen = d.mapStart()
+ if containerLen != decContainerLenNil {
+ if containerLen != 0 {
+ fastpathTV.DecMapInt64UintL(v, containerLen, d)
}
+ d.mapEnd()
}
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeBool(v2)
+ case *map[int64]uint:
+ fastpathTV.DecMapInt64UintX(v, d)
+ case map[int64]uint8:
+ containerLen = d.mapStart()
+ if containerLen != decContainerLenNil {
+ if containerLen != 0 {
+ fastpathTV.DecMapInt64Uint8L(v, containerLen, d)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeBool(v2)
+ d.mapEnd()
+ }
+ case *map[int64]uint8:
+ fastpathTV.DecMapInt64Uint8X(v, d)
+ case map[int64]uint64:
+ containerLen = d.mapStart()
+ if containerLen != decContainerLenNil {
+ if containerLen != 0 {
+ fastpathTV.DecMapInt64Uint64L(v, containerLen, d)
}
+ d.mapEnd()
}
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint8IntfR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint8IntfV(rv2i(rv).(map[uint8]interface{}), e)
-}
-func (_ fastpathT) EncMapUint8IntfV(v map[uint8]interface{}, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
+ case *map[int64]uint64:
+ fastpathTV.DecMapInt64Uint64X(v, d)
+ case map[int64]int:
+ containerLen = d.mapStart()
+ if containerLen != decContainerLenNil {
+ if containerLen != 0 {
+ fastpathTV.DecMapInt64IntL(v, containerLen, d)
+ }
+ d.mapEnd()
}
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint8(k2)))
- ee.WriteMapElemValue()
- e.encode(v[uint8(k2)])
+ case *map[int64]int:
+ fastpathTV.DecMapInt64IntX(v, d)
+ case map[int64]int64:
+ containerLen = d.mapStart()
+ if containerLen != decContainerLenNil {
+ if containerLen != 0 {
+ fastpathTV.DecMapInt64Int64L(v, containerLen, d)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint8(k2)))
- e.encode(v[uint8(k2)])
+ d.mapEnd()
+ }
+ case *map[int64]int64:
+ fastpathTV.DecMapInt64Int64X(v, d)
+ case map[int64]float32:
+ containerLen = d.mapStart()
+ if containerLen != decContainerLenNil {
+ if containerLen != 0 {
+ fastpathTV.DecMapInt64Float32L(v, containerLen, d)
}
+ d.mapEnd()
}
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- e.encode(v2)
+ case *map[int64]float32:
+ fastpathTV.DecMapInt64Float32X(v, d)
+ case map[int64]float64:
+ containerLen = d.mapStart()
+ if containerLen != decContainerLenNil {
+ if containerLen != 0 {
+ fastpathTV.DecMapInt64Float64L(v, containerLen, d)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- e.encode(v2)
+ d.mapEnd()
+ }
+ case *map[int64]float64:
+ fastpathTV.DecMapInt64Float64X(v, d)
+ case map[int64]bool:
+ containerLen = d.mapStart()
+ if containerLen != decContainerLenNil {
+ if containerLen != 0 {
+ fastpathTV.DecMapInt64BoolL(v, containerLen, d)
}
+ d.mapEnd()
}
+ case *map[int64]bool:
+ fastpathTV.DecMapInt64BoolX(v, d)
+ default:
+ _ = v // workaround https://github.com/golang/go/issues/12927 seen in go1.4
+ return false
}
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint8StringR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint8StringV(rv2i(rv).(map[uint8]string), e)
-}
-func (_ fastpathT) EncMapUint8StringV(v map[uint8]string, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint8(k2)))
- ee.WriteMapElemValue()
- ee.EncodeStringEnc(cUTF8, v[uint8(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint8(k2)))
- ee.EncodeStringEnc(cUTF8, v[uint8(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeStringEnc(cUTF8, v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeStringEnc(cUTF8, v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint8UintR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint8UintV(rv2i(rv).(map[uint8]uint), e)
-}
-func (_ fastpathT) EncMapUint8UintV(v map[uint8]uint, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint8(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[uint8(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint8(k2)))
- ee.EncodeUint(uint64(v[uint8(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint8Uint8R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint8Uint8V(rv2i(rv).(map[uint8]uint8), e)
-}
-func (_ fastpathT) EncMapUint8Uint8V(v map[uint8]uint8, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint8(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[uint8(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint8(k2)))
- ee.EncodeUint(uint64(v[uint8(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint8Uint16R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint8Uint16V(rv2i(rv).(map[uint8]uint16), e)
-}
-func (_ fastpathT) EncMapUint8Uint16V(v map[uint8]uint16, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint8(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[uint8(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint8(k2)))
- ee.EncodeUint(uint64(v[uint8(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint8Uint32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint8Uint32V(rv2i(rv).(map[uint8]uint32), e)
-}
-func (_ fastpathT) EncMapUint8Uint32V(v map[uint8]uint32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint8(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[uint8(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint8(k2)))
- ee.EncodeUint(uint64(v[uint8(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint8Uint64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint8Uint64V(rv2i(rv).(map[uint8]uint64), e)
-}
-func (_ fastpathT) EncMapUint8Uint64V(v map[uint8]uint64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint8(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[uint8(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint8(k2)))
- ee.EncodeUint(uint64(v[uint8(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint8UintptrR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint8UintptrV(rv2i(rv).(map[uint8]uintptr), e)
-}
-func (_ fastpathT) EncMapUint8UintptrV(v map[uint8]uintptr, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint8(k2)))
- ee.WriteMapElemValue()
- e.encode(v[uint8(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint8(k2)))
- e.encode(v[uint8(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- e.encode(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- e.encode(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint8IntR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint8IntV(rv2i(rv).(map[uint8]int), e)
-}
-func (_ fastpathT) EncMapUint8IntV(v map[uint8]int, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint8(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[uint8(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint8(k2)))
- ee.EncodeInt(int64(v[uint8(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint8Int8R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint8Int8V(rv2i(rv).(map[uint8]int8), e)
-}
-func (_ fastpathT) EncMapUint8Int8V(v map[uint8]int8, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint8(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[uint8(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint8(k2)))
- ee.EncodeInt(int64(v[uint8(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint8Int16R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint8Int16V(rv2i(rv).(map[uint8]int16), e)
-}
-func (_ fastpathT) EncMapUint8Int16V(v map[uint8]int16, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint8(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[uint8(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint8(k2)))
- ee.EncodeInt(int64(v[uint8(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint8Int32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint8Int32V(rv2i(rv).(map[uint8]int32), e)
-}
-func (_ fastpathT) EncMapUint8Int32V(v map[uint8]int32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint8(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[uint8(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint8(k2)))
- ee.EncodeInt(int64(v[uint8(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint8Int64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint8Int64V(rv2i(rv).(map[uint8]int64), e)
-}
-func (_ fastpathT) EncMapUint8Int64V(v map[uint8]int64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint8(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[uint8(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint8(k2)))
- ee.EncodeInt(int64(v[uint8(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint8Float32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint8Float32V(rv2i(rv).(map[uint8]float32), e)
-}
-func (_ fastpathT) EncMapUint8Float32V(v map[uint8]float32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint8(k2)))
- ee.WriteMapElemValue()
- ee.EncodeFloat32(v[uint8(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint8(k2)))
- ee.EncodeFloat32(v[uint8(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeFloat32(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeFloat32(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint8Float64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint8Float64V(rv2i(rv).(map[uint8]float64), e)
-}
-func (_ fastpathT) EncMapUint8Float64V(v map[uint8]float64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint8(k2)))
- ee.WriteMapElemValue()
- ee.EncodeFloat64(v[uint8(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint8(k2)))
- ee.EncodeFloat64(v[uint8(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeFloat64(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeFloat64(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint8BoolR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint8BoolV(rv2i(rv).(map[uint8]bool), e)
-}
-func (_ fastpathT) EncMapUint8BoolV(v map[uint8]bool, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint8(k2)))
- ee.WriteMapElemValue()
- ee.EncodeBool(v[uint8(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint8(k2)))
- ee.EncodeBool(v[uint8(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeBool(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeBool(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint16IntfR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint16IntfV(rv2i(rv).(map[uint16]interface{}), e)
-}
-func (_ fastpathT) EncMapUint16IntfV(v map[uint16]interface{}, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint16(k2)))
- ee.WriteMapElemValue()
- e.encode(v[uint16(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint16(k2)))
- e.encode(v[uint16(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- e.encode(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- e.encode(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint16StringR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint16StringV(rv2i(rv).(map[uint16]string), e)
-}
-func (_ fastpathT) EncMapUint16StringV(v map[uint16]string, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint16(k2)))
- ee.WriteMapElemValue()
- ee.EncodeStringEnc(cUTF8, v[uint16(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint16(k2)))
- ee.EncodeStringEnc(cUTF8, v[uint16(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeStringEnc(cUTF8, v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeStringEnc(cUTF8, v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint16UintR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint16UintV(rv2i(rv).(map[uint16]uint), e)
-}
-func (_ fastpathT) EncMapUint16UintV(v map[uint16]uint, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint16(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[uint16(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint16(k2)))
- ee.EncodeUint(uint64(v[uint16(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint16Uint8R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint16Uint8V(rv2i(rv).(map[uint16]uint8), e)
-}
-func (_ fastpathT) EncMapUint16Uint8V(v map[uint16]uint8, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint16(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[uint16(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint16(k2)))
- ee.EncodeUint(uint64(v[uint16(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint16Uint16R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint16Uint16V(rv2i(rv).(map[uint16]uint16), e)
-}
-func (_ fastpathT) EncMapUint16Uint16V(v map[uint16]uint16, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint16(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[uint16(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint16(k2)))
- ee.EncodeUint(uint64(v[uint16(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint16Uint32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint16Uint32V(rv2i(rv).(map[uint16]uint32), e)
-}
-func (_ fastpathT) EncMapUint16Uint32V(v map[uint16]uint32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint16(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[uint16(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint16(k2)))
- ee.EncodeUint(uint64(v[uint16(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint16Uint64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint16Uint64V(rv2i(rv).(map[uint16]uint64), e)
-}
-func (_ fastpathT) EncMapUint16Uint64V(v map[uint16]uint64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint16(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[uint16(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint16(k2)))
- ee.EncodeUint(uint64(v[uint16(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint16UintptrR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint16UintptrV(rv2i(rv).(map[uint16]uintptr), e)
-}
-func (_ fastpathT) EncMapUint16UintptrV(v map[uint16]uintptr, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint16(k2)))
- ee.WriteMapElemValue()
- e.encode(v[uint16(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint16(k2)))
- e.encode(v[uint16(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- e.encode(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- e.encode(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint16IntR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint16IntV(rv2i(rv).(map[uint16]int), e)
-}
-func (_ fastpathT) EncMapUint16IntV(v map[uint16]int, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint16(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[uint16(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint16(k2)))
- ee.EncodeInt(int64(v[uint16(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint16Int8R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint16Int8V(rv2i(rv).(map[uint16]int8), e)
-}
-func (_ fastpathT) EncMapUint16Int8V(v map[uint16]int8, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint16(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[uint16(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint16(k2)))
- ee.EncodeInt(int64(v[uint16(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint16Int16R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint16Int16V(rv2i(rv).(map[uint16]int16), e)
-}
-func (_ fastpathT) EncMapUint16Int16V(v map[uint16]int16, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint16(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[uint16(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint16(k2)))
- ee.EncodeInt(int64(v[uint16(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint16Int32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint16Int32V(rv2i(rv).(map[uint16]int32), e)
-}
-func (_ fastpathT) EncMapUint16Int32V(v map[uint16]int32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint16(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[uint16(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint16(k2)))
- ee.EncodeInt(int64(v[uint16(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint16Int64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint16Int64V(rv2i(rv).(map[uint16]int64), e)
-}
-func (_ fastpathT) EncMapUint16Int64V(v map[uint16]int64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint16(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[uint16(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint16(k2)))
- ee.EncodeInt(int64(v[uint16(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint16Float32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint16Float32V(rv2i(rv).(map[uint16]float32), e)
-}
-func (_ fastpathT) EncMapUint16Float32V(v map[uint16]float32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint16(k2)))
- ee.WriteMapElemValue()
- ee.EncodeFloat32(v[uint16(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint16(k2)))
- ee.EncodeFloat32(v[uint16(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeFloat32(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeFloat32(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint16Float64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint16Float64V(rv2i(rv).(map[uint16]float64), e)
-}
-func (_ fastpathT) EncMapUint16Float64V(v map[uint16]float64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint16(k2)))
- ee.WriteMapElemValue()
- ee.EncodeFloat64(v[uint16(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint16(k2)))
- ee.EncodeFloat64(v[uint16(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeFloat64(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeFloat64(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint16BoolR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint16BoolV(rv2i(rv).(map[uint16]bool), e)
-}
-func (_ fastpathT) EncMapUint16BoolV(v map[uint16]bool, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint16(k2)))
- ee.WriteMapElemValue()
- ee.EncodeBool(v[uint16(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint16(k2)))
- ee.EncodeBool(v[uint16(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeBool(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeBool(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint32IntfR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint32IntfV(rv2i(rv).(map[uint32]interface{}), e)
-}
-func (_ fastpathT) EncMapUint32IntfV(v map[uint32]interface{}, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint32(k2)))
- ee.WriteMapElemValue()
- e.encode(v[uint32(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint32(k2)))
- e.encode(v[uint32(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- e.encode(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- e.encode(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint32StringR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint32StringV(rv2i(rv).(map[uint32]string), e)
-}
-func (_ fastpathT) EncMapUint32StringV(v map[uint32]string, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint32(k2)))
- ee.WriteMapElemValue()
- ee.EncodeStringEnc(cUTF8, v[uint32(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint32(k2)))
- ee.EncodeStringEnc(cUTF8, v[uint32(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeStringEnc(cUTF8, v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeStringEnc(cUTF8, v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint32UintR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint32UintV(rv2i(rv).(map[uint32]uint), e)
-}
-func (_ fastpathT) EncMapUint32UintV(v map[uint32]uint, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint32(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[uint32(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint32(k2)))
- ee.EncodeUint(uint64(v[uint32(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint32Uint8R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint32Uint8V(rv2i(rv).(map[uint32]uint8), e)
-}
-func (_ fastpathT) EncMapUint32Uint8V(v map[uint32]uint8, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint32(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[uint32(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint32(k2)))
- ee.EncodeUint(uint64(v[uint32(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint32Uint16R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint32Uint16V(rv2i(rv).(map[uint32]uint16), e)
-}
-func (_ fastpathT) EncMapUint32Uint16V(v map[uint32]uint16, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint32(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[uint32(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint32(k2)))
- ee.EncodeUint(uint64(v[uint32(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint32Uint32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint32Uint32V(rv2i(rv).(map[uint32]uint32), e)
-}
-func (_ fastpathT) EncMapUint32Uint32V(v map[uint32]uint32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint32(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[uint32(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint32(k2)))
- ee.EncodeUint(uint64(v[uint32(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint32Uint64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint32Uint64V(rv2i(rv).(map[uint32]uint64), e)
-}
-func (_ fastpathT) EncMapUint32Uint64V(v map[uint32]uint64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint32(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[uint32(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint32(k2)))
- ee.EncodeUint(uint64(v[uint32(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint32UintptrR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint32UintptrV(rv2i(rv).(map[uint32]uintptr), e)
-}
-func (_ fastpathT) EncMapUint32UintptrV(v map[uint32]uintptr, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint32(k2)))
- ee.WriteMapElemValue()
- e.encode(v[uint32(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint32(k2)))
- e.encode(v[uint32(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- e.encode(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- e.encode(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint32IntR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint32IntV(rv2i(rv).(map[uint32]int), e)
-}
-func (_ fastpathT) EncMapUint32IntV(v map[uint32]int, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint32(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[uint32(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint32(k2)))
- ee.EncodeInt(int64(v[uint32(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint32Int8R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint32Int8V(rv2i(rv).(map[uint32]int8), e)
-}
-func (_ fastpathT) EncMapUint32Int8V(v map[uint32]int8, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint32(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[uint32(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint32(k2)))
- ee.EncodeInt(int64(v[uint32(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint32Int16R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint32Int16V(rv2i(rv).(map[uint32]int16), e)
-}
-func (_ fastpathT) EncMapUint32Int16V(v map[uint32]int16, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint32(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[uint32(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint32(k2)))
- ee.EncodeInt(int64(v[uint32(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint32Int32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint32Int32V(rv2i(rv).(map[uint32]int32), e)
-}
-func (_ fastpathT) EncMapUint32Int32V(v map[uint32]int32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint32(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[uint32(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint32(k2)))
- ee.EncodeInt(int64(v[uint32(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint32Int64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint32Int64V(rv2i(rv).(map[uint32]int64), e)
-}
-func (_ fastpathT) EncMapUint32Int64V(v map[uint32]int64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint32(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[uint32(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint32(k2)))
- ee.EncodeInt(int64(v[uint32(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint32Float32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint32Float32V(rv2i(rv).(map[uint32]float32), e)
-}
-func (_ fastpathT) EncMapUint32Float32V(v map[uint32]float32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint32(k2)))
- ee.WriteMapElemValue()
- ee.EncodeFloat32(v[uint32(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint32(k2)))
- ee.EncodeFloat32(v[uint32(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeFloat32(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeFloat32(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint32Float64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint32Float64V(rv2i(rv).(map[uint32]float64), e)
-}
-func (_ fastpathT) EncMapUint32Float64V(v map[uint32]float64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint32(k2)))
- ee.WriteMapElemValue()
- ee.EncodeFloat64(v[uint32(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint32(k2)))
- ee.EncodeFloat64(v[uint32(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeFloat64(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeFloat64(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint32BoolR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint32BoolV(rv2i(rv).(map[uint32]bool), e)
-}
-func (_ fastpathT) EncMapUint32BoolV(v map[uint32]bool, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint32(k2)))
- ee.WriteMapElemValue()
- ee.EncodeBool(v[uint32(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint32(k2)))
- ee.EncodeBool(v[uint32(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeBool(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeBool(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint64IntfR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint64IntfV(rv2i(rv).(map[uint64]interface{}), e)
-}
-func (_ fastpathT) EncMapUint64IntfV(v map[uint64]interface{}, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint64(k2)))
- ee.WriteMapElemValue()
- e.encode(v[uint64(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint64(k2)))
- e.encode(v[uint64(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- e.encode(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- e.encode(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint64StringR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint64StringV(rv2i(rv).(map[uint64]string), e)
-}
-func (_ fastpathT) EncMapUint64StringV(v map[uint64]string, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint64(k2)))
- ee.WriteMapElemValue()
- ee.EncodeStringEnc(cUTF8, v[uint64(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint64(k2)))
- ee.EncodeStringEnc(cUTF8, v[uint64(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeStringEnc(cUTF8, v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeStringEnc(cUTF8, v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint64UintR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint64UintV(rv2i(rv).(map[uint64]uint), e)
-}
-func (_ fastpathT) EncMapUint64UintV(v map[uint64]uint, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint64(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[uint64(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint64(k2)))
- ee.EncodeUint(uint64(v[uint64(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint64Uint8R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint64Uint8V(rv2i(rv).(map[uint64]uint8), e)
-}
-func (_ fastpathT) EncMapUint64Uint8V(v map[uint64]uint8, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint64(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[uint64(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint64(k2)))
- ee.EncodeUint(uint64(v[uint64(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint64Uint16R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint64Uint16V(rv2i(rv).(map[uint64]uint16), e)
-}
-func (_ fastpathT) EncMapUint64Uint16V(v map[uint64]uint16, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint64(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[uint64(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint64(k2)))
- ee.EncodeUint(uint64(v[uint64(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint64Uint32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint64Uint32V(rv2i(rv).(map[uint64]uint32), e)
-}
-func (_ fastpathT) EncMapUint64Uint32V(v map[uint64]uint32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint64(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[uint64(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint64(k2)))
- ee.EncodeUint(uint64(v[uint64(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint64Uint64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint64Uint64V(rv2i(rv).(map[uint64]uint64), e)
-}
-func (_ fastpathT) EncMapUint64Uint64V(v map[uint64]uint64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint64(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[uint64(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint64(k2)))
- ee.EncodeUint(uint64(v[uint64(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint64UintptrR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint64UintptrV(rv2i(rv).(map[uint64]uintptr), e)
-}
-func (_ fastpathT) EncMapUint64UintptrV(v map[uint64]uintptr, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint64(k2)))
- ee.WriteMapElemValue()
- e.encode(v[uint64(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint64(k2)))
- e.encode(v[uint64(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- e.encode(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- e.encode(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint64IntR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint64IntV(rv2i(rv).(map[uint64]int), e)
-}
-func (_ fastpathT) EncMapUint64IntV(v map[uint64]int, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint64(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[uint64(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint64(k2)))
- ee.EncodeInt(int64(v[uint64(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint64Int8R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint64Int8V(rv2i(rv).(map[uint64]int8), e)
-}
-func (_ fastpathT) EncMapUint64Int8V(v map[uint64]int8, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint64(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[uint64(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint64(k2)))
- ee.EncodeInt(int64(v[uint64(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint64Int16R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint64Int16V(rv2i(rv).(map[uint64]int16), e)
-}
-func (_ fastpathT) EncMapUint64Int16V(v map[uint64]int16, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint64(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[uint64(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint64(k2)))
- ee.EncodeInt(int64(v[uint64(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint64Int32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint64Int32V(rv2i(rv).(map[uint64]int32), e)
-}
-func (_ fastpathT) EncMapUint64Int32V(v map[uint64]int32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint64(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[uint64(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint64(k2)))
- ee.EncodeInt(int64(v[uint64(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint64Int64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint64Int64V(rv2i(rv).(map[uint64]int64), e)
-}
-func (_ fastpathT) EncMapUint64Int64V(v map[uint64]int64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint64(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[uint64(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint64(k2)))
- ee.EncodeInt(int64(v[uint64(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint64Float32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint64Float32V(rv2i(rv).(map[uint64]float32), e)
-}
-func (_ fastpathT) EncMapUint64Float32V(v map[uint64]float32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint64(k2)))
- ee.WriteMapElemValue()
- ee.EncodeFloat32(v[uint64(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint64(k2)))
- ee.EncodeFloat32(v[uint64(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeFloat32(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeFloat32(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint64Float64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint64Float64V(rv2i(rv).(map[uint64]float64), e)
-}
-func (_ fastpathT) EncMapUint64Float64V(v map[uint64]float64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint64(k2)))
- ee.WriteMapElemValue()
- ee.EncodeFloat64(v[uint64(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint64(k2)))
- ee.EncodeFloat64(v[uint64(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeFloat64(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeFloat64(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint64BoolR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint64BoolV(rv2i(rv).(map[uint64]bool), e)
-}
-func (_ fastpathT) EncMapUint64BoolV(v map[uint64]bool, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint64(k2)))
- ee.WriteMapElemValue()
- ee.EncodeBool(v[uint64(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint64(k2)))
- ee.EncodeBool(v[uint64(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeBool(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeBool(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUintptrIntfR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUintptrIntfV(rv2i(rv).(map[uintptr]interface{}), e)
-}
-func (_ fastpathT) EncMapUintptrIntfV(v map[uintptr]interface{}, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- e.encode(uintptr(k2))
- ee.WriteMapElemValue()
- e.encode(v[uintptr(k2)])
- }
- } else {
- for _, k2 := range v2 {
- e.encode(uintptr(k2))
- e.encode(v[uintptr(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- e.encode(k2)
- ee.WriteMapElemValue()
- e.encode(v2)
- }
- } else {
- for k2, v2 := range v {
- e.encode(k2)
- e.encode(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUintptrStringR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUintptrStringV(rv2i(rv).(map[uintptr]string), e)
-}
-func (_ fastpathT) EncMapUintptrStringV(v map[uintptr]string, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- e.encode(uintptr(k2))
- ee.WriteMapElemValue()
- ee.EncodeStringEnc(cUTF8, v[uintptr(k2)])
- }
- } else {
- for _, k2 := range v2 {
- e.encode(uintptr(k2))
- ee.EncodeStringEnc(cUTF8, v[uintptr(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- e.encode(k2)
- ee.WriteMapElemValue()
- ee.EncodeStringEnc(cUTF8, v2)
- }
- } else {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeStringEnc(cUTF8, v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUintptrUintR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUintptrUintV(rv2i(rv).(map[uintptr]uint), e)
-}
-func (_ fastpathT) EncMapUintptrUintV(v map[uintptr]uint, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- e.encode(uintptr(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[uintptr(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- e.encode(uintptr(k2))
- ee.EncodeUint(uint64(v[uintptr(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- e.encode(k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUintptrUint8R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUintptrUint8V(rv2i(rv).(map[uintptr]uint8), e)
-}
-func (_ fastpathT) EncMapUintptrUint8V(v map[uintptr]uint8, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- e.encode(uintptr(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[uintptr(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- e.encode(uintptr(k2))
- ee.EncodeUint(uint64(v[uintptr(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- e.encode(k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUintptrUint16R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUintptrUint16V(rv2i(rv).(map[uintptr]uint16), e)
-}
-func (_ fastpathT) EncMapUintptrUint16V(v map[uintptr]uint16, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- e.encode(uintptr(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[uintptr(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- e.encode(uintptr(k2))
- ee.EncodeUint(uint64(v[uintptr(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- e.encode(k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUintptrUint32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUintptrUint32V(rv2i(rv).(map[uintptr]uint32), e)
-}
-func (_ fastpathT) EncMapUintptrUint32V(v map[uintptr]uint32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- e.encode(uintptr(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[uintptr(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- e.encode(uintptr(k2))
- ee.EncodeUint(uint64(v[uintptr(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- e.encode(k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUintptrUint64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUintptrUint64V(rv2i(rv).(map[uintptr]uint64), e)
-}
-func (_ fastpathT) EncMapUintptrUint64V(v map[uintptr]uint64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- e.encode(uintptr(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[uintptr(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- e.encode(uintptr(k2))
- ee.EncodeUint(uint64(v[uintptr(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- e.encode(k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUintptrUintptrR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUintptrUintptrV(rv2i(rv).(map[uintptr]uintptr), e)
-}
-func (_ fastpathT) EncMapUintptrUintptrV(v map[uintptr]uintptr, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- e.encode(uintptr(k2))
- ee.WriteMapElemValue()
- e.encode(v[uintptr(k2)])
- }
- } else {
- for _, k2 := range v2 {
- e.encode(uintptr(k2))
- e.encode(v[uintptr(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- e.encode(k2)
- ee.WriteMapElemValue()
- e.encode(v2)
- }
- } else {
- for k2, v2 := range v {
- e.encode(k2)
- e.encode(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUintptrIntR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUintptrIntV(rv2i(rv).(map[uintptr]int), e)
-}
-func (_ fastpathT) EncMapUintptrIntV(v map[uintptr]int, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- e.encode(uintptr(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[uintptr(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- e.encode(uintptr(k2))
- ee.EncodeInt(int64(v[uintptr(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- e.encode(k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUintptrInt8R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUintptrInt8V(rv2i(rv).(map[uintptr]int8), e)
-}
-func (_ fastpathT) EncMapUintptrInt8V(v map[uintptr]int8, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- e.encode(uintptr(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[uintptr(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- e.encode(uintptr(k2))
- ee.EncodeInt(int64(v[uintptr(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- e.encode(k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUintptrInt16R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUintptrInt16V(rv2i(rv).(map[uintptr]int16), e)
-}
-func (_ fastpathT) EncMapUintptrInt16V(v map[uintptr]int16, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- e.encode(uintptr(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[uintptr(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- e.encode(uintptr(k2))
- ee.EncodeInt(int64(v[uintptr(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- e.encode(k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUintptrInt32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUintptrInt32V(rv2i(rv).(map[uintptr]int32), e)
-}
-func (_ fastpathT) EncMapUintptrInt32V(v map[uintptr]int32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- e.encode(uintptr(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[uintptr(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- e.encode(uintptr(k2))
- ee.EncodeInt(int64(v[uintptr(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- e.encode(k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUintptrInt64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUintptrInt64V(rv2i(rv).(map[uintptr]int64), e)
-}
-func (_ fastpathT) EncMapUintptrInt64V(v map[uintptr]int64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- e.encode(uintptr(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[uintptr(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- e.encode(uintptr(k2))
- ee.EncodeInt(int64(v[uintptr(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- e.encode(k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUintptrFloat32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUintptrFloat32V(rv2i(rv).(map[uintptr]float32), e)
-}
-func (_ fastpathT) EncMapUintptrFloat32V(v map[uintptr]float32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- e.encode(uintptr(k2))
- ee.WriteMapElemValue()
- ee.EncodeFloat32(v[uintptr(k2)])
- }
- } else {
- for _, k2 := range v2 {
- e.encode(uintptr(k2))
- ee.EncodeFloat32(v[uintptr(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- e.encode(k2)
- ee.WriteMapElemValue()
- ee.EncodeFloat32(v2)
- }
- } else {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeFloat32(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUintptrFloat64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUintptrFloat64V(rv2i(rv).(map[uintptr]float64), e)
-}
-func (_ fastpathT) EncMapUintptrFloat64V(v map[uintptr]float64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- e.encode(uintptr(k2))
- ee.WriteMapElemValue()
- ee.EncodeFloat64(v[uintptr(k2)])
- }
- } else {
- for _, k2 := range v2 {
- e.encode(uintptr(k2))
- ee.EncodeFloat64(v[uintptr(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- e.encode(k2)
- ee.WriteMapElemValue()
- ee.EncodeFloat64(v2)
- }
- } else {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeFloat64(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUintptrBoolR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUintptrBoolV(rv2i(rv).(map[uintptr]bool), e)
-}
-func (_ fastpathT) EncMapUintptrBoolV(v map[uintptr]bool, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i uint
- for k := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- e.encode(uintptr(k2))
- ee.WriteMapElemValue()
- ee.EncodeBool(v[uintptr(k2)])
- }
- } else {
- for _, k2 := range v2 {
- e.encode(uintptr(k2))
- ee.EncodeBool(v[uintptr(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- e.encode(k2)
- ee.WriteMapElemValue()
- ee.EncodeBool(v2)
- }
- } else {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeBool(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapIntIntfR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapIntIntfV(rv2i(rv).(map[int]interface{}), e)
-}
-func (_ fastpathT) EncMapIntIntfV(v map[int]interface{}, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int(k2)))
- ee.WriteMapElemValue()
- e.encode(v[int(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int(k2)))
- e.encode(v[int(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- e.encode(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- e.encode(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapIntStringR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapIntStringV(rv2i(rv).(map[int]string), e)
-}
-func (_ fastpathT) EncMapIntStringV(v map[int]string, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int(k2)))
- ee.WriteMapElemValue()
- ee.EncodeStringEnc(cUTF8, v[int(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int(k2)))
- ee.EncodeStringEnc(cUTF8, v[int(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeStringEnc(cUTF8, v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeStringEnc(cUTF8, v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapIntUintR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapIntUintV(rv2i(rv).(map[int]uint), e)
-}
-func (_ fastpathT) EncMapIntUintV(v map[int]uint, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[int(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int(k2)))
- ee.EncodeUint(uint64(v[int(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapIntUint8R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapIntUint8V(rv2i(rv).(map[int]uint8), e)
-}
-func (_ fastpathT) EncMapIntUint8V(v map[int]uint8, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[int(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int(k2)))
- ee.EncodeUint(uint64(v[int(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapIntUint16R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapIntUint16V(rv2i(rv).(map[int]uint16), e)
-}
-func (_ fastpathT) EncMapIntUint16V(v map[int]uint16, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[int(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int(k2)))
- ee.EncodeUint(uint64(v[int(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapIntUint32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapIntUint32V(rv2i(rv).(map[int]uint32), e)
-}
-func (_ fastpathT) EncMapIntUint32V(v map[int]uint32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[int(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int(k2)))
- ee.EncodeUint(uint64(v[int(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapIntUint64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapIntUint64V(rv2i(rv).(map[int]uint64), e)
-}
-func (_ fastpathT) EncMapIntUint64V(v map[int]uint64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[int(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int(k2)))
- ee.EncodeUint(uint64(v[int(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapIntUintptrR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapIntUintptrV(rv2i(rv).(map[int]uintptr), e)
-}
-func (_ fastpathT) EncMapIntUintptrV(v map[int]uintptr, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int(k2)))
- ee.WriteMapElemValue()
- e.encode(v[int(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int(k2)))
- e.encode(v[int(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- e.encode(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- e.encode(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapIntIntR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapIntIntV(rv2i(rv).(map[int]int), e)
-}
-func (_ fastpathT) EncMapIntIntV(v map[int]int, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[int(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int(k2)))
- ee.EncodeInt(int64(v[int(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapIntInt8R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapIntInt8V(rv2i(rv).(map[int]int8), e)
-}
-func (_ fastpathT) EncMapIntInt8V(v map[int]int8, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[int(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int(k2)))
- ee.EncodeInt(int64(v[int(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapIntInt16R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapIntInt16V(rv2i(rv).(map[int]int16), e)
-}
-func (_ fastpathT) EncMapIntInt16V(v map[int]int16, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[int(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int(k2)))
- ee.EncodeInt(int64(v[int(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapIntInt32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapIntInt32V(rv2i(rv).(map[int]int32), e)
-}
-func (_ fastpathT) EncMapIntInt32V(v map[int]int32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[int(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int(k2)))
- ee.EncodeInt(int64(v[int(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapIntInt64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapIntInt64V(rv2i(rv).(map[int]int64), e)
-}
-func (_ fastpathT) EncMapIntInt64V(v map[int]int64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[int(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int(k2)))
- ee.EncodeInt(int64(v[int(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapIntFloat32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapIntFloat32V(rv2i(rv).(map[int]float32), e)
-}
-func (_ fastpathT) EncMapIntFloat32V(v map[int]float32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int(k2)))
- ee.WriteMapElemValue()
- ee.EncodeFloat32(v[int(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int(k2)))
- ee.EncodeFloat32(v[int(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeFloat32(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeFloat32(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapIntFloat64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapIntFloat64V(rv2i(rv).(map[int]float64), e)
-}
-func (_ fastpathT) EncMapIntFloat64V(v map[int]float64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int(k2)))
- ee.WriteMapElemValue()
- ee.EncodeFloat64(v[int(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int(k2)))
- ee.EncodeFloat64(v[int(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeFloat64(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeFloat64(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapIntBoolR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapIntBoolV(rv2i(rv).(map[int]bool), e)
-}
-func (_ fastpathT) EncMapIntBoolV(v map[int]bool, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int(k2)))
- ee.WriteMapElemValue()
- ee.EncodeBool(v[int(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int(k2)))
- ee.EncodeBool(v[int(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeBool(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeBool(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapInt8IntfR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt8IntfV(rv2i(rv).(map[int8]interface{}), e)
-}
-func (_ fastpathT) EncMapInt8IntfV(v map[int8]interface{}, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int8(k2)))
- ee.WriteMapElemValue()
- e.encode(v[int8(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int8(k2)))
- e.encode(v[int8(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- e.encode(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- e.encode(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapInt8StringR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt8StringV(rv2i(rv).(map[int8]string), e)
-}
-func (_ fastpathT) EncMapInt8StringV(v map[int8]string, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int8(k2)))
- ee.WriteMapElemValue()
- ee.EncodeStringEnc(cUTF8, v[int8(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int8(k2)))
- ee.EncodeStringEnc(cUTF8, v[int8(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeStringEnc(cUTF8, v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeStringEnc(cUTF8, v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapInt8UintR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt8UintV(rv2i(rv).(map[int8]uint), e)
-}
-func (_ fastpathT) EncMapInt8UintV(v map[int8]uint, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int8(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[int8(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int8(k2)))
- ee.EncodeUint(uint64(v[int8(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapInt8Uint8R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt8Uint8V(rv2i(rv).(map[int8]uint8), e)
-}
-func (_ fastpathT) EncMapInt8Uint8V(v map[int8]uint8, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int8(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[int8(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int8(k2)))
- ee.EncodeUint(uint64(v[int8(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapInt8Uint16R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt8Uint16V(rv2i(rv).(map[int8]uint16), e)
-}
-func (_ fastpathT) EncMapInt8Uint16V(v map[int8]uint16, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int8(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[int8(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int8(k2)))
- ee.EncodeUint(uint64(v[int8(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapInt8Uint32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt8Uint32V(rv2i(rv).(map[int8]uint32), e)
-}
-func (_ fastpathT) EncMapInt8Uint32V(v map[int8]uint32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int8(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[int8(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int8(k2)))
- ee.EncodeUint(uint64(v[int8(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapInt8Uint64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt8Uint64V(rv2i(rv).(map[int8]uint64), e)
-}
-func (_ fastpathT) EncMapInt8Uint64V(v map[int8]uint64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int8(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[int8(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int8(k2)))
- ee.EncodeUint(uint64(v[int8(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapInt8UintptrR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt8UintptrV(rv2i(rv).(map[int8]uintptr), e)
-}
-func (_ fastpathT) EncMapInt8UintptrV(v map[int8]uintptr, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int8(k2)))
- ee.WriteMapElemValue()
- e.encode(v[int8(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int8(k2)))
- e.encode(v[int8(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- e.encode(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- e.encode(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapInt8IntR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt8IntV(rv2i(rv).(map[int8]int), e)
-}
-func (_ fastpathT) EncMapInt8IntV(v map[int8]int, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int8(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[int8(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int8(k2)))
- ee.EncodeInt(int64(v[int8(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapInt8Int8R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt8Int8V(rv2i(rv).(map[int8]int8), e)
-}
-func (_ fastpathT) EncMapInt8Int8V(v map[int8]int8, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int8(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[int8(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int8(k2)))
- ee.EncodeInt(int64(v[int8(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapInt8Int16R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt8Int16V(rv2i(rv).(map[int8]int16), e)
-}
-func (_ fastpathT) EncMapInt8Int16V(v map[int8]int16, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int8(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[int8(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int8(k2)))
- ee.EncodeInt(int64(v[int8(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapInt8Int32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt8Int32V(rv2i(rv).(map[int8]int32), e)
-}
-func (_ fastpathT) EncMapInt8Int32V(v map[int8]int32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int8(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[int8(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int8(k2)))
- ee.EncodeInt(int64(v[int8(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapInt8Int64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt8Int64V(rv2i(rv).(map[int8]int64), e)
-}
-func (_ fastpathT) EncMapInt8Int64V(v map[int8]int64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int8(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[int8(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int8(k2)))
- ee.EncodeInt(int64(v[int8(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapInt8Float32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt8Float32V(rv2i(rv).(map[int8]float32), e)
-}
-func (_ fastpathT) EncMapInt8Float32V(v map[int8]float32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int8(k2)))
- ee.WriteMapElemValue()
- ee.EncodeFloat32(v[int8(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int8(k2)))
- ee.EncodeFloat32(v[int8(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeFloat32(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeFloat32(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapInt8Float64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt8Float64V(rv2i(rv).(map[int8]float64), e)
-}
-func (_ fastpathT) EncMapInt8Float64V(v map[int8]float64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int8(k2)))
- ee.WriteMapElemValue()
- ee.EncodeFloat64(v[int8(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int8(k2)))
- ee.EncodeFloat64(v[int8(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeFloat64(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeFloat64(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapInt8BoolR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt8BoolV(rv2i(rv).(map[int8]bool), e)
-}
-func (_ fastpathT) EncMapInt8BoolV(v map[int8]bool, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int8(k2)))
- ee.WriteMapElemValue()
- ee.EncodeBool(v[int8(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int8(k2)))
- ee.EncodeBool(v[int8(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeBool(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeBool(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapInt16IntfR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt16IntfV(rv2i(rv).(map[int16]interface{}), e)
-}
-func (_ fastpathT) EncMapInt16IntfV(v map[int16]interface{}, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int16(k2)))
- ee.WriteMapElemValue()
- e.encode(v[int16(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int16(k2)))
- e.encode(v[int16(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- e.encode(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- e.encode(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapInt16StringR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt16StringV(rv2i(rv).(map[int16]string), e)
-}
-func (_ fastpathT) EncMapInt16StringV(v map[int16]string, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int16(k2)))
- ee.WriteMapElemValue()
- ee.EncodeStringEnc(cUTF8, v[int16(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int16(k2)))
- ee.EncodeStringEnc(cUTF8, v[int16(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeStringEnc(cUTF8, v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeStringEnc(cUTF8, v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapInt16UintR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt16UintV(rv2i(rv).(map[int16]uint), e)
-}
-func (_ fastpathT) EncMapInt16UintV(v map[int16]uint, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int16(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[int16(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int16(k2)))
- ee.EncodeUint(uint64(v[int16(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapInt16Uint8R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt16Uint8V(rv2i(rv).(map[int16]uint8), e)
-}
-func (_ fastpathT) EncMapInt16Uint8V(v map[int16]uint8, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int16(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[int16(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int16(k2)))
- ee.EncodeUint(uint64(v[int16(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapInt16Uint16R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt16Uint16V(rv2i(rv).(map[int16]uint16), e)
-}
-func (_ fastpathT) EncMapInt16Uint16V(v map[int16]uint16, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int16(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[int16(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int16(k2)))
- ee.EncodeUint(uint64(v[int16(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapInt16Uint32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt16Uint32V(rv2i(rv).(map[int16]uint32), e)
-}
-func (_ fastpathT) EncMapInt16Uint32V(v map[int16]uint32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int16(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[int16(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int16(k2)))
- ee.EncodeUint(uint64(v[int16(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapInt16Uint64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt16Uint64V(rv2i(rv).(map[int16]uint64), e)
-}
-func (_ fastpathT) EncMapInt16Uint64V(v map[int16]uint64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int16(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[int16(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int16(k2)))
- ee.EncodeUint(uint64(v[int16(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapInt16UintptrR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt16UintptrV(rv2i(rv).(map[int16]uintptr), e)
-}
-func (_ fastpathT) EncMapInt16UintptrV(v map[int16]uintptr, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int16(k2)))
- ee.WriteMapElemValue()
- e.encode(v[int16(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int16(k2)))
- e.encode(v[int16(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- e.encode(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- e.encode(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapInt16IntR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt16IntV(rv2i(rv).(map[int16]int), e)
-}
-func (_ fastpathT) EncMapInt16IntV(v map[int16]int, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int16(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[int16(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int16(k2)))
- ee.EncodeInt(int64(v[int16(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapInt16Int8R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt16Int8V(rv2i(rv).(map[int16]int8), e)
-}
-func (_ fastpathT) EncMapInt16Int8V(v map[int16]int8, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int16(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[int16(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int16(k2)))
- ee.EncodeInt(int64(v[int16(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapInt16Int16R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt16Int16V(rv2i(rv).(map[int16]int16), e)
-}
-func (_ fastpathT) EncMapInt16Int16V(v map[int16]int16, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int16(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[int16(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int16(k2)))
- ee.EncodeInt(int64(v[int16(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapInt16Int32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt16Int32V(rv2i(rv).(map[int16]int32), e)
-}
-func (_ fastpathT) EncMapInt16Int32V(v map[int16]int32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int16(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[int16(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int16(k2)))
- ee.EncodeInt(int64(v[int16(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapInt16Int64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt16Int64V(rv2i(rv).(map[int16]int64), e)
-}
-func (_ fastpathT) EncMapInt16Int64V(v map[int16]int64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int16(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[int16(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int16(k2)))
- ee.EncodeInt(int64(v[int16(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapInt16Float32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt16Float32V(rv2i(rv).(map[int16]float32), e)
-}
-func (_ fastpathT) EncMapInt16Float32V(v map[int16]float32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int16(k2)))
- ee.WriteMapElemValue()
- ee.EncodeFloat32(v[int16(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int16(k2)))
- ee.EncodeFloat32(v[int16(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeFloat32(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeFloat32(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapInt16Float64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt16Float64V(rv2i(rv).(map[int16]float64), e)
-}
-func (_ fastpathT) EncMapInt16Float64V(v map[int16]float64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int16(k2)))
- ee.WriteMapElemValue()
- ee.EncodeFloat64(v[int16(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int16(k2)))
- ee.EncodeFloat64(v[int16(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeFloat64(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeFloat64(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapInt16BoolR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt16BoolV(rv2i(rv).(map[int16]bool), e)
-}
-func (_ fastpathT) EncMapInt16BoolV(v map[int16]bool, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int16(k2)))
- ee.WriteMapElemValue()
- ee.EncodeBool(v[int16(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int16(k2)))
- ee.EncodeBool(v[int16(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeBool(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeBool(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapInt32IntfR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt32IntfV(rv2i(rv).(map[int32]interface{}), e)
-}
-func (_ fastpathT) EncMapInt32IntfV(v map[int32]interface{}, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int32(k2)))
- ee.WriteMapElemValue()
- e.encode(v[int32(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int32(k2)))
- e.encode(v[int32(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- e.encode(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- e.encode(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapInt32StringR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt32StringV(rv2i(rv).(map[int32]string), e)
-}
-func (_ fastpathT) EncMapInt32StringV(v map[int32]string, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int32(k2)))
- ee.WriteMapElemValue()
- ee.EncodeStringEnc(cUTF8, v[int32(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int32(k2)))
- ee.EncodeStringEnc(cUTF8, v[int32(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeStringEnc(cUTF8, v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeStringEnc(cUTF8, v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapInt32UintR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt32UintV(rv2i(rv).(map[int32]uint), e)
-}
-func (_ fastpathT) EncMapInt32UintV(v map[int32]uint, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int32(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[int32(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int32(k2)))
- ee.EncodeUint(uint64(v[int32(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapInt32Uint8R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt32Uint8V(rv2i(rv).(map[int32]uint8), e)
-}
-func (_ fastpathT) EncMapInt32Uint8V(v map[int32]uint8, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int32(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[int32(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int32(k2)))
- ee.EncodeUint(uint64(v[int32(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapInt32Uint16R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt32Uint16V(rv2i(rv).(map[int32]uint16), e)
-}
-func (_ fastpathT) EncMapInt32Uint16V(v map[int32]uint16, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int32(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[int32(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int32(k2)))
- ee.EncodeUint(uint64(v[int32(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapInt32Uint32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt32Uint32V(rv2i(rv).(map[int32]uint32), e)
-}
-func (_ fastpathT) EncMapInt32Uint32V(v map[int32]uint32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int32(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[int32(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int32(k2)))
- ee.EncodeUint(uint64(v[int32(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapInt32Uint64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt32Uint64V(rv2i(rv).(map[int32]uint64), e)
-}
-func (_ fastpathT) EncMapInt32Uint64V(v map[int32]uint64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int32(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[int32(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int32(k2)))
- ee.EncodeUint(uint64(v[int32(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapInt32UintptrR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt32UintptrV(rv2i(rv).(map[int32]uintptr), e)
-}
-func (_ fastpathT) EncMapInt32UintptrV(v map[int32]uintptr, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int32(k2)))
- ee.WriteMapElemValue()
- e.encode(v[int32(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int32(k2)))
- e.encode(v[int32(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- e.encode(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- e.encode(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapInt32IntR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt32IntV(rv2i(rv).(map[int32]int), e)
-}
-func (_ fastpathT) EncMapInt32IntV(v map[int32]int, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int32(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[int32(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int32(k2)))
- ee.EncodeInt(int64(v[int32(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapInt32Int8R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt32Int8V(rv2i(rv).(map[int32]int8), e)
-}
-func (_ fastpathT) EncMapInt32Int8V(v map[int32]int8, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int32(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[int32(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int32(k2)))
- ee.EncodeInt(int64(v[int32(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapInt32Int16R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt32Int16V(rv2i(rv).(map[int32]int16), e)
-}
-func (_ fastpathT) EncMapInt32Int16V(v map[int32]int16, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int32(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[int32(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int32(k2)))
- ee.EncodeInt(int64(v[int32(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapInt32Int32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt32Int32V(rv2i(rv).(map[int32]int32), e)
-}
-func (_ fastpathT) EncMapInt32Int32V(v map[int32]int32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int32(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[int32(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int32(k2)))
- ee.EncodeInt(int64(v[int32(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapInt32Int64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt32Int64V(rv2i(rv).(map[int32]int64), e)
-}
-func (_ fastpathT) EncMapInt32Int64V(v map[int32]int64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int32(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[int32(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int32(k2)))
- ee.EncodeInt(int64(v[int32(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapInt32Float32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt32Float32V(rv2i(rv).(map[int32]float32), e)
-}
-func (_ fastpathT) EncMapInt32Float32V(v map[int32]float32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int32(k2)))
- ee.WriteMapElemValue()
- ee.EncodeFloat32(v[int32(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int32(k2)))
- ee.EncodeFloat32(v[int32(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeFloat32(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeFloat32(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapInt32Float64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt32Float64V(rv2i(rv).(map[int32]float64), e)
-}
-func (_ fastpathT) EncMapInt32Float64V(v map[int32]float64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int32(k2)))
- ee.WriteMapElemValue()
- ee.EncodeFloat64(v[int32(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int32(k2)))
- ee.EncodeFloat64(v[int32(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeFloat64(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeFloat64(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapInt32BoolR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt32BoolV(rv2i(rv).(map[int32]bool), e)
-}
-func (_ fastpathT) EncMapInt32BoolV(v map[int32]bool, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int32(k2)))
- ee.WriteMapElemValue()
- ee.EncodeBool(v[int32(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int32(k2)))
- ee.EncodeBool(v[int32(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeBool(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeBool(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapInt64IntfR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt64IntfV(rv2i(rv).(map[int64]interface{}), e)
-}
-func (_ fastpathT) EncMapInt64IntfV(v map[int64]interface{}, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int64(k2)))
- ee.WriteMapElemValue()
- e.encode(v[int64(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int64(k2)))
- e.encode(v[int64(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- e.encode(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- e.encode(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapInt64StringR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt64StringV(rv2i(rv).(map[int64]string), e)
-}
-func (_ fastpathT) EncMapInt64StringV(v map[int64]string, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int64(k2)))
- ee.WriteMapElemValue()
- ee.EncodeStringEnc(cUTF8, v[int64(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int64(k2)))
- ee.EncodeStringEnc(cUTF8, v[int64(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeStringEnc(cUTF8, v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeStringEnc(cUTF8, v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapInt64UintR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt64UintV(rv2i(rv).(map[int64]uint), e)
-}
-func (_ fastpathT) EncMapInt64UintV(v map[int64]uint, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int64(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[int64(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int64(k2)))
- ee.EncodeUint(uint64(v[int64(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapInt64Uint8R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt64Uint8V(rv2i(rv).(map[int64]uint8), e)
-}
-func (_ fastpathT) EncMapInt64Uint8V(v map[int64]uint8, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int64(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[int64(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int64(k2)))
- ee.EncodeUint(uint64(v[int64(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapInt64Uint16R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt64Uint16V(rv2i(rv).(map[int64]uint16), e)
-}
-func (_ fastpathT) EncMapInt64Uint16V(v map[int64]uint16, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int64(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[int64(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int64(k2)))
- ee.EncodeUint(uint64(v[int64(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapInt64Uint32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt64Uint32V(rv2i(rv).(map[int64]uint32), e)
-}
-func (_ fastpathT) EncMapInt64Uint32V(v map[int64]uint32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int64(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[int64(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int64(k2)))
- ee.EncodeUint(uint64(v[int64(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapInt64Uint64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt64Uint64V(rv2i(rv).(map[int64]uint64), e)
-}
-func (_ fastpathT) EncMapInt64Uint64V(v map[int64]uint64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int64(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[int64(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int64(k2)))
- ee.EncodeUint(uint64(v[int64(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapInt64UintptrR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt64UintptrV(rv2i(rv).(map[int64]uintptr), e)
-}
-func (_ fastpathT) EncMapInt64UintptrV(v map[int64]uintptr, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int64(k2)))
- ee.WriteMapElemValue()
- e.encode(v[int64(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int64(k2)))
- e.encode(v[int64(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- e.encode(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- e.encode(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapInt64IntR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt64IntV(rv2i(rv).(map[int64]int), e)
-}
-func (_ fastpathT) EncMapInt64IntV(v map[int64]int, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int64(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[int64(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int64(k2)))
- ee.EncodeInt(int64(v[int64(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapInt64Int8R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt64Int8V(rv2i(rv).(map[int64]int8), e)
-}
-func (_ fastpathT) EncMapInt64Int8V(v map[int64]int8, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int64(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[int64(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int64(k2)))
- ee.EncodeInt(int64(v[int64(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapInt64Int16R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt64Int16V(rv2i(rv).(map[int64]int16), e)
-}
-func (_ fastpathT) EncMapInt64Int16V(v map[int64]int16, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int64(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[int64(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int64(k2)))
- ee.EncodeInt(int64(v[int64(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapInt64Int32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt64Int32V(rv2i(rv).(map[int64]int32), e)
-}
-func (_ fastpathT) EncMapInt64Int32V(v map[int64]int32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int64(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[int64(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int64(k2)))
- ee.EncodeInt(int64(v[int64(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapInt64Int64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt64Int64V(rv2i(rv).(map[int64]int64), e)
-}
-func (_ fastpathT) EncMapInt64Int64V(v map[int64]int64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int64(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[int64(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int64(k2)))
- ee.EncodeInt(int64(v[int64(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapInt64Float32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt64Float32V(rv2i(rv).(map[int64]float32), e)
-}
-func (_ fastpathT) EncMapInt64Float32V(v map[int64]float32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int64(k2)))
- ee.WriteMapElemValue()
- ee.EncodeFloat32(v[int64(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int64(k2)))
- ee.EncodeFloat32(v[int64(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeFloat32(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeFloat32(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapInt64Float64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt64Float64V(rv2i(rv).(map[int64]float64), e)
-}
-func (_ fastpathT) EncMapInt64Float64V(v map[int64]float64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int64(k2)))
- ee.WriteMapElemValue()
- ee.EncodeFloat64(v[int64(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int64(k2)))
- ee.EncodeFloat64(v[int64(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeFloat64(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeFloat64(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapInt64BoolR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt64BoolV(rv2i(rv).(map[int64]bool), e)
-}
-func (_ fastpathT) EncMapInt64BoolV(v map[int64]bool, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]int64, len(v))
- var i uint
- for k := range v {
- v2[i] = int64(k)
- i++
- }
- sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int64(k2)))
- ee.WriteMapElemValue()
- ee.EncodeBool(v[int64(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int64(k2)))
- ee.EncodeBool(v[int64(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeBool(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeBool(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapBoolIntfR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapBoolIntfV(rv2i(rv).(map[bool]interface{}), e)
-}
-func (_ fastpathT) EncMapBoolIntfV(v map[bool]interface{}, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]bool, len(v))
- var i uint
- for k := range v {
- v2[i] = bool(k)
- i++
- }
- sort.Sort(boolSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeBool(bool(k2))
- ee.WriteMapElemValue()
- e.encode(v[bool(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeBool(bool(k2))
- e.encode(v[bool(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeBool(k2)
- ee.WriteMapElemValue()
- e.encode(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeBool(k2)
- e.encode(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapBoolStringR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapBoolStringV(rv2i(rv).(map[bool]string), e)
-}
-func (_ fastpathT) EncMapBoolStringV(v map[bool]string, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]bool, len(v))
- var i uint
- for k := range v {
- v2[i] = bool(k)
- i++
- }
- sort.Sort(boolSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeBool(bool(k2))
- ee.WriteMapElemValue()
- ee.EncodeStringEnc(cUTF8, v[bool(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeBool(bool(k2))
- ee.EncodeStringEnc(cUTF8, v[bool(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeBool(k2)
- ee.WriteMapElemValue()
- ee.EncodeStringEnc(cUTF8, v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeBool(k2)
- ee.EncodeStringEnc(cUTF8, v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapBoolUintR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapBoolUintV(rv2i(rv).(map[bool]uint), e)
-}
-func (_ fastpathT) EncMapBoolUintV(v map[bool]uint, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]bool, len(v))
- var i uint
- for k := range v {
- v2[i] = bool(k)
- i++
- }
- sort.Sort(boolSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeBool(bool(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[bool(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeBool(bool(k2))
- ee.EncodeUint(uint64(v[bool(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeBool(k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeBool(k2)
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapBoolUint8R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapBoolUint8V(rv2i(rv).(map[bool]uint8), e)
-}
-func (_ fastpathT) EncMapBoolUint8V(v map[bool]uint8, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]bool, len(v))
- var i uint
- for k := range v {
- v2[i] = bool(k)
- i++
- }
- sort.Sort(boolSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeBool(bool(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[bool(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeBool(bool(k2))
- ee.EncodeUint(uint64(v[bool(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeBool(k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeBool(k2)
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapBoolUint16R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapBoolUint16V(rv2i(rv).(map[bool]uint16), e)
-}
-func (_ fastpathT) EncMapBoolUint16V(v map[bool]uint16, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]bool, len(v))
- var i uint
- for k := range v {
- v2[i] = bool(k)
- i++
- }
- sort.Sort(boolSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeBool(bool(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[bool(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeBool(bool(k2))
- ee.EncodeUint(uint64(v[bool(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeBool(k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeBool(k2)
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapBoolUint32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapBoolUint32V(rv2i(rv).(map[bool]uint32), e)
-}
-func (_ fastpathT) EncMapBoolUint32V(v map[bool]uint32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]bool, len(v))
- var i uint
- for k := range v {
- v2[i] = bool(k)
- i++
- }
- sort.Sort(boolSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeBool(bool(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[bool(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeBool(bool(k2))
- ee.EncodeUint(uint64(v[bool(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeBool(k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeBool(k2)
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapBoolUint64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapBoolUint64V(rv2i(rv).(map[bool]uint64), e)
-}
-func (_ fastpathT) EncMapBoolUint64V(v map[bool]uint64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]bool, len(v))
- var i uint
- for k := range v {
- v2[i] = bool(k)
- i++
- }
- sort.Sort(boolSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeBool(bool(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[bool(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeBool(bool(k2))
- ee.EncodeUint(uint64(v[bool(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeBool(k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeBool(k2)
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapBoolUintptrR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapBoolUintptrV(rv2i(rv).(map[bool]uintptr), e)
-}
-func (_ fastpathT) EncMapBoolUintptrV(v map[bool]uintptr, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]bool, len(v))
- var i uint
- for k := range v {
- v2[i] = bool(k)
- i++
- }
- sort.Sort(boolSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeBool(bool(k2))
- ee.WriteMapElemValue()
- e.encode(v[bool(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeBool(bool(k2))
- e.encode(v[bool(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeBool(k2)
- ee.WriteMapElemValue()
- e.encode(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeBool(k2)
- e.encode(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapBoolIntR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapBoolIntV(rv2i(rv).(map[bool]int), e)
-}
-func (_ fastpathT) EncMapBoolIntV(v map[bool]int, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]bool, len(v))
- var i uint
- for k := range v {
- v2[i] = bool(k)
- i++
- }
- sort.Sort(boolSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeBool(bool(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[bool(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeBool(bool(k2))
- ee.EncodeInt(int64(v[bool(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeBool(k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeBool(k2)
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapBoolInt8R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapBoolInt8V(rv2i(rv).(map[bool]int8), e)
-}
-func (_ fastpathT) EncMapBoolInt8V(v map[bool]int8, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]bool, len(v))
- var i uint
- for k := range v {
- v2[i] = bool(k)
- i++
- }
- sort.Sort(boolSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeBool(bool(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[bool(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeBool(bool(k2))
- ee.EncodeInt(int64(v[bool(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeBool(k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeBool(k2)
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapBoolInt16R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapBoolInt16V(rv2i(rv).(map[bool]int16), e)
-}
-func (_ fastpathT) EncMapBoolInt16V(v map[bool]int16, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]bool, len(v))
- var i uint
- for k := range v {
- v2[i] = bool(k)
- i++
- }
- sort.Sort(boolSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeBool(bool(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[bool(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeBool(bool(k2))
- ee.EncodeInt(int64(v[bool(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeBool(k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeBool(k2)
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapBoolInt32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapBoolInt32V(rv2i(rv).(map[bool]int32), e)
-}
-func (_ fastpathT) EncMapBoolInt32V(v map[bool]int32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]bool, len(v))
- var i uint
- for k := range v {
- v2[i] = bool(k)
- i++
- }
- sort.Sort(boolSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeBool(bool(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[bool(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeBool(bool(k2))
- ee.EncodeInt(int64(v[bool(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeBool(k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeBool(k2)
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapBoolInt64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapBoolInt64V(rv2i(rv).(map[bool]int64), e)
-}
-func (_ fastpathT) EncMapBoolInt64V(v map[bool]int64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]bool, len(v))
- var i uint
- for k := range v {
- v2[i] = bool(k)
- i++
- }
- sort.Sort(boolSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeBool(bool(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[bool(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeBool(bool(k2))
- ee.EncodeInt(int64(v[bool(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeBool(k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeBool(k2)
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapBoolFloat32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapBoolFloat32V(rv2i(rv).(map[bool]float32), e)
-}
-func (_ fastpathT) EncMapBoolFloat32V(v map[bool]float32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]bool, len(v))
- var i uint
- for k := range v {
- v2[i] = bool(k)
- i++
- }
- sort.Sort(boolSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeBool(bool(k2))
- ee.WriteMapElemValue()
- ee.EncodeFloat32(v[bool(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeBool(bool(k2))
- ee.EncodeFloat32(v[bool(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeBool(k2)
- ee.WriteMapElemValue()
- ee.EncodeFloat32(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeBool(k2)
- ee.EncodeFloat32(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapBoolFloat64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapBoolFloat64V(rv2i(rv).(map[bool]float64), e)
-}
-func (_ fastpathT) EncMapBoolFloat64V(v map[bool]float64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]bool, len(v))
- var i uint
- for k := range v {
- v2[i] = bool(k)
- i++
- }
- sort.Sort(boolSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeBool(bool(k2))
- ee.WriteMapElemValue()
- ee.EncodeFloat64(v[bool(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeBool(bool(k2))
- ee.EncodeFloat64(v[bool(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeBool(k2)
- ee.WriteMapElemValue()
- ee.EncodeFloat64(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeBool(k2)
- ee.EncodeFloat64(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapBoolBoolR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapBoolBoolV(rv2i(rv).(map[bool]bool), e)
-}
-func (_ fastpathT) EncMapBoolBoolV(v map[bool]bool, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]bool, len(v))
- var i uint
- for k := range v {
- v2[i] = bool(k)
- i++
- }
- sort.Sort(boolSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeBool(bool(k2))
- ee.WriteMapElemValue()
- ee.EncodeBool(v[bool(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeBool(bool(k2))
- ee.EncodeBool(v[bool(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeBool(k2)
- ee.WriteMapElemValue()
- ee.EncodeBool(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeBool(k2)
- ee.EncodeBool(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-// -- decode
-
-// -- -- fast path type switch
-func fastpathDecodeTypeSwitch(iv interface{}, d *Decoder) bool {
- var changed bool
- switch v := iv.(type) {
-
- case []interface{}:
- var v2 []interface{}
- v2, changed = fastpathTV.DecSliceIntfV(v, false, d)
- if changed && len(v) > 0 && len(v2) > 0 && !(len(v2) == len(v) && &v2[0] == &v[0]) {
- copy(v, v2)
- }
- case *[]interface{}:
- var v2 []interface{}
- v2, changed = fastpathTV.DecSliceIntfV(*v, true, d)
- if changed {
- *v = v2
- }
- case []string:
- var v2 []string
- v2, changed = fastpathTV.DecSliceStringV(v, false, d)
- if changed && len(v) > 0 && len(v2) > 0 && !(len(v2) == len(v) && &v2[0] == &v[0]) {
- copy(v, v2)
- }
- case *[]string:
- var v2 []string
- v2, changed = fastpathTV.DecSliceStringV(*v, true, d)
- if changed {
- *v = v2
- }
- case []float32:
- var v2 []float32
- v2, changed = fastpathTV.DecSliceFloat32V(v, false, d)
- if changed && len(v) > 0 && len(v2) > 0 && !(len(v2) == len(v) && &v2[0] == &v[0]) {
- copy(v, v2)
- }
- case *[]float32:
- var v2 []float32
- v2, changed = fastpathTV.DecSliceFloat32V(*v, true, d)
- if changed {
- *v = v2
- }
- case []float64:
- var v2 []float64
- v2, changed = fastpathTV.DecSliceFloat64V(v, false, d)
- if changed && len(v) > 0 && len(v2) > 0 && !(len(v2) == len(v) && &v2[0] == &v[0]) {
- copy(v, v2)
- }
- case *[]float64:
- var v2 []float64
- v2, changed = fastpathTV.DecSliceFloat64V(*v, true, d)
- if changed {
- *v = v2
- }
- case []uint:
- var v2 []uint
- v2, changed = fastpathTV.DecSliceUintV(v, false, d)
- if changed && len(v) > 0 && len(v2) > 0 && !(len(v2) == len(v) && &v2[0] == &v[0]) {
- copy(v, v2)
- }
- case *[]uint:
- var v2 []uint
- v2, changed = fastpathTV.DecSliceUintV(*v, true, d)
- if changed {
- *v = v2
- }
- case []uint16:
- var v2 []uint16
- v2, changed = fastpathTV.DecSliceUint16V(v, false, d)
- if changed && len(v) > 0 && len(v2) > 0 && !(len(v2) == len(v) && &v2[0] == &v[0]) {
- copy(v, v2)
- }
- case *[]uint16:
- var v2 []uint16
- v2, changed = fastpathTV.DecSliceUint16V(*v, true, d)
- if changed {
- *v = v2
- }
- case []uint32:
- var v2 []uint32
- v2, changed = fastpathTV.DecSliceUint32V(v, false, d)
- if changed && len(v) > 0 && len(v2) > 0 && !(len(v2) == len(v) && &v2[0] == &v[0]) {
- copy(v, v2)
- }
- case *[]uint32:
- var v2 []uint32
- v2, changed = fastpathTV.DecSliceUint32V(*v, true, d)
- if changed {
- *v = v2
- }
- case []uint64:
- var v2 []uint64
- v2, changed = fastpathTV.DecSliceUint64V(v, false, d)
- if changed && len(v) > 0 && len(v2) > 0 && !(len(v2) == len(v) && &v2[0] == &v[0]) {
- copy(v, v2)
- }
- case *[]uint64:
- var v2 []uint64
- v2, changed = fastpathTV.DecSliceUint64V(*v, true, d)
- if changed {
- *v = v2
- }
- case []uintptr:
- var v2 []uintptr
- v2, changed = fastpathTV.DecSliceUintptrV(v, false, d)
- if changed && len(v) > 0 && len(v2) > 0 && !(len(v2) == len(v) && &v2[0] == &v[0]) {
- copy(v, v2)
- }
- case *[]uintptr:
- var v2 []uintptr
- v2, changed = fastpathTV.DecSliceUintptrV(*v, true, d)
- if changed {
- *v = v2
- }
- case []int:
- var v2 []int
- v2, changed = fastpathTV.DecSliceIntV(v, false, d)
- if changed && len(v) > 0 && len(v2) > 0 && !(len(v2) == len(v) && &v2[0] == &v[0]) {
- copy(v, v2)
- }
- case *[]int:
- var v2 []int
- v2, changed = fastpathTV.DecSliceIntV(*v, true, d)
- if changed {
- *v = v2
- }
- case []int8:
- var v2 []int8
- v2, changed = fastpathTV.DecSliceInt8V(v, false, d)
- if changed && len(v) > 0 && len(v2) > 0 && !(len(v2) == len(v) && &v2[0] == &v[0]) {
- copy(v, v2)
- }
- case *[]int8:
- var v2 []int8
- v2, changed = fastpathTV.DecSliceInt8V(*v, true, d)
- if changed {
- *v = v2
- }
- case []int16:
- var v2 []int16
- v2, changed = fastpathTV.DecSliceInt16V(v, false, d)
- if changed && len(v) > 0 && len(v2) > 0 && !(len(v2) == len(v) && &v2[0] == &v[0]) {
- copy(v, v2)
- }
- case *[]int16:
- var v2 []int16
- v2, changed = fastpathTV.DecSliceInt16V(*v, true, d)
- if changed {
- *v = v2
- }
- case []int32:
- var v2 []int32
- v2, changed = fastpathTV.DecSliceInt32V(v, false, d)
- if changed && len(v) > 0 && len(v2) > 0 && !(len(v2) == len(v) && &v2[0] == &v[0]) {
- copy(v, v2)
- }
- case *[]int32:
- var v2 []int32
- v2, changed = fastpathTV.DecSliceInt32V(*v, true, d)
- if changed {
- *v = v2
- }
- case []int64:
- var v2 []int64
- v2, changed = fastpathTV.DecSliceInt64V(v, false, d)
- if changed && len(v) > 0 && len(v2) > 0 && !(len(v2) == len(v) && &v2[0] == &v[0]) {
- copy(v, v2)
- }
- case *[]int64:
- var v2 []int64
- v2, changed = fastpathTV.DecSliceInt64V(*v, true, d)
- if changed {
- *v = v2
- }
- case []bool:
- var v2 []bool
- v2, changed = fastpathTV.DecSliceBoolV(v, false, d)
- if changed && len(v) > 0 && len(v2) > 0 && !(len(v2) == len(v) && &v2[0] == &v[0]) {
- copy(v, v2)
- }
- case *[]bool:
- var v2 []bool
- v2, changed = fastpathTV.DecSliceBoolV(*v, true, d)
- if changed {
- *v = v2
- }
-
- case map[interface{}]interface{}:
- fastpathTV.DecMapIntfIntfV(v, false, d)
- case *map[interface{}]interface{}:
- var v2 map[interface{}]interface{}
- v2, changed = fastpathTV.DecMapIntfIntfV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[interface{}]string:
- fastpathTV.DecMapIntfStringV(v, false, d)
- case *map[interface{}]string:
- var v2 map[interface{}]string
- v2, changed = fastpathTV.DecMapIntfStringV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[interface{}]uint:
- fastpathTV.DecMapIntfUintV(v, false, d)
- case *map[interface{}]uint:
- var v2 map[interface{}]uint
- v2, changed = fastpathTV.DecMapIntfUintV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[interface{}]uint8:
- fastpathTV.DecMapIntfUint8V(v, false, d)
- case *map[interface{}]uint8:
- var v2 map[interface{}]uint8
- v2, changed = fastpathTV.DecMapIntfUint8V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[interface{}]uint16:
- fastpathTV.DecMapIntfUint16V(v, false, d)
- case *map[interface{}]uint16:
- var v2 map[interface{}]uint16
- v2, changed = fastpathTV.DecMapIntfUint16V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[interface{}]uint32:
- fastpathTV.DecMapIntfUint32V(v, false, d)
- case *map[interface{}]uint32:
- var v2 map[interface{}]uint32
- v2, changed = fastpathTV.DecMapIntfUint32V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[interface{}]uint64:
- fastpathTV.DecMapIntfUint64V(v, false, d)
- case *map[interface{}]uint64:
- var v2 map[interface{}]uint64
- v2, changed = fastpathTV.DecMapIntfUint64V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[interface{}]uintptr:
- fastpathTV.DecMapIntfUintptrV(v, false, d)
- case *map[interface{}]uintptr:
- var v2 map[interface{}]uintptr
- v2, changed = fastpathTV.DecMapIntfUintptrV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[interface{}]int:
- fastpathTV.DecMapIntfIntV(v, false, d)
- case *map[interface{}]int:
- var v2 map[interface{}]int
- v2, changed = fastpathTV.DecMapIntfIntV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[interface{}]int8:
- fastpathTV.DecMapIntfInt8V(v, false, d)
- case *map[interface{}]int8:
- var v2 map[interface{}]int8
- v2, changed = fastpathTV.DecMapIntfInt8V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[interface{}]int16:
- fastpathTV.DecMapIntfInt16V(v, false, d)
- case *map[interface{}]int16:
- var v2 map[interface{}]int16
- v2, changed = fastpathTV.DecMapIntfInt16V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[interface{}]int32:
- fastpathTV.DecMapIntfInt32V(v, false, d)
- case *map[interface{}]int32:
- var v2 map[interface{}]int32
- v2, changed = fastpathTV.DecMapIntfInt32V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[interface{}]int64:
- fastpathTV.DecMapIntfInt64V(v, false, d)
- case *map[interface{}]int64:
- var v2 map[interface{}]int64
- v2, changed = fastpathTV.DecMapIntfInt64V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[interface{}]float32:
- fastpathTV.DecMapIntfFloat32V(v, false, d)
- case *map[interface{}]float32:
- var v2 map[interface{}]float32
- v2, changed = fastpathTV.DecMapIntfFloat32V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[interface{}]float64:
- fastpathTV.DecMapIntfFloat64V(v, false, d)
- case *map[interface{}]float64:
- var v2 map[interface{}]float64
- v2, changed = fastpathTV.DecMapIntfFloat64V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[interface{}]bool:
- fastpathTV.DecMapIntfBoolV(v, false, d)
- case *map[interface{}]bool:
- var v2 map[interface{}]bool
- v2, changed = fastpathTV.DecMapIntfBoolV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[string]interface{}:
- fastpathTV.DecMapStringIntfV(v, false, d)
- case *map[string]interface{}:
- var v2 map[string]interface{}
- v2, changed = fastpathTV.DecMapStringIntfV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[string]string:
- fastpathTV.DecMapStringStringV(v, false, d)
- case *map[string]string:
- var v2 map[string]string
- v2, changed = fastpathTV.DecMapStringStringV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[string]uint:
- fastpathTV.DecMapStringUintV(v, false, d)
- case *map[string]uint:
- var v2 map[string]uint
- v2, changed = fastpathTV.DecMapStringUintV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[string]uint8:
- fastpathTV.DecMapStringUint8V(v, false, d)
- case *map[string]uint8:
- var v2 map[string]uint8
- v2, changed = fastpathTV.DecMapStringUint8V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[string]uint16:
- fastpathTV.DecMapStringUint16V(v, false, d)
- case *map[string]uint16:
- var v2 map[string]uint16
- v2, changed = fastpathTV.DecMapStringUint16V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[string]uint32:
- fastpathTV.DecMapStringUint32V(v, false, d)
- case *map[string]uint32:
- var v2 map[string]uint32
- v2, changed = fastpathTV.DecMapStringUint32V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[string]uint64:
- fastpathTV.DecMapStringUint64V(v, false, d)
- case *map[string]uint64:
- var v2 map[string]uint64
- v2, changed = fastpathTV.DecMapStringUint64V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[string]uintptr:
- fastpathTV.DecMapStringUintptrV(v, false, d)
- case *map[string]uintptr:
- var v2 map[string]uintptr
- v2, changed = fastpathTV.DecMapStringUintptrV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[string]int:
- fastpathTV.DecMapStringIntV(v, false, d)
- case *map[string]int:
- var v2 map[string]int
- v2, changed = fastpathTV.DecMapStringIntV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[string]int8:
- fastpathTV.DecMapStringInt8V(v, false, d)
- case *map[string]int8:
- var v2 map[string]int8
- v2, changed = fastpathTV.DecMapStringInt8V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[string]int16:
- fastpathTV.DecMapStringInt16V(v, false, d)
- case *map[string]int16:
- var v2 map[string]int16
- v2, changed = fastpathTV.DecMapStringInt16V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[string]int32:
- fastpathTV.DecMapStringInt32V(v, false, d)
- case *map[string]int32:
- var v2 map[string]int32
- v2, changed = fastpathTV.DecMapStringInt32V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[string]int64:
- fastpathTV.DecMapStringInt64V(v, false, d)
- case *map[string]int64:
- var v2 map[string]int64
- v2, changed = fastpathTV.DecMapStringInt64V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[string]float32:
- fastpathTV.DecMapStringFloat32V(v, false, d)
- case *map[string]float32:
- var v2 map[string]float32
- v2, changed = fastpathTV.DecMapStringFloat32V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[string]float64:
- fastpathTV.DecMapStringFloat64V(v, false, d)
- case *map[string]float64:
- var v2 map[string]float64
- v2, changed = fastpathTV.DecMapStringFloat64V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[string]bool:
- fastpathTV.DecMapStringBoolV(v, false, d)
- case *map[string]bool:
- var v2 map[string]bool
- v2, changed = fastpathTV.DecMapStringBoolV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[float32]interface{}:
- fastpathTV.DecMapFloat32IntfV(v, false, d)
- case *map[float32]interface{}:
- var v2 map[float32]interface{}
- v2, changed = fastpathTV.DecMapFloat32IntfV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[float32]string:
- fastpathTV.DecMapFloat32StringV(v, false, d)
- case *map[float32]string:
- var v2 map[float32]string
- v2, changed = fastpathTV.DecMapFloat32StringV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[float32]uint:
- fastpathTV.DecMapFloat32UintV(v, false, d)
- case *map[float32]uint:
- var v2 map[float32]uint
- v2, changed = fastpathTV.DecMapFloat32UintV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[float32]uint8:
- fastpathTV.DecMapFloat32Uint8V(v, false, d)
- case *map[float32]uint8:
- var v2 map[float32]uint8
- v2, changed = fastpathTV.DecMapFloat32Uint8V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[float32]uint16:
- fastpathTV.DecMapFloat32Uint16V(v, false, d)
- case *map[float32]uint16:
- var v2 map[float32]uint16
- v2, changed = fastpathTV.DecMapFloat32Uint16V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[float32]uint32:
- fastpathTV.DecMapFloat32Uint32V(v, false, d)
- case *map[float32]uint32:
- var v2 map[float32]uint32
- v2, changed = fastpathTV.DecMapFloat32Uint32V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[float32]uint64:
- fastpathTV.DecMapFloat32Uint64V(v, false, d)
- case *map[float32]uint64:
- var v2 map[float32]uint64
- v2, changed = fastpathTV.DecMapFloat32Uint64V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[float32]uintptr:
- fastpathTV.DecMapFloat32UintptrV(v, false, d)
- case *map[float32]uintptr:
- var v2 map[float32]uintptr
- v2, changed = fastpathTV.DecMapFloat32UintptrV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[float32]int:
- fastpathTV.DecMapFloat32IntV(v, false, d)
- case *map[float32]int:
- var v2 map[float32]int
- v2, changed = fastpathTV.DecMapFloat32IntV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[float32]int8:
- fastpathTV.DecMapFloat32Int8V(v, false, d)
- case *map[float32]int8:
- var v2 map[float32]int8
- v2, changed = fastpathTV.DecMapFloat32Int8V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[float32]int16:
- fastpathTV.DecMapFloat32Int16V(v, false, d)
- case *map[float32]int16:
- var v2 map[float32]int16
- v2, changed = fastpathTV.DecMapFloat32Int16V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[float32]int32:
- fastpathTV.DecMapFloat32Int32V(v, false, d)
- case *map[float32]int32:
- var v2 map[float32]int32
- v2, changed = fastpathTV.DecMapFloat32Int32V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[float32]int64:
- fastpathTV.DecMapFloat32Int64V(v, false, d)
- case *map[float32]int64:
- var v2 map[float32]int64
- v2, changed = fastpathTV.DecMapFloat32Int64V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[float32]float32:
- fastpathTV.DecMapFloat32Float32V(v, false, d)
- case *map[float32]float32:
- var v2 map[float32]float32
- v2, changed = fastpathTV.DecMapFloat32Float32V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[float32]float64:
- fastpathTV.DecMapFloat32Float64V(v, false, d)
- case *map[float32]float64:
- var v2 map[float32]float64
- v2, changed = fastpathTV.DecMapFloat32Float64V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[float32]bool:
- fastpathTV.DecMapFloat32BoolV(v, false, d)
- case *map[float32]bool:
- var v2 map[float32]bool
- v2, changed = fastpathTV.DecMapFloat32BoolV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[float64]interface{}:
- fastpathTV.DecMapFloat64IntfV(v, false, d)
- case *map[float64]interface{}:
- var v2 map[float64]interface{}
- v2, changed = fastpathTV.DecMapFloat64IntfV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[float64]string:
- fastpathTV.DecMapFloat64StringV(v, false, d)
- case *map[float64]string:
- var v2 map[float64]string
- v2, changed = fastpathTV.DecMapFloat64StringV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[float64]uint:
- fastpathTV.DecMapFloat64UintV(v, false, d)
- case *map[float64]uint:
- var v2 map[float64]uint
- v2, changed = fastpathTV.DecMapFloat64UintV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[float64]uint8:
- fastpathTV.DecMapFloat64Uint8V(v, false, d)
- case *map[float64]uint8:
- var v2 map[float64]uint8
- v2, changed = fastpathTV.DecMapFloat64Uint8V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[float64]uint16:
- fastpathTV.DecMapFloat64Uint16V(v, false, d)
- case *map[float64]uint16:
- var v2 map[float64]uint16
- v2, changed = fastpathTV.DecMapFloat64Uint16V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[float64]uint32:
- fastpathTV.DecMapFloat64Uint32V(v, false, d)
- case *map[float64]uint32:
- var v2 map[float64]uint32
- v2, changed = fastpathTV.DecMapFloat64Uint32V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[float64]uint64:
- fastpathTV.DecMapFloat64Uint64V(v, false, d)
- case *map[float64]uint64:
- var v2 map[float64]uint64
- v2, changed = fastpathTV.DecMapFloat64Uint64V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[float64]uintptr:
- fastpathTV.DecMapFloat64UintptrV(v, false, d)
- case *map[float64]uintptr:
- var v2 map[float64]uintptr
- v2, changed = fastpathTV.DecMapFloat64UintptrV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[float64]int:
- fastpathTV.DecMapFloat64IntV(v, false, d)
- case *map[float64]int:
- var v2 map[float64]int
- v2, changed = fastpathTV.DecMapFloat64IntV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[float64]int8:
- fastpathTV.DecMapFloat64Int8V(v, false, d)
- case *map[float64]int8:
- var v2 map[float64]int8
- v2, changed = fastpathTV.DecMapFloat64Int8V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[float64]int16:
- fastpathTV.DecMapFloat64Int16V(v, false, d)
- case *map[float64]int16:
- var v2 map[float64]int16
- v2, changed = fastpathTV.DecMapFloat64Int16V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[float64]int32:
- fastpathTV.DecMapFloat64Int32V(v, false, d)
- case *map[float64]int32:
- var v2 map[float64]int32
- v2, changed = fastpathTV.DecMapFloat64Int32V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[float64]int64:
- fastpathTV.DecMapFloat64Int64V(v, false, d)
- case *map[float64]int64:
- var v2 map[float64]int64
- v2, changed = fastpathTV.DecMapFloat64Int64V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[float64]float32:
- fastpathTV.DecMapFloat64Float32V(v, false, d)
- case *map[float64]float32:
- var v2 map[float64]float32
- v2, changed = fastpathTV.DecMapFloat64Float32V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[float64]float64:
- fastpathTV.DecMapFloat64Float64V(v, false, d)
- case *map[float64]float64:
- var v2 map[float64]float64
- v2, changed = fastpathTV.DecMapFloat64Float64V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[float64]bool:
- fastpathTV.DecMapFloat64BoolV(v, false, d)
- case *map[float64]bool:
- var v2 map[float64]bool
- v2, changed = fastpathTV.DecMapFloat64BoolV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint]interface{}:
- fastpathTV.DecMapUintIntfV(v, false, d)
- case *map[uint]interface{}:
- var v2 map[uint]interface{}
- v2, changed = fastpathTV.DecMapUintIntfV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint]string:
- fastpathTV.DecMapUintStringV(v, false, d)
- case *map[uint]string:
- var v2 map[uint]string
- v2, changed = fastpathTV.DecMapUintStringV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint]uint:
- fastpathTV.DecMapUintUintV(v, false, d)
- case *map[uint]uint:
- var v2 map[uint]uint
- v2, changed = fastpathTV.DecMapUintUintV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint]uint8:
- fastpathTV.DecMapUintUint8V(v, false, d)
- case *map[uint]uint8:
- var v2 map[uint]uint8
- v2, changed = fastpathTV.DecMapUintUint8V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint]uint16:
- fastpathTV.DecMapUintUint16V(v, false, d)
- case *map[uint]uint16:
- var v2 map[uint]uint16
- v2, changed = fastpathTV.DecMapUintUint16V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint]uint32:
- fastpathTV.DecMapUintUint32V(v, false, d)
- case *map[uint]uint32:
- var v2 map[uint]uint32
- v2, changed = fastpathTV.DecMapUintUint32V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint]uint64:
- fastpathTV.DecMapUintUint64V(v, false, d)
- case *map[uint]uint64:
- var v2 map[uint]uint64
- v2, changed = fastpathTV.DecMapUintUint64V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint]uintptr:
- fastpathTV.DecMapUintUintptrV(v, false, d)
- case *map[uint]uintptr:
- var v2 map[uint]uintptr
- v2, changed = fastpathTV.DecMapUintUintptrV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint]int:
- fastpathTV.DecMapUintIntV(v, false, d)
- case *map[uint]int:
- var v2 map[uint]int
- v2, changed = fastpathTV.DecMapUintIntV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint]int8:
- fastpathTV.DecMapUintInt8V(v, false, d)
- case *map[uint]int8:
- var v2 map[uint]int8
- v2, changed = fastpathTV.DecMapUintInt8V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint]int16:
- fastpathTV.DecMapUintInt16V(v, false, d)
- case *map[uint]int16:
- var v2 map[uint]int16
- v2, changed = fastpathTV.DecMapUintInt16V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint]int32:
- fastpathTV.DecMapUintInt32V(v, false, d)
- case *map[uint]int32:
- var v2 map[uint]int32
- v2, changed = fastpathTV.DecMapUintInt32V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint]int64:
- fastpathTV.DecMapUintInt64V(v, false, d)
- case *map[uint]int64:
- var v2 map[uint]int64
- v2, changed = fastpathTV.DecMapUintInt64V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint]float32:
- fastpathTV.DecMapUintFloat32V(v, false, d)
- case *map[uint]float32:
- var v2 map[uint]float32
- v2, changed = fastpathTV.DecMapUintFloat32V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint]float64:
- fastpathTV.DecMapUintFloat64V(v, false, d)
- case *map[uint]float64:
- var v2 map[uint]float64
- v2, changed = fastpathTV.DecMapUintFloat64V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint]bool:
- fastpathTV.DecMapUintBoolV(v, false, d)
- case *map[uint]bool:
- var v2 map[uint]bool
- v2, changed = fastpathTV.DecMapUintBoolV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint8]interface{}:
- fastpathTV.DecMapUint8IntfV(v, false, d)
- case *map[uint8]interface{}:
- var v2 map[uint8]interface{}
- v2, changed = fastpathTV.DecMapUint8IntfV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint8]string:
- fastpathTV.DecMapUint8StringV(v, false, d)
- case *map[uint8]string:
- var v2 map[uint8]string
- v2, changed = fastpathTV.DecMapUint8StringV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint8]uint:
- fastpathTV.DecMapUint8UintV(v, false, d)
- case *map[uint8]uint:
- var v2 map[uint8]uint
- v2, changed = fastpathTV.DecMapUint8UintV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint8]uint8:
- fastpathTV.DecMapUint8Uint8V(v, false, d)
- case *map[uint8]uint8:
- var v2 map[uint8]uint8
- v2, changed = fastpathTV.DecMapUint8Uint8V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint8]uint16:
- fastpathTV.DecMapUint8Uint16V(v, false, d)
- case *map[uint8]uint16:
- var v2 map[uint8]uint16
- v2, changed = fastpathTV.DecMapUint8Uint16V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint8]uint32:
- fastpathTV.DecMapUint8Uint32V(v, false, d)
- case *map[uint8]uint32:
- var v2 map[uint8]uint32
- v2, changed = fastpathTV.DecMapUint8Uint32V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint8]uint64:
- fastpathTV.DecMapUint8Uint64V(v, false, d)
- case *map[uint8]uint64:
- var v2 map[uint8]uint64
- v2, changed = fastpathTV.DecMapUint8Uint64V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint8]uintptr:
- fastpathTV.DecMapUint8UintptrV(v, false, d)
- case *map[uint8]uintptr:
- var v2 map[uint8]uintptr
- v2, changed = fastpathTV.DecMapUint8UintptrV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint8]int:
- fastpathTV.DecMapUint8IntV(v, false, d)
- case *map[uint8]int:
- var v2 map[uint8]int
- v2, changed = fastpathTV.DecMapUint8IntV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint8]int8:
- fastpathTV.DecMapUint8Int8V(v, false, d)
- case *map[uint8]int8:
- var v2 map[uint8]int8
- v2, changed = fastpathTV.DecMapUint8Int8V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint8]int16:
- fastpathTV.DecMapUint8Int16V(v, false, d)
- case *map[uint8]int16:
- var v2 map[uint8]int16
- v2, changed = fastpathTV.DecMapUint8Int16V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint8]int32:
- fastpathTV.DecMapUint8Int32V(v, false, d)
- case *map[uint8]int32:
- var v2 map[uint8]int32
- v2, changed = fastpathTV.DecMapUint8Int32V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint8]int64:
- fastpathTV.DecMapUint8Int64V(v, false, d)
- case *map[uint8]int64:
- var v2 map[uint8]int64
- v2, changed = fastpathTV.DecMapUint8Int64V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint8]float32:
- fastpathTV.DecMapUint8Float32V(v, false, d)
- case *map[uint8]float32:
- var v2 map[uint8]float32
- v2, changed = fastpathTV.DecMapUint8Float32V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint8]float64:
- fastpathTV.DecMapUint8Float64V(v, false, d)
- case *map[uint8]float64:
- var v2 map[uint8]float64
- v2, changed = fastpathTV.DecMapUint8Float64V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint8]bool:
- fastpathTV.DecMapUint8BoolV(v, false, d)
- case *map[uint8]bool:
- var v2 map[uint8]bool
- v2, changed = fastpathTV.DecMapUint8BoolV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint16]interface{}:
- fastpathTV.DecMapUint16IntfV(v, false, d)
- case *map[uint16]interface{}:
- var v2 map[uint16]interface{}
- v2, changed = fastpathTV.DecMapUint16IntfV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint16]string:
- fastpathTV.DecMapUint16StringV(v, false, d)
- case *map[uint16]string:
- var v2 map[uint16]string
- v2, changed = fastpathTV.DecMapUint16StringV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint16]uint:
- fastpathTV.DecMapUint16UintV(v, false, d)
- case *map[uint16]uint:
- var v2 map[uint16]uint
- v2, changed = fastpathTV.DecMapUint16UintV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint16]uint8:
- fastpathTV.DecMapUint16Uint8V(v, false, d)
- case *map[uint16]uint8:
- var v2 map[uint16]uint8
- v2, changed = fastpathTV.DecMapUint16Uint8V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint16]uint16:
- fastpathTV.DecMapUint16Uint16V(v, false, d)
- case *map[uint16]uint16:
- var v2 map[uint16]uint16
- v2, changed = fastpathTV.DecMapUint16Uint16V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint16]uint32:
- fastpathTV.DecMapUint16Uint32V(v, false, d)
- case *map[uint16]uint32:
- var v2 map[uint16]uint32
- v2, changed = fastpathTV.DecMapUint16Uint32V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint16]uint64:
- fastpathTV.DecMapUint16Uint64V(v, false, d)
- case *map[uint16]uint64:
- var v2 map[uint16]uint64
- v2, changed = fastpathTV.DecMapUint16Uint64V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint16]uintptr:
- fastpathTV.DecMapUint16UintptrV(v, false, d)
- case *map[uint16]uintptr:
- var v2 map[uint16]uintptr
- v2, changed = fastpathTV.DecMapUint16UintptrV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint16]int:
- fastpathTV.DecMapUint16IntV(v, false, d)
- case *map[uint16]int:
- var v2 map[uint16]int
- v2, changed = fastpathTV.DecMapUint16IntV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint16]int8:
- fastpathTV.DecMapUint16Int8V(v, false, d)
- case *map[uint16]int8:
- var v2 map[uint16]int8
- v2, changed = fastpathTV.DecMapUint16Int8V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint16]int16:
- fastpathTV.DecMapUint16Int16V(v, false, d)
- case *map[uint16]int16:
- var v2 map[uint16]int16
- v2, changed = fastpathTV.DecMapUint16Int16V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint16]int32:
- fastpathTV.DecMapUint16Int32V(v, false, d)
- case *map[uint16]int32:
- var v2 map[uint16]int32
- v2, changed = fastpathTV.DecMapUint16Int32V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint16]int64:
- fastpathTV.DecMapUint16Int64V(v, false, d)
- case *map[uint16]int64:
- var v2 map[uint16]int64
- v2, changed = fastpathTV.DecMapUint16Int64V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint16]float32:
- fastpathTV.DecMapUint16Float32V(v, false, d)
- case *map[uint16]float32:
- var v2 map[uint16]float32
- v2, changed = fastpathTV.DecMapUint16Float32V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint16]float64:
- fastpathTV.DecMapUint16Float64V(v, false, d)
- case *map[uint16]float64:
- var v2 map[uint16]float64
- v2, changed = fastpathTV.DecMapUint16Float64V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint16]bool:
- fastpathTV.DecMapUint16BoolV(v, false, d)
- case *map[uint16]bool:
- var v2 map[uint16]bool
- v2, changed = fastpathTV.DecMapUint16BoolV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint32]interface{}:
- fastpathTV.DecMapUint32IntfV(v, false, d)
- case *map[uint32]interface{}:
- var v2 map[uint32]interface{}
- v2, changed = fastpathTV.DecMapUint32IntfV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint32]string:
- fastpathTV.DecMapUint32StringV(v, false, d)
- case *map[uint32]string:
- var v2 map[uint32]string
- v2, changed = fastpathTV.DecMapUint32StringV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint32]uint:
- fastpathTV.DecMapUint32UintV(v, false, d)
- case *map[uint32]uint:
- var v2 map[uint32]uint
- v2, changed = fastpathTV.DecMapUint32UintV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint32]uint8:
- fastpathTV.DecMapUint32Uint8V(v, false, d)
- case *map[uint32]uint8:
- var v2 map[uint32]uint8
- v2, changed = fastpathTV.DecMapUint32Uint8V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint32]uint16:
- fastpathTV.DecMapUint32Uint16V(v, false, d)
- case *map[uint32]uint16:
- var v2 map[uint32]uint16
- v2, changed = fastpathTV.DecMapUint32Uint16V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint32]uint32:
- fastpathTV.DecMapUint32Uint32V(v, false, d)
- case *map[uint32]uint32:
- var v2 map[uint32]uint32
- v2, changed = fastpathTV.DecMapUint32Uint32V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint32]uint64:
- fastpathTV.DecMapUint32Uint64V(v, false, d)
- case *map[uint32]uint64:
- var v2 map[uint32]uint64
- v2, changed = fastpathTV.DecMapUint32Uint64V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint32]uintptr:
- fastpathTV.DecMapUint32UintptrV(v, false, d)
- case *map[uint32]uintptr:
- var v2 map[uint32]uintptr
- v2, changed = fastpathTV.DecMapUint32UintptrV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint32]int:
- fastpathTV.DecMapUint32IntV(v, false, d)
- case *map[uint32]int:
- var v2 map[uint32]int
- v2, changed = fastpathTV.DecMapUint32IntV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint32]int8:
- fastpathTV.DecMapUint32Int8V(v, false, d)
- case *map[uint32]int8:
- var v2 map[uint32]int8
- v2, changed = fastpathTV.DecMapUint32Int8V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint32]int16:
- fastpathTV.DecMapUint32Int16V(v, false, d)
- case *map[uint32]int16:
- var v2 map[uint32]int16
- v2, changed = fastpathTV.DecMapUint32Int16V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint32]int32:
- fastpathTV.DecMapUint32Int32V(v, false, d)
- case *map[uint32]int32:
- var v2 map[uint32]int32
- v2, changed = fastpathTV.DecMapUint32Int32V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint32]int64:
- fastpathTV.DecMapUint32Int64V(v, false, d)
- case *map[uint32]int64:
- var v2 map[uint32]int64
- v2, changed = fastpathTV.DecMapUint32Int64V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint32]float32:
- fastpathTV.DecMapUint32Float32V(v, false, d)
- case *map[uint32]float32:
- var v2 map[uint32]float32
- v2, changed = fastpathTV.DecMapUint32Float32V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint32]float64:
- fastpathTV.DecMapUint32Float64V(v, false, d)
- case *map[uint32]float64:
- var v2 map[uint32]float64
- v2, changed = fastpathTV.DecMapUint32Float64V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint32]bool:
- fastpathTV.DecMapUint32BoolV(v, false, d)
- case *map[uint32]bool:
- var v2 map[uint32]bool
- v2, changed = fastpathTV.DecMapUint32BoolV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint64]interface{}:
- fastpathTV.DecMapUint64IntfV(v, false, d)
- case *map[uint64]interface{}:
- var v2 map[uint64]interface{}
- v2, changed = fastpathTV.DecMapUint64IntfV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint64]string:
- fastpathTV.DecMapUint64StringV(v, false, d)
- case *map[uint64]string:
- var v2 map[uint64]string
- v2, changed = fastpathTV.DecMapUint64StringV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint64]uint:
- fastpathTV.DecMapUint64UintV(v, false, d)
- case *map[uint64]uint:
- var v2 map[uint64]uint
- v2, changed = fastpathTV.DecMapUint64UintV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint64]uint8:
- fastpathTV.DecMapUint64Uint8V(v, false, d)
- case *map[uint64]uint8:
- var v2 map[uint64]uint8
- v2, changed = fastpathTV.DecMapUint64Uint8V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint64]uint16:
- fastpathTV.DecMapUint64Uint16V(v, false, d)
- case *map[uint64]uint16:
- var v2 map[uint64]uint16
- v2, changed = fastpathTV.DecMapUint64Uint16V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint64]uint32:
- fastpathTV.DecMapUint64Uint32V(v, false, d)
- case *map[uint64]uint32:
- var v2 map[uint64]uint32
- v2, changed = fastpathTV.DecMapUint64Uint32V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint64]uint64:
- fastpathTV.DecMapUint64Uint64V(v, false, d)
- case *map[uint64]uint64:
- var v2 map[uint64]uint64
- v2, changed = fastpathTV.DecMapUint64Uint64V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint64]uintptr:
- fastpathTV.DecMapUint64UintptrV(v, false, d)
- case *map[uint64]uintptr:
- var v2 map[uint64]uintptr
- v2, changed = fastpathTV.DecMapUint64UintptrV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint64]int:
- fastpathTV.DecMapUint64IntV(v, false, d)
- case *map[uint64]int:
- var v2 map[uint64]int
- v2, changed = fastpathTV.DecMapUint64IntV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint64]int8:
- fastpathTV.DecMapUint64Int8V(v, false, d)
- case *map[uint64]int8:
- var v2 map[uint64]int8
- v2, changed = fastpathTV.DecMapUint64Int8V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint64]int16:
- fastpathTV.DecMapUint64Int16V(v, false, d)
- case *map[uint64]int16:
- var v2 map[uint64]int16
- v2, changed = fastpathTV.DecMapUint64Int16V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint64]int32:
- fastpathTV.DecMapUint64Int32V(v, false, d)
- case *map[uint64]int32:
- var v2 map[uint64]int32
- v2, changed = fastpathTV.DecMapUint64Int32V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint64]int64:
- fastpathTV.DecMapUint64Int64V(v, false, d)
- case *map[uint64]int64:
- var v2 map[uint64]int64
- v2, changed = fastpathTV.DecMapUint64Int64V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint64]float32:
- fastpathTV.DecMapUint64Float32V(v, false, d)
- case *map[uint64]float32:
- var v2 map[uint64]float32
- v2, changed = fastpathTV.DecMapUint64Float32V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint64]float64:
- fastpathTV.DecMapUint64Float64V(v, false, d)
- case *map[uint64]float64:
- var v2 map[uint64]float64
- v2, changed = fastpathTV.DecMapUint64Float64V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uint64]bool:
- fastpathTV.DecMapUint64BoolV(v, false, d)
- case *map[uint64]bool:
- var v2 map[uint64]bool
- v2, changed = fastpathTV.DecMapUint64BoolV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uintptr]interface{}:
- fastpathTV.DecMapUintptrIntfV(v, false, d)
- case *map[uintptr]interface{}:
- var v2 map[uintptr]interface{}
- v2, changed = fastpathTV.DecMapUintptrIntfV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uintptr]string:
- fastpathTV.DecMapUintptrStringV(v, false, d)
- case *map[uintptr]string:
- var v2 map[uintptr]string
- v2, changed = fastpathTV.DecMapUintptrStringV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uintptr]uint:
- fastpathTV.DecMapUintptrUintV(v, false, d)
- case *map[uintptr]uint:
- var v2 map[uintptr]uint
- v2, changed = fastpathTV.DecMapUintptrUintV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uintptr]uint8:
- fastpathTV.DecMapUintptrUint8V(v, false, d)
- case *map[uintptr]uint8:
- var v2 map[uintptr]uint8
- v2, changed = fastpathTV.DecMapUintptrUint8V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uintptr]uint16:
- fastpathTV.DecMapUintptrUint16V(v, false, d)
- case *map[uintptr]uint16:
- var v2 map[uintptr]uint16
- v2, changed = fastpathTV.DecMapUintptrUint16V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uintptr]uint32:
- fastpathTV.DecMapUintptrUint32V(v, false, d)
- case *map[uintptr]uint32:
- var v2 map[uintptr]uint32
- v2, changed = fastpathTV.DecMapUintptrUint32V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uintptr]uint64:
- fastpathTV.DecMapUintptrUint64V(v, false, d)
- case *map[uintptr]uint64:
- var v2 map[uintptr]uint64
- v2, changed = fastpathTV.DecMapUintptrUint64V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uintptr]uintptr:
- fastpathTV.DecMapUintptrUintptrV(v, false, d)
- case *map[uintptr]uintptr:
- var v2 map[uintptr]uintptr
- v2, changed = fastpathTV.DecMapUintptrUintptrV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uintptr]int:
- fastpathTV.DecMapUintptrIntV(v, false, d)
- case *map[uintptr]int:
- var v2 map[uintptr]int
- v2, changed = fastpathTV.DecMapUintptrIntV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uintptr]int8:
- fastpathTV.DecMapUintptrInt8V(v, false, d)
- case *map[uintptr]int8:
- var v2 map[uintptr]int8
- v2, changed = fastpathTV.DecMapUintptrInt8V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uintptr]int16:
- fastpathTV.DecMapUintptrInt16V(v, false, d)
- case *map[uintptr]int16:
- var v2 map[uintptr]int16
- v2, changed = fastpathTV.DecMapUintptrInt16V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uintptr]int32:
- fastpathTV.DecMapUintptrInt32V(v, false, d)
- case *map[uintptr]int32:
- var v2 map[uintptr]int32
- v2, changed = fastpathTV.DecMapUintptrInt32V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uintptr]int64:
- fastpathTV.DecMapUintptrInt64V(v, false, d)
- case *map[uintptr]int64:
- var v2 map[uintptr]int64
- v2, changed = fastpathTV.DecMapUintptrInt64V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uintptr]float32:
- fastpathTV.DecMapUintptrFloat32V(v, false, d)
- case *map[uintptr]float32:
- var v2 map[uintptr]float32
- v2, changed = fastpathTV.DecMapUintptrFloat32V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uintptr]float64:
- fastpathTV.DecMapUintptrFloat64V(v, false, d)
- case *map[uintptr]float64:
- var v2 map[uintptr]float64
- v2, changed = fastpathTV.DecMapUintptrFloat64V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[uintptr]bool:
- fastpathTV.DecMapUintptrBoolV(v, false, d)
- case *map[uintptr]bool:
- var v2 map[uintptr]bool
- v2, changed = fastpathTV.DecMapUintptrBoolV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int]interface{}:
- fastpathTV.DecMapIntIntfV(v, false, d)
- case *map[int]interface{}:
- var v2 map[int]interface{}
- v2, changed = fastpathTV.DecMapIntIntfV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int]string:
- fastpathTV.DecMapIntStringV(v, false, d)
- case *map[int]string:
- var v2 map[int]string
- v2, changed = fastpathTV.DecMapIntStringV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int]uint:
- fastpathTV.DecMapIntUintV(v, false, d)
- case *map[int]uint:
- var v2 map[int]uint
- v2, changed = fastpathTV.DecMapIntUintV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int]uint8:
- fastpathTV.DecMapIntUint8V(v, false, d)
- case *map[int]uint8:
- var v2 map[int]uint8
- v2, changed = fastpathTV.DecMapIntUint8V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int]uint16:
- fastpathTV.DecMapIntUint16V(v, false, d)
- case *map[int]uint16:
- var v2 map[int]uint16
- v2, changed = fastpathTV.DecMapIntUint16V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int]uint32:
- fastpathTV.DecMapIntUint32V(v, false, d)
- case *map[int]uint32:
- var v2 map[int]uint32
- v2, changed = fastpathTV.DecMapIntUint32V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int]uint64:
- fastpathTV.DecMapIntUint64V(v, false, d)
- case *map[int]uint64:
- var v2 map[int]uint64
- v2, changed = fastpathTV.DecMapIntUint64V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int]uintptr:
- fastpathTV.DecMapIntUintptrV(v, false, d)
- case *map[int]uintptr:
- var v2 map[int]uintptr
- v2, changed = fastpathTV.DecMapIntUintptrV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int]int:
- fastpathTV.DecMapIntIntV(v, false, d)
- case *map[int]int:
- var v2 map[int]int
- v2, changed = fastpathTV.DecMapIntIntV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int]int8:
- fastpathTV.DecMapIntInt8V(v, false, d)
- case *map[int]int8:
- var v2 map[int]int8
- v2, changed = fastpathTV.DecMapIntInt8V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int]int16:
- fastpathTV.DecMapIntInt16V(v, false, d)
- case *map[int]int16:
- var v2 map[int]int16
- v2, changed = fastpathTV.DecMapIntInt16V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int]int32:
- fastpathTV.DecMapIntInt32V(v, false, d)
- case *map[int]int32:
- var v2 map[int]int32
- v2, changed = fastpathTV.DecMapIntInt32V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int]int64:
- fastpathTV.DecMapIntInt64V(v, false, d)
- case *map[int]int64:
- var v2 map[int]int64
- v2, changed = fastpathTV.DecMapIntInt64V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int]float32:
- fastpathTV.DecMapIntFloat32V(v, false, d)
- case *map[int]float32:
- var v2 map[int]float32
- v2, changed = fastpathTV.DecMapIntFloat32V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int]float64:
- fastpathTV.DecMapIntFloat64V(v, false, d)
- case *map[int]float64:
- var v2 map[int]float64
- v2, changed = fastpathTV.DecMapIntFloat64V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int]bool:
- fastpathTV.DecMapIntBoolV(v, false, d)
- case *map[int]bool:
- var v2 map[int]bool
- v2, changed = fastpathTV.DecMapIntBoolV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int8]interface{}:
- fastpathTV.DecMapInt8IntfV(v, false, d)
- case *map[int8]interface{}:
- var v2 map[int8]interface{}
- v2, changed = fastpathTV.DecMapInt8IntfV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int8]string:
- fastpathTV.DecMapInt8StringV(v, false, d)
- case *map[int8]string:
- var v2 map[int8]string
- v2, changed = fastpathTV.DecMapInt8StringV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int8]uint:
- fastpathTV.DecMapInt8UintV(v, false, d)
- case *map[int8]uint:
- var v2 map[int8]uint
- v2, changed = fastpathTV.DecMapInt8UintV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int8]uint8:
- fastpathTV.DecMapInt8Uint8V(v, false, d)
- case *map[int8]uint8:
- var v2 map[int8]uint8
- v2, changed = fastpathTV.DecMapInt8Uint8V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int8]uint16:
- fastpathTV.DecMapInt8Uint16V(v, false, d)
- case *map[int8]uint16:
- var v2 map[int8]uint16
- v2, changed = fastpathTV.DecMapInt8Uint16V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int8]uint32:
- fastpathTV.DecMapInt8Uint32V(v, false, d)
- case *map[int8]uint32:
- var v2 map[int8]uint32
- v2, changed = fastpathTV.DecMapInt8Uint32V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int8]uint64:
- fastpathTV.DecMapInt8Uint64V(v, false, d)
- case *map[int8]uint64:
- var v2 map[int8]uint64
- v2, changed = fastpathTV.DecMapInt8Uint64V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int8]uintptr:
- fastpathTV.DecMapInt8UintptrV(v, false, d)
- case *map[int8]uintptr:
- var v2 map[int8]uintptr
- v2, changed = fastpathTV.DecMapInt8UintptrV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int8]int:
- fastpathTV.DecMapInt8IntV(v, false, d)
- case *map[int8]int:
- var v2 map[int8]int
- v2, changed = fastpathTV.DecMapInt8IntV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int8]int8:
- fastpathTV.DecMapInt8Int8V(v, false, d)
- case *map[int8]int8:
- var v2 map[int8]int8
- v2, changed = fastpathTV.DecMapInt8Int8V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int8]int16:
- fastpathTV.DecMapInt8Int16V(v, false, d)
- case *map[int8]int16:
- var v2 map[int8]int16
- v2, changed = fastpathTV.DecMapInt8Int16V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int8]int32:
- fastpathTV.DecMapInt8Int32V(v, false, d)
- case *map[int8]int32:
- var v2 map[int8]int32
- v2, changed = fastpathTV.DecMapInt8Int32V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int8]int64:
- fastpathTV.DecMapInt8Int64V(v, false, d)
- case *map[int8]int64:
- var v2 map[int8]int64
- v2, changed = fastpathTV.DecMapInt8Int64V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int8]float32:
- fastpathTV.DecMapInt8Float32V(v, false, d)
- case *map[int8]float32:
- var v2 map[int8]float32
- v2, changed = fastpathTV.DecMapInt8Float32V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int8]float64:
- fastpathTV.DecMapInt8Float64V(v, false, d)
- case *map[int8]float64:
- var v2 map[int8]float64
- v2, changed = fastpathTV.DecMapInt8Float64V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int8]bool:
- fastpathTV.DecMapInt8BoolV(v, false, d)
- case *map[int8]bool:
- var v2 map[int8]bool
- v2, changed = fastpathTV.DecMapInt8BoolV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int16]interface{}:
- fastpathTV.DecMapInt16IntfV(v, false, d)
- case *map[int16]interface{}:
- var v2 map[int16]interface{}
- v2, changed = fastpathTV.DecMapInt16IntfV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int16]string:
- fastpathTV.DecMapInt16StringV(v, false, d)
- case *map[int16]string:
- var v2 map[int16]string
- v2, changed = fastpathTV.DecMapInt16StringV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int16]uint:
- fastpathTV.DecMapInt16UintV(v, false, d)
- case *map[int16]uint:
- var v2 map[int16]uint
- v2, changed = fastpathTV.DecMapInt16UintV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int16]uint8:
- fastpathTV.DecMapInt16Uint8V(v, false, d)
- case *map[int16]uint8:
- var v2 map[int16]uint8
- v2, changed = fastpathTV.DecMapInt16Uint8V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int16]uint16:
- fastpathTV.DecMapInt16Uint16V(v, false, d)
- case *map[int16]uint16:
- var v2 map[int16]uint16
- v2, changed = fastpathTV.DecMapInt16Uint16V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int16]uint32:
- fastpathTV.DecMapInt16Uint32V(v, false, d)
- case *map[int16]uint32:
- var v2 map[int16]uint32
- v2, changed = fastpathTV.DecMapInt16Uint32V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int16]uint64:
- fastpathTV.DecMapInt16Uint64V(v, false, d)
- case *map[int16]uint64:
- var v2 map[int16]uint64
- v2, changed = fastpathTV.DecMapInt16Uint64V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int16]uintptr:
- fastpathTV.DecMapInt16UintptrV(v, false, d)
- case *map[int16]uintptr:
- var v2 map[int16]uintptr
- v2, changed = fastpathTV.DecMapInt16UintptrV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int16]int:
- fastpathTV.DecMapInt16IntV(v, false, d)
- case *map[int16]int:
- var v2 map[int16]int
- v2, changed = fastpathTV.DecMapInt16IntV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int16]int8:
- fastpathTV.DecMapInt16Int8V(v, false, d)
- case *map[int16]int8:
- var v2 map[int16]int8
- v2, changed = fastpathTV.DecMapInt16Int8V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int16]int16:
- fastpathTV.DecMapInt16Int16V(v, false, d)
- case *map[int16]int16:
- var v2 map[int16]int16
- v2, changed = fastpathTV.DecMapInt16Int16V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int16]int32:
- fastpathTV.DecMapInt16Int32V(v, false, d)
- case *map[int16]int32:
- var v2 map[int16]int32
- v2, changed = fastpathTV.DecMapInt16Int32V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int16]int64:
- fastpathTV.DecMapInt16Int64V(v, false, d)
- case *map[int16]int64:
- var v2 map[int16]int64
- v2, changed = fastpathTV.DecMapInt16Int64V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int16]float32:
- fastpathTV.DecMapInt16Float32V(v, false, d)
- case *map[int16]float32:
- var v2 map[int16]float32
- v2, changed = fastpathTV.DecMapInt16Float32V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int16]float64:
- fastpathTV.DecMapInt16Float64V(v, false, d)
- case *map[int16]float64:
- var v2 map[int16]float64
- v2, changed = fastpathTV.DecMapInt16Float64V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int16]bool:
- fastpathTV.DecMapInt16BoolV(v, false, d)
- case *map[int16]bool:
- var v2 map[int16]bool
- v2, changed = fastpathTV.DecMapInt16BoolV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int32]interface{}:
- fastpathTV.DecMapInt32IntfV(v, false, d)
- case *map[int32]interface{}:
- var v2 map[int32]interface{}
- v2, changed = fastpathTV.DecMapInt32IntfV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int32]string:
- fastpathTV.DecMapInt32StringV(v, false, d)
- case *map[int32]string:
- var v2 map[int32]string
- v2, changed = fastpathTV.DecMapInt32StringV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int32]uint:
- fastpathTV.DecMapInt32UintV(v, false, d)
- case *map[int32]uint:
- var v2 map[int32]uint
- v2, changed = fastpathTV.DecMapInt32UintV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int32]uint8:
- fastpathTV.DecMapInt32Uint8V(v, false, d)
- case *map[int32]uint8:
- var v2 map[int32]uint8
- v2, changed = fastpathTV.DecMapInt32Uint8V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int32]uint16:
- fastpathTV.DecMapInt32Uint16V(v, false, d)
- case *map[int32]uint16:
- var v2 map[int32]uint16
- v2, changed = fastpathTV.DecMapInt32Uint16V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int32]uint32:
- fastpathTV.DecMapInt32Uint32V(v, false, d)
- case *map[int32]uint32:
- var v2 map[int32]uint32
- v2, changed = fastpathTV.DecMapInt32Uint32V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int32]uint64:
- fastpathTV.DecMapInt32Uint64V(v, false, d)
- case *map[int32]uint64:
- var v2 map[int32]uint64
- v2, changed = fastpathTV.DecMapInt32Uint64V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int32]uintptr:
- fastpathTV.DecMapInt32UintptrV(v, false, d)
- case *map[int32]uintptr:
- var v2 map[int32]uintptr
- v2, changed = fastpathTV.DecMapInt32UintptrV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int32]int:
- fastpathTV.DecMapInt32IntV(v, false, d)
- case *map[int32]int:
- var v2 map[int32]int
- v2, changed = fastpathTV.DecMapInt32IntV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int32]int8:
- fastpathTV.DecMapInt32Int8V(v, false, d)
- case *map[int32]int8:
- var v2 map[int32]int8
- v2, changed = fastpathTV.DecMapInt32Int8V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int32]int16:
- fastpathTV.DecMapInt32Int16V(v, false, d)
- case *map[int32]int16:
- var v2 map[int32]int16
- v2, changed = fastpathTV.DecMapInt32Int16V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int32]int32:
- fastpathTV.DecMapInt32Int32V(v, false, d)
- case *map[int32]int32:
- var v2 map[int32]int32
- v2, changed = fastpathTV.DecMapInt32Int32V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int32]int64:
- fastpathTV.DecMapInt32Int64V(v, false, d)
- case *map[int32]int64:
- var v2 map[int32]int64
- v2, changed = fastpathTV.DecMapInt32Int64V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int32]float32:
- fastpathTV.DecMapInt32Float32V(v, false, d)
- case *map[int32]float32:
- var v2 map[int32]float32
- v2, changed = fastpathTV.DecMapInt32Float32V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int32]float64:
- fastpathTV.DecMapInt32Float64V(v, false, d)
- case *map[int32]float64:
- var v2 map[int32]float64
- v2, changed = fastpathTV.DecMapInt32Float64V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int32]bool:
- fastpathTV.DecMapInt32BoolV(v, false, d)
- case *map[int32]bool:
- var v2 map[int32]bool
- v2, changed = fastpathTV.DecMapInt32BoolV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int64]interface{}:
- fastpathTV.DecMapInt64IntfV(v, false, d)
- case *map[int64]interface{}:
- var v2 map[int64]interface{}
- v2, changed = fastpathTV.DecMapInt64IntfV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int64]string:
- fastpathTV.DecMapInt64StringV(v, false, d)
- case *map[int64]string:
- var v2 map[int64]string
- v2, changed = fastpathTV.DecMapInt64StringV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int64]uint:
- fastpathTV.DecMapInt64UintV(v, false, d)
- case *map[int64]uint:
- var v2 map[int64]uint
- v2, changed = fastpathTV.DecMapInt64UintV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int64]uint8:
- fastpathTV.DecMapInt64Uint8V(v, false, d)
- case *map[int64]uint8:
- var v2 map[int64]uint8
- v2, changed = fastpathTV.DecMapInt64Uint8V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int64]uint16:
- fastpathTV.DecMapInt64Uint16V(v, false, d)
- case *map[int64]uint16:
- var v2 map[int64]uint16
- v2, changed = fastpathTV.DecMapInt64Uint16V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int64]uint32:
- fastpathTV.DecMapInt64Uint32V(v, false, d)
- case *map[int64]uint32:
- var v2 map[int64]uint32
- v2, changed = fastpathTV.DecMapInt64Uint32V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int64]uint64:
- fastpathTV.DecMapInt64Uint64V(v, false, d)
- case *map[int64]uint64:
- var v2 map[int64]uint64
- v2, changed = fastpathTV.DecMapInt64Uint64V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int64]uintptr:
- fastpathTV.DecMapInt64UintptrV(v, false, d)
- case *map[int64]uintptr:
- var v2 map[int64]uintptr
- v2, changed = fastpathTV.DecMapInt64UintptrV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int64]int:
- fastpathTV.DecMapInt64IntV(v, false, d)
- case *map[int64]int:
- var v2 map[int64]int
- v2, changed = fastpathTV.DecMapInt64IntV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int64]int8:
- fastpathTV.DecMapInt64Int8V(v, false, d)
- case *map[int64]int8:
- var v2 map[int64]int8
- v2, changed = fastpathTV.DecMapInt64Int8V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int64]int16:
- fastpathTV.DecMapInt64Int16V(v, false, d)
- case *map[int64]int16:
- var v2 map[int64]int16
- v2, changed = fastpathTV.DecMapInt64Int16V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int64]int32:
- fastpathTV.DecMapInt64Int32V(v, false, d)
- case *map[int64]int32:
- var v2 map[int64]int32
- v2, changed = fastpathTV.DecMapInt64Int32V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int64]int64:
- fastpathTV.DecMapInt64Int64V(v, false, d)
- case *map[int64]int64:
- var v2 map[int64]int64
- v2, changed = fastpathTV.DecMapInt64Int64V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int64]float32:
- fastpathTV.DecMapInt64Float32V(v, false, d)
- case *map[int64]float32:
- var v2 map[int64]float32
- v2, changed = fastpathTV.DecMapInt64Float32V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int64]float64:
- fastpathTV.DecMapInt64Float64V(v, false, d)
- case *map[int64]float64:
- var v2 map[int64]float64
- v2, changed = fastpathTV.DecMapInt64Float64V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[int64]bool:
- fastpathTV.DecMapInt64BoolV(v, false, d)
- case *map[int64]bool:
- var v2 map[int64]bool
- v2, changed = fastpathTV.DecMapInt64BoolV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[bool]interface{}:
- fastpathTV.DecMapBoolIntfV(v, false, d)
- case *map[bool]interface{}:
- var v2 map[bool]interface{}
- v2, changed = fastpathTV.DecMapBoolIntfV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[bool]string:
- fastpathTV.DecMapBoolStringV(v, false, d)
- case *map[bool]string:
- var v2 map[bool]string
- v2, changed = fastpathTV.DecMapBoolStringV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[bool]uint:
- fastpathTV.DecMapBoolUintV(v, false, d)
- case *map[bool]uint:
- var v2 map[bool]uint
- v2, changed = fastpathTV.DecMapBoolUintV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[bool]uint8:
- fastpathTV.DecMapBoolUint8V(v, false, d)
- case *map[bool]uint8:
- var v2 map[bool]uint8
- v2, changed = fastpathTV.DecMapBoolUint8V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[bool]uint16:
- fastpathTV.DecMapBoolUint16V(v, false, d)
- case *map[bool]uint16:
- var v2 map[bool]uint16
- v2, changed = fastpathTV.DecMapBoolUint16V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[bool]uint32:
- fastpathTV.DecMapBoolUint32V(v, false, d)
- case *map[bool]uint32:
- var v2 map[bool]uint32
- v2, changed = fastpathTV.DecMapBoolUint32V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[bool]uint64:
- fastpathTV.DecMapBoolUint64V(v, false, d)
- case *map[bool]uint64:
- var v2 map[bool]uint64
- v2, changed = fastpathTV.DecMapBoolUint64V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[bool]uintptr:
- fastpathTV.DecMapBoolUintptrV(v, false, d)
- case *map[bool]uintptr:
- var v2 map[bool]uintptr
- v2, changed = fastpathTV.DecMapBoolUintptrV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[bool]int:
- fastpathTV.DecMapBoolIntV(v, false, d)
- case *map[bool]int:
- var v2 map[bool]int
- v2, changed = fastpathTV.DecMapBoolIntV(*v, true, d)
- if changed {
- *v = v2
- }
- case map[bool]int8:
- fastpathTV.DecMapBoolInt8V(v, false, d)
- case *map[bool]int8:
- var v2 map[bool]int8
- v2, changed = fastpathTV.DecMapBoolInt8V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[bool]int16:
- fastpathTV.DecMapBoolInt16V(v, false, d)
- case *map[bool]int16:
- var v2 map[bool]int16
- v2, changed = fastpathTV.DecMapBoolInt16V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[bool]int32:
- fastpathTV.DecMapBoolInt32V(v, false, d)
- case *map[bool]int32:
- var v2 map[bool]int32
- v2, changed = fastpathTV.DecMapBoolInt32V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[bool]int64:
- fastpathTV.DecMapBoolInt64V(v, false, d)
- case *map[bool]int64:
- var v2 map[bool]int64
- v2, changed = fastpathTV.DecMapBoolInt64V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[bool]float32:
- fastpathTV.DecMapBoolFloat32V(v, false, d)
- case *map[bool]float32:
- var v2 map[bool]float32
- v2, changed = fastpathTV.DecMapBoolFloat32V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[bool]float64:
- fastpathTV.DecMapBoolFloat64V(v, false, d)
- case *map[bool]float64:
- var v2 map[bool]float64
- v2, changed = fastpathTV.DecMapBoolFloat64V(*v, true, d)
- if changed {
- *v = v2
- }
- case map[bool]bool:
- fastpathTV.DecMapBoolBoolV(v, false, d)
- case *map[bool]bool:
- var v2 map[bool]bool
- v2, changed = fastpathTV.DecMapBoolBoolV(*v, true, d)
- if changed {
- *v = v2
- }
- default:
- _ = v // workaround https://github.com/golang/go/issues/12927 seen in go1.4
- return false
- }
- return true
-}
-
-func fastpathDecodeSetZeroTypeSwitch(iv interface{}) bool {
- switch v := iv.(type) {
-
- case *[]interface{}:
- *v = nil
- case *[]string:
- *v = nil
- case *[]float32:
- *v = nil
- case *[]float64:
- *v = nil
- case *[]uint:
- *v = nil
- case *[]uint8:
- *v = nil
- case *[]uint16:
- *v = nil
- case *[]uint32:
- *v = nil
- case *[]uint64:
- *v = nil
- case *[]uintptr:
- *v = nil
- case *[]int:
- *v = nil
- case *[]int8:
- *v = nil
- case *[]int16:
- *v = nil
- case *[]int32:
- *v = nil
- case *[]int64:
- *v = nil
- case *[]bool:
- *v = nil
-
- case *map[interface{}]interface{}:
- *v = nil
- case *map[interface{}]string:
- *v = nil
- case *map[interface{}]uint:
- *v = nil
- case *map[interface{}]uint8:
- *v = nil
- case *map[interface{}]uint16:
- *v = nil
- case *map[interface{}]uint32:
- *v = nil
- case *map[interface{}]uint64:
- *v = nil
- case *map[interface{}]uintptr:
- *v = nil
- case *map[interface{}]int:
- *v = nil
- case *map[interface{}]int8:
- *v = nil
- case *map[interface{}]int16:
- *v = nil
- case *map[interface{}]int32:
- *v = nil
- case *map[interface{}]int64:
- *v = nil
- case *map[interface{}]float32:
- *v = nil
- case *map[interface{}]float64:
- *v = nil
- case *map[interface{}]bool:
- *v = nil
- case *map[string]interface{}:
- *v = nil
- case *map[string]string:
- *v = nil
- case *map[string]uint:
- *v = nil
- case *map[string]uint8:
- *v = nil
- case *map[string]uint16:
- *v = nil
- case *map[string]uint32:
- *v = nil
- case *map[string]uint64:
- *v = nil
- case *map[string]uintptr:
- *v = nil
- case *map[string]int:
- *v = nil
- case *map[string]int8:
- *v = nil
- case *map[string]int16:
- *v = nil
- case *map[string]int32:
- *v = nil
- case *map[string]int64:
- *v = nil
- case *map[string]float32:
- *v = nil
- case *map[string]float64:
- *v = nil
- case *map[string]bool:
- *v = nil
- case *map[float32]interface{}:
- *v = nil
- case *map[float32]string:
- *v = nil
- case *map[float32]uint:
- *v = nil
- case *map[float32]uint8:
- *v = nil
- case *map[float32]uint16:
- *v = nil
- case *map[float32]uint32:
- *v = nil
- case *map[float32]uint64:
- *v = nil
- case *map[float32]uintptr:
- *v = nil
- case *map[float32]int:
- *v = nil
- case *map[float32]int8:
- *v = nil
- case *map[float32]int16:
- *v = nil
- case *map[float32]int32:
- *v = nil
- case *map[float32]int64:
- *v = nil
- case *map[float32]float32:
- *v = nil
- case *map[float32]float64:
- *v = nil
- case *map[float32]bool:
- *v = nil
- case *map[float64]interface{}:
- *v = nil
- case *map[float64]string:
- *v = nil
- case *map[float64]uint:
- *v = nil
- case *map[float64]uint8:
- *v = nil
- case *map[float64]uint16:
- *v = nil
- case *map[float64]uint32:
- *v = nil
- case *map[float64]uint64:
- *v = nil
- case *map[float64]uintptr:
- *v = nil
- case *map[float64]int:
- *v = nil
- case *map[float64]int8:
- *v = nil
- case *map[float64]int16:
- *v = nil
- case *map[float64]int32:
- *v = nil
- case *map[float64]int64:
- *v = nil
- case *map[float64]float32:
- *v = nil
- case *map[float64]float64:
- *v = nil
- case *map[float64]bool:
- *v = nil
- case *map[uint]interface{}:
- *v = nil
- case *map[uint]string:
- *v = nil
- case *map[uint]uint:
- *v = nil
- case *map[uint]uint8:
- *v = nil
- case *map[uint]uint16:
- *v = nil
- case *map[uint]uint32:
- *v = nil
- case *map[uint]uint64:
- *v = nil
- case *map[uint]uintptr:
- *v = nil
- case *map[uint]int:
- *v = nil
- case *map[uint]int8:
- *v = nil
- case *map[uint]int16:
- *v = nil
- case *map[uint]int32:
- *v = nil
- case *map[uint]int64:
- *v = nil
- case *map[uint]float32:
- *v = nil
- case *map[uint]float64:
- *v = nil
- case *map[uint]bool:
- *v = nil
- case *map[uint8]interface{}:
- *v = nil
- case *map[uint8]string:
- *v = nil
- case *map[uint8]uint:
- *v = nil
- case *map[uint8]uint8:
- *v = nil
- case *map[uint8]uint16:
- *v = nil
- case *map[uint8]uint32:
- *v = nil
- case *map[uint8]uint64:
- *v = nil
- case *map[uint8]uintptr:
- *v = nil
- case *map[uint8]int:
- *v = nil
- case *map[uint8]int8:
- *v = nil
- case *map[uint8]int16:
- *v = nil
- case *map[uint8]int32:
- *v = nil
- case *map[uint8]int64:
- *v = nil
- case *map[uint8]float32:
- *v = nil
- case *map[uint8]float64:
- *v = nil
- case *map[uint8]bool:
- *v = nil
- case *map[uint16]interface{}:
- *v = nil
- case *map[uint16]string:
- *v = nil
- case *map[uint16]uint:
- *v = nil
- case *map[uint16]uint8:
- *v = nil
- case *map[uint16]uint16:
- *v = nil
- case *map[uint16]uint32:
- *v = nil
- case *map[uint16]uint64:
- *v = nil
- case *map[uint16]uintptr:
- *v = nil
- case *map[uint16]int:
- *v = nil
- case *map[uint16]int8:
- *v = nil
- case *map[uint16]int16:
- *v = nil
- case *map[uint16]int32:
- *v = nil
- case *map[uint16]int64:
- *v = nil
- case *map[uint16]float32:
- *v = nil
- case *map[uint16]float64:
- *v = nil
- case *map[uint16]bool:
- *v = nil
- case *map[uint32]interface{}:
- *v = nil
- case *map[uint32]string:
- *v = nil
- case *map[uint32]uint:
- *v = nil
- case *map[uint32]uint8:
- *v = nil
- case *map[uint32]uint16:
- *v = nil
- case *map[uint32]uint32:
- *v = nil
- case *map[uint32]uint64:
- *v = nil
- case *map[uint32]uintptr:
- *v = nil
- case *map[uint32]int:
- *v = nil
- case *map[uint32]int8:
- *v = nil
- case *map[uint32]int16:
- *v = nil
- case *map[uint32]int32:
- *v = nil
- case *map[uint32]int64:
- *v = nil
- case *map[uint32]float32:
- *v = nil
- case *map[uint32]float64:
- *v = nil
- case *map[uint32]bool:
- *v = nil
- case *map[uint64]interface{}:
- *v = nil
- case *map[uint64]string:
- *v = nil
- case *map[uint64]uint:
- *v = nil
- case *map[uint64]uint8:
- *v = nil
- case *map[uint64]uint16:
- *v = nil
- case *map[uint64]uint32:
- *v = nil
- case *map[uint64]uint64:
- *v = nil
- case *map[uint64]uintptr:
- *v = nil
- case *map[uint64]int:
- *v = nil
- case *map[uint64]int8:
- *v = nil
- case *map[uint64]int16:
- *v = nil
- case *map[uint64]int32:
- *v = nil
- case *map[uint64]int64:
- *v = nil
- case *map[uint64]float32:
- *v = nil
- case *map[uint64]float64:
- *v = nil
- case *map[uint64]bool:
- *v = nil
- case *map[uintptr]interface{}:
- *v = nil
- case *map[uintptr]string:
- *v = nil
- case *map[uintptr]uint:
- *v = nil
- case *map[uintptr]uint8:
- *v = nil
- case *map[uintptr]uint16:
- *v = nil
- case *map[uintptr]uint32:
- *v = nil
- case *map[uintptr]uint64:
- *v = nil
- case *map[uintptr]uintptr:
- *v = nil
- case *map[uintptr]int:
- *v = nil
- case *map[uintptr]int8:
- *v = nil
- case *map[uintptr]int16:
- *v = nil
- case *map[uintptr]int32:
- *v = nil
- case *map[uintptr]int64:
- *v = nil
- case *map[uintptr]float32:
- *v = nil
- case *map[uintptr]float64:
- *v = nil
- case *map[uintptr]bool:
- *v = nil
- case *map[int]interface{}:
- *v = nil
- case *map[int]string:
- *v = nil
- case *map[int]uint:
- *v = nil
- case *map[int]uint8:
- *v = nil
- case *map[int]uint16:
- *v = nil
- case *map[int]uint32:
- *v = nil
- case *map[int]uint64:
- *v = nil
- case *map[int]uintptr:
- *v = nil
- case *map[int]int:
- *v = nil
- case *map[int]int8:
- *v = nil
- case *map[int]int16:
- *v = nil
- case *map[int]int32:
- *v = nil
- case *map[int]int64:
- *v = nil
- case *map[int]float32:
- *v = nil
- case *map[int]float64:
- *v = nil
- case *map[int]bool:
- *v = nil
- case *map[int8]interface{}:
- *v = nil
- case *map[int8]string:
- *v = nil
- case *map[int8]uint:
- *v = nil
- case *map[int8]uint8:
- *v = nil
- case *map[int8]uint16:
- *v = nil
- case *map[int8]uint32:
- *v = nil
- case *map[int8]uint64:
- *v = nil
- case *map[int8]uintptr:
- *v = nil
- case *map[int8]int:
- *v = nil
- case *map[int8]int8:
- *v = nil
- case *map[int8]int16:
- *v = nil
- case *map[int8]int32:
- *v = nil
- case *map[int8]int64:
- *v = nil
- case *map[int8]float32:
- *v = nil
- case *map[int8]float64:
- *v = nil
- case *map[int8]bool:
- *v = nil
- case *map[int16]interface{}:
- *v = nil
- case *map[int16]string:
- *v = nil
- case *map[int16]uint:
- *v = nil
- case *map[int16]uint8:
- *v = nil
- case *map[int16]uint16:
- *v = nil
- case *map[int16]uint32:
- *v = nil
- case *map[int16]uint64:
- *v = nil
- case *map[int16]uintptr:
- *v = nil
- case *map[int16]int:
- *v = nil
- case *map[int16]int8:
- *v = nil
- case *map[int16]int16:
- *v = nil
- case *map[int16]int32:
- *v = nil
- case *map[int16]int64:
- *v = nil
- case *map[int16]float32:
- *v = nil
- case *map[int16]float64:
- *v = nil
- case *map[int16]bool:
- *v = nil
- case *map[int32]interface{}:
- *v = nil
- case *map[int32]string:
- *v = nil
- case *map[int32]uint:
- *v = nil
- case *map[int32]uint8:
- *v = nil
- case *map[int32]uint16:
- *v = nil
- case *map[int32]uint32:
- *v = nil
- case *map[int32]uint64:
- *v = nil
- case *map[int32]uintptr:
- *v = nil
- case *map[int32]int:
- *v = nil
- case *map[int32]int8:
- *v = nil
- case *map[int32]int16:
- *v = nil
- case *map[int32]int32:
- *v = nil
- case *map[int32]int64:
- *v = nil
- case *map[int32]float32:
- *v = nil
- case *map[int32]float64:
- *v = nil
- case *map[int32]bool:
- *v = nil
- case *map[int64]interface{}:
- *v = nil
- case *map[int64]string:
- *v = nil
- case *map[int64]uint:
- *v = nil
- case *map[int64]uint8:
- *v = nil
- case *map[int64]uint16:
- *v = nil
- case *map[int64]uint32:
- *v = nil
- case *map[int64]uint64:
- *v = nil
- case *map[int64]uintptr:
- *v = nil
- case *map[int64]int:
- *v = nil
- case *map[int64]int8:
- *v = nil
- case *map[int64]int16:
- *v = nil
- case *map[int64]int32:
- *v = nil
- case *map[int64]int64:
- *v = nil
- case *map[int64]float32:
- *v = nil
- case *map[int64]float64:
- *v = nil
- case *map[int64]bool:
- *v = nil
- case *map[bool]interface{}:
- *v = nil
- case *map[bool]string:
- *v = nil
- case *map[bool]uint:
- *v = nil
- case *map[bool]uint8:
- *v = nil
- case *map[bool]uint16:
- *v = nil
- case *map[bool]uint32:
- *v = nil
- case *map[bool]uint64:
- *v = nil
- case *map[bool]uintptr:
- *v = nil
- case *map[bool]int:
- *v = nil
- case *map[bool]int8:
- *v = nil
- case *map[bool]int16:
- *v = nil
- case *map[bool]int32:
- *v = nil
- case *map[bool]int64:
- *v = nil
- case *map[bool]float32:
- *v = nil
- case *map[bool]float64:
- *v = nil
- case *map[bool]bool:
- *v = nil
- default:
- _ = v // workaround https://github.com/golang/go/issues/12927 seen in go1.4
- return false
- }
- return true
-}
-
-// -- -- fast path functions
-
-func (d *Decoder) fastpathDecSliceIntfR(f *codecFnInfo, rv reflect.Value) {
- if array := f.seq == seqTypeArray; !array && rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*[]interface{})
- v, changed := fastpathTV.DecSliceIntfV(*vp, !array, d)
- if changed {
- *vp = v
- }
- } else {
- v := rv2i(rv).([]interface{})
- v2, changed := fastpathTV.DecSliceIntfV(v, !array, d)
- if changed && len(v) > 0 && len(v2) > 0 && !(len(v2) == len(v) && &v2[0] == &v[0]) {
- copy(v, v2)
- }
- }
-}
-func (f fastpathT) DecSliceIntfX(vp *[]interface{}, d *Decoder) {
- v, changed := f.DecSliceIntfV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecSliceIntfV(v []interface{}, canChange bool, d *Decoder) (_ []interface{}, changed bool) {
- dd := d.d
- slh, containerLenS := d.decSliceHelperStart()
- if containerLenS == 0 {
- if canChange {
- if v == nil {
- v = []interface{}{}
- } else if len(v) != 0 {
- v = v[:0]
- }
- changed = true
- }
- slh.End()
- return v, changed
- }
- d.depthIncr()
- hasLen := containerLenS > 0
- var xlen int
- if hasLen && canChange {
- if containerLenS > cap(v) {
- xlen = decInferLen(containerLenS, d.h.MaxInitLen, 16)
- if xlen <= cap(v) {
- v = v[:uint(xlen)]
- } else {
- v = make([]interface{}, uint(xlen))
- }
- changed = true
- } else if containerLenS != len(v) {
- v = v[:containerLenS]
- changed = true
- }
- }
- var j int
- for j = 0; (hasLen && j < containerLenS) || !(hasLen || dd.CheckBreak()); j++ {
- if j == 0 && len(v) == 0 && canChange {
- if hasLen {
- xlen = decInferLen(containerLenS, d.h.MaxInitLen, 16)
- } else {
- xlen = 8
- }
- v = make([]interface{}, uint(xlen))
- changed = true
- }
- // if indefinite, etc, then expand the slice if necessary
- var decodeIntoBlank bool
- if j >= len(v) {
- if canChange {
- v = append(v, nil)
- changed = true
- } else {
- d.arrayCannotExpand(len(v), j+1)
- decodeIntoBlank = true
- }
- }
- slh.ElemContainerState(j)
- if decodeIntoBlank {
- d.swallow()
- } else if dd.TryDecodeAsNil() {
- v[uint(j)] = nil
- } else {
- d.decode(&v[uint(j)])
- }
- }
- if canChange {
- if j < len(v) {
- v = v[:uint(j)]
- changed = true
- } else if j == 0 && v == nil {
- v = make([]interface{}, 0)
- changed = true
- }
- }
- slh.End()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecSliceStringR(f *codecFnInfo, rv reflect.Value) {
- if array := f.seq == seqTypeArray; !array && rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*[]string)
- v, changed := fastpathTV.DecSliceStringV(*vp, !array, d)
- if changed {
- *vp = v
- }
- } else {
- v := rv2i(rv).([]string)
- v2, changed := fastpathTV.DecSliceStringV(v, !array, d)
- if changed && len(v) > 0 && len(v2) > 0 && !(len(v2) == len(v) && &v2[0] == &v[0]) {
- copy(v, v2)
- }
- }
-}
-func (f fastpathT) DecSliceStringX(vp *[]string, d *Decoder) {
- v, changed := f.DecSliceStringV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecSliceStringV(v []string, canChange bool, d *Decoder) (_ []string, changed bool) {
- dd := d.d
- slh, containerLenS := d.decSliceHelperStart()
- if containerLenS == 0 {
- if canChange {
- if v == nil {
- v = []string{}
- } else if len(v) != 0 {
- v = v[:0]
- }
- changed = true
- }
- slh.End()
- return v, changed
- }
- d.depthIncr()
- hasLen := containerLenS > 0
- var xlen int
- if hasLen && canChange {
- if containerLenS > cap(v) {
- xlen = decInferLen(containerLenS, d.h.MaxInitLen, 16)
- if xlen <= cap(v) {
- v = v[:uint(xlen)]
- } else {
- v = make([]string, uint(xlen))
- }
- changed = true
- } else if containerLenS != len(v) {
- v = v[:containerLenS]
- changed = true
- }
- }
- var j int
- for j = 0; (hasLen && j < containerLenS) || !(hasLen || dd.CheckBreak()); j++ {
- if j == 0 && len(v) == 0 && canChange {
- if hasLen {
- xlen = decInferLen(containerLenS, d.h.MaxInitLen, 16)
- } else {
- xlen = 8
- }
- v = make([]string, uint(xlen))
- changed = true
- }
- // if indefinite, etc, then expand the slice if necessary
- var decodeIntoBlank bool
- if j >= len(v) {
- if canChange {
- v = append(v, "")
- changed = true
- } else {
- d.arrayCannotExpand(len(v), j+1)
- decodeIntoBlank = true
- }
- }
- slh.ElemContainerState(j)
- if decodeIntoBlank {
- d.swallow()
- } else if dd.TryDecodeAsNil() {
- v[uint(j)] = ""
- } else {
- v[uint(j)] = dd.DecodeString()
- }
- }
- if canChange {
- if j < len(v) {
- v = v[:uint(j)]
- changed = true
- } else if j == 0 && v == nil {
- v = make([]string, 0)
- changed = true
- }
- }
- slh.End()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecSliceFloat32R(f *codecFnInfo, rv reflect.Value) {
- if array := f.seq == seqTypeArray; !array && rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*[]float32)
- v, changed := fastpathTV.DecSliceFloat32V(*vp, !array, d)
- if changed {
- *vp = v
- }
- } else {
- v := rv2i(rv).([]float32)
- v2, changed := fastpathTV.DecSliceFloat32V(v, !array, d)
- if changed && len(v) > 0 && len(v2) > 0 && !(len(v2) == len(v) && &v2[0] == &v[0]) {
- copy(v, v2)
- }
- }
-}
-func (f fastpathT) DecSliceFloat32X(vp *[]float32, d *Decoder) {
- v, changed := f.DecSliceFloat32V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecSliceFloat32V(v []float32, canChange bool, d *Decoder) (_ []float32, changed bool) {
- dd := d.d
- slh, containerLenS := d.decSliceHelperStart()
- if containerLenS == 0 {
- if canChange {
- if v == nil {
- v = []float32{}
- } else if len(v) != 0 {
- v = v[:0]
- }
- changed = true
- }
- slh.End()
- return v, changed
- }
- d.depthIncr()
- hasLen := containerLenS > 0
- var xlen int
- if hasLen && canChange {
- if containerLenS > cap(v) {
- xlen = decInferLen(containerLenS, d.h.MaxInitLen, 4)
- if xlen <= cap(v) {
- v = v[:uint(xlen)]
- } else {
- v = make([]float32, uint(xlen))
- }
- changed = true
- } else if containerLenS != len(v) {
- v = v[:containerLenS]
- changed = true
- }
- }
- var j int
- for j = 0; (hasLen && j < containerLenS) || !(hasLen || dd.CheckBreak()); j++ {
- if j == 0 && len(v) == 0 && canChange {
- if hasLen {
- xlen = decInferLen(containerLenS, d.h.MaxInitLen, 4)
- } else {
- xlen = 8
- }
- v = make([]float32, uint(xlen))
- changed = true
- }
- // if indefinite, etc, then expand the slice if necessary
- var decodeIntoBlank bool
- if j >= len(v) {
- if canChange {
- v = append(v, 0)
- changed = true
- } else {
- d.arrayCannotExpand(len(v), j+1)
- decodeIntoBlank = true
- }
- }
- slh.ElemContainerState(j)
- if decodeIntoBlank {
- d.swallow()
- } else if dd.TryDecodeAsNil() {
- v[uint(j)] = 0
- } else {
- v[uint(j)] = float32(chkOvf.Float32V(dd.DecodeFloat64()))
- }
- }
- if canChange {
- if j < len(v) {
- v = v[:uint(j)]
- changed = true
- } else if j == 0 && v == nil {
- v = make([]float32, 0)
- changed = true
- }
- }
- slh.End()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecSliceFloat64R(f *codecFnInfo, rv reflect.Value) {
- if array := f.seq == seqTypeArray; !array && rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*[]float64)
- v, changed := fastpathTV.DecSliceFloat64V(*vp, !array, d)
- if changed {
- *vp = v
- }
- } else {
- v := rv2i(rv).([]float64)
- v2, changed := fastpathTV.DecSliceFloat64V(v, !array, d)
- if changed && len(v) > 0 && len(v2) > 0 && !(len(v2) == len(v) && &v2[0] == &v[0]) {
- copy(v, v2)
- }
- }
-}
-func (f fastpathT) DecSliceFloat64X(vp *[]float64, d *Decoder) {
- v, changed := f.DecSliceFloat64V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecSliceFloat64V(v []float64, canChange bool, d *Decoder) (_ []float64, changed bool) {
- dd := d.d
- slh, containerLenS := d.decSliceHelperStart()
- if containerLenS == 0 {
- if canChange {
- if v == nil {
- v = []float64{}
- } else if len(v) != 0 {
- v = v[:0]
- }
- changed = true
- }
- slh.End()
- return v, changed
- }
- d.depthIncr()
- hasLen := containerLenS > 0
- var xlen int
- if hasLen && canChange {
- if containerLenS > cap(v) {
- xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8)
- if xlen <= cap(v) {
- v = v[:uint(xlen)]
- } else {
- v = make([]float64, uint(xlen))
- }
- changed = true
- } else if containerLenS != len(v) {
- v = v[:containerLenS]
- changed = true
- }
- }
- var j int
- for j = 0; (hasLen && j < containerLenS) || !(hasLen || dd.CheckBreak()); j++ {
- if j == 0 && len(v) == 0 && canChange {
- if hasLen {
- xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8)
- } else {
- xlen = 8
- }
- v = make([]float64, uint(xlen))
- changed = true
- }
- // if indefinite, etc, then expand the slice if necessary
- var decodeIntoBlank bool
- if j >= len(v) {
- if canChange {
- v = append(v, 0)
- changed = true
- } else {
- d.arrayCannotExpand(len(v), j+1)
- decodeIntoBlank = true
- }
- }
- slh.ElemContainerState(j)
- if decodeIntoBlank {
- d.swallow()
- } else if dd.TryDecodeAsNil() {
- v[uint(j)] = 0
- } else {
- v[uint(j)] = dd.DecodeFloat64()
- }
- }
- if canChange {
- if j < len(v) {
- v = v[:uint(j)]
- changed = true
- } else if j == 0 && v == nil {
- v = make([]float64, 0)
- changed = true
- }
- }
- slh.End()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecSliceUintR(f *codecFnInfo, rv reflect.Value) {
- if array := f.seq == seqTypeArray; !array && rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*[]uint)
- v, changed := fastpathTV.DecSliceUintV(*vp, !array, d)
- if changed {
- *vp = v
- }
- } else {
- v := rv2i(rv).([]uint)
- v2, changed := fastpathTV.DecSliceUintV(v, !array, d)
- if changed && len(v) > 0 && len(v2) > 0 && !(len(v2) == len(v) && &v2[0] == &v[0]) {
- copy(v, v2)
- }
- }
-}
-func (f fastpathT) DecSliceUintX(vp *[]uint, d *Decoder) {
- v, changed := f.DecSliceUintV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecSliceUintV(v []uint, canChange bool, d *Decoder) (_ []uint, changed bool) {
- dd := d.d
- slh, containerLenS := d.decSliceHelperStart()
- if containerLenS == 0 {
- if canChange {
- if v == nil {
- v = []uint{}
- } else if len(v) != 0 {
- v = v[:0]
- }
- changed = true
- }
- slh.End()
- return v, changed
- }
- d.depthIncr()
- hasLen := containerLenS > 0
- var xlen int
- if hasLen && canChange {
- if containerLenS > cap(v) {
- xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8)
- if xlen <= cap(v) {
- v = v[:uint(xlen)]
- } else {
- v = make([]uint, uint(xlen))
- }
- changed = true
- } else if containerLenS != len(v) {
- v = v[:containerLenS]
- changed = true
- }
- }
- var j int
- for j = 0; (hasLen && j < containerLenS) || !(hasLen || dd.CheckBreak()); j++ {
- if j == 0 && len(v) == 0 && canChange {
- if hasLen {
- xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8)
- } else {
- xlen = 8
- }
- v = make([]uint, uint(xlen))
- changed = true
- }
- // if indefinite, etc, then expand the slice if necessary
- var decodeIntoBlank bool
- if j >= len(v) {
- if canChange {
- v = append(v, 0)
- changed = true
- } else {
- d.arrayCannotExpand(len(v), j+1)
- decodeIntoBlank = true
- }
- }
- slh.ElemContainerState(j)
- if decodeIntoBlank {
- d.swallow()
- } else if dd.TryDecodeAsNil() {
- v[uint(j)] = 0
- } else {
- v[uint(j)] = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- }
- }
- if canChange {
- if j < len(v) {
- v = v[:uint(j)]
- changed = true
- } else if j == 0 && v == nil {
- v = make([]uint, 0)
- changed = true
- }
- }
- slh.End()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecSliceUint8R(f *codecFnInfo, rv reflect.Value) {
- if array := f.seq == seqTypeArray; !array && rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*[]uint8)
- v, changed := fastpathTV.DecSliceUint8V(*vp, !array, d)
- if changed {
- *vp = v
- }
- } else {
- v := rv2i(rv).([]uint8)
- v2, changed := fastpathTV.DecSliceUint8V(v, !array, d)
- if changed && len(v) > 0 && len(v2) > 0 && !(len(v2) == len(v) && &v2[0] == &v[0]) {
- copy(v, v2)
- }
- }
-}
-func (f fastpathT) DecSliceUint8X(vp *[]uint8, d *Decoder) {
- v, changed := f.DecSliceUint8V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecSliceUint8V(v []uint8, canChange bool, d *Decoder) (_ []uint8, changed bool) {
- dd := d.d
- slh, containerLenS := d.decSliceHelperStart()
- if containerLenS == 0 {
- if canChange {
- if v == nil {
- v = []uint8{}
- } else if len(v) != 0 {
- v = v[:0]
- }
- changed = true
- }
- slh.End()
- return v, changed
- }
- d.depthIncr()
- hasLen := containerLenS > 0
- var xlen int
- if hasLen && canChange {
- if containerLenS > cap(v) {
- xlen = decInferLen(containerLenS, d.h.MaxInitLen, 1)
- if xlen <= cap(v) {
- v = v[:uint(xlen)]
- } else {
- v = make([]uint8, uint(xlen))
- }
- changed = true
- } else if containerLenS != len(v) {
- v = v[:containerLenS]
- changed = true
- }
- }
- var j int
- for j = 0; (hasLen && j < containerLenS) || !(hasLen || dd.CheckBreak()); j++ {
- if j == 0 && len(v) == 0 && canChange {
- if hasLen {
- xlen = decInferLen(containerLenS, d.h.MaxInitLen, 1)
- } else {
- xlen = 8
- }
- v = make([]uint8, uint(xlen))
- changed = true
- }
- // if indefinite, etc, then expand the slice if necessary
- var decodeIntoBlank bool
- if j >= len(v) {
- if canChange {
- v = append(v, 0)
- changed = true
- } else {
- d.arrayCannotExpand(len(v), j+1)
- decodeIntoBlank = true
- }
- }
- slh.ElemContainerState(j)
- if decodeIntoBlank {
- d.swallow()
- } else if dd.TryDecodeAsNil() {
- v[uint(j)] = 0
- } else {
- v[uint(j)] = uint8(chkOvf.UintV(dd.DecodeUint64(), 8))
- }
- }
- if canChange {
- if j < len(v) {
- v = v[:uint(j)]
- changed = true
- } else if j == 0 && v == nil {
- v = make([]uint8, 0)
- changed = true
- }
- }
- slh.End()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecSliceUint16R(f *codecFnInfo, rv reflect.Value) {
- if array := f.seq == seqTypeArray; !array && rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*[]uint16)
- v, changed := fastpathTV.DecSliceUint16V(*vp, !array, d)
- if changed {
- *vp = v
- }
- } else {
- v := rv2i(rv).([]uint16)
- v2, changed := fastpathTV.DecSliceUint16V(v, !array, d)
- if changed && len(v) > 0 && len(v2) > 0 && !(len(v2) == len(v) && &v2[0] == &v[0]) {
- copy(v, v2)
- }
- }
-}
-func (f fastpathT) DecSliceUint16X(vp *[]uint16, d *Decoder) {
- v, changed := f.DecSliceUint16V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecSliceUint16V(v []uint16, canChange bool, d *Decoder) (_ []uint16, changed bool) {
- dd := d.d
- slh, containerLenS := d.decSliceHelperStart()
- if containerLenS == 0 {
- if canChange {
- if v == nil {
- v = []uint16{}
- } else if len(v) != 0 {
- v = v[:0]
- }
- changed = true
- }
- slh.End()
- return v, changed
- }
- d.depthIncr()
- hasLen := containerLenS > 0
- var xlen int
- if hasLen && canChange {
- if containerLenS > cap(v) {
- xlen = decInferLen(containerLenS, d.h.MaxInitLen, 2)
- if xlen <= cap(v) {
- v = v[:uint(xlen)]
- } else {
- v = make([]uint16, uint(xlen))
- }
- changed = true
- } else if containerLenS != len(v) {
- v = v[:containerLenS]
- changed = true
- }
- }
- var j int
- for j = 0; (hasLen && j < containerLenS) || !(hasLen || dd.CheckBreak()); j++ {
- if j == 0 && len(v) == 0 && canChange {
- if hasLen {
- xlen = decInferLen(containerLenS, d.h.MaxInitLen, 2)
- } else {
- xlen = 8
- }
- v = make([]uint16, uint(xlen))
- changed = true
- }
- // if indefinite, etc, then expand the slice if necessary
- var decodeIntoBlank bool
- if j >= len(v) {
- if canChange {
- v = append(v, 0)
- changed = true
- } else {
- d.arrayCannotExpand(len(v), j+1)
- decodeIntoBlank = true
- }
- }
- slh.ElemContainerState(j)
- if decodeIntoBlank {
- d.swallow()
- } else if dd.TryDecodeAsNil() {
- v[uint(j)] = 0
- } else {
- v[uint(j)] = uint16(chkOvf.UintV(dd.DecodeUint64(), 16))
- }
- }
- if canChange {
- if j < len(v) {
- v = v[:uint(j)]
- changed = true
- } else if j == 0 && v == nil {
- v = make([]uint16, 0)
- changed = true
- }
- }
- slh.End()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecSliceUint32R(f *codecFnInfo, rv reflect.Value) {
- if array := f.seq == seqTypeArray; !array && rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*[]uint32)
- v, changed := fastpathTV.DecSliceUint32V(*vp, !array, d)
- if changed {
- *vp = v
- }
- } else {
- v := rv2i(rv).([]uint32)
- v2, changed := fastpathTV.DecSliceUint32V(v, !array, d)
- if changed && len(v) > 0 && len(v2) > 0 && !(len(v2) == len(v) && &v2[0] == &v[0]) {
- copy(v, v2)
- }
- }
-}
-func (f fastpathT) DecSliceUint32X(vp *[]uint32, d *Decoder) {
- v, changed := f.DecSliceUint32V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecSliceUint32V(v []uint32, canChange bool, d *Decoder) (_ []uint32, changed bool) {
- dd := d.d
- slh, containerLenS := d.decSliceHelperStart()
- if containerLenS == 0 {
- if canChange {
- if v == nil {
- v = []uint32{}
- } else if len(v) != 0 {
- v = v[:0]
- }
- changed = true
- }
- slh.End()
- return v, changed
- }
- d.depthIncr()
- hasLen := containerLenS > 0
- var xlen int
- if hasLen && canChange {
- if containerLenS > cap(v) {
- xlen = decInferLen(containerLenS, d.h.MaxInitLen, 4)
- if xlen <= cap(v) {
- v = v[:uint(xlen)]
- } else {
- v = make([]uint32, uint(xlen))
- }
- changed = true
- } else if containerLenS != len(v) {
- v = v[:containerLenS]
- changed = true
- }
- }
- var j int
- for j = 0; (hasLen && j < containerLenS) || !(hasLen || dd.CheckBreak()); j++ {
- if j == 0 && len(v) == 0 && canChange {
- if hasLen {
- xlen = decInferLen(containerLenS, d.h.MaxInitLen, 4)
- } else {
- xlen = 8
- }
- v = make([]uint32, uint(xlen))
- changed = true
- }
- // if indefinite, etc, then expand the slice if necessary
- var decodeIntoBlank bool
- if j >= len(v) {
- if canChange {
- v = append(v, 0)
- changed = true
- } else {
- d.arrayCannotExpand(len(v), j+1)
- decodeIntoBlank = true
- }
- }
- slh.ElemContainerState(j)
- if decodeIntoBlank {
- d.swallow()
- } else if dd.TryDecodeAsNil() {
- v[uint(j)] = 0
- } else {
- v[uint(j)] = uint32(chkOvf.UintV(dd.DecodeUint64(), 32))
- }
- }
- if canChange {
- if j < len(v) {
- v = v[:uint(j)]
- changed = true
- } else if j == 0 && v == nil {
- v = make([]uint32, 0)
- changed = true
- }
- }
- slh.End()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecSliceUint64R(f *codecFnInfo, rv reflect.Value) {
- if array := f.seq == seqTypeArray; !array && rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*[]uint64)
- v, changed := fastpathTV.DecSliceUint64V(*vp, !array, d)
- if changed {
- *vp = v
- }
- } else {
- v := rv2i(rv).([]uint64)
- v2, changed := fastpathTV.DecSliceUint64V(v, !array, d)
- if changed && len(v) > 0 && len(v2) > 0 && !(len(v2) == len(v) && &v2[0] == &v[0]) {
- copy(v, v2)
- }
- }
-}
-func (f fastpathT) DecSliceUint64X(vp *[]uint64, d *Decoder) {
- v, changed := f.DecSliceUint64V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecSliceUint64V(v []uint64, canChange bool, d *Decoder) (_ []uint64, changed bool) {
- dd := d.d
- slh, containerLenS := d.decSliceHelperStart()
- if containerLenS == 0 {
- if canChange {
- if v == nil {
- v = []uint64{}
- } else if len(v) != 0 {
- v = v[:0]
- }
- changed = true
- }
- slh.End()
- return v, changed
- }
- d.depthIncr()
- hasLen := containerLenS > 0
- var xlen int
- if hasLen && canChange {
- if containerLenS > cap(v) {
- xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8)
- if xlen <= cap(v) {
- v = v[:uint(xlen)]
- } else {
- v = make([]uint64, uint(xlen))
- }
- changed = true
- } else if containerLenS != len(v) {
- v = v[:containerLenS]
- changed = true
- }
- }
- var j int
- for j = 0; (hasLen && j < containerLenS) || !(hasLen || dd.CheckBreak()); j++ {
- if j == 0 && len(v) == 0 && canChange {
- if hasLen {
- xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8)
- } else {
- xlen = 8
- }
- v = make([]uint64, uint(xlen))
- changed = true
- }
- // if indefinite, etc, then expand the slice if necessary
- var decodeIntoBlank bool
- if j >= len(v) {
- if canChange {
- v = append(v, 0)
- changed = true
- } else {
- d.arrayCannotExpand(len(v), j+1)
- decodeIntoBlank = true
- }
- }
- slh.ElemContainerState(j)
- if decodeIntoBlank {
- d.swallow()
- } else if dd.TryDecodeAsNil() {
- v[uint(j)] = 0
- } else {
- v[uint(j)] = dd.DecodeUint64()
- }
- }
- if canChange {
- if j < len(v) {
- v = v[:uint(j)]
- changed = true
- } else if j == 0 && v == nil {
- v = make([]uint64, 0)
- changed = true
- }
- }
- slh.End()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecSliceUintptrR(f *codecFnInfo, rv reflect.Value) {
- if array := f.seq == seqTypeArray; !array && rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*[]uintptr)
- v, changed := fastpathTV.DecSliceUintptrV(*vp, !array, d)
- if changed {
- *vp = v
- }
- } else {
- v := rv2i(rv).([]uintptr)
- v2, changed := fastpathTV.DecSliceUintptrV(v, !array, d)
- if changed && len(v) > 0 && len(v2) > 0 && !(len(v2) == len(v) && &v2[0] == &v[0]) {
- copy(v, v2)
- }
- }
-}
-func (f fastpathT) DecSliceUintptrX(vp *[]uintptr, d *Decoder) {
- v, changed := f.DecSliceUintptrV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecSliceUintptrV(v []uintptr, canChange bool, d *Decoder) (_ []uintptr, changed bool) {
- dd := d.d
- slh, containerLenS := d.decSliceHelperStart()
- if containerLenS == 0 {
- if canChange {
- if v == nil {
- v = []uintptr{}
- } else if len(v) != 0 {
- v = v[:0]
- }
- changed = true
- }
- slh.End()
- return v, changed
- }
- d.depthIncr()
- hasLen := containerLenS > 0
- var xlen int
- if hasLen && canChange {
- if containerLenS > cap(v) {
- xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8)
- if xlen <= cap(v) {
- v = v[:uint(xlen)]
- } else {
- v = make([]uintptr, uint(xlen))
- }
- changed = true
- } else if containerLenS != len(v) {
- v = v[:containerLenS]
- changed = true
- }
- }
- var j int
- for j = 0; (hasLen && j < containerLenS) || !(hasLen || dd.CheckBreak()); j++ {
- if j == 0 && len(v) == 0 && canChange {
- if hasLen {
- xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8)
- } else {
- xlen = 8
- }
- v = make([]uintptr, uint(xlen))
- changed = true
- }
- // if indefinite, etc, then expand the slice if necessary
- var decodeIntoBlank bool
- if j >= len(v) {
- if canChange {
- v = append(v, 0)
- changed = true
- } else {
- d.arrayCannotExpand(len(v), j+1)
- decodeIntoBlank = true
- }
- }
- slh.ElemContainerState(j)
- if decodeIntoBlank {
- d.swallow()
- } else if dd.TryDecodeAsNil() {
- v[uint(j)] = 0
- } else {
- v[uint(j)] = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- }
- }
- if canChange {
- if j < len(v) {
- v = v[:uint(j)]
- changed = true
- } else if j == 0 && v == nil {
- v = make([]uintptr, 0)
- changed = true
- }
- }
- slh.End()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecSliceIntR(f *codecFnInfo, rv reflect.Value) {
- if array := f.seq == seqTypeArray; !array && rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*[]int)
- v, changed := fastpathTV.DecSliceIntV(*vp, !array, d)
- if changed {
- *vp = v
- }
- } else {
- v := rv2i(rv).([]int)
- v2, changed := fastpathTV.DecSliceIntV(v, !array, d)
- if changed && len(v) > 0 && len(v2) > 0 && !(len(v2) == len(v) && &v2[0] == &v[0]) {
- copy(v, v2)
- }
- }
-}
-func (f fastpathT) DecSliceIntX(vp *[]int, d *Decoder) {
- v, changed := f.DecSliceIntV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecSliceIntV(v []int, canChange bool, d *Decoder) (_ []int, changed bool) {
- dd := d.d
- slh, containerLenS := d.decSliceHelperStart()
- if containerLenS == 0 {
- if canChange {
- if v == nil {
- v = []int{}
- } else if len(v) != 0 {
- v = v[:0]
- }
- changed = true
- }
- slh.End()
- return v, changed
- }
- d.depthIncr()
- hasLen := containerLenS > 0
- var xlen int
- if hasLen && canChange {
- if containerLenS > cap(v) {
- xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8)
- if xlen <= cap(v) {
- v = v[:uint(xlen)]
- } else {
- v = make([]int, uint(xlen))
- }
- changed = true
- } else if containerLenS != len(v) {
- v = v[:containerLenS]
- changed = true
- }
- }
- var j int
- for j = 0; (hasLen && j < containerLenS) || !(hasLen || dd.CheckBreak()); j++ {
- if j == 0 && len(v) == 0 && canChange {
- if hasLen {
- xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8)
- } else {
- xlen = 8
- }
- v = make([]int, uint(xlen))
- changed = true
- }
- // if indefinite, etc, then expand the slice if necessary
- var decodeIntoBlank bool
- if j >= len(v) {
- if canChange {
- v = append(v, 0)
- changed = true
- } else {
- d.arrayCannotExpand(len(v), j+1)
- decodeIntoBlank = true
- }
- }
- slh.ElemContainerState(j)
- if decodeIntoBlank {
- d.swallow()
- } else if dd.TryDecodeAsNil() {
- v[uint(j)] = 0
- } else {
- v[uint(j)] = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize))
- }
- }
- if canChange {
- if j < len(v) {
- v = v[:uint(j)]
- changed = true
- } else if j == 0 && v == nil {
- v = make([]int, 0)
- changed = true
- }
- }
- slh.End()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecSliceInt8R(f *codecFnInfo, rv reflect.Value) {
- if array := f.seq == seqTypeArray; !array && rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*[]int8)
- v, changed := fastpathTV.DecSliceInt8V(*vp, !array, d)
- if changed {
- *vp = v
- }
- } else {
- v := rv2i(rv).([]int8)
- v2, changed := fastpathTV.DecSliceInt8V(v, !array, d)
- if changed && len(v) > 0 && len(v2) > 0 && !(len(v2) == len(v) && &v2[0] == &v[0]) {
- copy(v, v2)
- }
- }
-}
-func (f fastpathT) DecSliceInt8X(vp *[]int8, d *Decoder) {
- v, changed := f.DecSliceInt8V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecSliceInt8V(v []int8, canChange bool, d *Decoder) (_ []int8, changed bool) {
- dd := d.d
- slh, containerLenS := d.decSliceHelperStart()
- if containerLenS == 0 {
- if canChange {
- if v == nil {
- v = []int8{}
- } else if len(v) != 0 {
- v = v[:0]
- }
- changed = true
- }
- slh.End()
- return v, changed
- }
- d.depthIncr()
- hasLen := containerLenS > 0
- var xlen int
- if hasLen && canChange {
- if containerLenS > cap(v) {
- xlen = decInferLen(containerLenS, d.h.MaxInitLen, 1)
- if xlen <= cap(v) {
- v = v[:uint(xlen)]
- } else {
- v = make([]int8, uint(xlen))
- }
- changed = true
- } else if containerLenS != len(v) {
- v = v[:containerLenS]
- changed = true
- }
- }
- var j int
- for j = 0; (hasLen && j < containerLenS) || !(hasLen || dd.CheckBreak()); j++ {
- if j == 0 && len(v) == 0 && canChange {
- if hasLen {
- xlen = decInferLen(containerLenS, d.h.MaxInitLen, 1)
- } else {
- xlen = 8
- }
- v = make([]int8, uint(xlen))
- changed = true
- }
- // if indefinite, etc, then expand the slice if necessary
- var decodeIntoBlank bool
- if j >= len(v) {
- if canChange {
- v = append(v, 0)
- changed = true
- } else {
- d.arrayCannotExpand(len(v), j+1)
- decodeIntoBlank = true
- }
- }
- slh.ElemContainerState(j)
- if decodeIntoBlank {
- d.swallow()
- } else if dd.TryDecodeAsNil() {
- v[uint(j)] = 0
- } else {
- v[uint(j)] = int8(chkOvf.IntV(dd.DecodeInt64(), 8))
- }
- }
- if canChange {
- if j < len(v) {
- v = v[:uint(j)]
- changed = true
- } else if j == 0 && v == nil {
- v = make([]int8, 0)
- changed = true
- }
- }
- slh.End()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecSliceInt16R(f *codecFnInfo, rv reflect.Value) {
- if array := f.seq == seqTypeArray; !array && rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*[]int16)
- v, changed := fastpathTV.DecSliceInt16V(*vp, !array, d)
- if changed {
- *vp = v
- }
- } else {
- v := rv2i(rv).([]int16)
- v2, changed := fastpathTV.DecSliceInt16V(v, !array, d)
- if changed && len(v) > 0 && len(v2) > 0 && !(len(v2) == len(v) && &v2[0] == &v[0]) {
- copy(v, v2)
- }
- }
-}
-func (f fastpathT) DecSliceInt16X(vp *[]int16, d *Decoder) {
- v, changed := f.DecSliceInt16V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecSliceInt16V(v []int16, canChange bool, d *Decoder) (_ []int16, changed bool) {
- dd := d.d
- slh, containerLenS := d.decSliceHelperStart()
- if containerLenS == 0 {
- if canChange {
- if v == nil {
- v = []int16{}
- } else if len(v) != 0 {
- v = v[:0]
- }
- changed = true
- }
- slh.End()
- return v, changed
- }
- d.depthIncr()
- hasLen := containerLenS > 0
- var xlen int
- if hasLen && canChange {
- if containerLenS > cap(v) {
- xlen = decInferLen(containerLenS, d.h.MaxInitLen, 2)
- if xlen <= cap(v) {
- v = v[:uint(xlen)]
- } else {
- v = make([]int16, uint(xlen))
- }
- changed = true
- } else if containerLenS != len(v) {
- v = v[:containerLenS]
- changed = true
- }
- }
- var j int
- for j = 0; (hasLen && j < containerLenS) || !(hasLen || dd.CheckBreak()); j++ {
- if j == 0 && len(v) == 0 && canChange {
- if hasLen {
- xlen = decInferLen(containerLenS, d.h.MaxInitLen, 2)
- } else {
- xlen = 8
- }
- v = make([]int16, uint(xlen))
- changed = true
- }
- // if indefinite, etc, then expand the slice if necessary
- var decodeIntoBlank bool
- if j >= len(v) {
- if canChange {
- v = append(v, 0)
- changed = true
- } else {
- d.arrayCannotExpand(len(v), j+1)
- decodeIntoBlank = true
- }
- }
- slh.ElemContainerState(j)
- if decodeIntoBlank {
- d.swallow()
- } else if dd.TryDecodeAsNil() {
- v[uint(j)] = 0
- } else {
- v[uint(j)] = int16(chkOvf.IntV(dd.DecodeInt64(), 16))
- }
- }
- if canChange {
- if j < len(v) {
- v = v[:uint(j)]
- changed = true
- } else if j == 0 && v == nil {
- v = make([]int16, 0)
- changed = true
- }
- }
- slh.End()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecSliceInt32R(f *codecFnInfo, rv reflect.Value) {
- if array := f.seq == seqTypeArray; !array && rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*[]int32)
- v, changed := fastpathTV.DecSliceInt32V(*vp, !array, d)
- if changed {
- *vp = v
- }
- } else {
- v := rv2i(rv).([]int32)
- v2, changed := fastpathTV.DecSliceInt32V(v, !array, d)
- if changed && len(v) > 0 && len(v2) > 0 && !(len(v2) == len(v) && &v2[0] == &v[0]) {
- copy(v, v2)
- }
- }
-}
-func (f fastpathT) DecSliceInt32X(vp *[]int32, d *Decoder) {
- v, changed := f.DecSliceInt32V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecSliceInt32V(v []int32, canChange bool, d *Decoder) (_ []int32, changed bool) {
- dd := d.d
- slh, containerLenS := d.decSliceHelperStart()
- if containerLenS == 0 {
- if canChange {
- if v == nil {
- v = []int32{}
- } else if len(v) != 0 {
- v = v[:0]
- }
- changed = true
- }
- slh.End()
- return v, changed
- }
- d.depthIncr()
- hasLen := containerLenS > 0
- var xlen int
- if hasLen && canChange {
- if containerLenS > cap(v) {
- xlen = decInferLen(containerLenS, d.h.MaxInitLen, 4)
- if xlen <= cap(v) {
- v = v[:uint(xlen)]
- } else {
- v = make([]int32, uint(xlen))
- }
- changed = true
- } else if containerLenS != len(v) {
- v = v[:containerLenS]
- changed = true
- }
- }
- var j int
- for j = 0; (hasLen && j < containerLenS) || !(hasLen || dd.CheckBreak()); j++ {
- if j == 0 && len(v) == 0 && canChange {
- if hasLen {
- xlen = decInferLen(containerLenS, d.h.MaxInitLen, 4)
- } else {
- xlen = 8
- }
- v = make([]int32, uint(xlen))
- changed = true
- }
- // if indefinite, etc, then expand the slice if necessary
- var decodeIntoBlank bool
- if j >= len(v) {
- if canChange {
- v = append(v, 0)
- changed = true
- } else {
- d.arrayCannotExpand(len(v), j+1)
- decodeIntoBlank = true
- }
- }
- slh.ElemContainerState(j)
- if decodeIntoBlank {
- d.swallow()
- } else if dd.TryDecodeAsNil() {
- v[uint(j)] = 0
- } else {
- v[uint(j)] = int32(chkOvf.IntV(dd.DecodeInt64(), 32))
- }
- }
- if canChange {
- if j < len(v) {
- v = v[:uint(j)]
- changed = true
- } else if j == 0 && v == nil {
- v = make([]int32, 0)
- changed = true
- }
- }
- slh.End()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecSliceInt64R(f *codecFnInfo, rv reflect.Value) {
- if array := f.seq == seqTypeArray; !array && rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*[]int64)
- v, changed := fastpathTV.DecSliceInt64V(*vp, !array, d)
- if changed {
- *vp = v
- }
- } else {
- v := rv2i(rv).([]int64)
- v2, changed := fastpathTV.DecSliceInt64V(v, !array, d)
- if changed && len(v) > 0 && len(v2) > 0 && !(len(v2) == len(v) && &v2[0] == &v[0]) {
- copy(v, v2)
- }
- }
-}
-func (f fastpathT) DecSliceInt64X(vp *[]int64, d *Decoder) {
- v, changed := f.DecSliceInt64V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecSliceInt64V(v []int64, canChange bool, d *Decoder) (_ []int64, changed bool) {
- dd := d.d
- slh, containerLenS := d.decSliceHelperStart()
- if containerLenS == 0 {
- if canChange {
- if v == nil {
- v = []int64{}
- } else if len(v) != 0 {
- v = v[:0]
- }
- changed = true
- }
- slh.End()
- return v, changed
- }
- d.depthIncr()
- hasLen := containerLenS > 0
- var xlen int
- if hasLen && canChange {
- if containerLenS > cap(v) {
- xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8)
- if xlen <= cap(v) {
- v = v[:uint(xlen)]
- } else {
- v = make([]int64, uint(xlen))
- }
- changed = true
- } else if containerLenS != len(v) {
- v = v[:containerLenS]
- changed = true
- }
- }
- var j int
- for j = 0; (hasLen && j < containerLenS) || !(hasLen || dd.CheckBreak()); j++ {
- if j == 0 && len(v) == 0 && canChange {
- if hasLen {
- xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8)
- } else {
- xlen = 8
- }
- v = make([]int64, uint(xlen))
- changed = true
- }
- // if indefinite, etc, then expand the slice if necessary
- var decodeIntoBlank bool
- if j >= len(v) {
- if canChange {
- v = append(v, 0)
- changed = true
- } else {
- d.arrayCannotExpand(len(v), j+1)
- decodeIntoBlank = true
- }
- }
- slh.ElemContainerState(j)
- if decodeIntoBlank {
- d.swallow()
- } else if dd.TryDecodeAsNil() {
- v[uint(j)] = 0
- } else {
- v[uint(j)] = dd.DecodeInt64()
- }
- }
- if canChange {
- if j < len(v) {
- v = v[:uint(j)]
- changed = true
- } else if j == 0 && v == nil {
- v = make([]int64, 0)
- changed = true
- }
- }
- slh.End()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecSliceBoolR(f *codecFnInfo, rv reflect.Value) {
- if array := f.seq == seqTypeArray; !array && rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*[]bool)
- v, changed := fastpathTV.DecSliceBoolV(*vp, !array, d)
- if changed {
- *vp = v
- }
- } else {
- v := rv2i(rv).([]bool)
- v2, changed := fastpathTV.DecSliceBoolV(v, !array, d)
- if changed && len(v) > 0 && len(v2) > 0 && !(len(v2) == len(v) && &v2[0] == &v[0]) {
- copy(v, v2)
- }
- }
-}
-func (f fastpathT) DecSliceBoolX(vp *[]bool, d *Decoder) {
- v, changed := f.DecSliceBoolV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecSliceBoolV(v []bool, canChange bool, d *Decoder) (_ []bool, changed bool) {
- dd := d.d
- slh, containerLenS := d.decSliceHelperStart()
- if containerLenS == 0 {
- if canChange {
- if v == nil {
- v = []bool{}
- } else if len(v) != 0 {
- v = v[:0]
- }
- changed = true
- }
- slh.End()
- return v, changed
- }
- d.depthIncr()
- hasLen := containerLenS > 0
- var xlen int
- if hasLen && canChange {
- if containerLenS > cap(v) {
- xlen = decInferLen(containerLenS, d.h.MaxInitLen, 1)
- if xlen <= cap(v) {
- v = v[:uint(xlen)]
- } else {
- v = make([]bool, uint(xlen))
- }
- changed = true
- } else if containerLenS != len(v) {
- v = v[:containerLenS]
- changed = true
- }
- }
- var j int
- for j = 0; (hasLen && j < containerLenS) || !(hasLen || dd.CheckBreak()); j++ {
- if j == 0 && len(v) == 0 && canChange {
- if hasLen {
- xlen = decInferLen(containerLenS, d.h.MaxInitLen, 1)
- } else {
- xlen = 8
- }
- v = make([]bool, uint(xlen))
- changed = true
- }
- // if indefinite, etc, then expand the slice if necessary
- var decodeIntoBlank bool
- if j >= len(v) {
- if canChange {
- v = append(v, false)
- changed = true
- } else {
- d.arrayCannotExpand(len(v), j+1)
- decodeIntoBlank = true
- }
- }
- slh.ElemContainerState(j)
- if decodeIntoBlank {
- d.swallow()
- } else if dd.TryDecodeAsNil() {
- v[uint(j)] = false
- } else {
- v[uint(j)] = dd.DecodeBool()
- }
- }
- if canChange {
- if j < len(v) {
- v = v[:uint(j)]
- changed = true
- } else if j == 0 && v == nil {
- v = make([]bool, 0)
- changed = true
- }
- }
- slh.End()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapIntfIntfR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[interface{}]interface{})
- v, changed := fastpathTV.DecMapIntfIntfV(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapIntfIntfV(rv2i(rv).(map[interface{}]interface{}), false, d)
- }
-}
-func (f fastpathT) DecMapIntfIntfX(vp *map[interface{}]interface{}, d *Decoder) {
- v, changed := f.DecMapIntfIntfV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapIntfIntfV(v map[interface{}]interface{}, canChange bool,
- d *Decoder) (_ map[interface{}]interface{}, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 32)
- v = make(map[interface{}]interface{}, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset
- var mk interface{}
- var mv interface{}
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = nil
- d.decode(&mk)
- if bv, bok := mk.([]byte); bok {
- mk = d.string(bv)
- }
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = nil
- }
- continue
- }
- if mapGet {
- mv = v[mk]
- } else {
- mv = nil
- }
- d.decode(&mv)
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapIntfStringR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[interface{}]string)
- v, changed := fastpathTV.DecMapIntfStringV(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapIntfStringV(rv2i(rv).(map[interface{}]string), false, d)
- }
-}
-func (f fastpathT) DecMapIntfStringX(vp *map[interface{}]string, d *Decoder) {
- v, changed := f.DecMapIntfStringV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapIntfStringV(v map[interface{}]string, canChange bool,
- d *Decoder) (_ map[interface{}]string, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 32)
- v = make(map[interface{}]string, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk interface{}
- var mv string
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = nil
- d.decode(&mk)
- if bv, bok := mk.([]byte); bok {
- mk = d.string(bv)
- }
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = ""
- }
- continue
- }
- mv = dd.DecodeString()
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapIntfUintR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[interface{}]uint)
- v, changed := fastpathTV.DecMapIntfUintV(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapIntfUintV(rv2i(rv).(map[interface{}]uint), false, d)
- }
-}
-func (f fastpathT) DecMapIntfUintX(vp *map[interface{}]uint, d *Decoder) {
- v, changed := f.DecMapIntfUintV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapIntfUintV(v map[interface{}]uint, canChange bool,
- d *Decoder) (_ map[interface{}]uint, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 24)
- v = make(map[interface{}]uint, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk interface{}
- var mv uint
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = nil
- d.decode(&mk)
- if bv, bok := mk.([]byte); bok {
- mk = d.string(bv)
- }
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapIntfUint8R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[interface{}]uint8)
- v, changed := fastpathTV.DecMapIntfUint8V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapIntfUint8V(rv2i(rv).(map[interface{}]uint8), false, d)
- }
-}
-func (f fastpathT) DecMapIntfUint8X(vp *map[interface{}]uint8, d *Decoder) {
- v, changed := f.DecMapIntfUint8V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapIntfUint8V(v map[interface{}]uint8, canChange bool,
- d *Decoder) (_ map[interface{}]uint8, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 17)
- v = make(map[interface{}]uint8, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk interface{}
- var mv uint8
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = nil
- d.decode(&mk)
- if bv, bok := mk.([]byte); bok {
- mk = d.string(bv)
- }
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uint8(chkOvf.UintV(dd.DecodeUint64(), 8))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapIntfUint16R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[interface{}]uint16)
- v, changed := fastpathTV.DecMapIntfUint16V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapIntfUint16V(rv2i(rv).(map[interface{}]uint16), false, d)
- }
-}
-func (f fastpathT) DecMapIntfUint16X(vp *map[interface{}]uint16, d *Decoder) {
- v, changed := f.DecMapIntfUint16V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapIntfUint16V(v map[interface{}]uint16, canChange bool,
- d *Decoder) (_ map[interface{}]uint16, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 18)
- v = make(map[interface{}]uint16, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk interface{}
- var mv uint16
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = nil
- d.decode(&mk)
- if bv, bok := mk.([]byte); bok {
- mk = d.string(bv)
- }
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uint16(chkOvf.UintV(dd.DecodeUint64(), 16))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapIntfUint32R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[interface{}]uint32)
- v, changed := fastpathTV.DecMapIntfUint32V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapIntfUint32V(rv2i(rv).(map[interface{}]uint32), false, d)
- }
-}
-func (f fastpathT) DecMapIntfUint32X(vp *map[interface{}]uint32, d *Decoder) {
- v, changed := f.DecMapIntfUint32V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapIntfUint32V(v map[interface{}]uint32, canChange bool,
- d *Decoder) (_ map[interface{}]uint32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 20)
- v = make(map[interface{}]uint32, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk interface{}
- var mv uint32
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = nil
- d.decode(&mk)
- if bv, bok := mk.([]byte); bok {
- mk = d.string(bv)
- }
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uint32(chkOvf.UintV(dd.DecodeUint64(), 32))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapIntfUint64R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[interface{}]uint64)
- v, changed := fastpathTV.DecMapIntfUint64V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapIntfUint64V(rv2i(rv).(map[interface{}]uint64), false, d)
- }
-}
-func (f fastpathT) DecMapIntfUint64X(vp *map[interface{}]uint64, d *Decoder) {
- v, changed := f.DecMapIntfUint64V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapIntfUint64V(v map[interface{}]uint64, canChange bool,
- d *Decoder) (_ map[interface{}]uint64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 24)
- v = make(map[interface{}]uint64, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk interface{}
- var mv uint64
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = nil
- d.decode(&mk)
- if bv, bok := mk.([]byte); bok {
- mk = d.string(bv)
- }
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = dd.DecodeUint64()
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapIntfUintptrR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[interface{}]uintptr)
- v, changed := fastpathTV.DecMapIntfUintptrV(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapIntfUintptrV(rv2i(rv).(map[interface{}]uintptr), false, d)
- }
-}
-func (f fastpathT) DecMapIntfUintptrX(vp *map[interface{}]uintptr, d *Decoder) {
- v, changed := f.DecMapIntfUintptrV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapIntfUintptrV(v map[interface{}]uintptr, canChange bool,
- d *Decoder) (_ map[interface{}]uintptr, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 24)
- v = make(map[interface{}]uintptr, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk interface{}
- var mv uintptr
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = nil
- d.decode(&mk)
- if bv, bok := mk.([]byte); bok {
- mk = d.string(bv)
- }
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapIntfIntR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[interface{}]int)
- v, changed := fastpathTV.DecMapIntfIntV(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapIntfIntV(rv2i(rv).(map[interface{}]int), false, d)
- }
-}
-func (f fastpathT) DecMapIntfIntX(vp *map[interface{}]int, d *Decoder) {
- v, changed := f.DecMapIntfIntV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapIntfIntV(v map[interface{}]int, canChange bool,
- d *Decoder) (_ map[interface{}]int, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 24)
- v = make(map[interface{}]int, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk interface{}
- var mv int
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = nil
- d.decode(&mk)
- if bv, bok := mk.([]byte); bok {
- mk = d.string(bv)
- }
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapIntfInt8R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[interface{}]int8)
- v, changed := fastpathTV.DecMapIntfInt8V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapIntfInt8V(rv2i(rv).(map[interface{}]int8), false, d)
- }
-}
-func (f fastpathT) DecMapIntfInt8X(vp *map[interface{}]int8, d *Decoder) {
- v, changed := f.DecMapIntfInt8V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapIntfInt8V(v map[interface{}]int8, canChange bool,
- d *Decoder) (_ map[interface{}]int8, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 17)
- v = make(map[interface{}]int8, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk interface{}
- var mv int8
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = nil
- d.decode(&mk)
- if bv, bok := mk.([]byte); bok {
- mk = d.string(bv)
- }
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = int8(chkOvf.IntV(dd.DecodeInt64(), 8))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapIntfInt16R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[interface{}]int16)
- v, changed := fastpathTV.DecMapIntfInt16V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapIntfInt16V(rv2i(rv).(map[interface{}]int16), false, d)
- }
-}
-func (f fastpathT) DecMapIntfInt16X(vp *map[interface{}]int16, d *Decoder) {
- v, changed := f.DecMapIntfInt16V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapIntfInt16V(v map[interface{}]int16, canChange bool,
- d *Decoder) (_ map[interface{}]int16, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 18)
- v = make(map[interface{}]int16, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk interface{}
- var mv int16
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = nil
- d.decode(&mk)
- if bv, bok := mk.([]byte); bok {
- mk = d.string(bv)
- }
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = int16(chkOvf.IntV(dd.DecodeInt64(), 16))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapIntfInt32R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[interface{}]int32)
- v, changed := fastpathTV.DecMapIntfInt32V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapIntfInt32V(rv2i(rv).(map[interface{}]int32), false, d)
- }
-}
-func (f fastpathT) DecMapIntfInt32X(vp *map[interface{}]int32, d *Decoder) {
- v, changed := f.DecMapIntfInt32V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapIntfInt32V(v map[interface{}]int32, canChange bool,
- d *Decoder) (_ map[interface{}]int32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 20)
- v = make(map[interface{}]int32, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk interface{}
- var mv int32
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = nil
- d.decode(&mk)
- if bv, bok := mk.([]byte); bok {
- mk = d.string(bv)
- }
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = int32(chkOvf.IntV(dd.DecodeInt64(), 32))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapIntfInt64R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[interface{}]int64)
- v, changed := fastpathTV.DecMapIntfInt64V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapIntfInt64V(rv2i(rv).(map[interface{}]int64), false, d)
- }
-}
-func (f fastpathT) DecMapIntfInt64X(vp *map[interface{}]int64, d *Decoder) {
- v, changed := f.DecMapIntfInt64V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapIntfInt64V(v map[interface{}]int64, canChange bool,
- d *Decoder) (_ map[interface{}]int64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 24)
- v = make(map[interface{}]int64, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk interface{}
- var mv int64
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = nil
- d.decode(&mk)
- if bv, bok := mk.([]byte); bok {
- mk = d.string(bv)
- }
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = dd.DecodeInt64()
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapIntfFloat32R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[interface{}]float32)
- v, changed := fastpathTV.DecMapIntfFloat32V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapIntfFloat32V(rv2i(rv).(map[interface{}]float32), false, d)
- }
-}
-func (f fastpathT) DecMapIntfFloat32X(vp *map[interface{}]float32, d *Decoder) {
- v, changed := f.DecMapIntfFloat32V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapIntfFloat32V(v map[interface{}]float32, canChange bool,
- d *Decoder) (_ map[interface{}]float32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 20)
- v = make(map[interface{}]float32, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk interface{}
- var mv float32
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = nil
- d.decode(&mk)
- if bv, bok := mk.([]byte); bok {
- mk = d.string(bv)
- }
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = float32(chkOvf.Float32V(dd.DecodeFloat64()))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapIntfFloat64R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[interface{}]float64)
- v, changed := fastpathTV.DecMapIntfFloat64V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapIntfFloat64V(rv2i(rv).(map[interface{}]float64), false, d)
- }
-}
-func (f fastpathT) DecMapIntfFloat64X(vp *map[interface{}]float64, d *Decoder) {
- v, changed := f.DecMapIntfFloat64V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapIntfFloat64V(v map[interface{}]float64, canChange bool,
- d *Decoder) (_ map[interface{}]float64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 24)
- v = make(map[interface{}]float64, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk interface{}
- var mv float64
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = nil
- d.decode(&mk)
- if bv, bok := mk.([]byte); bok {
- mk = d.string(bv)
- }
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = dd.DecodeFloat64()
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapIntfBoolR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[interface{}]bool)
- v, changed := fastpathTV.DecMapIntfBoolV(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapIntfBoolV(rv2i(rv).(map[interface{}]bool), false, d)
- }
-}
-func (f fastpathT) DecMapIntfBoolX(vp *map[interface{}]bool, d *Decoder) {
- v, changed := f.DecMapIntfBoolV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapIntfBoolV(v map[interface{}]bool, canChange bool,
- d *Decoder) (_ map[interface{}]bool, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 17)
- v = make(map[interface{}]bool, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk interface{}
- var mv bool
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = nil
- d.decode(&mk)
- if bv, bok := mk.([]byte); bok {
- mk = d.string(bv)
- }
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = false
- }
- continue
- }
- mv = dd.DecodeBool()
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapStringIntfR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[string]interface{})
- v, changed := fastpathTV.DecMapStringIntfV(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapStringIntfV(rv2i(rv).(map[string]interface{}), false, d)
- }
-}
-func (f fastpathT) DecMapStringIntfX(vp *map[string]interface{}, d *Decoder) {
- v, changed := f.DecMapStringIntfV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapStringIntfV(v map[string]interface{}, canChange bool,
- d *Decoder) (_ map[string]interface{}, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 32)
- v = make(map[string]interface{}, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset
- var mk string
- var mv interface{}
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeString()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = nil
- }
- continue
- }
- if mapGet {
- mv = v[mk]
- } else {
- mv = nil
- }
- d.decode(&mv)
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapStringStringR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[string]string)
- v, changed := fastpathTV.DecMapStringStringV(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapStringStringV(rv2i(rv).(map[string]string), false, d)
- }
-}
-func (f fastpathT) DecMapStringStringX(vp *map[string]string, d *Decoder) {
- v, changed := f.DecMapStringStringV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapStringStringV(v map[string]string, canChange bool,
- d *Decoder) (_ map[string]string, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 32)
- v = make(map[string]string, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk string
- var mv string
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeString()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = ""
- }
- continue
- }
- mv = dd.DecodeString()
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapStringUintR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[string]uint)
- v, changed := fastpathTV.DecMapStringUintV(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapStringUintV(rv2i(rv).(map[string]uint), false, d)
- }
-}
-func (f fastpathT) DecMapStringUintX(vp *map[string]uint, d *Decoder) {
- v, changed := f.DecMapStringUintV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapStringUintV(v map[string]uint, canChange bool,
- d *Decoder) (_ map[string]uint, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 24)
- v = make(map[string]uint, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk string
- var mv uint
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeString()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapStringUint8R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[string]uint8)
- v, changed := fastpathTV.DecMapStringUint8V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapStringUint8V(rv2i(rv).(map[string]uint8), false, d)
- }
-}
-func (f fastpathT) DecMapStringUint8X(vp *map[string]uint8, d *Decoder) {
- v, changed := f.DecMapStringUint8V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapStringUint8V(v map[string]uint8, canChange bool,
- d *Decoder) (_ map[string]uint8, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 17)
- v = make(map[string]uint8, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk string
- var mv uint8
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeString()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uint8(chkOvf.UintV(dd.DecodeUint64(), 8))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapStringUint16R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[string]uint16)
- v, changed := fastpathTV.DecMapStringUint16V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapStringUint16V(rv2i(rv).(map[string]uint16), false, d)
- }
-}
-func (f fastpathT) DecMapStringUint16X(vp *map[string]uint16, d *Decoder) {
- v, changed := f.DecMapStringUint16V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapStringUint16V(v map[string]uint16, canChange bool,
- d *Decoder) (_ map[string]uint16, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 18)
- v = make(map[string]uint16, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk string
- var mv uint16
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeString()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uint16(chkOvf.UintV(dd.DecodeUint64(), 16))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapStringUint32R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[string]uint32)
- v, changed := fastpathTV.DecMapStringUint32V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapStringUint32V(rv2i(rv).(map[string]uint32), false, d)
- }
-}
-func (f fastpathT) DecMapStringUint32X(vp *map[string]uint32, d *Decoder) {
- v, changed := f.DecMapStringUint32V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapStringUint32V(v map[string]uint32, canChange bool,
- d *Decoder) (_ map[string]uint32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 20)
- v = make(map[string]uint32, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk string
- var mv uint32
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeString()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uint32(chkOvf.UintV(dd.DecodeUint64(), 32))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapStringUint64R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[string]uint64)
- v, changed := fastpathTV.DecMapStringUint64V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapStringUint64V(rv2i(rv).(map[string]uint64), false, d)
- }
-}
-func (f fastpathT) DecMapStringUint64X(vp *map[string]uint64, d *Decoder) {
- v, changed := f.DecMapStringUint64V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapStringUint64V(v map[string]uint64, canChange bool,
- d *Decoder) (_ map[string]uint64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 24)
- v = make(map[string]uint64, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk string
- var mv uint64
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeString()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = dd.DecodeUint64()
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapStringUintptrR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[string]uintptr)
- v, changed := fastpathTV.DecMapStringUintptrV(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapStringUintptrV(rv2i(rv).(map[string]uintptr), false, d)
- }
-}
-func (f fastpathT) DecMapStringUintptrX(vp *map[string]uintptr, d *Decoder) {
- v, changed := f.DecMapStringUintptrV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapStringUintptrV(v map[string]uintptr, canChange bool,
- d *Decoder) (_ map[string]uintptr, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 24)
- v = make(map[string]uintptr, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk string
- var mv uintptr
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeString()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapStringIntR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[string]int)
- v, changed := fastpathTV.DecMapStringIntV(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapStringIntV(rv2i(rv).(map[string]int), false, d)
- }
-}
-func (f fastpathT) DecMapStringIntX(vp *map[string]int, d *Decoder) {
- v, changed := f.DecMapStringIntV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapStringIntV(v map[string]int, canChange bool,
- d *Decoder) (_ map[string]int, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 24)
- v = make(map[string]int, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk string
- var mv int
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeString()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapStringInt8R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[string]int8)
- v, changed := fastpathTV.DecMapStringInt8V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapStringInt8V(rv2i(rv).(map[string]int8), false, d)
- }
-}
-func (f fastpathT) DecMapStringInt8X(vp *map[string]int8, d *Decoder) {
- v, changed := f.DecMapStringInt8V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapStringInt8V(v map[string]int8, canChange bool,
- d *Decoder) (_ map[string]int8, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 17)
- v = make(map[string]int8, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk string
- var mv int8
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeString()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = int8(chkOvf.IntV(dd.DecodeInt64(), 8))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapStringInt16R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[string]int16)
- v, changed := fastpathTV.DecMapStringInt16V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapStringInt16V(rv2i(rv).(map[string]int16), false, d)
- }
-}
-func (f fastpathT) DecMapStringInt16X(vp *map[string]int16, d *Decoder) {
- v, changed := f.DecMapStringInt16V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapStringInt16V(v map[string]int16, canChange bool,
- d *Decoder) (_ map[string]int16, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 18)
- v = make(map[string]int16, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk string
- var mv int16
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeString()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = int16(chkOvf.IntV(dd.DecodeInt64(), 16))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapStringInt32R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[string]int32)
- v, changed := fastpathTV.DecMapStringInt32V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapStringInt32V(rv2i(rv).(map[string]int32), false, d)
- }
-}
-func (f fastpathT) DecMapStringInt32X(vp *map[string]int32, d *Decoder) {
- v, changed := f.DecMapStringInt32V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapStringInt32V(v map[string]int32, canChange bool,
- d *Decoder) (_ map[string]int32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 20)
- v = make(map[string]int32, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk string
- var mv int32
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeString()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = int32(chkOvf.IntV(dd.DecodeInt64(), 32))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapStringInt64R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[string]int64)
- v, changed := fastpathTV.DecMapStringInt64V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapStringInt64V(rv2i(rv).(map[string]int64), false, d)
- }
-}
-func (f fastpathT) DecMapStringInt64X(vp *map[string]int64, d *Decoder) {
- v, changed := f.DecMapStringInt64V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapStringInt64V(v map[string]int64, canChange bool,
- d *Decoder) (_ map[string]int64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 24)
- v = make(map[string]int64, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk string
- var mv int64
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeString()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = dd.DecodeInt64()
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapStringFloat32R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[string]float32)
- v, changed := fastpathTV.DecMapStringFloat32V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapStringFloat32V(rv2i(rv).(map[string]float32), false, d)
- }
-}
-func (f fastpathT) DecMapStringFloat32X(vp *map[string]float32, d *Decoder) {
- v, changed := f.DecMapStringFloat32V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapStringFloat32V(v map[string]float32, canChange bool,
- d *Decoder) (_ map[string]float32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 20)
- v = make(map[string]float32, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk string
- var mv float32
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeString()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = float32(chkOvf.Float32V(dd.DecodeFloat64()))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapStringFloat64R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[string]float64)
- v, changed := fastpathTV.DecMapStringFloat64V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapStringFloat64V(rv2i(rv).(map[string]float64), false, d)
- }
-}
-func (f fastpathT) DecMapStringFloat64X(vp *map[string]float64, d *Decoder) {
- v, changed := f.DecMapStringFloat64V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapStringFloat64V(v map[string]float64, canChange bool,
- d *Decoder) (_ map[string]float64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 24)
- v = make(map[string]float64, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk string
- var mv float64
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeString()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = dd.DecodeFloat64()
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapStringBoolR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[string]bool)
- v, changed := fastpathTV.DecMapStringBoolV(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapStringBoolV(rv2i(rv).(map[string]bool), false, d)
- }
-}
-func (f fastpathT) DecMapStringBoolX(vp *map[string]bool, d *Decoder) {
- v, changed := f.DecMapStringBoolV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapStringBoolV(v map[string]bool, canChange bool,
- d *Decoder) (_ map[string]bool, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 17)
- v = make(map[string]bool, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk string
- var mv bool
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeString()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = false
- }
- continue
- }
- mv = dd.DecodeBool()
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapFloat32IntfR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[float32]interface{})
- v, changed := fastpathTV.DecMapFloat32IntfV(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapFloat32IntfV(rv2i(rv).(map[float32]interface{}), false, d)
- }
-}
-func (f fastpathT) DecMapFloat32IntfX(vp *map[float32]interface{}, d *Decoder) {
- v, changed := f.DecMapFloat32IntfV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapFloat32IntfV(v map[float32]interface{}, canChange bool,
- d *Decoder) (_ map[float32]interface{}, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 20)
- v = make(map[float32]interface{}, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset
- var mk float32
- var mv interface{}
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = float32(chkOvf.Float32V(dd.DecodeFloat64()))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = nil
- }
- continue
- }
- if mapGet {
- mv = v[mk]
- } else {
- mv = nil
- }
- d.decode(&mv)
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapFloat32StringR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[float32]string)
- v, changed := fastpathTV.DecMapFloat32StringV(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapFloat32StringV(rv2i(rv).(map[float32]string), false, d)
- }
-}
-func (f fastpathT) DecMapFloat32StringX(vp *map[float32]string, d *Decoder) {
- v, changed := f.DecMapFloat32StringV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapFloat32StringV(v map[float32]string, canChange bool,
- d *Decoder) (_ map[float32]string, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 20)
- v = make(map[float32]string, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk float32
- var mv string
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = float32(chkOvf.Float32V(dd.DecodeFloat64()))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = ""
- }
- continue
- }
- mv = dd.DecodeString()
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapFloat32UintR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[float32]uint)
- v, changed := fastpathTV.DecMapFloat32UintV(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapFloat32UintV(rv2i(rv).(map[float32]uint), false, d)
- }
-}
-func (f fastpathT) DecMapFloat32UintX(vp *map[float32]uint, d *Decoder) {
- v, changed := f.DecMapFloat32UintV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapFloat32UintV(v map[float32]uint, canChange bool,
- d *Decoder) (_ map[float32]uint, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
- v = make(map[float32]uint, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk float32
- var mv uint
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = float32(chkOvf.Float32V(dd.DecodeFloat64()))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapFloat32Uint8R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[float32]uint8)
- v, changed := fastpathTV.DecMapFloat32Uint8V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapFloat32Uint8V(rv2i(rv).(map[float32]uint8), false, d)
- }
-}
-func (f fastpathT) DecMapFloat32Uint8X(vp *map[float32]uint8, d *Decoder) {
- v, changed := f.DecMapFloat32Uint8V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapFloat32Uint8V(v map[float32]uint8, canChange bool,
- d *Decoder) (_ map[float32]uint8, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 5)
- v = make(map[float32]uint8, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk float32
- var mv uint8
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = float32(chkOvf.Float32V(dd.DecodeFloat64()))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uint8(chkOvf.UintV(dd.DecodeUint64(), 8))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapFloat32Uint16R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[float32]uint16)
- v, changed := fastpathTV.DecMapFloat32Uint16V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapFloat32Uint16V(rv2i(rv).(map[float32]uint16), false, d)
- }
-}
-func (f fastpathT) DecMapFloat32Uint16X(vp *map[float32]uint16, d *Decoder) {
- v, changed := f.DecMapFloat32Uint16V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapFloat32Uint16V(v map[float32]uint16, canChange bool,
- d *Decoder) (_ map[float32]uint16, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 6)
- v = make(map[float32]uint16, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk float32
- var mv uint16
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = float32(chkOvf.Float32V(dd.DecodeFloat64()))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uint16(chkOvf.UintV(dd.DecodeUint64(), 16))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapFloat32Uint32R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[float32]uint32)
- v, changed := fastpathTV.DecMapFloat32Uint32V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapFloat32Uint32V(rv2i(rv).(map[float32]uint32), false, d)
- }
-}
-func (f fastpathT) DecMapFloat32Uint32X(vp *map[float32]uint32, d *Decoder) {
- v, changed := f.DecMapFloat32Uint32V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapFloat32Uint32V(v map[float32]uint32, canChange bool,
- d *Decoder) (_ map[float32]uint32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 8)
- v = make(map[float32]uint32, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk float32
- var mv uint32
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = float32(chkOvf.Float32V(dd.DecodeFloat64()))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uint32(chkOvf.UintV(dd.DecodeUint64(), 32))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapFloat32Uint64R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[float32]uint64)
- v, changed := fastpathTV.DecMapFloat32Uint64V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapFloat32Uint64V(rv2i(rv).(map[float32]uint64), false, d)
- }
-}
-func (f fastpathT) DecMapFloat32Uint64X(vp *map[float32]uint64, d *Decoder) {
- v, changed := f.DecMapFloat32Uint64V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapFloat32Uint64V(v map[float32]uint64, canChange bool,
- d *Decoder) (_ map[float32]uint64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
- v = make(map[float32]uint64, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk float32
- var mv uint64
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = float32(chkOvf.Float32V(dd.DecodeFloat64()))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = dd.DecodeUint64()
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapFloat32UintptrR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[float32]uintptr)
- v, changed := fastpathTV.DecMapFloat32UintptrV(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapFloat32UintptrV(rv2i(rv).(map[float32]uintptr), false, d)
- }
-}
-func (f fastpathT) DecMapFloat32UintptrX(vp *map[float32]uintptr, d *Decoder) {
- v, changed := f.DecMapFloat32UintptrV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapFloat32UintptrV(v map[float32]uintptr, canChange bool,
- d *Decoder) (_ map[float32]uintptr, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
- v = make(map[float32]uintptr, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk float32
- var mv uintptr
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = float32(chkOvf.Float32V(dd.DecodeFloat64()))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapFloat32IntR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[float32]int)
- v, changed := fastpathTV.DecMapFloat32IntV(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapFloat32IntV(rv2i(rv).(map[float32]int), false, d)
- }
-}
-func (f fastpathT) DecMapFloat32IntX(vp *map[float32]int, d *Decoder) {
- v, changed := f.DecMapFloat32IntV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapFloat32IntV(v map[float32]int, canChange bool,
- d *Decoder) (_ map[float32]int, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
- v = make(map[float32]int, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk float32
- var mv int
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = float32(chkOvf.Float32V(dd.DecodeFloat64()))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapFloat32Int8R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[float32]int8)
- v, changed := fastpathTV.DecMapFloat32Int8V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapFloat32Int8V(rv2i(rv).(map[float32]int8), false, d)
- }
-}
-func (f fastpathT) DecMapFloat32Int8X(vp *map[float32]int8, d *Decoder) {
- v, changed := f.DecMapFloat32Int8V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapFloat32Int8V(v map[float32]int8, canChange bool,
- d *Decoder) (_ map[float32]int8, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 5)
- v = make(map[float32]int8, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk float32
- var mv int8
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = float32(chkOvf.Float32V(dd.DecodeFloat64()))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = int8(chkOvf.IntV(dd.DecodeInt64(), 8))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapFloat32Int16R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[float32]int16)
- v, changed := fastpathTV.DecMapFloat32Int16V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapFloat32Int16V(rv2i(rv).(map[float32]int16), false, d)
- }
-}
-func (f fastpathT) DecMapFloat32Int16X(vp *map[float32]int16, d *Decoder) {
- v, changed := f.DecMapFloat32Int16V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapFloat32Int16V(v map[float32]int16, canChange bool,
- d *Decoder) (_ map[float32]int16, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 6)
- v = make(map[float32]int16, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk float32
- var mv int16
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = float32(chkOvf.Float32V(dd.DecodeFloat64()))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = int16(chkOvf.IntV(dd.DecodeInt64(), 16))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapFloat32Int32R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[float32]int32)
- v, changed := fastpathTV.DecMapFloat32Int32V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapFloat32Int32V(rv2i(rv).(map[float32]int32), false, d)
- }
-}
-func (f fastpathT) DecMapFloat32Int32X(vp *map[float32]int32, d *Decoder) {
- v, changed := f.DecMapFloat32Int32V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapFloat32Int32V(v map[float32]int32, canChange bool,
- d *Decoder) (_ map[float32]int32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 8)
- v = make(map[float32]int32, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk float32
- var mv int32
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = float32(chkOvf.Float32V(dd.DecodeFloat64()))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = int32(chkOvf.IntV(dd.DecodeInt64(), 32))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapFloat32Int64R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[float32]int64)
- v, changed := fastpathTV.DecMapFloat32Int64V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapFloat32Int64V(rv2i(rv).(map[float32]int64), false, d)
- }
-}
-func (f fastpathT) DecMapFloat32Int64X(vp *map[float32]int64, d *Decoder) {
- v, changed := f.DecMapFloat32Int64V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapFloat32Int64V(v map[float32]int64, canChange bool,
- d *Decoder) (_ map[float32]int64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
- v = make(map[float32]int64, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk float32
- var mv int64
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = float32(chkOvf.Float32V(dd.DecodeFloat64()))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = dd.DecodeInt64()
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapFloat32Float32R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[float32]float32)
- v, changed := fastpathTV.DecMapFloat32Float32V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapFloat32Float32V(rv2i(rv).(map[float32]float32), false, d)
- }
-}
-func (f fastpathT) DecMapFloat32Float32X(vp *map[float32]float32, d *Decoder) {
- v, changed := f.DecMapFloat32Float32V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapFloat32Float32V(v map[float32]float32, canChange bool,
- d *Decoder) (_ map[float32]float32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 8)
- v = make(map[float32]float32, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk float32
- var mv float32
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = float32(chkOvf.Float32V(dd.DecodeFloat64()))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = float32(chkOvf.Float32V(dd.DecodeFloat64()))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapFloat32Float64R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[float32]float64)
- v, changed := fastpathTV.DecMapFloat32Float64V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapFloat32Float64V(rv2i(rv).(map[float32]float64), false, d)
- }
-}
-func (f fastpathT) DecMapFloat32Float64X(vp *map[float32]float64, d *Decoder) {
- v, changed := f.DecMapFloat32Float64V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapFloat32Float64V(v map[float32]float64, canChange bool,
- d *Decoder) (_ map[float32]float64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
- v = make(map[float32]float64, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk float32
- var mv float64
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = float32(chkOvf.Float32V(dd.DecodeFloat64()))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = dd.DecodeFloat64()
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapFloat32BoolR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[float32]bool)
- v, changed := fastpathTV.DecMapFloat32BoolV(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapFloat32BoolV(rv2i(rv).(map[float32]bool), false, d)
- }
-}
-func (f fastpathT) DecMapFloat32BoolX(vp *map[float32]bool, d *Decoder) {
- v, changed := f.DecMapFloat32BoolV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapFloat32BoolV(v map[float32]bool, canChange bool,
- d *Decoder) (_ map[float32]bool, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 5)
- v = make(map[float32]bool, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk float32
- var mv bool
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = float32(chkOvf.Float32V(dd.DecodeFloat64()))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = false
- }
- continue
- }
- mv = dd.DecodeBool()
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapFloat64IntfR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[float64]interface{})
- v, changed := fastpathTV.DecMapFloat64IntfV(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapFloat64IntfV(rv2i(rv).(map[float64]interface{}), false, d)
- }
-}
-func (f fastpathT) DecMapFloat64IntfX(vp *map[float64]interface{}, d *Decoder) {
- v, changed := f.DecMapFloat64IntfV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapFloat64IntfV(v map[float64]interface{}, canChange bool,
- d *Decoder) (_ map[float64]interface{}, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 24)
- v = make(map[float64]interface{}, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset
- var mk float64
- var mv interface{}
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeFloat64()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = nil
- }
- continue
- }
- if mapGet {
- mv = v[mk]
- } else {
- mv = nil
- }
- d.decode(&mv)
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapFloat64StringR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[float64]string)
- v, changed := fastpathTV.DecMapFloat64StringV(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapFloat64StringV(rv2i(rv).(map[float64]string), false, d)
- }
-}
-func (f fastpathT) DecMapFloat64StringX(vp *map[float64]string, d *Decoder) {
- v, changed := f.DecMapFloat64StringV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapFloat64StringV(v map[float64]string, canChange bool,
- d *Decoder) (_ map[float64]string, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 24)
- v = make(map[float64]string, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk float64
- var mv string
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeFloat64()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = ""
- }
- continue
- }
- mv = dd.DecodeString()
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapFloat64UintR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[float64]uint)
- v, changed := fastpathTV.DecMapFloat64UintV(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapFloat64UintV(rv2i(rv).(map[float64]uint), false, d)
- }
-}
-func (f fastpathT) DecMapFloat64UintX(vp *map[float64]uint, d *Decoder) {
- v, changed := f.DecMapFloat64UintV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapFloat64UintV(v map[float64]uint, canChange bool,
- d *Decoder) (_ map[float64]uint, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
- v = make(map[float64]uint, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk float64
- var mv uint
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeFloat64()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapFloat64Uint8R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[float64]uint8)
- v, changed := fastpathTV.DecMapFloat64Uint8V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapFloat64Uint8V(rv2i(rv).(map[float64]uint8), false, d)
- }
-}
-func (f fastpathT) DecMapFloat64Uint8X(vp *map[float64]uint8, d *Decoder) {
- v, changed := f.DecMapFloat64Uint8V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapFloat64Uint8V(v map[float64]uint8, canChange bool,
- d *Decoder) (_ map[float64]uint8, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
- v = make(map[float64]uint8, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk float64
- var mv uint8
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeFloat64()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uint8(chkOvf.UintV(dd.DecodeUint64(), 8))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapFloat64Uint16R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[float64]uint16)
- v, changed := fastpathTV.DecMapFloat64Uint16V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapFloat64Uint16V(rv2i(rv).(map[float64]uint16), false, d)
- }
-}
-func (f fastpathT) DecMapFloat64Uint16X(vp *map[float64]uint16, d *Decoder) {
- v, changed := f.DecMapFloat64Uint16V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapFloat64Uint16V(v map[float64]uint16, canChange bool,
- d *Decoder) (_ map[float64]uint16, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 10)
- v = make(map[float64]uint16, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk float64
- var mv uint16
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeFloat64()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uint16(chkOvf.UintV(dd.DecodeUint64(), 16))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapFloat64Uint32R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[float64]uint32)
- v, changed := fastpathTV.DecMapFloat64Uint32V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapFloat64Uint32V(rv2i(rv).(map[float64]uint32), false, d)
- }
-}
-func (f fastpathT) DecMapFloat64Uint32X(vp *map[float64]uint32, d *Decoder) {
- v, changed := f.DecMapFloat64Uint32V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapFloat64Uint32V(v map[float64]uint32, canChange bool,
- d *Decoder) (_ map[float64]uint32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
- v = make(map[float64]uint32, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk float64
- var mv uint32
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeFloat64()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uint32(chkOvf.UintV(dd.DecodeUint64(), 32))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapFloat64Uint64R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[float64]uint64)
- v, changed := fastpathTV.DecMapFloat64Uint64V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapFloat64Uint64V(rv2i(rv).(map[float64]uint64), false, d)
- }
-}
-func (f fastpathT) DecMapFloat64Uint64X(vp *map[float64]uint64, d *Decoder) {
- v, changed := f.DecMapFloat64Uint64V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapFloat64Uint64V(v map[float64]uint64, canChange bool,
- d *Decoder) (_ map[float64]uint64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
- v = make(map[float64]uint64, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk float64
- var mv uint64
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeFloat64()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = dd.DecodeUint64()
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapFloat64UintptrR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[float64]uintptr)
- v, changed := fastpathTV.DecMapFloat64UintptrV(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapFloat64UintptrV(rv2i(rv).(map[float64]uintptr), false, d)
- }
-}
-func (f fastpathT) DecMapFloat64UintptrX(vp *map[float64]uintptr, d *Decoder) {
- v, changed := f.DecMapFloat64UintptrV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapFloat64UintptrV(v map[float64]uintptr, canChange bool,
- d *Decoder) (_ map[float64]uintptr, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
- v = make(map[float64]uintptr, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk float64
- var mv uintptr
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeFloat64()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapFloat64IntR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[float64]int)
- v, changed := fastpathTV.DecMapFloat64IntV(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapFloat64IntV(rv2i(rv).(map[float64]int), false, d)
- }
-}
-func (f fastpathT) DecMapFloat64IntX(vp *map[float64]int, d *Decoder) {
- v, changed := f.DecMapFloat64IntV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapFloat64IntV(v map[float64]int, canChange bool,
- d *Decoder) (_ map[float64]int, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
- v = make(map[float64]int, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk float64
- var mv int
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeFloat64()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapFloat64Int8R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[float64]int8)
- v, changed := fastpathTV.DecMapFloat64Int8V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapFloat64Int8V(rv2i(rv).(map[float64]int8), false, d)
- }
-}
-func (f fastpathT) DecMapFloat64Int8X(vp *map[float64]int8, d *Decoder) {
- v, changed := f.DecMapFloat64Int8V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapFloat64Int8V(v map[float64]int8, canChange bool,
- d *Decoder) (_ map[float64]int8, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
- v = make(map[float64]int8, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk float64
- var mv int8
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeFloat64()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = int8(chkOvf.IntV(dd.DecodeInt64(), 8))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapFloat64Int16R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[float64]int16)
- v, changed := fastpathTV.DecMapFloat64Int16V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapFloat64Int16V(rv2i(rv).(map[float64]int16), false, d)
- }
-}
-func (f fastpathT) DecMapFloat64Int16X(vp *map[float64]int16, d *Decoder) {
- v, changed := f.DecMapFloat64Int16V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapFloat64Int16V(v map[float64]int16, canChange bool,
- d *Decoder) (_ map[float64]int16, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 10)
- v = make(map[float64]int16, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk float64
- var mv int16
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeFloat64()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = int16(chkOvf.IntV(dd.DecodeInt64(), 16))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapFloat64Int32R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[float64]int32)
- v, changed := fastpathTV.DecMapFloat64Int32V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapFloat64Int32V(rv2i(rv).(map[float64]int32), false, d)
- }
-}
-func (f fastpathT) DecMapFloat64Int32X(vp *map[float64]int32, d *Decoder) {
- v, changed := f.DecMapFloat64Int32V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapFloat64Int32V(v map[float64]int32, canChange bool,
- d *Decoder) (_ map[float64]int32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
- v = make(map[float64]int32, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk float64
- var mv int32
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeFloat64()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = int32(chkOvf.IntV(dd.DecodeInt64(), 32))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapFloat64Int64R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[float64]int64)
- v, changed := fastpathTV.DecMapFloat64Int64V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapFloat64Int64V(rv2i(rv).(map[float64]int64), false, d)
- }
-}
-func (f fastpathT) DecMapFloat64Int64X(vp *map[float64]int64, d *Decoder) {
- v, changed := f.DecMapFloat64Int64V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapFloat64Int64V(v map[float64]int64, canChange bool,
- d *Decoder) (_ map[float64]int64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
- v = make(map[float64]int64, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk float64
- var mv int64
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeFloat64()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = dd.DecodeInt64()
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapFloat64Float32R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[float64]float32)
- v, changed := fastpathTV.DecMapFloat64Float32V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapFloat64Float32V(rv2i(rv).(map[float64]float32), false, d)
- }
-}
-func (f fastpathT) DecMapFloat64Float32X(vp *map[float64]float32, d *Decoder) {
- v, changed := f.DecMapFloat64Float32V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapFloat64Float32V(v map[float64]float32, canChange bool,
- d *Decoder) (_ map[float64]float32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
- v = make(map[float64]float32, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk float64
- var mv float32
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeFloat64()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = float32(chkOvf.Float32V(dd.DecodeFloat64()))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapFloat64Float64R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[float64]float64)
- v, changed := fastpathTV.DecMapFloat64Float64V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapFloat64Float64V(rv2i(rv).(map[float64]float64), false, d)
- }
-}
-func (f fastpathT) DecMapFloat64Float64X(vp *map[float64]float64, d *Decoder) {
- v, changed := f.DecMapFloat64Float64V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapFloat64Float64V(v map[float64]float64, canChange bool,
- d *Decoder) (_ map[float64]float64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
- v = make(map[float64]float64, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk float64
- var mv float64
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeFloat64()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = dd.DecodeFloat64()
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapFloat64BoolR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[float64]bool)
- v, changed := fastpathTV.DecMapFloat64BoolV(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapFloat64BoolV(rv2i(rv).(map[float64]bool), false, d)
- }
-}
-func (f fastpathT) DecMapFloat64BoolX(vp *map[float64]bool, d *Decoder) {
- v, changed := f.DecMapFloat64BoolV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapFloat64BoolV(v map[float64]bool, canChange bool,
- d *Decoder) (_ map[float64]bool, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
- v = make(map[float64]bool, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk float64
- var mv bool
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeFloat64()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = false
- }
- continue
- }
- mv = dd.DecodeBool()
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUintIntfR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint]interface{})
- v, changed := fastpathTV.DecMapUintIntfV(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUintIntfV(rv2i(rv).(map[uint]interface{}), false, d)
- }
-}
-func (f fastpathT) DecMapUintIntfX(vp *map[uint]interface{}, d *Decoder) {
- v, changed := f.DecMapUintIntfV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUintIntfV(v map[uint]interface{}, canChange bool,
- d *Decoder) (_ map[uint]interface{}, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 24)
- v = make(map[uint]interface{}, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset
- var mk uint
- var mv interface{}
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = nil
- }
- continue
- }
- if mapGet {
- mv = v[mk]
- } else {
- mv = nil
- }
- d.decode(&mv)
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUintStringR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint]string)
- v, changed := fastpathTV.DecMapUintStringV(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUintStringV(rv2i(rv).(map[uint]string), false, d)
- }
-}
-func (f fastpathT) DecMapUintStringX(vp *map[uint]string, d *Decoder) {
- v, changed := f.DecMapUintStringV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUintStringV(v map[uint]string, canChange bool,
- d *Decoder) (_ map[uint]string, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 24)
- v = make(map[uint]string, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint
- var mv string
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = ""
- }
- continue
- }
- mv = dd.DecodeString()
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUintUintR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint]uint)
- v, changed := fastpathTV.DecMapUintUintV(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUintUintV(rv2i(rv).(map[uint]uint), false, d)
- }
-}
-func (f fastpathT) DecMapUintUintX(vp *map[uint]uint, d *Decoder) {
- v, changed := f.DecMapUintUintV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUintUintV(v map[uint]uint, canChange bool,
- d *Decoder) (_ map[uint]uint, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
- v = make(map[uint]uint, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint
- var mv uint
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUintUint8R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint]uint8)
- v, changed := fastpathTV.DecMapUintUint8V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUintUint8V(rv2i(rv).(map[uint]uint8), false, d)
- }
-}
-func (f fastpathT) DecMapUintUint8X(vp *map[uint]uint8, d *Decoder) {
- v, changed := f.DecMapUintUint8V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUintUint8V(v map[uint]uint8, canChange bool,
- d *Decoder) (_ map[uint]uint8, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
- v = make(map[uint]uint8, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint
- var mv uint8
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uint8(chkOvf.UintV(dd.DecodeUint64(), 8))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUintUint16R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint]uint16)
- v, changed := fastpathTV.DecMapUintUint16V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUintUint16V(rv2i(rv).(map[uint]uint16), false, d)
- }
-}
-func (f fastpathT) DecMapUintUint16X(vp *map[uint]uint16, d *Decoder) {
- v, changed := f.DecMapUintUint16V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUintUint16V(v map[uint]uint16, canChange bool,
- d *Decoder) (_ map[uint]uint16, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 10)
- v = make(map[uint]uint16, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint
- var mv uint16
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uint16(chkOvf.UintV(dd.DecodeUint64(), 16))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUintUint32R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint]uint32)
- v, changed := fastpathTV.DecMapUintUint32V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUintUint32V(rv2i(rv).(map[uint]uint32), false, d)
- }
-}
-func (f fastpathT) DecMapUintUint32X(vp *map[uint]uint32, d *Decoder) {
- v, changed := f.DecMapUintUint32V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUintUint32V(v map[uint]uint32, canChange bool,
- d *Decoder) (_ map[uint]uint32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
- v = make(map[uint]uint32, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint
- var mv uint32
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uint32(chkOvf.UintV(dd.DecodeUint64(), 32))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUintUint64R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint]uint64)
- v, changed := fastpathTV.DecMapUintUint64V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUintUint64V(rv2i(rv).(map[uint]uint64), false, d)
- }
-}
-func (f fastpathT) DecMapUintUint64X(vp *map[uint]uint64, d *Decoder) {
- v, changed := f.DecMapUintUint64V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUintUint64V(v map[uint]uint64, canChange bool,
- d *Decoder) (_ map[uint]uint64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
- v = make(map[uint]uint64, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint
- var mv uint64
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = dd.DecodeUint64()
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUintUintptrR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint]uintptr)
- v, changed := fastpathTV.DecMapUintUintptrV(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUintUintptrV(rv2i(rv).(map[uint]uintptr), false, d)
- }
-}
-func (f fastpathT) DecMapUintUintptrX(vp *map[uint]uintptr, d *Decoder) {
- v, changed := f.DecMapUintUintptrV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUintUintptrV(v map[uint]uintptr, canChange bool,
- d *Decoder) (_ map[uint]uintptr, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
- v = make(map[uint]uintptr, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint
- var mv uintptr
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUintIntR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint]int)
- v, changed := fastpathTV.DecMapUintIntV(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUintIntV(rv2i(rv).(map[uint]int), false, d)
- }
-}
-func (f fastpathT) DecMapUintIntX(vp *map[uint]int, d *Decoder) {
- v, changed := f.DecMapUintIntV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUintIntV(v map[uint]int, canChange bool,
- d *Decoder) (_ map[uint]int, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
- v = make(map[uint]int, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint
- var mv int
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUintInt8R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint]int8)
- v, changed := fastpathTV.DecMapUintInt8V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUintInt8V(rv2i(rv).(map[uint]int8), false, d)
- }
-}
-func (f fastpathT) DecMapUintInt8X(vp *map[uint]int8, d *Decoder) {
- v, changed := f.DecMapUintInt8V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUintInt8V(v map[uint]int8, canChange bool,
- d *Decoder) (_ map[uint]int8, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
- v = make(map[uint]int8, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint
- var mv int8
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = int8(chkOvf.IntV(dd.DecodeInt64(), 8))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUintInt16R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint]int16)
- v, changed := fastpathTV.DecMapUintInt16V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUintInt16V(rv2i(rv).(map[uint]int16), false, d)
- }
-}
-func (f fastpathT) DecMapUintInt16X(vp *map[uint]int16, d *Decoder) {
- v, changed := f.DecMapUintInt16V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUintInt16V(v map[uint]int16, canChange bool,
- d *Decoder) (_ map[uint]int16, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 10)
- v = make(map[uint]int16, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint
- var mv int16
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = int16(chkOvf.IntV(dd.DecodeInt64(), 16))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUintInt32R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint]int32)
- v, changed := fastpathTV.DecMapUintInt32V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUintInt32V(rv2i(rv).(map[uint]int32), false, d)
- }
-}
-func (f fastpathT) DecMapUintInt32X(vp *map[uint]int32, d *Decoder) {
- v, changed := f.DecMapUintInt32V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUintInt32V(v map[uint]int32, canChange bool,
- d *Decoder) (_ map[uint]int32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
- v = make(map[uint]int32, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint
- var mv int32
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = int32(chkOvf.IntV(dd.DecodeInt64(), 32))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUintInt64R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint]int64)
- v, changed := fastpathTV.DecMapUintInt64V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUintInt64V(rv2i(rv).(map[uint]int64), false, d)
- }
-}
-func (f fastpathT) DecMapUintInt64X(vp *map[uint]int64, d *Decoder) {
- v, changed := f.DecMapUintInt64V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUintInt64V(v map[uint]int64, canChange bool,
- d *Decoder) (_ map[uint]int64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
- v = make(map[uint]int64, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint
- var mv int64
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = dd.DecodeInt64()
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUintFloat32R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint]float32)
- v, changed := fastpathTV.DecMapUintFloat32V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUintFloat32V(rv2i(rv).(map[uint]float32), false, d)
- }
-}
-func (f fastpathT) DecMapUintFloat32X(vp *map[uint]float32, d *Decoder) {
- v, changed := f.DecMapUintFloat32V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUintFloat32V(v map[uint]float32, canChange bool,
- d *Decoder) (_ map[uint]float32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
- v = make(map[uint]float32, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint
- var mv float32
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = float32(chkOvf.Float32V(dd.DecodeFloat64()))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUintFloat64R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint]float64)
- v, changed := fastpathTV.DecMapUintFloat64V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUintFloat64V(rv2i(rv).(map[uint]float64), false, d)
- }
-}
-func (f fastpathT) DecMapUintFloat64X(vp *map[uint]float64, d *Decoder) {
- v, changed := f.DecMapUintFloat64V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUintFloat64V(v map[uint]float64, canChange bool,
- d *Decoder) (_ map[uint]float64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
- v = make(map[uint]float64, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint
- var mv float64
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = dd.DecodeFloat64()
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUintBoolR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint]bool)
- v, changed := fastpathTV.DecMapUintBoolV(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUintBoolV(rv2i(rv).(map[uint]bool), false, d)
- }
-}
-func (f fastpathT) DecMapUintBoolX(vp *map[uint]bool, d *Decoder) {
- v, changed := f.DecMapUintBoolV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUintBoolV(v map[uint]bool, canChange bool,
- d *Decoder) (_ map[uint]bool, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
- v = make(map[uint]bool, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint
- var mv bool
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = false
- }
- continue
- }
- mv = dd.DecodeBool()
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUint8IntfR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint8]interface{})
- v, changed := fastpathTV.DecMapUint8IntfV(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUint8IntfV(rv2i(rv).(map[uint8]interface{}), false, d)
- }
-}
-func (f fastpathT) DecMapUint8IntfX(vp *map[uint8]interface{}, d *Decoder) {
- v, changed := f.DecMapUint8IntfV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUint8IntfV(v map[uint8]interface{}, canChange bool,
- d *Decoder) (_ map[uint8]interface{}, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 17)
- v = make(map[uint8]interface{}, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset
- var mk uint8
- var mv interface{}
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uint8(chkOvf.UintV(dd.DecodeUint64(), 8))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = nil
- }
- continue
- }
- if mapGet {
- mv = v[mk]
- } else {
- mv = nil
- }
- d.decode(&mv)
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUint8StringR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint8]string)
- v, changed := fastpathTV.DecMapUint8StringV(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUint8StringV(rv2i(rv).(map[uint8]string), false, d)
- }
-}
-func (f fastpathT) DecMapUint8StringX(vp *map[uint8]string, d *Decoder) {
- v, changed := f.DecMapUint8StringV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUint8StringV(v map[uint8]string, canChange bool,
- d *Decoder) (_ map[uint8]string, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 17)
- v = make(map[uint8]string, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint8
- var mv string
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uint8(chkOvf.UintV(dd.DecodeUint64(), 8))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = ""
- }
- continue
- }
- mv = dd.DecodeString()
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUint8UintR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint8]uint)
- v, changed := fastpathTV.DecMapUint8UintV(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUint8UintV(rv2i(rv).(map[uint8]uint), false, d)
- }
-}
-func (f fastpathT) DecMapUint8UintX(vp *map[uint8]uint, d *Decoder) {
- v, changed := f.DecMapUint8UintV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUint8UintV(v map[uint8]uint, canChange bool,
- d *Decoder) (_ map[uint8]uint, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
- v = make(map[uint8]uint, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint8
- var mv uint
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uint8(chkOvf.UintV(dd.DecodeUint64(), 8))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUint8Uint8R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint8]uint8)
- v, changed := fastpathTV.DecMapUint8Uint8V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUint8Uint8V(rv2i(rv).(map[uint8]uint8), false, d)
- }
-}
-func (f fastpathT) DecMapUint8Uint8X(vp *map[uint8]uint8, d *Decoder) {
- v, changed := f.DecMapUint8Uint8V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUint8Uint8V(v map[uint8]uint8, canChange bool,
- d *Decoder) (_ map[uint8]uint8, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 2)
- v = make(map[uint8]uint8, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint8
- var mv uint8
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uint8(chkOvf.UintV(dd.DecodeUint64(), 8))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uint8(chkOvf.UintV(dd.DecodeUint64(), 8))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUint8Uint16R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint8]uint16)
- v, changed := fastpathTV.DecMapUint8Uint16V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUint8Uint16V(rv2i(rv).(map[uint8]uint16), false, d)
- }
-}
-func (f fastpathT) DecMapUint8Uint16X(vp *map[uint8]uint16, d *Decoder) {
- v, changed := f.DecMapUint8Uint16V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUint8Uint16V(v map[uint8]uint16, canChange bool,
- d *Decoder) (_ map[uint8]uint16, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 3)
- v = make(map[uint8]uint16, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint8
- var mv uint16
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uint8(chkOvf.UintV(dd.DecodeUint64(), 8))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uint16(chkOvf.UintV(dd.DecodeUint64(), 16))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUint8Uint32R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint8]uint32)
- v, changed := fastpathTV.DecMapUint8Uint32V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUint8Uint32V(rv2i(rv).(map[uint8]uint32), false, d)
- }
-}
-func (f fastpathT) DecMapUint8Uint32X(vp *map[uint8]uint32, d *Decoder) {
- v, changed := f.DecMapUint8Uint32V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUint8Uint32V(v map[uint8]uint32, canChange bool,
- d *Decoder) (_ map[uint8]uint32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 5)
- v = make(map[uint8]uint32, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint8
- var mv uint32
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uint8(chkOvf.UintV(dd.DecodeUint64(), 8))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uint32(chkOvf.UintV(dd.DecodeUint64(), 32))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUint8Uint64R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint8]uint64)
- v, changed := fastpathTV.DecMapUint8Uint64V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUint8Uint64V(rv2i(rv).(map[uint8]uint64), false, d)
- }
-}
-func (f fastpathT) DecMapUint8Uint64X(vp *map[uint8]uint64, d *Decoder) {
- v, changed := f.DecMapUint8Uint64V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUint8Uint64V(v map[uint8]uint64, canChange bool,
- d *Decoder) (_ map[uint8]uint64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
- v = make(map[uint8]uint64, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint8
- var mv uint64
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uint8(chkOvf.UintV(dd.DecodeUint64(), 8))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = dd.DecodeUint64()
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUint8UintptrR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint8]uintptr)
- v, changed := fastpathTV.DecMapUint8UintptrV(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUint8UintptrV(rv2i(rv).(map[uint8]uintptr), false, d)
- }
-}
-func (f fastpathT) DecMapUint8UintptrX(vp *map[uint8]uintptr, d *Decoder) {
- v, changed := f.DecMapUint8UintptrV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUint8UintptrV(v map[uint8]uintptr, canChange bool,
- d *Decoder) (_ map[uint8]uintptr, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
- v = make(map[uint8]uintptr, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint8
- var mv uintptr
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uint8(chkOvf.UintV(dd.DecodeUint64(), 8))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUint8IntR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint8]int)
- v, changed := fastpathTV.DecMapUint8IntV(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUint8IntV(rv2i(rv).(map[uint8]int), false, d)
- }
-}
-func (f fastpathT) DecMapUint8IntX(vp *map[uint8]int, d *Decoder) {
- v, changed := f.DecMapUint8IntV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUint8IntV(v map[uint8]int, canChange bool,
- d *Decoder) (_ map[uint8]int, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
- v = make(map[uint8]int, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint8
- var mv int
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uint8(chkOvf.UintV(dd.DecodeUint64(), 8))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUint8Int8R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint8]int8)
- v, changed := fastpathTV.DecMapUint8Int8V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUint8Int8V(rv2i(rv).(map[uint8]int8), false, d)
- }
-}
-func (f fastpathT) DecMapUint8Int8X(vp *map[uint8]int8, d *Decoder) {
- v, changed := f.DecMapUint8Int8V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUint8Int8V(v map[uint8]int8, canChange bool,
- d *Decoder) (_ map[uint8]int8, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 2)
- v = make(map[uint8]int8, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint8
- var mv int8
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uint8(chkOvf.UintV(dd.DecodeUint64(), 8))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = int8(chkOvf.IntV(dd.DecodeInt64(), 8))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUint8Int16R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint8]int16)
- v, changed := fastpathTV.DecMapUint8Int16V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUint8Int16V(rv2i(rv).(map[uint8]int16), false, d)
- }
-}
-func (f fastpathT) DecMapUint8Int16X(vp *map[uint8]int16, d *Decoder) {
- v, changed := f.DecMapUint8Int16V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUint8Int16V(v map[uint8]int16, canChange bool,
- d *Decoder) (_ map[uint8]int16, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 3)
- v = make(map[uint8]int16, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint8
- var mv int16
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uint8(chkOvf.UintV(dd.DecodeUint64(), 8))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = int16(chkOvf.IntV(dd.DecodeInt64(), 16))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUint8Int32R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint8]int32)
- v, changed := fastpathTV.DecMapUint8Int32V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUint8Int32V(rv2i(rv).(map[uint8]int32), false, d)
- }
-}
-func (f fastpathT) DecMapUint8Int32X(vp *map[uint8]int32, d *Decoder) {
- v, changed := f.DecMapUint8Int32V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUint8Int32V(v map[uint8]int32, canChange bool,
- d *Decoder) (_ map[uint8]int32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 5)
- v = make(map[uint8]int32, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint8
- var mv int32
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uint8(chkOvf.UintV(dd.DecodeUint64(), 8))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = int32(chkOvf.IntV(dd.DecodeInt64(), 32))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUint8Int64R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint8]int64)
- v, changed := fastpathTV.DecMapUint8Int64V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUint8Int64V(rv2i(rv).(map[uint8]int64), false, d)
- }
-}
-func (f fastpathT) DecMapUint8Int64X(vp *map[uint8]int64, d *Decoder) {
- v, changed := f.DecMapUint8Int64V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUint8Int64V(v map[uint8]int64, canChange bool,
- d *Decoder) (_ map[uint8]int64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
- v = make(map[uint8]int64, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint8
- var mv int64
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uint8(chkOvf.UintV(dd.DecodeUint64(), 8))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = dd.DecodeInt64()
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUint8Float32R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint8]float32)
- v, changed := fastpathTV.DecMapUint8Float32V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUint8Float32V(rv2i(rv).(map[uint8]float32), false, d)
- }
-}
-func (f fastpathT) DecMapUint8Float32X(vp *map[uint8]float32, d *Decoder) {
- v, changed := f.DecMapUint8Float32V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUint8Float32V(v map[uint8]float32, canChange bool,
- d *Decoder) (_ map[uint8]float32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 5)
- v = make(map[uint8]float32, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint8
- var mv float32
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uint8(chkOvf.UintV(dd.DecodeUint64(), 8))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = float32(chkOvf.Float32V(dd.DecodeFloat64()))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUint8Float64R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint8]float64)
- v, changed := fastpathTV.DecMapUint8Float64V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUint8Float64V(rv2i(rv).(map[uint8]float64), false, d)
- }
-}
-func (f fastpathT) DecMapUint8Float64X(vp *map[uint8]float64, d *Decoder) {
- v, changed := f.DecMapUint8Float64V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUint8Float64V(v map[uint8]float64, canChange bool,
- d *Decoder) (_ map[uint8]float64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
- v = make(map[uint8]float64, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint8
- var mv float64
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uint8(chkOvf.UintV(dd.DecodeUint64(), 8))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = dd.DecodeFloat64()
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUint8BoolR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint8]bool)
- v, changed := fastpathTV.DecMapUint8BoolV(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUint8BoolV(rv2i(rv).(map[uint8]bool), false, d)
- }
-}
-func (f fastpathT) DecMapUint8BoolX(vp *map[uint8]bool, d *Decoder) {
- v, changed := f.DecMapUint8BoolV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUint8BoolV(v map[uint8]bool, canChange bool,
- d *Decoder) (_ map[uint8]bool, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 2)
- v = make(map[uint8]bool, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint8
- var mv bool
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uint8(chkOvf.UintV(dd.DecodeUint64(), 8))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = false
- }
- continue
- }
- mv = dd.DecodeBool()
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUint16IntfR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint16]interface{})
- v, changed := fastpathTV.DecMapUint16IntfV(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUint16IntfV(rv2i(rv).(map[uint16]interface{}), false, d)
- }
-}
-func (f fastpathT) DecMapUint16IntfX(vp *map[uint16]interface{}, d *Decoder) {
- v, changed := f.DecMapUint16IntfV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUint16IntfV(v map[uint16]interface{}, canChange bool,
- d *Decoder) (_ map[uint16]interface{}, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 18)
- v = make(map[uint16]interface{}, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset
- var mk uint16
- var mv interface{}
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uint16(chkOvf.UintV(dd.DecodeUint64(), 16))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = nil
- }
- continue
- }
- if mapGet {
- mv = v[mk]
- } else {
- mv = nil
- }
- d.decode(&mv)
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUint16StringR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint16]string)
- v, changed := fastpathTV.DecMapUint16StringV(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUint16StringV(rv2i(rv).(map[uint16]string), false, d)
- }
-}
-func (f fastpathT) DecMapUint16StringX(vp *map[uint16]string, d *Decoder) {
- v, changed := f.DecMapUint16StringV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUint16StringV(v map[uint16]string, canChange bool,
- d *Decoder) (_ map[uint16]string, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 18)
- v = make(map[uint16]string, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint16
- var mv string
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uint16(chkOvf.UintV(dd.DecodeUint64(), 16))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = ""
- }
- continue
- }
- mv = dd.DecodeString()
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUint16UintR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint16]uint)
- v, changed := fastpathTV.DecMapUint16UintV(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUint16UintV(rv2i(rv).(map[uint16]uint), false, d)
- }
-}
-func (f fastpathT) DecMapUint16UintX(vp *map[uint16]uint, d *Decoder) {
- v, changed := f.DecMapUint16UintV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUint16UintV(v map[uint16]uint, canChange bool,
- d *Decoder) (_ map[uint16]uint, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 10)
- v = make(map[uint16]uint, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint16
- var mv uint
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uint16(chkOvf.UintV(dd.DecodeUint64(), 16))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUint16Uint8R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint16]uint8)
- v, changed := fastpathTV.DecMapUint16Uint8V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUint16Uint8V(rv2i(rv).(map[uint16]uint8), false, d)
- }
-}
-func (f fastpathT) DecMapUint16Uint8X(vp *map[uint16]uint8, d *Decoder) {
- v, changed := f.DecMapUint16Uint8V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUint16Uint8V(v map[uint16]uint8, canChange bool,
- d *Decoder) (_ map[uint16]uint8, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 3)
- v = make(map[uint16]uint8, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint16
- var mv uint8
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uint16(chkOvf.UintV(dd.DecodeUint64(), 16))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uint8(chkOvf.UintV(dd.DecodeUint64(), 8))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUint16Uint16R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint16]uint16)
- v, changed := fastpathTV.DecMapUint16Uint16V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUint16Uint16V(rv2i(rv).(map[uint16]uint16), false, d)
- }
-}
-func (f fastpathT) DecMapUint16Uint16X(vp *map[uint16]uint16, d *Decoder) {
- v, changed := f.DecMapUint16Uint16V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUint16Uint16V(v map[uint16]uint16, canChange bool,
- d *Decoder) (_ map[uint16]uint16, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 4)
- v = make(map[uint16]uint16, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint16
- var mv uint16
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uint16(chkOvf.UintV(dd.DecodeUint64(), 16))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uint16(chkOvf.UintV(dd.DecodeUint64(), 16))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUint16Uint32R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint16]uint32)
- v, changed := fastpathTV.DecMapUint16Uint32V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUint16Uint32V(rv2i(rv).(map[uint16]uint32), false, d)
- }
-}
-func (f fastpathT) DecMapUint16Uint32X(vp *map[uint16]uint32, d *Decoder) {
- v, changed := f.DecMapUint16Uint32V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUint16Uint32V(v map[uint16]uint32, canChange bool,
- d *Decoder) (_ map[uint16]uint32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 6)
- v = make(map[uint16]uint32, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint16
- var mv uint32
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uint16(chkOvf.UintV(dd.DecodeUint64(), 16))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uint32(chkOvf.UintV(dd.DecodeUint64(), 32))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUint16Uint64R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint16]uint64)
- v, changed := fastpathTV.DecMapUint16Uint64V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUint16Uint64V(rv2i(rv).(map[uint16]uint64), false, d)
- }
-}
-func (f fastpathT) DecMapUint16Uint64X(vp *map[uint16]uint64, d *Decoder) {
- v, changed := f.DecMapUint16Uint64V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUint16Uint64V(v map[uint16]uint64, canChange bool,
- d *Decoder) (_ map[uint16]uint64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 10)
- v = make(map[uint16]uint64, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint16
- var mv uint64
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uint16(chkOvf.UintV(dd.DecodeUint64(), 16))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = dd.DecodeUint64()
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUint16UintptrR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint16]uintptr)
- v, changed := fastpathTV.DecMapUint16UintptrV(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUint16UintptrV(rv2i(rv).(map[uint16]uintptr), false, d)
- }
-}
-func (f fastpathT) DecMapUint16UintptrX(vp *map[uint16]uintptr, d *Decoder) {
- v, changed := f.DecMapUint16UintptrV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUint16UintptrV(v map[uint16]uintptr, canChange bool,
- d *Decoder) (_ map[uint16]uintptr, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 10)
- v = make(map[uint16]uintptr, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint16
- var mv uintptr
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uint16(chkOvf.UintV(dd.DecodeUint64(), 16))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUint16IntR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint16]int)
- v, changed := fastpathTV.DecMapUint16IntV(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUint16IntV(rv2i(rv).(map[uint16]int), false, d)
- }
-}
-func (f fastpathT) DecMapUint16IntX(vp *map[uint16]int, d *Decoder) {
- v, changed := f.DecMapUint16IntV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUint16IntV(v map[uint16]int, canChange bool,
- d *Decoder) (_ map[uint16]int, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 10)
- v = make(map[uint16]int, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint16
- var mv int
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uint16(chkOvf.UintV(dd.DecodeUint64(), 16))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUint16Int8R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint16]int8)
- v, changed := fastpathTV.DecMapUint16Int8V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUint16Int8V(rv2i(rv).(map[uint16]int8), false, d)
- }
-}
-func (f fastpathT) DecMapUint16Int8X(vp *map[uint16]int8, d *Decoder) {
- v, changed := f.DecMapUint16Int8V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUint16Int8V(v map[uint16]int8, canChange bool,
- d *Decoder) (_ map[uint16]int8, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 3)
- v = make(map[uint16]int8, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint16
- var mv int8
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uint16(chkOvf.UintV(dd.DecodeUint64(), 16))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = int8(chkOvf.IntV(dd.DecodeInt64(), 8))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUint16Int16R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint16]int16)
- v, changed := fastpathTV.DecMapUint16Int16V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUint16Int16V(rv2i(rv).(map[uint16]int16), false, d)
- }
-}
-func (f fastpathT) DecMapUint16Int16X(vp *map[uint16]int16, d *Decoder) {
- v, changed := f.DecMapUint16Int16V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUint16Int16V(v map[uint16]int16, canChange bool,
- d *Decoder) (_ map[uint16]int16, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 4)
- v = make(map[uint16]int16, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint16
- var mv int16
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uint16(chkOvf.UintV(dd.DecodeUint64(), 16))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = int16(chkOvf.IntV(dd.DecodeInt64(), 16))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUint16Int32R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint16]int32)
- v, changed := fastpathTV.DecMapUint16Int32V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUint16Int32V(rv2i(rv).(map[uint16]int32), false, d)
- }
-}
-func (f fastpathT) DecMapUint16Int32X(vp *map[uint16]int32, d *Decoder) {
- v, changed := f.DecMapUint16Int32V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUint16Int32V(v map[uint16]int32, canChange bool,
- d *Decoder) (_ map[uint16]int32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 6)
- v = make(map[uint16]int32, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint16
- var mv int32
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uint16(chkOvf.UintV(dd.DecodeUint64(), 16))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = int32(chkOvf.IntV(dd.DecodeInt64(), 32))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUint16Int64R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint16]int64)
- v, changed := fastpathTV.DecMapUint16Int64V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUint16Int64V(rv2i(rv).(map[uint16]int64), false, d)
- }
-}
-func (f fastpathT) DecMapUint16Int64X(vp *map[uint16]int64, d *Decoder) {
- v, changed := f.DecMapUint16Int64V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUint16Int64V(v map[uint16]int64, canChange bool,
- d *Decoder) (_ map[uint16]int64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 10)
- v = make(map[uint16]int64, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint16
- var mv int64
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uint16(chkOvf.UintV(dd.DecodeUint64(), 16))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = dd.DecodeInt64()
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUint16Float32R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint16]float32)
- v, changed := fastpathTV.DecMapUint16Float32V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUint16Float32V(rv2i(rv).(map[uint16]float32), false, d)
- }
-}
-func (f fastpathT) DecMapUint16Float32X(vp *map[uint16]float32, d *Decoder) {
- v, changed := f.DecMapUint16Float32V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUint16Float32V(v map[uint16]float32, canChange bool,
- d *Decoder) (_ map[uint16]float32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 6)
- v = make(map[uint16]float32, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint16
- var mv float32
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uint16(chkOvf.UintV(dd.DecodeUint64(), 16))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = float32(chkOvf.Float32V(dd.DecodeFloat64()))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUint16Float64R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint16]float64)
- v, changed := fastpathTV.DecMapUint16Float64V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUint16Float64V(rv2i(rv).(map[uint16]float64), false, d)
- }
-}
-func (f fastpathT) DecMapUint16Float64X(vp *map[uint16]float64, d *Decoder) {
- v, changed := f.DecMapUint16Float64V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUint16Float64V(v map[uint16]float64, canChange bool,
- d *Decoder) (_ map[uint16]float64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 10)
- v = make(map[uint16]float64, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint16
- var mv float64
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uint16(chkOvf.UintV(dd.DecodeUint64(), 16))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = dd.DecodeFloat64()
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUint16BoolR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint16]bool)
- v, changed := fastpathTV.DecMapUint16BoolV(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUint16BoolV(rv2i(rv).(map[uint16]bool), false, d)
- }
-}
-func (f fastpathT) DecMapUint16BoolX(vp *map[uint16]bool, d *Decoder) {
- v, changed := f.DecMapUint16BoolV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUint16BoolV(v map[uint16]bool, canChange bool,
- d *Decoder) (_ map[uint16]bool, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 3)
- v = make(map[uint16]bool, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint16
- var mv bool
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uint16(chkOvf.UintV(dd.DecodeUint64(), 16))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = false
- }
- continue
- }
- mv = dd.DecodeBool()
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUint32IntfR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint32]interface{})
- v, changed := fastpathTV.DecMapUint32IntfV(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUint32IntfV(rv2i(rv).(map[uint32]interface{}), false, d)
- }
-}
-func (f fastpathT) DecMapUint32IntfX(vp *map[uint32]interface{}, d *Decoder) {
- v, changed := f.DecMapUint32IntfV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUint32IntfV(v map[uint32]interface{}, canChange bool,
- d *Decoder) (_ map[uint32]interface{}, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 20)
- v = make(map[uint32]interface{}, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset
- var mk uint32
- var mv interface{}
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uint32(chkOvf.UintV(dd.DecodeUint64(), 32))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = nil
- }
- continue
- }
- if mapGet {
- mv = v[mk]
- } else {
- mv = nil
- }
- d.decode(&mv)
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUint32StringR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint32]string)
- v, changed := fastpathTV.DecMapUint32StringV(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUint32StringV(rv2i(rv).(map[uint32]string), false, d)
- }
-}
-func (f fastpathT) DecMapUint32StringX(vp *map[uint32]string, d *Decoder) {
- v, changed := f.DecMapUint32StringV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUint32StringV(v map[uint32]string, canChange bool,
- d *Decoder) (_ map[uint32]string, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 20)
- v = make(map[uint32]string, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint32
- var mv string
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uint32(chkOvf.UintV(dd.DecodeUint64(), 32))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = ""
- }
- continue
- }
- mv = dd.DecodeString()
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUint32UintR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint32]uint)
- v, changed := fastpathTV.DecMapUint32UintV(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUint32UintV(rv2i(rv).(map[uint32]uint), false, d)
- }
-}
-func (f fastpathT) DecMapUint32UintX(vp *map[uint32]uint, d *Decoder) {
- v, changed := f.DecMapUint32UintV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUint32UintV(v map[uint32]uint, canChange bool,
- d *Decoder) (_ map[uint32]uint, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
- v = make(map[uint32]uint, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint32
- var mv uint
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uint32(chkOvf.UintV(dd.DecodeUint64(), 32))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUint32Uint8R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint32]uint8)
- v, changed := fastpathTV.DecMapUint32Uint8V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUint32Uint8V(rv2i(rv).(map[uint32]uint8), false, d)
- }
-}
-func (f fastpathT) DecMapUint32Uint8X(vp *map[uint32]uint8, d *Decoder) {
- v, changed := f.DecMapUint32Uint8V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUint32Uint8V(v map[uint32]uint8, canChange bool,
- d *Decoder) (_ map[uint32]uint8, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 5)
- v = make(map[uint32]uint8, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint32
- var mv uint8
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uint32(chkOvf.UintV(dd.DecodeUint64(), 32))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uint8(chkOvf.UintV(dd.DecodeUint64(), 8))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUint32Uint16R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint32]uint16)
- v, changed := fastpathTV.DecMapUint32Uint16V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUint32Uint16V(rv2i(rv).(map[uint32]uint16), false, d)
- }
-}
-func (f fastpathT) DecMapUint32Uint16X(vp *map[uint32]uint16, d *Decoder) {
- v, changed := f.DecMapUint32Uint16V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUint32Uint16V(v map[uint32]uint16, canChange bool,
- d *Decoder) (_ map[uint32]uint16, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 6)
- v = make(map[uint32]uint16, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint32
- var mv uint16
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uint32(chkOvf.UintV(dd.DecodeUint64(), 32))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uint16(chkOvf.UintV(dd.DecodeUint64(), 16))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUint32Uint32R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint32]uint32)
- v, changed := fastpathTV.DecMapUint32Uint32V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUint32Uint32V(rv2i(rv).(map[uint32]uint32), false, d)
- }
-}
-func (f fastpathT) DecMapUint32Uint32X(vp *map[uint32]uint32, d *Decoder) {
- v, changed := f.DecMapUint32Uint32V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUint32Uint32V(v map[uint32]uint32, canChange bool,
- d *Decoder) (_ map[uint32]uint32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 8)
- v = make(map[uint32]uint32, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint32
- var mv uint32
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uint32(chkOvf.UintV(dd.DecodeUint64(), 32))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uint32(chkOvf.UintV(dd.DecodeUint64(), 32))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUint32Uint64R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint32]uint64)
- v, changed := fastpathTV.DecMapUint32Uint64V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUint32Uint64V(rv2i(rv).(map[uint32]uint64), false, d)
- }
-}
-func (f fastpathT) DecMapUint32Uint64X(vp *map[uint32]uint64, d *Decoder) {
- v, changed := f.DecMapUint32Uint64V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUint32Uint64V(v map[uint32]uint64, canChange bool,
- d *Decoder) (_ map[uint32]uint64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
- v = make(map[uint32]uint64, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint32
- var mv uint64
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uint32(chkOvf.UintV(dd.DecodeUint64(), 32))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = dd.DecodeUint64()
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUint32UintptrR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint32]uintptr)
- v, changed := fastpathTV.DecMapUint32UintptrV(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUint32UintptrV(rv2i(rv).(map[uint32]uintptr), false, d)
- }
-}
-func (f fastpathT) DecMapUint32UintptrX(vp *map[uint32]uintptr, d *Decoder) {
- v, changed := f.DecMapUint32UintptrV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUint32UintptrV(v map[uint32]uintptr, canChange bool,
- d *Decoder) (_ map[uint32]uintptr, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
- v = make(map[uint32]uintptr, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint32
- var mv uintptr
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uint32(chkOvf.UintV(dd.DecodeUint64(), 32))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUint32IntR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint32]int)
- v, changed := fastpathTV.DecMapUint32IntV(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUint32IntV(rv2i(rv).(map[uint32]int), false, d)
- }
-}
-func (f fastpathT) DecMapUint32IntX(vp *map[uint32]int, d *Decoder) {
- v, changed := f.DecMapUint32IntV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUint32IntV(v map[uint32]int, canChange bool,
- d *Decoder) (_ map[uint32]int, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
- v = make(map[uint32]int, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint32
- var mv int
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uint32(chkOvf.UintV(dd.DecodeUint64(), 32))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUint32Int8R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint32]int8)
- v, changed := fastpathTV.DecMapUint32Int8V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUint32Int8V(rv2i(rv).(map[uint32]int8), false, d)
- }
-}
-func (f fastpathT) DecMapUint32Int8X(vp *map[uint32]int8, d *Decoder) {
- v, changed := f.DecMapUint32Int8V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUint32Int8V(v map[uint32]int8, canChange bool,
- d *Decoder) (_ map[uint32]int8, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 5)
- v = make(map[uint32]int8, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint32
- var mv int8
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uint32(chkOvf.UintV(dd.DecodeUint64(), 32))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = int8(chkOvf.IntV(dd.DecodeInt64(), 8))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUint32Int16R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint32]int16)
- v, changed := fastpathTV.DecMapUint32Int16V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUint32Int16V(rv2i(rv).(map[uint32]int16), false, d)
- }
-}
-func (f fastpathT) DecMapUint32Int16X(vp *map[uint32]int16, d *Decoder) {
- v, changed := f.DecMapUint32Int16V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUint32Int16V(v map[uint32]int16, canChange bool,
- d *Decoder) (_ map[uint32]int16, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 6)
- v = make(map[uint32]int16, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint32
- var mv int16
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uint32(chkOvf.UintV(dd.DecodeUint64(), 32))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = int16(chkOvf.IntV(dd.DecodeInt64(), 16))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUint32Int32R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint32]int32)
- v, changed := fastpathTV.DecMapUint32Int32V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUint32Int32V(rv2i(rv).(map[uint32]int32), false, d)
- }
-}
-func (f fastpathT) DecMapUint32Int32X(vp *map[uint32]int32, d *Decoder) {
- v, changed := f.DecMapUint32Int32V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUint32Int32V(v map[uint32]int32, canChange bool,
- d *Decoder) (_ map[uint32]int32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 8)
- v = make(map[uint32]int32, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint32
- var mv int32
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uint32(chkOvf.UintV(dd.DecodeUint64(), 32))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = int32(chkOvf.IntV(dd.DecodeInt64(), 32))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUint32Int64R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint32]int64)
- v, changed := fastpathTV.DecMapUint32Int64V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUint32Int64V(rv2i(rv).(map[uint32]int64), false, d)
- }
-}
-func (f fastpathT) DecMapUint32Int64X(vp *map[uint32]int64, d *Decoder) {
- v, changed := f.DecMapUint32Int64V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUint32Int64V(v map[uint32]int64, canChange bool,
- d *Decoder) (_ map[uint32]int64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
- v = make(map[uint32]int64, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint32
- var mv int64
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uint32(chkOvf.UintV(dd.DecodeUint64(), 32))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = dd.DecodeInt64()
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUint32Float32R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint32]float32)
- v, changed := fastpathTV.DecMapUint32Float32V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUint32Float32V(rv2i(rv).(map[uint32]float32), false, d)
- }
-}
-func (f fastpathT) DecMapUint32Float32X(vp *map[uint32]float32, d *Decoder) {
- v, changed := f.DecMapUint32Float32V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUint32Float32V(v map[uint32]float32, canChange bool,
- d *Decoder) (_ map[uint32]float32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 8)
- v = make(map[uint32]float32, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint32
- var mv float32
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uint32(chkOvf.UintV(dd.DecodeUint64(), 32))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = float32(chkOvf.Float32V(dd.DecodeFloat64()))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUint32Float64R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint32]float64)
- v, changed := fastpathTV.DecMapUint32Float64V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUint32Float64V(rv2i(rv).(map[uint32]float64), false, d)
- }
-}
-func (f fastpathT) DecMapUint32Float64X(vp *map[uint32]float64, d *Decoder) {
- v, changed := f.DecMapUint32Float64V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUint32Float64V(v map[uint32]float64, canChange bool,
- d *Decoder) (_ map[uint32]float64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
- v = make(map[uint32]float64, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint32
- var mv float64
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uint32(chkOvf.UintV(dd.DecodeUint64(), 32))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = dd.DecodeFloat64()
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUint32BoolR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint32]bool)
- v, changed := fastpathTV.DecMapUint32BoolV(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUint32BoolV(rv2i(rv).(map[uint32]bool), false, d)
- }
-}
-func (f fastpathT) DecMapUint32BoolX(vp *map[uint32]bool, d *Decoder) {
- v, changed := f.DecMapUint32BoolV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUint32BoolV(v map[uint32]bool, canChange bool,
- d *Decoder) (_ map[uint32]bool, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 5)
- v = make(map[uint32]bool, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint32
- var mv bool
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uint32(chkOvf.UintV(dd.DecodeUint64(), 32))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = false
- }
- continue
- }
- mv = dd.DecodeBool()
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUint64IntfR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint64]interface{})
- v, changed := fastpathTV.DecMapUint64IntfV(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUint64IntfV(rv2i(rv).(map[uint64]interface{}), false, d)
- }
-}
-func (f fastpathT) DecMapUint64IntfX(vp *map[uint64]interface{}, d *Decoder) {
- v, changed := f.DecMapUint64IntfV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUint64IntfV(v map[uint64]interface{}, canChange bool,
- d *Decoder) (_ map[uint64]interface{}, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 24)
- v = make(map[uint64]interface{}, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset
- var mk uint64
- var mv interface{}
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeUint64()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = nil
- }
- continue
- }
- if mapGet {
- mv = v[mk]
- } else {
- mv = nil
- }
- d.decode(&mv)
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUint64StringR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint64]string)
- v, changed := fastpathTV.DecMapUint64StringV(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUint64StringV(rv2i(rv).(map[uint64]string), false, d)
- }
-}
-func (f fastpathT) DecMapUint64StringX(vp *map[uint64]string, d *Decoder) {
- v, changed := f.DecMapUint64StringV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUint64StringV(v map[uint64]string, canChange bool,
- d *Decoder) (_ map[uint64]string, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 24)
- v = make(map[uint64]string, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint64
- var mv string
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeUint64()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = ""
- }
- continue
- }
- mv = dd.DecodeString()
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUint64UintR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint64]uint)
- v, changed := fastpathTV.DecMapUint64UintV(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUint64UintV(rv2i(rv).(map[uint64]uint), false, d)
- }
-}
-func (f fastpathT) DecMapUint64UintX(vp *map[uint64]uint, d *Decoder) {
- v, changed := f.DecMapUint64UintV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUint64UintV(v map[uint64]uint, canChange bool,
- d *Decoder) (_ map[uint64]uint, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
- v = make(map[uint64]uint, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint64
- var mv uint
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeUint64()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUint64Uint8R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint64]uint8)
- v, changed := fastpathTV.DecMapUint64Uint8V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUint64Uint8V(rv2i(rv).(map[uint64]uint8), false, d)
- }
-}
-func (f fastpathT) DecMapUint64Uint8X(vp *map[uint64]uint8, d *Decoder) {
- v, changed := f.DecMapUint64Uint8V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUint64Uint8V(v map[uint64]uint8, canChange bool,
- d *Decoder) (_ map[uint64]uint8, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
- v = make(map[uint64]uint8, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint64
- var mv uint8
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeUint64()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uint8(chkOvf.UintV(dd.DecodeUint64(), 8))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUint64Uint16R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint64]uint16)
- v, changed := fastpathTV.DecMapUint64Uint16V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUint64Uint16V(rv2i(rv).(map[uint64]uint16), false, d)
- }
-}
-func (f fastpathT) DecMapUint64Uint16X(vp *map[uint64]uint16, d *Decoder) {
- v, changed := f.DecMapUint64Uint16V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUint64Uint16V(v map[uint64]uint16, canChange bool,
- d *Decoder) (_ map[uint64]uint16, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 10)
- v = make(map[uint64]uint16, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint64
- var mv uint16
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeUint64()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uint16(chkOvf.UintV(dd.DecodeUint64(), 16))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUint64Uint32R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint64]uint32)
- v, changed := fastpathTV.DecMapUint64Uint32V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUint64Uint32V(rv2i(rv).(map[uint64]uint32), false, d)
- }
-}
-func (f fastpathT) DecMapUint64Uint32X(vp *map[uint64]uint32, d *Decoder) {
- v, changed := f.DecMapUint64Uint32V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUint64Uint32V(v map[uint64]uint32, canChange bool,
- d *Decoder) (_ map[uint64]uint32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
- v = make(map[uint64]uint32, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint64
- var mv uint32
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeUint64()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uint32(chkOvf.UintV(dd.DecodeUint64(), 32))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUint64Uint64R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint64]uint64)
- v, changed := fastpathTV.DecMapUint64Uint64V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUint64Uint64V(rv2i(rv).(map[uint64]uint64), false, d)
- }
-}
-func (f fastpathT) DecMapUint64Uint64X(vp *map[uint64]uint64, d *Decoder) {
- v, changed := f.DecMapUint64Uint64V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUint64Uint64V(v map[uint64]uint64, canChange bool,
- d *Decoder) (_ map[uint64]uint64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
- v = make(map[uint64]uint64, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint64
- var mv uint64
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeUint64()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = dd.DecodeUint64()
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUint64UintptrR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint64]uintptr)
- v, changed := fastpathTV.DecMapUint64UintptrV(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUint64UintptrV(rv2i(rv).(map[uint64]uintptr), false, d)
- }
-}
-func (f fastpathT) DecMapUint64UintptrX(vp *map[uint64]uintptr, d *Decoder) {
- v, changed := f.DecMapUint64UintptrV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUint64UintptrV(v map[uint64]uintptr, canChange bool,
- d *Decoder) (_ map[uint64]uintptr, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
- v = make(map[uint64]uintptr, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint64
- var mv uintptr
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeUint64()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUint64IntR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint64]int)
- v, changed := fastpathTV.DecMapUint64IntV(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUint64IntV(rv2i(rv).(map[uint64]int), false, d)
- }
-}
-func (f fastpathT) DecMapUint64IntX(vp *map[uint64]int, d *Decoder) {
- v, changed := f.DecMapUint64IntV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUint64IntV(v map[uint64]int, canChange bool,
- d *Decoder) (_ map[uint64]int, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
- v = make(map[uint64]int, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint64
- var mv int
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeUint64()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUint64Int8R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint64]int8)
- v, changed := fastpathTV.DecMapUint64Int8V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUint64Int8V(rv2i(rv).(map[uint64]int8), false, d)
- }
-}
-func (f fastpathT) DecMapUint64Int8X(vp *map[uint64]int8, d *Decoder) {
- v, changed := f.DecMapUint64Int8V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUint64Int8V(v map[uint64]int8, canChange bool,
- d *Decoder) (_ map[uint64]int8, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
- v = make(map[uint64]int8, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint64
- var mv int8
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeUint64()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = int8(chkOvf.IntV(dd.DecodeInt64(), 8))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUint64Int16R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint64]int16)
- v, changed := fastpathTV.DecMapUint64Int16V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUint64Int16V(rv2i(rv).(map[uint64]int16), false, d)
- }
-}
-func (f fastpathT) DecMapUint64Int16X(vp *map[uint64]int16, d *Decoder) {
- v, changed := f.DecMapUint64Int16V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUint64Int16V(v map[uint64]int16, canChange bool,
- d *Decoder) (_ map[uint64]int16, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 10)
- v = make(map[uint64]int16, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint64
- var mv int16
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeUint64()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = int16(chkOvf.IntV(dd.DecodeInt64(), 16))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUint64Int32R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint64]int32)
- v, changed := fastpathTV.DecMapUint64Int32V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUint64Int32V(rv2i(rv).(map[uint64]int32), false, d)
- }
-}
-func (f fastpathT) DecMapUint64Int32X(vp *map[uint64]int32, d *Decoder) {
- v, changed := f.DecMapUint64Int32V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUint64Int32V(v map[uint64]int32, canChange bool,
- d *Decoder) (_ map[uint64]int32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
- v = make(map[uint64]int32, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint64
- var mv int32
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeUint64()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = int32(chkOvf.IntV(dd.DecodeInt64(), 32))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUint64Int64R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint64]int64)
- v, changed := fastpathTV.DecMapUint64Int64V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUint64Int64V(rv2i(rv).(map[uint64]int64), false, d)
- }
-}
-func (f fastpathT) DecMapUint64Int64X(vp *map[uint64]int64, d *Decoder) {
- v, changed := f.DecMapUint64Int64V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUint64Int64V(v map[uint64]int64, canChange bool,
- d *Decoder) (_ map[uint64]int64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
- v = make(map[uint64]int64, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint64
- var mv int64
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeUint64()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = dd.DecodeInt64()
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUint64Float32R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint64]float32)
- v, changed := fastpathTV.DecMapUint64Float32V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUint64Float32V(rv2i(rv).(map[uint64]float32), false, d)
- }
-}
-func (f fastpathT) DecMapUint64Float32X(vp *map[uint64]float32, d *Decoder) {
- v, changed := f.DecMapUint64Float32V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUint64Float32V(v map[uint64]float32, canChange bool,
- d *Decoder) (_ map[uint64]float32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
- v = make(map[uint64]float32, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint64
- var mv float32
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeUint64()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = float32(chkOvf.Float32V(dd.DecodeFloat64()))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUint64Float64R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint64]float64)
- v, changed := fastpathTV.DecMapUint64Float64V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUint64Float64V(rv2i(rv).(map[uint64]float64), false, d)
- }
-}
-func (f fastpathT) DecMapUint64Float64X(vp *map[uint64]float64, d *Decoder) {
- v, changed := f.DecMapUint64Float64V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUint64Float64V(v map[uint64]float64, canChange bool,
- d *Decoder) (_ map[uint64]float64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
- v = make(map[uint64]float64, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint64
- var mv float64
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeUint64()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = dd.DecodeFloat64()
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUint64BoolR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uint64]bool)
- v, changed := fastpathTV.DecMapUint64BoolV(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUint64BoolV(rv2i(rv).(map[uint64]bool), false, d)
- }
-}
-func (f fastpathT) DecMapUint64BoolX(vp *map[uint64]bool, d *Decoder) {
- v, changed := f.DecMapUint64BoolV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUint64BoolV(v map[uint64]bool, canChange bool,
- d *Decoder) (_ map[uint64]bool, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
- v = make(map[uint64]bool, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uint64
- var mv bool
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeUint64()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = false
- }
- continue
- }
- mv = dd.DecodeBool()
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUintptrIntfR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uintptr]interface{})
- v, changed := fastpathTV.DecMapUintptrIntfV(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUintptrIntfV(rv2i(rv).(map[uintptr]interface{}), false, d)
- }
-}
-func (f fastpathT) DecMapUintptrIntfX(vp *map[uintptr]interface{}, d *Decoder) {
- v, changed := f.DecMapUintptrIntfV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUintptrIntfV(v map[uintptr]interface{}, canChange bool,
- d *Decoder) (_ map[uintptr]interface{}, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 24)
- v = make(map[uintptr]interface{}, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset
- var mk uintptr
- var mv interface{}
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = nil
- }
- continue
- }
- if mapGet {
- mv = v[mk]
- } else {
- mv = nil
- }
- d.decode(&mv)
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUintptrStringR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uintptr]string)
- v, changed := fastpathTV.DecMapUintptrStringV(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUintptrStringV(rv2i(rv).(map[uintptr]string), false, d)
- }
-}
-func (f fastpathT) DecMapUintptrStringX(vp *map[uintptr]string, d *Decoder) {
- v, changed := f.DecMapUintptrStringV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUintptrStringV(v map[uintptr]string, canChange bool,
- d *Decoder) (_ map[uintptr]string, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 24)
- v = make(map[uintptr]string, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uintptr
- var mv string
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = ""
- }
- continue
- }
- mv = dd.DecodeString()
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUintptrUintR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uintptr]uint)
- v, changed := fastpathTV.DecMapUintptrUintV(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUintptrUintV(rv2i(rv).(map[uintptr]uint), false, d)
- }
-}
-func (f fastpathT) DecMapUintptrUintX(vp *map[uintptr]uint, d *Decoder) {
- v, changed := f.DecMapUintptrUintV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUintptrUintV(v map[uintptr]uint, canChange bool,
- d *Decoder) (_ map[uintptr]uint, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
- v = make(map[uintptr]uint, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uintptr
- var mv uint
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUintptrUint8R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uintptr]uint8)
- v, changed := fastpathTV.DecMapUintptrUint8V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUintptrUint8V(rv2i(rv).(map[uintptr]uint8), false, d)
- }
-}
-func (f fastpathT) DecMapUintptrUint8X(vp *map[uintptr]uint8, d *Decoder) {
- v, changed := f.DecMapUintptrUint8V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUintptrUint8V(v map[uintptr]uint8, canChange bool,
- d *Decoder) (_ map[uintptr]uint8, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
- v = make(map[uintptr]uint8, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uintptr
- var mv uint8
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uint8(chkOvf.UintV(dd.DecodeUint64(), 8))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUintptrUint16R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uintptr]uint16)
- v, changed := fastpathTV.DecMapUintptrUint16V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUintptrUint16V(rv2i(rv).(map[uintptr]uint16), false, d)
- }
-}
-func (f fastpathT) DecMapUintptrUint16X(vp *map[uintptr]uint16, d *Decoder) {
- v, changed := f.DecMapUintptrUint16V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUintptrUint16V(v map[uintptr]uint16, canChange bool,
- d *Decoder) (_ map[uintptr]uint16, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 10)
- v = make(map[uintptr]uint16, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uintptr
- var mv uint16
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uint16(chkOvf.UintV(dd.DecodeUint64(), 16))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUintptrUint32R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uintptr]uint32)
- v, changed := fastpathTV.DecMapUintptrUint32V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUintptrUint32V(rv2i(rv).(map[uintptr]uint32), false, d)
- }
-}
-func (f fastpathT) DecMapUintptrUint32X(vp *map[uintptr]uint32, d *Decoder) {
- v, changed := f.DecMapUintptrUint32V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUintptrUint32V(v map[uintptr]uint32, canChange bool,
- d *Decoder) (_ map[uintptr]uint32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
- v = make(map[uintptr]uint32, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uintptr
- var mv uint32
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uint32(chkOvf.UintV(dd.DecodeUint64(), 32))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUintptrUint64R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uintptr]uint64)
- v, changed := fastpathTV.DecMapUintptrUint64V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUintptrUint64V(rv2i(rv).(map[uintptr]uint64), false, d)
- }
-}
-func (f fastpathT) DecMapUintptrUint64X(vp *map[uintptr]uint64, d *Decoder) {
- v, changed := f.DecMapUintptrUint64V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUintptrUint64V(v map[uintptr]uint64, canChange bool,
- d *Decoder) (_ map[uintptr]uint64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
- v = make(map[uintptr]uint64, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uintptr
- var mv uint64
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = dd.DecodeUint64()
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUintptrUintptrR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uintptr]uintptr)
- v, changed := fastpathTV.DecMapUintptrUintptrV(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUintptrUintptrV(rv2i(rv).(map[uintptr]uintptr), false, d)
- }
-}
-func (f fastpathT) DecMapUintptrUintptrX(vp *map[uintptr]uintptr, d *Decoder) {
- v, changed := f.DecMapUintptrUintptrV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUintptrUintptrV(v map[uintptr]uintptr, canChange bool,
- d *Decoder) (_ map[uintptr]uintptr, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
- v = make(map[uintptr]uintptr, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uintptr
- var mv uintptr
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUintptrIntR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uintptr]int)
- v, changed := fastpathTV.DecMapUintptrIntV(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUintptrIntV(rv2i(rv).(map[uintptr]int), false, d)
- }
-}
-func (f fastpathT) DecMapUintptrIntX(vp *map[uintptr]int, d *Decoder) {
- v, changed := f.DecMapUintptrIntV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUintptrIntV(v map[uintptr]int, canChange bool,
- d *Decoder) (_ map[uintptr]int, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
- v = make(map[uintptr]int, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uintptr
- var mv int
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUintptrInt8R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uintptr]int8)
- v, changed := fastpathTV.DecMapUintptrInt8V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUintptrInt8V(rv2i(rv).(map[uintptr]int8), false, d)
- }
-}
-func (f fastpathT) DecMapUintptrInt8X(vp *map[uintptr]int8, d *Decoder) {
- v, changed := f.DecMapUintptrInt8V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUintptrInt8V(v map[uintptr]int8, canChange bool,
- d *Decoder) (_ map[uintptr]int8, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
- v = make(map[uintptr]int8, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uintptr
- var mv int8
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = int8(chkOvf.IntV(dd.DecodeInt64(), 8))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUintptrInt16R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uintptr]int16)
- v, changed := fastpathTV.DecMapUintptrInt16V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUintptrInt16V(rv2i(rv).(map[uintptr]int16), false, d)
- }
-}
-func (f fastpathT) DecMapUintptrInt16X(vp *map[uintptr]int16, d *Decoder) {
- v, changed := f.DecMapUintptrInt16V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUintptrInt16V(v map[uintptr]int16, canChange bool,
- d *Decoder) (_ map[uintptr]int16, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 10)
- v = make(map[uintptr]int16, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uintptr
- var mv int16
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = int16(chkOvf.IntV(dd.DecodeInt64(), 16))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUintptrInt32R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uintptr]int32)
- v, changed := fastpathTV.DecMapUintptrInt32V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUintptrInt32V(rv2i(rv).(map[uintptr]int32), false, d)
- }
-}
-func (f fastpathT) DecMapUintptrInt32X(vp *map[uintptr]int32, d *Decoder) {
- v, changed := f.DecMapUintptrInt32V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUintptrInt32V(v map[uintptr]int32, canChange bool,
- d *Decoder) (_ map[uintptr]int32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
- v = make(map[uintptr]int32, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uintptr
- var mv int32
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = int32(chkOvf.IntV(dd.DecodeInt64(), 32))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUintptrInt64R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uintptr]int64)
- v, changed := fastpathTV.DecMapUintptrInt64V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUintptrInt64V(rv2i(rv).(map[uintptr]int64), false, d)
- }
-}
-func (f fastpathT) DecMapUintptrInt64X(vp *map[uintptr]int64, d *Decoder) {
- v, changed := f.DecMapUintptrInt64V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUintptrInt64V(v map[uintptr]int64, canChange bool,
- d *Decoder) (_ map[uintptr]int64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
- v = make(map[uintptr]int64, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uintptr
- var mv int64
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = dd.DecodeInt64()
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapUintptrFloat32R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uintptr]float32)
- v, changed := fastpathTV.DecMapUintptrFloat32V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUintptrFloat32V(rv2i(rv).(map[uintptr]float32), false, d)
- }
-}
-func (f fastpathT) DecMapUintptrFloat32X(vp *map[uintptr]float32, d *Decoder) {
- v, changed := f.DecMapUintptrFloat32V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUintptrFloat32V(v map[uintptr]float32, canChange bool,
- d *Decoder) (_ map[uintptr]float32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
- v = make(map[uintptr]float32, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uintptr
- var mv float32
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = float32(chkOvf.Float32V(dd.DecodeFloat64()))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
+ return true
}
-func (d *Decoder) fastpathDecMapUintptrFloat64R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uintptr]float64)
- v, changed := fastpathTV.DecMapUintptrFloat64V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUintptrFloat64V(rv2i(rv).(map[uintptr]float64), false, d)
- }
-}
-func (f fastpathT) DecMapUintptrFloat64X(vp *map[uintptr]float64, d *Decoder) {
- v, changed := f.DecMapUintptrFloat64V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUintptrFloat64V(v map[uintptr]float64, canChange bool,
- d *Decoder) (_ map[uintptr]float64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
- v = make(map[uintptr]float64, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uintptr
- var mv float64
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = dd.DecodeFloat64()
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
+func fastpathDecodeSetZeroTypeSwitch(iv interface{}) bool {
+ switch v := iv.(type) {
+ case *[]interface{}:
+ *v = nil
+ case *[]string:
+ *v = nil
+ case *[][]byte:
+ *v = nil
+ case *[]float32:
+ *v = nil
+ case *[]float64:
+ *v = nil
+ case *[]uint:
+ *v = nil
+ case *[]uint16:
+ *v = nil
+ case *[]uint32:
+ *v = nil
+ case *[]uint64:
+ *v = nil
+ case *[]int:
+ *v = nil
+ case *[]int8:
+ *v = nil
+ case *[]int16:
+ *v = nil
+ case *[]int32:
+ *v = nil
+ case *[]int64:
+ *v = nil
+ case *[]bool:
+ *v = nil
-func (d *Decoder) fastpathDecMapUintptrBoolR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[uintptr]bool)
- v, changed := fastpathTV.DecMapUintptrBoolV(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapUintptrBoolV(rv2i(rv).(map[uintptr]bool), false, d)
- }
-}
-func (f fastpathT) DecMapUintptrBoolX(vp *map[uintptr]bool, d *Decoder) {
- v, changed := f.DecMapUintptrBoolV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapUintptrBoolV(v map[uintptr]bool, canChange bool,
- d *Decoder) (_ map[uintptr]bool, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
- v = make(map[uintptr]bool, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk uintptr
- var mv bool
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = false
- }
- continue
- }
- mv = dd.DecodeBool()
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
+ case *map[string]interface{}:
+ *v = nil
+ case *map[string]string:
+ *v = nil
+ case *map[string][]byte:
+ *v = nil
+ case *map[string]uint:
+ *v = nil
+ case *map[string]uint8:
+ *v = nil
+ case *map[string]uint64:
+ *v = nil
+ case *map[string]int:
+ *v = nil
+ case *map[string]int64:
+ *v = nil
+ case *map[string]float32:
+ *v = nil
+ case *map[string]float64:
+ *v = nil
+ case *map[string]bool:
+ *v = nil
+ case *map[uint]interface{}:
+ *v = nil
+ case *map[uint]string:
+ *v = nil
+ case *map[uint][]byte:
+ *v = nil
+ case *map[uint]uint:
+ *v = nil
+ case *map[uint]uint8:
+ *v = nil
+ case *map[uint]uint64:
+ *v = nil
+ case *map[uint]int:
+ *v = nil
+ case *map[uint]int64:
+ *v = nil
+ case *map[uint]float32:
+ *v = nil
+ case *map[uint]float64:
+ *v = nil
+ case *map[uint]bool:
+ *v = nil
+ case *map[uint8]interface{}:
+ *v = nil
+ case *map[uint8]string:
+ *v = nil
+ case *map[uint8][]byte:
+ *v = nil
+ case *map[uint8]uint:
+ *v = nil
+ case *map[uint8]uint8:
+ *v = nil
+ case *map[uint8]uint64:
+ *v = nil
+ case *map[uint8]int:
+ *v = nil
+ case *map[uint8]int64:
+ *v = nil
+ case *map[uint8]float32:
+ *v = nil
+ case *map[uint8]float64:
+ *v = nil
+ case *map[uint8]bool:
+ *v = nil
+ case *map[uint64]interface{}:
+ *v = nil
+ case *map[uint64]string:
+ *v = nil
+ case *map[uint64][]byte:
+ *v = nil
+ case *map[uint64]uint:
+ *v = nil
+ case *map[uint64]uint8:
+ *v = nil
+ case *map[uint64]uint64:
+ *v = nil
+ case *map[uint64]int:
+ *v = nil
+ case *map[uint64]int64:
+ *v = nil
+ case *map[uint64]float32:
+ *v = nil
+ case *map[uint64]float64:
+ *v = nil
+ case *map[uint64]bool:
+ *v = nil
+ case *map[int]interface{}:
+ *v = nil
+ case *map[int]string:
+ *v = nil
+ case *map[int][]byte:
+ *v = nil
+ case *map[int]uint:
+ *v = nil
+ case *map[int]uint8:
+ *v = nil
+ case *map[int]uint64:
+ *v = nil
+ case *map[int]int:
+ *v = nil
+ case *map[int]int64:
+ *v = nil
+ case *map[int]float32:
+ *v = nil
+ case *map[int]float64:
+ *v = nil
+ case *map[int]bool:
+ *v = nil
+ case *map[int64]interface{}:
+ *v = nil
+ case *map[int64]string:
+ *v = nil
+ case *map[int64][]byte:
+ *v = nil
+ case *map[int64]uint:
+ *v = nil
+ case *map[int64]uint8:
+ *v = nil
+ case *map[int64]uint64:
+ *v = nil
+ case *map[int64]int:
+ *v = nil
+ case *map[int64]int64:
+ *v = nil
+ case *map[int64]float32:
+ *v = nil
+ case *map[int64]float64:
+ *v = nil
+ case *map[int64]bool:
+ *v = nil
-func (d *Decoder) fastpathDecMapIntIntfR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int]interface{})
- v, changed := fastpathTV.DecMapIntIntfV(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapIntIntfV(rv2i(rv).(map[int]interface{}), false, d)
- }
-}
-func (f fastpathT) DecMapIntIntfX(vp *map[int]interface{}, d *Decoder) {
- v, changed := f.DecMapIntIntfV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapIntIntfV(v map[int]interface{}, canChange bool,
- d *Decoder) (_ map[int]interface{}, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 24)
- v = make(map[int]interface{}, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset
- var mk int
- var mv interface{}
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = nil
- }
- continue
- }
- if mapGet {
- mv = v[mk]
- } else {
- mv = nil
- }
- d.decode(&mv)
- if v != nil {
- v[mk] = mv
- }
+ default:
+ _ = v // workaround https://github.com/golang/go/issues/12927 seen in go1.4
+ return false
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
+ return true
}
-func (d *Decoder) fastpathDecMapIntStringR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int]string)
- v, changed := fastpathTV.DecMapIntStringV(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapIntStringV(rv2i(rv).(map[int]string), false, d)
- }
-}
-func (f fastpathT) DecMapIntStringX(vp *map[int]string, d *Decoder) {
- v, changed := f.DecMapIntStringV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapIntStringV(v map[int]string, canChange bool,
- d *Decoder) (_ map[int]string, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 24)
- v = make(map[int]string, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk int
- var mv string
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = ""
- }
- continue
- }
- mv = dd.DecodeString()
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
+// -- -- fast path functions
-func (d *Decoder) fastpathDecMapIntUintR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int]uint)
- v, changed := fastpathTV.DecMapIntUintV(*vp, true, d)
- if changed {
+func (d *Decoder) fastpathDecSliceIntfR(f *codecFnInfo, rv reflect.Value) {
+ if f.seq != seqTypeArray && rv.Kind() == reflect.Ptr {
+ vp := rv2i(rv).(*[]interface{})
+ if v, changed := fastpathTV.DecSliceIntfY(*vp, d); changed {
*vp = v
}
} else {
- fastpathTV.DecMapIntUintV(rv2i(rv).(map[int]uint), false, d)
+ fastpathTV.DecSliceIntfN(rv2i(rv).([]interface{}), d)
}
}
-func (f fastpathT) DecMapIntUintX(vp *map[int]uint, d *Decoder) {
- v, changed := f.DecMapIntUintV(*vp, true, d)
- if changed {
+func (f fastpathT) DecSliceIntfX(vp *[]interface{}, d *Decoder) {
+ if v, changed := f.DecSliceIntfY(*vp, d); changed {
*vp = v
}
}
-func (_ fastpathT) DecMapIntUintV(v map[int]uint, canChange bool,
- d *Decoder) (_ map[int]uint, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
- v = make(map[int]uint, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk int
- var mv uint
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if v != nil {
- v[mk] = mv
+func (fastpathT) DecSliceIntfY(v []interface{}, d *Decoder) (_ []interface{}, changed bool) {
+ slh, containerLenS := d.decSliceHelperStart()
+ if slh.IsNil {
+ if v == nil {
+ return
}
+ return nil, true
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapIntUint8R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int]uint8)
- v, changed := fastpathTV.DecMapIntUint8V(*vp, true, d)
- if changed {
- *vp = v
+ if containerLenS == 0 {
+ if v == nil {
+ v = []interface{}{}
+ } else if len(v) != 0 {
+ v = v[:0]
}
- } else {
- fastpathTV.DecMapIntUint8V(rv2i(rv).(map[int]uint8), false, d)
- }
-}
-func (f fastpathT) DecMapIntUint8X(vp *map[int]uint8, d *Decoder) {
- v, changed := f.DecMapIntUint8V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapIntUint8V(v map[int]uint8, canChange bool,
- d *Decoder) (_ map[int]uint8, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
- v = make(map[int]uint8, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
+ slh.End()
+ return v, true
}
- d.depthIncr()
- var mk int
- var mv uint8
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
+ hasLen := containerLenS > 0
+ var xlen int
+ if hasLen {
+ if containerLenS > cap(v) {
+ xlen = decInferLen(containerLenS, d.h.MaxInitLen, 16)
+ if xlen <= cap(v) {
+ v = v[:uint(xlen)]
} else {
- v[mk] = 0
+ v = make([]interface{}, uint(xlen))
}
- continue
- }
- mv = uint8(chkOvf.UintV(dd.DecodeUint64(), 8))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapIntUint16R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int]uint16)
- v, changed := fastpathTV.DecMapIntUint16V(*vp, true, d)
- if changed {
- *vp = v
+ changed = true
+ } else if containerLenS != len(v) {
+ v = v[:containerLenS]
+ changed = true
}
- } else {
- fastpathTV.DecMapIntUint16V(rv2i(rv).(map[int]uint16), false, d)
- }
-}
-func (f fastpathT) DecMapIntUint16X(vp *map[int]uint16, d *Decoder) {
- v, changed := f.DecMapIntUint16V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapIntUint16V(v map[int]uint16, canChange bool,
- d *Decoder) (_ map[int]uint16, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 10)
- v = make(map[int]uint16, xlen)
- changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk int
- var mv uint16
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
+ var j int
+ for j = 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ {
+ if j == 0 && len(v) == 0 {
+ if hasLen {
+ xlen = decInferLen(containerLenS, d.h.MaxInitLen, 16)
} else {
- v[mk] = 0
+ xlen = 8
}
- continue
- }
- mv = uint16(chkOvf.UintV(dd.DecodeUint64(), 16))
- if v != nil {
- v[mk] = mv
+ v = make([]interface{}, uint(xlen))
+ changed = true
}
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapIntUint32R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int]uint32)
- v, changed := fastpathTV.DecMapIntUint32V(*vp, true, d)
- if changed {
- *vp = v
+ if j >= len(v) {
+ v = append(v, nil)
+ changed = true
}
- } else {
- fastpathTV.DecMapIntUint32V(rv2i(rv).(map[int]uint32), false, d)
- }
-}
-func (f fastpathT) DecMapIntUint32X(vp *map[int]uint32, d *Decoder) {
- v, changed := f.DecMapIntUint32V(*vp, true, d)
- if changed {
- *vp = v
+ slh.ElemContainerState(j)
+ d.decode(&v[uint(j)])
}
-}
-func (_ fastpathT) DecMapIntUint32V(v map[int]uint32, canChange bool,
- d *Decoder) (_ map[int]uint32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
- v = make(map[int]uint32, xlen)
+ if j < len(v) {
+ v = v[:uint(j)]
changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk int
- var mv uint32
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uint32(chkOvf.UintV(dd.DecodeUint64(), 32))
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapIntUint64R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int]uint64)
- v, changed := fastpathTV.DecMapIntUint64V(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapIntUint64V(rv2i(rv).(map[int]uint64), false, d)
- }
-}
-func (f fastpathT) DecMapIntUint64X(vp *map[int]uint64, d *Decoder) {
- v, changed := f.DecMapIntUint64V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapIntUint64V(v map[int]uint64, canChange bool,
- d *Decoder) (_ map[int]uint64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
- v = make(map[int]uint64, xlen)
+ } else if j == 0 && v == nil {
+ v = []interface{}{}
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk int
- var mv uint64
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = dd.DecodeUint64()
- if v != nil {
- v[mk] = mv
- }
- }
- dd.ReadMapEnd()
- d.depthDecr()
+ slh.End()
return v, changed
}
-
-func (d *Decoder) fastpathDecMapIntUintptrR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int]uintptr)
- v, changed := fastpathTV.DecMapIntUintptrV(*vp, true, d)
- if changed {
- *vp = v
- }
- } else {
- fastpathTV.DecMapIntUintptrV(rv2i(rv).(map[int]uintptr), false, d)
- }
-}
-func (f fastpathT) DecMapIntUintptrX(vp *map[int]uintptr, d *Decoder) {
- v, changed := f.DecMapIntUintptrV(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapIntUintptrV(v map[int]uintptr, canChange bool,
- d *Decoder) (_ map[int]uintptr, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
- v = make(map[int]uintptr, xlen)
- changed = true
+func (fastpathT) DecSliceIntfN(v []interface{}, d *Decoder) {
+ slh, containerLenS := d.decSliceHelperStart()
+ if slh.IsNil {
+ return
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
+ if containerLenS == 0 {
+ slh.End()
+ return
}
- d.depthIncr()
- var mk int
- var mv uintptr
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if v != nil {
- v[mk] = mv
+ hasLen := containerLenS > 0
+ for j := 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ {
+ if j >= len(v) {
+ fastpathDecArrayCannotExpand(slh, hasLen, len(v), j, containerLenS)
+ return
}
+ slh.ElemContainerState(j)
+ d.decode(&v[uint(j)])
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
+ slh.End()
}
-func (d *Decoder) fastpathDecMapIntIntR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int]int)
- v, changed := fastpathTV.DecMapIntIntV(*vp, true, d)
- if changed {
+func (d *Decoder) fastpathDecSliceStringR(f *codecFnInfo, rv reflect.Value) {
+ if f.seq != seqTypeArray && rv.Kind() == reflect.Ptr {
+ vp := rv2i(rv).(*[]string)
+ if v, changed := fastpathTV.DecSliceStringY(*vp, d); changed {
*vp = v
}
} else {
- fastpathTV.DecMapIntIntV(rv2i(rv).(map[int]int), false, d)
+ fastpathTV.DecSliceStringN(rv2i(rv).([]string), d)
}
}
-func (f fastpathT) DecMapIntIntX(vp *map[int]int, d *Decoder) {
- v, changed := f.DecMapIntIntV(*vp, true, d)
- if changed {
+func (f fastpathT) DecSliceStringX(vp *[]string, d *Decoder) {
+ if v, changed := f.DecSliceStringY(*vp, d); changed {
*vp = v
}
}
-func (_ fastpathT) DecMapIntIntV(v map[int]int, canChange bool,
- d *Decoder) (_ map[int]int, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
- v = make(map[int]int, xlen)
- changed = true
+func (fastpathT) DecSliceStringY(v []string, d *Decoder) (_ []string, changed bool) {
+ slh, containerLenS := d.decSliceHelperStart()
+ if slh.IsNil {
+ if v == nil {
+ return
+ }
+ return nil, true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
+ if containerLenS == 0 {
+ if v == nil {
+ v = []string{}
+ } else if len(v) != 0 {
+ v = v[:0]
+ }
+ slh.End()
+ return v, true
}
- d.depthIncr()
- var mk int
- var mv int
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
+ hasLen := containerLenS > 0
+ var xlen int
+ if hasLen {
+ if containerLenS > cap(v) {
+ xlen = decInferLen(containerLenS, d.h.MaxInitLen, 16)
+ if xlen <= cap(v) {
+ v = v[:uint(xlen)]
} else {
- v[mk] = 0
+ v = make([]string, uint(xlen))
}
- continue
- }
- mv = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize))
- if v != nil {
- v[mk] = mv
+ changed = true
+ } else if containerLenS != len(v) {
+ v = v[:containerLenS]
+ changed = true
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapIntInt8R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int]int8)
- v, changed := fastpathTV.DecMapIntInt8V(*vp, true, d)
- if changed {
- *vp = v
+ var j int
+ for j = 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ {
+ if j == 0 && len(v) == 0 {
+ if hasLen {
+ xlen = decInferLen(containerLenS, d.h.MaxInitLen, 16)
+ } else {
+ xlen = 8
+ }
+ v = make([]string, uint(xlen))
+ changed = true
}
- } else {
- fastpathTV.DecMapIntInt8V(rv2i(rv).(map[int]int8), false, d)
+ if j >= len(v) {
+ v = append(v, "")
+ changed = true
+ }
+ slh.ElemContainerState(j)
+ v[uint(j)] = string(d.d.DecodeStringAsBytes())
}
-}
-func (f fastpathT) DecMapIntInt8X(vp *map[int]int8, d *Decoder) {
- v, changed := f.DecMapIntInt8V(*vp, true, d)
- if changed {
- *vp = v
+ if j < len(v) {
+ v = v[:uint(j)]
+ changed = true
+ } else if j == 0 && v == nil {
+ v = []string{}
+ changed = true
}
+ slh.End()
+ return v, changed
}
-func (_ fastpathT) DecMapIntInt8V(v map[int]int8, canChange bool,
- d *Decoder) (_ map[int]int8, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
- v = make(map[int]int8, xlen)
- changed = true
+func (fastpathT) DecSliceStringN(v []string, d *Decoder) {
+ slh, containerLenS := d.decSliceHelperStart()
+ if slh.IsNil {
+ return
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
+ if containerLenS == 0 {
+ slh.End()
+ return
}
- d.depthIncr()
- var mk int
- var mv int8
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = int8(chkOvf.IntV(dd.DecodeInt64(), 8))
- if v != nil {
- v[mk] = mv
+ hasLen := containerLenS > 0
+ for j := 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ {
+ if j >= len(v) {
+ fastpathDecArrayCannotExpand(slh, hasLen, len(v), j, containerLenS)
+ return
}
+ slh.ElemContainerState(j)
+ v[uint(j)] = string(d.d.DecodeStringAsBytes())
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
+ slh.End()
}
-func (d *Decoder) fastpathDecMapIntInt16R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int]int16)
- v, changed := fastpathTV.DecMapIntInt16V(*vp, true, d)
- if changed {
+func (d *Decoder) fastpathDecSliceBytesR(f *codecFnInfo, rv reflect.Value) {
+ if f.seq != seqTypeArray && rv.Kind() == reflect.Ptr {
+ vp := rv2i(rv).(*[][]byte)
+ if v, changed := fastpathTV.DecSliceBytesY(*vp, d); changed {
*vp = v
}
} else {
- fastpathTV.DecMapIntInt16V(rv2i(rv).(map[int]int16), false, d)
+ fastpathTV.DecSliceBytesN(rv2i(rv).([][]byte), d)
}
}
-func (f fastpathT) DecMapIntInt16X(vp *map[int]int16, d *Decoder) {
- v, changed := f.DecMapIntInt16V(*vp, true, d)
- if changed {
+func (f fastpathT) DecSliceBytesX(vp *[][]byte, d *Decoder) {
+ if v, changed := f.DecSliceBytesY(*vp, d); changed {
*vp = v
}
}
-func (_ fastpathT) DecMapIntInt16V(v map[int]int16, canChange bool,
- d *Decoder) (_ map[int]int16, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 10)
- v = make(map[int]int16, xlen)
- changed = true
+func (fastpathT) DecSliceBytesY(v [][]byte, d *Decoder) (_ [][]byte, changed bool) {
+ slh, containerLenS := d.decSliceHelperStart()
+ if slh.IsNil {
+ if v == nil {
+ return
+ }
+ return nil, true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
+ if containerLenS == 0 {
+ if v == nil {
+ v = [][]byte{}
+ } else if len(v) != 0 {
+ v = v[:0]
+ }
+ slh.End()
+ return v, true
}
- d.depthIncr()
- var mk int
- var mv int16
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
+ hasLen := containerLenS > 0
+ var xlen int
+ if hasLen {
+ if containerLenS > cap(v) {
+ xlen = decInferLen(containerLenS, d.h.MaxInitLen, 24)
+ if xlen <= cap(v) {
+ v = v[:uint(xlen)]
} else {
- v[mk] = 0
+ v = make([][]byte, uint(xlen))
}
- continue
- }
- mv = int16(chkOvf.IntV(dd.DecodeInt64(), 16))
- if v != nil {
- v[mk] = mv
+ changed = true
+ } else if containerLenS != len(v) {
+ v = v[:containerLenS]
+ changed = true
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapIntInt32R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int]int32)
- v, changed := fastpathTV.DecMapIntInt32V(*vp, true, d)
- if changed {
- *vp = v
+ var j int
+ for j = 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ {
+ if j == 0 && len(v) == 0 {
+ if hasLen {
+ xlen = decInferLen(containerLenS, d.h.MaxInitLen, 24)
+ } else {
+ xlen = 8
+ }
+ v = make([][]byte, uint(xlen))
+ changed = true
}
- } else {
- fastpathTV.DecMapIntInt32V(rv2i(rv).(map[int]int32), false, d)
+ if j >= len(v) {
+ v = append(v, nil)
+ changed = true
+ }
+ slh.ElemContainerState(j)
+ v[uint(j)] = d.d.DecodeBytes(nil, false)
}
-}
-func (f fastpathT) DecMapIntInt32X(vp *map[int]int32, d *Decoder) {
- v, changed := f.DecMapIntInt32V(*vp, true, d)
- if changed {
- *vp = v
+ if j < len(v) {
+ v = v[:uint(j)]
+ changed = true
+ } else if j == 0 && v == nil {
+ v = [][]byte{}
+ changed = true
}
+ slh.End()
+ return v, changed
}
-func (_ fastpathT) DecMapIntInt32V(v map[int]int32, canChange bool,
- d *Decoder) (_ map[int]int32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
- v = make(map[int]int32, xlen)
- changed = true
+func (fastpathT) DecSliceBytesN(v [][]byte, d *Decoder) {
+ slh, containerLenS := d.decSliceHelperStart()
+ if slh.IsNil {
+ return
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
+ if containerLenS == 0 {
+ slh.End()
+ return
}
- d.depthIncr()
- var mk int
- var mv int32
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = int32(chkOvf.IntV(dd.DecodeInt64(), 32))
- if v != nil {
- v[mk] = mv
+ hasLen := containerLenS > 0
+ for j := 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ {
+ if j >= len(v) {
+ fastpathDecArrayCannotExpand(slh, hasLen, len(v), j, containerLenS)
+ return
}
+ slh.ElemContainerState(j)
+ v[uint(j)] = d.d.DecodeBytes(nil, false)
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
+ slh.End()
}
-func (d *Decoder) fastpathDecMapIntInt64R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int]int64)
- v, changed := fastpathTV.DecMapIntInt64V(*vp, true, d)
- if changed {
+func (d *Decoder) fastpathDecSliceFloat32R(f *codecFnInfo, rv reflect.Value) {
+ if f.seq != seqTypeArray && rv.Kind() == reflect.Ptr {
+ vp := rv2i(rv).(*[]float32)
+ if v, changed := fastpathTV.DecSliceFloat32Y(*vp, d); changed {
*vp = v
}
} else {
- fastpathTV.DecMapIntInt64V(rv2i(rv).(map[int]int64), false, d)
+ fastpathTV.DecSliceFloat32N(rv2i(rv).([]float32), d)
}
}
-func (f fastpathT) DecMapIntInt64X(vp *map[int]int64, d *Decoder) {
- v, changed := f.DecMapIntInt64V(*vp, true, d)
- if changed {
+func (f fastpathT) DecSliceFloat32X(vp *[]float32, d *Decoder) {
+ if v, changed := f.DecSliceFloat32Y(*vp, d); changed {
*vp = v
}
}
-func (_ fastpathT) DecMapIntInt64V(v map[int]int64, canChange bool,
- d *Decoder) (_ map[int]int64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
- v = make(map[int]int64, xlen)
- changed = true
+func (fastpathT) DecSliceFloat32Y(v []float32, d *Decoder) (_ []float32, changed bool) {
+ slh, containerLenS := d.decSliceHelperStart()
+ if slh.IsNil {
+ if v == nil {
+ return
+ }
+ return nil, true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
+ if containerLenS == 0 {
+ if v == nil {
+ v = []float32{}
+ } else if len(v) != 0 {
+ v = v[:0]
+ }
+ slh.End()
+ return v, true
}
- d.depthIncr()
- var mk int
- var mv int64
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
+ hasLen := containerLenS > 0
+ var xlen int
+ if hasLen {
+ if containerLenS > cap(v) {
+ xlen = decInferLen(containerLenS, d.h.MaxInitLen, 4)
+ if xlen <= cap(v) {
+ v = v[:uint(xlen)]
} else {
- v[mk] = 0
+ v = make([]float32, uint(xlen))
}
- continue
- }
- mv = dd.DecodeInt64()
- if v != nil {
- v[mk] = mv
+ changed = true
+ } else if containerLenS != len(v) {
+ v = v[:containerLenS]
+ changed = true
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapIntFloat32R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int]float32)
- v, changed := fastpathTV.DecMapIntFloat32V(*vp, true, d)
- if changed {
- *vp = v
+ var j int
+ for j = 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ {
+ if j == 0 && len(v) == 0 {
+ if hasLen {
+ xlen = decInferLen(containerLenS, d.h.MaxInitLen, 4)
+ } else {
+ xlen = 8
+ }
+ v = make([]float32, uint(xlen))
+ changed = true
}
- } else {
- fastpathTV.DecMapIntFloat32V(rv2i(rv).(map[int]float32), false, d)
+ if j >= len(v) {
+ v = append(v, 0)
+ changed = true
+ }
+ slh.ElemContainerState(j)
+ v[uint(j)] = float32(d.decodeFloat32())
}
-}
-func (f fastpathT) DecMapIntFloat32X(vp *map[int]float32, d *Decoder) {
- v, changed := f.DecMapIntFloat32V(*vp, true, d)
- if changed {
- *vp = v
+ if j < len(v) {
+ v = v[:uint(j)]
+ changed = true
+ } else if j == 0 && v == nil {
+ v = []float32{}
+ changed = true
}
+ slh.End()
+ return v, changed
}
-func (_ fastpathT) DecMapIntFloat32V(v map[int]float32, canChange bool,
- d *Decoder) (_ map[int]float32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
- v = make(map[int]float32, xlen)
- changed = true
+func (fastpathT) DecSliceFloat32N(v []float32, d *Decoder) {
+ slh, containerLenS := d.decSliceHelperStart()
+ if slh.IsNil {
+ return
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
+ if containerLenS == 0 {
+ slh.End()
+ return
}
- d.depthIncr()
- var mk int
- var mv float32
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = float32(chkOvf.Float32V(dd.DecodeFloat64()))
- if v != nil {
- v[mk] = mv
+ hasLen := containerLenS > 0
+ for j := 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ {
+ if j >= len(v) {
+ fastpathDecArrayCannotExpand(slh, hasLen, len(v), j, containerLenS)
+ return
}
+ slh.ElemContainerState(j)
+ v[uint(j)] = float32(d.decodeFloat32())
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
+ slh.End()
}
-func (d *Decoder) fastpathDecMapIntFloat64R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int]float64)
- v, changed := fastpathTV.DecMapIntFloat64V(*vp, true, d)
- if changed {
+func (d *Decoder) fastpathDecSliceFloat64R(f *codecFnInfo, rv reflect.Value) {
+ if f.seq != seqTypeArray && rv.Kind() == reflect.Ptr {
+ vp := rv2i(rv).(*[]float64)
+ if v, changed := fastpathTV.DecSliceFloat64Y(*vp, d); changed {
*vp = v
}
} else {
- fastpathTV.DecMapIntFloat64V(rv2i(rv).(map[int]float64), false, d)
+ fastpathTV.DecSliceFloat64N(rv2i(rv).([]float64), d)
}
}
-func (f fastpathT) DecMapIntFloat64X(vp *map[int]float64, d *Decoder) {
- v, changed := f.DecMapIntFloat64V(*vp, true, d)
- if changed {
+func (f fastpathT) DecSliceFloat64X(vp *[]float64, d *Decoder) {
+ if v, changed := f.DecSliceFloat64Y(*vp, d); changed {
*vp = v
}
}
-func (_ fastpathT) DecMapIntFloat64V(v map[int]float64, canChange bool,
- d *Decoder) (_ map[int]float64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
- v = make(map[int]float64, xlen)
- changed = true
+func (fastpathT) DecSliceFloat64Y(v []float64, d *Decoder) (_ []float64, changed bool) {
+ slh, containerLenS := d.decSliceHelperStart()
+ if slh.IsNil {
+ if v == nil {
+ return
+ }
+ return nil, true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
+ if containerLenS == 0 {
+ if v == nil {
+ v = []float64{}
+ } else if len(v) != 0 {
+ v = v[:0]
+ }
+ slh.End()
+ return v, true
}
- d.depthIncr()
- var mk int
- var mv float64
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
+ hasLen := containerLenS > 0
+ var xlen int
+ if hasLen {
+ if containerLenS > cap(v) {
+ xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8)
+ if xlen <= cap(v) {
+ v = v[:uint(xlen)]
+ } else {
+ v = make([]float64, uint(xlen))
+ }
+ changed = true
+ } else if containerLenS != len(v) {
+ v = v[:containerLenS]
+ changed = true
+ }
+ }
+ var j int
+ for j = 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ {
+ if j == 0 && len(v) == 0 {
+ if hasLen {
+ xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8)
} else {
- v[mk] = 0
+ xlen = 8
}
- continue
+ v = make([]float64, uint(xlen))
+ changed = true
}
- mv = dd.DecodeFloat64()
- if v != nil {
- v[mk] = mv
+ if j >= len(v) {
+ v = append(v, 0)
+ changed = true
+ }
+ slh.ElemContainerState(j)
+ v[uint(j)] = d.d.DecodeFloat64()
+ }
+ if j < len(v) {
+ v = v[:uint(j)]
+ changed = true
+ } else if j == 0 && v == nil {
+ v = []float64{}
+ changed = true
+ }
+ slh.End()
+ return v, changed
+}
+func (fastpathT) DecSliceFloat64N(v []float64, d *Decoder) {
+ slh, containerLenS := d.decSliceHelperStart()
+ if slh.IsNil {
+ return
+ }
+ if containerLenS == 0 {
+ slh.End()
+ return
+ }
+ hasLen := containerLenS > 0
+ for j := 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ {
+ if j >= len(v) {
+ fastpathDecArrayCannotExpand(slh, hasLen, len(v), j, containerLenS)
+ return
}
+ slh.ElemContainerState(j)
+ v[uint(j)] = d.d.DecodeFloat64()
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
+ slh.End()
}
-func (d *Decoder) fastpathDecMapIntBoolR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int]bool)
- v, changed := fastpathTV.DecMapIntBoolV(*vp, true, d)
- if changed {
+func (d *Decoder) fastpathDecSliceUintR(f *codecFnInfo, rv reflect.Value) {
+ if f.seq != seqTypeArray && rv.Kind() == reflect.Ptr {
+ vp := rv2i(rv).(*[]uint)
+ if v, changed := fastpathTV.DecSliceUintY(*vp, d); changed {
*vp = v
}
} else {
- fastpathTV.DecMapIntBoolV(rv2i(rv).(map[int]bool), false, d)
+ fastpathTV.DecSliceUintN(rv2i(rv).([]uint), d)
}
}
-func (f fastpathT) DecMapIntBoolX(vp *map[int]bool, d *Decoder) {
- v, changed := f.DecMapIntBoolV(*vp, true, d)
- if changed {
+func (f fastpathT) DecSliceUintX(vp *[]uint, d *Decoder) {
+ if v, changed := f.DecSliceUintY(*vp, d); changed {
*vp = v
}
}
-func (_ fastpathT) DecMapIntBoolV(v map[int]bool, canChange bool,
- d *Decoder) (_ map[int]bool, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
- v = make(map[int]bool, xlen)
- changed = true
+func (fastpathT) DecSliceUintY(v []uint, d *Decoder) (_ []uint, changed bool) {
+ slh, containerLenS := d.decSliceHelperStart()
+ if slh.IsNil {
+ if v == nil {
+ return
+ }
+ return nil, true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
+ if containerLenS == 0 {
+ if v == nil {
+ v = []uint{}
+ } else if len(v) != 0 {
+ v = v[:0]
+ }
+ slh.End()
+ return v, true
}
- d.depthIncr()
- var mk int
- var mv bool
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
+ hasLen := containerLenS > 0
+ var xlen int
+ if hasLen {
+ if containerLenS > cap(v) {
+ xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8)
+ if xlen <= cap(v) {
+ v = v[:uint(xlen)]
} else {
- v[mk] = false
+ v = make([]uint, uint(xlen))
}
- continue
+ changed = true
+ } else if containerLenS != len(v) {
+ v = v[:containerLenS]
+ changed = true
}
- mv = dd.DecodeBool()
- if v != nil {
- v[mk] = mv
+ }
+ var j int
+ for j = 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ {
+ if j == 0 && len(v) == 0 {
+ if hasLen {
+ xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8)
+ } else {
+ xlen = 8
+ }
+ v = make([]uint, uint(xlen))
+ changed = true
+ }
+ if j >= len(v) {
+ v = append(v, 0)
+ changed = true
}
+ slh.ElemContainerState(j)
+ v[uint(j)] = uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize))
+ }
+ if j < len(v) {
+ v = v[:uint(j)]
+ changed = true
+ } else if j == 0 && v == nil {
+ v = []uint{}
+ changed = true
}
- dd.ReadMapEnd()
- d.depthDecr()
+ slh.End()
return v, changed
}
+func (fastpathT) DecSliceUintN(v []uint, d *Decoder) {
+ slh, containerLenS := d.decSliceHelperStart()
+ if slh.IsNil {
+ return
+ }
+ if containerLenS == 0 {
+ slh.End()
+ return
+ }
+ hasLen := containerLenS > 0
+ for j := 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ {
+ if j >= len(v) {
+ fastpathDecArrayCannotExpand(slh, hasLen, len(v), j, containerLenS)
+ return
+ }
+ slh.ElemContainerState(j)
+ v[uint(j)] = uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize))
+ }
+ slh.End()
+}
-func (d *Decoder) fastpathDecMapInt8IntfR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int8]interface{})
- v, changed := fastpathTV.DecMapInt8IntfV(*vp, true, d)
- if changed {
+func (d *Decoder) fastpathDecSliceUint16R(f *codecFnInfo, rv reflect.Value) {
+ if f.seq != seqTypeArray && rv.Kind() == reflect.Ptr {
+ vp := rv2i(rv).(*[]uint16)
+ if v, changed := fastpathTV.DecSliceUint16Y(*vp, d); changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt8IntfV(rv2i(rv).(map[int8]interface{}), false, d)
+ fastpathTV.DecSliceUint16N(rv2i(rv).([]uint16), d)
}
}
-func (f fastpathT) DecMapInt8IntfX(vp *map[int8]interface{}, d *Decoder) {
- v, changed := f.DecMapInt8IntfV(*vp, true, d)
- if changed {
+func (f fastpathT) DecSliceUint16X(vp *[]uint16, d *Decoder) {
+ if v, changed := f.DecSliceUint16Y(*vp, d); changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt8IntfV(v map[int8]interface{}, canChange bool,
- d *Decoder) (_ map[int8]interface{}, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 17)
- v = make(map[int8]interface{}, xlen)
- changed = true
+func (fastpathT) DecSliceUint16Y(v []uint16, d *Decoder) (_ []uint16, changed bool) {
+ slh, containerLenS := d.decSliceHelperStart()
+ if slh.IsNil {
+ if v == nil {
+ return
+ }
+ return nil, true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
+ if containerLenS == 0 {
+ if v == nil {
+ v = []uint16{}
+ } else if len(v) != 0 {
+ v = v[:0]
+ }
+ slh.End()
+ return v, true
}
- d.depthIncr()
- mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset
- var mk int8
- var mv interface{}
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = int8(chkOvf.IntV(dd.DecodeInt64(), 8))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
+ hasLen := containerLenS > 0
+ var xlen int
+ if hasLen {
+ if containerLenS > cap(v) {
+ xlen = decInferLen(containerLenS, d.h.MaxInitLen, 2)
+ if xlen <= cap(v) {
+ v = v[:uint(xlen)]
} else {
- v[mk] = nil
+ v = make([]uint16, uint(xlen))
}
- continue
+ changed = true
+ } else if containerLenS != len(v) {
+ v = v[:containerLenS]
+ changed = true
}
- if mapGet {
- mv = v[mk]
- } else {
- mv = nil
+ }
+ var j int
+ for j = 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ {
+ if j == 0 && len(v) == 0 {
+ if hasLen {
+ xlen = decInferLen(containerLenS, d.h.MaxInitLen, 2)
+ } else {
+ xlen = 8
+ }
+ v = make([]uint16, uint(xlen))
+ changed = true
}
- d.decode(&mv)
- if v != nil {
- v[mk] = mv
+ if j >= len(v) {
+ v = append(v, 0)
+ changed = true
}
+ slh.ElemContainerState(j)
+ v[uint(j)] = uint16(chkOvf.UintV(d.d.DecodeUint64(), 16))
+ }
+ if j < len(v) {
+ v = v[:uint(j)]
+ changed = true
+ } else if j == 0 && v == nil {
+ v = []uint16{}
+ changed = true
}
- dd.ReadMapEnd()
- d.depthDecr()
+ slh.End()
return v, changed
}
+func (fastpathT) DecSliceUint16N(v []uint16, d *Decoder) {
+ slh, containerLenS := d.decSliceHelperStart()
+ if slh.IsNil {
+ return
+ }
+ if containerLenS == 0 {
+ slh.End()
+ return
+ }
+ hasLen := containerLenS > 0
+ for j := 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ {
+ if j >= len(v) {
+ fastpathDecArrayCannotExpand(slh, hasLen, len(v), j, containerLenS)
+ return
+ }
+ slh.ElemContainerState(j)
+ v[uint(j)] = uint16(chkOvf.UintV(d.d.DecodeUint64(), 16))
+ }
+ slh.End()
+}
-func (d *Decoder) fastpathDecMapInt8StringR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int8]string)
- v, changed := fastpathTV.DecMapInt8StringV(*vp, true, d)
- if changed {
+func (d *Decoder) fastpathDecSliceUint32R(f *codecFnInfo, rv reflect.Value) {
+ if f.seq != seqTypeArray && rv.Kind() == reflect.Ptr {
+ vp := rv2i(rv).(*[]uint32)
+ if v, changed := fastpathTV.DecSliceUint32Y(*vp, d); changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt8StringV(rv2i(rv).(map[int8]string), false, d)
+ fastpathTV.DecSliceUint32N(rv2i(rv).([]uint32), d)
}
}
-func (f fastpathT) DecMapInt8StringX(vp *map[int8]string, d *Decoder) {
- v, changed := f.DecMapInt8StringV(*vp, true, d)
- if changed {
+func (f fastpathT) DecSliceUint32X(vp *[]uint32, d *Decoder) {
+ if v, changed := f.DecSliceUint32Y(*vp, d); changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt8StringV(v map[int8]string, canChange bool,
- d *Decoder) (_ map[int8]string, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 17)
- v = make(map[int8]string, xlen)
- changed = true
+func (fastpathT) DecSliceUint32Y(v []uint32, d *Decoder) (_ []uint32, changed bool) {
+ slh, containerLenS := d.decSliceHelperStart()
+ if slh.IsNil {
+ if v == nil {
+ return
+ }
+ return nil, true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
+ if containerLenS == 0 {
+ if v == nil {
+ v = []uint32{}
+ } else if len(v) != 0 {
+ v = v[:0]
+ }
+ slh.End()
+ return v, true
}
- d.depthIncr()
- var mk int8
- var mv string
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = int8(chkOvf.IntV(dd.DecodeInt64(), 8))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
+ hasLen := containerLenS > 0
+ var xlen int
+ if hasLen {
+ if containerLenS > cap(v) {
+ xlen = decInferLen(containerLenS, d.h.MaxInitLen, 4)
+ if xlen <= cap(v) {
+ v = v[:uint(xlen)]
} else {
- v[mk] = ""
+ v = make([]uint32, uint(xlen))
}
- continue
- }
- mv = dd.DecodeString()
- if v != nil {
- v[mk] = mv
+ changed = true
+ } else if containerLenS != len(v) {
+ v = v[:containerLenS]
+ changed = true
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapInt8UintR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int8]uint)
- v, changed := fastpathTV.DecMapInt8UintV(*vp, true, d)
- if changed {
- *vp = v
+ var j int
+ for j = 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ {
+ if j == 0 && len(v) == 0 {
+ if hasLen {
+ xlen = decInferLen(containerLenS, d.h.MaxInitLen, 4)
+ } else {
+ xlen = 8
+ }
+ v = make([]uint32, uint(xlen))
+ changed = true
}
- } else {
- fastpathTV.DecMapInt8UintV(rv2i(rv).(map[int8]uint), false, d)
+ if j >= len(v) {
+ v = append(v, 0)
+ changed = true
+ }
+ slh.ElemContainerState(j)
+ v[uint(j)] = uint32(chkOvf.UintV(d.d.DecodeUint64(), 32))
}
-}
-func (f fastpathT) DecMapInt8UintX(vp *map[int8]uint, d *Decoder) {
- v, changed := f.DecMapInt8UintV(*vp, true, d)
- if changed {
- *vp = v
+ if j < len(v) {
+ v = v[:uint(j)]
+ changed = true
+ } else if j == 0 && v == nil {
+ v = []uint32{}
+ changed = true
}
+ slh.End()
+ return v, changed
}
-func (_ fastpathT) DecMapInt8UintV(v map[int8]uint, canChange bool,
- d *Decoder) (_ map[int8]uint, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
- v = make(map[int8]uint, xlen)
- changed = true
+func (fastpathT) DecSliceUint32N(v []uint32, d *Decoder) {
+ slh, containerLenS := d.decSliceHelperStart()
+ if slh.IsNil {
+ return
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
+ if containerLenS == 0 {
+ slh.End()
+ return
}
- d.depthIncr()
- var mk int8
- var mv uint
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = int8(chkOvf.IntV(dd.DecodeInt64(), 8))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if v != nil {
- v[mk] = mv
+ hasLen := containerLenS > 0
+ for j := 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ {
+ if j >= len(v) {
+ fastpathDecArrayCannotExpand(slh, hasLen, len(v), j, containerLenS)
+ return
}
+ slh.ElemContainerState(j)
+ v[uint(j)] = uint32(chkOvf.UintV(d.d.DecodeUint64(), 32))
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
+ slh.End()
}
-func (d *Decoder) fastpathDecMapInt8Uint8R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int8]uint8)
- v, changed := fastpathTV.DecMapInt8Uint8V(*vp, true, d)
- if changed {
+func (d *Decoder) fastpathDecSliceUint64R(f *codecFnInfo, rv reflect.Value) {
+ if f.seq != seqTypeArray && rv.Kind() == reflect.Ptr {
+ vp := rv2i(rv).(*[]uint64)
+ if v, changed := fastpathTV.DecSliceUint64Y(*vp, d); changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt8Uint8V(rv2i(rv).(map[int8]uint8), false, d)
+ fastpathTV.DecSliceUint64N(rv2i(rv).([]uint64), d)
}
}
-func (f fastpathT) DecMapInt8Uint8X(vp *map[int8]uint8, d *Decoder) {
- v, changed := f.DecMapInt8Uint8V(*vp, true, d)
- if changed {
+func (f fastpathT) DecSliceUint64X(vp *[]uint64, d *Decoder) {
+ if v, changed := f.DecSliceUint64Y(*vp, d); changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt8Uint8V(v map[int8]uint8, canChange bool,
- d *Decoder) (_ map[int8]uint8, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 2)
- v = make(map[int8]uint8, xlen)
- changed = true
+func (fastpathT) DecSliceUint64Y(v []uint64, d *Decoder) (_ []uint64, changed bool) {
+ slh, containerLenS := d.decSliceHelperStart()
+ if slh.IsNil {
+ if v == nil {
+ return
+ }
+ return nil, true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
+ if containerLenS == 0 {
+ if v == nil {
+ v = []uint64{}
+ } else if len(v) != 0 {
+ v = v[:0]
+ }
+ slh.End()
+ return v, true
}
- d.depthIncr()
- var mk int8
- var mv uint8
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = int8(chkOvf.IntV(dd.DecodeInt64(), 8))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
+ hasLen := containerLenS > 0
+ var xlen int
+ if hasLen {
+ if containerLenS > cap(v) {
+ xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8)
+ if xlen <= cap(v) {
+ v = v[:uint(xlen)]
} else {
- v[mk] = 0
+ v = make([]uint64, uint(xlen))
}
- continue
- }
- mv = uint8(chkOvf.UintV(dd.DecodeUint64(), 8))
- if v != nil {
- v[mk] = mv
+ changed = true
+ } else if containerLenS != len(v) {
+ v = v[:containerLenS]
+ changed = true
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapInt8Uint16R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int8]uint16)
- v, changed := fastpathTV.DecMapInt8Uint16V(*vp, true, d)
- if changed {
- *vp = v
+ var j int
+ for j = 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ {
+ if j == 0 && len(v) == 0 {
+ if hasLen {
+ xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8)
+ } else {
+ xlen = 8
+ }
+ v = make([]uint64, uint(xlen))
+ changed = true
}
- } else {
- fastpathTV.DecMapInt8Uint16V(rv2i(rv).(map[int8]uint16), false, d)
+ if j >= len(v) {
+ v = append(v, 0)
+ changed = true
+ }
+ slh.ElemContainerState(j)
+ v[uint(j)] = d.d.DecodeUint64()
}
-}
-func (f fastpathT) DecMapInt8Uint16X(vp *map[int8]uint16, d *Decoder) {
- v, changed := f.DecMapInt8Uint16V(*vp, true, d)
- if changed {
- *vp = v
+ if j < len(v) {
+ v = v[:uint(j)]
+ changed = true
+ } else if j == 0 && v == nil {
+ v = []uint64{}
+ changed = true
}
+ slh.End()
+ return v, changed
}
-func (_ fastpathT) DecMapInt8Uint16V(v map[int8]uint16, canChange bool,
- d *Decoder) (_ map[int8]uint16, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 3)
- v = make(map[int8]uint16, xlen)
- changed = true
+func (fastpathT) DecSliceUint64N(v []uint64, d *Decoder) {
+ slh, containerLenS := d.decSliceHelperStart()
+ if slh.IsNil {
+ return
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
+ if containerLenS == 0 {
+ slh.End()
+ return
}
- d.depthIncr()
- var mk int8
- var mv uint16
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = int8(chkOvf.IntV(dd.DecodeInt64(), 8))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uint16(chkOvf.UintV(dd.DecodeUint64(), 16))
- if v != nil {
- v[mk] = mv
+ hasLen := containerLenS > 0
+ for j := 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ {
+ if j >= len(v) {
+ fastpathDecArrayCannotExpand(slh, hasLen, len(v), j, containerLenS)
+ return
}
+ slh.ElemContainerState(j)
+ v[uint(j)] = d.d.DecodeUint64()
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
+ slh.End()
}
-func (d *Decoder) fastpathDecMapInt8Uint32R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int8]uint32)
- v, changed := fastpathTV.DecMapInt8Uint32V(*vp, true, d)
- if changed {
+func (d *Decoder) fastpathDecSliceIntR(f *codecFnInfo, rv reflect.Value) {
+ if f.seq != seqTypeArray && rv.Kind() == reflect.Ptr {
+ vp := rv2i(rv).(*[]int)
+ if v, changed := fastpathTV.DecSliceIntY(*vp, d); changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt8Uint32V(rv2i(rv).(map[int8]uint32), false, d)
+ fastpathTV.DecSliceIntN(rv2i(rv).([]int), d)
}
}
-func (f fastpathT) DecMapInt8Uint32X(vp *map[int8]uint32, d *Decoder) {
- v, changed := f.DecMapInt8Uint32V(*vp, true, d)
- if changed {
+func (f fastpathT) DecSliceIntX(vp *[]int, d *Decoder) {
+ if v, changed := f.DecSliceIntY(*vp, d); changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt8Uint32V(v map[int8]uint32, canChange bool,
- d *Decoder) (_ map[int8]uint32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 5)
- v = make(map[int8]uint32, xlen)
- changed = true
+func (fastpathT) DecSliceIntY(v []int, d *Decoder) (_ []int, changed bool) {
+ slh, containerLenS := d.decSliceHelperStart()
+ if slh.IsNil {
+ if v == nil {
+ return
+ }
+ return nil, true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
+ if containerLenS == 0 {
+ if v == nil {
+ v = []int{}
+ } else if len(v) != 0 {
+ v = v[:0]
+ }
+ slh.End()
+ return v, true
}
- d.depthIncr()
- var mk int8
- var mv uint32
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = int8(chkOvf.IntV(dd.DecodeInt64(), 8))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
+ hasLen := containerLenS > 0
+ var xlen int
+ if hasLen {
+ if containerLenS > cap(v) {
+ xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8)
+ if xlen <= cap(v) {
+ v = v[:uint(xlen)]
} else {
- v[mk] = 0
+ v = make([]int, uint(xlen))
}
- continue
- }
- mv = uint32(chkOvf.UintV(dd.DecodeUint64(), 32))
- if v != nil {
- v[mk] = mv
+ changed = true
+ } else if containerLenS != len(v) {
+ v = v[:containerLenS]
+ changed = true
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapInt8Uint64R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int8]uint64)
- v, changed := fastpathTV.DecMapInt8Uint64V(*vp, true, d)
- if changed {
- *vp = v
+ var j int
+ for j = 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ {
+ if j == 0 && len(v) == 0 {
+ if hasLen {
+ xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8)
+ } else {
+ xlen = 8
+ }
+ v = make([]int, uint(xlen))
+ changed = true
}
- } else {
- fastpathTV.DecMapInt8Uint64V(rv2i(rv).(map[int8]uint64), false, d)
+ if j >= len(v) {
+ v = append(v, 0)
+ changed = true
+ }
+ slh.ElemContainerState(j)
+ v[uint(j)] = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize))
}
-}
-func (f fastpathT) DecMapInt8Uint64X(vp *map[int8]uint64, d *Decoder) {
- v, changed := f.DecMapInt8Uint64V(*vp, true, d)
- if changed {
- *vp = v
+ if j < len(v) {
+ v = v[:uint(j)]
+ changed = true
+ } else if j == 0 && v == nil {
+ v = []int{}
+ changed = true
}
+ slh.End()
+ return v, changed
}
-func (_ fastpathT) DecMapInt8Uint64V(v map[int8]uint64, canChange bool,
- d *Decoder) (_ map[int8]uint64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
- v = make(map[int8]uint64, xlen)
- changed = true
+func (fastpathT) DecSliceIntN(v []int, d *Decoder) {
+ slh, containerLenS := d.decSliceHelperStart()
+ if slh.IsNil {
+ return
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
+ if containerLenS == 0 {
+ slh.End()
+ return
}
- d.depthIncr()
- var mk int8
- var mv uint64
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = int8(chkOvf.IntV(dd.DecodeInt64(), 8))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = dd.DecodeUint64()
- if v != nil {
- v[mk] = mv
+ hasLen := containerLenS > 0
+ for j := 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ {
+ if j >= len(v) {
+ fastpathDecArrayCannotExpand(slh, hasLen, len(v), j, containerLenS)
+ return
}
+ slh.ElemContainerState(j)
+ v[uint(j)] = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize))
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
+ slh.End()
}
-func (d *Decoder) fastpathDecMapInt8UintptrR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int8]uintptr)
- v, changed := fastpathTV.DecMapInt8UintptrV(*vp, true, d)
- if changed {
+func (d *Decoder) fastpathDecSliceInt8R(f *codecFnInfo, rv reflect.Value) {
+ if f.seq != seqTypeArray && rv.Kind() == reflect.Ptr {
+ vp := rv2i(rv).(*[]int8)
+ if v, changed := fastpathTV.DecSliceInt8Y(*vp, d); changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt8UintptrV(rv2i(rv).(map[int8]uintptr), false, d)
+ fastpathTV.DecSliceInt8N(rv2i(rv).([]int8), d)
}
}
-func (f fastpathT) DecMapInt8UintptrX(vp *map[int8]uintptr, d *Decoder) {
- v, changed := f.DecMapInt8UintptrV(*vp, true, d)
- if changed {
+func (f fastpathT) DecSliceInt8X(vp *[]int8, d *Decoder) {
+ if v, changed := f.DecSliceInt8Y(*vp, d); changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt8UintptrV(v map[int8]uintptr, canChange bool,
- d *Decoder) (_ map[int8]uintptr, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
- v = make(map[int8]uintptr, xlen)
- changed = true
+func (fastpathT) DecSliceInt8Y(v []int8, d *Decoder) (_ []int8, changed bool) {
+ slh, containerLenS := d.decSliceHelperStart()
+ if slh.IsNil {
+ if v == nil {
+ return
+ }
+ return nil, true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
+ if containerLenS == 0 {
+ if v == nil {
+ v = []int8{}
+ } else if len(v) != 0 {
+ v = v[:0]
+ }
+ slh.End()
+ return v, true
}
- d.depthIncr()
- var mk int8
- var mv uintptr
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = int8(chkOvf.IntV(dd.DecodeInt64(), 8))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
+ hasLen := containerLenS > 0
+ var xlen int
+ if hasLen {
+ if containerLenS > cap(v) {
+ xlen = decInferLen(containerLenS, d.h.MaxInitLen, 1)
+ if xlen <= cap(v) {
+ v = v[:uint(xlen)]
} else {
- v[mk] = 0
+ v = make([]int8, uint(xlen))
}
- continue
- }
- mv = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if v != nil {
- v[mk] = mv
+ changed = true
+ } else if containerLenS != len(v) {
+ v = v[:containerLenS]
+ changed = true
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapInt8IntR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int8]int)
- v, changed := fastpathTV.DecMapInt8IntV(*vp, true, d)
- if changed {
- *vp = v
+ var j int
+ for j = 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ {
+ if j == 0 && len(v) == 0 {
+ if hasLen {
+ xlen = decInferLen(containerLenS, d.h.MaxInitLen, 1)
+ } else {
+ xlen = 8
+ }
+ v = make([]int8, uint(xlen))
+ changed = true
}
- } else {
- fastpathTV.DecMapInt8IntV(rv2i(rv).(map[int8]int), false, d)
+ if j >= len(v) {
+ v = append(v, 0)
+ changed = true
+ }
+ slh.ElemContainerState(j)
+ v[uint(j)] = int8(chkOvf.IntV(d.d.DecodeInt64(), 8))
}
-}
-func (f fastpathT) DecMapInt8IntX(vp *map[int8]int, d *Decoder) {
- v, changed := f.DecMapInt8IntV(*vp, true, d)
- if changed {
- *vp = v
+ if j < len(v) {
+ v = v[:uint(j)]
+ changed = true
+ } else if j == 0 && v == nil {
+ v = []int8{}
+ changed = true
}
+ slh.End()
+ return v, changed
}
-func (_ fastpathT) DecMapInt8IntV(v map[int8]int, canChange bool,
- d *Decoder) (_ map[int8]int, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
- v = make(map[int8]int, xlen)
- changed = true
+func (fastpathT) DecSliceInt8N(v []int8, d *Decoder) {
+ slh, containerLenS := d.decSliceHelperStart()
+ if slh.IsNil {
+ return
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
+ if containerLenS == 0 {
+ slh.End()
+ return
}
- d.depthIncr()
- var mk int8
- var mv int
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = int8(chkOvf.IntV(dd.DecodeInt64(), 8))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize))
- if v != nil {
- v[mk] = mv
+ hasLen := containerLenS > 0
+ for j := 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ {
+ if j >= len(v) {
+ fastpathDecArrayCannotExpand(slh, hasLen, len(v), j, containerLenS)
+ return
}
+ slh.ElemContainerState(j)
+ v[uint(j)] = int8(chkOvf.IntV(d.d.DecodeInt64(), 8))
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
+ slh.End()
}
-func (d *Decoder) fastpathDecMapInt8Int8R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int8]int8)
- v, changed := fastpathTV.DecMapInt8Int8V(*vp, true, d)
- if changed {
+func (d *Decoder) fastpathDecSliceInt16R(f *codecFnInfo, rv reflect.Value) {
+ if f.seq != seqTypeArray && rv.Kind() == reflect.Ptr {
+ vp := rv2i(rv).(*[]int16)
+ if v, changed := fastpathTV.DecSliceInt16Y(*vp, d); changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt8Int8V(rv2i(rv).(map[int8]int8), false, d)
+ fastpathTV.DecSliceInt16N(rv2i(rv).([]int16), d)
}
}
-func (f fastpathT) DecMapInt8Int8X(vp *map[int8]int8, d *Decoder) {
- v, changed := f.DecMapInt8Int8V(*vp, true, d)
- if changed {
+func (f fastpathT) DecSliceInt16X(vp *[]int16, d *Decoder) {
+ if v, changed := f.DecSliceInt16Y(*vp, d); changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt8Int8V(v map[int8]int8, canChange bool,
- d *Decoder) (_ map[int8]int8, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 2)
- v = make(map[int8]int8, xlen)
- changed = true
+func (fastpathT) DecSliceInt16Y(v []int16, d *Decoder) (_ []int16, changed bool) {
+ slh, containerLenS := d.decSliceHelperStart()
+ if slh.IsNil {
+ if v == nil {
+ return
+ }
+ return nil, true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
+ if containerLenS == 0 {
+ if v == nil {
+ v = []int16{}
+ } else if len(v) != 0 {
+ v = v[:0]
+ }
+ slh.End()
+ return v, true
}
- d.depthIncr()
- var mk int8
- var mv int8
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = int8(chkOvf.IntV(dd.DecodeInt64(), 8))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
+ hasLen := containerLenS > 0
+ var xlen int
+ if hasLen {
+ if containerLenS > cap(v) {
+ xlen = decInferLen(containerLenS, d.h.MaxInitLen, 2)
+ if xlen <= cap(v) {
+ v = v[:uint(xlen)]
} else {
- v[mk] = 0
+ v = make([]int16, uint(xlen))
}
- continue
- }
- mv = int8(chkOvf.IntV(dd.DecodeInt64(), 8))
- if v != nil {
- v[mk] = mv
+ changed = true
+ } else if containerLenS != len(v) {
+ v = v[:containerLenS]
+ changed = true
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapInt8Int16R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int8]int16)
- v, changed := fastpathTV.DecMapInt8Int16V(*vp, true, d)
- if changed {
- *vp = v
+ var j int
+ for j = 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ {
+ if j == 0 && len(v) == 0 {
+ if hasLen {
+ xlen = decInferLen(containerLenS, d.h.MaxInitLen, 2)
+ } else {
+ xlen = 8
+ }
+ v = make([]int16, uint(xlen))
+ changed = true
}
- } else {
- fastpathTV.DecMapInt8Int16V(rv2i(rv).(map[int8]int16), false, d)
+ if j >= len(v) {
+ v = append(v, 0)
+ changed = true
+ }
+ slh.ElemContainerState(j)
+ v[uint(j)] = int16(chkOvf.IntV(d.d.DecodeInt64(), 16))
}
-}
-func (f fastpathT) DecMapInt8Int16X(vp *map[int8]int16, d *Decoder) {
- v, changed := f.DecMapInt8Int16V(*vp, true, d)
- if changed {
- *vp = v
+ if j < len(v) {
+ v = v[:uint(j)]
+ changed = true
+ } else if j == 0 && v == nil {
+ v = []int16{}
+ changed = true
}
+ slh.End()
+ return v, changed
}
-func (_ fastpathT) DecMapInt8Int16V(v map[int8]int16, canChange bool,
- d *Decoder) (_ map[int8]int16, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 3)
- v = make(map[int8]int16, xlen)
- changed = true
+func (fastpathT) DecSliceInt16N(v []int16, d *Decoder) {
+ slh, containerLenS := d.decSliceHelperStart()
+ if slh.IsNil {
+ return
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
+ if containerLenS == 0 {
+ slh.End()
+ return
}
- d.depthIncr()
- var mk int8
- var mv int16
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = int8(chkOvf.IntV(dd.DecodeInt64(), 8))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = int16(chkOvf.IntV(dd.DecodeInt64(), 16))
- if v != nil {
- v[mk] = mv
+ hasLen := containerLenS > 0
+ for j := 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ {
+ if j >= len(v) {
+ fastpathDecArrayCannotExpand(slh, hasLen, len(v), j, containerLenS)
+ return
}
+ slh.ElemContainerState(j)
+ v[uint(j)] = int16(chkOvf.IntV(d.d.DecodeInt64(), 16))
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
+ slh.End()
}
-func (d *Decoder) fastpathDecMapInt8Int32R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int8]int32)
- v, changed := fastpathTV.DecMapInt8Int32V(*vp, true, d)
- if changed {
+func (d *Decoder) fastpathDecSliceInt32R(f *codecFnInfo, rv reflect.Value) {
+ if f.seq != seqTypeArray && rv.Kind() == reflect.Ptr {
+ vp := rv2i(rv).(*[]int32)
+ if v, changed := fastpathTV.DecSliceInt32Y(*vp, d); changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt8Int32V(rv2i(rv).(map[int8]int32), false, d)
+ fastpathTV.DecSliceInt32N(rv2i(rv).([]int32), d)
}
}
-func (f fastpathT) DecMapInt8Int32X(vp *map[int8]int32, d *Decoder) {
- v, changed := f.DecMapInt8Int32V(*vp, true, d)
- if changed {
+func (f fastpathT) DecSliceInt32X(vp *[]int32, d *Decoder) {
+ if v, changed := f.DecSliceInt32Y(*vp, d); changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt8Int32V(v map[int8]int32, canChange bool,
- d *Decoder) (_ map[int8]int32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 5)
- v = make(map[int8]int32, xlen)
- changed = true
+func (fastpathT) DecSliceInt32Y(v []int32, d *Decoder) (_ []int32, changed bool) {
+ slh, containerLenS := d.decSliceHelperStart()
+ if slh.IsNil {
+ if v == nil {
+ return
+ }
+ return nil, true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
+ if containerLenS == 0 {
+ if v == nil {
+ v = []int32{}
+ } else if len(v) != 0 {
+ v = v[:0]
+ }
+ slh.End()
+ return v, true
}
- d.depthIncr()
- var mk int8
- var mv int32
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = int8(chkOvf.IntV(dd.DecodeInt64(), 8))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
+ hasLen := containerLenS > 0
+ var xlen int
+ if hasLen {
+ if containerLenS > cap(v) {
+ xlen = decInferLen(containerLenS, d.h.MaxInitLen, 4)
+ if xlen <= cap(v) {
+ v = v[:uint(xlen)]
} else {
- v[mk] = 0
+ v = make([]int32, uint(xlen))
}
- continue
- }
- mv = int32(chkOvf.IntV(dd.DecodeInt64(), 32))
- if v != nil {
- v[mk] = mv
+ changed = true
+ } else if containerLenS != len(v) {
+ v = v[:containerLenS]
+ changed = true
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapInt8Int64R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int8]int64)
- v, changed := fastpathTV.DecMapInt8Int64V(*vp, true, d)
- if changed {
- *vp = v
+ var j int
+ for j = 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ {
+ if j == 0 && len(v) == 0 {
+ if hasLen {
+ xlen = decInferLen(containerLenS, d.h.MaxInitLen, 4)
+ } else {
+ xlen = 8
+ }
+ v = make([]int32, uint(xlen))
+ changed = true
}
- } else {
- fastpathTV.DecMapInt8Int64V(rv2i(rv).(map[int8]int64), false, d)
+ if j >= len(v) {
+ v = append(v, 0)
+ changed = true
+ }
+ slh.ElemContainerState(j)
+ v[uint(j)] = int32(chkOvf.IntV(d.d.DecodeInt64(), 32))
}
-}
-func (f fastpathT) DecMapInt8Int64X(vp *map[int8]int64, d *Decoder) {
- v, changed := f.DecMapInt8Int64V(*vp, true, d)
- if changed {
- *vp = v
+ if j < len(v) {
+ v = v[:uint(j)]
+ changed = true
+ } else if j == 0 && v == nil {
+ v = []int32{}
+ changed = true
}
+ slh.End()
+ return v, changed
}
-func (_ fastpathT) DecMapInt8Int64V(v map[int8]int64, canChange bool,
- d *Decoder) (_ map[int8]int64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
- v = make(map[int8]int64, xlen)
- changed = true
+func (fastpathT) DecSliceInt32N(v []int32, d *Decoder) {
+ slh, containerLenS := d.decSliceHelperStart()
+ if slh.IsNil {
+ return
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
+ if containerLenS == 0 {
+ slh.End()
+ return
}
- d.depthIncr()
- var mk int8
- var mv int64
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = int8(chkOvf.IntV(dd.DecodeInt64(), 8))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = dd.DecodeInt64()
- if v != nil {
- v[mk] = mv
+ hasLen := containerLenS > 0
+ for j := 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ {
+ if j >= len(v) {
+ fastpathDecArrayCannotExpand(slh, hasLen, len(v), j, containerLenS)
+ return
}
+ slh.ElemContainerState(j)
+ v[uint(j)] = int32(chkOvf.IntV(d.d.DecodeInt64(), 32))
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
+ slh.End()
}
-func (d *Decoder) fastpathDecMapInt8Float32R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int8]float32)
- v, changed := fastpathTV.DecMapInt8Float32V(*vp, true, d)
- if changed {
+func (d *Decoder) fastpathDecSliceInt64R(f *codecFnInfo, rv reflect.Value) {
+ if f.seq != seqTypeArray && rv.Kind() == reflect.Ptr {
+ vp := rv2i(rv).(*[]int64)
+ if v, changed := fastpathTV.DecSliceInt64Y(*vp, d); changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt8Float32V(rv2i(rv).(map[int8]float32), false, d)
+ fastpathTV.DecSliceInt64N(rv2i(rv).([]int64), d)
}
}
-func (f fastpathT) DecMapInt8Float32X(vp *map[int8]float32, d *Decoder) {
- v, changed := f.DecMapInt8Float32V(*vp, true, d)
- if changed {
+func (f fastpathT) DecSliceInt64X(vp *[]int64, d *Decoder) {
+ if v, changed := f.DecSliceInt64Y(*vp, d); changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt8Float32V(v map[int8]float32, canChange bool,
- d *Decoder) (_ map[int8]float32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 5)
- v = make(map[int8]float32, xlen)
- changed = true
+func (fastpathT) DecSliceInt64Y(v []int64, d *Decoder) (_ []int64, changed bool) {
+ slh, containerLenS := d.decSliceHelperStart()
+ if slh.IsNil {
+ if v == nil {
+ return
+ }
+ return nil, true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
+ if containerLenS == 0 {
+ if v == nil {
+ v = []int64{}
+ } else if len(v) != 0 {
+ v = v[:0]
+ }
+ slh.End()
+ return v, true
}
- d.depthIncr()
- var mk int8
- var mv float32
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = int8(chkOvf.IntV(dd.DecodeInt64(), 8))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
+ hasLen := containerLenS > 0
+ var xlen int
+ if hasLen {
+ if containerLenS > cap(v) {
+ xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8)
+ if xlen <= cap(v) {
+ v = v[:uint(xlen)]
} else {
- v[mk] = 0
+ v = make([]int64, uint(xlen))
}
- continue
- }
- mv = float32(chkOvf.Float32V(dd.DecodeFloat64()))
- if v != nil {
- v[mk] = mv
+ changed = true
+ } else if containerLenS != len(v) {
+ v = v[:containerLenS]
+ changed = true
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
-}
-
-func (d *Decoder) fastpathDecMapInt8Float64R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int8]float64)
- v, changed := fastpathTV.DecMapInt8Float64V(*vp, true, d)
- if changed {
- *vp = v
+ var j int
+ for j = 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ {
+ if j == 0 && len(v) == 0 {
+ if hasLen {
+ xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8)
+ } else {
+ xlen = 8
+ }
+ v = make([]int64, uint(xlen))
+ changed = true
}
- } else {
- fastpathTV.DecMapInt8Float64V(rv2i(rv).(map[int8]float64), false, d)
+ if j >= len(v) {
+ v = append(v, 0)
+ changed = true
+ }
+ slh.ElemContainerState(j)
+ v[uint(j)] = d.d.DecodeInt64()
}
-}
-func (f fastpathT) DecMapInt8Float64X(vp *map[int8]float64, d *Decoder) {
- v, changed := f.DecMapInt8Float64V(*vp, true, d)
- if changed {
- *vp = v
+ if j < len(v) {
+ v = v[:uint(j)]
+ changed = true
+ } else if j == 0 && v == nil {
+ v = []int64{}
+ changed = true
}
+ slh.End()
+ return v, changed
}
-func (_ fastpathT) DecMapInt8Float64V(v map[int8]float64, canChange bool,
- d *Decoder) (_ map[int8]float64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
- v = make(map[int8]float64, xlen)
- changed = true
+func (fastpathT) DecSliceInt64N(v []int64, d *Decoder) {
+ slh, containerLenS := d.decSliceHelperStart()
+ if slh.IsNil {
+ return
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
+ if containerLenS == 0 {
+ slh.End()
+ return
}
- d.depthIncr()
- var mk int8
- var mv float64
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = int8(chkOvf.IntV(dd.DecodeInt64(), 8))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = dd.DecodeFloat64()
- if v != nil {
- v[mk] = mv
+ hasLen := containerLenS > 0
+ for j := 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ {
+ if j >= len(v) {
+ fastpathDecArrayCannotExpand(slh, hasLen, len(v), j, containerLenS)
+ return
}
+ slh.ElemContainerState(j)
+ v[uint(j)] = d.d.DecodeInt64()
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
+ slh.End()
}
-func (d *Decoder) fastpathDecMapInt8BoolR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int8]bool)
- v, changed := fastpathTV.DecMapInt8BoolV(*vp, true, d)
- if changed {
+func (d *Decoder) fastpathDecSliceBoolR(f *codecFnInfo, rv reflect.Value) {
+ if f.seq != seqTypeArray && rv.Kind() == reflect.Ptr {
+ vp := rv2i(rv).(*[]bool)
+ if v, changed := fastpathTV.DecSliceBoolY(*vp, d); changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt8BoolV(rv2i(rv).(map[int8]bool), false, d)
+ fastpathTV.DecSliceBoolN(rv2i(rv).([]bool), d)
}
}
-func (f fastpathT) DecMapInt8BoolX(vp *map[int8]bool, d *Decoder) {
- v, changed := f.DecMapInt8BoolV(*vp, true, d)
- if changed {
+func (f fastpathT) DecSliceBoolX(vp *[]bool, d *Decoder) {
+ if v, changed := f.DecSliceBoolY(*vp, d); changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt8BoolV(v map[int8]bool, canChange bool,
- d *Decoder) (_ map[int8]bool, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 2)
- v = make(map[int8]bool, xlen)
- changed = true
+func (fastpathT) DecSliceBoolY(v []bool, d *Decoder) (_ []bool, changed bool) {
+ slh, containerLenS := d.decSliceHelperStart()
+ if slh.IsNil {
+ if v == nil {
+ return
+ }
+ return nil, true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
+ if containerLenS == 0 {
+ if v == nil {
+ v = []bool{}
+ } else if len(v) != 0 {
+ v = v[:0]
+ }
+ slh.End()
+ return v, true
}
- d.depthIncr()
- var mk int8
- var mv bool
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = int8(chkOvf.IntV(dd.DecodeInt64(), 8))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
+ hasLen := containerLenS > 0
+ var xlen int
+ if hasLen {
+ if containerLenS > cap(v) {
+ xlen = decInferLen(containerLenS, d.h.MaxInitLen, 1)
+ if xlen <= cap(v) {
+ v = v[:uint(xlen)]
} else {
- v[mk] = false
+ v = make([]bool, uint(xlen))
}
- continue
+ changed = true
+ } else if containerLenS != len(v) {
+ v = v[:containerLenS]
+ changed = true
}
- mv = dd.DecodeBool()
- if v != nil {
- v[mk] = mv
+ }
+ var j int
+ for j = 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ {
+ if j == 0 && len(v) == 0 {
+ if hasLen {
+ xlen = decInferLen(containerLenS, d.h.MaxInitLen, 1)
+ } else {
+ xlen = 8
+ }
+ v = make([]bool, uint(xlen))
+ changed = true
+ }
+ if j >= len(v) {
+ v = append(v, false)
+ changed = true
}
+ slh.ElemContainerState(j)
+ v[uint(j)] = d.d.DecodeBool()
+ }
+ if j < len(v) {
+ v = v[:uint(j)]
+ changed = true
+ } else if j == 0 && v == nil {
+ v = []bool{}
+ changed = true
}
- dd.ReadMapEnd()
- d.depthDecr()
+ slh.End()
return v, changed
}
-
-func (d *Decoder) fastpathDecMapInt16IntfR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int16]interface{})
- v, changed := fastpathTV.DecMapInt16IntfV(*vp, true, d)
- if changed {
- *vp = v
+func (fastpathT) DecSliceBoolN(v []bool, d *Decoder) {
+ slh, containerLenS := d.decSliceHelperStart()
+ if slh.IsNil {
+ return
+ }
+ if containerLenS == 0 {
+ slh.End()
+ return
+ }
+ hasLen := containerLenS > 0
+ for j := 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ {
+ if j >= len(v) {
+ fastpathDecArrayCannotExpand(slh, hasLen, len(v), j, containerLenS)
+ return
}
- } else {
- fastpathTV.DecMapInt16IntfV(rv2i(rv).(map[int16]interface{}), false, d)
+ slh.ElemContainerState(j)
+ v[uint(j)] = d.d.DecodeBool()
}
+ slh.End()
}
-func (f fastpathT) DecMapInt16IntfX(vp *map[int16]interface{}, d *Decoder) {
- v, changed := f.DecMapInt16IntfV(*vp, true, d)
- if changed {
- *vp = v
+func fastpathDecArrayCannotExpand(slh decSliceHelper, hasLen bool, lenv, j, containerLenS int) {
+ slh.d.arrayCannotExpand(lenv, j+1)
+ slh.ElemContainerState(j)
+ slh.d.swallow()
+ j++
+ for ; (hasLen && j < containerLenS) || !(hasLen || slh.d.checkBreak()); j++ {
+ slh.ElemContainerState(j)
+ slh.d.swallow()
}
+ slh.End()
}
-func (_ fastpathT) DecMapInt16IntfV(v map[int16]interface{}, canChange bool,
- d *Decoder) (_ map[int16]interface{}, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 18)
- v = make(map[int16]interface{}, xlen)
- changed = true
+
+func (d *Decoder) fastpathDecMapStringIntfR(f *codecFnInfo, rv reflect.Value) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ if rv.Kind() == reflect.Ptr {
+ *(rv2i(rv).(*map[string]interface{})) = nil
+ }
+ } else {
+ if rv.Kind() == reflect.Ptr {
+ vp, _ := rv2i(rv).(*map[string]interface{})
+ if *vp == nil {
+ *vp = make(map[string]interface{}, decInferLen(containerLen, d.h.MaxInitLen, 32))
+ }
+ if containerLen != 0 {
+ fastpathTV.DecMapStringIntfL(*vp, containerLen, d)
+ }
+ } else if containerLen != 0 {
+ fastpathTV.DecMapStringIntfL(rv2i(rv).(map[string]interface{}), containerLen, d)
+ }
+ d.mapEnd()
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
+}
+func (f fastpathT) DecMapStringIntfX(vp *map[string]interface{}, d *Decoder) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ *vp = nil
+ } else {
+ if *vp == nil {
+ *vp = make(map[string]interface{}, decInferLen(containerLen, d.h.MaxInitLen, 32))
+ }
+ if containerLen != 0 {
+ f.DecMapStringIntfL(*vp, containerLen, d)
+ }
+ d.mapEnd()
}
- d.depthIncr()
+}
+func (fastpathT) DecMapStringIntfL(v map[string]interface{}, containerLen int, d *Decoder) {
mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset
- var mk int16
+ var mk string
var mv interface{}
hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = int16(chkOvf.IntV(dd.DecodeInt64(), 16))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = nil
- }
- continue
- }
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
+ mk = string(d.d.DecodeStringAsBytes())
+ d.mapElemValue()
if mapGet {
mv = v[mk]
} else {
@@ -31205,1960 +5696,1649 @@ func (_ fastpathT) DecMapInt16IntfV(v map[int16]interface{}, canChange bool,
v[mk] = mv
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
}
-
-func (d *Decoder) fastpathDecMapInt16StringR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int16]string)
- v, changed := fastpathTV.DecMapInt16StringV(*vp, true, d)
- if changed {
- *vp = v
+func (d *Decoder) fastpathDecMapStringStringR(f *codecFnInfo, rv reflect.Value) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ if rv.Kind() == reflect.Ptr {
+ *(rv2i(rv).(*map[string]string)) = nil
}
} else {
- fastpathTV.DecMapInt16StringV(rv2i(rv).(map[int16]string), false, d)
+ if rv.Kind() == reflect.Ptr {
+ vp, _ := rv2i(rv).(*map[string]string)
+ if *vp == nil {
+ *vp = make(map[string]string, decInferLen(containerLen, d.h.MaxInitLen, 32))
+ }
+ if containerLen != 0 {
+ fastpathTV.DecMapStringStringL(*vp, containerLen, d)
+ }
+ } else if containerLen != 0 {
+ fastpathTV.DecMapStringStringL(rv2i(rv).(map[string]string), containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (f fastpathT) DecMapInt16StringX(vp *map[int16]string, d *Decoder) {
- v, changed := f.DecMapInt16StringV(*vp, true, d)
- if changed {
- *vp = v
+func (f fastpathT) DecMapStringStringX(vp *map[string]string, d *Decoder) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ *vp = nil
+ } else {
+ if *vp == nil {
+ *vp = make(map[string]string, decInferLen(containerLen, d.h.MaxInitLen, 32))
+ }
+ if containerLen != 0 {
+ f.DecMapStringStringL(*vp, containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (_ fastpathT) DecMapInt16StringV(v map[int16]string, canChange bool,
- d *Decoder) (_ map[int16]string, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 18)
- v = make(map[int16]string, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk int16
+func (fastpathT) DecMapStringStringL(v map[string]string, containerLen int, d *Decoder) {
+ var mk string
var mv string
hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = int16(chkOvf.IntV(dd.DecodeInt64(), 16))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = ""
- }
- continue
- }
- mv = dd.DecodeString()
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
+ mk = string(d.d.DecodeStringAsBytes())
+ d.mapElemValue()
+ mv = string(d.d.DecodeStringAsBytes())
if v != nil {
v[mk] = mv
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
}
-
-func (d *Decoder) fastpathDecMapInt16UintR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int16]uint)
- v, changed := fastpathTV.DecMapInt16UintV(*vp, true, d)
- if changed {
- *vp = v
+func (d *Decoder) fastpathDecMapStringBytesR(f *codecFnInfo, rv reflect.Value) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ if rv.Kind() == reflect.Ptr {
+ *(rv2i(rv).(*map[string][]byte)) = nil
}
} else {
- fastpathTV.DecMapInt16UintV(rv2i(rv).(map[int16]uint), false, d)
+ if rv.Kind() == reflect.Ptr {
+ vp, _ := rv2i(rv).(*map[string][]byte)
+ if *vp == nil {
+ *vp = make(map[string][]byte, decInferLen(containerLen, d.h.MaxInitLen, 40))
+ }
+ if containerLen != 0 {
+ fastpathTV.DecMapStringBytesL(*vp, containerLen, d)
+ }
+ } else if containerLen != 0 {
+ fastpathTV.DecMapStringBytesL(rv2i(rv).(map[string][]byte), containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (f fastpathT) DecMapInt16UintX(vp *map[int16]uint, d *Decoder) {
- v, changed := f.DecMapInt16UintV(*vp, true, d)
- if changed {
- *vp = v
+func (f fastpathT) DecMapStringBytesX(vp *map[string][]byte, d *Decoder) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ *vp = nil
+ } else {
+ if *vp == nil {
+ *vp = make(map[string][]byte, decInferLen(containerLen, d.h.MaxInitLen, 40))
+ }
+ if containerLen != 0 {
+ f.DecMapStringBytesL(*vp, containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (_ fastpathT) DecMapInt16UintV(v map[int16]uint, canChange bool,
- d *Decoder) (_ map[int16]uint, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 10)
- v = make(map[int16]uint, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk int16
- var mv uint
+func (fastpathT) DecMapStringBytesL(v map[string][]byte, containerLen int, d *Decoder) {
+ mapGet := v != nil && !d.h.MapValueReset
+ var mk string
+ var mv []byte
hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = int16(chkOvf.IntV(dd.DecodeInt64(), 16))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
+ mk = string(d.d.DecodeStringAsBytes())
+ d.mapElemValue()
+ if mapGet {
+ mv = v[mk]
+ } else {
+ mv = nil
}
- mv = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
+ mv = d.d.DecodeBytes(mv, false)
if v != nil {
v[mk] = mv
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
}
-
-func (d *Decoder) fastpathDecMapInt16Uint8R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int16]uint8)
- v, changed := fastpathTV.DecMapInt16Uint8V(*vp, true, d)
- if changed {
- *vp = v
+func (d *Decoder) fastpathDecMapStringUintR(f *codecFnInfo, rv reflect.Value) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ if rv.Kind() == reflect.Ptr {
+ *(rv2i(rv).(*map[string]uint)) = nil
}
} else {
- fastpathTV.DecMapInt16Uint8V(rv2i(rv).(map[int16]uint8), false, d)
+ if rv.Kind() == reflect.Ptr {
+ vp, _ := rv2i(rv).(*map[string]uint)
+ if *vp == nil {
+ *vp = make(map[string]uint, decInferLen(containerLen, d.h.MaxInitLen, 24))
+ }
+ if containerLen != 0 {
+ fastpathTV.DecMapStringUintL(*vp, containerLen, d)
+ }
+ } else if containerLen != 0 {
+ fastpathTV.DecMapStringUintL(rv2i(rv).(map[string]uint), containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (f fastpathT) DecMapInt16Uint8X(vp *map[int16]uint8, d *Decoder) {
- v, changed := f.DecMapInt16Uint8V(*vp, true, d)
- if changed {
- *vp = v
+func (f fastpathT) DecMapStringUintX(vp *map[string]uint, d *Decoder) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ *vp = nil
+ } else {
+ if *vp == nil {
+ *vp = make(map[string]uint, decInferLen(containerLen, d.h.MaxInitLen, 24))
+ }
+ if containerLen != 0 {
+ f.DecMapStringUintL(*vp, containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (_ fastpathT) DecMapInt16Uint8V(v map[int16]uint8, canChange bool,
- d *Decoder) (_ map[int16]uint8, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 3)
- v = make(map[int16]uint8, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk int16
- var mv uint8
+func (fastpathT) DecMapStringUintL(v map[string]uint, containerLen int, d *Decoder) {
+ var mk string
+ var mv uint
hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = int16(chkOvf.IntV(dd.DecodeInt64(), 16))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uint8(chkOvf.UintV(dd.DecodeUint64(), 8))
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
+ mk = string(d.d.DecodeStringAsBytes())
+ d.mapElemValue()
+ mv = uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize))
if v != nil {
v[mk] = mv
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
}
-
-func (d *Decoder) fastpathDecMapInt16Uint16R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int16]uint16)
- v, changed := fastpathTV.DecMapInt16Uint16V(*vp, true, d)
- if changed {
- *vp = v
+func (d *Decoder) fastpathDecMapStringUint8R(f *codecFnInfo, rv reflect.Value) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ if rv.Kind() == reflect.Ptr {
+ *(rv2i(rv).(*map[string]uint8)) = nil
}
} else {
- fastpathTV.DecMapInt16Uint16V(rv2i(rv).(map[int16]uint16), false, d)
+ if rv.Kind() == reflect.Ptr {
+ vp, _ := rv2i(rv).(*map[string]uint8)
+ if *vp == nil {
+ *vp = make(map[string]uint8, decInferLen(containerLen, d.h.MaxInitLen, 17))
+ }
+ if containerLen != 0 {
+ fastpathTV.DecMapStringUint8L(*vp, containerLen, d)
+ }
+ } else if containerLen != 0 {
+ fastpathTV.DecMapStringUint8L(rv2i(rv).(map[string]uint8), containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (f fastpathT) DecMapInt16Uint16X(vp *map[int16]uint16, d *Decoder) {
- v, changed := f.DecMapInt16Uint16V(*vp, true, d)
- if changed {
- *vp = v
+func (f fastpathT) DecMapStringUint8X(vp *map[string]uint8, d *Decoder) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ *vp = nil
+ } else {
+ if *vp == nil {
+ *vp = make(map[string]uint8, decInferLen(containerLen, d.h.MaxInitLen, 17))
+ }
+ if containerLen != 0 {
+ f.DecMapStringUint8L(*vp, containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (_ fastpathT) DecMapInt16Uint16V(v map[int16]uint16, canChange bool,
- d *Decoder) (_ map[int16]uint16, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 4)
- v = make(map[int16]uint16, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk int16
- var mv uint16
+func (fastpathT) DecMapStringUint8L(v map[string]uint8, containerLen int, d *Decoder) {
+ var mk string
+ var mv uint8
hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = int16(chkOvf.IntV(dd.DecodeInt64(), 16))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uint16(chkOvf.UintV(dd.DecodeUint64(), 16))
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
+ mk = string(d.d.DecodeStringAsBytes())
+ d.mapElemValue()
+ mv = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8))
if v != nil {
v[mk] = mv
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
}
-
-func (d *Decoder) fastpathDecMapInt16Uint32R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int16]uint32)
- v, changed := fastpathTV.DecMapInt16Uint32V(*vp, true, d)
- if changed {
- *vp = v
+func (d *Decoder) fastpathDecMapStringUint64R(f *codecFnInfo, rv reflect.Value) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ if rv.Kind() == reflect.Ptr {
+ *(rv2i(rv).(*map[string]uint64)) = nil
}
} else {
- fastpathTV.DecMapInt16Uint32V(rv2i(rv).(map[int16]uint32), false, d)
+ if rv.Kind() == reflect.Ptr {
+ vp, _ := rv2i(rv).(*map[string]uint64)
+ if *vp == nil {
+ *vp = make(map[string]uint64, decInferLen(containerLen, d.h.MaxInitLen, 24))
+ }
+ if containerLen != 0 {
+ fastpathTV.DecMapStringUint64L(*vp, containerLen, d)
+ }
+ } else if containerLen != 0 {
+ fastpathTV.DecMapStringUint64L(rv2i(rv).(map[string]uint64), containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (f fastpathT) DecMapInt16Uint32X(vp *map[int16]uint32, d *Decoder) {
- v, changed := f.DecMapInt16Uint32V(*vp, true, d)
- if changed {
- *vp = v
+func (f fastpathT) DecMapStringUint64X(vp *map[string]uint64, d *Decoder) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ *vp = nil
+ } else {
+ if *vp == nil {
+ *vp = make(map[string]uint64, decInferLen(containerLen, d.h.MaxInitLen, 24))
+ }
+ if containerLen != 0 {
+ f.DecMapStringUint64L(*vp, containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (_ fastpathT) DecMapInt16Uint32V(v map[int16]uint32, canChange bool,
- d *Decoder) (_ map[int16]uint32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 6)
- v = make(map[int16]uint32, xlen)
- changed = true
+func (fastpathT) DecMapStringUint64L(v map[string]uint64, containerLen int, d *Decoder) {
+ var mk string
+ var mv uint64
+ hasLen := containerLen > 0
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
+ mk = string(d.d.DecodeStringAsBytes())
+ d.mapElemValue()
+ mv = d.d.DecodeUint64()
+ if v != nil {
+ v[mk] = mv
+ }
+ }
+}
+func (d *Decoder) fastpathDecMapStringIntR(f *codecFnInfo, rv reflect.Value) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ if rv.Kind() == reflect.Ptr {
+ *(rv2i(rv).(*map[string]int)) = nil
+ }
+ } else {
+ if rv.Kind() == reflect.Ptr {
+ vp, _ := rv2i(rv).(*map[string]int)
+ if *vp == nil {
+ *vp = make(map[string]int, decInferLen(containerLen, d.h.MaxInitLen, 24))
+ }
+ if containerLen != 0 {
+ fastpathTV.DecMapStringIntL(*vp, containerLen, d)
+ }
+ } else if containerLen != 0 {
+ fastpathTV.DecMapStringIntL(rv2i(rv).(map[string]int), containerLen, d)
+ }
+ d.mapEnd()
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
+}
+func (f fastpathT) DecMapStringIntX(vp *map[string]int, d *Decoder) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ *vp = nil
+ } else {
+ if *vp == nil {
+ *vp = make(map[string]int, decInferLen(containerLen, d.h.MaxInitLen, 24))
+ }
+ if containerLen != 0 {
+ f.DecMapStringIntL(*vp, containerLen, d)
+ }
+ d.mapEnd()
}
- d.depthIncr()
- var mk int16
- var mv uint32
+}
+func (fastpathT) DecMapStringIntL(v map[string]int, containerLen int, d *Decoder) {
+ var mk string
+ var mv int
hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = int16(chkOvf.IntV(dd.DecodeInt64(), 16))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uint32(chkOvf.UintV(dd.DecodeUint64(), 32))
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
+ mk = string(d.d.DecodeStringAsBytes())
+ d.mapElemValue()
+ mv = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize))
if v != nil {
v[mk] = mv
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
}
-
-func (d *Decoder) fastpathDecMapInt16Uint64R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int16]uint64)
- v, changed := fastpathTV.DecMapInt16Uint64V(*vp, true, d)
- if changed {
- *vp = v
+func (d *Decoder) fastpathDecMapStringInt64R(f *codecFnInfo, rv reflect.Value) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ if rv.Kind() == reflect.Ptr {
+ *(rv2i(rv).(*map[string]int64)) = nil
}
} else {
- fastpathTV.DecMapInt16Uint64V(rv2i(rv).(map[int16]uint64), false, d)
+ if rv.Kind() == reflect.Ptr {
+ vp, _ := rv2i(rv).(*map[string]int64)
+ if *vp == nil {
+ *vp = make(map[string]int64, decInferLen(containerLen, d.h.MaxInitLen, 24))
+ }
+ if containerLen != 0 {
+ fastpathTV.DecMapStringInt64L(*vp, containerLen, d)
+ }
+ } else if containerLen != 0 {
+ fastpathTV.DecMapStringInt64L(rv2i(rv).(map[string]int64), containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (f fastpathT) DecMapInt16Uint64X(vp *map[int16]uint64, d *Decoder) {
- v, changed := f.DecMapInt16Uint64V(*vp, true, d)
- if changed {
- *vp = v
+func (f fastpathT) DecMapStringInt64X(vp *map[string]int64, d *Decoder) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ *vp = nil
+ } else {
+ if *vp == nil {
+ *vp = make(map[string]int64, decInferLen(containerLen, d.h.MaxInitLen, 24))
+ }
+ if containerLen != 0 {
+ f.DecMapStringInt64L(*vp, containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (_ fastpathT) DecMapInt16Uint64V(v map[int16]uint64, canChange bool,
- d *Decoder) (_ map[int16]uint64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 10)
- v = make(map[int16]uint64, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk int16
- var mv uint64
+func (fastpathT) DecMapStringInt64L(v map[string]int64, containerLen int, d *Decoder) {
+ var mk string
+ var mv int64
hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = int16(chkOvf.IntV(dd.DecodeInt64(), 16))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = dd.DecodeUint64()
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
+ mk = string(d.d.DecodeStringAsBytes())
+ d.mapElemValue()
+ mv = d.d.DecodeInt64()
if v != nil {
v[mk] = mv
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
}
-
-func (d *Decoder) fastpathDecMapInt16UintptrR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int16]uintptr)
- v, changed := fastpathTV.DecMapInt16UintptrV(*vp, true, d)
- if changed {
- *vp = v
+func (d *Decoder) fastpathDecMapStringFloat32R(f *codecFnInfo, rv reflect.Value) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ if rv.Kind() == reflect.Ptr {
+ *(rv2i(rv).(*map[string]float32)) = nil
}
} else {
- fastpathTV.DecMapInt16UintptrV(rv2i(rv).(map[int16]uintptr), false, d)
+ if rv.Kind() == reflect.Ptr {
+ vp, _ := rv2i(rv).(*map[string]float32)
+ if *vp == nil {
+ *vp = make(map[string]float32, decInferLen(containerLen, d.h.MaxInitLen, 20))
+ }
+ if containerLen != 0 {
+ fastpathTV.DecMapStringFloat32L(*vp, containerLen, d)
+ }
+ } else if containerLen != 0 {
+ fastpathTV.DecMapStringFloat32L(rv2i(rv).(map[string]float32), containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (f fastpathT) DecMapInt16UintptrX(vp *map[int16]uintptr, d *Decoder) {
- v, changed := f.DecMapInt16UintptrV(*vp, true, d)
- if changed {
- *vp = v
+func (f fastpathT) DecMapStringFloat32X(vp *map[string]float32, d *Decoder) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ *vp = nil
+ } else {
+ if *vp == nil {
+ *vp = make(map[string]float32, decInferLen(containerLen, d.h.MaxInitLen, 20))
+ }
+ if containerLen != 0 {
+ f.DecMapStringFloat32L(*vp, containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (_ fastpathT) DecMapInt16UintptrV(v map[int16]uintptr, canChange bool,
- d *Decoder) (_ map[int16]uintptr, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 10)
- v = make(map[int16]uintptr, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk int16
- var mv uintptr
+func (fastpathT) DecMapStringFloat32L(v map[string]float32, containerLen int, d *Decoder) {
+ var mk string
+ var mv float32
hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = int16(chkOvf.IntV(dd.DecodeInt64(), 16))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
+ mk = string(d.d.DecodeStringAsBytes())
+ d.mapElemValue()
+ mv = float32(d.decodeFloat32())
if v != nil {
v[mk] = mv
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
}
-
-func (d *Decoder) fastpathDecMapInt16IntR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int16]int)
- v, changed := fastpathTV.DecMapInt16IntV(*vp, true, d)
- if changed {
- *vp = v
+func (d *Decoder) fastpathDecMapStringFloat64R(f *codecFnInfo, rv reflect.Value) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ if rv.Kind() == reflect.Ptr {
+ *(rv2i(rv).(*map[string]float64)) = nil
}
} else {
- fastpathTV.DecMapInt16IntV(rv2i(rv).(map[int16]int), false, d)
+ if rv.Kind() == reflect.Ptr {
+ vp, _ := rv2i(rv).(*map[string]float64)
+ if *vp == nil {
+ *vp = make(map[string]float64, decInferLen(containerLen, d.h.MaxInitLen, 24))
+ }
+ if containerLen != 0 {
+ fastpathTV.DecMapStringFloat64L(*vp, containerLen, d)
+ }
+ } else if containerLen != 0 {
+ fastpathTV.DecMapStringFloat64L(rv2i(rv).(map[string]float64), containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (f fastpathT) DecMapInt16IntX(vp *map[int16]int, d *Decoder) {
- v, changed := f.DecMapInt16IntV(*vp, true, d)
- if changed {
- *vp = v
+func (f fastpathT) DecMapStringFloat64X(vp *map[string]float64, d *Decoder) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ *vp = nil
+ } else {
+ if *vp == nil {
+ *vp = make(map[string]float64, decInferLen(containerLen, d.h.MaxInitLen, 24))
+ }
+ if containerLen != 0 {
+ f.DecMapStringFloat64L(*vp, containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (_ fastpathT) DecMapInt16IntV(v map[int16]int, canChange bool,
- d *Decoder) (_ map[int16]int, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 10)
- v = make(map[int16]int, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk int16
- var mv int
+func (fastpathT) DecMapStringFloat64L(v map[string]float64, containerLen int, d *Decoder) {
+ var mk string
+ var mv float64
hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = int16(chkOvf.IntV(dd.DecodeInt64(), 16))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize))
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
+ mk = string(d.d.DecodeStringAsBytes())
+ d.mapElemValue()
+ mv = d.d.DecodeFloat64()
if v != nil {
v[mk] = mv
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
}
-
-func (d *Decoder) fastpathDecMapInt16Int8R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int16]int8)
- v, changed := fastpathTV.DecMapInt16Int8V(*vp, true, d)
- if changed {
- *vp = v
+func (d *Decoder) fastpathDecMapStringBoolR(f *codecFnInfo, rv reflect.Value) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ if rv.Kind() == reflect.Ptr {
+ *(rv2i(rv).(*map[string]bool)) = nil
}
} else {
- fastpathTV.DecMapInt16Int8V(rv2i(rv).(map[int16]int8), false, d)
+ if rv.Kind() == reflect.Ptr {
+ vp, _ := rv2i(rv).(*map[string]bool)
+ if *vp == nil {
+ *vp = make(map[string]bool, decInferLen(containerLen, d.h.MaxInitLen, 17))
+ }
+ if containerLen != 0 {
+ fastpathTV.DecMapStringBoolL(*vp, containerLen, d)
+ }
+ } else if containerLen != 0 {
+ fastpathTV.DecMapStringBoolL(rv2i(rv).(map[string]bool), containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (f fastpathT) DecMapInt16Int8X(vp *map[int16]int8, d *Decoder) {
- v, changed := f.DecMapInt16Int8V(*vp, true, d)
- if changed {
- *vp = v
+func (f fastpathT) DecMapStringBoolX(vp *map[string]bool, d *Decoder) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ *vp = nil
+ } else {
+ if *vp == nil {
+ *vp = make(map[string]bool, decInferLen(containerLen, d.h.MaxInitLen, 17))
+ }
+ if containerLen != 0 {
+ f.DecMapStringBoolL(*vp, containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (_ fastpathT) DecMapInt16Int8V(v map[int16]int8, canChange bool,
- d *Decoder) (_ map[int16]int8, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 3)
- v = make(map[int16]int8, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk int16
- var mv int8
+func (fastpathT) DecMapStringBoolL(v map[string]bool, containerLen int, d *Decoder) {
+ var mk string
+ var mv bool
hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = int16(chkOvf.IntV(dd.DecodeInt64(), 16))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = int8(chkOvf.IntV(dd.DecodeInt64(), 8))
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
+ mk = string(d.d.DecodeStringAsBytes())
+ d.mapElemValue()
+ mv = d.d.DecodeBool()
if v != nil {
v[mk] = mv
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
}
-
-func (d *Decoder) fastpathDecMapInt16Int16R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int16]int16)
- v, changed := fastpathTV.DecMapInt16Int16V(*vp, true, d)
- if changed {
- *vp = v
+func (d *Decoder) fastpathDecMapUintIntfR(f *codecFnInfo, rv reflect.Value) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ if rv.Kind() == reflect.Ptr {
+ *(rv2i(rv).(*map[uint]interface{})) = nil
}
} else {
- fastpathTV.DecMapInt16Int16V(rv2i(rv).(map[int16]int16), false, d)
+ if rv.Kind() == reflect.Ptr {
+ vp, _ := rv2i(rv).(*map[uint]interface{})
+ if *vp == nil {
+ *vp = make(map[uint]interface{}, decInferLen(containerLen, d.h.MaxInitLen, 24))
+ }
+ if containerLen != 0 {
+ fastpathTV.DecMapUintIntfL(*vp, containerLen, d)
+ }
+ } else if containerLen != 0 {
+ fastpathTV.DecMapUintIntfL(rv2i(rv).(map[uint]interface{}), containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (f fastpathT) DecMapInt16Int16X(vp *map[int16]int16, d *Decoder) {
- v, changed := f.DecMapInt16Int16V(*vp, true, d)
- if changed {
- *vp = v
+func (f fastpathT) DecMapUintIntfX(vp *map[uint]interface{}, d *Decoder) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ *vp = nil
+ } else {
+ if *vp == nil {
+ *vp = make(map[uint]interface{}, decInferLen(containerLen, d.h.MaxInitLen, 24))
+ }
+ if containerLen != 0 {
+ f.DecMapUintIntfL(*vp, containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (_ fastpathT) DecMapInt16Int16V(v map[int16]int16, canChange bool,
- d *Decoder) (_ map[int16]int16, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 4)
- v = make(map[int16]int16, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk int16
- var mv int16
+func (fastpathT) DecMapUintIntfL(v map[uint]interface{}, containerLen int, d *Decoder) {
+ mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset
+ var mk uint
+ var mv interface{}
hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = int16(chkOvf.IntV(dd.DecodeInt64(), 16))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
+ mk = uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize))
+ d.mapElemValue()
+ if mapGet {
+ mv = v[mk]
+ } else {
+ mv = nil
}
- mv = int16(chkOvf.IntV(dd.DecodeInt64(), 16))
+ d.decode(&mv)
if v != nil {
v[mk] = mv
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
}
-
-func (d *Decoder) fastpathDecMapInt16Int32R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int16]int32)
- v, changed := fastpathTV.DecMapInt16Int32V(*vp, true, d)
- if changed {
- *vp = v
+func (d *Decoder) fastpathDecMapUintStringR(f *codecFnInfo, rv reflect.Value) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ if rv.Kind() == reflect.Ptr {
+ *(rv2i(rv).(*map[uint]string)) = nil
}
} else {
- fastpathTV.DecMapInt16Int32V(rv2i(rv).(map[int16]int32), false, d)
+ if rv.Kind() == reflect.Ptr {
+ vp, _ := rv2i(rv).(*map[uint]string)
+ if *vp == nil {
+ *vp = make(map[uint]string, decInferLen(containerLen, d.h.MaxInitLen, 24))
+ }
+ if containerLen != 0 {
+ fastpathTV.DecMapUintStringL(*vp, containerLen, d)
+ }
+ } else if containerLen != 0 {
+ fastpathTV.DecMapUintStringL(rv2i(rv).(map[uint]string), containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (f fastpathT) DecMapInt16Int32X(vp *map[int16]int32, d *Decoder) {
- v, changed := f.DecMapInt16Int32V(*vp, true, d)
- if changed {
- *vp = v
+func (f fastpathT) DecMapUintStringX(vp *map[uint]string, d *Decoder) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ *vp = nil
+ } else {
+ if *vp == nil {
+ *vp = make(map[uint]string, decInferLen(containerLen, d.h.MaxInitLen, 24))
+ }
+ if containerLen != 0 {
+ f.DecMapUintStringL(*vp, containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (_ fastpathT) DecMapInt16Int32V(v map[int16]int32, canChange bool,
- d *Decoder) (_ map[int16]int32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 6)
- v = make(map[int16]int32, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk int16
- var mv int32
+func (fastpathT) DecMapUintStringL(v map[uint]string, containerLen int, d *Decoder) {
+ var mk uint
+ var mv string
hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = int16(chkOvf.IntV(dd.DecodeInt64(), 16))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = int32(chkOvf.IntV(dd.DecodeInt64(), 32))
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
+ mk = uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize))
+ d.mapElemValue()
+ mv = string(d.d.DecodeStringAsBytes())
if v != nil {
v[mk] = mv
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
}
-
-func (d *Decoder) fastpathDecMapInt16Int64R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int16]int64)
- v, changed := fastpathTV.DecMapInt16Int64V(*vp, true, d)
- if changed {
- *vp = v
+func (d *Decoder) fastpathDecMapUintBytesR(f *codecFnInfo, rv reflect.Value) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ if rv.Kind() == reflect.Ptr {
+ *(rv2i(rv).(*map[uint][]byte)) = nil
}
} else {
- fastpathTV.DecMapInt16Int64V(rv2i(rv).(map[int16]int64), false, d)
+ if rv.Kind() == reflect.Ptr {
+ vp, _ := rv2i(rv).(*map[uint][]byte)
+ if *vp == nil {
+ *vp = make(map[uint][]byte, decInferLen(containerLen, d.h.MaxInitLen, 32))
+ }
+ if containerLen != 0 {
+ fastpathTV.DecMapUintBytesL(*vp, containerLen, d)
+ }
+ } else if containerLen != 0 {
+ fastpathTV.DecMapUintBytesL(rv2i(rv).(map[uint][]byte), containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (f fastpathT) DecMapInt16Int64X(vp *map[int16]int64, d *Decoder) {
- v, changed := f.DecMapInt16Int64V(*vp, true, d)
- if changed {
- *vp = v
+func (f fastpathT) DecMapUintBytesX(vp *map[uint][]byte, d *Decoder) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ *vp = nil
+ } else {
+ if *vp == nil {
+ *vp = make(map[uint][]byte, decInferLen(containerLen, d.h.MaxInitLen, 32))
+ }
+ if containerLen != 0 {
+ f.DecMapUintBytesL(*vp, containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (_ fastpathT) DecMapInt16Int64V(v map[int16]int64, canChange bool,
- d *Decoder) (_ map[int16]int64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 10)
- v = make(map[int16]int64, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk int16
- var mv int64
+func (fastpathT) DecMapUintBytesL(v map[uint][]byte, containerLen int, d *Decoder) {
+ mapGet := v != nil && !d.h.MapValueReset
+ var mk uint
+ var mv []byte
hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = int16(chkOvf.IntV(dd.DecodeInt64(), 16))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
+ mk = uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize))
+ d.mapElemValue()
+ if mapGet {
+ mv = v[mk]
+ } else {
+ mv = nil
}
- mv = dd.DecodeInt64()
+ mv = d.d.DecodeBytes(mv, false)
if v != nil {
v[mk] = mv
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
}
-
-func (d *Decoder) fastpathDecMapInt16Float32R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int16]float32)
- v, changed := fastpathTV.DecMapInt16Float32V(*vp, true, d)
- if changed {
- *vp = v
+func (d *Decoder) fastpathDecMapUintUintR(f *codecFnInfo, rv reflect.Value) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ if rv.Kind() == reflect.Ptr {
+ *(rv2i(rv).(*map[uint]uint)) = nil
}
} else {
- fastpathTV.DecMapInt16Float32V(rv2i(rv).(map[int16]float32), false, d)
+ if rv.Kind() == reflect.Ptr {
+ vp, _ := rv2i(rv).(*map[uint]uint)
+ if *vp == nil {
+ *vp = make(map[uint]uint, decInferLen(containerLen, d.h.MaxInitLen, 16))
+ }
+ if containerLen != 0 {
+ fastpathTV.DecMapUintUintL(*vp, containerLen, d)
+ }
+ } else if containerLen != 0 {
+ fastpathTV.DecMapUintUintL(rv2i(rv).(map[uint]uint), containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (f fastpathT) DecMapInt16Float32X(vp *map[int16]float32, d *Decoder) {
- v, changed := f.DecMapInt16Float32V(*vp, true, d)
- if changed {
- *vp = v
+func (f fastpathT) DecMapUintUintX(vp *map[uint]uint, d *Decoder) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ *vp = nil
+ } else {
+ if *vp == nil {
+ *vp = make(map[uint]uint, decInferLen(containerLen, d.h.MaxInitLen, 16))
+ }
+ if containerLen != 0 {
+ f.DecMapUintUintL(*vp, containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (_ fastpathT) DecMapInt16Float32V(v map[int16]float32, canChange bool,
- d *Decoder) (_ map[int16]float32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 6)
- v = make(map[int16]float32, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk int16
- var mv float32
+func (fastpathT) DecMapUintUintL(v map[uint]uint, containerLen int, d *Decoder) {
+ var mk uint
+ var mv uint
hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = int16(chkOvf.IntV(dd.DecodeInt64(), 16))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = float32(chkOvf.Float32V(dd.DecodeFloat64()))
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
+ mk = uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize))
+ d.mapElemValue()
+ mv = uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize))
if v != nil {
v[mk] = mv
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
}
-
-func (d *Decoder) fastpathDecMapInt16Float64R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int16]float64)
- v, changed := fastpathTV.DecMapInt16Float64V(*vp, true, d)
- if changed {
- *vp = v
+func (d *Decoder) fastpathDecMapUintUint8R(f *codecFnInfo, rv reflect.Value) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ if rv.Kind() == reflect.Ptr {
+ *(rv2i(rv).(*map[uint]uint8)) = nil
}
} else {
- fastpathTV.DecMapInt16Float64V(rv2i(rv).(map[int16]float64), false, d)
+ if rv.Kind() == reflect.Ptr {
+ vp, _ := rv2i(rv).(*map[uint]uint8)
+ if *vp == nil {
+ *vp = make(map[uint]uint8, decInferLen(containerLen, d.h.MaxInitLen, 9))
+ }
+ if containerLen != 0 {
+ fastpathTV.DecMapUintUint8L(*vp, containerLen, d)
+ }
+ } else if containerLen != 0 {
+ fastpathTV.DecMapUintUint8L(rv2i(rv).(map[uint]uint8), containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (f fastpathT) DecMapInt16Float64X(vp *map[int16]float64, d *Decoder) {
- v, changed := f.DecMapInt16Float64V(*vp, true, d)
- if changed {
- *vp = v
+func (f fastpathT) DecMapUintUint8X(vp *map[uint]uint8, d *Decoder) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ *vp = nil
+ } else {
+ if *vp == nil {
+ *vp = make(map[uint]uint8, decInferLen(containerLen, d.h.MaxInitLen, 9))
+ }
+ if containerLen != 0 {
+ f.DecMapUintUint8L(*vp, containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (_ fastpathT) DecMapInt16Float64V(v map[int16]float64, canChange bool,
- d *Decoder) (_ map[int16]float64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 10)
- v = make(map[int16]float64, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk int16
- var mv float64
+func (fastpathT) DecMapUintUint8L(v map[uint]uint8, containerLen int, d *Decoder) {
+ var mk uint
+ var mv uint8
hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = int16(chkOvf.IntV(dd.DecodeInt64(), 16))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = dd.DecodeFloat64()
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
+ mk = uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize))
+ d.mapElemValue()
+ mv = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8))
if v != nil {
v[mk] = mv
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
}
-
-func (d *Decoder) fastpathDecMapInt16BoolR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int16]bool)
- v, changed := fastpathTV.DecMapInt16BoolV(*vp, true, d)
- if changed {
- *vp = v
+func (d *Decoder) fastpathDecMapUintUint64R(f *codecFnInfo, rv reflect.Value) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ if rv.Kind() == reflect.Ptr {
+ *(rv2i(rv).(*map[uint]uint64)) = nil
}
} else {
- fastpathTV.DecMapInt16BoolV(rv2i(rv).(map[int16]bool), false, d)
+ if rv.Kind() == reflect.Ptr {
+ vp, _ := rv2i(rv).(*map[uint]uint64)
+ if *vp == nil {
+ *vp = make(map[uint]uint64, decInferLen(containerLen, d.h.MaxInitLen, 16))
+ }
+ if containerLen != 0 {
+ fastpathTV.DecMapUintUint64L(*vp, containerLen, d)
+ }
+ } else if containerLen != 0 {
+ fastpathTV.DecMapUintUint64L(rv2i(rv).(map[uint]uint64), containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (f fastpathT) DecMapInt16BoolX(vp *map[int16]bool, d *Decoder) {
- v, changed := f.DecMapInt16BoolV(*vp, true, d)
- if changed {
- *vp = v
+func (f fastpathT) DecMapUintUint64X(vp *map[uint]uint64, d *Decoder) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ *vp = nil
+ } else {
+ if *vp == nil {
+ *vp = make(map[uint]uint64, decInferLen(containerLen, d.h.MaxInitLen, 16))
+ }
+ if containerLen != 0 {
+ f.DecMapUintUint64L(*vp, containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (_ fastpathT) DecMapInt16BoolV(v map[int16]bool, canChange bool,
- d *Decoder) (_ map[int16]bool, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 3)
- v = make(map[int16]bool, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk int16
- var mv bool
+func (fastpathT) DecMapUintUint64L(v map[uint]uint64, containerLen int, d *Decoder) {
+ var mk uint
+ var mv uint64
hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = int16(chkOvf.IntV(dd.DecodeInt64(), 16))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = false
- }
- continue
- }
- mv = dd.DecodeBool()
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
+ mk = uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize))
+ d.mapElemValue()
+ mv = d.d.DecodeUint64()
if v != nil {
v[mk] = mv
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
}
-
-func (d *Decoder) fastpathDecMapInt32IntfR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int32]interface{})
- v, changed := fastpathTV.DecMapInt32IntfV(*vp, true, d)
- if changed {
- *vp = v
+func (d *Decoder) fastpathDecMapUintIntR(f *codecFnInfo, rv reflect.Value) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ if rv.Kind() == reflect.Ptr {
+ *(rv2i(rv).(*map[uint]int)) = nil
}
} else {
- fastpathTV.DecMapInt32IntfV(rv2i(rv).(map[int32]interface{}), false, d)
+ if rv.Kind() == reflect.Ptr {
+ vp, _ := rv2i(rv).(*map[uint]int)
+ if *vp == nil {
+ *vp = make(map[uint]int, decInferLen(containerLen, d.h.MaxInitLen, 16))
+ }
+ if containerLen != 0 {
+ fastpathTV.DecMapUintIntL(*vp, containerLen, d)
+ }
+ } else if containerLen != 0 {
+ fastpathTV.DecMapUintIntL(rv2i(rv).(map[uint]int), containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (f fastpathT) DecMapInt32IntfX(vp *map[int32]interface{}, d *Decoder) {
- v, changed := f.DecMapInt32IntfV(*vp, true, d)
- if changed {
- *vp = v
+func (f fastpathT) DecMapUintIntX(vp *map[uint]int, d *Decoder) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ *vp = nil
+ } else {
+ if *vp == nil {
+ *vp = make(map[uint]int, decInferLen(containerLen, d.h.MaxInitLen, 16))
+ }
+ if containerLen != 0 {
+ f.DecMapUintIntL(*vp, containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (_ fastpathT) DecMapInt32IntfV(v map[int32]interface{}, canChange bool,
- d *Decoder) (_ map[int32]interface{}, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 20)
- v = make(map[int32]interface{}, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset
- var mk int32
- var mv interface{}
+func (fastpathT) DecMapUintIntL(v map[uint]int, containerLen int, d *Decoder) {
+ var mk uint
+ var mv int
hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = int32(chkOvf.IntV(dd.DecodeInt64(), 32))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = nil
- }
- continue
- }
- if mapGet {
- mv = v[mk]
- } else {
- mv = nil
- }
- d.decode(&mv)
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
+ mk = uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize))
+ d.mapElemValue()
+ mv = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize))
if v != nil {
v[mk] = mv
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
}
-
-func (d *Decoder) fastpathDecMapInt32StringR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int32]string)
- v, changed := fastpathTV.DecMapInt32StringV(*vp, true, d)
- if changed {
- *vp = v
+func (d *Decoder) fastpathDecMapUintInt64R(f *codecFnInfo, rv reflect.Value) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ if rv.Kind() == reflect.Ptr {
+ *(rv2i(rv).(*map[uint]int64)) = nil
}
} else {
- fastpathTV.DecMapInt32StringV(rv2i(rv).(map[int32]string), false, d)
- }
-}
-func (f fastpathT) DecMapInt32StringX(vp *map[int32]string, d *Decoder) {
- v, changed := f.DecMapInt32StringV(*vp, true, d)
- if changed {
- *vp = v
+ if rv.Kind() == reflect.Ptr {
+ vp, _ := rv2i(rv).(*map[uint]int64)
+ if *vp == nil {
+ *vp = make(map[uint]int64, decInferLen(containerLen, d.h.MaxInitLen, 16))
+ }
+ if containerLen != 0 {
+ fastpathTV.DecMapUintInt64L(*vp, containerLen, d)
+ }
+ } else if containerLen != 0 {
+ fastpathTV.DecMapUintInt64L(rv2i(rv).(map[uint]int64), containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (_ fastpathT) DecMapInt32StringV(v map[int32]string, canChange bool,
- d *Decoder) (_ map[int32]string, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 20)
- v = make(map[int32]string, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
+func (f fastpathT) DecMapUintInt64X(vp *map[uint]int64, d *Decoder) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ *vp = nil
+ } else {
+ if *vp == nil {
+ *vp = make(map[uint]int64, decInferLen(containerLen, d.h.MaxInitLen, 16))
+ }
+ if containerLen != 0 {
+ f.DecMapUintInt64L(*vp, containerLen, d)
+ }
+ d.mapEnd()
}
- d.depthIncr()
- var mk int32
- var mv string
+}
+func (fastpathT) DecMapUintInt64L(v map[uint]int64, containerLen int, d *Decoder) {
+ var mk uint
+ var mv int64
hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = int32(chkOvf.IntV(dd.DecodeInt64(), 32))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = ""
- }
- continue
- }
- mv = dd.DecodeString()
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
+ mk = uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize))
+ d.mapElemValue()
+ mv = d.d.DecodeInt64()
if v != nil {
v[mk] = mv
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
}
-
-func (d *Decoder) fastpathDecMapInt32UintR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int32]uint)
- v, changed := fastpathTV.DecMapInt32UintV(*vp, true, d)
- if changed {
- *vp = v
+func (d *Decoder) fastpathDecMapUintFloat32R(f *codecFnInfo, rv reflect.Value) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ if rv.Kind() == reflect.Ptr {
+ *(rv2i(rv).(*map[uint]float32)) = nil
}
} else {
- fastpathTV.DecMapInt32UintV(rv2i(rv).(map[int32]uint), false, d)
+ if rv.Kind() == reflect.Ptr {
+ vp, _ := rv2i(rv).(*map[uint]float32)
+ if *vp == nil {
+ *vp = make(map[uint]float32, decInferLen(containerLen, d.h.MaxInitLen, 12))
+ }
+ if containerLen != 0 {
+ fastpathTV.DecMapUintFloat32L(*vp, containerLen, d)
+ }
+ } else if containerLen != 0 {
+ fastpathTV.DecMapUintFloat32L(rv2i(rv).(map[uint]float32), containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (f fastpathT) DecMapInt32UintX(vp *map[int32]uint, d *Decoder) {
- v, changed := f.DecMapInt32UintV(*vp, true, d)
- if changed {
- *vp = v
+func (f fastpathT) DecMapUintFloat32X(vp *map[uint]float32, d *Decoder) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ *vp = nil
+ } else {
+ if *vp == nil {
+ *vp = make(map[uint]float32, decInferLen(containerLen, d.h.MaxInitLen, 12))
+ }
+ if containerLen != 0 {
+ f.DecMapUintFloat32L(*vp, containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (_ fastpathT) DecMapInt32UintV(v map[int32]uint, canChange bool,
- d *Decoder) (_ map[int32]uint, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
- v = make(map[int32]uint, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk int32
- var mv uint
+func (fastpathT) DecMapUintFloat32L(v map[uint]float32, containerLen int, d *Decoder) {
+ var mk uint
+ var mv float32
hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = int32(chkOvf.IntV(dd.DecodeInt64(), 32))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
+ mk = uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize))
+ d.mapElemValue()
+ mv = float32(d.decodeFloat32())
if v != nil {
v[mk] = mv
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
}
-
-func (d *Decoder) fastpathDecMapInt32Uint8R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int32]uint8)
- v, changed := fastpathTV.DecMapInt32Uint8V(*vp, true, d)
- if changed {
- *vp = v
+func (d *Decoder) fastpathDecMapUintFloat64R(f *codecFnInfo, rv reflect.Value) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ if rv.Kind() == reflect.Ptr {
+ *(rv2i(rv).(*map[uint]float64)) = nil
}
} else {
- fastpathTV.DecMapInt32Uint8V(rv2i(rv).(map[int32]uint8), false, d)
+ if rv.Kind() == reflect.Ptr {
+ vp, _ := rv2i(rv).(*map[uint]float64)
+ if *vp == nil {
+ *vp = make(map[uint]float64, decInferLen(containerLen, d.h.MaxInitLen, 16))
+ }
+ if containerLen != 0 {
+ fastpathTV.DecMapUintFloat64L(*vp, containerLen, d)
+ }
+ } else if containerLen != 0 {
+ fastpathTV.DecMapUintFloat64L(rv2i(rv).(map[uint]float64), containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (f fastpathT) DecMapInt32Uint8X(vp *map[int32]uint8, d *Decoder) {
- v, changed := f.DecMapInt32Uint8V(*vp, true, d)
- if changed {
- *vp = v
+func (f fastpathT) DecMapUintFloat64X(vp *map[uint]float64, d *Decoder) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ *vp = nil
+ } else {
+ if *vp == nil {
+ *vp = make(map[uint]float64, decInferLen(containerLen, d.h.MaxInitLen, 16))
+ }
+ if containerLen != 0 {
+ f.DecMapUintFloat64L(*vp, containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (_ fastpathT) DecMapInt32Uint8V(v map[int32]uint8, canChange bool,
- d *Decoder) (_ map[int32]uint8, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 5)
- v = make(map[int32]uint8, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk int32
- var mv uint8
+func (fastpathT) DecMapUintFloat64L(v map[uint]float64, containerLen int, d *Decoder) {
+ var mk uint
+ var mv float64
hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = int32(chkOvf.IntV(dd.DecodeInt64(), 32))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uint8(chkOvf.UintV(dd.DecodeUint64(), 8))
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
+ mk = uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize))
+ d.mapElemValue()
+ mv = d.d.DecodeFloat64()
if v != nil {
v[mk] = mv
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
}
-
-func (d *Decoder) fastpathDecMapInt32Uint16R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int32]uint16)
- v, changed := fastpathTV.DecMapInt32Uint16V(*vp, true, d)
- if changed {
- *vp = v
+func (d *Decoder) fastpathDecMapUintBoolR(f *codecFnInfo, rv reflect.Value) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ if rv.Kind() == reflect.Ptr {
+ *(rv2i(rv).(*map[uint]bool)) = nil
}
} else {
- fastpathTV.DecMapInt32Uint16V(rv2i(rv).(map[int32]uint16), false, d)
+ if rv.Kind() == reflect.Ptr {
+ vp, _ := rv2i(rv).(*map[uint]bool)
+ if *vp == nil {
+ *vp = make(map[uint]bool, decInferLen(containerLen, d.h.MaxInitLen, 9))
+ }
+ if containerLen != 0 {
+ fastpathTV.DecMapUintBoolL(*vp, containerLen, d)
+ }
+ } else if containerLen != 0 {
+ fastpathTV.DecMapUintBoolL(rv2i(rv).(map[uint]bool), containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (f fastpathT) DecMapInt32Uint16X(vp *map[int32]uint16, d *Decoder) {
- v, changed := f.DecMapInt32Uint16V(*vp, true, d)
- if changed {
- *vp = v
+func (f fastpathT) DecMapUintBoolX(vp *map[uint]bool, d *Decoder) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ *vp = nil
+ } else {
+ if *vp == nil {
+ *vp = make(map[uint]bool, decInferLen(containerLen, d.h.MaxInitLen, 9))
+ }
+ if containerLen != 0 {
+ f.DecMapUintBoolL(*vp, containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (_ fastpathT) DecMapInt32Uint16V(v map[int32]uint16, canChange bool,
- d *Decoder) (_ map[int32]uint16, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 6)
- v = make(map[int32]uint16, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk int32
- var mv uint16
+func (fastpathT) DecMapUintBoolL(v map[uint]bool, containerLen int, d *Decoder) {
+ var mk uint
+ var mv bool
hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = int32(chkOvf.IntV(dd.DecodeInt64(), 32))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uint16(chkOvf.UintV(dd.DecodeUint64(), 16))
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
+ mk = uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize))
+ d.mapElemValue()
+ mv = d.d.DecodeBool()
if v != nil {
v[mk] = mv
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
}
-
-func (d *Decoder) fastpathDecMapInt32Uint32R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int32]uint32)
- v, changed := fastpathTV.DecMapInt32Uint32V(*vp, true, d)
- if changed {
- *vp = v
+func (d *Decoder) fastpathDecMapUint8IntfR(f *codecFnInfo, rv reflect.Value) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ if rv.Kind() == reflect.Ptr {
+ *(rv2i(rv).(*map[uint8]interface{})) = nil
}
} else {
- fastpathTV.DecMapInt32Uint32V(rv2i(rv).(map[int32]uint32), false, d)
+ if rv.Kind() == reflect.Ptr {
+ vp, _ := rv2i(rv).(*map[uint8]interface{})
+ if *vp == nil {
+ *vp = make(map[uint8]interface{}, decInferLen(containerLen, d.h.MaxInitLen, 17))
+ }
+ if containerLen != 0 {
+ fastpathTV.DecMapUint8IntfL(*vp, containerLen, d)
+ }
+ } else if containerLen != 0 {
+ fastpathTV.DecMapUint8IntfL(rv2i(rv).(map[uint8]interface{}), containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (f fastpathT) DecMapInt32Uint32X(vp *map[int32]uint32, d *Decoder) {
- v, changed := f.DecMapInt32Uint32V(*vp, true, d)
- if changed {
- *vp = v
+func (f fastpathT) DecMapUint8IntfX(vp *map[uint8]interface{}, d *Decoder) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ *vp = nil
+ } else {
+ if *vp == nil {
+ *vp = make(map[uint8]interface{}, decInferLen(containerLen, d.h.MaxInitLen, 17))
+ }
+ if containerLen != 0 {
+ f.DecMapUint8IntfL(*vp, containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (_ fastpathT) DecMapInt32Uint32V(v map[int32]uint32, canChange bool,
- d *Decoder) (_ map[int32]uint32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 8)
- v = make(map[int32]uint32, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk int32
- var mv uint32
+func (fastpathT) DecMapUint8IntfL(v map[uint8]interface{}, containerLen int, d *Decoder) {
+ mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset
+ var mk uint8
+ var mv interface{}
hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = int32(chkOvf.IntV(dd.DecodeInt64(), 32))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
+ mk = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8))
+ d.mapElemValue()
+ if mapGet {
+ mv = v[mk]
+ } else {
+ mv = nil
}
- mv = uint32(chkOvf.UintV(dd.DecodeUint64(), 32))
+ d.decode(&mv)
if v != nil {
v[mk] = mv
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
}
-
-func (d *Decoder) fastpathDecMapInt32Uint64R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int32]uint64)
- v, changed := fastpathTV.DecMapInt32Uint64V(*vp, true, d)
- if changed {
- *vp = v
+func (d *Decoder) fastpathDecMapUint8StringR(f *codecFnInfo, rv reflect.Value) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ if rv.Kind() == reflect.Ptr {
+ *(rv2i(rv).(*map[uint8]string)) = nil
}
} else {
- fastpathTV.DecMapInt32Uint64V(rv2i(rv).(map[int32]uint64), false, d)
+ if rv.Kind() == reflect.Ptr {
+ vp, _ := rv2i(rv).(*map[uint8]string)
+ if *vp == nil {
+ *vp = make(map[uint8]string, decInferLen(containerLen, d.h.MaxInitLen, 17))
+ }
+ if containerLen != 0 {
+ fastpathTV.DecMapUint8StringL(*vp, containerLen, d)
+ }
+ } else if containerLen != 0 {
+ fastpathTV.DecMapUint8StringL(rv2i(rv).(map[uint8]string), containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (f fastpathT) DecMapInt32Uint64X(vp *map[int32]uint64, d *Decoder) {
- v, changed := f.DecMapInt32Uint64V(*vp, true, d)
- if changed {
- *vp = v
+func (f fastpathT) DecMapUint8StringX(vp *map[uint8]string, d *Decoder) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ *vp = nil
+ } else {
+ if *vp == nil {
+ *vp = make(map[uint8]string, decInferLen(containerLen, d.h.MaxInitLen, 17))
+ }
+ if containerLen != 0 {
+ f.DecMapUint8StringL(*vp, containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (_ fastpathT) DecMapInt32Uint64V(v map[int32]uint64, canChange bool,
- d *Decoder) (_ map[int32]uint64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
- v = make(map[int32]uint64, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk int32
- var mv uint64
+func (fastpathT) DecMapUint8StringL(v map[uint8]string, containerLen int, d *Decoder) {
+ var mk uint8
+ var mv string
hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = int32(chkOvf.IntV(dd.DecodeInt64(), 32))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = dd.DecodeUint64()
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
+ mk = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8))
+ d.mapElemValue()
+ mv = string(d.d.DecodeStringAsBytes())
if v != nil {
v[mk] = mv
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
}
-
-func (d *Decoder) fastpathDecMapInt32UintptrR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int32]uintptr)
- v, changed := fastpathTV.DecMapInt32UintptrV(*vp, true, d)
- if changed {
- *vp = v
+func (d *Decoder) fastpathDecMapUint8BytesR(f *codecFnInfo, rv reflect.Value) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ if rv.Kind() == reflect.Ptr {
+ *(rv2i(rv).(*map[uint8][]byte)) = nil
}
} else {
- fastpathTV.DecMapInt32UintptrV(rv2i(rv).(map[int32]uintptr), false, d)
+ if rv.Kind() == reflect.Ptr {
+ vp, _ := rv2i(rv).(*map[uint8][]byte)
+ if *vp == nil {
+ *vp = make(map[uint8][]byte, decInferLen(containerLen, d.h.MaxInitLen, 25))
+ }
+ if containerLen != 0 {
+ fastpathTV.DecMapUint8BytesL(*vp, containerLen, d)
+ }
+ } else if containerLen != 0 {
+ fastpathTV.DecMapUint8BytesL(rv2i(rv).(map[uint8][]byte), containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (f fastpathT) DecMapInt32UintptrX(vp *map[int32]uintptr, d *Decoder) {
- v, changed := f.DecMapInt32UintptrV(*vp, true, d)
- if changed {
- *vp = v
+func (f fastpathT) DecMapUint8BytesX(vp *map[uint8][]byte, d *Decoder) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ *vp = nil
+ } else {
+ if *vp == nil {
+ *vp = make(map[uint8][]byte, decInferLen(containerLen, d.h.MaxInitLen, 25))
+ }
+ if containerLen != 0 {
+ f.DecMapUint8BytesL(*vp, containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (_ fastpathT) DecMapInt32UintptrV(v map[int32]uintptr, canChange bool,
- d *Decoder) (_ map[int32]uintptr, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
- v = make(map[int32]uintptr, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk int32
- var mv uintptr
+func (fastpathT) DecMapUint8BytesL(v map[uint8][]byte, containerLen int, d *Decoder) {
+ mapGet := v != nil && !d.h.MapValueReset
+ var mk uint8
+ var mv []byte
hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = int32(chkOvf.IntV(dd.DecodeInt64(), 32))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
+ mk = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8))
+ d.mapElemValue()
+ if mapGet {
+ mv = v[mk]
+ } else {
+ mv = nil
}
- mv = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
+ mv = d.d.DecodeBytes(mv, false)
if v != nil {
v[mk] = mv
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
}
-
-func (d *Decoder) fastpathDecMapInt32IntR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int32]int)
- v, changed := fastpathTV.DecMapInt32IntV(*vp, true, d)
- if changed {
- *vp = v
+func (d *Decoder) fastpathDecMapUint8UintR(f *codecFnInfo, rv reflect.Value) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ if rv.Kind() == reflect.Ptr {
+ *(rv2i(rv).(*map[uint8]uint)) = nil
}
} else {
- fastpathTV.DecMapInt32IntV(rv2i(rv).(map[int32]int), false, d)
+ if rv.Kind() == reflect.Ptr {
+ vp, _ := rv2i(rv).(*map[uint8]uint)
+ if *vp == nil {
+ *vp = make(map[uint8]uint, decInferLen(containerLen, d.h.MaxInitLen, 9))
+ }
+ if containerLen != 0 {
+ fastpathTV.DecMapUint8UintL(*vp, containerLen, d)
+ }
+ } else if containerLen != 0 {
+ fastpathTV.DecMapUint8UintL(rv2i(rv).(map[uint8]uint), containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (f fastpathT) DecMapInt32IntX(vp *map[int32]int, d *Decoder) {
- v, changed := f.DecMapInt32IntV(*vp, true, d)
- if changed {
- *vp = v
+func (f fastpathT) DecMapUint8UintX(vp *map[uint8]uint, d *Decoder) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ *vp = nil
+ } else {
+ if *vp == nil {
+ *vp = make(map[uint8]uint, decInferLen(containerLen, d.h.MaxInitLen, 9))
+ }
+ if containerLen != 0 {
+ f.DecMapUint8UintL(*vp, containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (_ fastpathT) DecMapInt32IntV(v map[int32]int, canChange bool,
- d *Decoder) (_ map[int32]int, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
- v = make(map[int32]int, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk int32
- var mv int
+func (fastpathT) DecMapUint8UintL(v map[uint8]uint, containerLen int, d *Decoder) {
+ var mk uint8
+ var mv uint
hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = int32(chkOvf.IntV(dd.DecodeInt64(), 32))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize))
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
+ mk = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8))
+ d.mapElemValue()
+ mv = uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize))
if v != nil {
v[mk] = mv
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
}
-
-func (d *Decoder) fastpathDecMapInt32Int8R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int32]int8)
- v, changed := fastpathTV.DecMapInt32Int8V(*vp, true, d)
- if changed {
- *vp = v
+func (d *Decoder) fastpathDecMapUint8Uint8R(f *codecFnInfo, rv reflect.Value) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ if rv.Kind() == reflect.Ptr {
+ *(rv2i(rv).(*map[uint8]uint8)) = nil
}
} else {
- fastpathTV.DecMapInt32Int8V(rv2i(rv).(map[int32]int8), false, d)
+ if rv.Kind() == reflect.Ptr {
+ vp, _ := rv2i(rv).(*map[uint8]uint8)
+ if *vp == nil {
+ *vp = make(map[uint8]uint8, decInferLen(containerLen, d.h.MaxInitLen, 2))
+ }
+ if containerLen != 0 {
+ fastpathTV.DecMapUint8Uint8L(*vp, containerLen, d)
+ }
+ } else if containerLen != 0 {
+ fastpathTV.DecMapUint8Uint8L(rv2i(rv).(map[uint8]uint8), containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (f fastpathT) DecMapInt32Int8X(vp *map[int32]int8, d *Decoder) {
- v, changed := f.DecMapInt32Int8V(*vp, true, d)
- if changed {
- *vp = v
+func (f fastpathT) DecMapUint8Uint8X(vp *map[uint8]uint8, d *Decoder) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ *vp = nil
+ } else {
+ if *vp == nil {
+ *vp = make(map[uint8]uint8, decInferLen(containerLen, d.h.MaxInitLen, 2))
+ }
+ if containerLen != 0 {
+ f.DecMapUint8Uint8L(*vp, containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (_ fastpathT) DecMapInt32Int8V(v map[int32]int8, canChange bool,
- d *Decoder) (_ map[int32]int8, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 5)
- v = make(map[int32]int8, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk int32
- var mv int8
+func (fastpathT) DecMapUint8Uint8L(v map[uint8]uint8, containerLen int, d *Decoder) {
+ var mk uint8
+ var mv uint8
hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = int32(chkOvf.IntV(dd.DecodeInt64(), 32))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = int8(chkOvf.IntV(dd.DecodeInt64(), 8))
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
+ mk = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8))
+ d.mapElemValue()
+ mv = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8))
if v != nil {
v[mk] = mv
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
}
-
-func (d *Decoder) fastpathDecMapInt32Int16R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int32]int16)
- v, changed := fastpathTV.DecMapInt32Int16V(*vp, true, d)
- if changed {
- *vp = v
+func (d *Decoder) fastpathDecMapUint8Uint64R(f *codecFnInfo, rv reflect.Value) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ if rv.Kind() == reflect.Ptr {
+ *(rv2i(rv).(*map[uint8]uint64)) = nil
}
} else {
- fastpathTV.DecMapInt32Int16V(rv2i(rv).(map[int32]int16), false, d)
+ if rv.Kind() == reflect.Ptr {
+ vp, _ := rv2i(rv).(*map[uint8]uint64)
+ if *vp == nil {
+ *vp = make(map[uint8]uint64, decInferLen(containerLen, d.h.MaxInitLen, 9))
+ }
+ if containerLen != 0 {
+ fastpathTV.DecMapUint8Uint64L(*vp, containerLen, d)
+ }
+ } else if containerLen != 0 {
+ fastpathTV.DecMapUint8Uint64L(rv2i(rv).(map[uint8]uint64), containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (f fastpathT) DecMapInt32Int16X(vp *map[int32]int16, d *Decoder) {
- v, changed := f.DecMapInt32Int16V(*vp, true, d)
- if changed {
- *vp = v
+func (f fastpathT) DecMapUint8Uint64X(vp *map[uint8]uint64, d *Decoder) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ *vp = nil
+ } else {
+ if *vp == nil {
+ *vp = make(map[uint8]uint64, decInferLen(containerLen, d.h.MaxInitLen, 9))
+ }
+ if containerLen != 0 {
+ f.DecMapUint8Uint64L(*vp, containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (_ fastpathT) DecMapInt32Int16V(v map[int32]int16, canChange bool,
- d *Decoder) (_ map[int32]int16, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 6)
- v = make(map[int32]int16, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk int32
- var mv int16
+func (fastpathT) DecMapUint8Uint64L(v map[uint8]uint64, containerLen int, d *Decoder) {
+ var mk uint8
+ var mv uint64
hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = int32(chkOvf.IntV(dd.DecodeInt64(), 32))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = int16(chkOvf.IntV(dd.DecodeInt64(), 16))
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
+ mk = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8))
+ d.mapElemValue()
+ mv = d.d.DecodeUint64()
if v != nil {
v[mk] = mv
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
}
-
-func (d *Decoder) fastpathDecMapInt32Int32R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int32]int32)
- v, changed := fastpathTV.DecMapInt32Int32V(*vp, true, d)
- if changed {
- *vp = v
+func (d *Decoder) fastpathDecMapUint8IntR(f *codecFnInfo, rv reflect.Value) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ if rv.Kind() == reflect.Ptr {
+ *(rv2i(rv).(*map[uint8]int)) = nil
}
} else {
- fastpathTV.DecMapInt32Int32V(rv2i(rv).(map[int32]int32), false, d)
+ if rv.Kind() == reflect.Ptr {
+ vp, _ := rv2i(rv).(*map[uint8]int)
+ if *vp == nil {
+ *vp = make(map[uint8]int, decInferLen(containerLen, d.h.MaxInitLen, 9))
+ }
+ if containerLen != 0 {
+ fastpathTV.DecMapUint8IntL(*vp, containerLen, d)
+ }
+ } else if containerLen != 0 {
+ fastpathTV.DecMapUint8IntL(rv2i(rv).(map[uint8]int), containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (f fastpathT) DecMapInt32Int32X(vp *map[int32]int32, d *Decoder) {
- v, changed := f.DecMapInt32Int32V(*vp, true, d)
- if changed {
- *vp = v
+func (f fastpathT) DecMapUint8IntX(vp *map[uint8]int, d *Decoder) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ *vp = nil
+ } else {
+ if *vp == nil {
+ *vp = make(map[uint8]int, decInferLen(containerLen, d.h.MaxInitLen, 9))
+ }
+ if containerLen != 0 {
+ f.DecMapUint8IntL(*vp, containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (_ fastpathT) DecMapInt32Int32V(v map[int32]int32, canChange bool,
- d *Decoder) (_ map[int32]int32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 8)
- v = make(map[int32]int32, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk int32
- var mv int32
+func (fastpathT) DecMapUint8IntL(v map[uint8]int, containerLen int, d *Decoder) {
+ var mk uint8
+ var mv int
hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = int32(chkOvf.IntV(dd.DecodeInt64(), 32))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = int32(chkOvf.IntV(dd.DecodeInt64(), 32))
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
+ mk = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8))
+ d.mapElemValue()
+ mv = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize))
if v != nil {
v[mk] = mv
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
}
-
-func (d *Decoder) fastpathDecMapInt32Int64R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int32]int64)
- v, changed := fastpathTV.DecMapInt32Int64V(*vp, true, d)
- if changed {
- *vp = v
+func (d *Decoder) fastpathDecMapUint8Int64R(f *codecFnInfo, rv reflect.Value) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ if rv.Kind() == reflect.Ptr {
+ *(rv2i(rv).(*map[uint8]int64)) = nil
}
} else {
- fastpathTV.DecMapInt32Int64V(rv2i(rv).(map[int32]int64), false, d)
+ if rv.Kind() == reflect.Ptr {
+ vp, _ := rv2i(rv).(*map[uint8]int64)
+ if *vp == nil {
+ *vp = make(map[uint8]int64, decInferLen(containerLen, d.h.MaxInitLen, 9))
+ }
+ if containerLen != 0 {
+ fastpathTV.DecMapUint8Int64L(*vp, containerLen, d)
+ }
+ } else if containerLen != 0 {
+ fastpathTV.DecMapUint8Int64L(rv2i(rv).(map[uint8]int64), containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (f fastpathT) DecMapInt32Int64X(vp *map[int32]int64, d *Decoder) {
- v, changed := f.DecMapInt32Int64V(*vp, true, d)
- if changed {
- *vp = v
+func (f fastpathT) DecMapUint8Int64X(vp *map[uint8]int64, d *Decoder) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ *vp = nil
+ } else {
+ if *vp == nil {
+ *vp = make(map[uint8]int64, decInferLen(containerLen, d.h.MaxInitLen, 9))
+ }
+ if containerLen != 0 {
+ f.DecMapUint8Int64L(*vp, containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (_ fastpathT) DecMapInt32Int64V(v map[int32]int64, canChange bool,
- d *Decoder) (_ map[int32]int64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
- v = make(map[int32]int64, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk int32
+func (fastpathT) DecMapUint8Int64L(v map[uint8]int64, containerLen int, d *Decoder) {
+ var mk uint8
var mv int64
hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = int32(chkOvf.IntV(dd.DecodeInt64(), 32))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = dd.DecodeInt64()
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
+ mk = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8))
+ d.mapElemValue()
+ mv = d.d.DecodeInt64()
if v != nil {
v[mk] = mv
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
}
-
-func (d *Decoder) fastpathDecMapInt32Float32R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int32]float32)
- v, changed := fastpathTV.DecMapInt32Float32V(*vp, true, d)
- if changed {
- *vp = v
+func (d *Decoder) fastpathDecMapUint8Float32R(f *codecFnInfo, rv reflect.Value) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ if rv.Kind() == reflect.Ptr {
+ *(rv2i(rv).(*map[uint8]float32)) = nil
}
} else {
- fastpathTV.DecMapInt32Float32V(rv2i(rv).(map[int32]float32), false, d)
- }
-}
-func (f fastpathT) DecMapInt32Float32X(vp *map[int32]float32, d *Decoder) {
- v, changed := f.DecMapInt32Float32V(*vp, true, d)
- if changed {
- *vp = v
+ if rv.Kind() == reflect.Ptr {
+ vp, _ := rv2i(rv).(*map[uint8]float32)
+ if *vp == nil {
+ *vp = make(map[uint8]float32, decInferLen(containerLen, d.h.MaxInitLen, 5))
+ }
+ if containerLen != 0 {
+ fastpathTV.DecMapUint8Float32L(*vp, containerLen, d)
+ }
+ } else if containerLen != 0 {
+ fastpathTV.DecMapUint8Float32L(rv2i(rv).(map[uint8]float32), containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (_ fastpathT) DecMapInt32Float32V(v map[int32]float32, canChange bool,
- d *Decoder) (_ map[int32]float32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 8)
- v = make(map[int32]float32, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
+func (f fastpathT) DecMapUint8Float32X(vp *map[uint8]float32, d *Decoder) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ *vp = nil
+ } else {
+ if *vp == nil {
+ *vp = make(map[uint8]float32, decInferLen(containerLen, d.h.MaxInitLen, 5))
+ }
+ if containerLen != 0 {
+ f.DecMapUint8Float32L(*vp, containerLen, d)
+ }
+ d.mapEnd()
}
- d.depthIncr()
- var mk int32
+}
+func (fastpathT) DecMapUint8Float32L(v map[uint8]float32, containerLen int, d *Decoder) {
+ var mk uint8
var mv float32
hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = int32(chkOvf.IntV(dd.DecodeInt64(), 32))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = float32(chkOvf.Float32V(dd.DecodeFloat64()))
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
+ mk = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8))
+ d.mapElemValue()
+ mv = float32(d.decodeFloat32())
if v != nil {
v[mk] = mv
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
}
-
-func (d *Decoder) fastpathDecMapInt32Float64R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int32]float64)
- v, changed := fastpathTV.DecMapInt32Float64V(*vp, true, d)
- if changed {
- *vp = v
+func (d *Decoder) fastpathDecMapUint8Float64R(f *codecFnInfo, rv reflect.Value) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ if rv.Kind() == reflect.Ptr {
+ *(rv2i(rv).(*map[uint8]float64)) = nil
}
} else {
- fastpathTV.DecMapInt32Float64V(rv2i(rv).(map[int32]float64), false, d)
+ if rv.Kind() == reflect.Ptr {
+ vp, _ := rv2i(rv).(*map[uint8]float64)
+ if *vp == nil {
+ *vp = make(map[uint8]float64, decInferLen(containerLen, d.h.MaxInitLen, 9))
+ }
+ if containerLen != 0 {
+ fastpathTV.DecMapUint8Float64L(*vp, containerLen, d)
+ }
+ } else if containerLen != 0 {
+ fastpathTV.DecMapUint8Float64L(rv2i(rv).(map[uint8]float64), containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (f fastpathT) DecMapInt32Float64X(vp *map[int32]float64, d *Decoder) {
- v, changed := f.DecMapInt32Float64V(*vp, true, d)
- if changed {
- *vp = v
+func (f fastpathT) DecMapUint8Float64X(vp *map[uint8]float64, d *Decoder) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ *vp = nil
+ } else {
+ if *vp == nil {
+ *vp = make(map[uint8]float64, decInferLen(containerLen, d.h.MaxInitLen, 9))
+ }
+ if containerLen != 0 {
+ f.DecMapUint8Float64L(*vp, containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (_ fastpathT) DecMapInt32Float64V(v map[int32]float64, canChange bool,
- d *Decoder) (_ map[int32]float64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
- v = make(map[int32]float64, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk int32
+func (fastpathT) DecMapUint8Float64L(v map[uint8]float64, containerLen int, d *Decoder) {
+ var mk uint8
var mv float64
hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = int32(chkOvf.IntV(dd.DecodeInt64(), 32))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = dd.DecodeFloat64()
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
+ mk = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8))
+ d.mapElemValue()
+ mv = d.d.DecodeFloat64()
if v != nil {
v[mk] = mv
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
}
-
-func (d *Decoder) fastpathDecMapInt32BoolR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int32]bool)
- v, changed := fastpathTV.DecMapInt32BoolV(*vp, true, d)
- if changed {
- *vp = v
+func (d *Decoder) fastpathDecMapUint8BoolR(f *codecFnInfo, rv reflect.Value) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ if rv.Kind() == reflect.Ptr {
+ *(rv2i(rv).(*map[uint8]bool)) = nil
}
} else {
- fastpathTV.DecMapInt32BoolV(rv2i(rv).(map[int32]bool), false, d)
+ if rv.Kind() == reflect.Ptr {
+ vp, _ := rv2i(rv).(*map[uint8]bool)
+ if *vp == nil {
+ *vp = make(map[uint8]bool, decInferLen(containerLen, d.h.MaxInitLen, 2))
+ }
+ if containerLen != 0 {
+ fastpathTV.DecMapUint8BoolL(*vp, containerLen, d)
+ }
+ } else if containerLen != 0 {
+ fastpathTV.DecMapUint8BoolL(rv2i(rv).(map[uint8]bool), containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (f fastpathT) DecMapInt32BoolX(vp *map[int32]bool, d *Decoder) {
- v, changed := f.DecMapInt32BoolV(*vp, true, d)
- if changed {
- *vp = v
+func (f fastpathT) DecMapUint8BoolX(vp *map[uint8]bool, d *Decoder) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ *vp = nil
+ } else {
+ if *vp == nil {
+ *vp = make(map[uint8]bool, decInferLen(containerLen, d.h.MaxInitLen, 2))
+ }
+ if containerLen != 0 {
+ f.DecMapUint8BoolL(*vp, containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (_ fastpathT) DecMapInt32BoolV(v map[int32]bool, canChange bool,
- d *Decoder) (_ map[int32]bool, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 5)
- v = make(map[int32]bool, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk int32
+func (fastpathT) DecMapUint8BoolL(v map[uint8]bool, containerLen int, d *Decoder) {
+ var mk uint8
var mv bool
hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = int32(chkOvf.IntV(dd.DecodeInt64(), 32))
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = false
- }
- continue
- }
- mv = dd.DecodeBool()
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
+ mk = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8))
+ d.mapElemValue()
+ mv = d.d.DecodeBool()
if v != nil {
v[mk] = mv
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
}
-
-func (d *Decoder) fastpathDecMapInt64IntfR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int64]interface{})
- v, changed := fastpathTV.DecMapInt64IntfV(*vp, true, d)
- if changed {
- *vp = v
+func (d *Decoder) fastpathDecMapUint64IntfR(f *codecFnInfo, rv reflect.Value) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ if rv.Kind() == reflect.Ptr {
+ *(rv2i(rv).(*map[uint64]interface{})) = nil
}
} else {
- fastpathTV.DecMapInt64IntfV(rv2i(rv).(map[int64]interface{}), false, d)
+ if rv.Kind() == reflect.Ptr {
+ vp, _ := rv2i(rv).(*map[uint64]interface{})
+ if *vp == nil {
+ *vp = make(map[uint64]interface{}, decInferLen(containerLen, d.h.MaxInitLen, 24))
+ }
+ if containerLen != 0 {
+ fastpathTV.DecMapUint64IntfL(*vp, containerLen, d)
+ }
+ } else if containerLen != 0 {
+ fastpathTV.DecMapUint64IntfL(rv2i(rv).(map[uint64]interface{}), containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (f fastpathT) DecMapInt64IntfX(vp *map[int64]interface{}, d *Decoder) {
- v, changed := f.DecMapInt64IntfV(*vp, true, d)
- if changed {
- *vp = v
+func (f fastpathT) DecMapUint64IntfX(vp *map[uint64]interface{}, d *Decoder) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ *vp = nil
+ } else {
+ if *vp == nil {
+ *vp = make(map[uint64]interface{}, decInferLen(containerLen, d.h.MaxInitLen, 24))
+ }
+ if containerLen != 0 {
+ f.DecMapUint64IntfL(*vp, containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (_ fastpathT) DecMapInt64IntfV(v map[int64]interface{}, canChange bool,
- d *Decoder) (_ map[int64]interface{}, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 24)
- v = make(map[int64]interface{}, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
+func (fastpathT) DecMapUint64IntfL(v map[uint64]interface{}, containerLen int, d *Decoder) {
mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset
- var mk int64
+ var mk uint64
var mv interface{}
hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeInt64()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = nil
- }
- continue
- }
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
+ mk = d.d.DecodeUint64()
+ d.mapElemValue()
if mapGet {
mv = v[mk]
} else {
@@ -33169,1904 +7349,1602 @@ func (_ fastpathT) DecMapInt64IntfV(v map[int64]interface{}, canChange bool,
v[mk] = mv
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
}
-
-func (d *Decoder) fastpathDecMapInt64StringR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int64]string)
- v, changed := fastpathTV.DecMapInt64StringV(*vp, true, d)
- if changed {
- *vp = v
+func (d *Decoder) fastpathDecMapUint64StringR(f *codecFnInfo, rv reflect.Value) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ if rv.Kind() == reflect.Ptr {
+ *(rv2i(rv).(*map[uint64]string)) = nil
}
} else {
- fastpathTV.DecMapInt64StringV(rv2i(rv).(map[int64]string), false, d)
+ if rv.Kind() == reflect.Ptr {
+ vp, _ := rv2i(rv).(*map[uint64]string)
+ if *vp == nil {
+ *vp = make(map[uint64]string, decInferLen(containerLen, d.h.MaxInitLen, 24))
+ }
+ if containerLen != 0 {
+ fastpathTV.DecMapUint64StringL(*vp, containerLen, d)
+ }
+ } else if containerLen != 0 {
+ fastpathTV.DecMapUint64StringL(rv2i(rv).(map[uint64]string), containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (f fastpathT) DecMapInt64StringX(vp *map[int64]string, d *Decoder) {
- v, changed := f.DecMapInt64StringV(*vp, true, d)
- if changed {
- *vp = v
+func (f fastpathT) DecMapUint64StringX(vp *map[uint64]string, d *Decoder) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ *vp = nil
+ } else {
+ if *vp == nil {
+ *vp = make(map[uint64]string, decInferLen(containerLen, d.h.MaxInitLen, 24))
+ }
+ if containerLen != 0 {
+ f.DecMapUint64StringL(*vp, containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (_ fastpathT) DecMapInt64StringV(v map[int64]string, canChange bool,
- d *Decoder) (_ map[int64]string, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 24)
- v = make(map[int64]string, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk int64
+func (fastpathT) DecMapUint64StringL(v map[uint64]string, containerLen int, d *Decoder) {
+ var mk uint64
var mv string
hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeInt64()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = ""
- }
- continue
- }
- mv = dd.DecodeString()
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
+ mk = d.d.DecodeUint64()
+ d.mapElemValue()
+ mv = string(d.d.DecodeStringAsBytes())
if v != nil {
v[mk] = mv
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
}
-
-func (d *Decoder) fastpathDecMapInt64UintR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int64]uint)
- v, changed := fastpathTV.DecMapInt64UintV(*vp, true, d)
- if changed {
- *vp = v
+func (d *Decoder) fastpathDecMapUint64BytesR(f *codecFnInfo, rv reflect.Value) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ if rv.Kind() == reflect.Ptr {
+ *(rv2i(rv).(*map[uint64][]byte)) = nil
}
} else {
- fastpathTV.DecMapInt64UintV(rv2i(rv).(map[int64]uint), false, d)
+ if rv.Kind() == reflect.Ptr {
+ vp, _ := rv2i(rv).(*map[uint64][]byte)
+ if *vp == nil {
+ *vp = make(map[uint64][]byte, decInferLen(containerLen, d.h.MaxInitLen, 32))
+ }
+ if containerLen != 0 {
+ fastpathTV.DecMapUint64BytesL(*vp, containerLen, d)
+ }
+ } else if containerLen != 0 {
+ fastpathTV.DecMapUint64BytesL(rv2i(rv).(map[uint64][]byte), containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (f fastpathT) DecMapInt64UintX(vp *map[int64]uint, d *Decoder) {
- v, changed := f.DecMapInt64UintV(*vp, true, d)
- if changed {
- *vp = v
+func (f fastpathT) DecMapUint64BytesX(vp *map[uint64][]byte, d *Decoder) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ *vp = nil
+ } else {
+ if *vp == nil {
+ *vp = make(map[uint64][]byte, decInferLen(containerLen, d.h.MaxInitLen, 32))
+ }
+ if containerLen != 0 {
+ f.DecMapUint64BytesL(*vp, containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (_ fastpathT) DecMapInt64UintV(v map[int64]uint, canChange bool,
- d *Decoder) (_ map[int64]uint, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
- v = make(map[int64]uint, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk int64
- var mv uint
+func (fastpathT) DecMapUint64BytesL(v map[uint64][]byte, containerLen int, d *Decoder) {
+ mapGet := v != nil && !d.h.MapValueReset
+ var mk uint64
+ var mv []byte
hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeInt64()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
+ mk = d.d.DecodeUint64()
+ d.mapElemValue()
+ if mapGet {
+ mv = v[mk]
+ } else {
+ mv = nil
}
- mv = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
+ mv = d.d.DecodeBytes(mv, false)
if v != nil {
v[mk] = mv
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
}
-
-func (d *Decoder) fastpathDecMapInt64Uint8R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int64]uint8)
- v, changed := fastpathTV.DecMapInt64Uint8V(*vp, true, d)
- if changed {
- *vp = v
+func (d *Decoder) fastpathDecMapUint64UintR(f *codecFnInfo, rv reflect.Value) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ if rv.Kind() == reflect.Ptr {
+ *(rv2i(rv).(*map[uint64]uint)) = nil
}
} else {
- fastpathTV.DecMapInt64Uint8V(rv2i(rv).(map[int64]uint8), false, d)
+ if rv.Kind() == reflect.Ptr {
+ vp, _ := rv2i(rv).(*map[uint64]uint)
+ if *vp == nil {
+ *vp = make(map[uint64]uint, decInferLen(containerLen, d.h.MaxInitLen, 16))
+ }
+ if containerLen != 0 {
+ fastpathTV.DecMapUint64UintL(*vp, containerLen, d)
+ }
+ } else if containerLen != 0 {
+ fastpathTV.DecMapUint64UintL(rv2i(rv).(map[uint64]uint), containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (f fastpathT) DecMapInt64Uint8X(vp *map[int64]uint8, d *Decoder) {
- v, changed := f.DecMapInt64Uint8V(*vp, true, d)
- if changed {
- *vp = v
+func (f fastpathT) DecMapUint64UintX(vp *map[uint64]uint, d *Decoder) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ *vp = nil
+ } else {
+ if *vp == nil {
+ *vp = make(map[uint64]uint, decInferLen(containerLen, d.h.MaxInitLen, 16))
+ }
+ if containerLen != 0 {
+ f.DecMapUint64UintL(*vp, containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (_ fastpathT) DecMapInt64Uint8V(v map[int64]uint8, canChange bool,
- d *Decoder) (_ map[int64]uint8, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
- v = make(map[int64]uint8, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk int64
- var mv uint8
+func (fastpathT) DecMapUint64UintL(v map[uint64]uint, containerLen int, d *Decoder) {
+ var mk uint64
+ var mv uint
hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeInt64()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uint8(chkOvf.UintV(dd.DecodeUint64(), 8))
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
+ mk = d.d.DecodeUint64()
+ d.mapElemValue()
+ mv = uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize))
if v != nil {
v[mk] = mv
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
}
-
-func (d *Decoder) fastpathDecMapInt64Uint16R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int64]uint16)
- v, changed := fastpathTV.DecMapInt64Uint16V(*vp, true, d)
- if changed {
- *vp = v
+func (d *Decoder) fastpathDecMapUint64Uint8R(f *codecFnInfo, rv reflect.Value) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ if rv.Kind() == reflect.Ptr {
+ *(rv2i(rv).(*map[uint64]uint8)) = nil
}
} else {
- fastpathTV.DecMapInt64Uint16V(rv2i(rv).(map[int64]uint16), false, d)
+ if rv.Kind() == reflect.Ptr {
+ vp, _ := rv2i(rv).(*map[uint64]uint8)
+ if *vp == nil {
+ *vp = make(map[uint64]uint8, decInferLen(containerLen, d.h.MaxInitLen, 9))
+ }
+ if containerLen != 0 {
+ fastpathTV.DecMapUint64Uint8L(*vp, containerLen, d)
+ }
+ } else if containerLen != 0 {
+ fastpathTV.DecMapUint64Uint8L(rv2i(rv).(map[uint64]uint8), containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (f fastpathT) DecMapInt64Uint16X(vp *map[int64]uint16, d *Decoder) {
- v, changed := f.DecMapInt64Uint16V(*vp, true, d)
- if changed {
- *vp = v
+func (f fastpathT) DecMapUint64Uint8X(vp *map[uint64]uint8, d *Decoder) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ *vp = nil
+ } else {
+ if *vp == nil {
+ *vp = make(map[uint64]uint8, decInferLen(containerLen, d.h.MaxInitLen, 9))
+ }
+ if containerLen != 0 {
+ f.DecMapUint64Uint8L(*vp, containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (_ fastpathT) DecMapInt64Uint16V(v map[int64]uint16, canChange bool,
- d *Decoder) (_ map[int64]uint16, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 10)
- v = make(map[int64]uint16, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk int64
- var mv uint16
+func (fastpathT) DecMapUint64Uint8L(v map[uint64]uint8, containerLen int, d *Decoder) {
+ var mk uint64
+ var mv uint8
hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeInt64()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uint16(chkOvf.UintV(dd.DecodeUint64(), 16))
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
+ mk = d.d.DecodeUint64()
+ d.mapElemValue()
+ mv = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8))
if v != nil {
v[mk] = mv
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
}
-
-func (d *Decoder) fastpathDecMapInt64Uint32R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int64]uint32)
- v, changed := fastpathTV.DecMapInt64Uint32V(*vp, true, d)
- if changed {
- *vp = v
+func (d *Decoder) fastpathDecMapUint64Uint64R(f *codecFnInfo, rv reflect.Value) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ if rv.Kind() == reflect.Ptr {
+ *(rv2i(rv).(*map[uint64]uint64)) = nil
}
} else {
- fastpathTV.DecMapInt64Uint32V(rv2i(rv).(map[int64]uint32), false, d)
+ if rv.Kind() == reflect.Ptr {
+ vp, _ := rv2i(rv).(*map[uint64]uint64)
+ if *vp == nil {
+ *vp = make(map[uint64]uint64, decInferLen(containerLen, d.h.MaxInitLen, 16))
+ }
+ if containerLen != 0 {
+ fastpathTV.DecMapUint64Uint64L(*vp, containerLen, d)
+ }
+ } else if containerLen != 0 {
+ fastpathTV.DecMapUint64Uint64L(rv2i(rv).(map[uint64]uint64), containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (f fastpathT) DecMapInt64Uint32X(vp *map[int64]uint32, d *Decoder) {
- v, changed := f.DecMapInt64Uint32V(*vp, true, d)
- if changed {
- *vp = v
+func (f fastpathT) DecMapUint64Uint64X(vp *map[uint64]uint64, d *Decoder) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ *vp = nil
+ } else {
+ if *vp == nil {
+ *vp = make(map[uint64]uint64, decInferLen(containerLen, d.h.MaxInitLen, 16))
+ }
+ if containerLen != 0 {
+ f.DecMapUint64Uint64L(*vp, containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (_ fastpathT) DecMapInt64Uint32V(v map[int64]uint32, canChange bool,
- d *Decoder) (_ map[int64]uint32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
- v = make(map[int64]uint32, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk int64
- var mv uint32
+func (fastpathT) DecMapUint64Uint64L(v map[uint64]uint64, containerLen int, d *Decoder) {
+ var mk uint64
+ var mv uint64
hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeInt64()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uint32(chkOvf.UintV(dd.DecodeUint64(), 32))
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
+ mk = d.d.DecodeUint64()
+ d.mapElemValue()
+ mv = d.d.DecodeUint64()
if v != nil {
v[mk] = mv
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
}
-
-func (d *Decoder) fastpathDecMapInt64Uint64R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int64]uint64)
- v, changed := fastpathTV.DecMapInt64Uint64V(*vp, true, d)
- if changed {
- *vp = v
+func (d *Decoder) fastpathDecMapUint64IntR(f *codecFnInfo, rv reflect.Value) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ if rv.Kind() == reflect.Ptr {
+ *(rv2i(rv).(*map[uint64]int)) = nil
}
} else {
- fastpathTV.DecMapInt64Uint64V(rv2i(rv).(map[int64]uint64), false, d)
+ if rv.Kind() == reflect.Ptr {
+ vp, _ := rv2i(rv).(*map[uint64]int)
+ if *vp == nil {
+ *vp = make(map[uint64]int, decInferLen(containerLen, d.h.MaxInitLen, 16))
+ }
+ if containerLen != 0 {
+ fastpathTV.DecMapUint64IntL(*vp, containerLen, d)
+ }
+ } else if containerLen != 0 {
+ fastpathTV.DecMapUint64IntL(rv2i(rv).(map[uint64]int), containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (f fastpathT) DecMapInt64Uint64X(vp *map[int64]uint64, d *Decoder) {
- v, changed := f.DecMapInt64Uint64V(*vp, true, d)
- if changed {
- *vp = v
+func (f fastpathT) DecMapUint64IntX(vp *map[uint64]int, d *Decoder) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ *vp = nil
+ } else {
+ if *vp == nil {
+ *vp = make(map[uint64]int, decInferLen(containerLen, d.h.MaxInitLen, 16))
+ }
+ if containerLen != 0 {
+ f.DecMapUint64IntL(*vp, containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (_ fastpathT) DecMapInt64Uint64V(v map[int64]uint64, canChange bool,
- d *Decoder) (_ map[int64]uint64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
- v = make(map[int64]uint64, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk int64
- var mv uint64
+func (fastpathT) DecMapUint64IntL(v map[uint64]int, containerLen int, d *Decoder) {
+ var mk uint64
+ var mv int
hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeInt64()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = dd.DecodeUint64()
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
+ mk = d.d.DecodeUint64()
+ d.mapElemValue()
+ mv = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize))
if v != nil {
v[mk] = mv
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
}
-
-func (d *Decoder) fastpathDecMapInt64UintptrR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int64]uintptr)
- v, changed := fastpathTV.DecMapInt64UintptrV(*vp, true, d)
- if changed {
- *vp = v
+func (d *Decoder) fastpathDecMapUint64Int64R(f *codecFnInfo, rv reflect.Value) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ if rv.Kind() == reflect.Ptr {
+ *(rv2i(rv).(*map[uint64]int64)) = nil
}
} else {
- fastpathTV.DecMapInt64UintptrV(rv2i(rv).(map[int64]uintptr), false, d)
+ if rv.Kind() == reflect.Ptr {
+ vp, _ := rv2i(rv).(*map[uint64]int64)
+ if *vp == nil {
+ *vp = make(map[uint64]int64, decInferLen(containerLen, d.h.MaxInitLen, 16))
+ }
+ if containerLen != 0 {
+ fastpathTV.DecMapUint64Int64L(*vp, containerLen, d)
+ }
+ } else if containerLen != 0 {
+ fastpathTV.DecMapUint64Int64L(rv2i(rv).(map[uint64]int64), containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (f fastpathT) DecMapInt64UintptrX(vp *map[int64]uintptr, d *Decoder) {
- v, changed := f.DecMapInt64UintptrV(*vp, true, d)
- if changed {
- *vp = v
+func (f fastpathT) DecMapUint64Int64X(vp *map[uint64]int64, d *Decoder) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ *vp = nil
+ } else {
+ if *vp == nil {
+ *vp = make(map[uint64]int64, decInferLen(containerLen, d.h.MaxInitLen, 16))
+ }
+ if containerLen != 0 {
+ f.DecMapUint64Int64L(*vp, containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (_ fastpathT) DecMapInt64UintptrV(v map[int64]uintptr, canChange bool,
- d *Decoder) (_ map[int64]uintptr, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
- v = make(map[int64]uintptr, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk int64
- var mv uintptr
+func (fastpathT) DecMapUint64Int64L(v map[uint64]int64, containerLen int, d *Decoder) {
+ var mk uint64
+ var mv int64
hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeInt64()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
+ mk = d.d.DecodeUint64()
+ d.mapElemValue()
+ mv = d.d.DecodeInt64()
if v != nil {
v[mk] = mv
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
}
-
-func (d *Decoder) fastpathDecMapInt64IntR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int64]int)
- v, changed := fastpathTV.DecMapInt64IntV(*vp, true, d)
- if changed {
- *vp = v
+func (d *Decoder) fastpathDecMapUint64Float32R(f *codecFnInfo, rv reflect.Value) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ if rv.Kind() == reflect.Ptr {
+ *(rv2i(rv).(*map[uint64]float32)) = nil
}
} else {
- fastpathTV.DecMapInt64IntV(rv2i(rv).(map[int64]int), false, d)
+ if rv.Kind() == reflect.Ptr {
+ vp, _ := rv2i(rv).(*map[uint64]float32)
+ if *vp == nil {
+ *vp = make(map[uint64]float32, decInferLen(containerLen, d.h.MaxInitLen, 12))
+ }
+ if containerLen != 0 {
+ fastpathTV.DecMapUint64Float32L(*vp, containerLen, d)
+ }
+ } else if containerLen != 0 {
+ fastpathTV.DecMapUint64Float32L(rv2i(rv).(map[uint64]float32), containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (f fastpathT) DecMapInt64IntX(vp *map[int64]int, d *Decoder) {
- v, changed := f.DecMapInt64IntV(*vp, true, d)
- if changed {
- *vp = v
+func (f fastpathT) DecMapUint64Float32X(vp *map[uint64]float32, d *Decoder) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ *vp = nil
+ } else {
+ if *vp == nil {
+ *vp = make(map[uint64]float32, decInferLen(containerLen, d.h.MaxInitLen, 12))
+ }
+ if containerLen != 0 {
+ f.DecMapUint64Float32L(*vp, containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (_ fastpathT) DecMapInt64IntV(v map[int64]int, canChange bool,
- d *Decoder) (_ map[int64]int, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
- v = make(map[int64]int, xlen)
- changed = true
+func (fastpathT) DecMapUint64Float32L(v map[uint64]float32, containerLen int, d *Decoder) {
+ var mk uint64
+ var mv float32
+ hasLen := containerLen > 0
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
+ mk = d.d.DecodeUint64()
+ d.mapElemValue()
+ mv = float32(d.decodeFloat32())
+ if v != nil {
+ v[mk] = mv
+ }
+ }
+}
+func (d *Decoder) fastpathDecMapUint64Float64R(f *codecFnInfo, rv reflect.Value) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ if rv.Kind() == reflect.Ptr {
+ *(rv2i(rv).(*map[uint64]float64)) = nil
+ }
+ } else {
+ if rv.Kind() == reflect.Ptr {
+ vp, _ := rv2i(rv).(*map[uint64]float64)
+ if *vp == nil {
+ *vp = make(map[uint64]float64, decInferLen(containerLen, d.h.MaxInitLen, 16))
+ }
+ if containerLen != 0 {
+ fastpathTV.DecMapUint64Float64L(*vp, containerLen, d)
+ }
+ } else if containerLen != 0 {
+ fastpathTV.DecMapUint64Float64L(rv2i(rv).(map[uint64]float64), containerLen, d)
+ }
+ d.mapEnd()
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
+}
+func (f fastpathT) DecMapUint64Float64X(vp *map[uint64]float64, d *Decoder) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ *vp = nil
+ } else {
+ if *vp == nil {
+ *vp = make(map[uint64]float64, decInferLen(containerLen, d.h.MaxInitLen, 16))
+ }
+ if containerLen != 0 {
+ f.DecMapUint64Float64L(*vp, containerLen, d)
+ }
+ d.mapEnd()
}
- d.depthIncr()
- var mk int64
- var mv int
+}
+func (fastpathT) DecMapUint64Float64L(v map[uint64]float64, containerLen int, d *Decoder) {
+ var mk uint64
+ var mv float64
hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeInt64()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize))
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
+ mk = d.d.DecodeUint64()
+ d.mapElemValue()
+ mv = d.d.DecodeFloat64()
if v != nil {
v[mk] = mv
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
}
-
-func (d *Decoder) fastpathDecMapInt64Int8R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int64]int8)
- v, changed := fastpathTV.DecMapInt64Int8V(*vp, true, d)
- if changed {
- *vp = v
+func (d *Decoder) fastpathDecMapUint64BoolR(f *codecFnInfo, rv reflect.Value) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ if rv.Kind() == reflect.Ptr {
+ *(rv2i(rv).(*map[uint64]bool)) = nil
}
} else {
- fastpathTV.DecMapInt64Int8V(rv2i(rv).(map[int64]int8), false, d)
+ if rv.Kind() == reflect.Ptr {
+ vp, _ := rv2i(rv).(*map[uint64]bool)
+ if *vp == nil {
+ *vp = make(map[uint64]bool, decInferLen(containerLen, d.h.MaxInitLen, 9))
+ }
+ if containerLen != 0 {
+ fastpathTV.DecMapUint64BoolL(*vp, containerLen, d)
+ }
+ } else if containerLen != 0 {
+ fastpathTV.DecMapUint64BoolL(rv2i(rv).(map[uint64]bool), containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (f fastpathT) DecMapInt64Int8X(vp *map[int64]int8, d *Decoder) {
- v, changed := f.DecMapInt64Int8V(*vp, true, d)
- if changed {
- *vp = v
+func (f fastpathT) DecMapUint64BoolX(vp *map[uint64]bool, d *Decoder) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ *vp = nil
+ } else {
+ if *vp == nil {
+ *vp = make(map[uint64]bool, decInferLen(containerLen, d.h.MaxInitLen, 9))
+ }
+ if containerLen != 0 {
+ f.DecMapUint64BoolL(*vp, containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (_ fastpathT) DecMapInt64Int8V(v map[int64]int8, canChange bool,
- d *Decoder) (_ map[int64]int8, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
- v = make(map[int64]int8, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk int64
- var mv int8
+func (fastpathT) DecMapUint64BoolL(v map[uint64]bool, containerLen int, d *Decoder) {
+ var mk uint64
+ var mv bool
hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeInt64()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = int8(chkOvf.IntV(dd.DecodeInt64(), 8))
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
+ mk = d.d.DecodeUint64()
+ d.mapElemValue()
+ mv = d.d.DecodeBool()
if v != nil {
v[mk] = mv
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
}
-
-func (d *Decoder) fastpathDecMapInt64Int16R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int64]int16)
- v, changed := fastpathTV.DecMapInt64Int16V(*vp, true, d)
- if changed {
- *vp = v
+func (d *Decoder) fastpathDecMapIntIntfR(f *codecFnInfo, rv reflect.Value) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ if rv.Kind() == reflect.Ptr {
+ *(rv2i(rv).(*map[int]interface{})) = nil
}
} else {
- fastpathTV.DecMapInt64Int16V(rv2i(rv).(map[int64]int16), false, d)
+ if rv.Kind() == reflect.Ptr {
+ vp, _ := rv2i(rv).(*map[int]interface{})
+ if *vp == nil {
+ *vp = make(map[int]interface{}, decInferLen(containerLen, d.h.MaxInitLen, 24))
+ }
+ if containerLen != 0 {
+ fastpathTV.DecMapIntIntfL(*vp, containerLen, d)
+ }
+ } else if containerLen != 0 {
+ fastpathTV.DecMapIntIntfL(rv2i(rv).(map[int]interface{}), containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (f fastpathT) DecMapInt64Int16X(vp *map[int64]int16, d *Decoder) {
- v, changed := f.DecMapInt64Int16V(*vp, true, d)
- if changed {
- *vp = v
+func (f fastpathT) DecMapIntIntfX(vp *map[int]interface{}, d *Decoder) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ *vp = nil
+ } else {
+ if *vp == nil {
+ *vp = make(map[int]interface{}, decInferLen(containerLen, d.h.MaxInitLen, 24))
+ }
+ if containerLen != 0 {
+ f.DecMapIntIntfL(*vp, containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (_ fastpathT) DecMapInt64Int16V(v map[int64]int16, canChange bool,
- d *Decoder) (_ map[int64]int16, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 10)
- v = make(map[int64]int16, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk int64
- var mv int16
+func (fastpathT) DecMapIntIntfL(v map[int]interface{}, containerLen int, d *Decoder) {
+ mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset
+ var mk int
+ var mv interface{}
hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeInt64()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
+ mk = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize))
+ d.mapElemValue()
+ if mapGet {
+ mv = v[mk]
+ } else {
+ mv = nil
}
- mv = int16(chkOvf.IntV(dd.DecodeInt64(), 16))
+ d.decode(&mv)
if v != nil {
v[mk] = mv
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
}
-
-func (d *Decoder) fastpathDecMapInt64Int32R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int64]int32)
- v, changed := fastpathTV.DecMapInt64Int32V(*vp, true, d)
- if changed {
- *vp = v
+func (d *Decoder) fastpathDecMapIntStringR(f *codecFnInfo, rv reflect.Value) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ if rv.Kind() == reflect.Ptr {
+ *(rv2i(rv).(*map[int]string)) = nil
}
} else {
- fastpathTV.DecMapInt64Int32V(rv2i(rv).(map[int64]int32), false, d)
+ if rv.Kind() == reflect.Ptr {
+ vp, _ := rv2i(rv).(*map[int]string)
+ if *vp == nil {
+ *vp = make(map[int]string, decInferLen(containerLen, d.h.MaxInitLen, 24))
+ }
+ if containerLen != 0 {
+ fastpathTV.DecMapIntStringL(*vp, containerLen, d)
+ }
+ } else if containerLen != 0 {
+ fastpathTV.DecMapIntStringL(rv2i(rv).(map[int]string), containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (f fastpathT) DecMapInt64Int32X(vp *map[int64]int32, d *Decoder) {
- v, changed := f.DecMapInt64Int32V(*vp, true, d)
- if changed {
- *vp = v
+func (f fastpathT) DecMapIntStringX(vp *map[int]string, d *Decoder) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ *vp = nil
+ } else {
+ if *vp == nil {
+ *vp = make(map[int]string, decInferLen(containerLen, d.h.MaxInitLen, 24))
+ }
+ if containerLen != 0 {
+ f.DecMapIntStringL(*vp, containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (_ fastpathT) DecMapInt64Int32V(v map[int64]int32, canChange bool,
- d *Decoder) (_ map[int64]int32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
- v = make(map[int64]int32, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk int64
- var mv int32
+func (fastpathT) DecMapIntStringL(v map[int]string, containerLen int, d *Decoder) {
+ var mk int
+ var mv string
hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeInt64()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = int32(chkOvf.IntV(dd.DecodeInt64(), 32))
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
+ mk = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize))
+ d.mapElemValue()
+ mv = string(d.d.DecodeStringAsBytes())
if v != nil {
v[mk] = mv
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
}
-
-func (d *Decoder) fastpathDecMapInt64Int64R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int64]int64)
- v, changed := fastpathTV.DecMapInt64Int64V(*vp, true, d)
- if changed {
- *vp = v
+func (d *Decoder) fastpathDecMapIntBytesR(f *codecFnInfo, rv reflect.Value) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ if rv.Kind() == reflect.Ptr {
+ *(rv2i(rv).(*map[int][]byte)) = nil
}
} else {
- fastpathTV.DecMapInt64Int64V(rv2i(rv).(map[int64]int64), false, d)
+ if rv.Kind() == reflect.Ptr {
+ vp, _ := rv2i(rv).(*map[int][]byte)
+ if *vp == nil {
+ *vp = make(map[int][]byte, decInferLen(containerLen, d.h.MaxInitLen, 32))
+ }
+ if containerLen != 0 {
+ fastpathTV.DecMapIntBytesL(*vp, containerLen, d)
+ }
+ } else if containerLen != 0 {
+ fastpathTV.DecMapIntBytesL(rv2i(rv).(map[int][]byte), containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (f fastpathT) DecMapInt64Int64X(vp *map[int64]int64, d *Decoder) {
- v, changed := f.DecMapInt64Int64V(*vp, true, d)
- if changed {
- *vp = v
+func (f fastpathT) DecMapIntBytesX(vp *map[int][]byte, d *Decoder) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ *vp = nil
+ } else {
+ if *vp == nil {
+ *vp = make(map[int][]byte, decInferLen(containerLen, d.h.MaxInitLen, 32))
+ }
+ if containerLen != 0 {
+ f.DecMapIntBytesL(*vp, containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (_ fastpathT) DecMapInt64Int64V(v map[int64]int64, canChange bool,
- d *Decoder) (_ map[int64]int64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
- v = make(map[int64]int64, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk int64
- var mv int64
+func (fastpathT) DecMapIntBytesL(v map[int][]byte, containerLen int, d *Decoder) {
+ mapGet := v != nil && !d.h.MapValueReset
+ var mk int
+ var mv []byte
hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeInt64()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
+ mk = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize))
+ d.mapElemValue()
+ if mapGet {
+ mv = v[mk]
+ } else {
+ mv = nil
}
- mv = dd.DecodeInt64()
+ mv = d.d.DecodeBytes(mv, false)
if v != nil {
v[mk] = mv
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
}
-
-func (d *Decoder) fastpathDecMapInt64Float32R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int64]float32)
- v, changed := fastpathTV.DecMapInt64Float32V(*vp, true, d)
- if changed {
- *vp = v
+func (d *Decoder) fastpathDecMapIntUintR(f *codecFnInfo, rv reflect.Value) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ if rv.Kind() == reflect.Ptr {
+ *(rv2i(rv).(*map[int]uint)) = nil
}
} else {
- fastpathTV.DecMapInt64Float32V(rv2i(rv).(map[int64]float32), false, d)
+ if rv.Kind() == reflect.Ptr {
+ vp, _ := rv2i(rv).(*map[int]uint)
+ if *vp == nil {
+ *vp = make(map[int]uint, decInferLen(containerLen, d.h.MaxInitLen, 16))
+ }
+ if containerLen != 0 {
+ fastpathTV.DecMapIntUintL(*vp, containerLen, d)
+ }
+ } else if containerLen != 0 {
+ fastpathTV.DecMapIntUintL(rv2i(rv).(map[int]uint), containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (f fastpathT) DecMapInt64Float32X(vp *map[int64]float32, d *Decoder) {
- v, changed := f.DecMapInt64Float32V(*vp, true, d)
- if changed {
- *vp = v
+func (f fastpathT) DecMapIntUintX(vp *map[int]uint, d *Decoder) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ *vp = nil
+ } else {
+ if *vp == nil {
+ *vp = make(map[int]uint, decInferLen(containerLen, d.h.MaxInitLen, 16))
+ }
+ if containerLen != 0 {
+ f.DecMapIntUintL(*vp, containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (_ fastpathT) DecMapInt64Float32V(v map[int64]float32, canChange bool,
- d *Decoder) (_ map[int64]float32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
- v = make(map[int64]float32, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk int64
- var mv float32
+func (fastpathT) DecMapIntUintL(v map[int]uint, containerLen int, d *Decoder) {
+ var mk int
+ var mv uint
hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeInt64()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = float32(chkOvf.Float32V(dd.DecodeFloat64()))
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
+ mk = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize))
+ d.mapElemValue()
+ mv = uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize))
if v != nil {
v[mk] = mv
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
}
-
-func (d *Decoder) fastpathDecMapInt64Float64R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int64]float64)
- v, changed := fastpathTV.DecMapInt64Float64V(*vp, true, d)
- if changed {
- *vp = v
+func (d *Decoder) fastpathDecMapIntUint8R(f *codecFnInfo, rv reflect.Value) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ if rv.Kind() == reflect.Ptr {
+ *(rv2i(rv).(*map[int]uint8)) = nil
}
} else {
- fastpathTV.DecMapInt64Float64V(rv2i(rv).(map[int64]float64), false, d)
+ if rv.Kind() == reflect.Ptr {
+ vp, _ := rv2i(rv).(*map[int]uint8)
+ if *vp == nil {
+ *vp = make(map[int]uint8, decInferLen(containerLen, d.h.MaxInitLen, 9))
+ }
+ if containerLen != 0 {
+ fastpathTV.DecMapIntUint8L(*vp, containerLen, d)
+ }
+ } else if containerLen != 0 {
+ fastpathTV.DecMapIntUint8L(rv2i(rv).(map[int]uint8), containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (f fastpathT) DecMapInt64Float64X(vp *map[int64]float64, d *Decoder) {
- v, changed := f.DecMapInt64Float64V(*vp, true, d)
- if changed {
- *vp = v
+func (f fastpathT) DecMapIntUint8X(vp *map[int]uint8, d *Decoder) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ *vp = nil
+ } else {
+ if *vp == nil {
+ *vp = make(map[int]uint8, decInferLen(containerLen, d.h.MaxInitLen, 9))
+ }
+ if containerLen != 0 {
+ f.DecMapIntUint8L(*vp, containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (_ fastpathT) DecMapInt64Float64V(v map[int64]float64, canChange bool,
- d *Decoder) (_ map[int64]float64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
- v = make(map[int64]float64, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk int64
- var mv float64
+func (fastpathT) DecMapIntUint8L(v map[int]uint8, containerLen int, d *Decoder) {
+ var mk int
+ var mv uint8
hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeInt64()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = dd.DecodeFloat64()
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
+ mk = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize))
+ d.mapElemValue()
+ mv = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8))
if v != nil {
v[mk] = mv
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
}
-
-func (d *Decoder) fastpathDecMapInt64BoolR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[int64]bool)
- v, changed := fastpathTV.DecMapInt64BoolV(*vp, true, d)
- if changed {
- *vp = v
+func (d *Decoder) fastpathDecMapIntUint64R(f *codecFnInfo, rv reflect.Value) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ if rv.Kind() == reflect.Ptr {
+ *(rv2i(rv).(*map[int]uint64)) = nil
}
} else {
- fastpathTV.DecMapInt64BoolV(rv2i(rv).(map[int64]bool), false, d)
+ if rv.Kind() == reflect.Ptr {
+ vp, _ := rv2i(rv).(*map[int]uint64)
+ if *vp == nil {
+ *vp = make(map[int]uint64, decInferLen(containerLen, d.h.MaxInitLen, 16))
+ }
+ if containerLen != 0 {
+ fastpathTV.DecMapIntUint64L(*vp, containerLen, d)
+ }
+ } else if containerLen != 0 {
+ fastpathTV.DecMapIntUint64L(rv2i(rv).(map[int]uint64), containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (f fastpathT) DecMapInt64BoolX(vp *map[int64]bool, d *Decoder) {
- v, changed := f.DecMapInt64BoolV(*vp, true, d)
- if changed {
- *vp = v
+func (f fastpathT) DecMapIntUint64X(vp *map[int]uint64, d *Decoder) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ *vp = nil
+ } else {
+ if *vp == nil {
+ *vp = make(map[int]uint64, decInferLen(containerLen, d.h.MaxInitLen, 16))
+ }
+ if containerLen != 0 {
+ f.DecMapIntUint64L(*vp, containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (_ fastpathT) DecMapInt64BoolV(v map[int64]bool, canChange bool,
- d *Decoder) (_ map[int64]bool, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
- v = make(map[int64]bool, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk int64
- var mv bool
+func (fastpathT) DecMapIntUint64L(v map[int]uint64, containerLen int, d *Decoder) {
+ var mk int
+ var mv uint64
hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeInt64()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = false
- }
- continue
- }
- mv = dd.DecodeBool()
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
+ mk = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize))
+ d.mapElemValue()
+ mv = d.d.DecodeUint64()
if v != nil {
v[mk] = mv
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
}
-
-func (d *Decoder) fastpathDecMapBoolIntfR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[bool]interface{})
- v, changed := fastpathTV.DecMapBoolIntfV(*vp, true, d)
- if changed {
- *vp = v
+func (d *Decoder) fastpathDecMapIntIntR(f *codecFnInfo, rv reflect.Value) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ if rv.Kind() == reflect.Ptr {
+ *(rv2i(rv).(*map[int]int)) = nil
}
} else {
- fastpathTV.DecMapBoolIntfV(rv2i(rv).(map[bool]interface{}), false, d)
+ if rv.Kind() == reflect.Ptr {
+ vp, _ := rv2i(rv).(*map[int]int)
+ if *vp == nil {
+ *vp = make(map[int]int, decInferLen(containerLen, d.h.MaxInitLen, 16))
+ }
+ if containerLen != 0 {
+ fastpathTV.DecMapIntIntL(*vp, containerLen, d)
+ }
+ } else if containerLen != 0 {
+ fastpathTV.DecMapIntIntL(rv2i(rv).(map[int]int), containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (f fastpathT) DecMapBoolIntfX(vp *map[bool]interface{}, d *Decoder) {
- v, changed := f.DecMapBoolIntfV(*vp, true, d)
- if changed {
- *vp = v
+func (f fastpathT) DecMapIntIntX(vp *map[int]int, d *Decoder) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ *vp = nil
+ } else {
+ if *vp == nil {
+ *vp = make(map[int]int, decInferLen(containerLen, d.h.MaxInitLen, 16))
+ }
+ if containerLen != 0 {
+ f.DecMapIntIntL(*vp, containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (_ fastpathT) DecMapBoolIntfV(v map[bool]interface{}, canChange bool,
- d *Decoder) (_ map[bool]interface{}, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 17)
- v = make(map[bool]interface{}, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset
- var mk bool
- var mv interface{}
+func (fastpathT) DecMapIntIntL(v map[int]int, containerLen int, d *Decoder) {
+ var mk int
+ var mv int
hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeBool()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = nil
- }
- continue
- }
- if mapGet {
- mv = v[mk]
- } else {
- mv = nil
- }
- d.decode(&mv)
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
+ mk = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize))
+ d.mapElemValue()
+ mv = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize))
if v != nil {
v[mk] = mv
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
}
-
-func (d *Decoder) fastpathDecMapBoolStringR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[bool]string)
- v, changed := fastpathTV.DecMapBoolStringV(*vp, true, d)
- if changed {
- *vp = v
+func (d *Decoder) fastpathDecMapIntInt64R(f *codecFnInfo, rv reflect.Value) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ if rv.Kind() == reflect.Ptr {
+ *(rv2i(rv).(*map[int]int64)) = nil
}
} else {
- fastpathTV.DecMapBoolStringV(rv2i(rv).(map[bool]string), false, d)
+ if rv.Kind() == reflect.Ptr {
+ vp, _ := rv2i(rv).(*map[int]int64)
+ if *vp == nil {
+ *vp = make(map[int]int64, decInferLen(containerLen, d.h.MaxInitLen, 16))
+ }
+ if containerLen != 0 {
+ fastpathTV.DecMapIntInt64L(*vp, containerLen, d)
+ }
+ } else if containerLen != 0 {
+ fastpathTV.DecMapIntInt64L(rv2i(rv).(map[int]int64), containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (f fastpathT) DecMapBoolStringX(vp *map[bool]string, d *Decoder) {
- v, changed := f.DecMapBoolStringV(*vp, true, d)
- if changed {
- *vp = v
+func (f fastpathT) DecMapIntInt64X(vp *map[int]int64, d *Decoder) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ *vp = nil
+ } else {
+ if *vp == nil {
+ *vp = make(map[int]int64, decInferLen(containerLen, d.h.MaxInitLen, 16))
+ }
+ if containerLen != 0 {
+ f.DecMapIntInt64L(*vp, containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (_ fastpathT) DecMapBoolStringV(v map[bool]string, canChange bool,
- d *Decoder) (_ map[bool]string, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 17)
- v = make(map[bool]string, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk bool
- var mv string
+func (fastpathT) DecMapIntInt64L(v map[int]int64, containerLen int, d *Decoder) {
+ var mk int
+ var mv int64
hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeBool()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = ""
- }
- continue
- }
- mv = dd.DecodeString()
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
+ mk = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize))
+ d.mapElemValue()
+ mv = d.d.DecodeInt64()
if v != nil {
v[mk] = mv
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
}
-
-func (d *Decoder) fastpathDecMapBoolUintR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[bool]uint)
- v, changed := fastpathTV.DecMapBoolUintV(*vp, true, d)
- if changed {
- *vp = v
+func (d *Decoder) fastpathDecMapIntFloat32R(f *codecFnInfo, rv reflect.Value) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ if rv.Kind() == reflect.Ptr {
+ *(rv2i(rv).(*map[int]float32)) = nil
}
} else {
- fastpathTV.DecMapBoolUintV(rv2i(rv).(map[bool]uint), false, d)
+ if rv.Kind() == reflect.Ptr {
+ vp, _ := rv2i(rv).(*map[int]float32)
+ if *vp == nil {
+ *vp = make(map[int]float32, decInferLen(containerLen, d.h.MaxInitLen, 12))
+ }
+ if containerLen != 0 {
+ fastpathTV.DecMapIntFloat32L(*vp, containerLen, d)
+ }
+ } else if containerLen != 0 {
+ fastpathTV.DecMapIntFloat32L(rv2i(rv).(map[int]float32), containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (f fastpathT) DecMapBoolUintX(vp *map[bool]uint, d *Decoder) {
- v, changed := f.DecMapBoolUintV(*vp, true, d)
- if changed {
- *vp = v
+func (f fastpathT) DecMapIntFloat32X(vp *map[int]float32, d *Decoder) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ *vp = nil
+ } else {
+ if *vp == nil {
+ *vp = make(map[int]float32, decInferLen(containerLen, d.h.MaxInitLen, 12))
+ }
+ if containerLen != 0 {
+ f.DecMapIntFloat32L(*vp, containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (_ fastpathT) DecMapBoolUintV(v map[bool]uint, canChange bool,
- d *Decoder) (_ map[bool]uint, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
- v = make(map[bool]uint, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk bool
- var mv uint
+func (fastpathT) DecMapIntFloat32L(v map[int]float32, containerLen int, d *Decoder) {
+ var mk int
+ var mv float32
hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeBool()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
+ mk = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize))
+ d.mapElemValue()
+ mv = float32(d.decodeFloat32())
if v != nil {
v[mk] = mv
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
}
-
-func (d *Decoder) fastpathDecMapBoolUint8R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[bool]uint8)
- v, changed := fastpathTV.DecMapBoolUint8V(*vp, true, d)
- if changed {
- *vp = v
+func (d *Decoder) fastpathDecMapIntFloat64R(f *codecFnInfo, rv reflect.Value) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ if rv.Kind() == reflect.Ptr {
+ *(rv2i(rv).(*map[int]float64)) = nil
}
} else {
- fastpathTV.DecMapBoolUint8V(rv2i(rv).(map[bool]uint8), false, d)
- }
-}
-func (f fastpathT) DecMapBoolUint8X(vp *map[bool]uint8, d *Decoder) {
- v, changed := f.DecMapBoolUint8V(*vp, true, d)
- if changed {
- *vp = v
- }
-}
-func (_ fastpathT) DecMapBoolUint8V(v map[bool]uint8, canChange bool,
- d *Decoder) (_ map[bool]uint8, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 2)
- v = make(map[bool]uint8, xlen)
- changed = true
+ if rv.Kind() == reflect.Ptr {
+ vp, _ := rv2i(rv).(*map[int]float64)
+ if *vp == nil {
+ *vp = make(map[int]float64, decInferLen(containerLen, d.h.MaxInitLen, 16))
+ }
+ if containerLen != 0 {
+ fastpathTV.DecMapIntFloat64L(*vp, containerLen, d)
+ }
+ } else if containerLen != 0 {
+ fastpathTV.DecMapIntFloat64L(rv2i(rv).(map[int]float64), containerLen, d)
+ }
+ d.mapEnd()
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
+}
+func (f fastpathT) DecMapIntFloat64X(vp *map[int]float64, d *Decoder) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ *vp = nil
+ } else {
+ if *vp == nil {
+ *vp = make(map[int]float64, decInferLen(containerLen, d.h.MaxInitLen, 16))
+ }
+ if containerLen != 0 {
+ f.DecMapIntFloat64L(*vp, containerLen, d)
+ }
+ d.mapEnd()
}
- d.depthIncr()
- var mk bool
- var mv uint8
+}
+func (fastpathT) DecMapIntFloat64L(v map[int]float64, containerLen int, d *Decoder) {
+ var mk int
+ var mv float64
hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeBool()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uint8(chkOvf.UintV(dd.DecodeUint64(), 8))
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
+ mk = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize))
+ d.mapElemValue()
+ mv = d.d.DecodeFloat64()
if v != nil {
v[mk] = mv
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
}
-
-func (d *Decoder) fastpathDecMapBoolUint16R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[bool]uint16)
- v, changed := fastpathTV.DecMapBoolUint16V(*vp, true, d)
- if changed {
- *vp = v
+func (d *Decoder) fastpathDecMapIntBoolR(f *codecFnInfo, rv reflect.Value) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ if rv.Kind() == reflect.Ptr {
+ *(rv2i(rv).(*map[int]bool)) = nil
}
} else {
- fastpathTV.DecMapBoolUint16V(rv2i(rv).(map[bool]uint16), false, d)
+ if rv.Kind() == reflect.Ptr {
+ vp, _ := rv2i(rv).(*map[int]bool)
+ if *vp == nil {
+ *vp = make(map[int]bool, decInferLen(containerLen, d.h.MaxInitLen, 9))
+ }
+ if containerLen != 0 {
+ fastpathTV.DecMapIntBoolL(*vp, containerLen, d)
+ }
+ } else if containerLen != 0 {
+ fastpathTV.DecMapIntBoolL(rv2i(rv).(map[int]bool), containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (f fastpathT) DecMapBoolUint16X(vp *map[bool]uint16, d *Decoder) {
- v, changed := f.DecMapBoolUint16V(*vp, true, d)
- if changed {
- *vp = v
+func (f fastpathT) DecMapIntBoolX(vp *map[int]bool, d *Decoder) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ *vp = nil
+ } else {
+ if *vp == nil {
+ *vp = make(map[int]bool, decInferLen(containerLen, d.h.MaxInitLen, 9))
+ }
+ if containerLen != 0 {
+ f.DecMapIntBoolL(*vp, containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (_ fastpathT) DecMapBoolUint16V(v map[bool]uint16, canChange bool,
- d *Decoder) (_ map[bool]uint16, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 3)
- v = make(map[bool]uint16, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk bool
- var mv uint16
+func (fastpathT) DecMapIntBoolL(v map[int]bool, containerLen int, d *Decoder) {
+ var mk int
+ var mv bool
hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeBool()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = uint16(chkOvf.UintV(dd.DecodeUint64(), 16))
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
+ mk = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize))
+ d.mapElemValue()
+ mv = d.d.DecodeBool()
if v != nil {
v[mk] = mv
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
}
-
-func (d *Decoder) fastpathDecMapBoolUint32R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[bool]uint32)
- v, changed := fastpathTV.DecMapBoolUint32V(*vp, true, d)
- if changed {
- *vp = v
+func (d *Decoder) fastpathDecMapInt64IntfR(f *codecFnInfo, rv reflect.Value) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ if rv.Kind() == reflect.Ptr {
+ *(rv2i(rv).(*map[int64]interface{})) = nil
}
} else {
- fastpathTV.DecMapBoolUint32V(rv2i(rv).(map[bool]uint32), false, d)
+ if rv.Kind() == reflect.Ptr {
+ vp, _ := rv2i(rv).(*map[int64]interface{})
+ if *vp == nil {
+ *vp = make(map[int64]interface{}, decInferLen(containerLen, d.h.MaxInitLen, 24))
+ }
+ if containerLen != 0 {
+ fastpathTV.DecMapInt64IntfL(*vp, containerLen, d)
+ }
+ } else if containerLen != 0 {
+ fastpathTV.DecMapInt64IntfL(rv2i(rv).(map[int64]interface{}), containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (f fastpathT) DecMapBoolUint32X(vp *map[bool]uint32, d *Decoder) {
- v, changed := f.DecMapBoolUint32V(*vp, true, d)
- if changed {
- *vp = v
+func (f fastpathT) DecMapInt64IntfX(vp *map[int64]interface{}, d *Decoder) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ *vp = nil
+ } else {
+ if *vp == nil {
+ *vp = make(map[int64]interface{}, decInferLen(containerLen, d.h.MaxInitLen, 24))
+ }
+ if containerLen != 0 {
+ f.DecMapInt64IntfL(*vp, containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (_ fastpathT) DecMapBoolUint32V(v map[bool]uint32, canChange bool,
- d *Decoder) (_ map[bool]uint32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 5)
- v = make(map[bool]uint32, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk bool
- var mv uint32
+func (fastpathT) DecMapInt64IntfL(v map[int64]interface{}, containerLen int, d *Decoder) {
+ mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset
+ var mk int64
+ var mv interface{}
hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeBool()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
+ mk = d.d.DecodeInt64()
+ d.mapElemValue()
+ if mapGet {
+ mv = v[mk]
+ } else {
+ mv = nil
}
- mv = uint32(chkOvf.UintV(dd.DecodeUint64(), 32))
+ d.decode(&mv)
if v != nil {
v[mk] = mv
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
}
-
-func (d *Decoder) fastpathDecMapBoolUint64R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[bool]uint64)
- v, changed := fastpathTV.DecMapBoolUint64V(*vp, true, d)
- if changed {
- *vp = v
+func (d *Decoder) fastpathDecMapInt64StringR(f *codecFnInfo, rv reflect.Value) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ if rv.Kind() == reflect.Ptr {
+ *(rv2i(rv).(*map[int64]string)) = nil
}
} else {
- fastpathTV.DecMapBoolUint64V(rv2i(rv).(map[bool]uint64), false, d)
+ if rv.Kind() == reflect.Ptr {
+ vp, _ := rv2i(rv).(*map[int64]string)
+ if *vp == nil {
+ *vp = make(map[int64]string, decInferLen(containerLen, d.h.MaxInitLen, 24))
+ }
+ if containerLen != 0 {
+ fastpathTV.DecMapInt64StringL(*vp, containerLen, d)
+ }
+ } else if containerLen != 0 {
+ fastpathTV.DecMapInt64StringL(rv2i(rv).(map[int64]string), containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (f fastpathT) DecMapBoolUint64X(vp *map[bool]uint64, d *Decoder) {
- v, changed := f.DecMapBoolUint64V(*vp, true, d)
- if changed {
- *vp = v
+func (f fastpathT) DecMapInt64StringX(vp *map[int64]string, d *Decoder) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ *vp = nil
+ } else {
+ if *vp == nil {
+ *vp = make(map[int64]string, decInferLen(containerLen, d.h.MaxInitLen, 24))
+ }
+ if containerLen != 0 {
+ f.DecMapInt64StringL(*vp, containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (_ fastpathT) DecMapBoolUint64V(v map[bool]uint64, canChange bool,
- d *Decoder) (_ map[bool]uint64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
- v = make(map[bool]uint64, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk bool
- var mv uint64
+func (fastpathT) DecMapInt64StringL(v map[int64]string, containerLen int, d *Decoder) {
+ var mk int64
+ var mv string
hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeBool()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = dd.DecodeUint64()
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
+ mk = d.d.DecodeInt64()
+ d.mapElemValue()
+ mv = string(d.d.DecodeStringAsBytes())
if v != nil {
v[mk] = mv
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
}
-
-func (d *Decoder) fastpathDecMapBoolUintptrR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[bool]uintptr)
- v, changed := fastpathTV.DecMapBoolUintptrV(*vp, true, d)
- if changed {
- *vp = v
+func (d *Decoder) fastpathDecMapInt64BytesR(f *codecFnInfo, rv reflect.Value) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ if rv.Kind() == reflect.Ptr {
+ *(rv2i(rv).(*map[int64][]byte)) = nil
}
} else {
- fastpathTV.DecMapBoolUintptrV(rv2i(rv).(map[bool]uintptr), false, d)
+ if rv.Kind() == reflect.Ptr {
+ vp, _ := rv2i(rv).(*map[int64][]byte)
+ if *vp == nil {
+ *vp = make(map[int64][]byte, decInferLen(containerLen, d.h.MaxInitLen, 32))
+ }
+ if containerLen != 0 {
+ fastpathTV.DecMapInt64BytesL(*vp, containerLen, d)
+ }
+ } else if containerLen != 0 {
+ fastpathTV.DecMapInt64BytesL(rv2i(rv).(map[int64][]byte), containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (f fastpathT) DecMapBoolUintptrX(vp *map[bool]uintptr, d *Decoder) {
- v, changed := f.DecMapBoolUintptrV(*vp, true, d)
- if changed {
- *vp = v
+func (f fastpathT) DecMapInt64BytesX(vp *map[int64][]byte, d *Decoder) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ *vp = nil
+ } else {
+ if *vp == nil {
+ *vp = make(map[int64][]byte, decInferLen(containerLen, d.h.MaxInitLen, 32))
+ }
+ if containerLen != 0 {
+ f.DecMapInt64BytesL(*vp, containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (_ fastpathT) DecMapBoolUintptrV(v map[bool]uintptr, canChange bool,
- d *Decoder) (_ map[bool]uintptr, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
- v = make(map[bool]uintptr, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk bool
- var mv uintptr
+func (fastpathT) DecMapInt64BytesL(v map[int64][]byte, containerLen int, d *Decoder) {
+ mapGet := v != nil && !d.h.MapValueReset
+ var mk int64
+ var mv []byte
hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeBool()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
+ mk = d.d.DecodeInt64()
+ d.mapElemValue()
+ if mapGet {
+ mv = v[mk]
+ } else {
+ mv = nil
}
- mv = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
+ mv = d.d.DecodeBytes(mv, false)
if v != nil {
v[mk] = mv
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
}
-
-func (d *Decoder) fastpathDecMapBoolIntR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[bool]int)
- v, changed := fastpathTV.DecMapBoolIntV(*vp, true, d)
- if changed {
- *vp = v
+func (d *Decoder) fastpathDecMapInt64UintR(f *codecFnInfo, rv reflect.Value) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ if rv.Kind() == reflect.Ptr {
+ *(rv2i(rv).(*map[int64]uint)) = nil
}
} else {
- fastpathTV.DecMapBoolIntV(rv2i(rv).(map[bool]int), false, d)
+ if rv.Kind() == reflect.Ptr {
+ vp, _ := rv2i(rv).(*map[int64]uint)
+ if *vp == nil {
+ *vp = make(map[int64]uint, decInferLen(containerLen, d.h.MaxInitLen, 16))
+ }
+ if containerLen != 0 {
+ fastpathTV.DecMapInt64UintL(*vp, containerLen, d)
+ }
+ } else if containerLen != 0 {
+ fastpathTV.DecMapInt64UintL(rv2i(rv).(map[int64]uint), containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (f fastpathT) DecMapBoolIntX(vp *map[bool]int, d *Decoder) {
- v, changed := f.DecMapBoolIntV(*vp, true, d)
- if changed {
- *vp = v
+func (f fastpathT) DecMapInt64UintX(vp *map[int64]uint, d *Decoder) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ *vp = nil
+ } else {
+ if *vp == nil {
+ *vp = make(map[int64]uint, decInferLen(containerLen, d.h.MaxInitLen, 16))
+ }
+ if containerLen != 0 {
+ f.DecMapInt64UintL(*vp, containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (_ fastpathT) DecMapBoolIntV(v map[bool]int, canChange bool,
- d *Decoder) (_ map[bool]int, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
- v = make(map[bool]int, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk bool
- var mv int
+func (fastpathT) DecMapInt64UintL(v map[int64]uint, containerLen int, d *Decoder) {
+ var mk int64
+ var mv uint
hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeBool()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize))
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
+ mk = d.d.DecodeInt64()
+ d.mapElemValue()
+ mv = uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize))
if v != nil {
v[mk] = mv
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
}
-
-func (d *Decoder) fastpathDecMapBoolInt8R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[bool]int8)
- v, changed := fastpathTV.DecMapBoolInt8V(*vp, true, d)
- if changed {
- *vp = v
+func (d *Decoder) fastpathDecMapInt64Uint8R(f *codecFnInfo, rv reflect.Value) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ if rv.Kind() == reflect.Ptr {
+ *(rv2i(rv).(*map[int64]uint8)) = nil
}
} else {
- fastpathTV.DecMapBoolInt8V(rv2i(rv).(map[bool]int8), false, d)
+ if rv.Kind() == reflect.Ptr {
+ vp, _ := rv2i(rv).(*map[int64]uint8)
+ if *vp == nil {
+ *vp = make(map[int64]uint8, decInferLen(containerLen, d.h.MaxInitLen, 9))
+ }
+ if containerLen != 0 {
+ fastpathTV.DecMapInt64Uint8L(*vp, containerLen, d)
+ }
+ } else if containerLen != 0 {
+ fastpathTV.DecMapInt64Uint8L(rv2i(rv).(map[int64]uint8), containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (f fastpathT) DecMapBoolInt8X(vp *map[bool]int8, d *Decoder) {
- v, changed := f.DecMapBoolInt8V(*vp, true, d)
- if changed {
- *vp = v
+func (f fastpathT) DecMapInt64Uint8X(vp *map[int64]uint8, d *Decoder) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ *vp = nil
+ } else {
+ if *vp == nil {
+ *vp = make(map[int64]uint8, decInferLen(containerLen, d.h.MaxInitLen, 9))
+ }
+ if containerLen != 0 {
+ f.DecMapInt64Uint8L(*vp, containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (_ fastpathT) DecMapBoolInt8V(v map[bool]int8, canChange bool,
- d *Decoder) (_ map[bool]int8, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 2)
- v = make(map[bool]int8, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk bool
- var mv int8
+func (fastpathT) DecMapInt64Uint8L(v map[int64]uint8, containerLen int, d *Decoder) {
+ var mk int64
+ var mv uint8
hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeBool()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = int8(chkOvf.IntV(dd.DecodeInt64(), 8))
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
+ mk = d.d.DecodeInt64()
+ d.mapElemValue()
+ mv = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8))
if v != nil {
v[mk] = mv
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
}
-
-func (d *Decoder) fastpathDecMapBoolInt16R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[bool]int16)
- v, changed := fastpathTV.DecMapBoolInt16V(*vp, true, d)
- if changed {
- *vp = v
+func (d *Decoder) fastpathDecMapInt64Uint64R(f *codecFnInfo, rv reflect.Value) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ if rv.Kind() == reflect.Ptr {
+ *(rv2i(rv).(*map[int64]uint64)) = nil
}
} else {
- fastpathTV.DecMapBoolInt16V(rv2i(rv).(map[bool]int16), false, d)
+ if rv.Kind() == reflect.Ptr {
+ vp, _ := rv2i(rv).(*map[int64]uint64)
+ if *vp == nil {
+ *vp = make(map[int64]uint64, decInferLen(containerLen, d.h.MaxInitLen, 16))
+ }
+ if containerLen != 0 {
+ fastpathTV.DecMapInt64Uint64L(*vp, containerLen, d)
+ }
+ } else if containerLen != 0 {
+ fastpathTV.DecMapInt64Uint64L(rv2i(rv).(map[int64]uint64), containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (f fastpathT) DecMapBoolInt16X(vp *map[bool]int16, d *Decoder) {
- v, changed := f.DecMapBoolInt16V(*vp, true, d)
- if changed {
- *vp = v
+func (f fastpathT) DecMapInt64Uint64X(vp *map[int64]uint64, d *Decoder) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ *vp = nil
+ } else {
+ if *vp == nil {
+ *vp = make(map[int64]uint64, decInferLen(containerLen, d.h.MaxInitLen, 16))
+ }
+ if containerLen != 0 {
+ f.DecMapInt64Uint64L(*vp, containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (_ fastpathT) DecMapBoolInt16V(v map[bool]int16, canChange bool,
- d *Decoder) (_ map[bool]int16, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 3)
- v = make(map[bool]int16, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk bool
- var mv int16
+func (fastpathT) DecMapInt64Uint64L(v map[int64]uint64, containerLen int, d *Decoder) {
+ var mk int64
+ var mv uint64
hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeBool()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = int16(chkOvf.IntV(dd.DecodeInt64(), 16))
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
+ mk = d.d.DecodeInt64()
+ d.mapElemValue()
+ mv = d.d.DecodeUint64()
if v != nil {
v[mk] = mv
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
}
-
-func (d *Decoder) fastpathDecMapBoolInt32R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[bool]int32)
- v, changed := fastpathTV.DecMapBoolInt32V(*vp, true, d)
- if changed {
- *vp = v
+func (d *Decoder) fastpathDecMapInt64IntR(f *codecFnInfo, rv reflect.Value) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ if rv.Kind() == reflect.Ptr {
+ *(rv2i(rv).(*map[int64]int)) = nil
}
} else {
- fastpathTV.DecMapBoolInt32V(rv2i(rv).(map[bool]int32), false, d)
+ if rv.Kind() == reflect.Ptr {
+ vp, _ := rv2i(rv).(*map[int64]int)
+ if *vp == nil {
+ *vp = make(map[int64]int, decInferLen(containerLen, d.h.MaxInitLen, 16))
+ }
+ if containerLen != 0 {
+ fastpathTV.DecMapInt64IntL(*vp, containerLen, d)
+ }
+ } else if containerLen != 0 {
+ fastpathTV.DecMapInt64IntL(rv2i(rv).(map[int64]int), containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (f fastpathT) DecMapBoolInt32X(vp *map[bool]int32, d *Decoder) {
- v, changed := f.DecMapBoolInt32V(*vp, true, d)
- if changed {
- *vp = v
+func (f fastpathT) DecMapInt64IntX(vp *map[int64]int, d *Decoder) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ *vp = nil
+ } else {
+ if *vp == nil {
+ *vp = make(map[int64]int, decInferLen(containerLen, d.h.MaxInitLen, 16))
+ }
+ if containerLen != 0 {
+ f.DecMapInt64IntL(*vp, containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (_ fastpathT) DecMapBoolInt32V(v map[bool]int32, canChange bool,
- d *Decoder) (_ map[bool]int32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 5)
- v = make(map[bool]int32, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk bool
- var mv int32
+func (fastpathT) DecMapInt64IntL(v map[int64]int, containerLen int, d *Decoder) {
+ var mk int64
+ var mv int
hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeBool()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = int32(chkOvf.IntV(dd.DecodeInt64(), 32))
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
+ mk = d.d.DecodeInt64()
+ d.mapElemValue()
+ mv = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize))
if v != nil {
v[mk] = mv
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
}
-
-func (d *Decoder) fastpathDecMapBoolInt64R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[bool]int64)
- v, changed := fastpathTV.DecMapBoolInt64V(*vp, true, d)
- if changed {
- *vp = v
+func (d *Decoder) fastpathDecMapInt64Int64R(f *codecFnInfo, rv reflect.Value) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ if rv.Kind() == reflect.Ptr {
+ *(rv2i(rv).(*map[int64]int64)) = nil
}
} else {
- fastpathTV.DecMapBoolInt64V(rv2i(rv).(map[bool]int64), false, d)
+ if rv.Kind() == reflect.Ptr {
+ vp, _ := rv2i(rv).(*map[int64]int64)
+ if *vp == nil {
+ *vp = make(map[int64]int64, decInferLen(containerLen, d.h.MaxInitLen, 16))
+ }
+ if containerLen != 0 {
+ fastpathTV.DecMapInt64Int64L(*vp, containerLen, d)
+ }
+ } else if containerLen != 0 {
+ fastpathTV.DecMapInt64Int64L(rv2i(rv).(map[int64]int64), containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (f fastpathT) DecMapBoolInt64X(vp *map[bool]int64, d *Decoder) {
- v, changed := f.DecMapBoolInt64V(*vp, true, d)
- if changed {
- *vp = v
+func (f fastpathT) DecMapInt64Int64X(vp *map[int64]int64, d *Decoder) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ *vp = nil
+ } else {
+ if *vp == nil {
+ *vp = make(map[int64]int64, decInferLen(containerLen, d.h.MaxInitLen, 16))
+ }
+ if containerLen != 0 {
+ f.DecMapInt64Int64L(*vp, containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (_ fastpathT) DecMapBoolInt64V(v map[bool]int64, canChange bool,
- d *Decoder) (_ map[bool]int64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
- v = make(map[bool]int64, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk bool
+func (fastpathT) DecMapInt64Int64L(v map[int64]int64, containerLen int, d *Decoder) {
+ var mk int64
var mv int64
hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeBool()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = dd.DecodeInt64()
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
+ mk = d.d.DecodeInt64()
+ d.mapElemValue()
+ mv = d.d.DecodeInt64()
if v != nil {
v[mk] = mv
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
}
-
-func (d *Decoder) fastpathDecMapBoolFloat32R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[bool]float32)
- v, changed := fastpathTV.DecMapBoolFloat32V(*vp, true, d)
- if changed {
- *vp = v
+func (d *Decoder) fastpathDecMapInt64Float32R(f *codecFnInfo, rv reflect.Value) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ if rv.Kind() == reflect.Ptr {
+ *(rv2i(rv).(*map[int64]float32)) = nil
}
} else {
- fastpathTV.DecMapBoolFloat32V(rv2i(rv).(map[bool]float32), false, d)
+ if rv.Kind() == reflect.Ptr {
+ vp, _ := rv2i(rv).(*map[int64]float32)
+ if *vp == nil {
+ *vp = make(map[int64]float32, decInferLen(containerLen, d.h.MaxInitLen, 12))
+ }
+ if containerLen != 0 {
+ fastpathTV.DecMapInt64Float32L(*vp, containerLen, d)
+ }
+ } else if containerLen != 0 {
+ fastpathTV.DecMapInt64Float32L(rv2i(rv).(map[int64]float32), containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (f fastpathT) DecMapBoolFloat32X(vp *map[bool]float32, d *Decoder) {
- v, changed := f.DecMapBoolFloat32V(*vp, true, d)
- if changed {
- *vp = v
+func (f fastpathT) DecMapInt64Float32X(vp *map[int64]float32, d *Decoder) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ *vp = nil
+ } else {
+ if *vp == nil {
+ *vp = make(map[int64]float32, decInferLen(containerLen, d.h.MaxInitLen, 12))
+ }
+ if containerLen != 0 {
+ f.DecMapInt64Float32L(*vp, containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (_ fastpathT) DecMapBoolFloat32V(v map[bool]float32, canChange bool,
- d *Decoder) (_ map[bool]float32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 5)
- v = make(map[bool]float32, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk bool
+func (fastpathT) DecMapInt64Float32L(v map[int64]float32, containerLen int, d *Decoder) {
+ var mk int64
var mv float32
hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeBool()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = float32(chkOvf.Float32V(dd.DecodeFloat64()))
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
+ mk = d.d.DecodeInt64()
+ d.mapElemValue()
+ mv = float32(d.decodeFloat32())
if v != nil {
v[mk] = mv
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
}
-
-func (d *Decoder) fastpathDecMapBoolFloat64R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[bool]float64)
- v, changed := fastpathTV.DecMapBoolFloat64V(*vp, true, d)
- if changed {
- *vp = v
+func (d *Decoder) fastpathDecMapInt64Float64R(f *codecFnInfo, rv reflect.Value) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ if rv.Kind() == reflect.Ptr {
+ *(rv2i(rv).(*map[int64]float64)) = nil
}
} else {
- fastpathTV.DecMapBoolFloat64V(rv2i(rv).(map[bool]float64), false, d)
+ if rv.Kind() == reflect.Ptr {
+ vp, _ := rv2i(rv).(*map[int64]float64)
+ if *vp == nil {
+ *vp = make(map[int64]float64, decInferLen(containerLen, d.h.MaxInitLen, 16))
+ }
+ if containerLen != 0 {
+ fastpathTV.DecMapInt64Float64L(*vp, containerLen, d)
+ }
+ } else if containerLen != 0 {
+ fastpathTV.DecMapInt64Float64L(rv2i(rv).(map[int64]float64), containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (f fastpathT) DecMapBoolFloat64X(vp *map[bool]float64, d *Decoder) {
- v, changed := f.DecMapBoolFloat64V(*vp, true, d)
- if changed {
- *vp = v
+func (f fastpathT) DecMapInt64Float64X(vp *map[int64]float64, d *Decoder) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ *vp = nil
+ } else {
+ if *vp == nil {
+ *vp = make(map[int64]float64, decInferLen(containerLen, d.h.MaxInitLen, 16))
+ }
+ if containerLen != 0 {
+ f.DecMapInt64Float64L(*vp, containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (_ fastpathT) DecMapBoolFloat64V(v map[bool]float64, canChange bool,
- d *Decoder) (_ map[bool]float64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
- v = make(map[bool]float64, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk bool
+func (fastpathT) DecMapInt64Float64L(v map[int64]float64, containerLen int, d *Decoder) {
+ var mk int64
var mv float64
hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeBool()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
- }
- continue
- }
- mv = dd.DecodeFloat64()
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
+ mk = d.d.DecodeInt64()
+ d.mapElemValue()
+ mv = d.d.DecodeFloat64()
if v != nil {
v[mk] = mv
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
}
-
-func (d *Decoder) fastpathDecMapBoolBoolR(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[bool]bool)
- v, changed := fastpathTV.DecMapBoolBoolV(*vp, true, d)
- if changed {
- *vp = v
+func (d *Decoder) fastpathDecMapInt64BoolR(f *codecFnInfo, rv reflect.Value) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ if rv.Kind() == reflect.Ptr {
+ *(rv2i(rv).(*map[int64]bool)) = nil
}
} else {
- fastpathTV.DecMapBoolBoolV(rv2i(rv).(map[bool]bool), false, d)
+ if rv.Kind() == reflect.Ptr {
+ vp, _ := rv2i(rv).(*map[int64]bool)
+ if *vp == nil {
+ *vp = make(map[int64]bool, decInferLen(containerLen, d.h.MaxInitLen, 9))
+ }
+ if containerLen != 0 {
+ fastpathTV.DecMapInt64BoolL(*vp, containerLen, d)
+ }
+ } else if containerLen != 0 {
+ fastpathTV.DecMapInt64BoolL(rv2i(rv).(map[int64]bool), containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (f fastpathT) DecMapBoolBoolX(vp *map[bool]bool, d *Decoder) {
- v, changed := f.DecMapBoolBoolV(*vp, true, d)
- if changed {
- *vp = v
+func (f fastpathT) DecMapInt64BoolX(vp *map[int64]bool, d *Decoder) {
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ *vp = nil
+ } else {
+ if *vp == nil {
+ *vp = make(map[int64]bool, decInferLen(containerLen, d.h.MaxInitLen, 9))
+ }
+ if containerLen != 0 {
+ f.DecMapInt64BoolL(*vp, containerLen, d)
+ }
+ d.mapEnd()
}
}
-func (_ fastpathT) DecMapBoolBoolV(v map[bool]bool, canChange bool,
- d *Decoder) (_ map[bool]bool, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 2)
- v = make(map[bool]bool, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- d.depthIncr()
- var mk bool
+func (fastpathT) DecMapInt64BoolL(v map[int64]bool, containerLen int, d *Decoder) {
+ var mk int64
var mv bool
hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep {
- dd.ReadMapElemKey()
- }
- mk = dd.DecodeBool()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = false
- }
- continue
- }
- mv = dd.DecodeBool()
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
+ mk = d.d.DecodeInt64()
+ d.mapElemValue()
+ mv = d.d.DecodeBool()
if v != nil {
v[mk] = mv
}
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
}
diff --git a/vendor/github.com/ugorji/go/codec/fast-path.go.tmpl b/vendor/github.com/ugorji/go/codec/fast-path.go.tmpl
index 40c2827..537f069 100644
--- a/vendor/github.com/ugorji/go/codec/fast-path.go.tmpl
+++ b/vendor/github.com/ugorji/go/codec/fast-path.go.tmpl
@@ -10,7 +10,7 @@ package codec
// Fast path functions try to create a fast path encode or decode implementation
// for common maps and slices.
//
-// We define the functions and register then in this single file
+// We define the functions and register them in this single file
// so as not to pollute the encode.go and decode.go, and create a dependency in there.
// This file can be omitted without causing a build failure.
//
@@ -18,9 +18,10 @@ package codec
// - Many calls bypass reflection altogether
//
// Currently support
-// - slice of all builtin types,
-// - map of all builtin types to string or interface value
-// - symmetrical maps of all builtin types (e.g. str-str, uint8-uint8)
+// - slice of all builtin types (numeric, bool, string, []byte)
+// - maps of builtin types to builtin or interface{} type, EXCEPT FOR
+// keys of type uintptr, int8/16/32, uint16/32, float32/64, bool, interface{}
+// AND values of type type int8/16/32, uint16/32
// This should provide adequate "typical" implementations.
//
// Note that fast track decode functions must handle values for which an address cannot be obtained.
@@ -30,6 +31,24 @@ package codec
// // decoding into p2 will bomb if fast track functions do not treat like unaddressable.
//
+{{/*
+fastpathEncMapStringUint64R (called by fastpath...switch)
+EncMapStringUint64V (called by codecgen)
+
+fastpathEncSliceBoolR: (called by fastpath...switch) (checks f.ti.mbs and calls one of them below)
+EncSliceBoolV (also called by codecgen)
+EncAsMapSliceBoolV (delegate when mapbyslice=true)
+
+fastpathDecSliceIntfR (called by fastpath...switch) (calls Y or N below depending on if it can be updated)
+DecSliceIntfX (called by codecgen) (calls Y below)
+DecSliceIntfY (delegate when slice CAN be updated)
+DecSliceIntfN (delegate when slice CANNOT be updated e.g. from array or non-addressable slice)
+
+fastpathDecMap...R (called by fastpath...switch) (calls L or X? below)
+DecMap...X (called by codecgen)
+DecMap...L (delegated to by both above)
+*/ -}}
+
import (
"reflect"
"sort"
@@ -94,11 +113,13 @@ func init() {
i++
}
{{/* do not register []uint8 in fast-path */}}
- {{range .Values}}{{if not .Primitive}}{{if not .MapKey }}{{if ne .Elem "uint8"}}
- fn([]{{ .Elem }}(nil), (*Encoder).{{ .MethodNamePfx "fastpathEnc" false }}R, (*Decoder).{{ .MethodNamePfx "fastpathDec" false }}R){{end}}{{end}}{{end}}{{end}}
+ {{range .Values}}{{if not .Primitive}}{{if not .MapKey }}{{if ne .Elem "uint8" -}}
+ fn([]{{ .Elem }}(nil), (*Encoder).{{ .MethodNamePfx "fastpathEnc" false }}R, (*Decoder).{{ .MethodNamePfx "fastpathDec" false }}R)
+ {{end}}{{end}}{{end}}{{end}}
- {{range .Values}}{{if not .Primitive}}{{if .MapKey }}
- fn(map[{{ .MapKey }}]{{ .Elem }}(nil), (*Encoder).{{ .MethodNamePfx "fastpathEnc" false }}R, (*Decoder).{{ .MethodNamePfx "fastpathDec" false }}R){{end}}{{end}}{{end}}
+ {{range .Values}}{{if not .Primitive}}{{if .MapKey -}}
+ fn(map[{{ .MapKey }}]{{ .Elem }}(nil), (*Encoder).{{ .MethodNamePfx "fastpathEnc" false }}R, (*Decoder).{{ .MethodNamePfx "fastpathDec" false }}R)
+ {{end}}{{end}}{{end}}
sort.Sort(fastpathAslice(fastpathAV[:]))
}
@@ -108,60 +129,28 @@ func init() {
// -- -- fast path type switch
func fastpathEncodeTypeSwitch(iv interface{}, e *Encoder) bool {
switch v := iv.(type) {
-
-{{range .Values}}{{if not .Primitive}}{{if not .MapKey }}{{if ne .Elem "uint8"}}
+{{range .Values}}{{if not .Primitive}}{{if not .MapKey }}{{if ne .Elem "uint8" -}}
case []{{ .Elem }}:
fastpathTV.{{ .MethodNamePfx "Enc" false }}V(v, e)
case *[]{{ .Elem }}:
- fastpathTV.{{ .MethodNamePfx "Enc" false }}V(*v, e){{/*
-*/}}{{end}}{{end}}{{end}}{{end}}
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.{{ .MethodNamePfx "Enc" false }}V(*v, e)
+ }
+{{end}}{{end}}{{end}}{{end -}}
-{{range .Values}}{{if not .Primitive}}{{if .MapKey }}
+{{range .Values}}{{if not .Primitive}}{{if .MapKey -}}
case map[{{ .MapKey }}]{{ .Elem }}:
fastpathTV.{{ .MethodNamePfx "Enc" false }}V(v, e)
case *map[{{ .MapKey }}]{{ .Elem }}:
- fastpathTV.{{ .MethodNamePfx "Enc" false }}V(*v, e){{/*
-*/}}{{end}}{{end}}{{end}}
-
- default:
- _ = v // workaround https://github.com/golang/go/issues/12927 seen in go1.4
- return false
- }
- return true
-}
-
-{{/*
-**** removing this block, as they are never called directly ****
-
-
-
-**** removing this block, as they are never called directly ****
-
-
-
-func fastpathEncodeTypeSwitchSlice(iv interface{}, e *Encoder) bool {
- switch v := iv.(type) {
-{{range .Values}}{{if not .Primitive}}{{if not .MapKey }}
- case []{{ .Elem }}:
- fastpathTV.{{ .MethodNamePfx "Enc" false }}V(v, e)
- case *[]{{ .Elem }}:
- fastpathTV.{{ .MethodNamePfx "Enc" false }}V(*v, e)
-{{end}}{{end}}{{end}}
- default:
- _ = v // workaround https://github.com/golang/go/issues/12927 seen in go1.4
- return false
- }
- return true
-}
+ if *v == nil {
+ e.e.EncodeNil()
+ } else {
+ fastpathTV.{{ .MethodNamePfx "Enc" false }}V(*v, e)
+ }
+{{end}}{{end}}{{end -}}
-func fastpathEncodeTypeSwitchMap(iv interface{}, e *Encoder) bool {
- switch v := iv.(type) {
-{{range .Values}}{{if not .Primitive}}{{if .MapKey }}
- case map[{{ .MapKey }}]{{ .Elem }}:
- fastpathTV.{{ .MethodNamePfx "Enc" false }}V(v, e)
- case *map[{{ .MapKey }}]{{ .Elem }}:
- fastpathTV.{{ .MethodNamePfx "Enc" false }}V(*v, e)
-{{end}}{{end}}{{end}}
default:
_ = v // workaround https://github.com/golang/go/issues/12927 seen in go1.4
return false
@@ -169,17 +158,8 @@ func fastpathEncodeTypeSwitchMap(iv interface{}, e *Encoder) bool {
return true
}
-
-
-**** removing this block, as they are never called directly ****
-
-
-
-**** removing this block, as they are never called directly ****
-*/}}
-
// -- -- fast path functions
-{{range .Values}}{{if not .Primitive}}{{if not .MapKey }}
+{{range .Values}}{{if not .Primitive}}{{if not .MapKey -}}
func (e *Encoder) {{ .MethodNamePfx "fastpathEnc" false }}R(f *codecFnInfo, rv reflect.Value) {
if f.ti.mbs {
fastpathTV.{{ .MethodNamePfx "EncAsMap" false }}V(rv2i(rv).([]{{ .Elem }}), e)
@@ -187,76 +167,48 @@ func (e *Encoder) {{ .MethodNamePfx "fastpathEnc" false }}R(f *codecFnInfo, rv r
fastpathTV.{{ .MethodNamePfx "Enc" false }}V(rv2i(rv).([]{{ .Elem }}), e)
}
}
-func (_ fastpathT) {{ .MethodNamePfx "Enc" false }}V(v []{{ .Elem }}, e *Encoder) {
- if v == nil { e.e.EncodeNil(); return }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteArrayStart(len(v))
- if esep {
- for _, v2 := range v {
- ee.WriteArrayElem()
- {{ encmd .Elem "v2"}}
- }
- } else {
- for _, v2 := range v {
- {{ encmd .Elem "v2"}}
- }
- } {{/*
- for _, v2 := range v {
- if esep { ee.WriteArrayElem() }
- {{ encmd .Elem "v2"}}
- } */}}
- ee.WriteArrayEnd()
+func (fastpathT) {{ .MethodNamePfx "Enc" false }}V(v []{{ .Elem }}, e *Encoder) {
+ {{/* if v == nil { e.e.EncodeNil(); return } */ -}}
+ e.arrayStart(len(v))
+ for j := range v {
+ e.arrayElem()
+ {{ encmd .Elem "v[j]"}}
+ }
+ e.arrayEnd()
}
-func (_ fastpathT) {{ .MethodNamePfx "EncAsMap" false }}V(v []{{ .Elem }}, e *Encoder) {
- ee, esep := e.e, e.hh.hasElemSeparators()
+func (fastpathT) {{ .MethodNamePfx "EncAsMap" false }}V(v []{{ .Elem }}, e *Encoder) {
+ {{/* if v == nil { e.e.EncodeNil() } else */ -}}
if len(v)%2 == 1 {
e.errorf(fastpathMapBySliceErrMsg, len(v))
- return
- }
- ee.WriteMapStart(len(v) / 2)
- if esep {
- for j, v2 := range v {
- if j%2 == 0 {
- ee.WriteMapElemKey()
- } else {
- ee.WriteMapElemValue()
- }
- {{ encmd .Elem "v2"}}
- }
} else {
- for _, v2 := range v {
- {{ encmd .Elem "v2"}}
- }
- } {{/*
- for j, v2 := range v {
- if esep {
+ e.mapStart(len(v) / 2)
+ for j := range v {
if j%2 == 0 {
- ee.WriteMapElemKey()
+ e.mapElemKey()
} else {
- ee.WriteMapElemValue()
+ e.mapElemValue()
}
- }
- {{ encmd .Elem "v2"}}
- } */}}
- ee.WriteMapEnd()
+ {{ encmd .Elem "v[j]"}}
+ }
+ e.mapEnd()
+ }
}
-{{end}}{{end}}{{end}}
+{{end}}{{end}}{{end -}}
-{{range .Values}}{{if not .Primitive}}{{if .MapKey }}
+{{range .Values}}{{if not .Primitive}}{{if .MapKey -}}
func (e *Encoder) {{ .MethodNamePfx "fastpathEnc" false }}R(f *codecFnInfo, rv reflect.Value) {
fastpathTV.{{ .MethodNamePfx "Enc" false }}V(rv2i(rv).(map[{{ .MapKey }}]{{ .Elem }}), e)
}
-func (_ fastpathT) {{ .MethodNamePfx "Enc" false }}V(v map[{{ .MapKey }}]{{ .Elem }}, e *Encoder) {
- if v == nil { e.e.EncodeNil(); return }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- {{if eq .MapKey "interface{}"}}{{/* out of band
- */}}var mksv []byte = make([]byte, 0, len(v)*16) // temporary byte slice for the encoding
+func (fastpathT) {{ .MethodNamePfx "Enc" false }}V(v map[{{ .MapKey }}]{{ .Elem }}, e *Encoder) {
+ {{/* if v == nil { e.e.EncodeNil(); return } */ -}}
+ e.mapStart(len(v))
+ if e.h.Canonical { {{/* need to figure out .NoCanonical */}}
+ {{if eq .MapKey "interface{}"}}{{/* out of band */ -}}
+ var mksv []byte = make([]byte, 0, len(v)*16) // temporary byte slice for the encoding
e2 := NewEncoderBytes(&mksv, e.hh)
- v2 := make([]bytesI, len(v))
- var i, l uint
- var vp *bytesI {{/* put loop variables outside. seems currently needed for better perf */}}
+ v2 := make([]bytesIntf, len(v))
+ var i, l uint {{/* put loop variables outside. seems currently needed for better perf */}}
+ var vp *bytesIntf
for k2 := range v {
l = uint(len(mksv))
e2.MustEncode(k2)
@@ -265,108 +217,81 @@ func (_ fastpathT) {{ .MethodNamePfx "Enc" false }}V(v map[{{ .MapKey }}]{{ .Ele
vp.i = k2
i++
}
- sort.Sort(bytesISlice(v2))
- if esep {
- for j := range v2 {
- ee.WriteMapElemKey()
- e.asis(v2[j].v)
- ee.WriteMapElemValue()
- e.encode(v[v2[j].i])
- }
- } else {
- for j := range v2 {
- e.asis(v2[j].v)
- e.encode(v[v2[j].i])
- }
- } {{/*
+ sort.Sort(bytesIntfSlice(v2))
for j := range v2 {
- if esep { ee.WriteMapElemKey() }
+ e.mapElemKey()
e.asis(v2[j].v)
- if esep { ee.WriteMapElemValue() }
+ e.mapElemValue()
e.encode(v[v2[j].i])
- } */}} {{else}}{{ $x := sorttype .MapKey true}}v2 := make([]{{ $x }}, len(v))
+ } {{else}}{{ $x := sorttype .MapKey true}}v2 := make([]{{ $x }}, len(v))
var i uint
for k := range v {
- v2[i] = {{ $x }}(k)
+ v2[i] = {{if eq $x .MapKey}}k{{else}}{{ $x }}(k){{end}}
i++
}
sort.Sort({{ sorttype .MapKey false}}(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- {{if eq .MapKey "string"}}ee.EncodeStringEnc(cUTF8, k2){{else}}{{ $y := printf "%s(k2)" .MapKey }}{{ encmd .MapKey $y }}{{end}}
- ee.WriteMapElemValue()
- {{ $y := printf "v[%s(k2)]" .MapKey }}{{ encmd .Elem $y }}
- }
- } else {
- for _, k2 := range v2 {
- {{if eq .MapKey "string"}}ee.EncodeStringEnc(cUTF8, k2){{else}}{{ $y := printf "%s(k2)" .MapKey }}{{ encmd .MapKey $y }}{{end}}
- {{ $y := printf "v[%s(k2)]" .MapKey }}{{ encmd .Elem $y }}
- }
- } {{/*
for _, k2 := range v2 {
- if esep { ee.WriteMapElemKey() }
- {{if eq .MapKey "string"}}ee.EncodeStringEnc(cUTF8, k2){{else}}{{ $y := printf "%s(k2)" .MapKey }}{{ encmd .MapKey $y }}{{end}}
- if esep { ee.WriteMapElemValue() }
- {{ $y := printf "v[%s(k2)]" .MapKey }}{{ encmd .Elem $y }}
- } */}} {{end}}
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- {{if eq .MapKey "string"}}ee.EncodeStringEnc(cUTF8, k2){{else}}{{ encmd .MapKey "k2"}}{{end}}
- ee.WriteMapElemValue()
- {{ encmd .Elem "v2"}}
- }
- } else {
- for k2, v2 := range v {
- {{if eq .MapKey "string"}}ee.EncodeStringEnc(cUTF8, k2){{else}}{{ encmd .MapKey "k2"}}{{end}}
- {{ encmd .Elem "v2"}}
- }
- } {{/*
+ e.mapElemKey()
+ {{if eq .MapKey "string"}} e.e.EncodeString(k2) {{else}}{{ $y := printf "%s(k2)" .MapKey }}{{if eq $x .MapKey }}{{ $y = "k2" }}{{end}}{{ encmd .MapKey $y }}{{end}}
+ e.mapElemValue()
+ {{ $y := printf "v[%s(k2)]" .MapKey }}{{if eq $x .MapKey }}{{ $y = "v[k2]" }}{{end}}{{ encmd .Elem $y }}
+ } {{end}}
+ } else {
for k2, v2 := range v {
- if esep { ee.WriteMapElemKey() }
- {{if eq .MapKey "string"}}ee.EncodeStringEnc(cUTF8, k2){{else}}{{ encmd .MapKey "k2"}}{{end}}
- if esep { ee.WriteMapElemValue() }
+ e.mapElemKey()
+ {{if eq .MapKey "string"}} e.e.EncodeString(k2) {{else}}{{ encmd .MapKey "k2"}}{{end}}
+ e.mapElemValue()
{{ encmd .Elem "v2"}}
- } */}}
+ }
}
- ee.WriteMapEnd()
+ e.mapEnd()
}
-{{end}}{{end}}{{end}}
+{{end}}{{end}}{{end -}}
// -- decode
// -- -- fast path type switch
func fastpathDecodeTypeSwitch(iv interface{}, d *Decoder) bool {
- var changed bool
+ var changed bool
+ var containerLen int
switch v := iv.(type) {
-{{range .Values}}{{if not .Primitive}}{{if not .MapKey }}{{if ne .Elem "uint8"}}
+{{range .Values}}{{if not .Primitive}}{{if not .MapKey }}{{if ne .Elem "uint8" -}}
case []{{ .Elem }}:
- var v2 []{{ .Elem }}
- v2, changed = fastpathTV.{{ .MethodNamePfx "Dec" false }}V(v, false, d)
- if changed && len(v) > 0 && len(v2) > 0 && !(len(v2) == len(v) && &v2[0] == &v[0]) {
- copy(v, v2)
- }
+ fastpathTV.{{ .MethodNamePfx "Dec" false }}N(v, d)
case *[]{{ .Elem }}:
var v2 []{{ .Elem }}
- v2, changed = fastpathTV.{{ .MethodNamePfx "Dec" false }}V(*v, true, d)
- if changed {
- *v = v2
- }{{/*
-*/}}{{end}}{{end}}{{end}}{{end}}
+ if v2, changed = fastpathTV.{{ .MethodNamePfx "Dec" false }}Y(*v, d); changed {
+ *v = v2
+ }
+{{end}}{{end}}{{end}}{{end -}}
{{range .Values}}{{if not .Primitive}}{{if .MapKey }}{{/*
// maps only change if nil, and in that case, there's no point copying
-*/}}
+*/ -}}
case map[{{ .MapKey }}]{{ .Elem }}:
- fastpathTV.{{ .MethodNamePfx "Dec" false }}V(v, false, d)
+ containerLen = d.mapStart()
+ if containerLen != decContainerLenNil {
+ if containerLen != 0 {
+ fastpathTV.{{ .MethodNamePfx "Dec" false }}L(v, containerLen, d)
+ }
+ d.mapEnd()
+ }
case *map[{{ .MapKey }}]{{ .Elem }}:
- var v2 map[{{ .MapKey }}]{{ .Elem }}
- v2, changed = fastpathTV.{{ .MethodNamePfx "Dec" false }}V(*v, true, d)
- if changed {
- *v = v2
- }{{/*
-*/}}{{end}}{{end}}{{end}}
+ {{/*
+ containerLen = d.mapStart()
+ if containerLen == 0 {
+ d.mapEnd()
+ } else if containerLen == decContainerLenNil {
+ *v = nil
+ } else {
+ if *v == nil {
+ *v = make(map[{{ .MapKey }}]{{ .Elem }}, decInferLen(containerLen, d.h.MaxInitLen, {{ .Size }}))
+ }
+ fastpathTV.{{ .MethodNamePfx "Dec" false }}L(*v, containerLen, d)
+ }
+ // consider delegating fully to X - encoding *map is uncommon, so ok to pay small function call cost
+ */ -}}
+ fastpathTV.{{ .MethodNamePfx "Dec" false }}X(v, d)
+{{end}}{{end}}{{end -}}
default:
_ = v // workaround https://github.com/golang/go/issues/12927 seen in go1.4
return false
@@ -376,14 +301,14 @@ func fastpathDecodeTypeSwitch(iv interface{}, d *Decoder) bool {
func fastpathDecodeSetZeroTypeSwitch(iv interface{}) bool {
switch v := iv.(type) {
-{{range .Values}}{{if not .Primitive}}{{if not .MapKey }}
+{{range .Values}}{{if not .Primitive}}{{if not .MapKey -}}
case *[]{{ .Elem }}:
- *v = nil {{/*
-*/}}{{end}}{{end}}{{end}}
-{{range .Values}}{{if not .Primitive}}{{if .MapKey }}
+ *v = nil
+{{end}}{{end}}{{end}}
+{{range .Values}}{{if not .Primitive}}{{if .MapKey -}}
case *map[{{ .MapKey }}]{{ .Elem }}:
- *v = nil {{/*
-*/}}{{end}}{{end}}{{end}}
+ *v = nil
+{{end}}{{end}}{{end}}
default:
_ = v // workaround https://github.com/golang/go/issues/12927 seen in go1.4
return false
@@ -392,47 +317,38 @@ func fastpathDecodeSetZeroTypeSwitch(iv interface{}) bool {
}
// -- -- fast path functions
-{{range .Values}}{{if not .Primitive}}{{if not .MapKey }}
+{{range .Values}}{{if not .Primitive}}{{if not .MapKey -}}
{{/*
-Slices can change if they
+Slices can change if they
- did not come from an array
- are addressable (from a ptr)
- are settable (e.g. contained in an interface{})
*/}}
func (d *Decoder) {{ .MethodNamePfx "fastpathDec" false }}R(f *codecFnInfo, rv reflect.Value) {
- if array := f.seq == seqTypeArray; !array && rv.Kind() == reflect.Ptr {
+ if f.seq != seqTypeArray && rv.Kind() == reflect.Ptr {
vp := rv2i(rv).(*[]{{ .Elem }})
- v, changed := fastpathTV.{{ .MethodNamePfx "Dec" false }}V(*vp, !array, d)
- if changed { *vp = v }
+ if v, changed := fastpathTV.{{ .MethodNamePfx "Dec" false }}Y(*vp, d); changed { *vp = v }
} else {
- v := rv2i(rv).([]{{ .Elem }})
- v2, changed := fastpathTV.{{ .MethodNamePfx "Dec" false }}V(v, !array, d)
- if changed && len(v) > 0 && len(v2) > 0 && !(len(v2) == len(v) && &v2[0] == &v[0]) {
- copy(v, v2)
- }
+ fastpathTV.{{ .MethodNamePfx "Dec" false }}N(rv2i(rv).([]{{ .Elem }}), d)
}
}
func (f fastpathT) {{ .MethodNamePfx "Dec" false }}X(vp *[]{{ .Elem }}, d *Decoder) {
- v, changed := f.{{ .MethodNamePfx "Dec" false }}V(*vp, true, d)
- if changed { *vp = v }
+ if v, changed := f.{{ .MethodNamePfx "Dec" false }}Y(*vp, d); changed { *vp = v }
}
-func (_ fastpathT) {{ .MethodNamePfx "Dec" false }}V(v []{{ .Elem }}, canChange bool, d *Decoder) (_ []{{ .Elem }}, changed bool) {
- dd := d.d{{/*
- // if dd.isContainerType(valueTypeNil) { dd.TryDecodeAsNil()
- */}}
+func (fastpathT) {{ .MethodNamePfx "Dec" false }}Y(v []{{ .Elem }}, d *Decoder) (_ []{{ .Elem }}, changed bool) {
slh, containerLenS := d.decSliceHelperStart()
+ if slh.IsNil {
+ if v == nil { return }
+ return nil, true
+ }
if containerLenS == 0 {
- if canChange {
- if v == nil { v = []{{ .Elem }}{} } else if len(v) != 0 { v = v[:0] }
- changed = true
- }
+ if v == nil { v = []{{ .Elem }}{} } else if len(v) != 0 { v = v[:0] }
slh.End()
- return v, changed
+ return v, true
}
- d.depthIncr()
hasLen := containerLenS > 0
var xlen int
- if hasLen && canChange {
+ if hasLen {
if containerLenS > cap(v) {
xlen = decInferLen(containerLenS, d.h.MaxInitLen, {{ .Size }})
if xlen <= cap(v) {
@@ -447,8 +363,8 @@ func (_ fastpathT) {{ .MethodNamePfx "Dec" false }}V(v []{{ .Elem }}, canChange
}
}
var j int
- for j = 0; (hasLen && j < containerLenS) || !(hasLen || dd.CheckBreak()); j++ {
- if j == 0 && len(v) == 0 && canChange {
+ for j = 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ {
+ if j == 0 && len(v) == 0 {
if hasLen {
xlen = decInferLen(containerLenS, d.h.MaxInitLen, {{ .Size }})
} else {
@@ -457,98 +373,131 @@ func (_ fastpathT) {{ .MethodNamePfx "Dec" false }}V(v []{{ .Elem }}, canChange
v = make([]{{ .Elem }}, uint(xlen))
changed = true
}
- // if indefinite, etc, then expand the slice if necessary
- var decodeIntoBlank bool
+ {{/* // if indefinite, etc, then expand the slice if necessary */ -}}
if j >= len(v) {
- if canChange {
- v = append(v, {{ zerocmd .Elem }})
- changed = true
- } else {
- d.arrayCannotExpand(len(v), j+1)
- decodeIntoBlank = true
- }
+ v = append(v, {{ zerocmd .Elem }})
+ changed = true
}
slh.ElemContainerState(j)
- if decodeIntoBlank {
- d.swallow()
- } else if dd.TryDecodeAsNil() {
- v[uint(j)] = {{ zerocmd .Elem }}
- } else {
- {{ if eq .Elem "interface{}" }}d.decode(&v[uint(j)]){{ else }}v[uint(j)] = {{ decmd .Elem }}{{ end }}
- }
+ {{ if eq .Elem "interface{}" }}d.decode(&v[uint(j)]){{ else }}v[uint(j)] = {{ decmd .Elem }}{{ end }}
}
- if canChange {
- if j < len(v) {
- v = v[:uint(j)]
- changed = true
- } else if j == 0 && v == nil {
- v = make([]{{ .Elem }}, 0)
- changed = true
- }
+ if j < len(v) {
+ v = v[:uint(j)]
+ changed = true
+ } else if j == 0 && v == nil {
+ v = []{{ .Elem }}{}
+ changed = true
}
slh.End()
- d.depthDecr()
return v, changed
}
-{{end}}{{end}}{{end}}
+func (fastpathT) {{ .MethodNamePfx "Dec" false }}N(v []{{ .Elem }}, d *Decoder) {
+ slh, containerLenS := d.decSliceHelperStart()
+ if slh.IsNil {
+ return
+ }
+ if containerLenS == 0 {
+ slh.End()
+ return
+ }
+ hasLen := containerLenS > 0
+ for j := 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ {
+ {{/* // if indefinite, etc, then expand the slice if necessary */ -}}
+ if j >= len(v) {
+ fastpathDecArrayCannotExpand(slh, hasLen, len(v), j, containerLenS)
+ return
+ }
+ slh.ElemContainerState(j)
+ {{ if eq .Elem "interface{}" -}}
+ d.decode(&v[uint(j)])
+ {{- else -}}
+ v[uint(j)] = {{ decmd .Elem }}
+ {{- end }}
+ }
+ slh.End()
+}
+{{end}}{{end}}{{end -}}
+
+func fastpathDecArrayCannotExpand(slh decSliceHelper, hasLen bool, lenv, j, containerLenS int) {
+ slh.d.arrayCannotExpand(lenv, j+1)
+ slh.ElemContainerState(j)
+ slh.d.swallow()
+ j++
+ for ; (hasLen && j < containerLenS) || !(hasLen || slh.d.checkBreak()); j++ {
+ slh.ElemContainerState(j)
+ slh.d.swallow()
+ }
+ slh.End()
+}
-{{range .Values}}{{if not .Primitive}}{{if .MapKey }}
+{{range .Values}}{{if not .Primitive}}{{if .MapKey -}}
{{/*
Maps can change if they are
- addressable (from a ptr)
- settable (e.g. contained in an interface{})
-*/}}
+*/ -}}
func (d *Decoder) {{ .MethodNamePfx "fastpathDec" false }}R(f *codecFnInfo, rv reflect.Value) {
- if rv.Kind() == reflect.Ptr {
- vp := rv2i(rv).(*map[{{ .MapKey }}]{{ .Elem }})
- v, changed := fastpathTV.{{ .MethodNamePfx "Dec" false }}V(*vp, true, d);
- if changed { *vp = v }
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ if rv.Kind() == reflect.Ptr {
+ *(rv2i(rv).(*map[{{ .MapKey }}]{{ .Elem }})) = nil
+ }
} else {
- fastpathTV.{{ .MethodNamePfx "Dec" false }}V(rv2i(rv).(map[{{ .MapKey }}]{{ .Elem }}), false, d)
+ if rv.Kind() == reflect.Ptr {
+ vp, _ := rv2i(rv).(*map[{{ .MapKey }}]{{ .Elem }})
+ if *vp == nil {
+ *vp = make(map[{{ .MapKey }}]{{ .Elem }}, decInferLen(containerLen, d.h.MaxInitLen, {{ .Size }}))
+ }
+ if containerLen != 0 {
+ fastpathTV.{{ .MethodNamePfx "Dec" false }}L(*vp, containerLen, d)
+ }
+ } else if containerLen != 0 {
+ fastpathTV.{{ .MethodNamePfx "Dec" false }}L(rv2i(rv).(map[{{ .MapKey }}]{{ .Elem }}), containerLen, d)
+ }
+ d.mapEnd()
}
}
func (f fastpathT) {{ .MethodNamePfx "Dec" false }}X(vp *map[{{ .MapKey }}]{{ .Elem }}, d *Decoder) {
- v, changed := f.{{ .MethodNamePfx "Dec" false }}V(*vp, true, d)
- if changed { *vp = v }
-}
-func (_ fastpathT) {{ .MethodNamePfx "Dec" false }}V(v map[{{ .MapKey }}]{{ .Elem }}, canChange bool,
- d *Decoder) (_ map[{{ .MapKey }}]{{ .Elem }}, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators(){{/*
- // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil()
- */}}
- containerLen := dd.ReadMapStart()
- if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, {{ .Size }})
- v = make(map[{{ .MapKey }}]{{ .Elem }}, xlen)
- changed = true
- }
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
+ containerLen := d.mapStart()
+ if containerLen == decContainerLenNil {
+ *vp = nil
+ } else {
+ if *vp == nil {
+ *vp = make(map[{{ .MapKey }}]{{ .Elem }}, decInferLen(containerLen, d.h.MaxInitLen, {{ .Size }}))
+ }
+ if containerLen != 0 {
+ f.{{ .MethodNamePfx "Dec" false }}L(*vp, containerLen, d)
+ }
+ d.mapEnd()
}
- d.depthIncr()
- {{ if eq .Elem "interface{}" }}mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset
- {{end}}var mk {{ .MapKey }}
+}
+func (fastpathT) {{ .MethodNamePfx "Dec" false }}L(v map[{{ .MapKey }}]{{ .Elem }}, containerLen int, d *Decoder) {
+ {{/* No need to check if containerLen == decContainerLenNil, as that is checked by R and L above */ -}}
+ {{if eq .Elem "interface{}" }}mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset
+ {{else if eq .Elem "bytes" "[]byte" }}mapGet := v != nil && !d.h.MapValueReset
+ {{end -}}
+ var mk {{ .MapKey }}
var mv {{ .Elem }}
hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep { dd.ReadMapElemKey() }
+ for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ {
+ d.mapElemKey()
{{ if eq .MapKey "interface{}" }}mk = nil
d.decode(&mk)
if bv, bok := mk.([]byte); bok {
mk = d.string(bv) {{/* // maps cannot have []byte as key. switch to string. */}}
}{{ else }}mk = {{ decmd .MapKey }}{{ end }}
- if esep { dd.ReadMapElemValue() }
- if dd.TryDecodeAsNil() {
- if v == nil {} else if d.h.DeleteOnNilMapValue { delete(v, mk) } else { v[mk] = {{ zerocmd .Elem }} }
- continue
- }
- {{ if eq .Elem "interface{}" }}if mapGet { mv = v[mk] } else { mv = nil }
- d.decode(&mv){{ else }}mv = {{ decmd .Elem }}{{ end }}
+ d.mapElemValue()
+ {{ if eq .Elem "interface{}" "[]byte" "bytes" -}}
+ if mapGet { mv = v[mk] } else { mv = nil }
+ {{ end -}}
+ {{ if eq .Elem "interface{}" -}}
+ d.decode(&mv)
+ {{ else if eq .Elem "[]byte" "bytes" -}}
+ mv = d.d.DecodeBytes(mv, false)
+ {{ else -}}
+ mv = {{ decmd .Elem }}
+ {{ end -}}
if v != nil { v[mk] = mv }
}
- dd.ReadMapEnd()
- d.depthDecr()
- return v, changed
}
{{end}}{{end}}{{end}}
diff --git a/vendor/github.com/ugorji/go/codec/fast-path.not.go b/vendor/github.com/ugorji/go/codec/fast-path.not.go
index cf97db0..6b6ac1f 100644
--- a/vendor/github.com/ugorji/go/codec/fast-path.not.go
+++ b/vendor/github.com/ugorji/go/codec/fast-path.not.go
@@ -34,12 +34,6 @@ type fastpathA [0]fastpathE
func (x fastpathA) index(rtid uintptr) int { return -1 }
-func (_ fastpathT) DecSliceUint8V(v []uint8, canChange bool, d *Decoder) (_ []uint8, changed bool) {
- fn := d.h.fn(uint8SliceTyp, true, true)
- d.kSlice(&fn.i, reflect.ValueOf(&v).Elem())
- return v, true
-}
-
var fastpathAV fastpathA
var fastpathTV fastpathT
diff --git a/vendor/github.com/ugorji/go/codec/gen-dec-array.go.tmpl b/vendor/github.com/ugorji/go/codec/gen-dec-array.go.tmpl
index 790e914..d2caa0b 100644
--- a/vendor/github.com/ugorji/go/codec/gen-dec-array.go.tmpl
+++ b/vendor/github.com/ugorji/go/codec/gen-dec-array.go.tmpl
@@ -1,9 +1,17 @@
{{var "v"}} := {{if not isArray}}*{{end}}{{ .Varname }}
-{{var "h"}}, {{var "l"}} := z.DecSliceHelperStart() {{/* // helper, containerLenS */}}{{if not isArray}}
+{{var "h"}}, {{var "l"}} := z.DecSliceHelperStart() {{/* // helper, containerLenS */}}
+{{if not isArray -}}
var {{var "c"}} bool {{/* // changed */}}
-_ = {{var "c"}}{{end}}
+_ = {{var "c"}}
+if {{var "h"}}.IsNil {
+ if {{var "v"}} != nil {
+ {{var "v"}} = nil
+ {{var "c"}} = true
+ }
+} else {{end -}}
if {{var "l"}} == 0 {
- {{if isSlice }}if {{var "v"}} == nil {
+ {{if isSlice -}}
+ if {{var "v"}} == nil {
{{var "v"}} = []{{ .Typ }}{}
{{var "c"}} = true
} else if len({{var "v"}}) != 0 {
@@ -12,7 +20,8 @@ if {{var "l"}} == 0 {
} {{else if isChan }}if {{var "v"}} == nil {
{{var "v"}} = make({{ .CTyp }}, 0)
{{var "c"}} = true
- } {{end}}
+ }
+ {{end -}}
} else {
{{var "hl"}} := {{var "l"}} > 0
var {{var "rl"}} int
@@ -30,10 +39,11 @@ if {{var "l"}} == 0 {
{{var "v"}} = {{var "v"}}[:{{var "l"}}]
{{var "c"}} = true
}
- } {{end}}
+ }
+ {{end -}}
var {{var "j"}} int
- // var {{var "dn"}} bool
- for {{var "j"}} = 0; ({{var "hl"}} && {{var "j"}} < {{var "l"}}) || !({{var "hl"}} || r.CheckBreak()); {{var "j"}}++ { // bounds-check-elimination
+ {{/* // var {{var "dn"}} bool */ -}}
+ for {{var "j"}} = 0; ({{var "hl"}} && {{var "j"}} < {{var "l"}}) || !({{var "hl"}} || z.DecCheckBreak()); {{var "j"}}++ { // bounds-check-elimination
{{if not isArray}} if {{var "j"}} == 0 && {{var "v"}} == nil {
if {{var "hl"}} {
{{var "rl"}} = z.DecInferLen({{var "l"}}, z.DecBasicHandle().MaxInitLen, {{ .Size }})
@@ -42,27 +52,27 @@ if {{var "l"}} == 0 {
}
{{var "v"}} = make({{if isSlice}}[]{{ .Typ }}{{else if isChan}}{{.CTyp}}{{end}}, {{var "rl"}})
{{var "c"}} = true
- }{{end}}
+ }
+ {{end -}}
{{var "h"}}.ElemContainerState({{var "j"}})
- {{/* {{var "dn"}} = r.TryDecodeAsNil() */}}{{/* commented out, as decLineVar handles this already each time */}}
+ {{/* {{var "dn"}} = r.TryDecodeAsNil() */}}{{/* commented out, as decLineVar handles this already each time */ -}}
{{if isChan}}{{ $x := printf "%[1]vvcx%[2]v" .TempVar .Rand }}var {{$x}} {{ .Typ }}
- {{ decLineVar $x }}
+ {{ decLineVar $x -}}
{{var "v"}} <- {{ $x }}
- // println(">>>> sending ", {{ $x }}, " into ", {{var "v"}}) // TODO: remove this
- {{else}}{{/* // if indefinite, etc, then expand the slice if necessary */}}
+ {{else}}{{/* // if indefinite, etc, then expand the slice if necessary */ -}}
var {{var "db"}} bool
if {{var "j"}} >= len({{var "v"}}) {
{{if isSlice }} {{var "v"}} = append({{var "v"}}, {{ zero }})
{{var "c"}} = true
{{else}} z.DecArrayCannotExpand(len(v), {{var "j"}}+1); {{var "db"}} = true
- {{end}}
+ {{end -}}
}
if {{var "db"}} {
z.DecSwallow()
} else {
- {{ $x := printf "%[1]vv%[2]v[%[1]vj%[2]v]" .TempVar .Rand }}{{ decLineVar $x }}
+ {{ $x := printf "%[1]vv%[2]v[%[1]vj%[2]v]" .TempVar .Rand }}{{ decLineVar $x -}}
}
- {{end}}
+ {{end -}}
}
{{if isSlice}} if {{var "j"}} < len({{var "v"}}) {
{{var "v"}} = {{var "v"}}[:{{var "j"}}]
@@ -70,9 +80,11 @@ if {{var "l"}} == 0 {
} else if {{var "j"}} == 0 && {{var "v"}} == nil {
{{var "v"}} = make([]{{ .Typ }}, 0)
{{var "c"}} = true
- } {{end}}
+ }
+ {{end -}}
}
{{var "h"}}.End()
{{if not isArray }}if {{var "c"}} {
*{{ .Varname }} = {{var "v"}}
-}{{end}}
+}
+{{end -}}
diff --git a/vendor/github.com/ugorji/go/codec/gen-dec-map.go.tmpl b/vendor/github.com/ugorji/go/codec/gen-dec-map.go.tmpl
index 8323b54..35bda4a 100644
--- a/vendor/github.com/ugorji/go/codec/gen-dec-map.go.tmpl
+++ b/vendor/github.com/ugorji/go/codec/gen-dec-map.go.tmpl
@@ -1,42 +1,53 @@
{{var "v"}} := *{{ .Varname }}
-{{var "l"}} := r.ReadMapStart()
-{{var "bh"}} := z.DecBasicHandle()
+{{var "l"}} := z.DecReadMapStart()
+if {{var "l"}} == codecSelferDecContainerLenNil{{xs}} {
+ *{{ .Varname }} = nil
+} else {
if {{var "v"}} == nil {
- {{var "rl"}} := z.DecInferLen({{var "l"}}, {{var "bh"}}.MaxInitLen, {{ .Size }})
+ {{var "rl"}} := z.DecInferLen({{var "l"}}, z.DecBasicHandle().MaxInitLen, {{ .Size }})
{{var "v"}} = make(map[{{ .KTyp }}]{{ .Typ }}, {{var "rl"}})
*{{ .Varname }} = {{var "v"}}
}
var {{var "mk"}} {{ .KTyp }}
var {{var "mv"}} {{ .Typ }}
var {{var "mg"}}, {{var "mdn"}} {{if decElemKindPtr}}, {{var "ms"}}, {{var "mok"}}{{end}} bool
-if {{var "bh"}}.MapValueReset {
+if z.DecBasicHandle().MapValueReset {
{{if decElemKindPtr}}{{var "mg"}} = true
- {{else if decElemKindIntf}}if !{{var "bh"}}.InterfaceReset { {{var "mg"}} = true }
+ {{else if decElemKindIntf}}if !z.DecBasicHandle().InterfaceReset { {{var "mg"}} = true }
{{else if not decElemKindImmutable}}{{var "mg"}} = true
{{end}} }
if {{var "l"}} != 0 {
-{{var "hl"}} := {{var "l"}} > 0
- for {{var "j"}} := 0; ({{var "hl"}} && {{var "j"}} < {{var "l"}}) || !({{var "hl"}} || r.CheckBreak()); {{var "j"}}++ {
- r.ReadMapElemKey() {{/* z.DecSendContainerState(codecSelfer_containerMapKey{{ .Sfx }}) */}}
- {{ $x := printf "%vmk%v" .TempVar .Rand }}{{ decLineVarK $x }}
-{{ if eq .KTyp "interface{}" }}{{/* // special case if a byte array. */}}if {{var "bv"}}, {{var "bok"}} := {{var "mk"}}.([]byte); {{var "bok"}} {
+ {{var "hl"}} := {{var "l"}} > 0
+ for {{var "j"}} := 0; ({{var "hl"}} && {{var "j"}} < {{var "l"}}) || !({{var "hl"}} || z.DecCheckBreak()); {{var "j"}}++ {
+ z.DecReadMapElemKey()
+ {{ $x := printf "%vmk%v" .TempVar .Rand }}{{ decLineVarK $x -}}
+ {{ if eq .KTyp "interface{}" }}{{/* // special case if a byte array. */ -}}
+ if {{var "bv"}}, {{var "bok"}} := {{var "mk"}}.([]byte); {{var "bok"}} {
{{var "mk"}} = string({{var "bv"}})
- }{{ end }}{{if decElemKindPtr}}
- {{var "ms"}} = true{{end}}
+ }
+ {{ end -}}
+ {{if decElemKindPtr -}}
+ {{var "ms"}} = true
+ {{end -}}
if {{var "mg"}} {
- {{if decElemKindPtr}}{{var "mv"}}, {{var "mok"}} = {{var "v"}}[{{var "mk"}}]
+ {{if decElemKindPtr -}}
+ {{var "mv"}}, {{var "mok"}} = {{var "v"}}[{{var "mk"}}]
if {{var "mok"}} {
{{var "ms"}} = false
- } {{else}}{{var "mv"}} = {{var "v"}}[{{var "mk"}}] {{end}}
+ }
+ {{else -}}
+ {{var "mv"}} = {{var "v"}}[{{var "mk"}}]
+ {{end -}}
} {{if not decElemKindImmutable}}else { {{var "mv"}} = {{decElemZero}} }{{end}}
- r.ReadMapElemValue() {{/* z.DecSendContainerState(codecSelfer_containerMapValue{{ .Sfx }}) */}}
+ z.DecReadMapElemValue()
{{var "mdn"}} = false
- {{ $x := printf "%vmv%v" .TempVar .Rand }}{{ $y := printf "%vmdn%v" .TempVar .Rand }}{{ decLineVar $x $y }}
+ {{ $x := printf "%vmv%v" .TempVar .Rand }}{{ $y := printf "%vmdn%v" .TempVar .Rand }}{{ decLineVar $x $y -}}
if {{var "mdn"}} {
- if {{ var "bh" }}.DeleteOnNilMapValue { delete({{var "v"}}, {{var "mk"}}) } else { {{var "v"}}[{{var "mk"}}] = {{decElemZero}} }
+ if z.DecBasicHandle().DeleteOnNilMapValue { delete({{var "v"}}, {{var "mk"}}) } else { {{var "v"}}[{{var "mk"}}] = {{decElemZero}} }
} else if {{if decElemKindPtr}} {{var "ms"}} && {{end}} {{var "v"}} != nil {
{{var "v"}}[{{var "mk"}}] = {{var "mv"}}
}
}
} // else len==0: TODO: Should we clear map entries?
-r.ReadMapEnd() {{/* z.DecSendContainerState(codecSelfer_containerMapEnd{{ .Sfx }}) */}}
+z.DecReadMapEnd()
+}
diff --git a/vendor/github.com/ugorji/go/codec/gen-helper.generated.go b/vendor/github.com/ugorji/go/codec/gen-helper.generated.go
index b515524..d86d3af 100644
--- a/vendor/github.com/ugorji/go/codec/gen-helper.generated.go
+++ b/vendor/github.com/ugorji/go/codec/gen-helper.generated.go
@@ -7,24 +7,14 @@
package codec
-import (
- "encoding"
- "reflect"
- "strconv"
-)
+import "encoding"
// GenVersion is the current version of codecgen.
-const GenVersion = 10
+const GenVersion = 16
// This file is used to generate helper code for codecgen.
// The values here i.e. genHelper(En|De)coder are not to be used directly by
// library users. They WILL change continuously and without notice.
-//
-// To help enforce this, we create an unexported type with exported members.
-// The only way to get the type is via the one exported type that we control (somewhat).
-//
-// When static codecs are created for types, they will use this value
-// to perform encoding or decoding of primitives or known slice or map types.
// GenHelperEncoder is exported so that it can be used externally by codecgen.
//
@@ -48,66 +38,22 @@ type genHelperEncDriver struct {
encDriver
}
-func (x genHelperEncDriver) EncodeBuiltin(rt uintptr, v interface{}) {}
-func (x genHelperEncDriver) EncStructFieldKey(keyType valueType, s string) {
- var m must
- if keyType == valueTypeString {
- x.encDriver.EncodeStringEnc(cUTF8, s)
- } else if keyType == valueTypeInt {
- x.encDriver.EncodeInt(m.Int(strconv.ParseInt(s, 10, 64)))
- } else if keyType == valueTypeUint {
- x.encDriver.EncodeUint(m.Uint(strconv.ParseUint(s, 10, 64)))
- } else if keyType == valueTypeFloat {
- x.encDriver.EncodeFloat64(m.Float(strconv.ParseFloat(s, 64)))
- }
- // encStructFieldKey(x.encDriver, keyType, s)
-}
-func (x genHelperEncDriver) EncodeSymbol(s string) {
- x.encDriver.EncodeStringEnc(cUTF8, s)
-}
-
type genHelperDecDriver struct {
decDriver
- C checkOverflow
-}
-
-func (x genHelperDecDriver) DecodeBuiltin(rt uintptr, v interface{}) {}
-func (x genHelperDecDriver) DecStructFieldKey(keyType valueType, buf *[decScratchByteArrayLen]byte) []byte {
- return decStructFieldKey(x.decDriver, keyType, buf)
-}
-func (x genHelperDecDriver) DecodeInt(bitsize uint8) (i int64) {
- return x.C.IntV(x.decDriver.DecodeInt64(), bitsize)
-}
-func (x genHelperDecDriver) DecodeUint(bitsize uint8) (ui uint64) {
- return x.C.UintV(x.decDriver.DecodeUint64(), bitsize)
-}
-func (x genHelperDecDriver) DecodeFloat(chkOverflow32 bool) (f float64) {
- f = x.DecodeFloat64()
- if chkOverflow32 && chkOvf.Float32(f) {
- panicv.errorf("float32 overflow: %v", f)
- }
- return
-}
-func (x genHelperDecDriver) DecodeFloat32As64() (f float64) {
- f = x.DecodeFloat64()
- if chkOvf.Float32(f) {
- panicv.errorf("float32 overflow: %v", f)
- }
- return
}
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
type genHelperEncoder struct {
M must
- e *Encoder
F fastpathT
+ e *Encoder
}
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
type genHelperDecoder struct {
C checkOverflow
- d *Decoder
F fastpathT
+ d *Decoder
}
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
@@ -127,9 +73,8 @@ func (f genHelperEncoder) IsJSONHandle() bool {
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
func (f genHelperEncoder) EncFallback(iv interface{}) {
- // println(">>>>>>>>> EncFallback")
// f.e.encodeI(iv, false, false)
- f.e.encodeValue(reflect.ValueOf(iv), nil, false)
+ f.e.encodeValue(rv4i(iv), nil)
}
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
@@ -153,18 +98,6 @@ func (f genHelperEncoder) EncBinaryMarshal(iv encoding.BinaryMarshaler) {
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
func (f genHelperEncoder) EncRaw(iv Raw) { f.e.rawBytes(iv) }
-// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
-//
-// Deprecated: builtin no longer supported - so we make this method a no-op,
-// but leave in-place so that old generated files continue to work without regeneration.
-func (f genHelperEncoder) TimeRtidIfBinc() (v uintptr) { return }
-
-// func (f genHelperEncoder) TimeRtidIfBinc() uintptr {
-// if _, ok := f.e.hh.(*BincHandle); ok {
-// return timeTypId
-// }
-// }
-
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
func (f genHelperEncoder) I2Rtid(v interface{}) uintptr {
return i2rtid(v)
@@ -172,38 +105,42 @@ func (f genHelperEncoder) I2Rtid(v interface{}) uintptr {
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
func (f genHelperEncoder) Extension(rtid uintptr) (xfn *extTypeTagFn) {
- return f.e.h.getExt(rtid)
+ return f.e.h.getExt(rtid, true)
}
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
func (f genHelperEncoder) EncExtension(v interface{}, xfFn *extTypeTagFn) {
- f.e.e.EncodeExt(v, xfFn.tag, xfFn.ext, f.e)
+ f.e.e.EncodeExt(v, xfFn.tag, xfFn.ext)
}
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
func (f genHelperEncoder) WriteStr(s string) {
- f.e.w.writestr(s)
+ f.e.w().writestr(s)
}
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
-//
-// Deprecated: No longer used,
-// but leave in-place so that old generated files continue to work without regeneration.
-func (f genHelperEncoder) HasExtensions() bool {
- return len(f.e.h.extHandle) != 0
-}
+func (f genHelperEncoder) BytesView(v string) []byte { return bytesView(v) }
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
-//
-// Deprecated: No longer used,
-// but leave in-place so that old generated files continue to work without regeneration.
-func (f genHelperEncoder) EncExt(v interface{}) (r bool) {
- if xfFn := f.e.h.getExt(i2rtid(v)); xfFn != nil {
- f.e.e.EncodeExt(v, xfFn.tag, xfFn.ext, f.e)
- return true
- }
- return false
-}
+func (f genHelperEncoder) EncWriteMapStart(length int) { f.e.mapStart(length) }
+
+// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
+func (f genHelperEncoder) EncWriteMapEnd() { f.e.mapEnd() }
+
+// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
+func (f genHelperEncoder) EncWriteArrayStart(length int) { f.e.arrayStart(length) }
+
+// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
+func (f genHelperEncoder) EncWriteArrayEnd() { f.e.arrayEnd() }
+
+// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
+func (f genHelperEncoder) EncWriteArrayElem() { f.e.arrayElem() }
+
+// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
+func (f genHelperEncoder) EncWriteMapElemKey() { f.e.mapElemKey() }
+
+// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
+func (f genHelperEncoder) EncWriteMapElemValue() { f.e.mapElemValue() }
// ---------------- DECODER FOLLOWS -----------------
@@ -232,13 +169,11 @@ func (f genHelperDecoder) DecScratchArrayBuffer() *[decScratchByteArrayLen]byte
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
func (f genHelperDecoder) DecFallback(iv interface{}, chkPtr bool) {
- // println(">>>>>>>>> DecFallback")
- rv := reflect.ValueOf(iv)
+ rv := rv4i(iv)
if chkPtr {
- rv = f.d.ensureDecodeable(rv)
+ f.d.ensureDecodeable(rv)
}
- f.d.decodeValue(rv, nil, false)
- // f.d.decodeValueFallback(rv)
+ f.d.decodeValue(rv, nil)
}
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
@@ -258,8 +193,7 @@ func (f genHelperDecoder) DecArrayCannotExpand(sliceLen, streamLen int) {
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
func (f genHelperDecoder) DecTextUnmarshal(tm encoding.TextUnmarshaler) {
- fnerr := tm.UnmarshalText(f.d.d.DecodeStringAsBytes())
- if fnerr != nil {
+ if fnerr := tm.UnmarshalText(f.d.d.DecodeStringAsBytes()); fnerr != nil {
panic(fnerr)
}
}
@@ -268,16 +202,14 @@ func (f genHelperDecoder) DecTextUnmarshal(tm encoding.TextUnmarshaler) {
func (f genHelperDecoder) DecJSONUnmarshal(tm jsonUnmarshaler) {
// bs := f.dd.DecodeStringAsBytes()
// grab the bytes to be read, as UnmarshalJSON needs the full JSON so as to unmarshal it itself.
- fnerr := tm.UnmarshalJSON(f.d.nextValueBytes())
- if fnerr != nil {
+ if fnerr := tm.UnmarshalJSON(f.d.nextValueBytes()); fnerr != nil {
panic(fnerr)
}
}
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
func (f genHelperDecoder) DecBinaryUnmarshal(bm encoding.BinaryUnmarshaler) {
- fnerr := bm.UnmarshalBinary(f.d.d.DecodeBytes(nil, true))
- if fnerr != nil {
+ if fnerr := bm.UnmarshalBinary(f.d.d.DecodeBytes(nil, true)); fnerr != nil {
panic(fnerr)
}
}
@@ -285,20 +217,6 @@ func (f genHelperDecoder) DecBinaryUnmarshal(bm encoding.BinaryUnmarshaler) {
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
func (f genHelperDecoder) DecRaw() []byte { return f.d.rawBytes() }
-// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
-//
-// Deprecated: builtin no longer supported - so we make this method a no-op,
-// but leave in-place so that old generated files continue to work without regeneration.
-func (f genHelperDecoder) TimeRtidIfBinc() (v uintptr) { return }
-
-// func (f genHelperDecoder) TimeRtidIfBinc() uintptr {
-// // Note: builtin is no longer supported - so make this a no-op
-// if _, ok := f.d.hh.(*BincHandle); ok {
-// return timeTypId
-// }
-// return 0
-// }
-
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
func (f genHelperDecoder) IsJSONHandle() bool {
return f.d.js
@@ -311,7 +229,7 @@ func (f genHelperDecoder) I2Rtid(v interface{}) uintptr {
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
func (f genHelperDecoder) Extension(rtid uintptr) (xfn *extTypeTagFn) {
- return f.d.h.getExt(rtid)
+ return f.d.h.getExt(rtid, true)
}
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
@@ -320,32 +238,36 @@ func (f genHelperDecoder) DecExtension(v interface{}, xfFn *extTypeTagFn) {
}
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
-//
-// Deprecated: No longer used,
-// but leave in-place so that old generated files continue to work without regeneration.
-func (f genHelperDecoder) HasExtensions() bool {
- return len(f.d.h.extHandle) != 0
+func (f genHelperDecoder) DecInferLen(clen, maxlen, unit int) (rvlen int) {
+ return decInferLen(clen, maxlen, unit)
}
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
-//
-// Deprecated: No longer used,
-// but leave in-place so that old generated files continue to work without regeneration.
-func (f genHelperDecoder) DecExt(v interface{}) (r bool) {
- if xfFn := f.d.h.getExt(i2rtid(v)); xfFn != nil {
- f.d.d.DecodeExt(v, xfFn.tag, xfFn.ext)
- return true
- }
- return false
-}
+func (f genHelperDecoder) StringView(v []byte) string { return stringView(v) }
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
-func (f genHelperDecoder) DecInferLen(clen, maxlen, unit int) (rvlen int) {
- return decInferLen(clen, maxlen, unit)
-}
+func (f genHelperDecoder) DecReadMapStart() int { return f.d.mapStart() }
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
-//
-// Deprecated: no longer used,
-// but leave in-place so that old generated files continue to work without regeneration.
-func (f genHelperDecoder) StringView(v []byte) string { return stringView(v) }
+func (f genHelperDecoder) DecReadMapEnd() { f.d.mapEnd() }
+
+// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
+func (f genHelperDecoder) DecReadArrayStart() int { return f.d.arrayStart() }
+
+// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
+func (f genHelperDecoder) DecReadArrayEnd() { f.d.arrayEnd() }
+
+// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
+func (f genHelperDecoder) DecReadArrayElem() { f.d.arrayElem() }
+
+// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
+func (f genHelperDecoder) DecReadMapElemKey() { f.d.mapElemKey() }
+
+// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
+func (f genHelperDecoder) DecReadMapElemValue() { f.d.mapElemValue() }
+
+// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
+func (f genHelperDecoder) DecDecodeFloat32() float32 { return f.d.decodeFloat32() }
+
+// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
+func (f genHelperDecoder) DecCheckBreak() bool { return f.d.checkBreak() }
diff --git a/vendor/github.com/ugorji/go/codec/gen-helper.go.tmpl b/vendor/github.com/ugorji/go/codec/gen-helper.go.tmpl
index 161aaf1..4465233 100644
--- a/vendor/github.com/ugorji/go/codec/gen-helper.go.tmpl
+++ b/vendor/github.com/ugorji/go/codec/gen-helper.go.tmpl
@@ -7,11 +7,7 @@
package codec
-import (
- "encoding"
- "reflect"
- "strconv"
-)
+import "encoding"
// GenVersion is the current version of codecgen.
const GenVersion = {{ .Version }}
@@ -19,12 +15,14 @@ const GenVersion = {{ .Version }}
// This file is used to generate helper code for codecgen.
// The values here i.e. genHelper(En|De)coder are not to be used directly by
// library users. They WILL change continuously and without notice.
-//
+
+{{/*
// To help enforce this, we create an unexported type with exported members.
// The only way to get the type is via the one exported type that we control (somewhat).
//
// When static codecs are created for types, they will use this value
// to perform encoding or decoding of primitives or known slice or map types.
+*/ -}}
// GenHelperEncoder is exported so that it can be used externally by codecgen.
//
@@ -48,66 +46,22 @@ type genHelperEncDriver struct {
encDriver
}
-func (x genHelperEncDriver) EncodeBuiltin(rt uintptr, v interface{}) {}
-func (x genHelperEncDriver) EncStructFieldKey(keyType valueType, s string) {
- var m must
- if keyType == valueTypeString {
- x.encDriver.EncodeStringEnc(cUTF8, s)
- } else if keyType == valueTypeInt {
- x.encDriver.EncodeInt(m.Int(strconv.ParseInt(s, 10, 64)))
- } else if keyType == valueTypeUint {
- x.encDriver.EncodeUint(m.Uint(strconv.ParseUint(s, 10, 64)))
- } else if keyType == valueTypeFloat {
- x.encDriver.EncodeFloat64(m.Float(strconv.ParseFloat(s, 64)))
- }
- // encStructFieldKey(x.encDriver, keyType, s)
-}
-func (x genHelperEncDriver) EncodeSymbol(s string) {
- x.encDriver.EncodeStringEnc(cUTF8, s)
-}
-
type genHelperDecDriver struct {
decDriver
- C checkOverflow
-}
-
-func (x genHelperDecDriver) DecodeBuiltin(rt uintptr, v interface{}) {}
-func (x genHelperDecDriver) DecStructFieldKey(keyType valueType, buf *[decScratchByteArrayLen]byte) []byte {
- return decStructFieldKey(x.decDriver, keyType, buf)
-}
-func (x genHelperDecDriver) DecodeInt(bitsize uint8) (i int64) {
- return x.C.IntV(x.decDriver.DecodeInt64(), bitsize)
-}
-func (x genHelperDecDriver) DecodeUint(bitsize uint8) (ui uint64) {
- return x.C.UintV(x.decDriver.DecodeUint64(), bitsize)
-}
-func (x genHelperDecDriver) DecodeFloat(chkOverflow32 bool) (f float64) {
- f = x.DecodeFloat64()
- if chkOverflow32 && chkOvf.Float32(f) {
- panicv.errorf("float32 overflow: %v", f)
- }
- return
-}
-func (x genHelperDecDriver) DecodeFloat32As64() (f float64) {
- f = x.DecodeFloat64()
- if chkOvf.Float32(f) {
- panicv.errorf("float32 overflow: %v", f)
- }
- return
}
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
type genHelperEncoder struct {
M must
- e *Encoder
F fastpathT
+ e *Encoder
}
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
type genHelperDecoder struct {
C checkOverflow
- d *Decoder
F fastpathT
+ d *Decoder
}
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
@@ -124,9 +78,8 @@ func (f genHelperEncoder) IsJSONHandle() bool {
}
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
func (f genHelperEncoder) EncFallback(iv interface{}) {
- // println(">>>>>>>>> EncFallback")
// f.e.encodeI(iv, false, false)
- f.e.encodeValue(reflect.ValueOf(iv), nil, false)
+ f.e.encodeValue(rv4i(iv), nil)
}
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
func (f genHelperEncoder) EncTextMarshal(iv encoding.TextMarshaler) {
@@ -145,16 +98,6 @@ func (f genHelperEncoder) EncBinaryMarshal(iv encoding.BinaryMarshaler) {
}
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
func (f genHelperEncoder) EncRaw(iv Raw) { f.e.rawBytes(iv) }
-// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
-//
-// Deprecated: builtin no longer supported - so we make this method a no-op,
-// but leave in-place so that old generated files continue to work without regeneration.
-func (f genHelperEncoder) TimeRtidIfBinc() (v uintptr) { return }
-// func (f genHelperEncoder) TimeRtidIfBinc() uintptr {
-// if _, ok := f.e.hh.(*BincHandle); ok {
-// return timeTypId
-// }
-// }
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
func (f genHelperEncoder) I2Rtid(v interface{}) uintptr {
@@ -162,34 +105,33 @@ func (f genHelperEncoder) I2Rtid(v interface{}) uintptr {
}
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
func (f genHelperEncoder) Extension(rtid uintptr) (xfn *extTypeTagFn) {
- return f.e.h.getExt(rtid)
+ return f.e.h.getExt(rtid, true)
}
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
func (f genHelperEncoder) EncExtension(v interface{}, xfFn *extTypeTagFn) {
- f.e.e.EncodeExt(v, xfFn.tag, xfFn.ext, f.e)
+ f.e.e.EncodeExt(v, xfFn.tag, xfFn.ext)
}
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
func (f genHelperEncoder) WriteStr(s string) {
- f.e.w.writestr(s)
+ f.e.w().writestr(s)
}
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
-//
-// Deprecated: No longer used,
-// but leave in-place so that old generated files continue to work without regeneration.
-func (f genHelperEncoder) HasExtensions() bool {
- return len(f.e.h.extHandle) != 0
-}
+func (f genHelperEncoder) BytesView(v string) []byte { return bytesView(v) }
+
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
-//
-// Deprecated: No longer used,
-// but leave in-place so that old generated files continue to work without regeneration.
-func (f genHelperEncoder) EncExt(v interface{}) (r bool) {
- if xfFn := f.e.h.getExt(i2rtid(v)); xfFn != nil {
- f.e.e.EncodeExt(v, xfFn.tag, xfFn.ext, f.e)
- return true
- }
- return false
-}
+func (f genHelperEncoder) EncWriteMapStart(length int) { f.e.mapStart(length) }
+// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
+func (f genHelperEncoder) EncWriteMapEnd() { f.e.mapEnd() }
+// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
+func (f genHelperEncoder) EncWriteArrayStart(length int) { f.e.arrayStart(length) }
+// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
+func (f genHelperEncoder) EncWriteArrayEnd() { f.e.arrayEnd() }
+// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
+func (f genHelperEncoder) EncWriteArrayElem() { f.e.arrayElem() }
+// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
+func (f genHelperEncoder) EncWriteMapElemKey() { f.e.mapElemKey() }
+// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
+func (f genHelperEncoder) EncWriteMapElemValue() { f.e.mapElemValue() }
// ---------------- DECODER FOLLOWS -----------------
@@ -213,13 +155,11 @@ func (f genHelperDecoder) DecScratchArrayBuffer() *[decScratchByteArrayLen]byte
}
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
func (f genHelperDecoder) DecFallback(iv interface{}, chkPtr bool) {
- // println(">>>>>>>>> DecFallback")
- rv := reflect.ValueOf(iv)
+ rv := rv4i(iv)
if chkPtr {
- rv = f.d.ensureDecodeable(rv)
+ f.d.ensureDecodeable(rv)
}
- f.d.decodeValue(rv, nil, false)
- // f.d.decodeValueFallback(rv)
+ f.d.decodeValue(rv, nil)
}
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
func (f genHelperDecoder) DecSliceHelperStart() (decSliceHelper, int) {
@@ -235,8 +175,7 @@ func (f genHelperDecoder) DecArrayCannotExpand(sliceLen, streamLen int) {
}
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
func (f genHelperDecoder) DecTextUnmarshal(tm encoding.TextUnmarshaler) {
- fnerr := tm.UnmarshalText(f.d.d.DecodeStringAsBytes())
- if fnerr != nil {
+ if fnerr := tm.UnmarshalText(f.d.d.DecodeStringAsBytes()); fnerr != nil {
panic(fnerr)
}
}
@@ -244,32 +183,18 @@ func (f genHelperDecoder) DecTextUnmarshal(tm encoding.TextUnmarshaler) {
func (f genHelperDecoder) DecJSONUnmarshal(tm jsonUnmarshaler) {
// bs := f.dd.DecodeStringAsBytes()
// grab the bytes to be read, as UnmarshalJSON needs the full JSON so as to unmarshal it itself.
- fnerr := tm.UnmarshalJSON(f.d.nextValueBytes())
- if fnerr != nil {
+ if fnerr := tm.UnmarshalJSON(f.d.nextValueBytes()); fnerr != nil {
panic(fnerr)
}
}
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
func (f genHelperDecoder) DecBinaryUnmarshal(bm encoding.BinaryUnmarshaler) {
- fnerr := bm.UnmarshalBinary(f.d.d.DecodeBytes(nil, true))
- if fnerr != nil {
+ if fnerr := bm.UnmarshalBinary(f.d.d.DecodeBytes(nil, true)); fnerr != nil {
panic(fnerr)
}
}
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
func (f genHelperDecoder) DecRaw() []byte { return f.d.rawBytes() }
-// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
-//
-// Deprecated: builtin no longer supported - so we make this method a no-op,
-// but leave in-place so that old generated files continue to work without regeneration.
-func (f genHelperDecoder) TimeRtidIfBinc() (v uintptr) { return }
-// func (f genHelperDecoder) TimeRtidIfBinc() uintptr {
-// // Note: builtin is no longer supported - so make this a no-op
-// if _, ok := f.d.hh.(*BincHandle); ok {
-// return timeTypId
-// }
-// return 0
-// }
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
func (f genHelperDecoder) IsJSONHandle() bool {
@@ -281,37 +206,36 @@ func (f genHelperDecoder) I2Rtid(v interface{}) uintptr {
}
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
func (f genHelperDecoder) Extension(rtid uintptr) (xfn *extTypeTagFn) {
- return f.d.h.getExt(rtid)
+ return f.d.h.getExt(rtid, true)
}
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
func (f genHelperDecoder) DecExtension(v interface{}, xfFn *extTypeTagFn) {
f.d.d.DecodeExt(v, xfFn.tag, xfFn.ext)
}
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
-//
-// Deprecated: No longer used,
-// but leave in-place so that old generated files continue to work without regeneration.
-func (f genHelperDecoder) HasExtensions() bool {
- return len(f.d.h.extHandle) != 0
-}
-// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
-//
-// Deprecated: No longer used,
-// but leave in-place so that old generated files continue to work without regeneration.
-func (f genHelperDecoder) DecExt(v interface{}) (r bool) {
- if xfFn := f.d.h.getExt(i2rtid(v)); xfFn != nil {
- f.d.d.DecodeExt(v, xfFn.tag, xfFn.ext)
- return true
- }
- return false
-}
-// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
func (f genHelperDecoder) DecInferLen(clen, maxlen, unit int) (rvlen int) {
return decInferLen(clen, maxlen, unit)
}
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
-//
-// Deprecated: no longer used,
-// but leave in-place so that old generated files continue to work without regeneration.
func (f genHelperDecoder) StringView(v []byte) string { return stringView(v) }
+// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
+func (f genHelperDecoder) DecReadMapStart() int { return f.d.mapStart() }
+// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
+func (f genHelperDecoder) DecReadMapEnd() { f.d.mapEnd() }
+// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
+func (f genHelperDecoder) DecReadArrayStart() int { return f.d.arrayStart() }
+// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
+func (f genHelperDecoder) DecReadArrayEnd() { f.d.arrayEnd() }
+// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
+func (f genHelperDecoder) DecReadArrayElem() { f.d.arrayElem() }
+// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
+func (f genHelperDecoder) DecReadMapElemKey() { f.d.mapElemKey() }
+// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
+func (f genHelperDecoder) DecReadMapElemValue() { f.d.mapElemValue() }
+
+// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
+func (f genHelperDecoder) DecDecodeFloat32() float32 { return f.d.decodeFloat32() }
+// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
+func (f genHelperDecoder) DecCheckBreak() bool { return f.d.checkBreak() }
+
diff --git a/vendor/github.com/ugorji/go/codec/gen.generated.go b/vendor/github.com/ugorji/go/codec/gen.generated.go
index 8b00090..5aca5a4 100644
--- a/vendor/github.com/ugorji/go/codec/gen.generated.go
+++ b/vendor/github.com/ugorji/go/codec/gen.generated.go
@@ -9,56 +9,75 @@ package codec
const genDecMapTmpl = `
{{var "v"}} := *{{ .Varname }}
-{{var "l"}} := r.ReadMapStart()
-{{var "bh"}} := z.DecBasicHandle()
+{{var "l"}} := z.DecReadMapStart()
+if {{var "l"}} == codecSelferDecContainerLenNil{{xs}} {
+ *{{ .Varname }} = nil
+} else {
if {{var "v"}} == nil {
- {{var "rl"}} := z.DecInferLen({{var "l"}}, {{var "bh"}}.MaxInitLen, {{ .Size }})
+ {{var "rl"}} := z.DecInferLen({{var "l"}}, z.DecBasicHandle().MaxInitLen, {{ .Size }})
{{var "v"}} = make(map[{{ .KTyp }}]{{ .Typ }}, {{var "rl"}})
*{{ .Varname }} = {{var "v"}}
}
var {{var "mk"}} {{ .KTyp }}
var {{var "mv"}} {{ .Typ }}
var {{var "mg"}}, {{var "mdn"}} {{if decElemKindPtr}}, {{var "ms"}}, {{var "mok"}}{{end}} bool
-if {{var "bh"}}.MapValueReset {
+if z.DecBasicHandle().MapValueReset {
{{if decElemKindPtr}}{{var "mg"}} = true
- {{else if decElemKindIntf}}if !{{var "bh"}}.InterfaceReset { {{var "mg"}} = true }
+ {{else if decElemKindIntf}}if !z.DecBasicHandle().InterfaceReset { {{var "mg"}} = true }
{{else if not decElemKindImmutable}}{{var "mg"}} = true
{{end}} }
if {{var "l"}} != 0 {
-{{var "hl"}} := {{var "l"}} > 0
- for {{var "j"}} := 0; ({{var "hl"}} && {{var "j"}} < {{var "l"}}) || !({{var "hl"}} || r.CheckBreak()); {{var "j"}}++ {
- r.ReadMapElemKey() {{/* z.DecSendContainerState(codecSelfer_containerMapKey{{ .Sfx }}) */}}
- {{ $x := printf "%vmk%v" .TempVar .Rand }}{{ decLineVarK $x }}
-{{ if eq .KTyp "interface{}" }}{{/* // special case if a byte array. */}}if {{var "bv"}}, {{var "bok"}} := {{var "mk"}}.([]byte); {{var "bok"}} {
+ {{var "hl"}} := {{var "l"}} > 0
+ for {{var "j"}} := 0; ({{var "hl"}} && {{var "j"}} < {{var "l"}}) || !({{var "hl"}} || z.DecCheckBreak()); {{var "j"}}++ {
+ z.DecReadMapElemKey()
+ {{ $x := printf "%vmk%v" .TempVar .Rand }}{{ decLineVarK $x -}}
+ {{ if eq .KTyp "interface{}" }}{{/* // special case if a byte array. */ -}}
+ if {{var "bv"}}, {{var "bok"}} := {{var "mk"}}.([]byte); {{var "bok"}} {
{{var "mk"}} = string({{var "bv"}})
- }{{ end }}{{if decElemKindPtr}}
- {{var "ms"}} = true{{end}}
+ }
+ {{ end -}}
+ {{if decElemKindPtr -}}
+ {{var "ms"}} = true
+ {{end -}}
if {{var "mg"}} {
- {{if decElemKindPtr}}{{var "mv"}}, {{var "mok"}} = {{var "v"}}[{{var "mk"}}]
+ {{if decElemKindPtr -}}
+ {{var "mv"}}, {{var "mok"}} = {{var "v"}}[{{var "mk"}}]
if {{var "mok"}} {
{{var "ms"}} = false
- } {{else}}{{var "mv"}} = {{var "v"}}[{{var "mk"}}] {{end}}
+ }
+ {{else -}}
+ {{var "mv"}} = {{var "v"}}[{{var "mk"}}]
+ {{end -}}
} {{if not decElemKindImmutable}}else { {{var "mv"}} = {{decElemZero}} }{{end}}
- r.ReadMapElemValue() {{/* z.DecSendContainerState(codecSelfer_containerMapValue{{ .Sfx }}) */}}
+ z.DecReadMapElemValue()
{{var "mdn"}} = false
- {{ $x := printf "%vmv%v" .TempVar .Rand }}{{ $y := printf "%vmdn%v" .TempVar .Rand }}{{ decLineVar $x $y }}
+ {{ $x := printf "%vmv%v" .TempVar .Rand }}{{ $y := printf "%vmdn%v" .TempVar .Rand }}{{ decLineVar $x $y -}}
if {{var "mdn"}} {
- if {{ var "bh" }}.DeleteOnNilMapValue { delete({{var "v"}}, {{var "mk"}}) } else { {{var "v"}}[{{var "mk"}}] = {{decElemZero}} }
+ if z.DecBasicHandle().DeleteOnNilMapValue { delete({{var "v"}}, {{var "mk"}}) } else { {{var "v"}}[{{var "mk"}}] = {{decElemZero}} }
} else if {{if decElemKindPtr}} {{var "ms"}} && {{end}} {{var "v"}} != nil {
{{var "v"}}[{{var "mk"}}] = {{var "mv"}}
}
}
} // else len==0: TODO: Should we clear map entries?
-r.ReadMapEnd() {{/* z.DecSendContainerState(codecSelfer_containerMapEnd{{ .Sfx }}) */}}
+z.DecReadMapEnd()
+}
`
const genDecListTmpl = `
{{var "v"}} := {{if not isArray}}*{{end}}{{ .Varname }}
-{{var "h"}}, {{var "l"}} := z.DecSliceHelperStart() {{/* // helper, containerLenS */}}{{if not isArray}}
+{{var "h"}}, {{var "l"}} := z.DecSliceHelperStart() {{/* // helper, containerLenS */}}
+{{if not isArray -}}
var {{var "c"}} bool {{/* // changed */}}
-_ = {{var "c"}}{{end}}
+_ = {{var "c"}}
+if {{var "h"}}.IsNil {
+ if {{var "v"}} != nil {
+ {{var "v"}} = nil
+ {{var "c"}} = true
+ }
+} else {{end -}}
if {{var "l"}} == 0 {
- {{if isSlice }}if {{var "v"}} == nil {
+ {{if isSlice -}}
+ if {{var "v"}} == nil {
{{var "v"}} = []{{ .Typ }}{}
{{var "c"}} = true
} else if len({{var "v"}}) != 0 {
@@ -67,7 +86,8 @@ if {{var "l"}} == 0 {
} {{else if isChan }}if {{var "v"}} == nil {
{{var "v"}} = make({{ .CTyp }}, 0)
{{var "c"}} = true
- } {{end}}
+ }
+ {{end -}}
} else {
{{var "hl"}} := {{var "l"}} > 0
var {{var "rl"}} int
@@ -85,10 +105,11 @@ if {{var "l"}} == 0 {
{{var "v"}} = {{var "v"}}[:{{var "l"}}]
{{var "c"}} = true
}
- } {{end}}
+ }
+ {{end -}}
var {{var "j"}} int
- // var {{var "dn"}} bool
- for {{var "j"}} = 0; ({{var "hl"}} && {{var "j"}} < {{var "l"}}) || !({{var "hl"}} || r.CheckBreak()); {{var "j"}}++ { // bounds-check-elimination
+ {{/* // var {{var "dn"}} bool */ -}}
+ for {{var "j"}} = 0; ({{var "hl"}} && {{var "j"}} < {{var "l"}}) || !({{var "hl"}} || z.DecCheckBreak()); {{var "j"}}++ { // bounds-check-elimination
{{if not isArray}} if {{var "j"}} == 0 && {{var "v"}} == nil {
if {{var "hl"}} {
{{var "rl"}} = z.DecInferLen({{var "l"}}, z.DecBasicHandle().MaxInitLen, {{ .Size }})
@@ -97,27 +118,27 @@ if {{var "l"}} == 0 {
}
{{var "v"}} = make({{if isSlice}}[]{{ .Typ }}{{else if isChan}}{{.CTyp}}{{end}}, {{var "rl"}})
{{var "c"}} = true
- }{{end}}
+ }
+ {{end -}}
{{var "h"}}.ElemContainerState({{var "j"}})
- {{/* {{var "dn"}} = r.TryDecodeAsNil() */}}{{/* commented out, as decLineVar handles this already each time */}}
+ {{/* {{var "dn"}} = r.TryDecodeAsNil() */}}{{/* commented out, as decLineVar handles this already each time */ -}}
{{if isChan}}{{ $x := printf "%[1]vvcx%[2]v" .TempVar .Rand }}var {{$x}} {{ .Typ }}
- {{ decLineVar $x }}
+ {{ decLineVar $x -}}
{{var "v"}} <- {{ $x }}
- // println(">>>> sending ", {{ $x }}, " into ", {{var "v"}}) // TODO: remove this
- {{else}}{{/* // if indefinite, etc, then expand the slice if necessary */}}
+ {{else}}{{/* // if indefinite, etc, then expand the slice if necessary */ -}}
var {{var "db"}} bool
if {{var "j"}} >= len({{var "v"}}) {
{{if isSlice }} {{var "v"}} = append({{var "v"}}, {{ zero }})
{{var "c"}} = true
{{else}} z.DecArrayCannotExpand(len(v), {{var "j"}}+1); {{var "db"}} = true
- {{end}}
+ {{end -}}
}
if {{var "db"}} {
z.DecSwallow()
} else {
- {{ $x := printf "%[1]vv%[2]v[%[1]vj%[2]v]" .TempVar .Rand }}{{ decLineVar $x }}
+ {{ $x := printf "%[1]vv%[2]v[%[1]vj%[2]v]" .TempVar .Rand }}{{ decLineVar $x -}}
}
- {{end}}
+ {{end -}}
}
{{if isSlice}} if {{var "j"}} < len({{var "v"}}) {
{{var "v"}} = {{var "v"}}[:{{var "j"}}]
@@ -125,12 +146,14 @@ if {{var "l"}} == 0 {
} else if {{var "j"}} == 0 && {{var "v"}} == nil {
{{var "v"}} = make([]{{ .Typ }}, 0)
{{var "c"}} = true
- } {{end}}
+ }
+ {{end -}}
}
{{var "h"}}.End()
{{if not isArray }}if {{var "c"}} {
*{{ .Varname }} = {{var "v"}}
-}{{end}}
+}
+{{end -}}
`
const genEncChanTmpl = `
diff --git a/vendor/github.com/ugorji/go/codec/gen.go b/vendor/github.com/ugorji/go/codec/gen.go
index 115c9b4..3573bc3 100644
--- a/vendor/github.com/ugorji/go/codec/gen.go
+++ b/vendor/github.com/ugorji/go/codec/gen.go
@@ -105,8 +105,14 @@ import (
// v7:
// v8: current - we now maintain compatibility with old generated code.
// v9: skipped
-// v10: modified encDriver and decDriver interfaces. Remove deprecated methods after Jan 1, 2019
-const genVersion = 10
+// v10: modified encDriver and decDriver interfaces.
+// v11: remove deprecated methods of encDriver and decDriver.
+// v12: removed deprecated methods from genHelper and changed container tracking logic
+// v13: 20190603 removed DecodeString - use DecodeStringAsBytes instead
+// v14: 20190611 refactored nil handling: TryDecodeAsNil -> selective TryNil, etc
+// v15: 20190626 encDriver.EncodeString handles StringToRaw flag inside handle
+// v16: 20190629 refactoring for v1.1.6
+const genVersion = 16
const (
genCodecPkg = "codec1978"
@@ -123,6 +129,21 @@ const (
//
// From testing, it didn't make much difference in runtime, so keep as true (one function only)
genUseOneFunctionForDecStructMap = true
+
+ // genFastpathCanonical configures whether we support Canonical in fast path.
+ // The savings is not much.
+ //
+ // NOTE: This MUST ALWAYS BE TRUE. fast-path.go.tmp doesn't handle it being false.
+ genFastpathCanonical = true // MUST be true
+
+ // genFastpathTrimTypes configures whether we trim uncommon fastpath types.
+ genFastpathTrimTypes = true
+
+ // genDecStructArrayInlineLoopCheck configures whether we create a next function
+ // for each iteration in the loop and call it, or just inline it.
+ //
+ // with inlining, we get better performance but about 10% larger files.
+ genDecStructArrayInlineLoopCheck = true
)
type genStructMapStyle uint8
@@ -157,10 +178,11 @@ func (x *genBuf) reset() {
// genRunner holds some state used during a Gen run.
type genRunner struct {
- w io.Writer // output
- c uint64 // counter used for generating varsfx
- t []reflect.Type // list of types to run selfer on
+ w io.Writer // output
+ c uint64 // counter used for generating varsfx
+ f uint64 // counter used for saying false
+ t []reflect.Type // list of types to run selfer on
tc reflect.Type // currently running selfer on this type
te map[uintptr]bool // types for which the encoder has been created
td map[uintptr]bool // types for which the decoder has been created
@@ -187,6 +209,30 @@ type genRunner struct {
nx bool // no extensions
}
+type genIfClause struct {
+ hasIf bool
+}
+
+func (g *genIfClause) end(x *genRunner) {
+ if g.hasIf {
+ x.line("}")
+ }
+}
+
+func (g *genIfClause) c(last bool) (v string) {
+ if last {
+ if g.hasIf {
+ v = " } else { "
+ }
+ } else if g.hasIf {
+ v = " } else if "
+ } else {
+ v = "if "
+ g.hasIf = true
+ }
+ return
+}
+
// Gen will write a complete go file containing Selfer implementations for each
// type passed. All the types must be in the same package.
//
@@ -233,9 +279,9 @@ func Gen(w io.Writer, buildTags, pkgName, uid string, noExtensions bool,
}
x.genRefPkgs(t)
}
+ x.line("// +build go1.6")
if buildTags != "" {
x.line("// +build " + buildTags)
- x.line("")
}
x.line(`
@@ -278,50 +324,41 @@ func Gen(w io.Writer, buildTags, pkgName, uid string, noExtensions bool,
x.linef("// ----- value types used ----")
for _, vt := range [...]valueType{
valueTypeArray, valueTypeMap, valueTypeString,
- valueTypeInt, valueTypeUint, valueTypeFloat} {
+ valueTypeInt, valueTypeUint, valueTypeFloat,
+ valueTypeNil,
+ } {
x.linef("codecSelferValueType%s%s = %v", vt.String(), x.xs, int64(vt))
}
x.linef("codecSelferBitsize%s = uint8(32 << (^uint(0) >> 63))", x.xs)
+ x.linef("codecSelferDecContainerLenNil%s = %d", x.xs, int64(decContainerLenNil))
x.line(")")
x.line("var (")
- x.line("errCodecSelferOnlyMapOrArrayEncodeToStruct" + x.xs + " = errors.New(`only encoded map or array can be decoded into a struct`)")
+ x.line("errCodecSelferOnlyMapOrArrayEncodeToStruct" + x.xs + " = " + "\nerrors.New(`only encoded map or array can be decoded into a struct`)")
x.line(")")
x.line("")
x.hn = "codecSelfer" + x.xs
x.line("type " + x.hn + " struct{}")
x.line("")
-
+ x.linef("func %sFalse() bool { return false }", x.hn)
+ x.line("")
x.varsfxreset()
x.line("func init() {")
x.linef("if %sGenVersion != %v {", x.cpfx, genVersion)
x.line("_, file, _, _ := runtime.Caller(0)")
- x.outf(`panic("codecgen version mismatch: current: %v, need " + strconv.FormatInt(int64(%sGenVersion), 10) + ". Re-generate file: " + file)`, genVersion, x.cpfx)
- // x.out(`panic(fmt.Errorf("codecgen version mismatch: current: %v, need %v. Re-generate file: %v", `)
- // x.linef(`%v, %sGenVersion, file))`, genVersion, x.cpfx)
+ x.linef("ver := strconv.FormatInt(int64(%sGenVersion), 10)", x.cpfx)
+ x.outf(`panic("codecgen version mismatch: current: %v, need " + ver + ". Re-generate file: " + file)`, genVersion)
x.linef("}")
- x.line("if false { var _ byte = 0; // reference the types, but skip this branch at build/run time")
- // x.line("_ = strconv.ParseInt")
- var n int
- // for k, t := range x.im {
- for _, k := range imKeys {
- t := x.im[k]
- x.linef("var v%v %s.%s", n, x.imn[k], t.Name())
- n++
- }
- if n > 0 {
- x.out("_")
- for i := 1; i < n; i++ {
- x.out(", _")
- }
- x.out(" = v0")
- for i := 1; i < n; i++ {
- x.outf(", v%v", i)
+ if len(imKeys) > 0 {
+ x.line("if false { // reference the types, but skip this branch at build/run time")
+ for _, k := range imKeys {
+ t := x.im[k]
+ x.linef("var _ %s.%s", x.imn[k], t.Name())
}
+ x.line("} ") // close if false
}
- x.line("} ") // close if false
- x.line("}") // close init
+ x.line("}") // close init
x.line("")
// generate rest of type info
@@ -422,6 +459,15 @@ func (x *genRunner) genRefPkgs(t reflect.Type) {
}
}
+// sayFalse will either say "false" or use a function call that returns false.
+func (x *genRunner) sayFalse() string {
+ x.f++
+ if x.f%2 == 0 {
+ return x.hn + "False()"
+ }
+ return "false"
+}
+
func (x *genRunner) varsfx() string {
x.c++
return strconv.FormatUint(x.c, 10)
@@ -452,6 +498,12 @@ func (x *genRunner) line(s string) {
}
}
+func (x *genRunner) lineIf(s string) {
+ if s != "" {
+ x.line(s)
+ }
+}
+
func (x *genRunner) linef(s string, params ...interface{}) {
x.outf(s, params...)
if len(s) == 0 || s[len(s)-1] != '\n' {
@@ -460,7 +512,7 @@ func (x *genRunner) linef(s string, params ...interface{}) {
}
func (x *genRunner) genTypeName(t reflect.Type) (n string) {
- // defer func() { fmt.Printf(">>>> ####: genTypeName: t: %v, name: '%s'\n", t, n) }()
+ // defer func() { xdebugf(">>>> ####: genTypeName: t: %v, name: '%s'\n", t, n) }()
// if the type has a PkgPath, which doesn't match the current package,
// then include it.
@@ -638,14 +690,19 @@ func (x *genRunner) registerXtraT(t reflect.Type) {
// encVar will encode a variable.
// The parameter, t, is the reflect.Type of the variable itself
func (x *genRunner) encVar(varname string, t reflect.Type) {
- // fmt.Printf(">>>>>> varname: %s, t: %v\n", varname, t)
var checkNil bool
+ // case reflect.Ptr, reflect.Interface, reflect.Slice, reflect.Map, reflect.Chan:
+ // do not include checkNil for slice and maps, as we already checkNil below it
switch t.Kind() {
- case reflect.Ptr, reflect.Interface, reflect.Slice, reflect.Map, reflect.Chan:
+ case reflect.Ptr, reflect.Interface, reflect.Chan:
checkNil = true
}
+ x.encVarChkNil(varname, t, checkNil)
+}
+
+func (x *genRunner) encVarChkNil(varname string, t reflect.Type, checkNil bool) {
if checkNil {
- x.linef("if %s == nil { r.EncodeNil() } else { ", varname)
+ x.linef("if %s == nil { r.EncodeNil() } else {", varname)
}
switch t.Kind() {
@@ -674,7 +731,6 @@ func (x *genRunner) encVar(varname string, t reflect.Type) {
if checkNil {
x.line("}")
}
-
}
// enc will encode a variable (varname) of type t, where t represents T.
@@ -693,17 +749,18 @@ func (x *genRunner) enc(varname string, t reflect.Type) {
// tptr := reflect.PtrTo(t)
tk := t.Kind()
if x.checkForSelfer(t, varname) {
- if tk == reflect.Array || (tk == reflect.Struct && rtid != timeTypId) { // varname is of type *T
+ if tk == reflect.Array ||
+ (tk == reflect.Struct && rtid != timeTypId) { // varname is of type *T
// if tptr.Implements(selferTyp) || t.Implements(selferTyp) {
- if ti2.isFlag(typeInfoFlagIsZeroerPtr) || ti2.isFlag(typeInfoFlagIsZeroer) {
+ if ti2.isFlag(tiflagSelfer) || ti2.isFlag(tiflagSelferPtr) {
x.line(varname + ".CodecEncodeSelf(e)")
return
}
} else { // varname is of type T
- if ti2.cs { // t.Implements(selferTyp) {
+ if ti2.isFlag(tiflagSelfer) {
x.line(varname + ".CodecEncodeSelf(e)")
return
- } else if ti2.csp { // tptr.Implements(selferTyp) {
+ } else if ti2.isFlag(tiflagSelferPtr) {
x.linef("%ssf%s := &%s", genTempVarPfx, mi, varname)
x.linef("%ssf%s.CodecEncodeSelf(e)", genTempVarPfx, mi)
return
@@ -738,53 +795,56 @@ func (x *genRunner) enc(varname string, t reflect.Type) {
// - type is time.Time, RawExt, Raw
// - the type implements (Text|JSON|Binary)(Unm|M)arshal
- x.line("if false {") //start if block
- defer func() { x.line("}") }() //end if block
+ var hasIf genIfClause
+ defer hasIf.end(x) // end if block (if necessary)
if t == timeTyp {
- x.linef("} else if !z.EncBasicHandle().TimeNotBuiltin { r.EncodeTime(%s)", varname)
+ x.linef("%s !z.EncBasicHandle().TimeNotBuiltin { r.EncodeTime(%s)", hasIf.c(false), varname)
// return
}
if t == rawTyp {
- x.linef("} else { z.EncRaw(%s)", varname)
+ x.linef("%s z.EncRaw(%s)", hasIf.c(true), varname)
return
}
if t == rawExtTyp {
- x.linef("} else { r.EncodeRawExt(%s, e)", varname)
+ x.linef("%s r.EncodeRawExt(%s)", hasIf.c(true), varname)
return
}
- // only check for extensions if the type is named, and has a packagePath.
+ // only check for extensions if extensions are configured,
+ // and the type is named, and has a packagePath,
+ // and this is not the CodecEncodeSelf or CodecDecodeSelf method (i.e. it is not a Selfer)
var arrayOrStruct = tk == reflect.Array || tk == reflect.Struct // meaning varname if of type *T
- if !x.nx && genImportPath(t) != "" && t.Name() != "" {
+ if !x.nx && varname != genTopLevelVarName && genImportPath(t) != "" && t.Name() != "" {
yy := fmt.Sprintf("%sxt%s", genTempVarPfx, mi)
- x.linef("} else if %s := z.Extension(z.I2Rtid(%s)); %s != nil { z.EncExtension(%s, %s) ", yy, varname, yy, varname, yy)
+ x.linef("%s %s := z.Extension(z.I2Rtid(%s)); %s != nil { z.EncExtension(%s, %s) ",
+ hasIf.c(false), yy, varname, yy, varname, yy)
}
if arrayOrStruct { // varname is of type *T
- if ti2.bm || ti2.bmp { // t.Implements(binaryMarshalerTyp) || tptr.Implements(binaryMarshalerTyp) {
- x.linef("} else if z.EncBinary() { z.EncBinaryMarshal(%v) ", varname)
+ if ti2.isFlag(tiflagBinaryMarshaler) || ti2.isFlag(tiflagBinaryMarshalerPtr) {
+ x.linef("%s z.EncBinary() { z.EncBinaryMarshal(%v) ", hasIf.c(false), varname)
}
- if ti2.jm || ti2.jmp { // t.Implements(jsonMarshalerTyp) || tptr.Implements(jsonMarshalerTyp) {
- x.linef("} else if !z.EncBinary() && z.IsJSONHandle() { z.EncJSONMarshal(%v) ", varname)
- } else if ti2.tm || ti2.tmp { // t.Implements(textMarshalerTyp) || tptr.Implements(textMarshalerTyp) {
- x.linef("} else if !z.EncBinary() { z.EncTextMarshal(%v) ", varname)
+ if ti2.isFlag(tiflagJsonMarshaler) || ti2.isFlag(tiflagJsonMarshalerPtr) {
+ x.linef("%s !z.EncBinary() && z.IsJSONHandle() { z.EncJSONMarshal(%v) ", hasIf.c(false), varname)
+ } else if ti2.isFlag(tiflagTextUnmarshaler) || ti2.isFlag(tiflagTextUnmarshalerPtr) {
+ x.linef("%s !z.EncBinary() { z.EncTextMarshal(%v) ", hasIf.c(false), varname)
}
} else { // varname is of type T
- if ti2.bm { // t.Implements(binaryMarshalerTyp) {
- x.linef("} else if z.EncBinary() { z.EncBinaryMarshal(%v) ", varname)
- } else if ti2.bmp { // tptr.Implements(binaryMarshalerTyp) {
- x.linef("} else if z.EncBinary() { z.EncBinaryMarshal(&%v) ", varname)
+ if ti2.isFlag(tiflagBinaryMarshaler) {
+ x.linef("%s z.EncBinary() { z.EncBinaryMarshal(%v) ", hasIf.c(false), varname)
+ } else if ti2.isFlag(tiflagBinaryMarshalerPtr) {
+ x.linef("%s z.EncBinary() { z.EncBinaryMarshal(&%v) ", hasIf.c(false), varname)
}
- if ti2.jm { // t.Implements(jsonMarshalerTyp) {
- x.linef("} else if !z.EncBinary() && z.IsJSONHandle() { z.EncJSONMarshal(%v) ", varname)
- } else if ti2.jmp { // tptr.Implements(jsonMarshalerTyp) {
- x.linef("} else if !z.EncBinary() && z.IsJSONHandle() { z.EncJSONMarshal(&%v) ", varname)
- } else if ti2.tm { // t.Implements(textMarshalerTyp) {
- x.linef("} else if !z.EncBinary() { z.EncTextMarshal(%v) ", varname)
- } else if ti2.tmp { // tptr.Implements(textMarshalerTyp) {
- x.linef("} else if !z.EncBinary() { z.EncTextMarshal(&%v) ", varname)
+ if ti2.isFlag(tiflagJsonMarshaler) {
+ x.linef("%s !z.EncBinary() && z.IsJSONHandle() { z.EncJSONMarshal(%v) ", hasIf.c(false), varname)
+ } else if ti2.isFlag(tiflagJsonMarshalerPtr) {
+ x.linef("%s !z.EncBinary() && z.IsJSONHandle() { z.EncJSONMarshal(&%v) ", hasIf.c(false), varname)
+ } else if ti2.isFlag(tiflagTextMarshaler) {
+ x.linef("%s !z.EncBinary() { z.EncTextMarshal(%v) ", hasIf.c(false), varname)
+ } else if ti2.isFlag(tiflagTextMarshalerPtr) {
+ x.linef("%s !z.EncBinary() { z.EncTextMarshal(&%v) ", hasIf.c(false), varname)
}
}
- x.line("} else {")
+ x.lineIf(hasIf.c(true))
switch t.Kind() {
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
@@ -798,7 +858,7 @@ func (x *genRunner) enc(varname string, t reflect.Type) {
case reflect.Bool:
x.line("r.EncodeBool(bool(" + varname + "))")
case reflect.String:
- x.line("r.EncodeStringEnc(codecSelferCcUTF8" + x.xs + ", string(" + varname + "))")
+ x.linef("r.EncodeString(string(%s))", varname)
case reflect.Chan:
x.xtraSM(varname, t, true, false)
// x.encListFallback(varname, rtid, t)
@@ -811,29 +871,30 @@ func (x *genRunner) enc(varname string, t reflect.Type) {
// else write encode function in-line.
// - if elements are primitives or Selfers, call dedicated function on each member.
// - else call Encoder.encode(XXX) on it.
+ x.linef("if %s == nil { r.EncodeNil() } else {", varname)
if rtid == uint8SliceTypId {
x.line("r.EncodeStringBytesRaw([]byte(" + varname + "))")
} else if fastpathAV.index(rtid) != -1 {
- g := x.newGenV(t)
+ g := x.newFastpathGenV(t)
x.line("z.F." + g.MethodNamePfx("Enc", false) + "V(" + varname + ", e)")
} else {
x.xtraSM(varname, t, true, false)
- // x.encListFallback(varname, rtid, t)
}
+ x.linef("} // end block: if %s slice == nil", varname)
case reflect.Map:
// if nil, call dedicated function
// if a known fastpath map, call dedicated function
// else write encode function in-line.
// - if elements are primitives or Selfers, call dedicated function on each member.
// - else call Encoder.encode(XXX) on it.
- // x.line("if " + varname + " == nil { \nr.EncodeNil()\n } else { ")
+ x.linef("if %s == nil { r.EncodeNil() } else {", varname)
if fastpathAV.index(rtid) != -1 {
- g := x.newGenV(t)
+ g := x.newFastpathGenV(t)
x.line("z.F." + g.MethodNamePfx("Enc", false) + "V(" + varname + ", e)")
} else {
x.xtraSM(varname, t, true, false)
- // x.encMapFallback(varname, rtid, t)
}
+ x.linef("} // end block: if %s map == nil", varname)
case reflect.Struct:
if !inlist {
delete(x.te, rtid)
@@ -862,12 +923,17 @@ func (x *genRunner) encZero(t reflect.Type) {
case reflect.Bool:
x.line("r.EncodeBool(false)")
case reflect.String:
- x.line("r.EncodeStringEnc(codecSelferCcUTF8" + x.xs + `, "")`)
+ x.linef(`r.EncodeString("")`)
default:
x.line("r.EncodeNil()")
}
}
+func (x *genRunner) doEncOmitEmptyLine(t2 reflect.StructField, varname string, buf *genBuf) {
+ x.f = 0
+ x.encOmitEmptyLine(t2, varname, buf)
+}
+
func (x *genRunner) encOmitEmptyLine(t2 reflect.StructField, varname string, buf *genBuf) {
// smartly check omitEmpty on a struct type, as it may contain uncomparable map/slice/etc.
// also, for maps/slices/arrays, check if len ! 0 (not if == zero value)
@@ -881,16 +947,16 @@ func (x *genRunner) encOmitEmptyLine(t2 reflect.StructField, varname string, buf
buf.s("!(").s(varname2).s(".IsZero())")
break
}
- if ti2.isFlag(typeInfoFlagIsZeroerPtr) || ti2.isFlag(typeInfoFlagIsZeroer) {
+ if ti2.isFlag(tiflagIsZeroerPtr) || ti2.isFlag(tiflagIsZeroer) {
buf.s("!(").s(varname2).s(".IsZero())")
break
}
- if ti2.isFlag(typeInfoFlagComparable) {
+ if ti2.isFlag(tiflagComparable) {
buf.s(varname2).s(" != ").s(x.genZeroValueR(t2.Type))
break
}
// buf.s("(")
- buf.s("false")
+ buf.s(x.sayFalse()) // buf.s("false")
for i, n := 0, t2.Type.NumField(); i < n; i++ {
f := t2.Type.Field(i)
if f.PkgPath != "" { // unexported
@@ -939,9 +1005,7 @@ func (x *genRunner) encStruct(varname string, rtid uintptr, t reflect.Type) {
for j, si := range tisfi {
_ = j
if !si.omitEmpty() {
- // x.linef("%s[%v] = true // %s", numfieldsvar, j, si.fieldName)
x.linef("true, // %s", si.fieldName)
- // nn++
continue
}
var t2 reflect.StructField
@@ -968,36 +1032,31 @@ func (x *genRunner) encStruct(varname string, rtid uintptr, t reflect.Type) {
}
}
}
- x.encOmitEmptyLine(t2, varname, &omitline)
+ x.doEncOmitEmptyLine(t2, varname, &omitline)
x.linef("%s, // %s", omitline.v(), si.fieldName)
}
x.line("}")
x.linef("_ = %s", numfieldsvar)
}
- // x.linef("var %snn%s int", genTempVarPfx, i)
- x.linef("if %s || %s {", ti2arrayvar, struct2arrvar) // if ti.toArray {
- x.linef("r.WriteArrayStart(%d)", len(tisfi))
- x.linef("} else {") // if not ti.toArray
- if ti.anyOmitEmpty {
- // nn = 0
- // x.linef("var %snn%s = %v", genTempVarPfx, i, nn)
- x.linef("var %snn%s int", genTempVarPfx, i)
- x.linef("for _, b := range %s { if b { %snn%s++ } }", numfieldsvar, genTempVarPfx, i)
- x.linef("r.WriteMapStart(%snn%s)", genTempVarPfx, i)
- x.linef("%snn%s = %v", genTempVarPfx, i, 0)
- } else {
- x.linef("r.WriteMapStart(%d)", len(tisfi))
+
+ type genFQN struct {
+ i string
+ fqname string
+ nilLine genBuf
+ nilVar string
+ canNil bool
+ sf reflect.StructField
}
- x.line("}") // close if not StructToArray
+ genFQNs := make([]genFQN, len(tisfi))
for j, si := range tisfi {
- i := x.varsfx()
- isNilVarName := genTempVarPfx + "n" + i
- var labelUsed bool
- var t2 reflect.StructField
+ q := &genFQNs[j]
+ q.i = x.varsfx()
+ q.nilVar = genTempVarPfx + "n" + q.i
+ q.canNil = false
+ q.fqname = varname
{
t2typ := t
- varname3 := varname
for ij, ix := range si.is {
if uint8(ij) == si.nis {
break
@@ -1005,53 +1064,70 @@ func (x *genRunner) encStruct(varname string, rtid uintptr, t reflect.Type) {
for t2typ.Kind() == reflect.Ptr {
t2typ = t2typ.Elem()
}
- t2 = t2typ.Field(int(ix))
- t2typ = t2.Type
- varname3 = varname3 + "." + t2.Name
+ q.sf = t2typ.Field(int(ix))
+ t2typ = q.sf.Type
+ q.fqname += "." + q.sf.Name
if t2typ.Kind() == reflect.Ptr {
- if !labelUsed {
- x.line("var " + isNilVarName + " bool")
+ if !q.canNil {
+ q.nilLine.f("%s == nil", q.fqname)
+ q.canNil = true
+ } else {
+ q.nilLine.f(" || %s == nil", q.fqname)
}
- x.line("if " + varname3 + " == nil { " + isNilVarName + " = true ")
- x.line("goto LABEL" + i)
- x.line("}")
- labelUsed = true
- // "varname3 = new(" + x.genTypeName(t3.Elem()) + ") }")
}
}
- // t2 = t.FieldByIndex(si.is)
}
- if labelUsed {
- x.line("LABEL" + i + ":")
+ }
+
+ for j := range genFQNs {
+ q := &genFQNs[j]
+ if q.canNil {
+ x.linef("var %s bool = %s", q.nilVar, q.nilLine.v())
}
- // if the type of the field is a Selfer, or one of the ones
+ }
+
+ x.linef("if %s || %s {", ti2arrayvar, struct2arrvar) // if ti.toArray
+ x.linef("z.EncWriteArrayStart(%d)", len(tisfi))
- x.linef("if %s || %s {", ti2arrayvar, struct2arrvar) // if ti.toArray
- if labelUsed {
- x.linef("if %s { r.WriteArrayElem(); r.EncodeNil() } else { ", isNilVarName)
+ for j, si := range tisfi {
+ q := &genFQNs[j]
+ // if the type of the field is a Selfer, or one of the ones
+ if q.canNil {
+ x.linef("if %s { z.EncWriteArrayElem(); r.EncodeNil() } else { ", q.nilVar)
}
- x.line("r.WriteArrayElem()")
+ x.linef("z.EncWriteArrayElem()")
if si.omitEmpty() {
x.linef("if %s[%v] {", numfieldsvar, j)
}
- x.encVar(varname+"."+t2.Name, t2.Type)
+ x.encVarChkNil(q.fqname, q.sf.Type, false)
if si.omitEmpty() {
x.linef("} else {")
- x.encZero(t2.Type)
+ x.encZero(q.sf.Type)
x.linef("}")
}
- if labelUsed {
+ if q.canNil {
x.line("}")
}
+ }
- x.linef("} else {") // if not ti.toArray
+ x.line("z.EncWriteArrayEnd()")
+ x.linef("} else {") // if not ti.toArray
+ if ti.anyOmitEmpty {
+ x.linef("var %snn%s int", genTempVarPfx, i)
+ x.linef("for _, b := range %s { if b { %snn%s++ } }", numfieldsvar, genTempVarPfx, i)
+ x.linef("z.EncWriteMapStart(%snn%s)", genTempVarPfx, i)
+ x.linef("%snn%s = %v", genTempVarPfx, i, 0)
+ } else {
+ x.linef("z.EncWriteMapStart(%d)", len(tisfi))
+ }
+ for j, si := range tisfi {
+ q := &genFQNs[j]
if si.omitEmpty() {
x.linef("if %s[%v] {", numfieldsvar, j)
}
- x.line("r.WriteMapElemKey()")
+ x.linef("z.EncWriteMapElemKey()")
- // x.line("r.EncodeStringEnc(codecSelferCcUTF8" + x.xs + ", `" + si.encName + "`)")
// emulate EncStructFieldKey
switch ti.keyType {
case valueTypeInt:
@@ -1064,34 +1140,29 @@ func (x *genRunner) encStruct(varname string, rtid uintptr, t reflect.Type) {
if si.encNameAsciiAlphaNum {
x.linef(`if z.IsJSONHandle() { z.WriteStr("\"%s\"") } else { `, si.encName)
}
- x.linef("r.EncodeStringEnc(codecSelferCcUTF8%s, `%s`)", x.xs, si.encName)
+ x.linef("r.EncodeString(`%s`)", si.encName)
if si.encNameAsciiAlphaNum {
x.linef("}")
}
}
- // x.linef("r.EncStructFieldKey(codecSelferValueType%s%s, `%s`)", ti.keyType.String(), x.xs, si.encName)
- x.line("r.WriteMapElemValue()")
- if labelUsed {
- x.line("if " + isNilVarName + " { r.EncodeNil() } else { ")
- x.encVar(varname+"."+t2.Name, t2.Type)
+ x.line("z.EncWriteMapElemValue()")
+ if q.canNil {
+ x.line("if " + q.nilVar + " { r.EncodeNil() } else { ")
+ x.encVarChkNil(q.fqname, q.sf.Type, false)
x.line("}")
} else {
- x.encVar(varname+"."+t2.Name, t2.Type)
+ x.encVarChkNil(q.fqname, q.sf.Type, false)
}
if si.omitEmpty() {
x.line("}")
}
- x.linef("} ") // end if/else ti.toArray
}
- x.linef("if %s || %s {", ti2arrayvar, struct2arrvar) // if ti.toArray {
- x.line("r.WriteArrayEnd()")
- x.line("} else {")
- x.line("r.WriteMapEnd()")
- x.line("}")
-
+ x.line("z.EncWriteMapEnd()")
+ x.linef("} ") // end if/else ti.toArray
}
func (x *genRunner) encListFallback(varname string, t reflect.Type) {
+ x.linef("if %s == nil { r.EncodeNil(); return }", varname)
elemBytes := t.Elem().Kind() == reflect.Uint8
if t.AssignableTo(uint8SliceTyp) {
x.linef("r.EncodeStringBytesRaw([]byte(%s))", varname)
@@ -1116,7 +1187,6 @@ func (x *genRunner) encListFallback(varname string, t reflect.Type) {
if err != nil {
panic(err)
}
- // x.linef("%s = sch%s", varname, i)
if elemBytes {
x.linef("r.EncodeStringBytesRaw([]byte(%s))", "sch"+i)
x.line("}")
@@ -1125,37 +1195,38 @@ func (x *genRunner) encListFallback(varname string, t reflect.Type) {
varname = "sch" + i
}
- x.line("r.WriteArrayStart(len(" + varname + "))")
+ x.line("z.EncWriteArrayStart(len(" + varname + "))")
x.linef("for _, %sv%s := range %s {", genTempVarPfx, i, varname)
- x.line("r.WriteArrayElem()")
+ x.linef("z.EncWriteArrayElem()")
x.encVar(genTempVarPfx+"v"+i, t.Elem())
x.line("}")
- x.line("r.WriteArrayEnd()")
+ x.line("z.EncWriteArrayEnd()")
if t.Kind() == reflect.Chan {
x.line("}")
}
}
func (x *genRunner) encMapFallback(varname string, t reflect.Type) {
- // TODO: expand this to handle canonical.
+ x.linef("if %s == nil { r.EncodeNil(); return }", varname)
+ // NOTE: Canonical Option is not honored
i := x.varsfx()
- x.line("r.WriteMapStart(len(" + varname + "))")
+ x.line("z.EncWriteMapStart(len(" + varname + "))")
x.linef("for %sk%s, %sv%s := range %s {", genTempVarPfx, i, genTempVarPfx, i, varname)
- x.line("r.WriteMapElemKey()")
+ x.linef("z.EncWriteMapElemKey()")
x.encVar(genTempVarPfx+"k"+i, t.Key())
- x.line("r.WriteMapElemValue()")
+ x.line("z.EncWriteMapElemValue()")
x.encVar(genTempVarPfx+"v"+i, t.Elem())
x.line("}")
- x.line("r.WriteMapEnd()")
+ x.line("z.EncWriteMapEnd()")
}
func (x *genRunner) decVarInitPtr(varname, nilvar string, t reflect.Type, si *structFieldInfo,
- newbuf, nilbuf *genBuf) (t2 reflect.StructField) {
+ newbuf, nilbuf *genBuf) (varname3 string, t2 reflect.StructField) {
//we must accommodate anonymous fields, where the embedded field is a nil pointer in the value.
// t2 = t.FieldByIndex(si.is)
+ varname3 = varname
t2typ := t
- varname3 := varname
t2kind := t2typ.Kind()
var nilbufed bool
if si != nil {
@@ -1163,7 +1234,8 @@ func (x *genRunner) decVarInitPtr(varname, nilvar string, t reflect.Type, si *st
if uint8(ij) == si.nis {
break
}
- for t2typ.Kind() == reflect.Ptr {
+ // only one-level pointers can be seen in a type
+ if t2typ.Kind() == reflect.Ptr {
t2typ = t2typ.Elem()
}
t2 = t2typ.Field(int(ix))
@@ -1174,23 +1246,24 @@ func (x *genRunner) decVarInitPtr(varname, nilvar string, t reflect.Type, si *st
continue
}
if newbuf != nil {
- newbuf.f("if %s == nil { %s = new(%s) }\n", varname3, varname3, x.genTypeName(t2typ.Elem()))
+ if len(newbuf.buf) > 0 {
+ newbuf.s("\n")
+ }
+ newbuf.f("if %s == nil { %s = new(%s) }", varname3, varname3, x.genTypeName(t2typ.Elem()))
}
if nilbuf != nil {
if !nilbufed {
- nilbuf.s("if true")
+ nilbuf.s("if ").s(varname3).s(" != nil")
nilbufed = true
+ } else {
+ nilbuf.s(" && ").s(varname3).s(" != nil")
}
- nilbuf.s(" && ").s(varname3).s(" != nil")
}
}
}
- // if t2typ.Kind() == reflect.Ptr {
- // varname3 = varname3 + t2.Name
- // }
if nilbuf != nil {
if nilbufed {
- nilbuf.s(" { ")
+ nilbuf.s(" { ").s("// remove the if-true\n")
}
if nilvar != "" {
nilbuf.s(nilvar).s(" = true")
@@ -1207,7 +1280,7 @@ func (x *genRunner) decVarInitPtr(varname, nilvar string, t reflect.Type, si *st
nilbuf.s("}")
}
}
- return t2
+ return
}
// decVar takes a variable called varname, of type t
@@ -1233,8 +1306,7 @@ func (x *genRunner) decVarMain(varname, rand string, t reflect.Type, checkNotNil
for t = t.Elem(); t.Kind() == reflect.Ptr; t = t.Elem() {
ptrPfx += "*"
if checkNotNil {
- x.linef("if %s%s == nil { %s%s = new(%s)}",
- ptrPfx, varname, ptrPfx, varname, x.genTypeName(t))
+ x.linef("if %s%s == nil { %s%s = new(%s)}", ptrPfx, varname, ptrPfx, varname, x.genTypeName(t))
}
}
// Should we create temp var if a slice/map indexing? No. dec(...) can now handle it.
@@ -1251,7 +1323,6 @@ func (x *genRunner) decVarMain(varname, rand string, t reflect.Type, checkNotNil
// decVar takes a variable called varname, of type t
func (x *genRunner) decVar(varname, nilvar string, t reflect.Type, canBeNil, checkNotNil bool) {
- i := x.varsfx()
// We only encode as nil if a nillable value.
// This removes some of the wasted checks for TryDecodeAsNil.
@@ -1260,22 +1331,15 @@ func (x *genRunner) decVar(varname, nilvar string, t reflect.Type, canBeNil, che
// This could happen when decoding from a struct encoded as an array.
// For that, decVar should be called with canNil=true, to force true as its value.
- if !canBeNil {
- canBeNil = genAnythingCanBeNil || !genIsImmutable(t)
- }
-
- if canBeNil {
+ i := x.varsfx()
+ if t.Kind() == reflect.Ptr {
var buf genBuf
x.decVarInitPtr(varname, nilvar, t, nil, nil, &buf)
- x.linef("if r.TryDecodeAsNil() { %s } else {", buf.buf)
- } else {
- x.line("// cannot be nil")
- }
-
- x.decVarMain(varname, i, t, checkNotNil)
-
- if canBeNil {
+ x.linef("if r.TryNil() { %s } else {", buf.buf)
+ x.decVarMain(varname, i, t, checkNotNil)
x.line("} ")
+ } else {
+ x.decVarMain(varname, i, t, checkNotNil)
}
}
@@ -1287,9 +1351,8 @@ func (x *genRunner) dec(varname string, t reflect.Type, isptr bool) {
// - t is always a baseType T (not a *T, etc).
rtid := rt2id(t)
ti2 := x.ti.get(rtid, t)
- // tptr := reflect.PtrTo(t)
if x.checkForSelfer(t, varname) {
- if ti2.cs || ti2.csp { // t.Implements(selferTyp) || tptr.Implements(selferTyp) {
+ if ti2.isFlag(tiflagSelfer) || ti2.isFlag(tiflagSelferPtr) {
x.line(varname + ".CodecDecodeSelf(d)")
return
}
@@ -1322,10 +1385,9 @@ func (x *genRunner) dec(varname string, t reflect.Type, isptr bool) {
// - the type implements (Text|JSON|Binary)(Unm|M)arshal
mi := x.varsfx()
- // x.linef("%sm%s := z.DecBinary()", genTempVarPfx, mi)
- // x.linef("_ = %sm%s", genTempVarPfx, mi)
- x.line("if false {") //start if block
- defer func() { x.line("}") }() //end if block
+
+ var hasIf genIfClause
+ defer hasIf.end(x)
var ptrPfx, addrPfx string
if isptr {
@@ -1334,37 +1396,38 @@ func (x *genRunner) dec(varname string, t reflect.Type, isptr bool) {
addrPfx = "&"
}
if t == timeTyp {
- x.linef("} else if !z.DecBasicHandle().TimeNotBuiltin { %s%v = r.DecodeTime()", ptrPfx, varname)
+ x.linef("%s !z.DecBasicHandle().TimeNotBuiltin { %s%v = r.DecodeTime()", hasIf.c(false), ptrPfx, varname)
// return
}
if t == rawTyp {
- x.linef("} else { %s%v = z.DecRaw()", ptrPfx, varname)
+ x.linef("%s %s%v = z.DecRaw()", hasIf.c(true), ptrPfx, varname)
return
}
if t == rawExtTyp {
- x.linef("} else { r.DecodeExt(%s%v, 0, nil)", addrPfx, varname)
+ x.linef("%s r.DecodeExt(%s%v, 0, nil)", hasIf.c(true), addrPfx, varname)
return
}
- // only check for extensions if the type is named, and has a packagePath.
- if !x.nx && genImportPath(t) != "" && t.Name() != "" {
+ // only check for extensions if extensions are configured,
+ // and the type is named, and has a packagePath,
+ // and this is not the CodecEncodeSelf or CodecDecodeSelf method (i.e. it is not a Selfer)
+ if !x.nx && varname != genTopLevelVarName && genImportPath(t) != "" && t.Name() != "" {
// first check if extensions are configued, before doing the interface conversion
- // x.linef("} else if z.HasExtensions() && z.DecExt(%s) {", varname)
yy := fmt.Sprintf("%sxt%s", genTempVarPfx, mi)
- x.linef("} else if %s := z.Extension(z.I2Rtid(%s)); %s != nil { z.DecExtension(%s, %s) ", yy, varname, yy, varname, yy)
+ x.linef("%s %s := z.Extension(z.I2Rtid(%s)); %s != nil { z.DecExtension(%s, %s) ", hasIf.c(false), yy, varname, yy, varname, yy)
}
- if ti2.bu || ti2.bup { // t.Implements(binaryUnmarshalerTyp) || tptr.Implements(binaryUnmarshalerTyp) {
- x.linef("} else if z.DecBinary() { z.DecBinaryUnmarshal(%s%v) ", addrPfx, varname)
+ if ti2.isFlag(tiflagBinaryUnmarshaler) || ti2.isFlag(tiflagBinaryUnmarshalerPtr) {
+ x.linef("%s z.DecBinary() { z.DecBinaryUnmarshal(%s%v) ", hasIf.c(false), addrPfx, varname)
}
- if ti2.ju || ti2.jup { // t.Implements(jsonUnmarshalerTyp) || tptr.Implements(jsonUnmarshalerTyp) {
- x.linef("} else if !z.DecBinary() && z.IsJSONHandle() { z.DecJSONUnmarshal(%s%v)", addrPfx, varname)
- } else if ti2.tu || ti2.tup { // t.Implements(textUnmarshalerTyp) || tptr.Implements(textUnmarshalerTyp) {
- x.linef("} else if !z.DecBinary() { z.DecTextUnmarshal(%s%v)", addrPfx, varname)
+ if ti2.isFlag(tiflagJsonUnmarshaler) || ti2.isFlag(tiflagJsonUnmarshalerPtr) {
+ x.linef("%s !z.DecBinary() && z.IsJSONHandle() { z.DecJSONUnmarshal(%s%v)", hasIf.c(false), addrPfx, varname)
+ } else if ti2.isFlag(tiflagTextUnmarshaler) || ti2.isFlag(tiflagTextUnmarshalerPtr) {
+ x.linef("%s !z.DecBinary() { z.DecTextUnmarshal(%s%v)", hasIf.c(false), addrPfx, varname)
}
- x.line("} else {")
+ x.lineIf(hasIf.c(true))
if x.decTryAssignPrimitive(varname, t, isptr) {
return
@@ -1383,7 +1446,7 @@ func (x *genRunner) dec(varname string, t reflect.Type, isptr bool) {
x.linef("%s%s = r.DecodeBytes(%s(%s[]byte)(%s), false)",
ptrPfx, varname, ptrPfx, ptrPfx, varname)
} else if fastpathAV.index(rtid) != -1 {
- g := x.newGenV(t)
+ g := x.newFastpathGenV(t)
x.linef("z.F.%sX(%s%s, d)", g.MethodNamePfx("Dec", false), addrPfx, varname)
} else {
x.xtraSM(varname, t, false, isptr)
@@ -1395,11 +1458,10 @@ func (x *genRunner) dec(varname string, t reflect.Type, isptr bool) {
// - if elements are primitives or Selfers, call dedicated function on each member.
// - else call Encoder.encode(XXX) on it.
if fastpathAV.index(rtid) != -1 {
- g := x.newGenV(t)
+ g := x.newFastpathGenV(t)
x.linef("z.F.%sX(%s%s, d)", g.MethodNamePfx("Dec", false), addrPfx, varname)
} else {
x.xtraSM(varname, t, false, isptr)
- // x.decMapFallback(varname, rtid, t)
}
case reflect.Struct:
if inlist {
@@ -1458,14 +1520,14 @@ func (x *genRunner) decTryAssignPrimitive(varname string, t reflect.Type, isptr
x.linef("%s%s = (%s)(z.C.UintV(r.DecodeUint64(), codecSelferBitsize%s))", ptr, varname, x.genTypeName(t), x.xs)
case reflect.Float32:
- x.linef("%s%s = (%s)(r.DecodeFloat32As64())", ptr, varname, x.genTypeName(t))
+ x.linef("%s%s = (%s)(z.DecDecodeFloat32())", ptr, varname, x.genTypeName(t))
case reflect.Float64:
x.linef("%s%s = (%s)(r.DecodeFloat64())", ptr, varname, x.genTypeName(t))
case reflect.Bool:
x.linef("%s%s = (%s)(r.DecodeBool())", ptr, varname, x.genTypeName(t))
case reflect.String:
- x.linef("%s%s = (%s)(r.DecodeString())", ptr, varname, x.genTypeName(t))
+ x.linef("%s%s = (%s)(string(r.DecodeStringAsBytes()))", ptr, varname, x.genTypeName(t))
default:
return false
}
@@ -1483,6 +1545,7 @@ func (x *genRunner) decListFallback(varname string, rtid uintptr, t reflect.Type
}
type tstruc struct {
TempVar string
+ Sfx string
Rand string
Varname string
CTyp string
@@ -1491,7 +1554,7 @@ func (x *genRunner) decListFallback(varname string, rtid uintptr, t reflect.Type
Size int
}
telem := t.Elem()
- ts := tstruc{genTempVarPfx, x.varsfx(), varname, x.genTypeName(t), x.genTypeName(telem), genIsImmutable(telem), int(telem.Size())}
+ ts := tstruc{genTempVarPfx, x.xs, x.varsfx(), varname, x.genTypeName(t), x.genTypeName(telem), genIsImmutable(telem), int(telem.Size())}
funcs := make(template.FuncMap)
@@ -1502,6 +1565,9 @@ func (x *genRunner) decListFallback(varname string, rtid uintptr, t reflect.Type
funcs["var"] = func(s string) string {
return ts.TempVar + s + ts.Rand
}
+ funcs["xs"] = func() string {
+ return ts.Sfx
+ }
funcs["zero"] = func() string {
return x.genZeroValueR(telem)
}
@@ -1564,6 +1630,9 @@ func (x *genRunner) decMapFallback(varname string, rtid uintptr, t reflect.Type)
funcs["var"] = func(s string) string {
return ts.TempVar + s + ts.Rand
}
+ funcs["xs"] = func() string {
+ return ts.Sfx
+ }
tm, err := template.New("").Funcs(funcs).Parse(genDecMapTmpl)
if err != nil {
@@ -1583,10 +1652,14 @@ func (x *genRunner) decStructMapSwitch(kName string, varname string, rtid uintpt
x.line("case \"" + si.encName + "\":")
newbuf.reset()
nilbuf.reset()
- t2 := x.decVarInitPtr(varname, "", t, si, &newbuf, &nilbuf)
- x.linef("if r.TryDecodeAsNil() { %s } else { %s", nilbuf.buf, newbuf.buf)
- x.decVarMain(varname+"."+t2.Name, x.varsfx(), t2.Type, false)
- x.line("}")
+ varname3, t2 := x.decVarInitPtr(varname, "", t, si, &newbuf, &nilbuf)
+ if len(newbuf.buf) > 0 {
+ x.linef("if r.TryNil() { %s } else { %s", nilbuf.buf, newbuf.buf)
+ }
+ x.decVarMain(varname3, x.varsfx(), t2.Type, false)
+ if len(newbuf.buf) > 0 {
+ x.line("}")
+ }
}
x.line("default:")
// pass the slice here, so that the string will not escape, and maybe save allocation
@@ -1604,14 +1677,14 @@ func (x *genRunner) decStructMap(varname, lenvarname string, rtid uintptr, t ref
case genStructMapStyleLenPrefix:
x.linef("for %sj%s := 0; %sj%s < %s; %sj%s++ {", tpfx, i, tpfx, i, lenvarname, tpfx, i)
case genStructMapStyleCheckBreak:
- x.linef("for %sj%s := 0; !r.CheckBreak(); %sj%s++ {", tpfx, i, tpfx, i)
+ x.linef("for %sj%s := 0; !z.DecCheckBreak(); %sj%s++ {", tpfx, i, tpfx, i)
default: // 0, otherwise.
x.linef("var %shl%s bool = %s >= 0", tpfx, i, lenvarname) // has length
x.linef("for %sj%s := 0; ; %sj%s++ {", tpfx, i, tpfx, i)
x.linef("if %shl%s { if %sj%s >= %s { break }", tpfx, i, tpfx, i, lenvarname)
- x.line("} else { if r.CheckBreak() { break }; }")
+ x.line("} else { if z.DecCheckBreak() { break }; }")
}
- x.line("r.ReadMapElemKey()")
+ x.line("z.DecReadMapElemKey()")
// emulate decstructfieldkey
switch ti.keyType {
@@ -1624,13 +1697,11 @@ func (x *genRunner) decStructMap(varname, lenvarname string, rtid uintptr, t ref
default: // string
x.linef("%s := z.StringView(r.DecodeStringAsBytes())", kName)
}
- // x.linef("%s := z.StringView(r.DecStructFieldKey(codecSelferValueType%s%s, z.DecScratchArrayBuffer()))", kName, ti.keyType.String(), x.xs)
- x.line("r.ReadMapElemValue()")
+ x.line("z.DecReadMapElemValue()")
x.decStructMapSwitch(kName, varname, rtid, t)
x.line("} // end for " + tpfx + "j" + i)
- x.line("r.ReadMapEnd()")
}
func (x *genRunner) decStructArray(varname, lenvarname, breakString string, rtid uintptr, t reflect.Type) {
@@ -1641,40 +1712,56 @@ func (x *genRunner) decStructArray(varname, lenvarname, breakString string, rtid
x.linef("var %sj%s int", tpfx, i)
x.linef("var %sb%s bool", tpfx, i) // break
x.linef("var %shl%s bool = %s >= 0", tpfx, i, lenvarname) // has length
- var newbuf, nilbuf genBuf
- for _, si := range tisfi {
- x.linef("%sj%s++; if %shl%s { %sb%s = %sj%s > %s } else { %sb%s = r.CheckBreak() }",
+ if !genDecStructArrayInlineLoopCheck {
+ x.linef("var %sfn%s = func() bool { ", tpfx, i)
+ x.linef("%sj%s++; if %shl%s { %sb%s = %sj%s > %s } else { %sb%s = z.DecCheckBreak() };",
tpfx, i, tpfx, i, tpfx, i,
tpfx, i, lenvarname, tpfx, i)
- x.linef("if %sb%s { r.ReadArrayEnd(); %s }", tpfx, i, breakString)
- x.line("r.ReadArrayElem()")
+ x.linef("if %sb%s { z.DecReadArrayEnd(); return true }; return false", tpfx, i)
+ x.linef("} // end func %sfn%s", tpfx, i)
+ }
+ var newbuf, nilbuf genBuf
+ for _, si := range tisfi {
+ if genDecStructArrayInlineLoopCheck {
+ x.linef("%sj%s++; if %shl%s { %sb%s = %sj%s > %s } else { %sb%s = z.DecCheckBreak() }",
+ tpfx, i, tpfx, i, tpfx, i,
+ tpfx, i, lenvarname, tpfx, i)
+ x.linef("if %sb%s { z.DecReadArrayEnd(); %s }", tpfx, i, breakString)
+ } else {
+ x.linef("if %sfn%s() { %s }", tpfx, i, breakString)
+ }
+ x.line("z.DecReadArrayElem()")
newbuf.reset()
nilbuf.reset()
- t2 := x.decVarInitPtr(varname, "", t, si, &newbuf, &nilbuf)
- x.linef("if r.TryDecodeAsNil() { %s } else { %s", nilbuf.buf, newbuf.buf)
- x.decVarMain(varname+"."+t2.Name, x.varsfx(), t2.Type, false)
- x.line("}")
+ varname3, t2 := x.decVarInitPtr(varname, "", t, si, &newbuf, &nilbuf)
+ if len(newbuf.buf) > 0 {
+ x.linef("if r.TryNil() { %s } else { %s", nilbuf.buf, newbuf.buf)
+ }
+ x.decVarMain(varname3, x.varsfx(), t2.Type, false)
+ if len(newbuf.buf) > 0 {
+ x.line("}")
+ }
}
// read remaining values and throw away.
x.line("for {")
- x.linef("%sj%s++; if %shl%s { %sb%s = %sj%s > %s } else { %sb%s = r.CheckBreak() }",
+ x.linef("%sj%s++; if %shl%s { %sb%s = %sj%s > %s } else { %sb%s = z.DecCheckBreak() }",
tpfx, i, tpfx, i, tpfx, i,
tpfx, i, lenvarname, tpfx, i)
x.linef("if %sb%s { break }", tpfx, i)
- x.line("r.ReadArrayElem()")
+ x.line("z.DecReadArrayElem()")
x.linef(`z.DecStructFieldNotFound(%sj%s - 1, "")`, tpfx, i)
x.line("}")
- x.line("r.ReadArrayEnd()")
}
func (x *genRunner) decStruct(varname string, rtid uintptr, t reflect.Type) {
// varname MUST be a ptr, or a struct field or a slice element.
i := x.varsfx()
x.linef("%sct%s := r.ContainerType()", genTempVarPfx, i)
- x.linef("if %sct%s == codecSelferValueTypeMap%s {", genTempVarPfx, i, x.xs)
- x.line(genTempVarPfx + "l" + i + " := r.ReadMapStart()")
+ x.linef("if %sct%s == codecSelferValueTypeNil%s {", genTempVarPfx, i, x.xs)
+ x.linef("*(%s) = %s{}", varname, x.genTypeName(t))
+ x.linef("} else if %sct%s == codecSelferValueTypeMap%s {", genTempVarPfx, i, x.xs)
+ x.line(genTempVarPfx + "l" + i + " := z.DecReadMapStart()")
x.linef("if %sl%s == 0 {", genTempVarPfx, i)
- x.line("r.ReadMapEnd()")
if genUseOneFunctionForDecStructMap {
x.line("} else { ")
x.linef("%s.codecDecodeSelfFromMap(%sl%s, d)", varname, genTempVarPfx, i)
@@ -1685,15 +1772,15 @@ func (x *genRunner) decStruct(varname string, rtid uintptr, t reflect.Type) {
x.line(varname + ".codecDecodeSelfFromMapCheckBreak(" + genTempVarPfx + "l" + i + ", d)")
}
x.line("}")
+ x.line("z.DecReadMapEnd()")
// else if container is array
x.linef("} else if %sct%s == codecSelferValueTypeArray%s {", genTempVarPfx, i, x.xs)
- x.line(genTempVarPfx + "l" + i + " := r.ReadArrayStart()")
- x.linef("if %sl%s == 0 {", genTempVarPfx, i)
- x.line("r.ReadArrayEnd()")
- x.line("} else { ")
+ x.line(genTempVarPfx + "l" + i + " := z.DecReadArrayStart()")
+ x.linef("if %sl%s != 0 {", genTempVarPfx, i)
x.linef("%s.codecDecodeSelfFromArray(%sl%s, d)", varname, genTempVarPfx, i)
x.line("}")
+ x.line("z.DecReadArrayEnd()")
// else panic
x.line("} else { ")
x.line("panic(errCodecSelferOnlyMapOrArrayEncodeToStruct" + x.xs + ")")
@@ -1702,15 +1789,17 @@ func (x *genRunner) decStruct(varname string, rtid uintptr, t reflect.Type) {
// --------
-type genV struct {
- // genV is either a primitive (Primitive != "") or a map (MapKey != "") or a slice
- MapKey string
- Elem string
- Primitive string
- Size int
+type fastpathGenV struct {
+ // fastpathGenV is either a primitive (Primitive != "") or a map (MapKey != "") or a slice
+ MapKey string
+ Elem string
+ Primitive string
+ Size int
+ NoCanonical bool
}
-func (x *genRunner) newGenV(t reflect.Type) (v genV) {
+func (x *genRunner) newFastpathGenV(t reflect.Type) (v fastpathGenV) {
+ v.NoCanonical = !genFastpathCanonical
switch t.Kind() {
case reflect.Slice, reflect.Array:
te := t.Elem()
@@ -1722,12 +1811,12 @@ func (x *genRunner) newGenV(t reflect.Type) (v genV) {
v.MapKey = x.genTypeName(tk)
v.Size = int(te.Size() + tk.Size())
default:
- panic("unexpected type for newGenV. Requires map or slice type")
+ panic("unexpected type for newFastpathGenV. Requires map or slice type")
}
return
}
-func (x *genV) MethodNamePfx(prefix string, prim bool) string {
+func (x *fastpathGenV) MethodNamePfx(prefix string, prim bool) string {
var name []byte
if prefix != "" {
name = append(name, prefix...)
@@ -1744,7 +1833,6 @@ func (x *genV) MethodNamePfx(prefix string, prim bool) string {
name = append(name, genTitleCaseName(x.Elem)...)
}
return string(name)
-
}
// genImportPath returns import path of a non-predeclared named typed, or an empty string otherwise.
@@ -1792,6 +1880,8 @@ func genTitleCaseName(s string) string {
switch s {
case "interface{}", "interface {}":
return "Intf"
+ case "[]byte", "[]uint8", "bytes":
+ return "Bytes"
default:
return strings.ToUpper(s[0:1]) + s[1:]
}
@@ -1879,7 +1969,7 @@ func genIsImmutable(t reflect.Type) (v bool) {
type genInternal struct {
Version int
- Values []genV
+ Values []fastpathGenV
}
func (x genInternal) FastpathLen() (l int) {
@@ -1895,6 +1985,8 @@ func genInternalZeroValue(s string) string {
switch s {
case "interface{}", "interface {}":
return "nil"
+ case "[]byte", "[]uint8", "bytes":
+ return "nil"
case "bool":
return "false"
case "string":
@@ -1904,48 +1996,59 @@ func genInternalZeroValue(s string) string {
}
}
-var genInternalNonZeroValueIdx [5]uint64
-var genInternalNonZeroValueStrs = [2][5]string{
- {`"string-is-an-interface"`, "true", `"some-string"`, "11.1", "33"},
- {`"string-is-an-interface-2"`, "true", `"some-string-2"`, "22.2", "44"},
+var genInternalNonZeroValueIdx [6]uint64
+var genInternalNonZeroValueStrs = [...][6]string{
+ {`"string-is-an-interface-1"`, "true", `"some-string-1"`, `[]byte("some-string-1")`, "11.1", "111"},
+ {`"string-is-an-interface-2"`, "false", `"some-string-2"`, `[]byte("some-string-2")`, "22.2", "77"},
+ {`"string-is-an-interface-3"`, "true", `"some-string-3"`, `[]byte("some-string-3")`, "33.3e3", "127"},
}
+// Note: last numbers must be in range: 0-127 (as they may be put into a int8, uint8, etc)
+
func genInternalNonZeroValue(s string) string {
+ var i int
switch s {
case "interface{}", "interface {}":
- genInternalNonZeroValueIdx[0]++
- return genInternalNonZeroValueStrs[genInternalNonZeroValueIdx[0]%2][0] // return string, to remove ambiguity
+ i = 0
case "bool":
- genInternalNonZeroValueIdx[1]++
- return genInternalNonZeroValueStrs[genInternalNonZeroValueIdx[1]%2][1]
+ i = 1
case "string":
- genInternalNonZeroValueIdx[2]++
- return genInternalNonZeroValueStrs[genInternalNonZeroValueIdx[2]%2][2]
+ i = 2
+ case "bytes", "[]byte", "[]uint8":
+ i = 3
case "float32", "float64", "float", "double":
- genInternalNonZeroValueIdx[3]++
- return genInternalNonZeroValueStrs[genInternalNonZeroValueIdx[3]%2][3]
+ i = 4
default:
- genInternalNonZeroValueIdx[4]++
- return genInternalNonZeroValueStrs[genInternalNonZeroValueIdx[4]%2][4]
+ i = 5
}
+ genInternalNonZeroValueIdx[i]++
+ idx := genInternalNonZeroValueIdx[i]
+ slen := uint64(len(genInternalNonZeroValueStrs))
+ return genInternalNonZeroValueStrs[idx%slen][i] // return string, to remove ambiguity
}
func genInternalEncCommandAsString(s string, vname string) string {
switch s {
- case "uint", "uint8", "uint16", "uint32", "uint64":
- return "ee.EncodeUint(uint64(" + vname + "))"
- case "int", "int8", "int16", "int32", "int64":
- return "ee.EncodeInt(int64(" + vname + "))"
+ case "uint64":
+ return "e.e.EncodeUint(" + vname + ")"
+ case "uint", "uint8", "uint16", "uint32":
+ return "e.e.EncodeUint(uint64(" + vname + "))"
+ case "int64":
+ return "e.e.EncodeInt(" + vname + ")"
+ case "int", "int8", "int16", "int32":
+ return "e.e.EncodeInt(int64(" + vname + "))"
+ case "[]byte", "[]uint8", "bytes":
+ return "e.e.EncodeStringBytesRaw(" + vname + ")"
case "string":
- return "ee.EncodeStringEnc(cUTF8, " + vname + ")"
+ return "e.e.EncodeString(" + vname + ")"
case "float32":
- return "ee.EncodeFloat32(" + vname + ")"
+ return "e.e.EncodeFloat32(" + vname + ")"
case "float64":
- return "ee.EncodeFloat64(" + vname + ")"
+ return "e.e.EncodeFloat64(" + vname + ")"
case "bool":
- return "ee.EncodeBool(" + vname + ")"
+ return "e.e.EncodeBool(" + vname + ")"
// case "symbol":
- // return "ee.EncodeSymbol(" + vname + ")"
+ // return "e.e.EncodeSymbol(" + vname + ")"
default:
return "e.encode(" + vname + ")"
}
@@ -1954,50 +2057,61 @@ func genInternalEncCommandAsString(s string, vname string) string {
func genInternalDecCommandAsString(s string) string {
switch s {
case "uint":
- return "uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))"
+ return "uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize))"
case "uint8":
- return "uint8(chkOvf.UintV(dd.DecodeUint64(), 8))"
+ return "uint8(chkOvf.UintV(d.d.DecodeUint64(), 8))"
case "uint16":
- return "uint16(chkOvf.UintV(dd.DecodeUint64(), 16))"
+ return "uint16(chkOvf.UintV(d.d.DecodeUint64(), 16))"
case "uint32":
- return "uint32(chkOvf.UintV(dd.DecodeUint64(), 32))"
+ return "uint32(chkOvf.UintV(d.d.DecodeUint64(), 32))"
case "uint64":
- return "dd.DecodeUint64()"
+ return "d.d.DecodeUint64()"
case "uintptr":
- return "uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))"
+ return "uintptr(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize))"
case "int":
- return "int(chkOvf.IntV(dd.DecodeInt64(), intBitsize))"
+ return "int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize))"
case "int8":
- return "int8(chkOvf.IntV(dd.DecodeInt64(), 8))"
+ return "int8(chkOvf.IntV(d.d.DecodeInt64(), 8))"
case "int16":
- return "int16(chkOvf.IntV(dd.DecodeInt64(), 16))"
+ return "int16(chkOvf.IntV(d.d.DecodeInt64(), 16))"
case "int32":
- return "int32(chkOvf.IntV(dd.DecodeInt64(), 32))"
+ return "int32(chkOvf.IntV(d.d.DecodeInt64(), 32))"
case "int64":
- return "dd.DecodeInt64()"
+ return "d.d.DecodeInt64()"
case "string":
- return "dd.DecodeString()"
+ return "string(d.d.DecodeStringAsBytes())"
+ case "[]byte", "[]uint8", "bytes":
+ return "d.d.DecodeBytes(nil, false)"
case "float32":
- return "float32(chkOvf.Float32V(dd.DecodeFloat64()))"
+ return "float32(d.decodeFloat32())"
case "float64":
- return "dd.DecodeFloat64()"
+ return "d.d.DecodeFloat64()"
case "bool":
- return "dd.DecodeBool()"
+ return "d.d.DecodeBool()"
default:
panic(errors.New("gen internal: unknown type for decode: " + s))
}
}
func genInternalSortType(s string, elem bool) string {
- for _, v := range [...]string{"int", "uint", "float", "bool", "string"} {
+ for _, v := range [...]string{
+ "int",
+ "uint",
+ "float",
+ "bool",
+ "string",
+ "bytes", "[]uint8", "[]byte",
+ } {
+ if v == "[]byte" || v == "[]uint8" {
+ v = "bytes"
+ }
if strings.HasPrefix(s, v) {
+ if v == "int" || v == "uint" || v == "float" {
+ v += "64"
+ }
if elem {
- if v == "int" || v == "uint" || v == "float" {
- return v + "64"
- } else {
- return v
- }
+ return v
}
return v + "Slice"
}
@@ -2024,49 +2138,12 @@ var genInternalTmplFuncs template.FuncMap
var genInternalOnce sync.Once
func genInternalInit() {
- types := [...]string{
- "interface{}",
- "string",
- "float32",
- "float64",
- "uint",
- "uint8",
- "uint16",
- "uint32",
- "uint64",
- "uintptr",
- "int",
- "int8",
- "int16",
- "int32",
- "int64",
- "bool",
- }
- // keep as slice, so it is in specific iteration order.
- // Initial order was uint64, string, interface{}, int, int64
- mapvaltypes := [...]string{
- "interface{}",
- "string",
- "uint",
- "uint8",
- "uint16",
- "uint32",
- "uint64",
- "uintptr",
- "int",
- "int8",
- "int16",
- "int32",
- "int64",
- "float32",
- "float64",
- "bool",
- }
wordSizeBytes := int(intBitsize) / 8
- mapvaltypes2 := map[string]int{
+ typesizes := map[string]int{
"interface{}": 2 * wordSizeBytes,
"string": 2 * wordSizeBytes,
+ "[]byte": 3 * wordSizeBytes,
"uint": 1 * wordSizeBytes,
"uint8": 1,
"uint16": 2,
@@ -2082,20 +2159,133 @@ func genInternalInit() {
"float64": 8,
"bool": 1,
}
+
+ // keep as slice, so it is in specific iteration order.
+ // Initial order was uint64, string, interface{}, int, int64, ...
+
+ var types = [...]string{
+ "interface{}",
+ "string",
+ "[]byte",
+ "float32",
+ "float64",
+ "uint",
+ "uint8",
+ "uint16",
+ "uint32",
+ "uint64",
+ "uintptr",
+ "int",
+ "int8",
+ "int16",
+ "int32",
+ "int64",
+ "bool",
+ }
+
+ var primitivetypes, slicetypes, mapkeytypes, mapvaltypes []string
+
+ primitivetypes = types[:]
+ slicetypes = types[:]
+ mapkeytypes = types[:]
+ mapvaltypes = types[:]
+
+ if genFastpathTrimTypes {
+ slicetypes = []string{
+ "interface{}",
+ "string",
+ "[]byte",
+ "float32",
+ "float64",
+ "uint",
+ // "uint8", // no need for fastpath of []uint8, as it is handled specially
+ "uint16",
+ "uint32",
+ "uint64",
+ // "uintptr",
+ "int",
+ "int8",
+ "int16",
+ "int32",
+ "int64",
+ "bool",
+ }
+
+ mapkeytypes = []string{
+ //"interface{}",
+ "string",
+ //"[]byte",
+ //"float32",
+ //"float64",
+ "uint",
+ "uint8",
+ //"uint16",
+ //"uint32",
+ "uint64",
+ //"uintptr",
+ "int",
+ //"int8",
+ //"int16",
+ //"int32",
+ "int64",
+ // "bool",
+ }
+
+ mapvaltypes = []string{
+ "interface{}",
+ "string",
+ "[]byte",
+ "uint",
+ "uint8",
+ //"uint16",
+ //"uint32",
+ "uint64",
+ // "uintptr",
+ "int",
+ //"int8",
+ //"int16",
+ //"int32",
+ "int64",
+ "float32",
+ "float64",
+ "bool",
+ }
+ }
+
+ // var mapkeytypes [len(&types) - 1]string // skip bool
+ // copy(mapkeytypes[:], types[:])
+
+ // var mb []byte
+ // mb = append(mb, '|')
+ // for _, s := range mapkeytypes {
+ // mb = append(mb, s...)
+ // mb = append(mb, '|')
+ // }
+ // var mapkeytypestr = string(mb)
+
var gt = genInternal{Version: genVersion}
// For each slice or map type, there must be a (symmetrical) Encode and Decode fast-path function
- for _, s := range types {
- gt.Values = append(gt.Values, genV{Primitive: s, Size: mapvaltypes2[s]})
+
+ for _, s := range primitivetypes {
+ gt.Values = append(gt.Values,
+ fastpathGenV{Primitive: s, Size: typesizes[s], NoCanonical: !genFastpathCanonical})
+ }
+ for _, s := range slicetypes {
// if s != "uint8" { // do not generate fast path for slice of bytes. Treat specially already.
- // gt.Values = append(gt.Values, genV{Elem: s, Size: mapvaltypes2[s]})
+ // gt.Values = append(gt.Values, fastpathGenV{Elem: s, Size: typesizes[s]})
+ // }
+ gt.Values = append(gt.Values,
+ fastpathGenV{Elem: s, Size: typesizes[s], NoCanonical: !genFastpathCanonical})
+ }
+ for _, s := range mapkeytypes {
+ // if _, ok := typesizes[s]; !ok {
+ // if strings.Contains(mapkeytypestr, "|"+s+"|") {
+ // gt.Values = append(gt.Values, fastpathGenV{MapKey: s, Elem: s, Size: 2 * typesizes[s]})
// }
- gt.Values = append(gt.Values, genV{Elem: s, Size: mapvaltypes2[s]})
- if _, ok := mapvaltypes2[s]; !ok {
- gt.Values = append(gt.Values, genV{MapKey: s, Elem: s, Size: 2 * mapvaltypes2[s]})
- }
for _, ms := range mapvaltypes {
- gt.Values = append(gt.Values, genV{MapKey: s, Elem: ms, Size: mapvaltypes2[s] + mapvaltypes2[ms]})
+ gt.Values = append(gt.Values,
+ fastpathGenV{MapKey: s, Elem: ms, Size: typesizes[s] + typesizes[ms], NoCanonical: !genFastpathCanonical})
}
}
diff --git a/vendor/github.com/ugorji/go/codec/go.mod b/vendor/github.com/ugorji/go/codec/go.mod
deleted file mode 100644
index 69ab4ea..0000000
--- a/vendor/github.com/ugorji/go/codec/go.mod
+++ /dev/null
@@ -1,3 +0,0 @@
-module github.com/ugorji/go/codec
-
-require github.com/ugorji/go v1.1.2
diff --git a/vendor/github.com/ugorji/go/codec/helper.go b/vendor/github.com/ugorji/go/codec/helper.go
index 8ada846..8f7626b 100644
--- a/vendor/github.com/ugorji/go/codec/helper.go
+++ b/vendor/github.com/ugorji/go/codec/helper.go
@@ -28,16 +28,6 @@ package codec
// Some streams also are text-based, and use explicit separators to denote the
// end/beginning of different values.
//
-// During encode, we use a high-level condition to determine how to iterate through
-// the container. That decision is based on whether the container is text-based (with
-// separators) or binary (without separators). If binary, we do not even call the
-// encoding of separators.
-//
-// During decode, we use a different high-level condition to determine how to iterate
-// through the containers. That decision is based on whether the stream contained
-// a length prefix, or if it used explicit breaks. If length-prefixed, we assume that
-// it has to be binary, and we do not even try to read separators.
-//
// Philosophy
// ------------
// On decode, this codec will update containers appropriately:
@@ -85,16 +75,59 @@ package codec
// and we don't have to keep sending the error value along with each call
// or storing it in the En|Decoder and checking it constantly along the way.
//
-// The disadvantage is that small functions which use panics cannot be inlined.
-// The code accounts for that by only using panics behind an interface;
-// since interface calls cannot be inlined, this is irrelevant.
-//
// We considered storing the error is En|Decoder.
// - once it has its err field set, it cannot be used again.
// - panicing will be optional, controlled by const flag.
// - code should always check error first and return early.
+//
// We eventually decided against it as it makes the code clumsier to always
// check for these error conditions.
+//
+// ------------------------------------------
+// We use sync.Pool only for the aid of long-lived objects shared across multiple goroutines.
+// Encoder, Decoder, enc|decDriver, reader|writer, etc do not fall into this bucket.
+//
+// Also, GC is much better now, eliminating some of the reasons to use a shared pool structure.
+// Instead, the short-lived objects use free-lists that live as long as the object exists.
+//
+// ------------------------------------------
+// Performance is affected by the following:
+// - Bounds Checking
+// - Inlining
+// - Pointer chasing
+// This package tries hard to manage the performance impact of these.
+//
+// ------------------------------------------
+// To alleviate performance due to pointer-chasing:
+// - Prefer non-pointer values in a struct field
+// - Refer to these directly within helper classes
+// e.g. json.go refers directly to d.d.decRd
+//
+// We made the changes to embed En/Decoder in en/decDriver,
+// but we had to explicitly reference the fields as opposed to using a function
+// to get the better performance that we were looking for.
+// For example, we explicitly call d.d.decRd.fn() instead of d.d.r().fn().
+//
+// ------------------------------------------
+// Bounds Checking
+// - Allow bytesDecReader to incur "bounds check error", and
+// recover that as an io.EOF.
+// This allows the bounds check branch to always be taken by the branch predictor,
+// giving better performance (in theory), while ensuring that the code is shorter.
+//
+// ------------------------------------------
+// Escape Analysis
+// - Prefer to return non-pointers if the value is used right away.
+// Newly allocated values returned as pointers will be heap-allocated as they escape.
+//
+// Prefer functions and methods that
+// - take no parameters and
+// - return no results and
+// - do not allocate.
+// These are optimized by the runtime.
+// For example, in json, we have dedicated functions for ReadMapElemKey, etc
+// which do not delegate to readDelim, as readDelim takes a parameter.
+// The difference in runtime was as much as 5%.
import (
"bytes"
@@ -114,7 +147,10 @@ import (
)
const (
- scratchByteArrayLen = 32
+ // rvNLen is the length of the array for readn or writen calls
+ rwNLen = 7
+
+ // scratchByteArrayLen = 64
// initCollectionCap = 16 // 32 is defensive. 16 is preferred.
// Support encoding.(Binary|Text)(Unm|M)arshaler.
@@ -139,51 +175,81 @@ const (
// so structFieldInfo fits into 8 bytes
maxLevelsEmbedding = 14
- // useFinalizers=true configures finalizers to release pool'ed resources
- // acquired by Encoder/Decoder during their GC.
- //
- // Note that calling SetFinalizer is always expensive,
- // as code must be run on the systemstack even for SetFinalizer(t, nil).
- //
- // We document that folks SHOULD call Release() when done, or they can
- // explicitly call SetFinalizer themselves e.g.
- // runtime.SetFinalizer(e, (*Encoder).Release)
- // runtime.SetFinalizer(d, (*Decoder).Release)
- useFinalizers = false
+ // xdebug controls whether xdebugf prints any output
+ xdebug = true
)
-var oneByteArr [1]byte
-var zeroByteSlice = oneByteArr[:0:0]
+var (
+ oneByteArr [1]byte
+ zeroByteSlice = oneByteArr[:0:0]
+
+ codecgen bool
+
+ panicv panicHdl
-var codecgen bool
+ refBitset bitset32
+ isnilBitset bitset32
+ scalarBitset bitset32
+)
-var refBitset bitset256
-var pool pooler
-var panicv panicHdl
+var (
+ errMapTypeNotMapKind = errors.New("MapType MUST be of Map Kind")
+ errSliceTypeNotSliceKind = errors.New("SliceType MUST be of Slice Kind")
+)
+
+var pool4tiload = sync.Pool{New: func() interface{} { return new(typeInfoLoadArray) }}
func init() {
- pool.init()
+ refBitset = refBitset.
+ set(byte(reflect.Map)).
+ set(byte(reflect.Ptr)).
+ set(byte(reflect.Func)).
+ set(byte(reflect.Chan)).
+ set(byte(reflect.UnsafePointer))
+
+ isnilBitset = isnilBitset.
+ set(byte(reflect.Map)).
+ set(byte(reflect.Ptr)).
+ set(byte(reflect.Func)).
+ set(byte(reflect.Chan)).
+ set(byte(reflect.UnsafePointer)).
+ set(byte(reflect.Interface)).
+ set(byte(reflect.Slice))
+
+ scalarBitset = scalarBitset.
+ set(byte(reflect.Bool)).
+ set(byte(reflect.Int)).
+ set(byte(reflect.Int8)).
+ set(byte(reflect.Int16)).
+ set(byte(reflect.Int32)).
+ set(byte(reflect.Int64)).
+ set(byte(reflect.Uint)).
+ set(byte(reflect.Uint8)).
+ set(byte(reflect.Uint16)).
+ set(byte(reflect.Uint32)).
+ set(byte(reflect.Uint64)).
+ set(byte(reflect.Uintptr)).
+ set(byte(reflect.Float32)).
+ set(byte(reflect.Float64)).
+ set(byte(reflect.Complex64)).
+ set(byte(reflect.Complex128)).
+ set(byte(reflect.String))
+
+}
+
+type handleFlag uint8
- refBitset.set(byte(reflect.Map))
- refBitset.set(byte(reflect.Ptr))
- refBitset.set(byte(reflect.Func))
- refBitset.set(byte(reflect.Chan))
-}
+const (
+ initedHandleFlag handleFlag = 1 << iota
+ binaryHandleFlag
+ jsonHandleFlag
+)
type clsErr struct {
closed bool // is it closed?
errClosed error // error on closing
}
-// type entryType uint8
-
-// const (
-// entryTypeBytes entryType = iota // make this 0, so a comparison is cheap
-// entryTypeIo
-// entryTypeBufio
-// entryTypeUnset = 255
-// )
-
type charEncoding uint8
const (
@@ -257,21 +323,15 @@ type containerState uint8
const (
_ containerState = iota
- containerMapStart // slot left open, since Driver method already covers it
+ containerMapStart
containerMapKey
containerMapValue
containerMapEnd
- containerArrayStart // slot left open, since Driver methods already cover it
+ containerArrayStart
containerArrayElem
containerArrayEnd
)
-// // sfiIdx used for tracking where a (field/enc)Name is seen in a []*structFieldInfo
-// type sfiIdx struct {
-// name string
-// index int
-// }
-
// do not recurse if a containing type refers to an embedded type
// which refers back to its containing type (via a pointer).
// The second time this back-reference happens, break out,
@@ -293,16 +353,15 @@ const (
typeInfoLoadArrayBLen = 8 * 4
)
+// typeInfoLoad is a transient object used while loading up a typeInfo.
type typeInfoLoad struct {
- // fNames []string
- // encNames []string
etypes []uintptr
sfis []structFieldInfo
}
+// typeInfoLoadArray is a cache object used to efficiently load up a typeInfo without
+// much allocation.
type typeInfoLoadArray struct {
- // fNames [typeInfoLoadArrayLen]string
- // encNames [typeInfoLoadArrayLen]string
sfis [typeInfoLoadArraySfisLen]structFieldInfo
sfiidx [typeInfoLoadArraySfiidxLen]byte
etypes [typeInfoLoadArrayEtypesLen]uintptr
@@ -347,8 +406,6 @@ func (e codecError) Error() string {
return fmt.Sprintf("%s error: %v", e.name, e.err)
}
-// type byteAccepter func(byte) bool
-
var (
bigen = binary.BigEndian
structInfoFieldName = "_struct"
@@ -441,6 +498,15 @@ var immutableKindsSet = [32]bool{
// reflect.UnsafePointer
}
+// SelfExt is a sentinel extension signifying that types
+// registered with it SHOULD be encoded and decoded
+// based on the native mode of the format.
+//
+// This allows users to define a tag for an extension,
+// but signify that the types should be encoded/decoded as the native encoding.
+// This way, users need not also define how to encode or decode the extension.
+var SelfExt = &extFailWrapper{}
+
// Selfer defines methods by which a value can encode or decode itself.
//
// Any type which implements Selfer will be able to encode or decode itself.
@@ -520,13 +586,22 @@ type BasicHandle struct {
extHandle
- intf2impls
+ rtidFns atomicRtidFnSlice
+ rtidFnsNoExt atomicRtidFnSlice
- inited uint32
- _ uint32 // padding
+ // ---- cache line
+
+ DecodeOptions
// ---- cache line
+ EncodeOptions
+
+ intf2impls
+
+ mu sync.Mutex
+ inited uint32 // holds if inited, and also handle flags (binary encoding, json handler, etc)
+
RPCOptions
// TimeNotBuiltin configures whether time.Time should be treated as a builtin type.
@@ -537,8 +612,14 @@ type BasicHandle struct {
// However, users can elect to handle time.Time as a custom extension, or via the
// standard library's encoding.Binary(M|Unm)arshaler or Text(M|Unm)arshaler interface.
// To elect this behavior, users can set TimeNotBuiltin=true.
+ //
// Note: Setting TimeNotBuiltin=true can be used to enable the legacy behavior
// (for Cbor and Msgpack), where time.Time was not a builtin supported type.
+ //
+ // Note: DO NOT CHANGE AFTER FIRST USE.
+ //
+ // Once a Handle has been used, do not modify this option.
+ // It will lead to unexpected behaviour during encoding and decoding.
TimeNotBuiltin bool
// ExplicitRelease configures whether Release() is implicitly called after an encode or
@@ -557,39 +638,67 @@ type BasicHandle struct {
// are returned to the shared pool before it is garbage-collected. Do it as below:
// runtime.SetFinalizer(e, (*Encoder).Release)
// runtime.SetFinalizer(d, (*Decoder).Release)
+ //
+ // Deprecated: This is not longer used as pools are only used for long-lived objects
+ // which are shared across goroutines.
+ // Setting this value has no effect. It is maintained for backward compatibility.
ExplicitRelease bool
- be bool // is handle a binary encoding?
- js bool // is handle javascript handler?
- n byte // first letter of handle name
- _ uint16 // padding
-
- // ---- cache line
-
- DecodeOptions
-
// ---- cache line
-
- EncodeOptions
-
- // noBuiltInTypeChecker
-
- rtidFns atomicRtidFnSlice
- mu sync.Mutex
- // r []uintptr // rtids mapped to s above
}
// basicHandle returns an initialized BasicHandle from the Handle.
func basicHandle(hh Handle) (x *BasicHandle) {
x = hh.getBasicHandle()
- if atomic.CompareAndSwapUint32(&x.inited, 0, 1) {
- x.be = hh.isBinary()
- _, x.js = hh.(*JsonHandle)
- x.n = hh.Name()[0]
+ // ** We need to simulate once.Do, to ensure no data race within the block.
+ // ** Consequently, below would not work.
+ // if atomic.CompareAndSwapUint32(&x.inited, 0, 1) {
+ // x.be = hh.isBinary()
+ // _, x.js = hh.(*JsonHandle)
+ // x.n = hh.Name()[0]
+ // }
+
+ // simulate once.Do using our own stored flag and mutex as a CompareAndSwap
+ // is not sufficient, since a race condition can occur within init(Handle) function.
+ // init is made noinline, so that this function can be inlined by its caller.
+ if atomic.LoadUint32(&x.inited) == 0 {
+ x.init(hh)
}
return
}
+func (x *BasicHandle) isJs() bool {
+ return handleFlag(x.inited)&jsonHandleFlag != 0
+}
+
+func (x *BasicHandle) isBe() bool {
+ return handleFlag(x.inited)&binaryHandleFlag != 0
+}
+
+//go:noinline
+func (x *BasicHandle) init(hh Handle) {
+ // make it uninlineable, as it is called at most once
+ x.mu.Lock()
+ if x.inited == 0 {
+ var f = initedHandleFlag
+ if hh.isBinary() {
+ f |= binaryHandleFlag
+ }
+ if _, b := hh.(*JsonHandle); b {
+ f |= jsonHandleFlag
+ }
+ atomic.StoreUint32(&x.inited, uint32(f))
+ // ensure MapType and SliceType are of correct type
+ if x.MapType != nil && x.MapType.Kind() != reflect.Map {
+ panic(errMapTypeNotMapKind)
+ }
+ if x.SliceType != nil && x.SliceType.Kind() != reflect.Slice {
+ panic(errSliceTypeNotSliceKind)
+ }
+ }
+ x.mu.Unlock()
+}
+
func (x *BasicHandle) getBasicHandle() *BasicHandle {
return x
}
@@ -624,31 +733,54 @@ LOOP:
return
}
-func (x *BasicHandle) fn(rt reflect.Type, checkFastpath, checkCodecSelfer bool) (fn *codecFn) {
+func (x *BasicHandle) fn(rt reflect.Type) (fn *codecFn) {
+ return x.fnVia(rt, &x.rtidFns, true)
+}
+
+func (x *BasicHandle) fnNoExt(rt reflect.Type) (fn *codecFn) {
+ return x.fnVia(rt, &x.rtidFnsNoExt, false)
+}
+
+func (x *BasicHandle) fnVia(rt reflect.Type, fs *atomicRtidFnSlice, checkExt bool) (fn *codecFn) {
rtid := rt2id(rt)
- sp := x.rtidFns.load()
+ sp := fs.load()
if sp != nil {
if _, fn = findFn(sp, rtid); fn != nil {
- // xdebugf("<<<< %c: found fn for %v in rtidfns of size: %v", c.n, rt, len(sp))
return
}
}
- c := x
- // xdebugf("#### for %c: load fn for %v in rtidfns of size: %v", c.n, rt, len(sp))
+ fn = x.fnLoad(rt, rtid, checkExt)
+ x.mu.Lock()
+ var sp2 []codecRtidFn
+ sp = fs.load()
+ if sp == nil {
+ sp2 = []codecRtidFn{{rtid, fn}}
+ fs.store(sp2)
+ } else {
+ idx, fn2 := findFn(sp, rtid)
+ if fn2 == nil {
+ sp2 = make([]codecRtidFn, len(sp)+1)
+ copy(sp2, sp[:idx])
+ copy(sp2[idx+1:], sp[idx:])
+ sp2[idx] = codecRtidFn{rtid, fn}
+ fs.store(sp2)
+ }
+ }
+ x.mu.Unlock()
+ return
+}
+
+func (x *BasicHandle) fnLoad(rt reflect.Type, rtid uintptr, checkExt bool) (fn *codecFn) {
fn = new(codecFn)
fi := &(fn.i)
- ti := c.getTypeInfo(rtid, rt)
+ ti := x.getTypeInfo(rtid, rt)
fi.ti = ti
rk := reflect.Kind(ti.kind)
- if checkCodecSelfer && (ti.cs || ti.csp) {
- fn.fe = (*Encoder).selferMarshal
- fn.fd = (*Decoder).selferUnmarshal
- fi.addrF = true
- fi.addrD = ti.csp
- fi.addrE = ti.csp
- } else if rtid == timeTypId && !c.TimeNotBuiltin {
+ // anything can be an extension except the built-in ones: time, raw and rawext
+
+ if rtid == timeTypId && !x.TimeNotBuiltin {
fn.fe = (*Encoder).kTime
fn.fd = (*Decoder).kTime
} else if rtid == rawTypId {
@@ -660,7 +792,7 @@ func (x *BasicHandle) fn(rt reflect.Type, checkFastpath, checkCodecSelfer bool)
fi.addrF = true
fi.addrD = true
fi.addrE = true
- } else if xfFn := c.getExt(rtid); xfFn != nil {
+ } else if xfFn := x.getExt(rtid, checkExt); xfFn != nil {
fi.xfTag, fi.xfFn = xfFn.tag, xfFn.ext
fn.fe = (*Encoder).ext
fn.fd = (*Decoder).ext
@@ -669,27 +801,39 @@ func (x *BasicHandle) fn(rt reflect.Type, checkFastpath, checkCodecSelfer bool)
if rk == reflect.Struct || rk == reflect.Array {
fi.addrE = true
}
- } else if supportMarshalInterfaces && c.be && (ti.bm || ti.bmp) && (ti.bu || ti.bup) {
+ } else if ti.isFlag(tiflagSelfer) || ti.isFlag(tiflagSelferPtr) {
+ fn.fe = (*Encoder).selferMarshal
+ fn.fd = (*Decoder).selferUnmarshal
+ fi.addrF = true
+ fi.addrD = ti.isFlag(tiflagSelferPtr)
+ fi.addrE = ti.isFlag(tiflagSelferPtr)
+ } else if supportMarshalInterfaces && x.isBe() &&
+ (ti.isFlag(tiflagBinaryMarshaler) || ti.isFlag(tiflagBinaryMarshalerPtr)) &&
+ (ti.isFlag(tiflagBinaryUnmarshaler) || ti.isFlag(tiflagBinaryUnmarshalerPtr)) {
fn.fe = (*Encoder).binaryMarshal
fn.fd = (*Decoder).binaryUnmarshal
fi.addrF = true
- fi.addrD = ti.bup
- fi.addrE = ti.bmp
- } else if supportMarshalInterfaces && !c.be && c.js && (ti.jm || ti.jmp) && (ti.ju || ti.jup) {
+ fi.addrD = ti.isFlag(tiflagBinaryUnmarshalerPtr)
+ fi.addrE = ti.isFlag(tiflagBinaryMarshalerPtr)
+ } else if supportMarshalInterfaces && !x.isBe() && x.isJs() &&
+ (ti.isFlag(tiflagJsonMarshaler) || ti.isFlag(tiflagJsonMarshalerPtr)) &&
+ (ti.isFlag(tiflagJsonUnmarshaler) || ti.isFlag(tiflagJsonUnmarshalerPtr)) {
//If JSON, we should check JSONMarshal before textMarshal
fn.fe = (*Encoder).jsonMarshal
fn.fd = (*Decoder).jsonUnmarshal
fi.addrF = true
- fi.addrD = ti.jup
- fi.addrE = ti.jmp
- } else if supportMarshalInterfaces && !c.be && (ti.tm || ti.tmp) && (ti.tu || ti.tup) {
+ fi.addrD = ti.isFlag(tiflagJsonUnmarshalerPtr)
+ fi.addrE = ti.isFlag(tiflagJsonMarshalerPtr)
+ } else if supportMarshalInterfaces && !x.isBe() &&
+ (ti.isFlag(tiflagTextMarshaler) || ti.isFlag(tiflagTextMarshalerPtr)) &&
+ (ti.isFlag(tiflagTextUnmarshaler) || ti.isFlag(tiflagTextUnmarshalerPtr)) {
fn.fe = (*Encoder).textMarshal
fn.fd = (*Decoder).textUnmarshal
fi.addrF = true
- fi.addrD = ti.tup
- fi.addrE = ti.tmp
+ fi.addrD = ti.isFlag(tiflagTextUnmarshalerPtr)
+ fi.addrE = ti.isFlag(tiflagTextMarshalerPtr)
} else {
- if fastpathEnabled && checkFastpath && (rk == reflect.Map || rk == reflect.Slice) {
+ if fastpathEnabled && (rk == reflect.Map || rk == reflect.Slice) {
if ti.pkgpath == "" { // un-named slice or map
if idx := fastpathAV.index(rtid); idx != -1 {
fn.fe = fastpathAV[idx].encfn
@@ -710,16 +854,17 @@ func (x *BasicHandle) fn(rt reflect.Type, checkFastpath, checkCodecSelfer bool)
xfnf := fastpathAV[idx].encfn
xrt := fastpathAV[idx].rt
fn.fe = func(e *Encoder, xf *codecFnInfo, xrv reflect.Value) {
- xfnf(e, xf, xrv.Convert(xrt))
+ xfnf(e, xf, rvConvert(xrv, xrt))
}
fi.addrD = true
fi.addrF = false // meaning it can be an address(ptr) or a value
xfnf2 := fastpathAV[idx].decfn
+ xptr2rt := reflect.PtrTo(xrt)
fn.fd = func(d *Decoder, xf *codecFnInfo, xrv reflect.Value) {
if xrv.Kind() == reflect.Ptr {
- xfnf2(d, xf, xrv.Convert(reflect.PtrTo(xrt)))
+ xfnf2(d, xf, rvConvert(xrv, xptr2rt))
} else {
- xfnf2(d, xf, xrv.Convert(xrt))
+ xfnf2(d, xf, rvConvert(xrv, xrt))
}
}
}
@@ -731,6 +876,16 @@ func (x *BasicHandle) fn(rt reflect.Type, checkFastpath, checkCodecSelfer bool)
fn.fe = (*Encoder).kBool
fn.fd = (*Decoder).kBool
case reflect.String:
+ // Do not use different functions based on StringToRaw option,
+ // as that will statically set the function for a string type,
+ // and if the Handle is modified thereafter, behaviour is non-deterministic.
+ // i.e. DO NOT DO:
+ // if x.StringToRaw {
+ // fn.fe = (*Encoder).kStringToRaw
+ // } else {
+ // fn.fe = (*Encoder).kStringEnc
+ // }
+
fn.fe = (*Encoder).kString
fn.fd = (*Decoder).kString
case reflect.Int:
@@ -777,24 +932,26 @@ func (x *BasicHandle) fn(rt reflect.Type, checkFastpath, checkCodecSelfer bool)
fn.fd = (*Decoder).kErr
case reflect.Chan:
fi.seq = seqTypeChan
- fn.fe = (*Encoder).kSlice
- fn.fd = (*Decoder).kSlice
+ fn.fe = (*Encoder).kChan
+ fn.fd = (*Decoder).kSliceForChan
case reflect.Slice:
fi.seq = seqTypeSlice
fn.fe = (*Encoder).kSlice
fn.fd = (*Decoder).kSlice
case reflect.Array:
fi.seq = seqTypeArray
- fn.fe = (*Encoder).kSlice
+ fn.fe = (*Encoder).kArray
fi.addrF = false
fi.addrD = false
rt2 := reflect.SliceOf(ti.elem)
fn.fd = func(d *Decoder, xf *codecFnInfo, xrv reflect.Value) {
- d.h.fn(rt2, true, false).fd(d, xf, xrv.Slice(0, xrv.Len()))
+ // call fnVia directly, so fn(...) is not recursive, and can be inlined
+ d.h.fnVia(rt2, &x.rtidFns, true).fd(d, xf, rvGetSlice4Array(xrv, rt2))
}
- // fn.fd = (*Decoder).kArray
case reflect.Struct:
- if ti.anyOmitEmpty || ti.mf || ti.mfp {
+ if ti.anyOmitEmpty ||
+ ti.isFlag(tiflagMissingFielder) ||
+ ti.isFlag(tiflagMissingFielderPtr) {
fn.fe = (*Encoder).kStruct
} else {
fn.fe = (*Encoder).kStructNoOmitempty
@@ -814,28 +971,6 @@ func (x *BasicHandle) fn(rt reflect.Type, checkFastpath, checkCodecSelfer bool)
}
}
}
-
- c.mu.Lock()
- var sp2 []codecRtidFn
- sp = c.rtidFns.load()
- if sp == nil {
- sp2 = []codecRtidFn{{rtid, fn}}
- c.rtidFns.store(sp2)
- // xdebugf(">>>> adding rt: %v to rtidfns of size: %v", rt, len(sp2))
- // xdebugf(">>>> loading stored rtidfns of size: %v", len(c.rtidFns.load()))
- } else {
- idx, fn2 := findFn(sp, rtid)
- if fn2 == nil {
- sp2 = make([]codecRtidFn, len(sp)+1)
- copy(sp2, sp[:idx])
- copy(sp2[idx+1:], sp[idx:])
- sp2[idx] = codecRtidFn{rtid, fn}
- c.rtidFns.store(sp2)
- // xdebugf(">>>> adding rt: %v to rtidfns of size: %v", rt, len(sp2))
-
- }
- }
- c.mu.Unlock()
return
}
@@ -845,8 +980,11 @@ func (x *BasicHandle) fn(rt reflect.Type, checkFastpath, checkCodecSelfer bool)
// Once a handle is configured, it can be shared across multiple Encoders and Decoders.
//
// Note that a Handle is NOT safe for concurrent modification.
-// Consequently, do not modify it after it is configured if shared among
-// multiple Encoders and Decoders in different goroutines.
+//
+// A Handle also should not be modified after it is configured and has
+// been used at least once. This is because stored state may be out of sync with the
+// new configuration, and a data race can occur when multiple goroutines access it.
+// i.e. multiple Encoders or Decoders in different goroutines.
//
// Consequently, the typical usage model is that a Handle is pre-configured
// before first time use, and not modified while in use.
@@ -856,12 +994,9 @@ type Handle interface {
// return the basic handle. It may not have been inited.
// Prefer to use basicHandle() helper function that ensures it has been inited.
getBasicHandle() *BasicHandle
- recreateEncDriver(encDriver) bool
- newEncDriver(w *Encoder) encDriver
- newDecDriver(r *Decoder) decDriver
+ newEncDriver() encDriver
+ newDecDriver() decDriver
isBinary() bool
- hasElemSeparators() bool
- // IsBuiltinType(rtid uintptr) bool
}
// Raw represents raw formatted bytes.
@@ -932,7 +1067,7 @@ type addExtWrapper struct {
}
func (x addExtWrapper) WriteExt(v interface{}) []byte {
- bs, err := x.encFn(reflect.ValueOf(v))
+ bs, err := x.encFn(rv4i(v))
if err != nil {
panic(err)
}
@@ -940,7 +1075,7 @@ func (x addExtWrapper) WriteExt(v interface{}) []byte {
}
func (x addExtWrapper) ReadExt(v interface{}, bs []byte) {
- if err := x.decFn(reflect.ValueOf(v), bs); err != nil {
+ if err := x.decFn(rv4i(v), bs); err != nil {
panic(err)
}
}
@@ -953,11 +1088,6 @@ func (x addExtWrapper) UpdateExt(dest interface{}, v interface{}) {
x.ReadExt(dest, v.([]byte))
}
-type extWrapper struct {
- BytesExt
- InterfaceExt
-}
-
type bytesExtFailer struct{}
func (bytesExtFailer) WriteExt(v interface{}) []byte {
@@ -978,6 +1108,21 @@ func (interfaceExtFailer) UpdateExt(dest interface{}, v interface{}) {
panicv.errorstr("InterfaceExt.UpdateExt is not supported")
}
+type bytesExtWrapper struct {
+ interfaceExtFailer
+ BytesExt
+}
+
+type interfaceExtWrapper struct {
+ bytesExtFailer
+ InterfaceExt
+}
+
+type extFailWrapper struct {
+ bytesExtFailer
+ interfaceExtFailer
+}
+
type binaryEncodingType struct{}
func (binaryEncodingType) isBinary() bool { return true }
@@ -989,29 +1134,16 @@ func (textEncodingType) isBinary() bool { return false }
// noBuiltInTypes is embedded into many types which do not support builtins
// e.g. msgpack, simple, cbor.
-// type noBuiltInTypeChecker struct{}
-// func (noBuiltInTypeChecker) IsBuiltinType(rt uintptr) bool { return false }
-// type noBuiltInTypes struct{ noBuiltInTypeChecker }
-
type noBuiltInTypes struct{}
func (noBuiltInTypes) EncodeBuiltin(rt uintptr, v interface{}) {}
func (noBuiltInTypes) DecodeBuiltin(rt uintptr, v interface{}) {}
-// type noStreamingCodec struct{}
-// func (noStreamingCodec) CheckBreak() bool { return false }
-// func (noStreamingCodec) hasElemSeparators() bool { return false }
-
-type noElemSeparators struct{}
-
-func (noElemSeparators) hasElemSeparators() (v bool) { return }
-func (noElemSeparators) recreateEncDriver(e encDriver) (v bool) { return }
-
// bigenHelper.
// Users must already slice the x completely, because we will not reslice.
type bigenHelper struct {
x []byte // must be correctly sliced to appropriate len. slicing is a cost.
- w *encWriterSwitch
+ w *encWr
}
func (z bigenHelper) writeUint16(v uint16) {
@@ -1035,7 +1167,7 @@ type extTypeTagFn struct {
rt reflect.Type
tag uint64
ext Ext
- _ [1]uint64 // padding
+ // _ [1]uint64 // padding
}
type extHandle []extTypeTagFn
@@ -1061,6 +1193,8 @@ func (o *extHandle) AddExt(rt reflect.Type, tag byte,
// Deprecated: Use SetBytesExt or SetInterfaceExt on the Handle instead.
func (o *extHandle) SetExt(rt reflect.Type, tag uint64, ext Ext) (err error) {
// o is a pointer, because we may need to initialize it
+ // We EXPECT *o is a pointer to a non-nil extHandle.
+
rk := rt.Kind()
for rk == reflect.Ptr {
rt = rt.Elem()
@@ -1074,16 +1208,12 @@ func (o *extHandle) SetExt(rt reflect.Type, tag uint64, ext Ext) (err error) {
rtid := rt2id(rt)
switch rtid {
case timeTypId, rawTypId, rawExtTypId:
- // all natively supported type, so cannot have an extension
- return // TODO: should we silently ignore, or return an error???
+ // all natively supported type, so cannot have an extension.
+ // However, we do not return an error for these, as we do not document that.
+ // Instead, we silently treat as a no-op, and return.
+ return
}
- // if o == nil {
- // return errors.New("codec.Handle.SetExt: extHandle not initialized")
- // }
o2 := *o
- // if o2 == nil {
- // return errors.New("codec.Handle.SetExt: extHandle not initialized")
- // }
for i := range o2 {
v := &o2[i]
if v.rtid == rtid {
@@ -1092,11 +1222,14 @@ func (o *extHandle) SetExt(rt reflect.Type, tag uint64, ext Ext) (err error) {
}
}
rtidptr := rt2id(reflect.PtrTo(rt))
- *o = append(o2, extTypeTagFn{rtid, rtidptr, rt, tag, ext, [1]uint64{}})
+ *o = append(o2, extTypeTagFn{rtid, rtidptr, rt, tag, ext}) // , [1]uint64{}})
return
}
-func (o extHandle) getExt(rtid uintptr) (v *extTypeTagFn) {
+func (o extHandle) getExt(rtid uintptr, check bool) (v *extTypeTagFn) {
+ if !check {
+ return
+ }
for i := range o {
v = &o[i]
if v.rtid == rtid || v.rtidptr == rtid {
@@ -1154,10 +1287,11 @@ func (o intf2impls) intf2impl(rtid uintptr) (rv reflect.Value) {
if v.impl == nil {
return
}
- if v.impl.Kind() == reflect.Ptr {
+ vkind := v.impl.Kind()
+ if vkind == reflect.Ptr {
return reflect.New(v.impl.Elem())
}
- return reflect.New(v.impl).Elem()
+ return rvZeroAddrK(v.impl, vkind)
}
}
return
@@ -1200,14 +1334,14 @@ type structFieldInfo struct {
encNameAsciiAlphaNum bool // the encName only contains ascii alphabet and numbers
structFieldInfoFlag
- _ [1]byte // padding
+ // _ [1]byte // padding
}
-func (si *structFieldInfo) setToZeroValue(v reflect.Value) {
- if v, valid := si.field(v, false); valid {
- v.Set(reflect.Zero(v.Type()))
- }
-}
+// func (si *structFieldInfo) setToZeroValue(v reflect.Value) {
+// if v, valid := si.field(v, false); valid {
+// v.Set(reflect.Zero(v.Type()))
+// }
+// }
// rv returns the field of the struct.
// If anonymous, it returns an Invalid
@@ -1226,11 +1360,6 @@ func (si *structFieldInfo) field(v reflect.Value, update bool) (rv2 reflect.Valu
return v, true
}
-// func (si *structFieldInfo) fieldval(v reflect.Value, update bool) reflect.Value {
-// v, _ = si.field(v, update)
-// return v
-// }
-
func parseStructInfo(stag string) (toArray, omitEmpty bool, keytype valueType) {
keytype = valueTypeString // default
if stag == "" {
@@ -1277,9 +1406,6 @@ func (si *structFieldInfo) parseTag(stag string) {
switch s {
case "omitempty":
si.flagSet(structFieldInfoFlagOmitEmpty)
- // si.omitEmpty = true
- // case "toarray":
- // si.toArray = true
}
}
}
@@ -1329,6 +1455,7 @@ type structFieldNode struct {
func (x *structFieldNode) field(si *structFieldInfo) (fv reflect.Value) {
// return si.fieldval(x.v, x.update)
+
// Note: we only cache if nis=2 or nis=3 i.e. up to 2 levels of embedding
// This mostly saves us time on the repeated calls to v.Elem, v.Field, etc.
var valid bool
@@ -1370,26 +1497,54 @@ func (x *structFieldNode) field(si *structFieldInfo) (fv reflect.Value) {
func baseStructRv(v reflect.Value, update bool) (v2 reflect.Value, valid bool) {
for v.Kind() == reflect.Ptr {
- if v.IsNil() {
+ if rvIsNil(v) {
if !update {
return
}
- v.Set(reflect.New(v.Type().Elem()))
+ rvSetDirect(v, reflect.New(v.Type().Elem()))
}
v = v.Elem()
}
return v, true
}
-type typeInfoFlag uint8
+type tiflag uint32
const (
- typeInfoFlagComparable = 1 << iota
- typeInfoFlagIsZeroer
- typeInfoFlagIsZeroerPtr
+ _ tiflag = 1 << iota
+
+ tiflagComparable
+
+ tiflagIsZeroer
+ tiflagIsZeroerPtr
+
+ tiflagBinaryMarshaler
+ tiflagBinaryMarshalerPtr
+
+ tiflagBinaryUnmarshaler
+ tiflagBinaryUnmarshalerPtr
+
+ tiflagTextMarshaler
+ tiflagTextMarshalerPtr
+
+ tiflagTextUnmarshaler
+ tiflagTextUnmarshalerPtr
+
+ tiflagJsonMarshaler
+ tiflagJsonMarshalerPtr
+
+ tiflagJsonUnmarshaler
+ tiflagJsonUnmarshalerPtr
+
+ tiflagSelfer
+ tiflagSelferPtr
+
+ tiflagMissingFielder
+ tiflagMissingFielderPtr
)
-// typeInfo keeps information about each (non-ptr) type referenced in the encode/decode sequence.
+// typeInfo keeps static (non-changing readonly)information
+// about each (non-ptr) type referenced in the encode/decode sequence.
//
// During an encode/decode sequence, we work as below:
// - If base is a built in type, en/decode base value
@@ -1403,7 +1558,6 @@ type typeInfo struct {
pkgpath string
rtid uintptr
- // rv0 reflect.Value // saved zero value, used if immutableKind
numMeth uint16 // number of methods
kind uint8
@@ -1424,38 +1578,35 @@ type typeInfo struct {
// sfis []structFieldInfo // all sfi, in src order, as created.
sfiNamesSort []byte // all names, with indexes into the sfiSort
- // format of marshal type fields below: [btj][mu]p? OR csp?
-
- bm bool // T is a binaryMarshaler
- bmp bool // *T is a binaryMarshaler
- bu bool // T is a binaryUnmarshaler
- bup bool // *T is a binaryUnmarshaler
- tm bool // T is a textMarshaler
- tmp bool // *T is a textMarshaler
- tu bool // T is a textUnmarshaler
- tup bool // *T is a textUnmarshaler
-
- jm bool // T is a jsonMarshaler
- jmp bool // *T is a jsonMarshaler
- ju bool // T is a jsonUnmarshaler
- jup bool // *T is a jsonUnmarshaler
- cs bool // T is a Selfer
- csp bool // *T is a Selfer
- mf bool // T is a MissingFielder
- mfp bool // *T is a MissingFielder
+ // rv0 is the zero value for the type.
+ // It is mostly beneficial for all non-reference kinds
+ // i.e. all but map/chan/func/ptr/unsafe.pointer
+ // so beneficial for intXX, bool, slices, structs, etc
+ rv0 reflect.Value
+
+ elemsize uintptr
// other flags, with individual bits representing if set.
- flags typeInfoFlag
+ flags tiflag
+
infoFieldOmitempty bool
- _ [6]byte // padding
- _ [2]uint64 // padding
+ elemkind uint8
+ _ [2]byte // padding
+ // _ [1]uint64 // padding
}
-func (ti *typeInfo) isFlag(f typeInfoFlag) bool {
+func (ti *typeInfo) isFlag(f tiflag) bool {
return ti.flags&f != 0
}
+func (ti *typeInfo) flag(when bool, f tiflag) *typeInfo {
+ if when {
+ ti.flags |= f
+ }
+ return ti
+}
+
func (ti *typeInfo) indexForEncName(name []byte) (index int16) {
var sn []byte
if len(name)+2 <= 32 {
@@ -1487,8 +1638,9 @@ type TypeInfos struct {
// infos: formerly map[uintptr]*typeInfo, now *[]rtid2ti, 2 words expected
infos atomicTypeInfoSlice
mu sync.Mutex
+ _ uint64 // padding (cache-aligned)
tags []string
- _ [2]uint64 // padding
+ _ uint64 // padding (cache-aligned)
}
// NewTypeInfos creates a TypeInfos given a set of struct tags keys.
@@ -1515,11 +1667,6 @@ func findTypeInfo(s []rtid2ti, rtid uintptr) (i uint, ti *typeInfo) {
// binary search. adapted from sort/search.go.
// Note: we use goto (instead of for loop) so this can be inlined.
- // if sp == nil {
- // return -1, nil
- // }
- // s := *sp
-
// h, i, j := 0, 0, len(s)
var h uint // var h, i uint
var j = uint(len(s))
@@ -1563,30 +1710,31 @@ func (x *TypeInfos) get(rtid uintptr, rt reflect.Type) (pti *typeInfo) {
pkgpath: rt.PkgPath(),
keyType: valueTypeString, // default it - so it's never 0
}
- // ti.rv0 = reflect.Zero(rt)
+ ti.rv0 = reflect.Zero(rt)
- // ti.comparable = rt.Comparable()
ti.numMeth = uint16(rt.NumMethod())
- ti.bm, ti.bmp = implIntf(rt, binaryMarshalerTyp)
- ti.bu, ti.bup = implIntf(rt, binaryUnmarshalerTyp)
- ti.tm, ti.tmp = implIntf(rt, textMarshalerTyp)
- ti.tu, ti.tup = implIntf(rt, textUnmarshalerTyp)
- ti.jm, ti.jmp = implIntf(rt, jsonMarshalerTyp)
- ti.ju, ti.jup = implIntf(rt, jsonUnmarshalerTyp)
- ti.cs, ti.csp = implIntf(rt, selferTyp)
- ti.mf, ti.mfp = implIntf(rt, missingFielderTyp)
-
- b1, b2 := implIntf(rt, iszeroTyp)
- if b1 {
- ti.flags |= typeInfoFlagIsZeroer
- }
- if b2 {
- ti.flags |= typeInfoFlagIsZeroerPtr
- }
- if rt.Comparable() {
- ti.flags |= typeInfoFlagComparable
- }
+ var b1, b2 bool
+ b1, b2 = implIntf(rt, binaryMarshalerTyp)
+ ti.flag(b1, tiflagBinaryMarshaler).flag(b2, tiflagBinaryMarshalerPtr)
+ b1, b2 = implIntf(rt, binaryUnmarshalerTyp)
+ ti.flag(b1, tiflagBinaryUnmarshaler).flag(b2, tiflagBinaryUnmarshalerPtr)
+ b1, b2 = implIntf(rt, textMarshalerTyp)
+ ti.flag(b1, tiflagTextMarshaler).flag(b2, tiflagTextMarshalerPtr)
+ b1, b2 = implIntf(rt, textUnmarshalerTyp)
+ ti.flag(b1, tiflagTextUnmarshaler).flag(b2, tiflagTextUnmarshalerPtr)
+ b1, b2 = implIntf(rt, jsonMarshalerTyp)
+ ti.flag(b1, tiflagJsonMarshaler).flag(b2, tiflagJsonMarshalerPtr)
+ b1, b2 = implIntf(rt, jsonUnmarshalerTyp)
+ ti.flag(b1, tiflagJsonUnmarshaler).flag(b2, tiflagJsonUnmarshalerPtr)
+ b1, b2 = implIntf(rt, selferTyp)
+ ti.flag(b1, tiflagSelfer).flag(b2, tiflagSelferPtr)
+ b1, b2 = implIntf(rt, missingFielderTyp)
+ ti.flag(b1, tiflagMissingFielder).flag(b2, tiflagMissingFielderPtr)
+ b1, b2 = implIntf(rt, iszeroTyp)
+ ti.flag(b1, tiflagIsZeroer).flag(b2, tiflagIsZeroerPtr)
+ b1 = rt.Comparable()
+ ti.flag(b1, tiflagComparable)
switch rk {
case reflect.Struct:
@@ -1597,13 +1745,12 @@ func (x *TypeInfos) get(rtid uintptr, rt reflect.Type) (pti *typeInfo) {
} else {
ti.keyType = valueTypeString
}
- pp, pi := &pool.tiload, pool.tiload.Get() // pool.tiLoad()
+ pp, pi := &pool4tiload, pool4tiload.Get() // pool.tiLoad()
pv := pi.(*typeInfoLoadArray)
pv.etypes[0] = ti.rtid
// vv := typeInfoLoad{pv.fNames[:0], pv.encNames[:0], pv.etypes[:1], pv.sfis[:0]}
vv := typeInfoLoad{pv.etypes[:1], pv.sfis[:0]}
x.rget(rt, rtid, omitEmpty, nil, &vv)
- // ti.sfis = vv.sfis
ti.sfiSrc, ti.sfiSort, ti.sfiNamesSort, ti.anyOmitEmpty = rgetResolveSFI(rt, vv.sfis, pv)
pp.Put(pi)
case reflect.Map:
@@ -1612,13 +1759,18 @@ func (x *TypeInfos) get(rtid uintptr, rt reflect.Type) (pti *typeInfo) {
case reflect.Slice:
ti.mbs, _ = implIntf(rt, mapBySliceTyp)
ti.elem = rt.Elem()
+ ti.elemsize = ti.elem.Size()
+ ti.elemkind = uint8(ti.elem.Kind())
case reflect.Chan:
ti.elem = rt.Elem()
ti.chandir = uint8(rt.ChanDir())
- case reflect.Array, reflect.Ptr:
+ case reflect.Array:
+ ti.elem = rt.Elem()
+ ti.elemsize = ti.elem.Size()
+ ti.elemkind = uint8(ti.elem.Kind())
+ case reflect.Ptr:
ti.elem = rt.Elem()
}
- // sfi = sfiSrc
x.mu.Lock()
sp = x.infos.load()
@@ -1765,9 +1917,6 @@ LOOP:
si.fieldName = f.Name
si.flagSet(structFieldInfoFlagReady)
- // pv.encNames = append(pv.encNames, si.encName)
-
- // si.ikind = int(f.Type.Kind())
if len(indexstack) > maxLevelsEmbedding-1 {
panicv.errorf("codec: only supports up to %v depth of embedding - type has %v depth",
maxLevelsEmbedding-1, len(indexstack))
@@ -1785,10 +1934,12 @@ LOOP:
func tiSep(name string) uint8 {
// (xn[0]%64) // (between 192-255 - outside ascii BMP)
- // return 0xfe - (name[0] & 63)
- // return 0xfe - (name[0] & 63) - uint8(len(name))
- // return 0xfe - (name[0] & 63) - uint8(len(name)&63)
- // return ((0xfe - (name[0] & 63)) & 0xf8) | (uint8(len(name) & 0x07))
+ // Tried the following before settling on correct implementation:
+ // return 0xfe - (name[0] & 63)
+ // return 0xfe - (name[0] & 63) - uint8(len(name))
+ // return 0xfe - (name[0] & 63) - uint8(len(name)&63)
+ // return ((0xfe - (name[0] & 63)) & 0xf8) | (uint8(len(name) & 0x07))
+
return 0xfe - (name[0] & 63) - uint8(len(name)&63)
}
@@ -1811,7 +1962,7 @@ func rgetResolveSFI(rt reflect.Type, x []structFieldInfo, pv *typeInfoLoadArray)
for i := range x {
ui = uint16(i)
xn = x[i].encName // fieldName or encName? use encName for now.
- if len(xn)+2 > cap(pv.b) {
+ if len(xn)+2 > cap(sn) {
sn = make([]byte, len(xn)+2)
} else {
sn = sn[:len(xn)+2]
@@ -1828,24 +1979,22 @@ func rgetResolveSFI(rt reflect.Type, x []structFieldInfo, pv *typeInfoLoadArray)
sa = append(sa, 0xff, byte(ui>>8), byte(ui))
} else {
index := uint16(sa[j+len(sn)+1]) | uint16(sa[j+len(sn)])<<8
- // one of them must be reset to nil,
- // and the index updated appropriately to the other one
- if x[i].nis == x[index].nis {
- } else if x[i].nis < x[index].nis {
+ // one of them must be cleared (reset to nil),
+ // and the index updated appropriately
+ i2clear := ui // index to be cleared
+ if x[i].nis < x[index].nis { // this one is shallower
+ // update the index to point to this later one.
sa[j+len(sn)], sa[j+len(sn)+1] = byte(ui>>8), byte(ui)
- if x[index].ready() {
- x[index].flagClr(structFieldInfoFlagReady)
- n--
- }
- } else {
- if x[i].ready() {
- x[i].flagClr(structFieldInfoFlagReady)
- n--
- }
+ // clear the earlier one, as this later one is shallower.
+ i2clear = index
+ }
+ if x[i2clear].ready() {
+ x[i2clear].flagClr(structFieldInfoFlagReady)
+ n--
}
}
-
}
+
var w []structFieldInfo
sharingArray := len(x) <= typeInfoLoadArraySfisLen // sharing array with typeInfoLoadArray
if sharingArray {
@@ -1921,13 +2070,13 @@ func isEmptyStruct(v reflect.Value, tinfos *TypeInfos, deref, checkStruct bool)
if ti.rtid == timeTypId {
return rv2i(v).(time.Time).IsZero()
}
- if ti.isFlag(typeInfoFlagIsZeroerPtr) && v.CanAddr() {
+ if ti.isFlag(tiflagIsZeroerPtr) && v.CanAddr() {
return rv2i(v.Addr()).(isZeroer).IsZero()
}
- if ti.isFlag(typeInfoFlagIsZeroer) {
+ if ti.isFlag(tiflagIsZeroer) {
return rv2i(v).(isZeroer).IsZero()
}
- if ti.isFlag(typeInfoFlagComparable) {
+ if ti.isFlag(tiflagComparable) {
return rv2i(v) == rv2i(reflect.Zero(vt))
}
if !checkStruct {
@@ -1964,7 +2113,13 @@ func panicToErr(h errDecorator, err *error) {
}
}
+func isSliceBoundsError(s string) bool {
+ return strings.Contains(s, "index out of range") ||
+ strings.Contains(s, "slice bounds out of range")
+}
+
func panicValToErr(h errDecorator, v interface{}, err *error) {
+ d, dok := h.(*Decoder)
switch xerr := v.(type) {
case nil:
case error:
@@ -1974,11 +2129,19 @@ func panicValToErr(h errDecorator, v interface{}, err *error) {
// treat as special (bubble up)
*err = xerr
default:
- h.wrapErr(xerr, err)
+ if dok && d.bytes && isSliceBoundsError(xerr.Error()) {
+ *err = io.EOF
+ } else {
+ h.wrapErr(xerr, err)
+ }
}
case string:
if xerr != "" {
- h.wrapErr(xerr, err)
+ if dok && d.bytes && isSliceBoundsError(xerr) {
+ *err = io.EOF
+ } else {
+ h.wrapErr(xerr, err)
+ }
}
case fmt.Stringer:
if xerr != nil {
@@ -1995,6 +2158,16 @@ func isImmutableKind(k reflect.Kind) (v bool) {
return immutableKindsSet[k%reflect.Kind(len(immutableKindsSet))] // bounds-check-elimination
}
+func usableByteSlice(bs []byte, slen int) []byte {
+ if cap(bs) >= slen {
+ if bs == nil {
+ return []byte{}
+ }
+ return bs[:slen]
+ }
+ return make([]byte, slen)
+}
+
// ----
type codecFnInfo struct {
@@ -2015,7 +2188,7 @@ type codecFn struct {
i codecFnInfo
fe func(*Encoder, *codecFnInfo, reflect.Value)
fd func(*Decoder, *codecFnInfo, reflect.Value)
- _ [1]uint64 // padding
+ _ [1]uint64 // padding (cache-aligned)
}
type codecRtidFn struct {
@@ -2023,6 +2196,29 @@ type codecRtidFn struct {
fn *codecFn
}
+func makeExt(ext interface{}) Ext {
+ if ext == nil {
+ return &extFailWrapper{}
+ }
+ switch t := ext.(type) {
+ case nil:
+ return &extFailWrapper{}
+ case Ext:
+ return t
+ case BytesExt:
+ return &bytesExtWrapper{BytesExt: t}
+ case InterfaceExt:
+ return &interfaceExtWrapper{InterfaceExt: t}
+ }
+ return &extFailWrapper{}
+}
+
+func baseRV(v interface{}) (rv reflect.Value) {
+ for rv = rv4i(v); rv.Kind() == reflect.Ptr; rv = rv.Elem() {
+ }
+ return
+}
+
// ----
// these "checkOverflow" functions must be inlinable, and not call anybody.
@@ -2105,9 +2301,52 @@ func (x checkOverflow) SignedIntV(v uint64) int64 {
return int64(v)
}
-// ------------------ SORT -----------------
+// ------------------ FLOATING POINT -----------------
+
+func isNaN64(f float64) bool { return f != f }
+func isNaN32(f float32) bool { return f != f }
+func abs32(f float32) float32 {
+ return math.Float32frombits(math.Float32bits(f) &^ (1 << 31))
+}
+
+// Per go spec, floats are represented in memory as
+// IEEE single or double precision floating point values.
+//
+// We also looked at the source for stdlib math/modf.go,
+// reviewed https://github.com/chewxy/math32
+// and read wikipedia documents describing the formats.
+//
+// It became clear that we could easily look at the bits to determine
+// whether any fraction exists.
+//
+// This is all we need for now.
+
+func noFrac64(f float64) (v bool) {
+ x := math.Float64bits(f)
+ e := uint64(x>>52)&0x7FF - 1023 // uint(x>>shift)&mask - bias
+ // clear top 12+e bits, the integer part; if the rest is 0, then no fraction.
+ if e < 52 {
+ // return x&((1<<64-1)>>(12+e)) == 0
+ return x<<(12+e) == 0
+ }
+ return
+}
+
+func noFrac32(f float32) (v bool) {
+ x := math.Float32bits(f)
+ e := uint32(x>>23)&0xFF - 127 // uint(x>>shift)&mask - bias
+ // clear top 9+e bits, the integer part; if the rest is 0, then no fraction.
+ if e < 23 {
+ // return x&((1<<32-1)>>(9+e)) == 0
+ return x<<(9+e) == 0
+ }
+ return
+}
-func isNaN(f float64) bool { return f != f }
+// func noFrac(f float64) bool {
+// _, frac := math.Modf(float64(f))
+// return frac == 0
+// }
// -----------------------
@@ -2125,141 +2364,21 @@ type ioBuffered interface {
// -----------------------
-type intSlice []int64
-type uintSlice []uint64
-
-// type uintptrSlice []uintptr
-type floatSlice []float64
-type boolSlice []bool
-type stringSlice []string
-
-// type bytesSlice [][]byte
-
-func (p intSlice) Len() int { return len(p) }
-func (p intSlice) Less(i, j int) bool { return p[uint(i)] < p[uint(j)] }
-func (p intSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
-
-func (p uintSlice) Len() int { return len(p) }
-func (p uintSlice) Less(i, j int) bool { return p[uint(i)] < p[uint(j)] }
-func (p uintSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
-
-// func (p uintptrSlice) Len() int { return len(p) }
-// func (p uintptrSlice) Less(i, j int) bool { return p[uint(i)] < p[uint(j)] }
-// func (p uintptrSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
-
-func (p floatSlice) Len() int { return len(p) }
-func (p floatSlice) Less(i, j int) bool {
- return p[uint(i)] < p[uint(j)] || isNaN(p[uint(i)]) && !isNaN(p[uint(j)])
-}
-func (p floatSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
-
-func (p stringSlice) Len() int { return len(p) }
-func (p stringSlice) Less(i, j int) bool { return p[uint(i)] < p[uint(j)] }
-func (p stringSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
-
-// func (p bytesSlice) Len() int { return len(p) }
-// func (p bytesSlice) Less(i, j int) bool { return bytes.Compare(p[uint(i)], p[uint(j)]) == -1 }
-// func (p bytesSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
-
-func (p boolSlice) Len() int { return len(p) }
-func (p boolSlice) Less(i, j int) bool { return !p[uint(i)] && p[uint(j)] }
-func (p boolSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
-
-// ---------------------
-
type sfiRv struct {
v *structFieldInfo
r reflect.Value
}
-type intRv struct {
- v int64
- r reflect.Value
-}
-type intRvSlice []intRv
-type uintRv struct {
- v uint64
- r reflect.Value
-}
-type uintRvSlice []uintRv
-type floatRv struct {
- v float64
- r reflect.Value
-}
-type floatRvSlice []floatRv
-type boolRv struct {
- v bool
- r reflect.Value
-}
-type boolRvSlice []boolRv
-type stringRv struct {
- v string
- r reflect.Value
-}
-type stringRvSlice []stringRv
-type bytesRv struct {
- v []byte
- r reflect.Value
-}
-type bytesRvSlice []bytesRv
-type timeRv struct {
- v time.Time
- r reflect.Value
-}
-type timeRvSlice []timeRv
-
-func (p intRvSlice) Len() int { return len(p) }
-func (p intRvSlice) Less(i, j int) bool { return p[uint(i)].v < p[uint(j)].v }
-func (p intRvSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
-
-func (p uintRvSlice) Len() int { return len(p) }
-func (p uintRvSlice) Less(i, j int) bool { return p[uint(i)].v < p[uint(j)].v }
-func (p uintRvSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
-
-func (p floatRvSlice) Len() int { return len(p) }
-func (p floatRvSlice) Less(i, j int) bool {
- return p[uint(i)].v < p[uint(j)].v || isNaN(p[uint(i)].v) && !isNaN(p[uint(j)].v)
-}
-func (p floatRvSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
-
-func (p stringRvSlice) Len() int { return len(p) }
-func (p stringRvSlice) Less(i, j int) bool { return p[uint(i)].v < p[uint(j)].v }
-func (p stringRvSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
-
-func (p bytesRvSlice) Len() int { return len(p) }
-func (p bytesRvSlice) Less(i, j int) bool { return bytes.Compare(p[uint(i)].v, p[uint(j)].v) == -1 }
-func (p bytesRvSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
-
-func (p boolRvSlice) Len() int { return len(p) }
-func (p boolRvSlice) Less(i, j int) bool { return !p[uint(i)].v && p[uint(j)].v }
-func (p boolRvSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
-
-func (p timeRvSlice) Len() int { return len(p) }
-func (p timeRvSlice) Less(i, j int) bool { return p[uint(i)].v.Before(p[uint(j)].v) }
-func (p timeRvSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
-
-// -----------------
-
-type bytesI struct {
- v []byte
- i interface{}
-}
-
-type bytesISlice []bytesI
-
-func (p bytesISlice) Len() int { return len(p) }
-func (p bytesISlice) Less(i, j int) bool { return bytes.Compare(p[uint(i)].v, p[uint(j)].v) == -1 }
-func (p bytesISlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
-
// -----------------
-type set []uintptr
+type set []interface{}
-func (s *set) add(v uintptr) (exists bool) {
+func (s *set) add(v interface{}) (exists bool) {
// e.ci is always nil, or len >= 1
x := *s
+
if x == nil {
- x = make([]uintptr, 1, 8)
+ x = make([]interface{}, 1, 8)
x[0] = v
*s = x
return
@@ -2296,7 +2415,7 @@ func (s *set) add(v uintptr) (exists bool) {
return
}
-func (s *set) remove(v uintptr) (exists bool) {
+func (s *set) remove(v interface{}) (exists bool) {
x := *s
if len(x) == 0 {
return
@@ -2334,8 +2453,13 @@ func (s *set) remove(v uintptr) (exists bool) {
type bitset256 [32]byte
+func (x *bitset256) check(pos byte) uint8 {
+ return x[pos>>3] & (1 << (pos & 7))
+}
+
func (x *bitset256) isset(pos byte) bool {
- return x[pos>>3]&(1<<(pos&7)) != 0
+ return x.check(pos) != 0
+ // return x[pos>>3]&(1<<(pos&7)) != 0
}
// func (x *bitset256) issetv(pos byte) byte {
@@ -2346,6 +2470,20 @@ func (x *bitset256) set(pos byte) {
x[pos>>3] |= (1 << (pos & 7))
}
+type bitset32 uint32
+
+func (x bitset32) set(pos byte) bitset32 {
+ return x | (1 << pos)
+}
+
+func (x bitset32) check(pos byte) uint32 {
+ return uint32(x) & (1 << pos)
+}
+func (x bitset32) isset(pos byte) bool {
+ return x.check(pos) != 0
+ // return x&(1<>3] &^= (1 << (pos & 7))
// }
@@ -2368,103 +2506,6 @@ func (x *bitset256) set(pos byte) {
// ------------
-type pooler struct {
- // function-scoped pooled resources
- tiload sync.Pool // for type info loading
- sfiRv8, sfiRv16, sfiRv32, sfiRv64, sfiRv128 sync.Pool // for struct encoding
-
- // lifetime-scoped pooled resources
- // dn sync.Pool // for decNaked
- buf1k, buf2k, buf4k, buf8k, buf16k, buf32k, buf64k sync.Pool // for [N]byte
-}
-
-func (p *pooler) init() {
- p.tiload.New = func() interface{} { return new(typeInfoLoadArray) }
-
- p.sfiRv8.New = func() interface{} { return new([8]sfiRv) }
- p.sfiRv16.New = func() interface{} { return new([16]sfiRv) }
- p.sfiRv32.New = func() interface{} { return new([32]sfiRv) }
- p.sfiRv64.New = func() interface{} { return new([64]sfiRv) }
- p.sfiRv128.New = func() interface{} { return new([128]sfiRv) }
-
- // p.dn.New = func() interface{} { x := new(decNaked); x.init(); return x }
-
- p.buf1k.New = func() interface{} { return new([1 * 1024]byte) }
- p.buf2k.New = func() interface{} { return new([2 * 1024]byte) }
- p.buf4k.New = func() interface{} { return new([4 * 1024]byte) }
- p.buf8k.New = func() interface{} { return new([8 * 1024]byte) }
- p.buf16k.New = func() interface{} { return new([16 * 1024]byte) }
- p.buf32k.New = func() interface{} { return new([32 * 1024]byte) }
- p.buf64k.New = func() interface{} { return new([64 * 1024]byte) }
-
-}
-
-// func (p *pooler) sfiRv8() (sp *sync.Pool, v interface{}) {
-// return &p.strRv8, p.strRv8.Get()
-// }
-// func (p *pooler) sfiRv16() (sp *sync.Pool, v interface{}) {
-// return &p.strRv16, p.strRv16.Get()
-// }
-// func (p *pooler) sfiRv32() (sp *sync.Pool, v interface{}) {
-// return &p.strRv32, p.strRv32.Get()
-// }
-// func (p *pooler) sfiRv64() (sp *sync.Pool, v interface{}) {
-// return &p.strRv64, p.strRv64.Get()
-// }
-// func (p *pooler) sfiRv128() (sp *sync.Pool, v interface{}) {
-// return &p.strRv128, p.strRv128.Get()
-// }
-
-// func (p *pooler) bytes1k() (sp *sync.Pool, v interface{}) {
-// return &p.buf1k, p.buf1k.Get()
-// }
-// func (p *pooler) bytes2k() (sp *sync.Pool, v interface{}) {
-// return &p.buf2k, p.buf2k.Get()
-// }
-// func (p *pooler) bytes4k() (sp *sync.Pool, v interface{}) {
-// return &p.buf4k, p.buf4k.Get()
-// }
-// func (p *pooler) bytes8k() (sp *sync.Pool, v interface{}) {
-// return &p.buf8k, p.buf8k.Get()
-// }
-// func (p *pooler) bytes16k() (sp *sync.Pool, v interface{}) {
-// return &p.buf16k, p.buf16k.Get()
-// }
-// func (p *pooler) bytes32k() (sp *sync.Pool, v interface{}) {
-// return &p.buf32k, p.buf32k.Get()
-// }
-// func (p *pooler) bytes64k() (sp *sync.Pool, v interface{}) {
-// return &p.buf64k, p.buf64k.Get()
-// }
-
-// func (p *pooler) tiLoad() (sp *sync.Pool, v interface{}) {
-// return &p.tiload, p.tiload.Get()
-// }
-
-// func (p *pooler) decNaked() (sp *sync.Pool, v interface{}) {
-// return &p.dn, p.dn.Get()
-// }
-
-// func (p *pooler) decNaked() (v *decNaked, f func(*decNaked) ) {
-// sp := &(p.dn)
-// vv := sp.Get()
-// return vv.(*decNaked), func(x *decNaked) { sp.Put(vv) }
-// }
-// func (p *pooler) decNakedGet() (v interface{}) {
-// return p.dn.Get()
-// }
-// func (p *pooler) tiLoadGet() (v interface{}) {
-// return p.tiload.Get()
-// }
-// func (p *pooler) decNakedPut(v interface{}) {
-// p.dn.Put(v)
-// }
-// func (p *pooler) tiLoadPut(v interface{}) {
-// p.tiload.Put(v)
-// }
-
-// ----------------------------------------------------
-
type panicHdl struct{}
func (panicHdl) errorv(err error) {
@@ -2480,12 +2521,13 @@ func (panicHdl) errorstr(message string) {
}
func (panicHdl) errorf(format string, params ...interface{}) {
- if format == "" {
- } else if len(params) == 0 {
- panic(format)
- } else {
+ if len(params) != 0 {
panic(fmt.Sprintf(format, params...))
}
+ if len(params) == 0 {
+ panic(format)
+ }
+ panic("undefined error")
}
// ----------------------------------------------------
@@ -2529,169 +2571,112 @@ func (must) Float(s float64, err error) float64 {
// -------------------
-type bytesBufPooler struct {
- pool *sync.Pool
- poolbuf interface{}
+func freelistCapacity(length int) (capacity int) {
+ for capacity = 8; capacity < length; capacity *= 2 {
+ }
+ return
}
-func (z *bytesBufPooler) end() {
- if z.pool != nil {
- z.pool.Put(z.poolbuf)
- z.pool, z.poolbuf = nil, nil
+type bytesFreelist [][]byte
+
+func (x *bytesFreelist) get(length int) (out []byte) {
+ var j int = -1
+ for i := 0; i < len(*x); i++ {
+ if cap((*x)[i]) >= length && (j == -1 || cap((*x)[j]) > cap((*x)[i])) {
+ j = i
+ }
+ }
+ if j == -1 {
+ return make([]byte, length, freelistCapacity(length))
+ }
+ out = (*x)[j][:length]
+ (*x)[j] = nil
+ for i := 0; i < len(out); i++ {
+ out[i] = 0
}
+ return
}
-func (z *bytesBufPooler) get(bufsize int) (buf []byte) {
- // ensure an end is called first (if necessary)
- if z.pool != nil {
- z.pool.Put(z.poolbuf)
- z.pool, z.poolbuf = nil, nil
+func (x *bytesFreelist) put(v []byte) {
+ if len(v) == 0 {
+ return
+ }
+ for i := 0; i < len(*x); i++ {
+ if cap((*x)[i]) == 0 {
+ (*x)[i] = v
+ return
+ }
}
+ *x = append(*x, v)
+}
- // // Try to use binary search.
- // // This is not optimal, as most folks select 1k or 2k buffers
- // // so a linear search is better (sequence of if/else blocks)
- // if bufsize < 1 {
- // bufsize = 0
- // } else {
- // bufsize--
- // bufsize /= 1024
- // }
- // switch bufsize {
- // case 0:
- // z.pool, z.poolbuf = pool.bytes1k()
- // buf = z.poolbuf.(*[1 * 1024]byte)[:]
- // case 1:
- // z.pool, z.poolbuf = pool.bytes2k()
- // buf = z.poolbuf.(*[2 * 1024]byte)[:]
- // case 2, 3:
- // z.pool, z.poolbuf = pool.bytes4k()
- // buf = z.poolbuf.(*[4 * 1024]byte)[:]
- // case 4, 5, 6, 7:
- // z.pool, z.poolbuf = pool.bytes8k()
- // buf = z.poolbuf.(*[8 * 1024]byte)[:]
- // case 8, 9, 10, 11, 12, 13, 14, 15:
- // z.pool, z.poolbuf = pool.bytes16k()
- // buf = z.poolbuf.(*[16 * 1024]byte)[:]
- // case 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31:
- // z.pool, z.poolbuf = pool.bytes32k()
- // buf = z.poolbuf.(*[32 * 1024]byte)[:]
- // default:
- // z.pool, z.poolbuf = pool.bytes64k()
- // buf = z.poolbuf.(*[64 * 1024]byte)[:]
- // }
- // return
-
- if bufsize <= 1*1024 {
- z.pool, z.poolbuf = &pool.buf1k, pool.buf1k.Get() // pool.bytes1k()
- buf = z.poolbuf.(*[1 * 1024]byte)[:]
- } else if bufsize <= 2*1024 {
- z.pool, z.poolbuf = &pool.buf2k, pool.buf2k.Get() // pool.bytes2k()
- buf = z.poolbuf.(*[2 * 1024]byte)[:]
- } else if bufsize <= 4*1024 {
- z.pool, z.poolbuf = &pool.buf4k, pool.buf4k.Get() // pool.bytes4k()
- buf = z.poolbuf.(*[4 * 1024]byte)[:]
- } else if bufsize <= 8*1024 {
- z.pool, z.poolbuf = &pool.buf8k, pool.buf8k.Get() // pool.bytes8k()
- buf = z.poolbuf.(*[8 * 1024]byte)[:]
- } else if bufsize <= 16*1024 {
- z.pool, z.poolbuf = &pool.buf16k, pool.buf16k.Get() // pool.bytes16k()
- buf = z.poolbuf.(*[16 * 1024]byte)[:]
- } else if bufsize <= 32*1024 {
- z.pool, z.poolbuf = &pool.buf32k, pool.buf32k.Get() // pool.bytes32k()
- buf = z.poolbuf.(*[32 * 1024]byte)[:]
- } else {
- z.pool, z.poolbuf = &pool.buf64k, pool.buf64k.Get() // pool.bytes64k()
- buf = z.poolbuf.(*[64 * 1024]byte)[:]
+func (x *bytesFreelist) check(v []byte, length int) (out []byte) {
+ if cap(v) < length {
+ x.put(v)
+ return x.get(length)
}
- return
+ return v[:length]
}
-// ----------------
+// -------------------------
-type sfiRvPooler struct {
- pool *sync.Pool
- poolv interface{}
-}
+type sfiRvFreelist [][]sfiRv
-func (z *sfiRvPooler) end() {
- if z.pool != nil {
- z.pool.Put(z.poolv)
- z.pool, z.poolv = nil, nil
+func (x *sfiRvFreelist) get(length int) (out []sfiRv) {
+ var j int = -1
+ for i := 0; i < len(*x); i++ {
+ if cap((*x)[i]) >= length && (j == -1 || cap((*x)[j]) > cap((*x)[i])) {
+ j = i
+ }
+ }
+ if j == -1 {
+ return make([]sfiRv, length, freelistCapacity(length))
+ }
+ out = (*x)[j][:length]
+ (*x)[j] = nil
+ for i := 0; i < len(out); i++ {
+ out[i] = sfiRv{}
}
+ return
}
-func (z *sfiRvPooler) get(newlen int) (fkvs []sfiRv) {
- if newlen < 0 { // bounds-check-elimination
- // cannot happen // here for bounds-check-elimination
- } else if newlen <= 8 {
- z.pool, z.poolv = &pool.sfiRv8, pool.sfiRv8.Get() // pool.sfiRv8()
- fkvs = z.poolv.(*[8]sfiRv)[:newlen]
- } else if newlen <= 16 {
- z.pool, z.poolv = &pool.sfiRv16, pool.sfiRv16.Get() // pool.sfiRv16()
- fkvs = z.poolv.(*[16]sfiRv)[:newlen]
- } else if newlen <= 32 {
- z.pool, z.poolv = &pool.sfiRv32, pool.sfiRv32.Get() // pool.sfiRv32()
- fkvs = z.poolv.(*[32]sfiRv)[:newlen]
- } else if newlen <= 64 {
- z.pool, z.poolv = &pool.sfiRv64, pool.sfiRv64.Get() // pool.sfiRv64()
- fkvs = z.poolv.(*[64]sfiRv)[:newlen]
- } else if newlen <= 128 {
- z.pool, z.poolv = &pool.sfiRv128, pool.sfiRv128.Get() // pool.sfiRv128()
- fkvs = z.poolv.(*[128]sfiRv)[:newlen]
- } else {
- fkvs = make([]sfiRv, newlen)
+func (x *sfiRvFreelist) put(v []sfiRv) {
+ for i := 0; i < len(*x); i++ {
+ if cap((*x)[i]) == 0 {
+ (*x)[i] = v
+ return
+ }
}
- return
+ *x = append(*x, v)
}
-// xdebugf prints the message in red on the terminal.
+// -----------
+
+// xdebugf printf. the message in red on the terminal.
// Use it in place of fmt.Printf (which it calls internally)
func xdebugf(pattern string, args ...interface{}) {
+ xdebugAnyf("31", pattern, args...)
+}
+
+// xdebug2f printf. the message in blue on the terminal.
+// Use it in place of fmt.Printf (which it calls internally)
+func xdebug2f(pattern string, args ...interface{}) {
+ xdebugAnyf("34", pattern, args...)
+}
+
+func xdebugAnyf(colorcode, pattern string, args ...interface{}) {
+ if !xdebug {
+ return
+ }
var delim string
if len(pattern) > 0 && pattern[len(pattern)-1] != '\n' {
delim = "\n"
}
- fmt.Printf("\033[1;31m"+pattern+delim+"\033[0m", args...)
-}
-
-// func isImmutableKind(k reflect.Kind) (v bool) {
-// return false ||
-// k == reflect.Int ||
-// k == reflect.Int8 ||
-// k == reflect.Int16 ||
-// k == reflect.Int32 ||
-// k == reflect.Int64 ||
-// k == reflect.Uint ||
-// k == reflect.Uint8 ||
-// k == reflect.Uint16 ||
-// k == reflect.Uint32 ||
-// k == reflect.Uint64 ||
-// k == reflect.Uintptr ||
-// k == reflect.Float32 ||
-// k == reflect.Float64 ||
-// k == reflect.Bool ||
-// k == reflect.String
-// }
+ fmt.Printf("\033[1;"+colorcode+"m"+pattern+delim+"\033[0m", args...)
+ // os.Stderr.Flush()
+}
-// func timeLocUTCName(tzint int16) string {
-// if tzint == 0 {
-// return "UTC"
-// }
-// var tzname = []byte("UTC+00:00")
-// //tzname := fmt.Sprintf("UTC%s%02d:%02d", tzsign, tz/60, tz%60) //perf issue using Sprintf. inline below.
-// //tzhr, tzmin := tz/60, tz%60 //faster if u convert to int first
-// var tzhr, tzmin int16
-// if tzint < 0 {
-// tzname[3] = '-' // (TODO: verify. this works here)
-// tzhr, tzmin = -tzint/60, (-tzint)%60
-// } else {
-// tzhr, tzmin = tzint/60, tzint%60
-// }
-// tzname[4] = timeDigits[tzhr/10]
-// tzname[5] = timeDigits[tzhr%10]
-// tzname[7] = timeDigits[tzmin/10]
-// tzname[8] = timeDigits[tzmin%10]
-// return string(tzname)
-// //return time.FixedZone(string(tzname), int(tzint)*60)
-// }
+// register these here, so that staticcheck stops barfing
+var _ = xdebug2f
+var _ = xdebugf
+var _ = isNaN32
diff --git a/vendor/github.com/ugorji/go/codec/helper_internal.go b/vendor/github.com/ugorji/go/codec/helper_internal.go
index 0cbd665..82d6e31 100644
--- a/vendor/github.com/ugorji/go/codec/helper_internal.go
+++ b/vendor/github.com/ugorji/go/codec/helper_internal.go
@@ -104,6 +104,9 @@ func growCap(oldCap, unit, num int) (newCap int) {
if num > 0 {
newCap += num
}
+ if newCap <= oldCap {
+ newCap = oldCap + 1
+ }
// ensure newCap is a multiple of 64 (if it is > 64) or 16.
if newCap > 64 {
diff --git a/vendor/github.com/ugorji/go/codec/helper_not_unsafe.go b/vendor/github.com/ugorji/go/codec/helper_not_unsafe.go
index eef5863..4572c6f 100644
--- a/vendor/github.com/ugorji/go/codec/helper_not_unsafe.go
+++ b/vendor/github.com/ugorji/go/codec/helper_not_unsafe.go
@@ -33,26 +33,47 @@ func bytesView(v string) []byte {
return []byte(v)
}
-func definitelyNil(v interface{}) bool {
- // this is a best-effort option.
- // We just return false, so we don't unnecessarily incur the cost of reflection this early.
- return false
+// isNil says whether the value v is nil.
+// This applies to references like map/ptr/unsafepointer/chan/func,
+// and non-reference values like interface/slice.
+func isNil(v interface{}) (rv reflect.Value, isnil bool) {
+ rv = rv4i(v)
+ if isnilBitset.isset(byte(rv.Kind())) {
+ isnil = rv.IsNil()
+ }
+ return
+}
+
+func rv4i(i interface{}) reflect.Value {
+ return reflect.ValueOf(i)
}
func rv2i(rv reflect.Value) interface{} {
return rv.Interface()
}
-func rt2id(rt reflect.Type) uintptr {
- return reflect.ValueOf(rt).Pointer()
+func rvIsNil(rv reflect.Value) bool {
+ return rv.IsNil()
+}
+
+func rvSetSliceLen(rv reflect.Value, length int) {
+ rv.SetLen(length)
}
-// func rv2rtid(rv reflect.Value) uintptr {
-// return reflect.ValueOf(rv.Type()).Pointer()
-// }
+func rvZeroAddrK(t reflect.Type, k reflect.Kind) reflect.Value {
+ return reflect.New(t).Elem()
+}
+
+func rvConvert(v reflect.Value, t reflect.Type) (rv reflect.Value) {
+ return v.Convert(t)
+}
+
+func rt2id(rt reflect.Type) uintptr {
+ return rv4i(rt).Pointer()
+}
func i2rtid(i interface{}) uintptr {
- return reflect.ValueOf(reflect.TypeOf(i)).Pointer()
+ return rv4i(reflect.TypeOf(i)).Pointer()
}
// --------------------------
@@ -85,14 +106,6 @@ func isEmptyValue(v reflect.Value, tinfos *TypeInfos, deref, checkStruct bool) b
return false
}
-// --------------------------
-// type ptrToRvMap struct{}
-
-// func (*ptrToRvMap) init() {}
-// func (*ptrToRvMap) get(i interface{}) reflect.Value {
-// return reflect.ValueOf(i).Elem()
-// }
-
// --------------------------
type atomicClsErr struct {
v atomic.Value
@@ -143,184 +156,254 @@ func (x *atomicRtidFnSlice) store(p []codecRtidFn) {
// --------------------------
func (n *decNaked) ru() reflect.Value {
- return reflect.ValueOf(&n.u).Elem()
+ return rv4i(&n.u).Elem()
}
func (n *decNaked) ri() reflect.Value {
- return reflect.ValueOf(&n.i).Elem()
+ return rv4i(&n.i).Elem()
}
func (n *decNaked) rf() reflect.Value {
- return reflect.ValueOf(&n.f).Elem()
+ return rv4i(&n.f).Elem()
}
func (n *decNaked) rl() reflect.Value {
- return reflect.ValueOf(&n.l).Elem()
+ return rv4i(&n.l).Elem()
}
func (n *decNaked) rs() reflect.Value {
- return reflect.ValueOf(&n.s).Elem()
+ return rv4i(&n.s).Elem()
}
func (n *decNaked) rt() reflect.Value {
- return reflect.ValueOf(&n.t).Elem()
+ return rv4i(&n.t).Elem()
}
func (n *decNaked) rb() reflect.Value {
- return reflect.ValueOf(&n.b).Elem()
+ return rv4i(&n.b).Elem()
}
// --------------------------
-func (d *Decoder) raw(f *codecFnInfo, rv reflect.Value) {
- rv.SetBytes(d.rawBytes())
+func rvSetBytes(rv reflect.Value, v []byte) {
+ rv.SetBytes(v)
}
-func (d *Decoder) kString(f *codecFnInfo, rv reflect.Value) {
- rv.SetString(d.d.DecodeString())
+func rvSetString(rv reflect.Value, v string) {
+ rv.SetString(v)
}
-func (d *Decoder) kBool(f *codecFnInfo, rv reflect.Value) {
- rv.SetBool(d.d.DecodeBool())
+func rvSetBool(rv reflect.Value, v bool) {
+ rv.SetBool(v)
}
-func (d *Decoder) kTime(f *codecFnInfo, rv reflect.Value) {
- rv.Set(reflect.ValueOf(d.d.DecodeTime()))
+func rvSetTime(rv reflect.Value, v time.Time) {
+ rv.Set(rv4i(v))
}
-func (d *Decoder) kFloat32(f *codecFnInfo, rv reflect.Value) {
- fv := d.d.DecodeFloat64()
- if chkOvf.Float32(fv) {
- d.errorf("float32 overflow: %v", fv)
- }
- rv.SetFloat(fv)
+func rvSetFloat32(rv reflect.Value, v float32) {
+ rv.SetFloat(float64(v))
}
-func (d *Decoder) kFloat64(f *codecFnInfo, rv reflect.Value) {
- rv.SetFloat(d.d.DecodeFloat64())
+func rvSetFloat64(rv reflect.Value, v float64) {
+ rv.SetFloat(v)
}
-func (d *Decoder) kInt(f *codecFnInfo, rv reflect.Value) {
- rv.SetInt(chkOvf.IntV(d.d.DecodeInt64(), intBitsize))
+func rvSetInt(rv reflect.Value, v int) {
+ rv.SetInt(int64(v))
}
-func (d *Decoder) kInt8(f *codecFnInfo, rv reflect.Value) {
- rv.SetInt(chkOvf.IntV(d.d.DecodeInt64(), 8))
+func rvSetInt8(rv reflect.Value, v int8) {
+ rv.SetInt(int64(v))
}
-func (d *Decoder) kInt16(f *codecFnInfo, rv reflect.Value) {
- rv.SetInt(chkOvf.IntV(d.d.DecodeInt64(), 16))
+func rvSetInt16(rv reflect.Value, v int16) {
+ rv.SetInt(int64(v))
}
-func (d *Decoder) kInt32(f *codecFnInfo, rv reflect.Value) {
- rv.SetInt(chkOvf.IntV(d.d.DecodeInt64(), 32))
+func rvSetInt32(rv reflect.Value, v int32) {
+ rv.SetInt(int64(v))
}
-func (d *Decoder) kInt64(f *codecFnInfo, rv reflect.Value) {
- rv.SetInt(d.d.DecodeInt64())
+func rvSetInt64(rv reflect.Value, v int64) {
+ rv.SetInt(v)
}
-func (d *Decoder) kUint(f *codecFnInfo, rv reflect.Value) {
- rv.SetUint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize))
+func rvSetUint(rv reflect.Value, v uint) {
+ rv.SetUint(uint64(v))
}
-func (d *Decoder) kUintptr(f *codecFnInfo, rv reflect.Value) {
- rv.SetUint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize))
+func rvSetUintptr(rv reflect.Value, v uintptr) {
+ rv.SetUint(uint64(v))
}
-func (d *Decoder) kUint8(f *codecFnInfo, rv reflect.Value) {
- rv.SetUint(chkOvf.UintV(d.d.DecodeUint64(), 8))
+func rvSetUint8(rv reflect.Value, v uint8) {
+ rv.SetUint(uint64(v))
}
-func (d *Decoder) kUint16(f *codecFnInfo, rv reflect.Value) {
- rv.SetUint(chkOvf.UintV(d.d.DecodeUint64(), 16))
+func rvSetUint16(rv reflect.Value, v uint16) {
+ rv.SetUint(uint64(v))
}
-func (d *Decoder) kUint32(f *codecFnInfo, rv reflect.Value) {
- rv.SetUint(chkOvf.UintV(d.d.DecodeUint64(), 32))
+func rvSetUint32(rv reflect.Value, v uint32) {
+ rv.SetUint(uint64(v))
}
-func (d *Decoder) kUint64(f *codecFnInfo, rv reflect.Value) {
- rv.SetUint(d.d.DecodeUint64())
+func rvSetUint64(rv reflect.Value, v uint64) {
+ rv.SetUint(v)
}
// ----------------
-func (e *Encoder) kBool(f *codecFnInfo, rv reflect.Value) {
- e.e.EncodeBool(rv.Bool())
+// rvSetDirect is rv.Set for all kinds except reflect.Interface
+func rvSetDirect(rv reflect.Value, v reflect.Value) {
+ rv.Set(v)
}
-func (e *Encoder) kTime(f *codecFnInfo, rv reflect.Value) {
- e.e.EncodeTime(rv2i(rv).(time.Time))
+// rvSlice returns a slice of the slice of lenth
+func rvSlice(rv reflect.Value, length int) reflect.Value {
+ return rv.Slice(0, length)
}
-func (e *Encoder) kString(f *codecFnInfo, rv reflect.Value) {
- e.e.EncodeStringEnc(cUTF8, rv.String())
+// ----------------
+
+func rvSliceIndex(rv reflect.Value, i int, ti *typeInfo) reflect.Value {
+ return rv.Index(i)
}
-func (e *Encoder) kFloat64(f *codecFnInfo, rv reflect.Value) {
- e.e.EncodeFloat64(rv.Float())
+func rvGetSliceLen(rv reflect.Value) int {
+ return rv.Len()
}
-func (e *Encoder) kFloat32(f *codecFnInfo, rv reflect.Value) {
- e.e.EncodeFloat32(float32(rv.Float()))
+func rvGetSliceCap(rv reflect.Value) int {
+ return rv.Cap()
}
-func (e *Encoder) kInt(f *codecFnInfo, rv reflect.Value) {
- e.e.EncodeInt(rv.Int())
+func rvGetArrayBytesRO(rv reflect.Value, scratch []byte) (bs []byte) {
+ l := rv.Len()
+ if rv.CanAddr() {
+ return rvGetBytes(rv.Slice(0, l))
+ }
+
+ if l <= cap(scratch) {
+ bs = scratch[:l]
+ } else {
+ bs = make([]byte, l)
+ }
+ reflect.Copy(rv4i(bs), rv)
+ return
}
-func (e *Encoder) kInt8(f *codecFnInfo, rv reflect.Value) {
- e.e.EncodeInt(rv.Int())
+func rvGetArray4Slice(rv reflect.Value) (v reflect.Value) {
+ v = rvZeroAddrK(reflectArrayOf(rvGetSliceLen(rv), rv.Type().Elem()), reflect.Array)
+ reflect.Copy(v, rv)
+ return
}
-func (e *Encoder) kInt16(f *codecFnInfo, rv reflect.Value) {
- e.e.EncodeInt(rv.Int())
+func rvGetSlice4Array(rv reflect.Value, tslice reflect.Type) (v reflect.Value) {
+ return rv.Slice(0, rv.Len())
}
-func (e *Encoder) kInt32(f *codecFnInfo, rv reflect.Value) {
- e.e.EncodeInt(rv.Int())
+func rvCopySlice(dest, src reflect.Value) {
+ reflect.Copy(dest, src)
}
-func (e *Encoder) kInt64(f *codecFnInfo, rv reflect.Value) {
- e.e.EncodeInt(rv.Int())
+// ------------
+
+func rvGetBool(rv reflect.Value) bool {
+ return rv.Bool()
}
-func (e *Encoder) kUint(f *codecFnInfo, rv reflect.Value) {
- e.e.EncodeUint(rv.Uint())
+func rvGetBytes(rv reflect.Value) []byte {
+ return rv.Bytes()
}
-func (e *Encoder) kUint8(f *codecFnInfo, rv reflect.Value) {
- e.e.EncodeUint(rv.Uint())
+func rvGetTime(rv reflect.Value) time.Time {
+ return rv2i(rv).(time.Time)
}
-func (e *Encoder) kUint16(f *codecFnInfo, rv reflect.Value) {
- e.e.EncodeUint(rv.Uint())
+func rvGetString(rv reflect.Value) string {
+ return rv.String()
}
-func (e *Encoder) kUint32(f *codecFnInfo, rv reflect.Value) {
- e.e.EncodeUint(rv.Uint())
+func rvGetFloat64(rv reflect.Value) float64 {
+ return rv.Float()
}
-func (e *Encoder) kUint64(f *codecFnInfo, rv reflect.Value) {
- e.e.EncodeUint(rv.Uint())
+func rvGetFloat32(rv reflect.Value) float32 {
+ return float32(rv.Float())
}
-func (e *Encoder) kUintptr(f *codecFnInfo, rv reflect.Value) {
- e.e.EncodeUint(rv.Uint())
+func rvGetInt(rv reflect.Value) int {
+ return int(rv.Int())
}
-// // keepAlive4BytesView maintains a reference to the input parameter for bytesView.
-// //
-// // Usage: call this at point where done with the bytes view.
-// func keepAlive4BytesView(v string) {}
+func rvGetInt8(rv reflect.Value) int8 {
+ return int8(rv.Int())
+}
-// // keepAlive4BytesView maintains a reference to the input parameter for stringView.
-// //
-// // Usage: call this at point where done with the string view.
-// func keepAlive4StringView(v []byte) {}
+func rvGetInt16(rv reflect.Value) int16 {
+ return int16(rv.Int())
+}
-// func definitelyNil(v interface{}) bool {
-// rv := reflect.ValueOf(v)
-// switch rv.Kind() {
-// case reflect.Invalid:
-// return true
-// case reflect.Ptr, reflect.Interface, reflect.Chan, reflect.Slice, reflect.Map, reflect.Func:
-// return rv.IsNil()
-// default:
-// return false
-// }
-// }
+func rvGetInt32(rv reflect.Value) int32 {
+ return int32(rv.Int())
+}
+
+func rvGetInt64(rv reflect.Value) int64 {
+ return rv.Int()
+}
+
+func rvGetUint(rv reflect.Value) uint {
+ return uint(rv.Uint())
+}
+
+func rvGetUint8(rv reflect.Value) uint8 {
+ return uint8(rv.Uint())
+}
+
+func rvGetUint16(rv reflect.Value) uint16 {
+ return uint16(rv.Uint())
+}
+
+func rvGetUint32(rv reflect.Value) uint32 {
+ return uint32(rv.Uint())
+}
+
+func rvGetUint64(rv reflect.Value) uint64 {
+ return rv.Uint()
+}
+
+func rvGetUintptr(rv reflect.Value) uintptr {
+ return uintptr(rv.Uint())
+}
+
+// ------------ map range and map indexing ----------
+
+func mapGet(m, k, v reflect.Value) (vv reflect.Value) {
+ return m.MapIndex(k)
+}
+
+func mapSet(m, k, v reflect.Value) {
+ m.SetMapIndex(k, v)
+}
+
+func mapDelete(m, k reflect.Value) {
+ m.SetMapIndex(k, reflect.Value{})
+}
+
+// return an addressable reflect value that can be used in mapRange and mapGet operations.
+//
+// all calls to mapGet or mapRange will call here to get an addressable reflect.Value.
+func mapAddressableRV(t reflect.Type, k reflect.Kind) (r reflect.Value) {
+ return // reflect.New(t).Elem()
+}
+
+// ---------- ENCODER optimized ---------------
+
+func (e *Encoder) jsondriver() *jsonEncDriver {
+ return e.e.(*jsonEncDriver)
+}
+
+// ---------- DECODER optimized ---------------
+
+func (d *Decoder) checkBreak() bool {
+ return d.d.CheckBreak()
+}
+
+func (d *Decoder) jsondriver() *jsonDecDriver {
+ return d.d.(*jsonDecDriver)
+}
diff --git a/vendor/github.com/ugorji/go/codec/helper_unsafe.go b/vendor/github.com/ugorji/go/codec/helper_unsafe.go
index 51de2d6..9a22ccf 100644
--- a/vendor/github.com/ugorji/go/codec/helper_unsafe.go
+++ b/vendor/github.com/ugorji/go/codec/helper_unsafe.go
@@ -17,10 +17,23 @@ import (
// This file has unsafe variants of some helper methods.
// NOTE: See helper_not_unsafe.go for the usage information.
-// var zeroRTv [4]uintptr
+// For reflect.Value code, we decided to do the following:
+// - if we know the kind, we can elide conditional checks for
+// - SetXXX (Int, Uint, String, Bool, etc)
+// - SetLen
+//
+// We can also optimize
+// - IsNil
const safeMode = false
-const unsafeFlagIndir = 1 << 7 // keep in sync with GO_ROOT/src/reflect/value.go
+
+// keep in sync with GO_ROOT/src/reflect/value.go
+const (
+ unsafeFlagIndir = 1 << 7
+ unsafeFlagAddr = 1 << 8
+ unsafeFlagKindMask = (1 << 5) - 1 // 5 bits for 27 kinds (up to 31)
+ // unsafeTypeKindDirectIface = 1 << 5
+)
type unsafeString struct {
Data unsafe.Pointer
@@ -60,47 +73,92 @@ func bytesView(v string) []byte {
return *(*[]byte)(unsafe.Pointer(&unsafeSlice{sx.Data, sx.Len, sx.Len}))
}
-func definitelyNil(v interface{}) bool {
- // There is no global way of checking if an interface is nil.
- // For true references (map, ptr, func, chan), you can just look
- // at the word of the interface. However, for slices, you have to dereference
- // the word, and get a pointer to the 3-word interface value.
- //
- // However, the following are cheap calls
- // - TypeOf(interface): cheap 2-line call.
- // - ValueOf(interface{}): expensive
- // - type.Kind: cheap call through an interface
- // - Value.Type(): cheap call
- // except it's a method value (e.g. r.Read, which implies that it is a Func)
+// // isNilRef says whether the interface is a nil reference or not.
+// //
+// // A reference here is a pointer-sized reference i.e. map, ptr, chan, func, unsafepointer.
+// // It is optional to extend this to also check if slices or interfaces are nil also.
+// //
+// // NOTE: There is no global way of checking if an interface is nil.
+// // For true references (map, ptr, func, chan), you can just look
+// // at the word of the interface.
+// // However, for slices, you have to dereference
+// // the word, and get a pointer to the 3-word interface value.
+// func isNilRef(v interface{}) (rv reflect.Value, isnil bool) {
+// isnil = ((*unsafeIntf)(unsafe.Pointer(&v))).word == nil
+// return
+// }
- return ((*unsafeIntf)(unsafe.Pointer(&v))).word == nil
+func isNil(v interface{}) (rv reflect.Value, isnil bool) {
+ var ui = (*unsafeIntf)(unsafe.Pointer(&v))
+ if ui.word == nil {
+ isnil = true
+ return
+ }
+ rv = rv4i(v) // reflect.value is cheap and inline'able
+ tk := rv.Kind()
+ isnil = (tk == reflect.Interface || tk == reflect.Slice) && *(*unsafe.Pointer)(ui.word) == nil
+ return
+}
+
+func rv2ptr(urv *unsafeReflectValue) (ptr unsafe.Pointer) {
+ // true references (map, func, chan, ptr - NOT slice) may be double-referenced? as flagIndir
+ if refBitset.isset(byte(urv.flag&unsafeFlagKindMask)) && urv.flag&unsafeFlagIndir != 0 {
+ ptr = *(*unsafe.Pointer)(urv.ptr)
+ } else {
+ ptr = urv.ptr
+ }
+ return
+}
+
+func rv4i(i interface{}) (rv reflect.Value) {
+ // Unfortunately, we cannot get the "kind" of the interface directly here.
+ // We need the 'rtype', whose structure changes in different go versions.
+ // Finally, it's not clear that there is benefit to reimplementing it,
+ // as the "escapes(i)" is not clearly expensive since we want i to exist on the heap.
+
+ return reflect.ValueOf(i)
}
func rv2i(rv reflect.Value) interface{} {
- // TODO: consider a more generally-known optimization for reflect.Value ==> Interface
- //
- // Currently, we use this fragile method that taps into implememtation details from
+ // We tap into implememtation details from
// the source go stdlib reflect/value.go, and trims the implementation.
+ urv := (*unsafeReflectValue)(unsafe.Pointer(&rv))
+ return *(*interface{})(unsafe.Pointer(&unsafeIntf{typ: urv.typ, word: rv2ptr(urv)}))
+}
+func rvIsNil(rv reflect.Value) bool {
urv := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- // true references (map, func, chan, ptr - NOT slice) may be double-referenced as flagIndir
- var ptr unsafe.Pointer
- if refBitset.isset(byte(urv.flag&(1<<5-1))) && urv.flag&unsafeFlagIndir != 0 {
- ptr = *(*unsafe.Pointer)(urv.ptr)
- } else {
- ptr = urv.ptr
+ if urv.flag&unsafeFlagIndir != 0 {
+ return *(*unsafe.Pointer)(urv.ptr) == nil
}
- return *(*interface{})(unsafe.Pointer(&unsafeIntf{typ: urv.typ, word: ptr}))
+ return urv.ptr == nil
+}
+
+func rvSetSliceLen(rv reflect.Value, length int) {
+ urv := (*unsafeReflectValue)(unsafe.Pointer(&rv))
+ (*unsafeString)(urv.ptr).Len = length
+}
+
+func rvZeroAddrK(t reflect.Type, k reflect.Kind) (rv reflect.Value) {
+ urv := (*unsafeReflectValue)(unsafe.Pointer(&rv))
+ urv.flag = uintptr(k) | unsafeFlagIndir | unsafeFlagAddr
+ urv.typ = ((*unsafeIntf)(unsafe.Pointer(&t))).word
+ urv.ptr = unsafe_New(urv.typ)
+ return
+}
+
+func rvConvert(v reflect.Value, t reflect.Type) (rv reflect.Value) {
+ uv := (*unsafeReflectValue)(unsafe.Pointer(&v))
+ urv := (*unsafeReflectValue)(unsafe.Pointer(&rv))
+ *urv = *uv
+ urv.typ = ((*unsafeIntf)(unsafe.Pointer(&t))).word
+ return
}
func rt2id(rt reflect.Type) uintptr {
return uintptr(((*unsafeIntf)(unsafe.Pointer(&rt))).word)
}
-// func rv2rtid(rv reflect.Value) uintptr {
-// return uintptr((*unsafeReflectValue)(unsafe.Pointer(&rv)).typ)
-// }
-
func i2rtid(i interface{}) uintptr {
return uintptr(((*unsafeIntf)(unsafe.Pointer(&i))).typ)
}
@@ -157,7 +215,7 @@ func isEmptyValue(v reflect.Value, tinfos *TypeInfos, deref, checkStruct bool) b
}
return isnil
case reflect.Ptr:
- // isnil := urv.ptr == nil (not sufficient, as a pointer value encodes the type)
+ // isnil := urv.ptr == nil // (not sufficient, as a pointer value encodes the type)
isnil := urv.ptr == nil || *(*unsafe.Pointer)(urv.ptr) == nil
if deref {
if isnil {
@@ -186,7 +244,7 @@ func isEmptyValue(v reflect.Value, tinfos *TypeInfos, deref, checkStruct bool) b
// ----------------------
type atomicTypeInfoSlice struct {
v unsafe.Pointer // *[]rtid2ti
- _ uintptr // padding (atomicXXX expected to be 2 words)
+ _ uint64 // padding (atomicXXX expected to be 2 words)
}
func (x *atomicTypeInfoSlice) load() (s []rtid2ti) {
@@ -204,7 +262,7 @@ func (x *atomicTypeInfoSlice) store(p []rtid2ti) {
// --------------------------
type atomicRtidFnSlice struct {
v unsafe.Pointer // *[]codecRtidFn
- _ uintptr // padding (atomicXXX expected to be 2 words)
+ _ uint64 // padding (atomicXXX expected to be 2 words) (make 1 word so JsonHandle fits)
}
func (x *atomicRtidFnSlice) load() (s []codecRtidFn) {
@@ -222,7 +280,7 @@ func (x *atomicRtidFnSlice) store(p []codecRtidFn) {
// --------------------------
type atomicClsErr struct {
v unsafe.Pointer // *clsErr
- _ uintptr // padding (atomicXXX expected to be 2 words)
+ _ uint64 // padding (atomicXXX expected to be 2 words)
}
func (x *atomicClsErr) load() (e clsErr) {
@@ -252,14 +310,14 @@ type unsafeDecNakedWrapper struct {
}
func (n *unsafeDecNakedWrapper) init() {
- n.ru = reflect.ValueOf(&n.u).Elem()
- n.ri = reflect.ValueOf(&n.i).Elem()
- n.rf = reflect.ValueOf(&n.f).Elem()
- n.rl = reflect.ValueOf(&n.l).Elem()
- n.rs = reflect.ValueOf(&n.s).Elem()
- n.rt = reflect.ValueOf(&n.t).Elem()
- n.rb = reflect.ValueOf(&n.b).Elem()
- // n.rr[] = reflect.ValueOf(&n.)
+ n.ru = rv4i(&n.u).Elem()
+ n.ri = rv4i(&n.i).Elem()
+ n.rf = rv4i(&n.f).Elem()
+ n.rl = rv4i(&n.l).Elem()
+ n.rs = rv4i(&n.s).Elem()
+ n.rt = rv4i(&n.t).Elem()
+ n.rb = rv4i(&n.b).Elem()
+ // n.rr[] = rv4i(&n.)
}
var defUnsafeDecNakedWrapper unsafeDecNakedWrapper
@@ -305,436 +363,505 @@ func (n *decNaked) rb() (v reflect.Value) {
}
// --------------------------
-func (d *Decoder) raw(f *codecFnInfo, rv reflect.Value) {
+func rvSetBytes(rv reflect.Value, v []byte) {
urv := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- *(*[]byte)(urv.ptr) = d.rawBytes()
+ *(*[]byte)(urv.ptr) = v
}
-func (d *Decoder) kString(f *codecFnInfo, rv reflect.Value) {
+func rvSetString(rv reflect.Value, v string) {
urv := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- *(*string)(urv.ptr) = d.d.DecodeString()
+ *(*string)(urv.ptr) = v
}
-func (d *Decoder) kBool(f *codecFnInfo, rv reflect.Value) {
+func rvSetBool(rv reflect.Value, v bool) {
urv := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- *(*bool)(urv.ptr) = d.d.DecodeBool()
+ *(*bool)(urv.ptr) = v
}
-func (d *Decoder) kTime(f *codecFnInfo, rv reflect.Value) {
+func rvSetTime(rv reflect.Value, v time.Time) {
urv := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- *(*time.Time)(urv.ptr) = d.d.DecodeTime()
+ *(*time.Time)(urv.ptr) = v
}
-func (d *Decoder) kFloat32(f *codecFnInfo, rv reflect.Value) {
- fv := d.d.DecodeFloat64()
- if chkOvf.Float32(fv) {
- d.errorf("float32 overflow: %v", fv)
- }
+func rvSetFloat32(rv reflect.Value, v float32) {
urv := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- *(*float32)(urv.ptr) = float32(fv)
+ *(*float32)(urv.ptr) = v
}
-func (d *Decoder) kFloat64(f *codecFnInfo, rv reflect.Value) {
+func rvSetFloat64(rv reflect.Value, v float64) {
urv := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- *(*float64)(urv.ptr) = d.d.DecodeFloat64()
+ *(*float64)(urv.ptr) = v
}
-func (d *Decoder) kInt(f *codecFnInfo, rv reflect.Value) {
+func rvSetInt(rv reflect.Value, v int) {
urv := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- *(*int)(urv.ptr) = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize))
+ *(*int)(urv.ptr) = v
}
-func (d *Decoder) kInt8(f *codecFnInfo, rv reflect.Value) {
+func rvSetInt8(rv reflect.Value, v int8) {
urv := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- *(*int8)(urv.ptr) = int8(chkOvf.IntV(d.d.DecodeInt64(), 8))
+ *(*int8)(urv.ptr) = v
}
-func (d *Decoder) kInt16(f *codecFnInfo, rv reflect.Value) {
+func rvSetInt16(rv reflect.Value, v int16) {
urv := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- *(*int16)(urv.ptr) = int16(chkOvf.IntV(d.d.DecodeInt64(), 16))
+ *(*int16)(urv.ptr) = v
}
-func (d *Decoder) kInt32(f *codecFnInfo, rv reflect.Value) {
+func rvSetInt32(rv reflect.Value, v int32) {
urv := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- *(*int32)(urv.ptr) = int32(chkOvf.IntV(d.d.DecodeInt64(), 32))
+ *(*int32)(urv.ptr) = v
}
-func (d *Decoder) kInt64(f *codecFnInfo, rv reflect.Value) {
+func rvSetInt64(rv reflect.Value, v int64) {
urv := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- *(*int64)(urv.ptr) = d.d.DecodeInt64()
+ *(*int64)(urv.ptr) = v
}
-func (d *Decoder) kUint(f *codecFnInfo, rv reflect.Value) {
+func rvSetUint(rv reflect.Value, v uint) {
urv := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- *(*uint)(urv.ptr) = uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize))
+ *(*uint)(urv.ptr) = v
}
-func (d *Decoder) kUintptr(f *codecFnInfo, rv reflect.Value) {
+func rvSetUintptr(rv reflect.Value, v uintptr) {
urv := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- *(*uintptr)(urv.ptr) = uintptr(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize))
+ *(*uintptr)(urv.ptr) = v
}
-func (d *Decoder) kUint8(f *codecFnInfo, rv reflect.Value) {
+func rvSetUint8(rv reflect.Value, v uint8) {
urv := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- *(*uint8)(urv.ptr) = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8))
+ *(*uint8)(urv.ptr) = v
}
-func (d *Decoder) kUint16(f *codecFnInfo, rv reflect.Value) {
+func rvSetUint16(rv reflect.Value, v uint16) {
urv := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- *(*uint16)(urv.ptr) = uint16(chkOvf.UintV(d.d.DecodeUint64(), 16))
+ *(*uint16)(urv.ptr) = v
}
-func (d *Decoder) kUint32(f *codecFnInfo, rv reflect.Value) {
+func rvSetUint32(rv reflect.Value, v uint32) {
urv := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- *(*uint32)(urv.ptr) = uint32(chkOvf.UintV(d.d.DecodeUint64(), 32))
+ *(*uint32)(urv.ptr) = v
}
-func (d *Decoder) kUint64(f *codecFnInfo, rv reflect.Value) {
+func rvSetUint64(rv reflect.Value, v uint64) {
urv := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- *(*uint64)(urv.ptr) = d.d.DecodeUint64()
+ *(*uint64)(urv.ptr) = v
+}
+
+// ----------------
+
+// rvSetDirect is rv.Set for all kinds except reflect.Interface
+func rvSetDirect(rv reflect.Value, v reflect.Value) {
+ urv := (*unsafeReflectValue)(unsafe.Pointer(&rv))
+ uv := (*unsafeReflectValue)(unsafe.Pointer(&v))
+ if uv.flag&unsafeFlagIndir == 0 {
+ *(*unsafe.Pointer)(urv.ptr) = uv.ptr
+ } else {
+ typedmemmove(urv.typ, urv.ptr, uv.ptr)
+ }
+}
+
+// rvSlice returns a slice of the slice of lenth
+func rvSlice(rv reflect.Value, length int) (v reflect.Value) {
+ urv := (*unsafeReflectValue)(unsafe.Pointer(&rv))
+ uv := (*unsafeReflectValue)(unsafe.Pointer(&v))
+ *uv = *urv
+ var x []unsafe.Pointer
+ uv.ptr = unsafe.Pointer(&x)
+ *(*unsafeSlice)(uv.ptr) = *(*unsafeSlice)(urv.ptr)
+ (*unsafeSlice)(uv.ptr).Len = length
+ return
+}
+
+// ------------
+
+func rvSliceIndex(rv reflect.Value, i int, ti *typeInfo) (v reflect.Value) {
+ urv := (*unsafeReflectValue)(unsafe.Pointer(&rv))
+ uv := (*unsafeReflectValue)(unsafe.Pointer(&v))
+ uv.ptr = unsafe.Pointer(uintptr(((*unsafeSlice)(urv.ptr)).Data) + (ti.elemsize * uintptr(i)))
+ uv.typ = ((*unsafeIntf)(unsafe.Pointer(&ti.elem))).word
+ uv.flag = uintptr(ti.elemkind) | unsafeFlagIndir | unsafeFlagAddr
+ return
+}
+
+func rvGetSliceLen(rv reflect.Value) int {
+ urv := (*unsafeReflectValue)(unsafe.Pointer(&rv))
+ return (*unsafeSlice)(urv.ptr).Len
+}
+
+func rvGetSliceCap(rv reflect.Value) int {
+ urv := (*unsafeReflectValue)(unsafe.Pointer(&rv))
+ return (*unsafeSlice)(urv.ptr).Cap
+}
+
+func rvGetArrayBytesRO(rv reflect.Value, scratch []byte) (bs []byte) {
+ l := rv.Len()
+ urv := (*unsafeReflectValue)(unsafe.Pointer(&rv))
+ bx := (*unsafeSlice)(unsafe.Pointer(&bs))
+ bx.Data = urv.ptr
+ bx.Len, bx.Cap = l, l
+ return
+}
+
+func rvGetArray4Slice(rv reflect.Value) (v reflect.Value) {
+ // It is possible that this slice is based off an array with a larger
+ // len that we want (where array len == slice cap).
+ // However, it is ok to create an array type that is a subset of the full
+ // e.g. full slice is based off a *[16]byte, but we can create a *[4]byte
+ // off of it. That is ok.
+ //
+ // Consequently, we use rvGetSliceLen, not rvGetSliceCap.
+
+ t := reflectArrayOf(rvGetSliceLen(rv), rv.Type().Elem())
+ // v = rvZeroAddrK(t, reflect.Array)
+
+ uv := (*unsafeReflectValue)(unsafe.Pointer(&v))
+ uv.flag = uintptr(reflect.Array) | unsafeFlagIndir | unsafeFlagAddr
+ uv.typ = ((*unsafeIntf)(unsafe.Pointer(&t))).word
+
+ urv := (*unsafeReflectValue)(unsafe.Pointer(&rv))
+ uv.ptr = *(*unsafe.Pointer)(urv.ptr) // slice rv has a ptr to the slice.
+
+ return
+}
+
+func rvGetSlice4Array(rv reflect.Value, tslice reflect.Type) (v reflect.Value) {
+ uv := (*unsafeReflectValue)(unsafe.Pointer(&v))
+
+ var x []unsafe.Pointer
+
+ uv.ptr = unsafe.Pointer(&x)
+ uv.typ = ((*unsafeIntf)(unsafe.Pointer(&tslice))).word
+ uv.flag = unsafeFlagIndir | uintptr(reflect.Slice)
+
+ s := (*unsafeSlice)(uv.ptr)
+ s.Data = ((*unsafeReflectValue)(unsafe.Pointer(&rv))).ptr
+ s.Len = rv.Len()
+ s.Cap = s.Len
+ return
+}
+
+func rvCopySlice(dest, src reflect.Value) {
+ t := dest.Type().Elem()
+ urv := (*unsafeReflectValue)(unsafe.Pointer(&dest))
+ destPtr := urv.ptr
+ urv = (*unsafeReflectValue)(unsafe.Pointer(&src))
+ typedslicecopy((*unsafeIntf)(unsafe.Pointer(&t)).word,
+ *(*unsafeSlice)(destPtr), *(*unsafeSlice)(urv.ptr))
}
// ------------
-func (e *Encoder) kBool(f *codecFnInfo, rv reflect.Value) {
+func rvGetBool(rv reflect.Value) bool {
v := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- e.e.EncodeBool(*(*bool)(v.ptr))
+ return *(*bool)(v.ptr)
}
-func (e *Encoder) kTime(f *codecFnInfo, rv reflect.Value) {
+func rvGetBytes(rv reflect.Value) []byte {
v := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- e.e.EncodeTime(*(*time.Time)(v.ptr))
+ return *(*[]byte)(v.ptr)
}
-func (e *Encoder) kString(f *codecFnInfo, rv reflect.Value) {
+func rvGetTime(rv reflect.Value) time.Time {
v := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- e.e.EncodeStringEnc(cUTF8, *(*string)(v.ptr))
+ return *(*time.Time)(v.ptr)
}
-func (e *Encoder) kFloat64(f *codecFnInfo, rv reflect.Value) {
+func rvGetString(rv reflect.Value) string {
v := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- e.e.EncodeFloat64(*(*float64)(v.ptr))
+ return *(*string)(v.ptr)
}
-func (e *Encoder) kFloat32(f *codecFnInfo, rv reflect.Value) {
+func rvGetFloat64(rv reflect.Value) float64 {
v := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- e.e.EncodeFloat32(*(*float32)(v.ptr))
+ return *(*float64)(v.ptr)
}
-func (e *Encoder) kInt(f *codecFnInfo, rv reflect.Value) {
+func rvGetFloat32(rv reflect.Value) float32 {
v := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- e.e.EncodeInt(int64(*(*int)(v.ptr)))
+ return *(*float32)(v.ptr)
}
-func (e *Encoder) kInt8(f *codecFnInfo, rv reflect.Value) {
+func rvGetInt(rv reflect.Value) int {
v := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- e.e.EncodeInt(int64(*(*int8)(v.ptr)))
+ return *(*int)(v.ptr)
}
-func (e *Encoder) kInt16(f *codecFnInfo, rv reflect.Value) {
+func rvGetInt8(rv reflect.Value) int8 {
v := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- e.e.EncodeInt(int64(*(*int16)(v.ptr)))
+ return *(*int8)(v.ptr)
}
-func (e *Encoder) kInt32(f *codecFnInfo, rv reflect.Value) {
+func rvGetInt16(rv reflect.Value) int16 {
v := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- e.e.EncodeInt(int64(*(*int32)(v.ptr)))
+ return *(*int16)(v.ptr)
}
-func (e *Encoder) kInt64(f *codecFnInfo, rv reflect.Value) {
+func rvGetInt32(rv reflect.Value) int32 {
v := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- e.e.EncodeInt(int64(*(*int64)(v.ptr)))
+ return *(*int32)(v.ptr)
}
-func (e *Encoder) kUint(f *codecFnInfo, rv reflect.Value) {
+func rvGetInt64(rv reflect.Value) int64 {
v := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- e.e.EncodeUint(uint64(*(*uint)(v.ptr)))
+ return *(*int64)(v.ptr)
}
-func (e *Encoder) kUint8(f *codecFnInfo, rv reflect.Value) {
+func rvGetUint(rv reflect.Value) uint {
v := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- e.e.EncodeUint(uint64(*(*uint8)(v.ptr)))
+ return *(*uint)(v.ptr)
}
-func (e *Encoder) kUint16(f *codecFnInfo, rv reflect.Value) {
+func rvGetUint8(rv reflect.Value) uint8 {
v := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- e.e.EncodeUint(uint64(*(*uint16)(v.ptr)))
+ return *(*uint8)(v.ptr)
}
-func (e *Encoder) kUint32(f *codecFnInfo, rv reflect.Value) {
+func rvGetUint16(rv reflect.Value) uint16 {
v := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- e.e.EncodeUint(uint64(*(*uint32)(v.ptr)))
+ return *(*uint16)(v.ptr)
}
-func (e *Encoder) kUint64(f *codecFnInfo, rv reflect.Value) {
+func rvGetUint32(rv reflect.Value) uint32 {
v := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- e.e.EncodeUint(uint64(*(*uint64)(v.ptr)))
+ return *(*uint32)(v.ptr)
}
-func (e *Encoder) kUintptr(f *codecFnInfo, rv reflect.Value) {
+func rvGetUint64(rv reflect.Value) uint64 {
v := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- e.e.EncodeUint(uint64(*(*uintptr)(v.ptr)))
+ return *(*uint64)(v.ptr)
}
-// ------------
+func rvGetUintptr(rv reflect.Value) uintptr {
+ v := (*unsafeReflectValue)(unsafe.Pointer(&rv))
+ return *(*uintptr)(v.ptr)
+}
-// func (d *Decoder) raw(f *codecFnInfo, rv reflect.Value) {
-// urv := (*unsafeReflectValue)(unsafe.Pointer(&rv))
-// // if urv.flag&unsafeFlagIndir != 0 {
-// // urv.ptr = *(*unsafe.Pointer)(urv.ptr)
-// // }
-// *(*[]byte)(urv.ptr) = d.rawBytes()
-// }
+// ------------ map range and map indexing ----------
-// func rv0t(rt reflect.Type) reflect.Value {
-// ut := (*unsafeIntf)(unsafe.Pointer(&rt))
-// // we need to determine whether ifaceIndir, and then whether to just pass 0 as the ptr
-// uv := unsafeReflectValue{ut.word, &zeroRTv, flag(rt.Kind())}
-// return *(*reflect.Value)(unsafe.Pointer(&uv})
-// }
+// regular calls to map via reflection: MapKeys, MapIndex, MapRange/MapIter etc
+// will always allocate for each map key or value.
+//
+// It is more performant to provide a value that the map entry is set into,
+// and that elides the allocation.
-// func rv2i(rv reflect.Value) interface{} {
-// urv := (*unsafeReflectValue)(unsafe.Pointer(&rv))
-// // true references (map, func, chan, ptr - NOT slice) may be double-referenced as flagIndir
-// var ptr unsafe.Pointer
-// // kk := reflect.Kind(urv.flag & (1<<5 - 1))
-// // if (kk == reflect.Map || kk == reflect.Ptr || kk == reflect.Chan || kk == reflect.Func) && urv.flag&unsafeFlagIndir != 0 {
-// if refBitset.isset(byte(urv.flag&(1<<5-1))) && urv.flag&unsafeFlagIndir != 0 {
-// ptr = *(*unsafe.Pointer)(urv.ptr)
-// } else {
-// ptr = urv.ptr
-// }
-// return *(*interface{})(unsafe.Pointer(&unsafeIntf{typ: urv.typ, word: ptr}))
-// // return *(*interface{})(unsafe.Pointer(&unsafeIntf{word: *(*unsafe.Pointer)(urv.ptr), typ: urv.typ}))
-// // return *(*interface{})(unsafe.Pointer(&unsafeIntf{word: urv.ptr, typ: urv.typ}))
-// }
+// unsafeMapHashIter
+//
+// go 1.4+ has runtime/hashmap.go or runtime/map.go which has a
+// hIter struct with the first 2 values being key and value
+// of the current iteration.
+//
+// This *hIter is passed to mapiterinit, mapiternext, mapiterkey, mapiterelem.
+// We bypass the reflect wrapper functions and just use the *hIter directly.
+//
+// Though *hIter has many fields, we only care about the first 2.
+type unsafeMapHashIter struct {
+ key, value unsafe.Pointer
+ // other fields are ignored
+}
-// func definitelyNil(v interface{}) bool {
-// var ui *unsafeIntf = (*unsafeIntf)(unsafe.Pointer(&v))
-// if ui.word == nil {
-// return true
-// }
-// var tk = reflect.TypeOf(v).Kind()
-// return (tk == reflect.Interface || tk == reflect.Slice) && *(*unsafe.Pointer)(ui.word) == nil
-// fmt.Printf(">>>> definitely nil: isnil: %v, TYPE: \t%T, word: %v, *word: %v, type: %v, nil: %v\n",
-// v == nil, v, word, *((*unsafe.Pointer)(word)), ui.typ, nil)
-// }
+type mapIter struct {
+ unsafeMapIter
+}
-// func keepAlive4BytesView(v string) {
-// runtime.KeepAlive(v)
-// }
+type unsafeMapIter struct {
+ it *unsafeMapHashIter
+ // k, v reflect.Value
+ mtyp, ktyp, vtyp unsafe.Pointer
+ mptr, kptr, vptr unsafe.Pointer
+ kisref, visref bool
+ mapvalues bool
+ done bool
+ started bool
+ // _ [2]uint64 // padding (cache-aligned)
+}
-// func keepAlive4StringView(v []byte) {
-// runtime.KeepAlive(v)
-// }
+func (t *unsafeMapIter) ValidKV() (r bool) {
+ return false
+}
-// func rt2id(rt reflect.Type) uintptr {
-// return uintptr(((*unsafeIntf)(unsafe.Pointer(&rt))).word)
-// // var i interface{} = rt
-// // // ui := (*unsafeIntf)(unsafe.Pointer(&i))
-// // return ((*unsafeIntf)(unsafe.Pointer(&i))).word
-// }
+func (t *unsafeMapIter) Next() (r bool) {
+ if t == nil || t.done {
+ return
+ }
+ if t.started {
+ mapiternext((unsafe.Pointer)(t.it))
+ } else {
+ t.started = true
+ }
-// func rv2i(rv reflect.Value) interface{} {
-// urv := (*unsafeReflectValue)(unsafe.Pointer(&rv))
-// // non-reference type: already indir
-// // reference type: depend on flagIndir property ('cos maybe was double-referenced)
-// // const (unsafeRvFlagKindMask = 1<<5 - 1 , unsafeRvFlagIndir = 1 << 7 )
-// // rvk := reflect.Kind(urv.flag & (1<<5 - 1))
-// // if (rvk == reflect.Chan ||
-// // rvk == reflect.Func ||
-// // rvk == reflect.Interface ||
-// // rvk == reflect.Map ||
-// // rvk == reflect.Ptr ||
-// // rvk == reflect.UnsafePointer) && urv.flag&(1<<8) != 0 {
-// // fmt.Printf(">>>>> ---- double indirect reference: %v, %v\n", rvk, rv.Type())
-// // return *(*interface{})(unsafe.Pointer(&unsafeIntf{word: *(*unsafe.Pointer)(urv.ptr), typ: urv.typ}))
-// // }
-// if urv.flag&(1<<5-1) == uintptr(reflect.Map) && urv.flag&(1<<7) != 0 {
-// // fmt.Printf(">>>>> ---- double indirect reference: %v, %v\n", rvk, rv.Type())
-// return *(*interface{})(unsafe.Pointer(&unsafeIntf{word: *(*unsafe.Pointer)(urv.ptr), typ: urv.typ}))
-// }
-// // fmt.Printf(">>>>> ++++ direct reference: %v, %v\n", rvk, rv.Type())
-// return *(*interface{})(unsafe.Pointer(&unsafeIntf{word: urv.ptr, typ: urv.typ}))
-// }
+ t.done = t.it.key == nil
+ if t.done {
+ return
+ }
+ unsafeMapSet(t.kptr, t.ktyp, t.it.key, t.kisref)
+ if t.mapvalues {
+ unsafeMapSet(t.vptr, t.vtyp, t.it.value, t.visref)
+ }
+ return true
+}
-// const (
-// unsafeRvFlagKindMask = 1<<5 - 1
-// unsafeRvKindDirectIface = 1 << 5
-// unsafeRvFlagIndir = 1 << 7
-// unsafeRvFlagAddr = 1 << 8
-// unsafeRvFlagMethod = 1 << 9
-
-// _USE_RV_INTERFACE bool = false
-// _UNSAFE_RV_DEBUG = true
-// )
-
-// type unsafeRtype struct {
-// _ [2]uintptr
-// _ uint32
-// _ uint8
-// _ uint8
-// _ uint8
-// kind uint8
-// _ [2]uintptr
-// _ int32
-// }
+func (t *unsafeMapIter) Key() (r reflect.Value) {
+ return
+}
-// func _rv2i(rv reflect.Value) interface{} {
-// // Note: From use,
-// // - it's never an interface
-// // - the only calls here are for ifaceIndir types.
-// // (though that conditional is wrong)
-// // To know for sure, we need the value of t.kind (which is not exposed).
-// //
-// // Need to validate the path: type is indirect ==> only value is indirect ==> default (value is direct)
-// // - Type indirect, Value indirect: ==> numbers, boolean, slice, struct, array, string
-// // - Type Direct, Value indirect: ==> map???
-// // - Type Direct, Value direct: ==> pointers, unsafe.Pointer, func, chan, map
-// //
-// // TRANSLATES TO:
-// // if typeIndirect { } else if valueIndirect { } else { }
-// //
-// // Since we don't deal with funcs, then "flagNethod" is unset, and can be ignored.
-
-// if _USE_RV_INTERFACE {
-// return rv.Interface()
-// }
-// urv := (*unsafeReflectValue)(unsafe.Pointer(&rv))
-
-// // if urv.flag&unsafeRvFlagMethod != 0 || urv.flag&unsafeRvFlagKindMask == uintptr(reflect.Interface) {
-// // println("***** IS flag method or interface: delegating to rv.Interface()")
-// // return rv.Interface()
-// // }
-
-// // if urv.flag&unsafeRvFlagKindMask == uintptr(reflect.Interface) {
-// // println("***** IS Interface: delegate to rv.Interface")
-// // return rv.Interface()
-// // }
-// // if urv.flag&unsafeRvFlagKindMask&unsafeRvKindDirectIface == 0 {
-// // if urv.flag&unsafeRvFlagAddr == 0 {
-// // println("***** IS ifaceIndir typ")
-// // // ui := unsafeIntf{word: urv.ptr, typ: urv.typ}
-// // // return *(*interface{})(unsafe.Pointer(&ui))
-// // // return *(*interface{})(unsafe.Pointer(&unsafeIntf{word: urv.ptr, typ: urv.typ}))
-// // }
-// // } else if urv.flag&unsafeRvFlagIndir != 0 {
-// // println("***** IS flagindir")
-// // // return *(*interface{})(unsafe.Pointer(&unsafeIntf{word: *(*unsafe.Pointer)(urv.ptr), typ: urv.typ}))
-// // } else {
-// // println("***** NOT flagindir")
-// // return *(*interface{})(unsafe.Pointer(&unsafeIntf{word: urv.ptr, typ: urv.typ}))
-// // }
-// // println("***** default: delegate to rv.Interface")
-
-// urt := (*unsafeRtype)(unsafe.Pointer(urv.typ))
-// if _UNSAFE_RV_DEBUG {
-// fmt.Printf(">>>> start: %v: ", rv.Type())
-// fmt.Printf("%v - %v\n", *urv, *urt)
-// }
-// if urt.kind&unsafeRvKindDirectIface == 0 {
-// if _UNSAFE_RV_DEBUG {
-// fmt.Printf("**** +ifaceIndir type: %v\n", rv.Type())
-// }
-// // println("***** IS ifaceIndir typ")
-// // if true || urv.flag&unsafeRvFlagAddr == 0 {
-// // // println(" ***** IS NOT addr")
-// return *(*interface{})(unsafe.Pointer(&unsafeIntf{word: urv.ptr, typ: urv.typ}))
-// // }
-// } else if urv.flag&unsafeRvFlagIndir != 0 {
-// if _UNSAFE_RV_DEBUG {
-// fmt.Printf("**** +flagIndir type: %v\n", rv.Type())
-// }
-// // println("***** IS flagindir")
-// return *(*interface{})(unsafe.Pointer(&unsafeIntf{word: *(*unsafe.Pointer)(urv.ptr), typ: urv.typ}))
-// } else {
-// if _UNSAFE_RV_DEBUG {
-// fmt.Printf("**** -flagIndir type: %v\n", rv.Type())
-// }
-// // println("***** NOT flagindir")
-// return *(*interface{})(unsafe.Pointer(&unsafeIntf{word: urv.ptr, typ: urv.typ}))
-// }
-// // println("***** default: delegating to rv.Interface()")
-// // return rv.Interface()
-// }
+func (t *unsafeMapIter) Value() (r reflect.Value) {
+ return
+}
-// var staticM0 = make(map[string]uint64)
-// var staticI0 = (int32)(-5)
-
-// func staticRv2iTest() {
-// i0 := (int32)(-5)
-// m0 := make(map[string]uint16)
-// m0["1"] = 1
-// for _, i := range []interface{}{
-// (int)(7),
-// (uint)(8),
-// (int16)(-9),
-// (uint16)(19),
-// (uintptr)(77),
-// (bool)(true),
-// float32(-32.7),
-// float64(64.9),
-// complex(float32(19), 5),
-// complex(float64(-32), 7),
-// [4]uint64{1, 2, 3, 4},
-// (chan<- int)(nil), // chan,
-// rv2i, // func
-// io.Writer(ioutil.Discard),
-// make(map[string]uint),
-// (map[string]uint)(nil),
-// staticM0,
-// m0,
-// &m0,
-// i0,
-// &i0,
-// &staticI0,
-// &staticM0,
-// []uint32{6, 7, 8},
-// "abc",
-// Raw{},
-// RawExt{},
-// &Raw{},
-// &RawExt{},
-// unsafe.Pointer(&i0),
-// } {
-// i2 := rv2i(reflect.ValueOf(i))
-// eq := reflect.DeepEqual(i, i2)
-// fmt.Printf(">>>> %v == %v? %v\n", i, i2, eq)
-// }
-// // os.Exit(0)
-// }
+func (t *unsafeMapIter) Done() {
+}
+
+func unsafeMapSet(p, ptyp, p2 unsafe.Pointer, isref bool) {
+ if isref {
+ *(*unsafe.Pointer)(p) = *(*unsafe.Pointer)(p2) // p2
+ } else {
+ typedmemmove(ptyp, p, p2) // *(*unsafe.Pointer)(p2)) // p2)
+ }
+}
+
+func unsafeMapKVPtr(urv *unsafeReflectValue) unsafe.Pointer {
+ if urv.flag&unsafeFlagIndir == 0 {
+ return unsafe.Pointer(&urv.ptr)
+ }
+ return urv.ptr
+}
-// func init() {
-// staticRv2iTest()
+func mapRange(t *mapIter, m, k, v reflect.Value, mapvalues bool) {
+ if rvIsNil(m) {
+ t.done = true
+ return
+ }
+ t.done = false
+ t.started = false
+ t.mapvalues = mapvalues
+
+ var urv *unsafeReflectValue
+
+ urv = (*unsafeReflectValue)(unsafe.Pointer(&m))
+ t.mtyp = urv.typ
+ t.mptr = rv2ptr(urv)
+
+ t.it = (*unsafeMapHashIter)(mapiterinit(t.mtyp, t.mptr))
+
+ urv = (*unsafeReflectValue)(unsafe.Pointer(&k))
+ t.ktyp = urv.typ
+ t.kptr = urv.ptr
+ t.kisref = refBitset.isset(byte(k.Kind()))
+
+ if mapvalues {
+ urv = (*unsafeReflectValue)(unsafe.Pointer(&v))
+ t.vtyp = urv.typ
+ t.vptr = urv.ptr
+ t.visref = refBitset.isset(byte(v.Kind()))
+ } else {
+ t.vtyp = nil
+ t.vptr = nil
+ }
+}
+
+func mapGet(m, k, v reflect.Value) (vv reflect.Value) {
+ var urv = (*unsafeReflectValue)(unsafe.Pointer(&k))
+ var kptr = unsafeMapKVPtr(urv)
+
+ urv = (*unsafeReflectValue)(unsafe.Pointer(&m))
+
+ vvptr := mapaccess(urv.typ, rv2ptr(urv), kptr)
+ if vvptr == nil {
+ return
+ }
+ // vvptr = *(*unsafe.Pointer)(vvptr)
+
+ urv = (*unsafeReflectValue)(unsafe.Pointer(&v))
+
+ unsafeMapSet(urv.ptr, urv.typ, vvptr, refBitset.isset(byte(v.Kind())))
+ return v
+}
+
+func mapSet(m, k, v reflect.Value) {
+ var urv = (*unsafeReflectValue)(unsafe.Pointer(&k))
+ var kptr = unsafeMapKVPtr(urv)
+ urv = (*unsafeReflectValue)(unsafe.Pointer(&v))
+ var vptr = unsafeMapKVPtr(urv)
+ urv = (*unsafeReflectValue)(unsafe.Pointer(&m))
+ mapassign(urv.typ, rv2ptr(urv), kptr, vptr)
+}
+
+// func mapDelete(m, k reflect.Value) {
+// var urv = (*unsafeReflectValue)(unsafe.Pointer(&k))
+// var kptr = unsafeMapKVPtr(urv)
+// urv = (*unsafeReflectValue)(unsafe.Pointer(&m))
+// mapdelete(urv.typ, rv2ptr(urv), kptr)
// }
-// func rv2i(rv reflect.Value) interface{} {
-// if _USE_RV_INTERFACE || rv.Kind() == reflect.Interface || rv.CanAddr() {
-// return rv.Interface()
-// }
-// // var i interface{}
-// // ui := (*unsafeIntf)(unsafe.Pointer(&i))
-// var ui unsafeIntf
-// urv := (*unsafeReflectValue)(unsafe.Pointer(&rv))
-// // fmt.Printf("urv: flag: %b, typ: %b, ptr: %b\n", urv.flag, uintptr(urv.typ), uintptr(urv.ptr))
-// if (urv.flag&unsafeRvFlagKindMask)&unsafeRvKindDirectIface == 0 {
-// if urv.flag&unsafeRvFlagAddr != 0 {
-// println("***** indirect and addressable! Needs typed move - delegate to rv.Interface()")
-// return rv.Interface()
-// }
-// println("****** indirect type/kind")
-// ui.word = urv.ptr
-// } else if urv.flag&unsafeRvFlagIndir != 0 {
-// println("****** unsafe rv flag indir")
-// ui.word = *(*unsafe.Pointer)(urv.ptr)
-// } else {
-// println("****** default: assign prt to word directly")
-// ui.word = urv.ptr
-// }
-// // ui.word = urv.ptr
-// ui.typ = urv.typ
-// // fmt.Printf("(pointers) ui.typ: %p, word: %p\n", ui.typ, ui.word)
-// // fmt.Printf("(binary) ui.typ: %b, word: %b\n", uintptr(ui.typ), uintptr(ui.word))
-// return *(*interface{})(unsafe.Pointer(&ui))
-// // return i
+// return an addressable reflect value that can be used in mapRange and mapGet operations.
+//
+// all calls to mapGet or mapRange will call here to get an addressable reflect.Value.
+func mapAddressableRV(t reflect.Type, k reflect.Kind) (r reflect.Value) {
+ // return reflect.New(t).Elem()
+ return rvZeroAddrK(t, k)
+}
+
+//go:linkname mapiterinit reflect.mapiterinit
+//go:noescape
+func mapiterinit(typ unsafe.Pointer, it unsafe.Pointer) (key unsafe.Pointer)
+
+//go:linkname mapiternext reflect.mapiternext
+//go:noescape
+func mapiternext(it unsafe.Pointer) (key unsafe.Pointer)
+
+//go:linkname mapaccess reflect.mapaccess
+//go:noescape
+func mapaccess(typ unsafe.Pointer, m unsafe.Pointer, key unsafe.Pointer) (val unsafe.Pointer)
+
+//go:linkname mapassign reflect.mapassign
+//go:noescape
+func mapassign(typ unsafe.Pointer, m unsafe.Pointer, key, val unsafe.Pointer)
+
+//go:linkname mapdelete reflect.mapdelete
+//go:noescape
+func mapdelete(typ unsafe.Pointer, m unsafe.Pointer, key unsafe.Pointer)
+
+//go:linkname typedmemmove reflect.typedmemmove
+//go:noescape
+func typedmemmove(typ unsafe.Pointer, dst, src unsafe.Pointer)
+
+//go:linkname unsafe_New reflect.unsafe_New
+//go:noescape
+func unsafe_New(typ unsafe.Pointer) unsafe.Pointer
+
+//go:linkname typedslicecopy reflect.typedslicecopy
+//go:noescape
+func typedslicecopy(elemType unsafe.Pointer, dst, src unsafeSlice) int
+
+// ---------- ENCODER optimized ---------------
+
+func (e *Encoder) jsondriver() *jsonEncDriver {
+ return (*jsonEncDriver)((*unsafeIntf)(unsafe.Pointer(&e.e)).word)
+}
+
+// ---------- DECODER optimized ---------------
+
+func (d *Decoder) checkBreak() bool {
+ // jsonDecDriver.CheckBreak() CANNOT be inlined.
+ // Consequently, there's no benefit in incurring the cost of this
+ // wrapping function checkBreak.
+ //
+ // It is faster to just call the interface method directly.
+
+ // if d.js {
+ // return d.jsondriver().CheckBreak()
+ // }
+ // if d.cbor {
+ // return d.cbordriver().CheckBreak()
+ // }
+ return d.d.CheckBreak()
+}
+
+func (d *Decoder) jsondriver() *jsonDecDriver {
+ return (*jsonDecDriver)((*unsafeIntf)(unsafe.Pointer(&d.d)).word)
+}
+
+// func (d *Decoder) cbordriver() *cborDecDriver {
+// return (*cborDecDriver)((*unsafeIntf)(unsafe.Pointer(&d.d)).word)
// }
diff --git a/vendor/github.com/ugorji/go/codec/json.go b/vendor/github.com/ugorji/go/codec/json.go
index 619bc5b..7b64e02 100644
--- a/vendor/github.com/ugorji/go/codec/json.go
+++ b/vendor/github.com/ugorji/go/codec/json.go
@@ -18,14 +18,10 @@ package codec
// - we cannot use strconv.Quote and strconv.Unquote because json quotes/unquotes differently.
// We implement it here.
-// Top-level methods of json(End|Dec)Driver (which are implementations of (en|de)cDriver
-// MUST not call one-another.
-
import (
"bytes"
"encoding/base64"
"math"
- "reflect"
"strconv"
"time"
"unicode"
@@ -46,11 +42,20 @@ const (
jsonLitTrue = 1
jsonLitFalseQ = 6
jsonLitFalse = 7
- // jsonLitNullQ = 13
- jsonLitNull = 14
+ jsonLitNullQ = 13
+ jsonLitNull = 14
)
var (
+ // jsonLiteralTrueQ = jsonLiterals[jsonLitTrueQ : jsonLitTrueQ+6]
+ // jsonLiteralFalseQ = jsonLiterals[jsonLitFalseQ : jsonLitFalseQ+7]
+ // jsonLiteralNullQ = jsonLiterals[jsonLitNullQ : jsonLitNullQ+6]
+
+ jsonLiteralTrue = jsonLiterals[jsonLitTrue : jsonLitTrue+4]
+ jsonLiteralFalse = jsonLiterals[jsonLitFalse : jsonLitFalse+5]
+ jsonLiteralNull = jsonLiterals[jsonLitNull : jsonLitNull+4]
+
+ // these are used, after consuming the first char
jsonLiteral4True = jsonLiterals[jsonLitTrue+1 : jsonLitTrue+4]
jsonLiteral4False = jsonLiterals[jsonLitFalse+1 : jsonLitFalse+5]
jsonLiteral4Null = jsonLiterals[jsonLitNull+1 : jsonLitNull+4]
@@ -61,7 +66,7 @@ const (
jsonU4Chk1 = 'a' - 10
jsonU4Chk0 = 'A' - 10
- jsonScratchArrayLen = 64
+ // jsonScratchArrayLen = cacheLineSize + 32 // 96
)
const (
@@ -120,429 +125,280 @@ func init() {
// ----------------
-type jsonEncDriverTypical struct {
- w *encWriterSwitch
- b *[jsonScratchArrayLen]byte
- tw bool // term white space
- c containerState
-}
-
-func (e *jsonEncDriverTypical) typical() {}
-
-func (e *jsonEncDriverTypical) reset(ee *jsonEncDriver) {
- e.w = ee.ew
- e.b = &ee.b
- e.tw = ee.h.TermWhitespace
- e.c = 0
-}
+type jsonEncDriver struct {
+ noBuiltInTypes
+ h *JsonHandle
-func (e *jsonEncDriverTypical) WriteArrayStart(length int) {
- e.w.writen1('[')
- e.c = containerArrayStart
-}
+ se interfaceExtWrapper
-func (e *jsonEncDriverTypical) WriteArrayElem() {
- if e.c != containerArrayStart {
- e.w.writen1(',')
- }
- e.c = containerArrayElem
-}
+ // ---- cpu cache line boundary?
+ di int8 // indent per: if negative, use tabs
+ d bool // indenting?
+ dl uint16 // indent level
+ ks bool // map key as string
+ is byte // integer as string
-func (e *jsonEncDriverTypical) WriteArrayEnd() {
- e.w.writen1(']')
- e.c = containerArrayEnd
-}
+ typical bool
-func (e *jsonEncDriverTypical) WriteMapStart(length int) {
- e.w.writen1('{')
- e.c = containerMapStart
-}
+ s *bitset256 // safe set for characters (taking h.HTMLAsIs into consideration)
+ // scratch: encode time, numbers, etc. Note: leave 1 byte for containerState
+ b [cacheLineSize + 24]byte // buffer for encoding numbers and time
-func (e *jsonEncDriverTypical) WriteMapElemKey() {
- if e.c != containerMapStart {
- e.w.writen1(',')
- }
- e.c = containerMapKey
+ e Encoder
}
-func (e *jsonEncDriverTypical) WriteMapElemValue() {
- e.w.writen1(':')
- e.c = containerMapValue
-}
+// Keep writeIndent, WriteArrayElem, WriteMapElemKey, WriteMapElemValue
+// in jsonEncDriver, so that *Encoder can directly call them
-func (e *jsonEncDriverTypical) WriteMapEnd() {
- e.w.writen1('}')
- e.c = containerMapEnd
-}
+func (e *jsonEncDriver) encoder() *Encoder { return &e.e }
-func (e *jsonEncDriverTypical) EncodeBool(b bool) {
- if b {
- e.w.writeb(jsonLiterals[jsonLitTrue : jsonLitTrue+4])
+func (e *jsonEncDriver) writeIndent() {
+ e.e.encWr.writen1('\n')
+ x := int(e.di) * int(e.dl)
+ if e.di < 0 {
+ x = -x
+ for x > jsonSpacesOrTabsLen {
+ e.e.encWr.writeb(jsonTabs[:])
+ x -= jsonSpacesOrTabsLen
+ }
+ e.e.encWr.writeb(jsonTabs[:x])
} else {
- e.w.writeb(jsonLiterals[jsonLitFalse : jsonLitFalse+5])
- }
-}
-
-func (e *jsonEncDriverTypical) EncodeFloat64(f float64) {
- fmt, prec := jsonFloatStrconvFmtPrec(f)
- e.w.writeb(strconv.AppendFloat(e.b[:0], f, fmt, prec, 64))
-}
-
-func (e *jsonEncDriverTypical) EncodeInt(v int64) {
- e.w.writeb(strconv.AppendInt(e.b[:0], v, 10))
-}
-
-func (e *jsonEncDriverTypical) EncodeUint(v uint64) {
- e.w.writeb(strconv.AppendUint(e.b[:0], v, 10))
-}
-
-func (e *jsonEncDriverTypical) EncodeFloat32(f float32) {
- e.EncodeFloat64(float64(f))
-}
-
-func (e *jsonEncDriverTypical) atEndOfEncode() {
- if e.tw {
- e.w.writen1(' ')
+ for x > jsonSpacesOrTabsLen {
+ e.e.encWr.writeb(jsonSpaces[:])
+ x -= jsonSpacesOrTabsLen
+ }
+ e.e.encWr.writeb(jsonSpaces[:x])
}
}
-// ----------------
-
-type jsonEncDriverGeneric struct {
- w *encWriterSwitch
- b *[jsonScratchArrayLen]byte
- c containerState
- // ds string // indent string
- di int8 // indent per
- d bool // indenting?
- dt bool // indent using tabs
- dl uint16 // indent level
- ks bool // map key as string
- is byte // integer as string
- tw bool // term white space
- _ [7]byte // padding
-}
-
-// indent is done as below:
-// - newline and indent are added before each mapKey or arrayElem
-// - newline and indent are added before each ending,
-// except there was no entry (so we can have {} or [])
-
-func (e *jsonEncDriverGeneric) reset(ee *jsonEncDriver) {
- e.w = ee.ew
- e.b = &ee.b
- e.tw = ee.h.TermWhitespace
- e.c = 0
- e.d, e.dt, e.dl, e.di = false, false, 0, 0
- h := ee.h
- if h.Indent > 0 {
- e.d = true
- e.di = int8(h.Indent)
- } else if h.Indent < 0 {
- e.d = true
- e.dt = true
- e.di = int8(-h.Indent)
+func (e *jsonEncDriver) WriteArrayElem() {
+ if e.e.c != containerArrayStart {
+ e.e.encWr.writen1(',')
}
- e.ks = h.MapKeyAsString
- e.is = h.IntegerAsString
-}
-
-func (e *jsonEncDriverGeneric) WriteArrayStart(length int) {
if e.d {
- e.dl++
+ e.writeIndent()
}
- e.w.writen1('[')
- e.c = containerArrayStart
}
-func (e *jsonEncDriverGeneric) WriteArrayElem() {
- if e.c != containerArrayStart {
- e.w.writen1(',')
+func (e *jsonEncDriver) WriteMapElemKey() {
+ if e.e.c != containerMapStart {
+ e.e.encWr.writen1(',')
}
if e.d {
e.writeIndent()
}
- e.c = containerArrayElem
}
-func (e *jsonEncDriverGeneric) WriteArrayEnd() {
+func (e *jsonEncDriver) WriteMapElemValue() {
if e.d {
- e.dl--
- if e.c != containerArrayStart {
- e.writeIndent()
- }
+ e.e.encWr.writen2(':', ' ')
+ } else {
+ e.e.encWr.writen1(':')
}
- e.w.writen1(']')
- e.c = containerArrayEnd
}
-func (e *jsonEncDriverGeneric) WriteMapStart(length int) {
- if e.d {
- e.dl++
- }
- e.w.writen1('{')
- e.c = containerMapStart
-}
+func (e *jsonEncDriver) EncodeNil() {
+ // We always encode nil as just null (never in quotes)
+ // This allows us to easily decode if a nil in the json stream
+ // ie if initial token is n.
-func (e *jsonEncDriverGeneric) WriteMapElemKey() {
- if e.c != containerMapStart {
- e.w.writen1(',')
- }
- if e.d {
- e.writeIndent()
- }
- e.c = containerMapKey
+ // e.e.encWr.writeb(jsonLiteralNull)
+ e.e.encWr.writen([rwNLen]byte{'n', 'u', 'l', 'l'}, 4)
}
-func (e *jsonEncDriverGeneric) WriteMapElemValue() {
- if e.d {
- e.w.writen2(':', ' ')
+func (e *jsonEncDriver) EncodeTime(t time.Time) {
+ // Do NOT use MarshalJSON, as it allocates internally.
+ // instead, we call AppendFormat directly, using our scratch buffer (e.b)
+
+ if t.IsZero() {
+ e.EncodeNil()
} else {
- e.w.writen1(':')
+ e.b[0] = '"'
+ b := fmtTime(t, e.b[1:1])
+ e.b[len(b)+1] = '"'
+ e.e.encWr.writeb(e.b[:len(b)+2])
}
- e.c = containerMapValue
}
-func (e *jsonEncDriverGeneric) WriteMapEnd() {
- if e.d {
- e.dl--
- if e.c != containerMapStart {
- e.writeIndent()
- }
+func (e *jsonEncDriver) EncodeExt(rv interface{}, xtag uint64, ext Ext) {
+ if ext == SelfExt {
+ rv2 := baseRV(rv)
+ e.e.encodeValue(rv2, e.h.fnNoExt(rv2.Type()))
+ } else if v := ext.ConvertExt(rv); v == nil {
+ e.EncodeNil()
+ } else {
+ e.e.encode(v)
}
- e.w.writen1('}')
- e.c = containerMapEnd
}
-func (e *jsonEncDriverGeneric) writeIndent() {
- e.w.writen1('\n')
- x := int(e.di) * int(e.dl)
- if e.dt {
- for x > jsonSpacesOrTabsLen {
- e.w.writeb(jsonTabs[:])
- x -= jsonSpacesOrTabsLen
- }
- e.w.writeb(jsonTabs[:x])
+func (e *jsonEncDriver) EncodeRawExt(re *RawExt) {
+ // only encodes re.Value (never re.Data)
+ if re.Value == nil {
+ e.EncodeNil()
} else {
- for x > jsonSpacesOrTabsLen {
- e.w.writeb(jsonSpaces[:])
- x -= jsonSpacesOrTabsLen
- }
- e.w.writeb(jsonSpaces[:x])
+ e.e.encode(re.Value)
}
}
-func (e *jsonEncDriverGeneric) EncodeBool(b bool) {
- if e.ks && e.c == containerMapKey {
+func (e *jsonEncDriver) EncodeBool(b bool) {
+ // Use writen with an array instead of writeb with a slice
+ // i.e. in place of e.e.encWr.writeb(jsonLiteralTrueQ)
+ // OR jsonLiteralTrue, jsonLiteralFalse, jsonLiteralFalseQ, etc
+
+ if e.ks && e.e.c == containerMapKey {
if b {
- e.w.writeb(jsonLiterals[jsonLitTrueQ : jsonLitTrueQ+6])
+ e.e.encWr.writen([rwNLen]byte{'"', 't', 'r', 'u', 'e', '"'}, 6)
} else {
- e.w.writeb(jsonLiterals[jsonLitFalseQ : jsonLitFalseQ+7])
+ e.e.encWr.writen([rwNLen]byte{'"', 'f', 'a', 'l', 's', 'e', '"'}, 7)
}
} else {
if b {
- e.w.writeb(jsonLiterals[jsonLitTrue : jsonLitTrue+4])
+ e.e.encWr.writen([rwNLen]byte{'t', 'r', 'u', 'e'}, 4)
} else {
- e.w.writeb(jsonLiterals[jsonLitFalse : jsonLitFalse+5])
+ e.e.encWr.writen([rwNLen]byte{'f', 'a', 'l', 's', 'e'}, 5)
}
}
}
-func (e *jsonEncDriverGeneric) EncodeFloat64(f float64) {
- // instead of using 'g', specify whether to use 'e' or 'f'
- fmt, prec := jsonFloatStrconvFmtPrec(f)
-
- var blen int
- if e.ks && e.c == containerMapKey {
- blen = 2 + len(strconv.AppendFloat(e.b[1:1], f, fmt, prec, 64))
+func (e *jsonEncDriver) encodeFloat(f float64, bitsize, fmt byte, prec int8) {
+ var blen uint
+ if e.ks && e.e.c == containerMapKey {
+ blen = 2 + uint(len(strconv.AppendFloat(e.b[1:1], f, fmt, int(prec), int(bitsize))))
+ // _ = e.b[:blen]
e.b[0] = '"'
e.b[blen-1] = '"'
+ e.e.encWr.writeb(e.b[:blen])
} else {
- blen = len(strconv.AppendFloat(e.b[:0], f, fmt, prec, 64))
+ e.e.encWr.writeb(strconv.AppendFloat(e.b[:0], f, fmt, int(prec), int(bitsize)))
}
- e.w.writeb(e.b[:blen])
}
-func (e *jsonEncDriverGeneric) EncodeInt(v int64) {
- x := e.is
- if x == 'A' || x == 'L' && (v > 1<<53 || v < -(1<<53)) || (e.ks && e.c == containerMapKey) {
+func (e *jsonEncDriver) EncodeFloat64(f float64) {
+ fmt, prec := jsonFloatStrconvFmtPrec64(f)
+ e.encodeFloat(f, 64, fmt, prec)
+}
+
+func (e *jsonEncDriver) EncodeFloat32(f float32) {
+ fmt, prec := jsonFloatStrconvFmtPrec32(f)
+ e.encodeFloat(float64(f), 32, fmt, prec)
+}
+
+func (e *jsonEncDriver) EncodeInt(v int64) {
+ if e.is == 'A' || e.is == 'L' && (v > 1<<53 || v < -(1<<53)) ||
+ (e.ks && e.e.c == containerMapKey) {
blen := 2 + len(strconv.AppendInt(e.b[1:1], v, 10))
e.b[0] = '"'
e.b[blen-1] = '"'
- e.w.writeb(e.b[:blen])
+ e.e.encWr.writeb(e.b[:blen])
return
}
- e.w.writeb(strconv.AppendInt(e.b[:0], v, 10))
+ e.e.encWr.writeb(strconv.AppendInt(e.b[:0], v, 10))
}
-func (e *jsonEncDriverGeneric) EncodeUint(v uint64) {
- x := e.is
- if x == 'A' || x == 'L' && v > 1<<53 || (e.ks && e.c == containerMapKey) {
+func (e *jsonEncDriver) EncodeUint(v uint64) {
+ if e.is == 'A' || e.is == 'L' && v > 1<<53 || (e.ks && e.e.c == containerMapKey) {
blen := 2 + len(strconv.AppendUint(e.b[1:1], v, 10))
e.b[0] = '"'
e.b[blen-1] = '"'
- e.w.writeb(e.b[:blen])
+ e.e.encWr.writeb(e.b[:blen])
return
}
- e.w.writeb(strconv.AppendUint(e.b[:0], v, 10))
-}
-
-func (e *jsonEncDriverGeneric) EncodeFloat32(f float32) {
- // e.encodeFloat(float64(f), 32)
- // always encode all floats as IEEE 64-bit floating point.
- // It also ensures that we can decode in full precision even if into a float32,
- // as what is written is always to float64 precision.
- e.EncodeFloat64(float64(f))
-}
-
-func (e *jsonEncDriverGeneric) atEndOfEncode() {
- if e.tw {
- if e.d {
- e.w.writen1('\n')
- } else {
- e.w.writen1(' ')
- }
- }
-}
-
-// --------------------
-
-type jsonEncDriver struct {
- noBuiltInTypes
- e *Encoder
- h *JsonHandle
- ew *encWriterSwitch
- se extWrapper
- // ---- cpu cache line boundary?
- bs []byte // scratch
- // ---- cpu cache line boundary?
- b [jsonScratchArrayLen]byte // scratch (encode time,
- _ [2]uint64 // padding
-}
-
-func (e *jsonEncDriver) EncodeNil() {
- // We always encode nil as just null (never in quotes)
- // This allows us to easily decode if a nil in the json stream
- // ie if initial token is n.
- e.ew.writeb(jsonLiterals[jsonLitNull : jsonLitNull+4])
-
- // if e.h.MapKeyAsString && e.c == containerMapKey {
- // e.ew.writeb(jsonLiterals[jsonLitNullQ : jsonLitNullQ+6])
- // } else {
- // e.ew.writeb(jsonLiterals[jsonLitNull : jsonLitNull+4])
- // }
+ e.e.encWr.writeb(strconv.AppendUint(e.b[:0], v, 10))
}
-func (e *jsonEncDriver) EncodeTime(t time.Time) {
- // Do NOT use MarshalJSON, as it allocates internally.
- // instead, we call AppendFormat directly, using our scratch buffer (e.b)
- if t.IsZero() {
- e.EncodeNil()
- } else {
- e.b[0] = '"'
- b := t.AppendFormat(e.b[1:1], time.RFC3339Nano)
- e.b[len(b)+1] = '"'
- e.ew.writeb(e.b[:len(b)+2])
- }
- // v, err := t.MarshalJSON(); if err != nil { e.e.error(err) } e.ew.writeb(v)
-}
-
-func (e *jsonEncDriver) EncodeExt(rv interface{}, xtag uint64, ext Ext, en *Encoder) {
- if v := ext.ConvertExt(rv); v == nil {
- e.EncodeNil()
- } else {
- en.encode(v)
- }
-}
-
-func (e *jsonEncDriver) EncodeRawExt(re *RawExt, en *Encoder) {
- // only encodes re.Value (never re.Data)
- if re.Value == nil {
- e.EncodeNil()
- } else {
- en.encode(re.Value)
+func (e *jsonEncDriver) EncodeString(v string) {
+ if e.h.StringToRaw {
+ e.EncodeStringBytesRaw(bytesView(v))
+ return
}
-}
-
-func (e *jsonEncDriver) EncodeString(c charEncoding, v string) {
e.quoteStr(v)
}
-func (e *jsonEncDriver) EncodeStringEnc(c charEncoding, v string) {
- e.quoteStr(v)
-}
-
-func (e *jsonEncDriver) EncodeStringBytes(c charEncoding, v []byte) {
+func (e *jsonEncDriver) EncodeStringBytesRaw(v []byte) {
// if encoding raw bytes and RawBytesExt is configured, use it to encode
if v == nil {
e.EncodeNil()
return
}
- if c == cRAW {
- if e.se.InterfaceExt != nil {
- e.EncodeExt(v, 0, &e.se, e.e)
- return
- }
+ if e.se.InterfaceExt != nil {
+ e.EncodeExt(v, 0, &e.se)
+ return
+ }
- slen := base64.StdEncoding.EncodedLen(len(v)) + 2
- if cap(e.bs) >= slen {
- e.bs = e.bs[:slen]
- } else {
- e.bs = make([]byte, slen)
- }
- e.bs[0] = '"'
- base64.StdEncoding.Encode(e.bs[1:], v)
- e.bs[slen-1] = '"'
- e.ew.writeb(e.bs)
+ slen := base64.StdEncoding.EncodedLen(len(v)) + 2
+ var bs []byte
+ if len(e.b) < slen {
+ bs = e.e.blist.get(slen)
} else {
- e.quoteStr(stringView(v))
+ bs = e.b[:slen]
+ }
+ bs[0] = '"'
+ base64.StdEncoding.Encode(bs[1:], v)
+ bs[len(bs)-1] = '"'
+ e.e.encWr.writeb(bs)
+ if len(e.b) < slen {
+ e.e.blist.put(bs)
}
}
-func (e *jsonEncDriver) EncodeStringBytesRaw(v []byte) {
- // if encoding raw bytes and RawBytesExt is configured, use it to encode
- if v == nil {
- e.EncodeNil()
- return
+// indent is done as below:
+// - newline and indent are added before each mapKey or arrayElem
+// - newline and indent are added before each ending,
+// except there was no entry (so we can have {} or [])
+
+func (e *jsonEncDriver) WriteArrayStart(length int) {
+ if e.d {
+ e.dl++
}
- if e.se.InterfaceExt != nil {
- e.EncodeExt(v, 0, &e.se, e.e)
- return
+ e.e.encWr.writen1('[')
+}
+
+func (e *jsonEncDriver) WriteArrayEnd() {
+ if e.d {
+ e.dl--
+ e.writeIndent()
}
+ e.e.encWr.writen1(']')
+}
- slen := base64.StdEncoding.EncodedLen(len(v)) + 2
- if cap(e.bs) >= slen {
- e.bs = e.bs[:slen]
- } else {
- e.bs = make([]byte, slen)
+func (e *jsonEncDriver) WriteMapStart(length int) {
+ if e.d {
+ e.dl++
}
- e.bs[0] = '"'
- base64.StdEncoding.Encode(e.bs[1:], v)
- e.bs[slen-1] = '"'
- e.ew.writeb(e.bs)
+ e.e.encWr.writen1('{')
}
-func (e *jsonEncDriver) EncodeAsis(v []byte) {
- e.ew.writeb(v)
+func (e *jsonEncDriver) WriteMapEnd() {
+ if e.d {
+ e.dl--
+ if e.e.c != containerMapStart {
+ e.writeIndent()
+ }
+ }
+ e.e.encWr.writen1('}')
}
func (e *jsonEncDriver) quoteStr(s string) {
// adapted from std pkg encoding/json
const hex = "0123456789abcdef"
- w := e.ew
- htmlasis := e.h.HTMLCharsAsIs
+ w := e.e.w()
w.writen1('"')
- var start int
- for i, slen := 0, len(s); i < slen; {
+ var i, start uint
+ for i < uint(len(s)) {
// encode all bytes < 0x20 (except \r, \n).
// also encode < > & to prevent security holes when served to some browsers.
- if b := s[i]; b < utf8.RuneSelf {
- // if 0x20 <= b && b != '\\' && b != '"' && b != '<' && b != '>' && b != '&' {
- // if (htmlasis && jsonCharSafeSet.isset(b)) || jsonCharHtmlSafeSet.isset(b) {
- if jsonCharHtmlSafeSet.isset(b) || (htmlasis && jsonCharSafeSet.isset(b)) {
- i++
- continue
- }
+
+ // We optimize for ascii, by assumining that most characters are in the BMP
+ // and natively consumed by json without much computation.
+
+ // if 0x20 <= b && b != '\\' && b != '"' && b != '<' && b != '>' && b != '&' {
+ // if (htmlasis && jsonCharSafeSet.isset(b)) || jsonCharHtmlSafeSet.isset(b) {
+ b := s[i]
+ if e.s.isset(b) {
+ i++
+ continue
+ }
+ if b < utf8.RuneSelf {
if start < i {
w.writestr(s[start:i])
}
@@ -568,13 +424,15 @@ func (e *jsonEncDriver) quoteStr(s string) {
continue
}
c, size := utf8.DecodeRuneInString(s[i:])
- if c == utf8.RuneError && size == 1 {
- if start < i {
- w.writestr(s[start:i])
+ if c == utf8.RuneError {
+ if size == 1 {
+ if start < i {
+ w.writestr(s[start:i])
+ }
+ w.writestr(`\ufffd`)
+ i++
+ start = i
}
- w.writestr(`\ufffd`)
- i += size
- start = i
continue
}
// U+2028 is LINE SEPARATOR. U+2029 is PARAGRAPH SEPARATOR.
@@ -585,39 +443,47 @@ func (e *jsonEncDriver) quoteStr(s string) {
}
w.writestr(`\u202`)
w.writen1(hex[c&0xF])
- i += size
+ i += uint(size)
start = i
continue
}
- i += size
+ i += uint(size)
}
- if start < len(s) {
+ if start < uint(len(s)) {
w.writestr(s[start:])
}
w.writen1('"')
}
+func (e *jsonEncDriver) atEndOfEncode() {
+ if e.h.TermWhitespace {
+ if e.e.c == 0 { // scalar written, output space
+ e.e.encWr.writen1(' ')
+ } else { // container written, output new-line
+ e.e.encWr.writen1('\n')
+ }
+ }
+}
+
+// ----------
+
type jsonDecDriver struct {
noBuiltInTypes
- d *Decoder
- h *JsonHandle
- r *decReaderSwitch
- se extWrapper
-
- // ---- writable fields during execution --- *try* to keep in sep cache line
-
- c containerState
- // tok is used to store the token read right after skipWhiteSpace.
- tok uint8
- fnull bool // found null from appendStringAsBytes
- bs []byte // scratch. Initialized from b. Used for parsing strings or numbers.
- bstr [8]byte // scratch used for string \UXXX parsing
+ h *JsonHandle
+
+ tok uint8 // used to store the token read right after skipWhiteSpace
+ fnil bool // found null
+ _ [2]byte // padding
+ bstr [4]byte // scratch used for string \UXXX parsing
+
+ buf []byte
+ se interfaceExtWrapper
+
+ _ uint64 // padding
+
// ---- cpu cache line boundary?
- b [jsonScratchArrayLen]byte // scratch 1, used for parsing strings or numbers or time.Time
- b2 [jsonScratchArrayLen]byte // scratch 2, used only for readUntil, decNumBytes
- // _ [3]uint64 // padding
- // n jsonNum
+ d Decoder
}
// func jsonIsWS(b byte) bool {
@@ -625,158 +491,144 @@ type jsonDecDriver struct {
// return jsonCharWhitespaceSet.isset(b)
// }
+func (d *jsonDecDriver) decoder() *Decoder {
+ return &d.d
+}
+
func (d *jsonDecDriver) uncacheRead() {
if d.tok != 0 {
- d.r.unreadn1()
+ d.d.decRd.unreadn1()
d.tok = 0
}
}
func (d *jsonDecDriver) ReadMapStart() int {
- if d.tok == 0 {
- d.tok = d.r.skip(&jsonCharWhitespaceSet)
+ d.advance()
+ if d.tok == 'n' {
+ d.readLit4Null()
+ return decContainerLenNil
}
- const xc uint8 = '{'
- if d.tok != xc {
- d.d.errorf("read map - expect char '%c' but got char '%c'", xc, d.tok)
+ if d.tok != '{' {
+ d.d.errorf("read map - expect char '%c' but got char '%c'", '{', d.tok)
}
d.tok = 0
- d.c = containerMapStart
- return -1
+ return decContainerLenUnknown
}
func (d *jsonDecDriver) ReadArrayStart() int {
- if d.tok == 0 {
- d.tok = d.r.skip(&jsonCharWhitespaceSet)
+ d.advance()
+ if d.tok == 'n' {
+ d.readLit4Null()
+ return decContainerLenNil
}
- const xc uint8 = '['
- if d.tok != xc {
- d.d.errorf("read array - expect char '%c' but got char '%c'", xc, d.tok)
+ if d.tok != '[' {
+ d.d.errorf("read array - expect char '%c' but got char '%c'", '[', d.tok)
}
d.tok = 0
- d.c = containerArrayStart
- return -1
+ return decContainerLenUnknown
}
func (d *jsonDecDriver) CheckBreak() bool {
- if d.tok == 0 {
- d.tok = d.r.skip(&jsonCharWhitespaceSet)
- }
+ d.advance()
return d.tok == '}' || d.tok == ']'
}
-// For the ReadXXX methods below, we could just delegate to helper functions
-// readContainerState(c containerState, xc uint8, check bool)
-// - ReadArrayElem would become:
-// readContainerState(containerArrayElem, ',', d.c != containerArrayStart)
-//
-// However, until mid-stack inlining comes in go1.11 which supports inlining of
-// one-liners, we explicitly write them all 5 out to elide the extra func call.
-//
-// TODO: For Go 1.11, if inlined, consider consolidating these.
-
func (d *jsonDecDriver) ReadArrayElem() {
const xc uint8 = ','
- if d.tok == 0 {
- d.tok = d.r.skip(&jsonCharWhitespaceSet)
- }
- if d.c != containerArrayStart {
+ if d.d.c != containerArrayStart {
+ d.advance()
if d.tok != xc {
- d.d.errorf("read array element - expect char '%c' but got char '%c'", xc, d.tok)
+ d.readDelimError(xc)
}
d.tok = 0
}
- d.c = containerArrayElem
}
func (d *jsonDecDriver) ReadArrayEnd() {
const xc uint8 = ']'
- if d.tok == 0 {
- d.tok = d.r.skip(&jsonCharWhitespaceSet)
- }
+ d.advance()
if d.tok != xc {
- d.d.errorf("read array end - expect char '%c' but got char '%c'", xc, d.tok)
+ d.readDelimError(xc)
}
d.tok = 0
- d.c = containerArrayEnd
}
func (d *jsonDecDriver) ReadMapElemKey() {
const xc uint8 = ','
- if d.tok == 0 {
- d.tok = d.r.skip(&jsonCharWhitespaceSet)
- }
- if d.c != containerMapStart {
+ if d.d.c != containerMapStart {
+ d.advance()
if d.tok != xc {
- d.d.errorf("read map key - expect char '%c' but got char '%c'", xc, d.tok)
+ d.readDelimError(xc)
}
d.tok = 0
}
- d.c = containerMapKey
}
func (d *jsonDecDriver) ReadMapElemValue() {
const xc uint8 = ':'
- if d.tok == 0 {
- d.tok = d.r.skip(&jsonCharWhitespaceSet)
- }
+ d.advance()
if d.tok != xc {
- d.d.errorf("read map value - expect char '%c' but got char '%c'", xc, d.tok)
+ d.readDelimError(xc)
}
d.tok = 0
- d.c = containerMapValue
}
func (d *jsonDecDriver) ReadMapEnd() {
const xc uint8 = '}'
- if d.tok == 0 {
- d.tok = d.r.skip(&jsonCharWhitespaceSet)
- }
+ d.advance()
if d.tok != xc {
- d.d.errorf("read map end - expect char '%c' but got char '%c'", xc, d.tok)
+ d.readDelimError(xc)
}
d.tok = 0
- d.c = containerMapEnd
}
-// func (d *jsonDecDriver) readLit(length, fromIdx uint8) {
-// // length here is always less than 8 (literals are: null, true, false)
-// bs := d.r.readx(int(length))
-// d.tok = 0
-// if jsonValidateSymbols && !bytes.Equal(bs, jsonLiterals[fromIdx:fromIdx+length]) {
-// d.d.errorf("expecting %s: got %s", jsonLiterals[fromIdx:fromIdx+length], bs)
+// func (d *jsonDecDriver) readDelim(xc uint8) {
+// d.advance()
+// if d.tok != xc {
+// d.readDelimError(xc)
// }
+// d.tok = 0
// }
+func (d *jsonDecDriver) readDelimError(xc uint8) {
+ d.d.errorf("read json delimiter - expect char '%c' but got char '%c'", xc, d.tok)
+}
+
func (d *jsonDecDriver) readLit4True() {
- bs := d.r.readx(3)
+ bs := d.d.decRd.readn(3)
d.tok = 0
- if jsonValidateSymbols && !bytes.Equal(bs, jsonLiteral4True) {
+ if jsonValidateSymbols && bs != [rwNLen]byte{'r', 'u', 'e'} { // !Equal jsonLiteral4True
d.d.errorf("expecting %s: got %s", jsonLiteral4True, bs)
}
}
func (d *jsonDecDriver) readLit4False() {
- bs := d.r.readx(4)
+ bs := d.d.decRd.readn(4)
d.tok = 0
- if jsonValidateSymbols && !bytes.Equal(bs, jsonLiteral4False) {
+ if jsonValidateSymbols && bs != [rwNLen]byte{'a', 'l', 's', 'e'} { // !Equal jsonLiteral4False
d.d.errorf("expecting %s: got %s", jsonLiteral4False, bs)
}
}
func (d *jsonDecDriver) readLit4Null() {
- bs := d.r.readx(3)
+ bs := d.d.decRd.readn(3) // readx(3)
d.tok = 0
- if jsonValidateSymbols && !bytes.Equal(bs, jsonLiteral4Null) {
+ if jsonValidateSymbols && bs != [rwNLen]byte{'u', 'l', 'l'} { // !Equal jsonLiteral4Null
d.d.errorf("expecting %s: got %s", jsonLiteral4Null, bs)
}
+ d.fnil = true
}
-func (d *jsonDecDriver) TryDecodeAsNil() bool {
+func (d *jsonDecDriver) advance() {
if d.tok == 0 {
- d.tok = d.r.skip(&jsonCharWhitespaceSet)
+ d.fnil = false
+ d.tok = d.d.decRd.skip(&jsonCharWhitespaceSet)
}
- // we shouldn't try to see if "null" was here, right?
+}
+
+func (d *jsonDecDriver) TryNil() bool {
+ d.advance()
+ // we shouldn't try to see if quoted "null" was here, right?
// only the plain string: `null` denotes a nil (ie not quotes)
if d.tok == 'n' {
d.readLit4Null()
@@ -785,13 +637,19 @@ func (d *jsonDecDriver) TryDecodeAsNil() bool {
return false
}
+func (d *jsonDecDriver) Nil() bool {
+ return d.fnil
+}
+
func (d *jsonDecDriver) DecodeBool() (v bool) {
- if d.tok == 0 {
- d.tok = d.r.skip(&jsonCharWhitespaceSet)
+ d.advance()
+ if d.tok == 'n' {
+ d.readLit4Null()
+ return
}
- fquot := d.c == containerMapKey && d.tok == '"'
+ fquot := d.d.c == containerMapKey && d.tok == '"'
if fquot {
- d.tok = d.r.readn1()
+ d.tok = d.d.decRd.readn1()
}
switch d.tok {
case 'f':
@@ -805,18 +663,20 @@ func (d *jsonDecDriver) DecodeBool() (v bool) {
// v = false // "unreachable"
}
if fquot {
- d.r.readn1()
+ d.d.decRd.readn1()
}
return
}
func (d *jsonDecDriver) DecodeTime() (t time.Time) {
// read string, and pass the string into json.unmarshal
- d.appendStringAsBytes()
- if d.fnull {
+ d.advance()
+ if d.tok == 'n' {
+ d.readLit4Null()
return
}
- t, err := time.Parse(time.RFC3339, stringView(d.bs))
+ bs := d.readString()
+ t, err := time.Parse(time.RFC3339, stringView(bs))
if err != nil {
d.d.errorv(err)
}
@@ -825,41 +685,38 @@ func (d *jsonDecDriver) DecodeTime() (t time.Time) {
func (d *jsonDecDriver) ContainerType() (vt valueType) {
// check container type by checking the first char
- if d.tok == 0 {
- d.tok = d.r.skip(&jsonCharWhitespaceSet)
- }
+ d.advance()
// optimize this, so we don't do 4 checks but do one computation.
// return jsonContainerSet[d.tok]
// ContainerType is mostly called for Map and Array,
// so this conditional is good enough (max 2 checks typically)
- if b := d.tok; b == '{' {
+ if d.tok == '{' {
return valueTypeMap
- } else if b == '[' {
+ } else if d.tok == '[' {
return valueTypeArray
- } else if b == 'n' {
+ } else if d.tok == 'n' {
+ d.readLit4Null()
return valueTypeNil
- } else if b == '"' {
+ } else if d.tok == '"' {
return valueTypeString
}
return valueTypeUnset
}
func (d *jsonDecDriver) decNumBytes() (bs []byte) {
- // stores num bytes in d.bs
- if d.tok == 0 {
- d.tok = d.r.skip(&jsonCharWhitespaceSet)
- }
+ d.advance()
if d.tok == '"' {
- bs = d.r.readUntil(d.b2[:0], '"')
- bs = bs[:len(bs)-1]
+ bs = d.d.decRd.readUntil('"', false)
+ } else if d.tok == 'n' {
+ d.readLit4Null()
} else {
- d.r.unreadn1()
- bs = d.r.readTo(d.bs[:0], &jsonNumSet)
+ d.d.decRd.unreadn1()
+ bs = d.d.decRd.readTo(&jsonNumSet)
}
d.tok = 0
- return bs
+ return
}
func (d *jsonDecDriver) DecodeUint64() (u uint64) {
@@ -874,7 +731,7 @@ func (d *jsonDecDriver) DecodeUint64() (u uint64) {
d.d.errorf("minus found parsing unsigned integer: %s", bs)
} else if badsyntax {
// fallback: try to decode as float, and cast
- n = d.decUint64ViaFloat(stringView(bs))
+ n = d.decUint64ViaFloat(bs)
}
return n
}
@@ -892,9 +749,9 @@ func (d *jsonDecDriver) DecodeInt64() (i int64) {
// d.d.errorf("invalid syntax for integer: %s", bs)
// fallback: try to decode as float, and cast
if neg {
- n = d.decUint64ViaFloat(stringView(bs[1:]))
+ n = d.decUint64ViaFloat(bs[1:])
} else {
- n = d.decUint64ViaFloat(stringView(bs))
+ n = d.decUint64ViaFloat(bs)
}
}
if neg {
@@ -911,14 +768,13 @@ func (d *jsonDecDriver) DecodeInt64() (i int64) {
return
}
-func (d *jsonDecDriver) decUint64ViaFloat(s string) (u uint64) {
+func (d *jsonDecDriver) decUint64ViaFloat(s []byte) (u uint64) {
if len(s) == 0 {
return
}
- f, err := strconv.ParseFloat(s, 64)
+ f, err := parseFloat64(s)
if err != nil {
d.d.errorf("invalid syntax for integer: %s", s)
- // d.d.errorv(err)
}
fi, ff := math.Modf(f)
if ff > 0 {
@@ -930,28 +786,62 @@ func (d *jsonDecDriver) decUint64ViaFloat(s string) (u uint64) {
}
func (d *jsonDecDriver) DecodeFloat64() (f float64) {
- bs := d.decNumBytes()
- if len(bs) == 0 {
- return
+ var err error
+ if bs := d.decNumBytes(); len(bs) > 0 {
+ if f, err = parseFloat64(bs); err != nil {
+ d.d.errorv(err)
+ }
}
- f, err := strconv.ParseFloat(stringView(bs), 64)
- if err != nil {
- d.d.errorv(err)
+ return
+}
+
+func (d *jsonDecDriver) DecodeFloat32() (f float32) {
+ var err error
+ if bs := d.decNumBytes(); len(bs) > 0 {
+ if f, err = parseFloat32(bs); err != nil {
+ d.d.errorv(err)
+ }
}
return
}
-func (d *jsonDecDriver) DecodeExt(rv interface{}, xtag uint64, ext Ext) (realxtag uint64) {
+func (d *jsonDecDriver) DecodeExt(rv interface{}, xtag uint64, ext Ext) {
+ d.advance()
+ if d.tok == 'n' {
+ d.readLit4Null()
+ return
+ }
if ext == nil {
re := rv.(*RawExt)
re.Tag = xtag
d.d.decode(&re.Value)
+ } else if ext == SelfExt {
+ rv2 := baseRV(rv)
+ d.d.decodeValue(rv2, d.h.fnNoExt(rv2.Type()))
} else {
- var v interface{}
- d.d.decode(&v)
- ext.UpdateExt(rv, v)
+ d.d.interfaceExtConvertAndDecode(rv, ext)
}
- return
+}
+
+func (d *jsonDecDriver) decBytesFromArray(bs []byte) []byte {
+ if bs == nil {
+ bs = []byte{}
+ } else {
+ bs = bs[:0]
+ }
+ d.tok = 0
+ bs = append(bs, uint8(d.DecodeUint64()))
+ d.tok = d.d.decRd.skip(&jsonCharWhitespaceSet)
+ for d.tok != ']' {
+ if d.tok != ',' {
+ d.d.errorf("read array element - expect char '%c' but got char '%c'", ',', d.tok)
+ }
+ d.tok = 0
+ bs = append(bs, uint8(chkOvf.UintV(d.DecodeUint64(), 8)))
+ d.tok = d.d.decRd.skip(&jsonCharWhitespaceSet)
+ }
+ d.tok = 0
+ return bs
}
func (d *jsonDecDriver) DecodeBytes(bs []byte, zerocopy bool) (bsOut []byte) {
@@ -961,37 +851,41 @@ func (d *jsonDecDriver) DecodeBytes(bs []byte, zerocopy bool) (bsOut []byte) {
d.DecodeExt(&bsOut, 0, &d.se)
return
}
- if d.tok == 0 {
- d.tok = d.r.skip(&jsonCharWhitespaceSet)
- }
+ d.advance()
// check if an "array" of uint8's (see ContainerType for how to infer if an array)
if d.tok == '[' {
- bsOut, _ = fastpathTV.DecSliceUint8V(bs, true, d.d)
- return
+ // bsOut, _ = fastpathTV.DecSliceUint8V(bs, true, d.d)
+ if zerocopy && len(bs) == 0 {
+ bs = d.d.b[:]
+ }
+ return d.decBytesFromArray(bs)
}
- d.appendStringAsBytes()
+
// base64 encodes []byte{} as "", and we encode nil []byte as null.
// Consequently, base64 should decode null as a nil []byte, and "" as an empty []byte{}.
- // appendStringAsBytes returns a zero-len slice for both, so as not to reset d.bs.
- // However, it sets a fnull field to true, so we can check if a null was found.
- if len(d.bs) == 0 {
- if d.fnull {
- return nil
- }
- return []byte{}
+ // appendStringAsBytes returns a zero-len slice for both, so as not to reset d.buf.
+ // However, it sets a fnil field to true, so we can check if a null was found.
+
+ if d.tok == 'n' {
+ d.readLit4Null()
+ return nil
}
- bs0 := d.bs
- slen := base64.StdEncoding.DecodedLen(len(bs0))
- if slen <= cap(bs) {
+
+ bs1 := d.readString()
+ slen := base64.StdEncoding.DecodedLen(len(bs1))
+ if slen == 0 {
+ bsOut = []byte{}
+ } else if slen <= cap(bs) {
bsOut = bs[:slen]
- } else if zerocopy && slen <= cap(d.b2) {
- bsOut = d.b2[:slen]
+ } else if zerocopy {
+ d.buf = d.d.blist.check(d.buf, slen)
+ bsOut = d.buf
} else {
bsOut = make([]byte, slen)
}
- slen2, err := base64.StdEncoding.Decode(bsOut, bs0)
+ slen2, err := base64.StdEncoding.Decode(bsOut, bs1)
if err != nil {
- d.d.errorf("error decoding base64 binary '%s': %v", bs0, err)
+ d.d.errorf("error decoding base64 binary '%s': %v", bs1, err)
return nil
}
if slen != slen2 {
@@ -1000,157 +894,179 @@ func (d *jsonDecDriver) DecodeBytes(bs []byte, zerocopy bool) (bsOut []byte) {
return
}
-func (d *jsonDecDriver) DecodeString() (s string) {
- d.appendStringAsBytes()
- return d.bsToString()
-}
-
func (d *jsonDecDriver) DecodeStringAsBytes() (s []byte) {
- d.appendStringAsBytes()
- return d.bs
-}
-
-func (d *jsonDecDriver) appendStringAsBytes() {
- if d.tok == 0 {
- d.tok = d.r.skip(&jsonCharWhitespaceSet)
- }
-
- d.fnull = false
+ d.advance()
if d.tok != '"' {
// d.d.errorf("expect char '%c' but got char '%c'", '"', d.tok)
// handle non-string scalar: null, true, false or a number
switch d.tok {
case 'n':
d.readLit4Null()
- d.bs = d.bs[:0]
- d.fnull = true
+ return []byte{}
case 'f':
d.readLit4False()
- d.bs = d.bs[:5]
- copy(d.bs, "false")
+ return jsonLiteralFalse
case 't':
d.readLit4True()
- d.bs = d.bs[:4]
- copy(d.bs, "true")
- default:
- // try to parse a valid number
- bs := d.decNumBytes()
- if len(bs) <= cap(d.bs) {
- d.bs = d.bs[:len(bs)]
- } else {
- d.bs = make([]byte, len(bs))
- }
- copy(d.bs, bs)
+ return jsonLiteralTrue
}
+ // try to parse a valid number
+ return d.decNumBytes()
+ }
+ s = d.appendStringAsBytes()
+ if d.fnil {
+ return nil
+ }
+ return
+}
+
+func (d *jsonDecDriver) readString() (bs []byte) {
+ if d.tok != '"' {
+ d.d.errorf("expecting string starting with '\"'; got '%c'", d.tok)
return
}
+ bs = d.d.decRd.readUntil('"', false)
d.tok = 0
- r := d.r
- var cs = r.readUntil(d.b2[:0], '"')
- var cslen = uint(len(cs))
- var c uint8
- v := d.bs[:0]
+ return
+}
+
+func (d *jsonDecDriver) appendStringAsBytes() (bs []byte) {
+ if d.buf != nil {
+ d.buf = d.buf[:0]
+ }
+ d.tok = 0
+
// append on each byte seen can be expensive, so we just
// keep track of where we last read a contiguous set of
// non-special bytes (using cursor variable),
// and when we see a special byte
// e.g. end-of-slice, " or \,
// we will append the full range into the v slice before proceeding
+
+ var cs = d.d.decRd.readUntil('"', true)
+ var c uint8
var i, cursor uint
for {
- if i == cslen {
- v = append(v, cs[cursor:]...)
- cs = r.readUntil(d.b2[:0], '"')
- cslen = uint(len(cs))
+ if i >= uint(len(cs)) {
+ d.buf = append(d.buf, cs[cursor:]...)
+ cs = d.d.decRd.readUntil('"', true)
i, cursor = 0, 0
+ continue // this continue helps elide the cs[i] below
}
c = cs[i]
if c == '"' {
- v = append(v, cs[cursor:i]...)
break
}
if c != '\\' {
i++
continue
}
- v = append(v, cs[cursor:i]...)
+
+ d.buf = append(d.buf, cs[cursor:i]...)
i++
+ if i >= uint(len(cs)) {
+ d.d.errorf("need at least 1 more bytes for \\ escape sequence")
+ return // bounds-check elimination
+ }
c = cs[i]
switch c {
case '"', '\\', '/', '\'':
- v = append(v, c)
+ d.buf = append(d.buf, c)
case 'b':
- v = append(v, '\b')
+ d.buf = append(d.buf, '\b')
case 'f':
- v = append(v, '\f')
+ d.buf = append(d.buf, '\f')
case 'n':
- v = append(v, '\n')
+ d.buf = append(d.buf, '\n')
case 'r':
- v = append(v, '\r')
+ d.buf = append(d.buf, '\r')
case 't':
- v = append(v, '\t')
+ d.buf = append(d.buf, '\t')
case 'u':
- var r rune
- var rr uint32
- if cslen < i+4 {
- d.d.errorf("need at least 4 more bytes for unicode sequence")
- }
- var j uint
- for _, c = range cs[i+1 : i+5] { // bounds-check-elimination
- // best to use explicit if-else
- // - not a table, etc which involve memory loads, array lookup with bounds checks, etc
- if c >= '0' && c <= '9' {
- rr = rr*16 + uint32(c-jsonU4Chk2)
- } else if c >= 'a' && c <= 'f' {
- rr = rr*16 + uint32(c-jsonU4Chk1)
- } else if c >= 'A' && c <= 'F' {
- rr = rr*16 + uint32(c-jsonU4Chk0)
- } else {
- r = unicode.ReplacementChar
- i += 4
- goto encode_rune
- }
+ i = d.appendStringAsBytesSlashU(cs, i)
+ default:
+ d.d.errorf("unsupported escaped value: %c", c)
+ }
+ i++
+ cursor = i
+ }
+ if len(cs) > 0 {
+ if len(d.buf) > 0 && cursor < uint(len(cs)) {
+ d.buf = append(d.buf, cs[cursor:i]...)
+ } else {
+ // if bytes, just return the cs got from readUntil.
+ // do not do it for io, especially bufio, as the buffer is needed for other things
+ cs = cs[:i]
+ if d.d.bytes {
+ return cs
}
- r = rune(rr)
+ d.buf = d.d.blist.check(d.buf, len(cs))
+ copy(d.buf, cs)
+ }
+ }
+ return d.buf
+}
+
+func (d *jsonDecDriver) appendStringAsBytesSlashU(cs []byte, i uint) uint {
+ var r rune
+ var rr uint32
+ var j uint
+ var c byte
+ if uint(len(cs)) < i+4 {
+ d.d.errorf("need at least 4 more bytes for unicode sequence")
+ return 0 // bounds-check elimination
+ }
+ for _, c = range cs[i+1 : i+5] { // bounds-check-elimination
+ // best to use explicit if-else
+ // - not a table, etc which involve memory loads, array lookup with bounds checks, etc
+ if c >= '0' && c <= '9' {
+ rr = rr*16 + uint32(c-jsonU4Chk2)
+ } else if c >= 'a' && c <= 'f' {
+ rr = rr*16 + uint32(c-jsonU4Chk1)
+ } else if c >= 'A' && c <= 'F' {
+ rr = rr*16 + uint32(c-jsonU4Chk0)
+ } else {
+ r = unicode.ReplacementChar
i += 4
- if utf16.IsSurrogate(r) {
- if len(cs) >= int(i+6) {
- var cx = cs[i+1:][:6:6] // [:6] affords bounds-check-elimination
- if cx[0] == '\\' && cx[1] == 'u' {
- i += 2
- var rr1 uint32
- for j = 2; j < 6; j++ {
- c = cx[j]
- if c >= '0' && c <= '9' {
- rr = rr*16 + uint32(c-jsonU4Chk2)
- } else if c >= 'a' && c <= 'f' {
- rr = rr*16 + uint32(c-jsonU4Chk1)
- } else if c >= 'A' && c <= 'F' {
- rr = rr*16 + uint32(c-jsonU4Chk0)
- } else {
- r = unicode.ReplacementChar
- i += 4
- goto encode_rune
- }
- }
- r = utf16.DecodeRune(r, rune(rr1))
+ goto encode_rune
+ }
+ }
+ r = rune(rr)
+ i += 4
+ if utf16.IsSurrogate(r) {
+ if len(cs) >= int(i+6) {
+ var cx = cs[i+1:][:6:6] // [:6] affords bounds-check-elimination
+ //var cx [6]byte
+ //copy(cx[:], cs[i+1:])
+ if cx[0] == '\\' && cx[1] == 'u' {
+ i += 2
+ var rr1 uint32
+ for j = 2; j < 6; j++ {
+ c = cx[j]
+ if c >= '0' && c <= '9' {
+ rr = rr*16 + uint32(c-jsonU4Chk2)
+ } else if c >= 'a' && c <= 'f' {
+ rr = rr*16 + uint32(c-jsonU4Chk1)
+ } else if c >= 'A' && c <= 'F' {
+ rr = rr*16 + uint32(c-jsonU4Chk0)
+ } else {
+ r = unicode.ReplacementChar
i += 4
goto encode_rune
}
}
- r = unicode.ReplacementChar
+ r = utf16.DecodeRune(r, rune(rr1))
+ i += 4
+ goto encode_rune
}
- encode_rune:
- w2 := utf8.EncodeRune(d.bstr[:], r)
- v = append(v, d.bstr[:w2]...)
- default:
- d.d.errorf("unsupported escaped value: %c", c)
}
- i++
- cursor = i
+ r = unicode.ReplacementChar
}
- d.bs = v
+encode_rune:
+ w2 := utf8.EncodeRune(d.bstr[:], r)
+ d.buf = append(d.buf, d.bstr[:w2]...)
+ return i
}
func (d *jsonDecDriver) nakedNum(z *decNaked, bs []byte) (err error) {
@@ -1198,25 +1114,22 @@ func (d *jsonDecDriver) nakedNum(z *decNaked, bs []byte) (err error) {
return
F:
z.v = valueTypeFloat
- z.f, err = strconv.ParseFloat(stringView(bs), 64)
+ z.f, err = parseFloat64(bs)
return
}
-func (d *jsonDecDriver) bsToString() string {
- // if x := d.s.sc; x != nil && x.so && x.st == '}' { // map key
- if jsonAlwaysReturnInternString || d.c == containerMapKey {
- return d.d.string(d.bs)
+func (d *jsonDecDriver) sliceToString(bs []byte) string {
+ if d.d.is != nil && (jsonAlwaysReturnInternString || d.d.c == containerMapKey) {
+ return d.d.string(bs)
}
- return string(d.bs)
+ return string(bs)
}
func (d *jsonDecDriver) DecodeNaked() {
z := d.d.naked()
- // var decodeFurther bool
- if d.tok == 0 {
- d.tok = d.r.skip(&jsonCharWhitespaceSet)
- }
+ d.advance()
+ var bs []byte
switch d.tok {
case 'n':
d.readLit4Null()
@@ -1235,30 +1148,29 @@ func (d *jsonDecDriver) DecodeNaked() {
z.v = valueTypeArray // don't consume. kInterfaceNaked will call ReadArrayStart
case '"':
// if a string, and MapKeyAsString, then try to decode it as a nil, bool or number first
- d.appendStringAsBytes()
- if len(d.bs) > 0 && d.c == containerMapKey && d.h.MapKeyAsString {
- switch stringView(d.bs) {
- case "null":
+ bs = d.appendStringAsBytes()
+ if len(bs) > 0 && d.d.c == containerMapKey && d.h.MapKeyAsString {
+ if bytes.Equal(bs, jsonLiteralNull) {
z.v = valueTypeNil
- case "true":
+ } else if bytes.Equal(bs, jsonLiteralTrue) {
z.v = valueTypeBool
z.b = true
- case "false":
+ } else if bytes.Equal(bs, jsonLiteralFalse) {
z.v = valueTypeBool
z.b = false
- default:
+ } else {
// check if a number: float, int or uint
- if err := d.nakedNum(z, d.bs); err != nil {
+ if err := d.nakedNum(z, bs); err != nil {
z.v = valueTypeString
- z.s = d.bsToString()
+ z.s = d.sliceToString(bs)
}
}
} else {
z.v = valueTypeString
- z.s = d.bsToString()
+ z.s = d.sliceToString(bs)
}
default: // number
- bs := d.decNumBytes()
+ bs = d.decNumBytes()
if len(bs) == 0 {
d.d.errorf("decode number from empty string")
return
@@ -1268,9 +1180,6 @@ func (d *jsonDecDriver) DecodeNaked() {
return
}
}
- // if decodeFurther {
- // d.s.sc.retryRead()
- // }
}
//----------------------
@@ -1342,121 +1251,117 @@ type JsonHandle struct {
// The only caveat is that nil value is ALWAYS written as null (never as "null")
MapKeyAsString bool
- // _ [2]byte // padding
+ // _ uint64 // padding (cache line)
- // Note: below, we store hardly-used items e.g. RawBytesExt is cached in the (en|de)cDriver.
+ // Note: below, we store hardly-used items
+ // e.g. RawBytesExt (which is already cached in the (en|de)cDriver).
// RawBytesExt, if configured, is used to encode and decode raw bytes in a custom way.
// If not configured, raw bytes are encoded to/from base64 text.
RawBytesExt InterfaceExt
- _ [2]uint64 // padding
+ _ [5]uint64 // padding (cache line)
}
// Name returns the name of the handle: json
-func (h *JsonHandle) Name() string { return "json" }
-func (h *JsonHandle) hasElemSeparators() bool { return true }
+func (h *JsonHandle) Name() string { return "json" }
+
+// func (h *JsonHandle) hasElemSeparators() bool { return true }
func (h *JsonHandle) typical() bool {
return h.Indent == 0 && !h.MapKeyAsString && h.IntegerAsString != 'A' && h.IntegerAsString != 'L'
}
-type jsonTypical interface {
- typical()
-}
-
-func (h *JsonHandle) recreateEncDriver(ed encDriver) (v bool) {
- _, v = ed.(jsonTypical)
- return v != h.typical()
-}
-
-// SetInterfaceExt sets an extension
-func (h *JsonHandle) SetInterfaceExt(rt reflect.Type, tag uint64, ext InterfaceExt) (err error) {
- return h.SetExt(rt, tag, &extWrapper{bytesExtFailer{}, ext})
+func (h *JsonHandle) newEncDriver() encDriver {
+ var e = &jsonEncDriver{h: h}
+ e.e.e = e
+ e.e.js = true
+ e.e.init(h)
+ e.reset()
+ return e
}
-type jsonEncDriverTypicalImpl struct {
- jsonEncDriver
- jsonEncDriverTypical
- _ [1]uint64 // padding
+func (h *JsonHandle) newDecDriver() decDriver {
+ var d = &jsonDecDriver{h: h}
+ d.d.d = d
+ d.d.js = true
+ d.d.jsms = h.MapKeyAsString
+ d.d.init(h)
+ d.reset()
+ return d
}
-func (x *jsonEncDriverTypicalImpl) reset() {
- x.jsonEncDriver.reset()
- x.jsonEncDriverTypical.reset(&x.jsonEncDriver)
-}
-
-type jsonEncDriverGenericImpl struct {
- jsonEncDriver
- jsonEncDriverGeneric
- // _ [2]uint64 // padding
-}
-
-func (x *jsonEncDriverGenericImpl) reset() {
- x.jsonEncDriver.reset()
- x.jsonEncDriverGeneric.reset(&x.jsonEncDriver)
-}
-
-func (h *JsonHandle) newEncDriver(e *Encoder) (ee encDriver) {
- var hd *jsonEncDriver
- if h.typical() {
- var v jsonEncDriverTypicalImpl
- ee = &v
- hd = &v.jsonEncDriver
+func (e *jsonEncDriver) reset() {
+ // (htmlasis && jsonCharSafeSet.isset(b)) || jsonCharHtmlSafeSet.isset(b)
+ e.typical = e.h.typical()
+ if e.h.HTMLCharsAsIs {
+ e.s = &jsonCharSafeSet
} else {
- var v jsonEncDriverGenericImpl
- ee = &v
- hd = &v.jsonEncDriver
+ e.s = &jsonCharHtmlSafeSet
}
- hd.e, hd.h, hd.bs = e, h, hd.b[:0]
- hd.se.BytesExt = bytesExtFailer{}
- ee.reset()
- return
-}
-
-func (h *JsonHandle) newDecDriver(d *Decoder) decDriver {
- // d := jsonDecDriver{r: r.(*bytesDecReader), h: h}
- hd := jsonDecDriver{d: d, h: h}
- hd.se.BytesExt = bytesExtFailer{}
- hd.bs = hd.b[:0]
- hd.reset()
- return &hd
-}
-
-func (e *jsonEncDriver) reset() {
- e.ew = e.e.w
e.se.InterfaceExt = e.h.RawBytesExt
- if e.bs != nil {
- e.bs = e.bs[:0]
+ e.d, e.dl, e.di = false, 0, 0
+ if e.h.Indent != 0 {
+ e.d = true
+ e.di = int8(e.h.Indent)
}
+ e.ks = e.h.MapKeyAsString
+ e.is = e.h.IntegerAsString
}
func (d *jsonDecDriver) reset() {
- d.r = d.d.r
d.se.InterfaceExt = d.h.RawBytesExt
- if d.bs != nil {
- d.bs = d.bs[:0]
- }
- d.c, d.tok = 0, 0
- // d.n.reset()
+ d.buf = d.d.blist.check(d.buf, 256)[:0]
+ d.tok = 0
+ d.fnil = false
}
-func jsonFloatStrconvFmtPrec(f float64) (fmt byte, prec int) {
+func (d *jsonDecDriver) atEndOfDecode() {}
+
+// jsonFloatStrconvFmtPrec ...
+//
+// ensure that every float has an 'e' or '.' in it,/ for easy differentiation from integers.
+// this is better/faster than checking if encoded value has [e.] and appending if needed.
+
+// func jsonFloatStrconvFmtPrec(f float64, bits32 bool) (fmt byte, prec int) {
+// fmt = 'f'
+// prec = -1
+// var abs = math.Abs(f)
+// if abs == 0 || abs == 1 {
+// prec = 1
+// } else if !bits32 && (abs < 1e-6 || abs >= 1e21) ||
+// bits32 && (float32(abs) < 1e-6 || float32(abs) >= 1e21) {
+// fmt = 'e'
+// } else if _, frac := math.Modf(abs); frac == 0 {
+// // ensure that floats have a .0 at the end, for easy identification as floats
+// prec = 1
+// }
+// return
+// }
+
+func jsonFloatStrconvFmtPrec64(f float64) (fmt byte, prec int8) {
+ fmt = 'f'
prec = -1
var abs = math.Abs(f)
- if abs != 0 && (abs < 1e-6 || abs >= 1e21) {
+ if abs == 0 || abs == 1 {
+ prec = 1
+ } else if abs < 1e-6 || abs >= 1e21 {
fmt = 'e'
- } else {
- fmt = 'f'
- // set prec to 1 iff mod is 0.
- // better than using jsonIsFloatBytesB2 to check if a . or E in the float bytes.
- // this ensures that every float has an e or .0 in it.
- if abs <= 1 {
- if abs == 0 || abs == 1 {
- prec = 1
- }
- } else if _, mod := math.Modf(abs); mod == 0 {
- prec = 1
- }
+ } else if noFrac64(abs) { // _, frac := math.Modf(abs); frac == 0 {
+ prec = 1
+ }
+ return
+}
+
+func jsonFloatStrconvFmtPrec32(f float32) (fmt byte, prec int8) {
+ fmt = 'f'
+ prec = -1
+ var abs = abs32(f)
+ if abs == 0 || abs == 1 {
+ prec = 1
+ } else if abs < 1e-6 || abs >= 1e21 {
+ fmt = 'e'
+ } else if noFrac32(abs) { // _, frac := math.Modf(abs); frac == 0 {
+ prec = 1
}
return
}
@@ -1502,7 +1407,87 @@ func jsonParseInteger(s []byte) (n uint64, neg, badSyntax, overflow bool) {
return
}
+var _ decDriverContainerTracker = (*jsonDecDriver)(nil)
+var _ encDriverContainerTracker = (*jsonEncDriver)(nil)
var _ decDriver = (*jsonDecDriver)(nil)
-var _ encDriver = (*jsonEncDriverGenericImpl)(nil)
-var _ encDriver = (*jsonEncDriverTypicalImpl)(nil)
-var _ jsonTypical = (*jsonEncDriverTypical)(nil)
+
+var _ encDriver = (*jsonEncDriver)(nil)
+
+// ----------------
+
+/*
+type jsonEncDriverTypical jsonEncDriver
+
+func (e *jsonEncDriverTypical) WriteArrayStart(length int) {
+ e.e.encWr.writen1('[')
+}
+
+func (e *jsonEncDriverTypical) WriteArrayElem() {
+ if e.e.c != containerArrayStart {
+ e.e.encWr.writen1(',')
+ }
+}
+
+func (e *jsonEncDriverTypical) WriteArrayEnd() {
+ e.e.encWr.writen1(']')
+}
+
+func (e *jsonEncDriverTypical) WriteMapStart(length int) {
+ e.e.encWr.writen1('{')
+}
+
+func (e *jsonEncDriverTypical) WriteMapElemKey() {
+ if e.e.c != containerMapStart {
+ e.e.encWr.writen1(',')
+ }
+}
+
+func (e *jsonEncDriverTypical) WriteMapElemValue() {
+ e.e.encWr.writen1(':')
+}
+
+func (e *jsonEncDriverTypical) WriteMapEnd() {
+ e.e.encWr.writen1('}')
+}
+
+func (e *jsonEncDriverTypical) EncodeBool(b bool) {
+ if b {
+ // e.e.encWr.writeb(jsonLiteralTrue)
+ e.e.encWr.writen([rwNLen]byte{'t', 'r', 'u', 'e'}, 4)
+ } else {
+ // e.e.encWr.writeb(jsonLiteralFalse)
+ e.e.encWr.writen([rwNLen]byte{'f', 'a', 'l', 's', 'e'}, 5)
+ }
+}
+
+func (e *jsonEncDriverTypical) EncodeInt(v int64) {
+ e.e.encWr.writeb(strconv.AppendInt(e.b[:0], v, 10))
+}
+
+func (e *jsonEncDriverTypical) EncodeUint(v uint64) {
+ e.e.encWr.writeb(strconv.AppendUint(e.b[:0], v, 10))
+}
+
+func (e *jsonEncDriverTypical) EncodeFloat64(f float64) {
+ fmt, prec := jsonFloatStrconvFmtPrec64(f)
+ e.e.encWr.writeb(strconv.AppendFloat(e.b[:0], f, fmt, int(prec), 64))
+ // e.e.encWr.writeb(strconv.AppendFloat(e.b[:0], f, jsonFloatStrconvFmtPrec64(f), 64))
+}
+
+func (e *jsonEncDriverTypical) EncodeFloat32(f float32) {
+ fmt, prec := jsonFloatStrconvFmtPrec32(f)
+ e.e.encWr.writeb(strconv.AppendFloat(e.b[:0], float64(f), fmt, int(prec), 32))
+}
+
+// func (e *jsonEncDriverTypical) encodeFloat(f float64, bitsize uint8) {
+// fmt, prec := jsonFloatStrconvFmtPrec(f, bitsize == 32)
+// e.e.encWr.writeb(strconv.AppendFloat(e.b[:0], f, fmt, prec, int(bitsize)))
+// }
+
+// func (e *jsonEncDriverTypical) atEndOfEncode() {
+// if e.tw {
+// e.e.encWr.writen1(' ')
+// }
+// }
+
+*/
diff --git a/vendor/github.com/ugorji/go/codec/mammoth-test.go.tmpl b/vendor/github.com/ugorji/go/codec/mammoth-test.go.tmpl
index c598cc7..ba55b39 100644
--- a/vendor/github.com/ugorji/go/codec/mammoth-test.go.tmpl
+++ b/vendor/github.com/ugorji/go/codec/mammoth-test.go.tmpl
@@ -7,7 +7,6 @@ package codec
import "testing"
import "fmt"
-import "reflect"
// TestMammoth has all the different paths optimized in fast-path
// It has all the primitives, slices and maps.
@@ -18,37 +17,37 @@ func init() { _ = fmt.Printf } // so we can include fmt as needed
type TestMammoth struct {
-{{range .Values }}{{if .Primitive }}{{/*
-*/}}{{ .MethodNamePfx "F" true }} {{ .Primitive }}
+{{range .Values }}{{if .Primitive -}}
+{{ .MethodNamePfx "F" true }} {{ .Primitive }}
{{ .MethodNamePfx "Fptr" true }} *{{ .Primitive }}
{{end}}{{end}}
-{{range .Values }}{{if not .Primitive }}{{if not .MapKey }}{{/*
-*/}}{{ .MethodNamePfx "F" false }} []{{ .Elem }}
+{{range .Values }}{{if not .Primitive }}{{if not .MapKey -}}
+{{ .MethodNamePfx "F" false }} []{{ .Elem }}
{{ .MethodNamePfx "Fptr" false }} *[]{{ .Elem }}
{{end}}{{end}}{{end}}
-{{range .Values }}{{if not .Primitive }}{{if .MapKey }}{{/*
-*/}}{{ .MethodNamePfx "F" false }} map[{{ .MapKey }}]{{ .Elem }}
+{{range .Values }}{{if not .Primitive }}{{if .MapKey -}}
+{{ .MethodNamePfx "F" false }} map[{{ .MapKey }}]{{ .Elem }}
{{ .MethodNamePfx "Fptr" false }} *map[{{ .MapKey }}]{{ .Elem }}
{{end}}{{end}}{{end}}
}
-{{range .Values }}{{if not .Primitive }}{{if not .MapKey }}{{/*
-*/}} type {{ .MethodNamePfx "typMbs" false }} []{{ .Elem }}
+{{range .Values }}{{if not .Primitive }}{{if not .MapKey -}}
+type {{ .MethodNamePfx "typMbs" false }} []{{ .Elem }}
func (_ {{ .MethodNamePfx "typMbs" false }}) MapBySlice() { }
{{end}}{{end}}{{end}}
-{{range .Values }}{{if not .Primitive }}{{if .MapKey }}{{/*
-*/}} type {{ .MethodNamePfx "typMap" false }} map[{{ .MapKey }}]{{ .Elem }}
+{{range .Values }}{{if not .Primitive }}{{if .MapKey -}}
+type {{ .MethodNamePfx "typMap" false }} map[{{ .MapKey }}]{{ .Elem }}
{{end}}{{end}}{{end}}
func doTestMammothSlices(t *testing.T, h Handle) {
-{{range $i, $e := .Values }}{{if not .Primitive }}{{if not .MapKey }}{{/*
-*/}}
+{{range $i, $e := .Values }}{{if not .Primitive }}{{if not .MapKey -}}
var v{{$i}}va [8]{{ .Elem }}
- for _, v := range [][]{{ .Elem }}{ nil, {}, { {{ nonzerocmd .Elem }}, {{ zerocmd .Elem }}, {{ zerocmd .Elem }}, {{ nonzerocmd .Elem }} } } { {{/*
+ for _, v := range [][]{{ .Elem }}{ nil, {}, { {{ nonzerocmd .Elem }}, {{ zerocmd .Elem }}, {{ zerocmd .Elem }}, {{ nonzerocmd .Elem }} } } {
+ {{/*
// fmt.Printf(">>>> running mammoth slice v{{$i}}: %v\n", v)
// - encode value to some []byte
// - decode into a length-wise-equal []byte
@@ -61,16 +60,19 @@ func doTestMammothSlices(t *testing.T, h Handle) {
// -
// - rinse and repeat for a MapBySlice version
// -
- */}}
+ */ -}}
var v{{$i}}v1, v{{$i}}v2 []{{ .Elem }}
+ var bs{{$i}} []byte
v{{$i}}v1 = v
- bs{{$i}} := testMarshalErr(v{{$i}}v1, h, t, "enc-slice-v{{$i}}")
+ bs{{$i}} = testMarshalErr(v{{$i}}v1, h, t, "enc-slice-v{{$i}}")
+ if v != nil {
if v == nil { v{{$i}}v2 = nil } else { v{{$i}}v2 = make([]{{ .Elem }}, len(v)) }
testUnmarshalErr(v{{$i}}v2, bs{{$i}}, h, t, "dec-slice-v{{$i}}")
testDeepEqualErr(v{{$i}}v1, v{{$i}}v2, t, "equal-slice-v{{$i}}")
if v == nil { v{{$i}}v2 = nil } else { v{{$i}}v2 = make([]{{ .Elem }}, len(v)) }
- testUnmarshalErr(reflect.ValueOf(v{{$i}}v2), bs{{$i}}, h, t, "dec-slice-v{{$i}}-noaddr") // non-addressable value
+ testUnmarshalErr(rv4i(v{{$i}}v2), bs{{$i}}, h, t, "dec-slice-v{{$i}}-noaddr") // non-addressable value
testDeepEqualErr(v{{$i}}v1, v{{$i}}v2, t, "equal-slice-v{{$i}}-noaddr")
+ }
// ...
bs{{$i}} = testMarshalErr(&v{{$i}}v1, h, t, "enc-slice-v{{$i}}-p")
v{{$i}}v2 = nil
@@ -102,9 +104,11 @@ func doTestMammothSlices(t *testing.T, h Handle) {
if v != nil { v{{$i}}v2 = make([]{{ .Elem }}, len(v)) }
v{{$i}}v3 = {{ .MethodNamePfx "typMbs" false }}(v{{$i}}v1)
v{{$i}}v4 = {{ .MethodNamePfx "typMbs" false }}(v{{$i}}v2)
+ if v != nil {
bs{{$i}} = testMarshalErr(v{{$i}}v3, h, t, "enc-slice-v{{$i}}-custom")
testUnmarshalErr(v{{$i}}v4, bs{{$i}}, h, t, "dec-slice-v{{$i}}-custom")
testDeepEqualErr(v{{$i}}v3, v{{$i}}v4, t, "equal-slice-v{{$i}}-custom")
+ }
bs{{$i}} = testMarshalErr(&v{{$i}}v3, h, t, "enc-slice-v{{$i}}-custom-p")
v{{$i}}v2 = nil
v{{$i}}v4 = {{ .MethodNamePfx "typMbs" false }}(v{{$i}}v2)
@@ -115,19 +119,21 @@ func doTestMammothSlices(t *testing.T, h Handle) {
}
func doTestMammothMaps(t *testing.T, h Handle) {
-{{range $i, $e := .Values }}{{if not .Primitive }}{{if .MapKey }}{{/*
-*/}}
+{{range $i, $e := .Values }}{{if not .Primitive }}{{if .MapKey -}}
for _, v := range []map[{{ .MapKey }}]{{ .Elem }}{ nil, {}, { {{ nonzerocmd .MapKey }}:{{ zerocmd .Elem }} {{if ne "bool" .MapKey}}, {{ nonzerocmd .MapKey }}:{{ nonzerocmd .Elem }} {{end}} } } {
// fmt.Printf(">>>> running mammoth map v{{$i}}: %v\n", v)
var v{{$i}}v1, v{{$i}}v2 map[{{ .MapKey }}]{{ .Elem }}
+ var bs{{$i}} []byte
v{{$i}}v1 = v
- bs{{$i}} := testMarshalErr(v{{$i}}v1, h, t, "enc-map-v{{$i}}")
+ bs{{$i}} = testMarshalErr(v{{$i}}v1, h, t, "enc-map-v{{$i}}")
+ if v != nil {
if v == nil { v{{$i}}v2 = nil } else { v{{$i}}v2 = make(map[{{ .MapKey }}]{{ .Elem }}, len(v)) } // reset map
testUnmarshalErr(v{{$i}}v2, bs{{$i}}, h, t, "dec-map-v{{$i}}")
testDeepEqualErr(v{{$i}}v1, v{{$i}}v2, t, "equal-map-v{{$i}}")
if v == nil { v{{$i}}v2 = nil } else { v{{$i}}v2 = make(map[{{ .MapKey }}]{{ .Elem }}, len(v)) } // reset map
- testUnmarshalErr(reflect.ValueOf(v{{$i}}v2), bs{{$i}}, h, t, "dec-map-v{{$i}}-noaddr") // decode into non-addressable map value
+ testUnmarshalErr(rv4i(v{{$i}}v2), bs{{$i}}, h, t, "dec-map-v{{$i}}-noaddr") // decode into non-addressable map value
testDeepEqualErr(v{{$i}}v1, v{{$i}}v2, t, "equal-map-v{{$i}}-noaddr")
+ }
if v == nil { v{{$i}}v2 = nil } else { v{{$i}}v2 = make(map[{{ .MapKey }}]{{ .Elem }}, len(v)) } // reset map
testUnmarshalErr(&v{{$i}}v2, bs{{$i}}, h, t, "dec-map-v{{$i}}-p-len")
testDeepEqualErr(v{{$i}}v1, v{{$i}}v2, t, "equal-map-v{{$i}}-p-len")
@@ -140,10 +146,12 @@ func doTestMammothMaps(t *testing.T, h Handle) {
var v{{$i}}v3, v{{$i}}v4 {{ .MethodNamePfx "typMap" false }}
v{{$i}}v3 = {{ .MethodNamePfx "typMap" false }}(v{{$i}}v1)
v{{$i}}v4 = {{ .MethodNamePfx "typMap" false }}(v{{$i}}v2)
+ if v != nil {
bs{{$i}} = testMarshalErr(v{{$i}}v3, h, t, "enc-map-v{{$i}}-custom")
testUnmarshalErr(v{{$i}}v4, bs{{$i}}, h, t, "dec-map-v{{$i}}-p-len")
testDeepEqualErr(v{{$i}}v3, v{{$i}}v4, t, "equal-map-v{{$i}}-p-len")
}
+ }
{{end}}{{end}}{{end}}
}
diff --git a/vendor/github.com/ugorji/go/codec/msgpack.go b/vendor/github.com/ugorji/go/codec/msgpack.go
index bc3f259..4543337 100644
--- a/vendor/github.com/ugorji/go/codec/msgpack.go
+++ b/vendor/github.com/ugorji/go/codec/msgpack.go
@@ -2,8 +2,6 @@
// Use of this source code is governed by a MIT license found in the LICENSE file.
/*
-MSGPACK
-
Msgpack-c implementation powers the c, c++, python, ruby, etc libraries.
We need to maintain compatibility with it and how it encodes integer values
without caring about the type.
@@ -24,7 +22,6 @@ import (
"io"
"math"
"net/rpc"
- "reflect"
"time"
)
@@ -172,23 +169,26 @@ type MsgpackSpecRpcMultiArgs []interface{}
// A MsgpackContainer type specifies the different types of msgpackContainers.
type msgpackContainerType struct {
- fixCutoff int
- bFixMin, b8, b16, b32 byte
- hasFixMin, has8, has8Always bool
+ fixCutoff uint8
+ bFixMin, b8, b16, b32 byte
+ // hasFixMin, has8, has8Always bool
}
var (
+ msgpackContainerRawLegacy = msgpackContainerType{
+ 32, mpFixStrMin, 0, mpStr16, mpStr32,
+ }
msgpackContainerStr = msgpackContainerType{
- 32, mpFixStrMin, mpStr8, mpStr16, mpStr32, true, true, false,
+ 32, mpFixStrMin, mpStr8, mpStr16, mpStr32, // true, true, false,
}
msgpackContainerBin = msgpackContainerType{
- 0, 0, mpBin8, mpBin16, mpBin32, false, true, true,
+ 0, 0, mpBin8, mpBin16, mpBin32, // false, true, true,
}
msgpackContainerList = msgpackContainerType{
- 16, mpFixArrayMin, 0, mpArray16, mpArray32, true, false, false,
+ 16, mpFixArrayMin, 0, mpArray16, mpArray32, // true, false, false,
}
msgpackContainerMap = msgpackContainerType{
- 16, mpFixMapMin, 0, mpMap16, mpMap32, true, false, false,
+ 16, mpFixMapMin, 0, mpMap16, mpMap32, // true, false, false,
}
)
@@ -197,16 +197,18 @@ var (
type msgpackEncDriver struct {
noBuiltInTypes
encDriverNoopContainerWriter
- // encNoSeparator
- e *Encoder
- w *encWriterSwitch
h *MsgpackHandle
x [8]byte
- // _ [3]uint64 // padding
+ _ [6]uint64 // padding
+ e Encoder
+}
+
+func (e *msgpackEncDriver) encoder() *Encoder {
+ return &e.e
}
func (e *msgpackEncDriver) EncodeNil() {
- e.w.writen1(mpNil)
+ e.e.encWr.writen1(mpNil)
}
func (e *msgpackEncDriver) EncodeInt(i int64) {
@@ -214,72 +216,72 @@ func (e *msgpackEncDriver) EncodeInt(i int64) {
e.EncodeUint(uint64(i))
} else if i > math.MaxInt8 {
if i <= math.MaxInt16 {
- e.w.writen1(mpInt16)
- bigenHelper{e.x[:2], e.w}.writeUint16(uint16(i))
+ e.e.encWr.writen1(mpInt16)
+ bigenHelper{e.x[:2], e.e.w()}.writeUint16(uint16(i))
} else if i <= math.MaxInt32 {
- e.w.writen1(mpInt32)
- bigenHelper{e.x[:4], e.w}.writeUint32(uint32(i))
+ e.e.encWr.writen1(mpInt32)
+ bigenHelper{e.x[:4], e.e.w()}.writeUint32(uint32(i))
} else {
- e.w.writen1(mpInt64)
- bigenHelper{e.x[:8], e.w}.writeUint64(uint64(i))
+ e.e.encWr.writen1(mpInt64)
+ bigenHelper{e.x[:8], e.e.w()}.writeUint64(uint64(i))
}
} else if i >= -32 {
if e.h.NoFixedNum {
- e.w.writen2(mpInt8, byte(i))
+ e.e.encWr.writen2(mpInt8, byte(i))
} else {
- e.w.writen1(byte(i))
+ e.e.encWr.writen1(byte(i))
}
} else if i >= math.MinInt8 {
- e.w.writen2(mpInt8, byte(i))
+ e.e.encWr.writen2(mpInt8, byte(i))
} else if i >= math.MinInt16 {
- e.w.writen1(mpInt16)
- bigenHelper{e.x[:2], e.w}.writeUint16(uint16(i))
+ e.e.encWr.writen1(mpInt16)
+ bigenHelper{e.x[:2], e.e.w()}.writeUint16(uint16(i))
} else if i >= math.MinInt32 {
- e.w.writen1(mpInt32)
- bigenHelper{e.x[:4], e.w}.writeUint32(uint32(i))
+ e.e.encWr.writen1(mpInt32)
+ bigenHelper{e.x[:4], e.e.w()}.writeUint32(uint32(i))
} else {
- e.w.writen1(mpInt64)
- bigenHelper{e.x[:8], e.w}.writeUint64(uint64(i))
+ e.e.encWr.writen1(mpInt64)
+ bigenHelper{e.x[:8], e.e.w()}.writeUint64(uint64(i))
}
}
func (e *msgpackEncDriver) EncodeUint(i uint64) {
if i <= math.MaxInt8 {
if e.h.NoFixedNum {
- e.w.writen2(mpUint8, byte(i))
+ e.e.encWr.writen2(mpUint8, byte(i))
} else {
- e.w.writen1(byte(i))
+ e.e.encWr.writen1(byte(i))
}
} else if i <= math.MaxUint8 {
- e.w.writen2(mpUint8, byte(i))
+ e.e.encWr.writen2(mpUint8, byte(i))
} else if i <= math.MaxUint16 {
- e.w.writen1(mpUint16)
- bigenHelper{e.x[:2], e.w}.writeUint16(uint16(i))
+ e.e.encWr.writen1(mpUint16)
+ bigenHelper{e.x[:2], e.e.w()}.writeUint16(uint16(i))
} else if i <= math.MaxUint32 {
- e.w.writen1(mpUint32)
- bigenHelper{e.x[:4], e.w}.writeUint32(uint32(i))
+ e.e.encWr.writen1(mpUint32)
+ bigenHelper{e.x[:4], e.e.w()}.writeUint32(uint32(i))
} else {
- e.w.writen1(mpUint64)
- bigenHelper{e.x[:8], e.w}.writeUint64(uint64(i))
+ e.e.encWr.writen1(mpUint64)
+ bigenHelper{e.x[:8], e.e.w()}.writeUint64(uint64(i))
}
}
func (e *msgpackEncDriver) EncodeBool(b bool) {
if b {
- e.w.writen1(mpTrue)
+ e.e.encWr.writen1(mpTrue)
} else {
- e.w.writen1(mpFalse)
+ e.e.encWr.writen1(mpFalse)
}
}
func (e *msgpackEncDriver) EncodeFloat32(f float32) {
- e.w.writen1(mpFloat)
- bigenHelper{e.x[:4], e.w}.writeUint32(math.Float32bits(f))
+ e.e.encWr.writen1(mpFloat)
+ bigenHelper{e.x[:4], e.e.w()}.writeUint32(math.Float32bits(f))
}
func (e *msgpackEncDriver) EncodeFloat64(f float64) {
- e.w.writen1(mpDouble)
- bigenHelper{e.x[:8], e.w}.writeUint64(math.Float64bits(f))
+ e.e.encWr.writen1(mpDouble)
+ bigenHelper{e.x[:8], e.e.w()}.writeUint64(math.Float64bits(f))
}
func (e *msgpackEncDriver) EncodeTime(t time.Time) {
@@ -302,60 +304,69 @@ func (e *msgpackEncDriver) EncodeTime(t time.Time) {
if e.h.WriteExt {
e.encodeExtPreamble(mpTimeExtTagU, l)
} else {
- e.writeContainerLen(msgpackContainerStr, l)
+ e.writeContainerLen(msgpackContainerRawLegacy, l)
}
switch l {
case 4:
- bigenHelper{e.x[:4], e.w}.writeUint32(uint32(data64))
+ bigenHelper{e.x[:4], e.e.w()}.writeUint32(uint32(data64))
case 8:
- bigenHelper{e.x[:8], e.w}.writeUint64(data64)
+ bigenHelper{e.x[:8], e.e.w()}.writeUint64(data64)
case 12:
- bigenHelper{e.x[:4], e.w}.writeUint32(uint32(nsec))
- bigenHelper{e.x[:8], e.w}.writeUint64(uint64(sec))
+ bigenHelper{e.x[:4], e.e.w()}.writeUint32(uint32(nsec))
+ bigenHelper{e.x[:8], e.e.w()}.writeUint64(uint64(sec))
}
}
-func (e *msgpackEncDriver) EncodeExt(v interface{}, xtag uint64, ext Ext, _ *Encoder) {
- bs := ext.WriteExt(v)
+func (e *msgpackEncDriver) EncodeExt(v interface{}, xtag uint64, ext Ext) {
+ var bs []byte
+ if ext == SelfExt {
+ bs = e.e.blist.get(1024)[:0]
+ e.e.sideEncode(v, &bs)
+ } else {
+ bs = ext.WriteExt(v)
+ }
if bs == nil {
e.EncodeNil()
return
}
if e.h.WriteExt {
e.encodeExtPreamble(uint8(xtag), len(bs))
- e.w.writeb(bs)
+ e.e.encWr.writeb(bs)
} else {
e.EncodeStringBytesRaw(bs)
}
+ if ext == SelfExt {
+ e.e.blist.put(bs)
+ }
}
-func (e *msgpackEncDriver) EncodeRawExt(re *RawExt, _ *Encoder) {
+func (e *msgpackEncDriver) EncodeRawExt(re *RawExt) {
e.encodeExtPreamble(uint8(re.Tag), len(re.Data))
- e.w.writeb(re.Data)
+ e.e.encWr.writeb(re.Data)
}
func (e *msgpackEncDriver) encodeExtPreamble(xtag byte, l int) {
if l == 1 {
- e.w.writen2(mpFixExt1, xtag)
+ e.e.encWr.writen2(mpFixExt1, xtag)
} else if l == 2 {
- e.w.writen2(mpFixExt2, xtag)
+ e.e.encWr.writen2(mpFixExt2, xtag)
} else if l == 4 {
- e.w.writen2(mpFixExt4, xtag)
+ e.e.encWr.writen2(mpFixExt4, xtag)
} else if l == 8 {
- e.w.writen2(mpFixExt8, xtag)
+ e.e.encWr.writen2(mpFixExt8, xtag)
} else if l == 16 {
- e.w.writen2(mpFixExt16, xtag)
+ e.e.encWr.writen2(mpFixExt16, xtag)
} else if l < 256 {
- e.w.writen2(mpExt8, byte(l))
- e.w.writen1(xtag)
+ e.e.encWr.writen2(mpExt8, byte(l))
+ e.e.encWr.writen1(xtag)
} else if l < 65536 {
- e.w.writen1(mpExt16)
- bigenHelper{e.x[:2], e.w}.writeUint16(uint16(l))
- e.w.writen1(xtag)
+ e.e.encWr.writen1(mpExt16)
+ bigenHelper{e.x[:2], e.e.w()}.writeUint16(uint16(l))
+ e.e.encWr.writen1(xtag)
} else {
- e.w.writen1(mpExt32)
- bigenHelper{e.x[:4], e.w}.writeUint32(uint32(l))
- e.w.writen1(xtag)
+ e.e.encWr.writen1(mpExt32)
+ bigenHelper{e.x[:4], e.e.w()}.writeUint32(uint32(l))
+ e.e.encWr.writen1(xtag)
}
}
@@ -367,39 +378,20 @@ func (e *msgpackEncDriver) WriteMapStart(length int) {
e.writeContainerLen(msgpackContainerMap, length)
}
-func (e *msgpackEncDriver) EncodeString(c charEncoding, s string) {
- slen := len(s)
- if c == cRAW && e.h.WriteExt {
- e.writeContainerLen(msgpackContainerBin, slen)
- } else {
- e.writeContainerLen(msgpackContainerStr, slen)
- }
- if slen > 0 {
- e.w.writestr(s)
- }
-}
-
-func (e *msgpackEncDriver) EncodeStringEnc(c charEncoding, s string) {
- slen := len(s)
- e.writeContainerLen(msgpackContainerStr, slen)
- if slen > 0 {
- e.w.writestr(s)
- }
-}
-
-func (e *msgpackEncDriver) EncodeStringBytes(c charEncoding, bs []byte) {
- if bs == nil {
- e.EncodeNil()
- return
- }
- slen := len(bs)
- if c == cRAW && e.h.WriteExt {
- e.writeContainerLen(msgpackContainerBin, slen)
+func (e *msgpackEncDriver) EncodeString(s string) {
+ var ct msgpackContainerType
+ if e.h.WriteExt {
+ if e.h.StringToRaw {
+ ct = msgpackContainerBin
+ } else {
+ ct = msgpackContainerStr
+ }
} else {
- e.writeContainerLen(msgpackContainerStr, slen)
+ ct = msgpackContainerRawLegacy
}
- if slen > 0 {
- e.w.writeb(bs)
+ e.writeContainerLen(ct, len(s))
+ if len(s) > 0 {
+ e.e.encWr.writestr(s)
}
}
@@ -408,46 +400,46 @@ func (e *msgpackEncDriver) EncodeStringBytesRaw(bs []byte) {
e.EncodeNil()
return
}
- slen := len(bs)
if e.h.WriteExt {
- e.writeContainerLen(msgpackContainerBin, slen)
+ e.writeContainerLen(msgpackContainerBin, len(bs))
} else {
- e.writeContainerLen(msgpackContainerStr, slen)
+ e.writeContainerLen(msgpackContainerRawLegacy, len(bs))
}
- if slen > 0 {
- e.w.writeb(bs)
+ if len(bs) > 0 {
+ e.e.encWr.writeb(bs)
}
}
func (e *msgpackEncDriver) writeContainerLen(ct msgpackContainerType, l int) {
- if ct.hasFixMin && l < ct.fixCutoff {
- e.w.writen1(ct.bFixMin | byte(l))
- } else if ct.has8 && l < 256 && (ct.has8Always || e.h.WriteExt) {
- e.w.writen2(ct.b8, uint8(l))
+ if ct.fixCutoff > 0 && l < int(ct.fixCutoff) {
+ e.e.encWr.writen1(ct.bFixMin | byte(l))
+ } else if ct.b8 > 0 && l < 256 {
+ e.e.encWr.writen2(ct.b8, uint8(l))
} else if l < 65536 {
- e.w.writen1(ct.b16)
- bigenHelper{e.x[:2], e.w}.writeUint16(uint16(l))
+ e.e.encWr.writen1(ct.b16)
+ bigenHelper{e.x[:2], e.e.w()}.writeUint16(uint16(l))
} else {
- e.w.writen1(ct.b32)
- bigenHelper{e.x[:4], e.w}.writeUint32(uint32(l))
+ e.e.encWr.writen1(ct.b32)
+ bigenHelper{e.x[:4], e.e.w()}.writeUint32(uint32(l))
}
}
//---------------------------------------------
type msgpackDecDriver struct {
- d *Decoder
- r *decReaderSwitch
+ decDriverNoopContainerReader
h *MsgpackHandle
// b [scratchByteArrayLen]byte
bd byte
bdRead bool
- br bool // bytes reader
+ fnil bool
noBuiltInTypes
- // noStreamingCodec
- // decNoSeparator
- decDriverNoopContainerReader
- // _ [3]uint64 // padding
+ _ [6]uint64 // padding
+ d Decoder
+}
+
+func (d *msgpackDecDriver) decoder() *Decoder {
+ return &d.d
}
// Note: This returns either a primitive (int, bool, etc) for non-containers,
@@ -459,6 +451,7 @@ func (d *msgpackDecDriver) DecodeNaked() {
if !d.bdRead {
d.readNextBd()
}
+ d.fnil = false
bd := d.bd
n := d.d.naked()
var decodeFurther bool
@@ -467,6 +460,7 @@ func (d *msgpackDecDriver) DecodeNaked() {
case mpNil:
n.v = valueTypeNil
d.bdRead = false
+ d.fnil = true
case mpFalse:
n.v = valueTypeBool
n.b = false
@@ -476,36 +470,36 @@ func (d *msgpackDecDriver) DecodeNaked() {
case mpFloat:
n.v = valueTypeFloat
- n.f = float64(math.Float32frombits(bigen.Uint32(d.r.readx(4))))
+ n.f = float64(math.Float32frombits(bigen.Uint32(d.d.decRd.readx(4))))
case mpDouble:
n.v = valueTypeFloat
- n.f = math.Float64frombits(bigen.Uint64(d.r.readx(8)))
+ n.f = math.Float64frombits(bigen.Uint64(d.d.decRd.readx(8)))
case mpUint8:
n.v = valueTypeUint
- n.u = uint64(d.r.readn1())
+ n.u = uint64(d.d.decRd.readn1())
case mpUint16:
n.v = valueTypeUint
- n.u = uint64(bigen.Uint16(d.r.readx(2)))
+ n.u = uint64(bigen.Uint16(d.d.decRd.readx(2)))
case mpUint32:
n.v = valueTypeUint
- n.u = uint64(bigen.Uint32(d.r.readx(4)))
+ n.u = uint64(bigen.Uint32(d.d.decRd.readx(4)))
case mpUint64:
n.v = valueTypeUint
- n.u = uint64(bigen.Uint64(d.r.readx(8)))
+ n.u = uint64(bigen.Uint64(d.d.decRd.readx(8)))
case mpInt8:
n.v = valueTypeInt
- n.i = int64(int8(d.r.readn1()))
+ n.i = int64(int8(d.d.decRd.readn1()))
case mpInt16:
n.v = valueTypeInt
- n.i = int64(int16(bigen.Uint16(d.r.readx(2))))
+ n.i = int64(int16(bigen.Uint16(d.d.decRd.readx(2))))
case mpInt32:
n.v = valueTypeInt
- n.i = int64(int32(bigen.Uint32(d.r.readx(4))))
+ n.i = int64(int32(bigen.Uint32(d.d.decRd.readx(4))))
case mpInt64:
n.v = valueTypeInt
- n.i = int64(int64(bigen.Uint64(d.r.readx(8))))
+ n.i = int64(int64(bigen.Uint64(d.d.decRd.readx(8))))
default:
switch {
@@ -518,16 +512,15 @@ func (d *msgpackDecDriver) DecodeNaked() {
n.v = valueTypeInt
n.i = int64(int8(bd))
case bd == mpStr8, bd == mpStr16, bd == mpStr32, bd >= mpFixStrMin && bd <= mpFixStrMax:
- if d.h.RawToString {
+ if d.h.WriteExt || d.h.RawToString {
n.v = valueTypeString
- n.s = d.DecodeString()
+ n.s = string(d.DecodeStringAsBytes())
} else {
n.v = valueTypeBytes
n.l = d.DecodeBytes(nil, false)
}
case bd == mpBin8, bd == mpBin16, bd == mpBin32:
- n.v = valueTypeBytes
- n.l = d.DecodeBytes(nil, false)
+ decNakedReadRawBytes(d, &d.d, n, d.h.RawToString)
case bd == mpArray16, bd == mpArray32, bd >= mpFixArrayMin && bd <= mpFixArrayMax:
n.v = valueTypeArray
decodeFurther = true
@@ -537,14 +530,14 @@ func (d *msgpackDecDriver) DecodeNaked() {
case bd >= mpFixExt1 && bd <= mpFixExt16, bd >= mpExt8 && bd <= mpExt32:
n.v = valueTypeExt
clen := d.readExtLen()
- n.u = uint64(d.r.readn1())
+ n.u = uint64(d.d.decRd.readn1())
if n.u == uint64(mpTimeExtTagU) {
n.v = valueTypeTime
n.t = d.decodeTime(clen)
- } else if d.br {
- n.l = d.r.readx(uint(clen))
+ } else if d.d.bytes {
+ n.l = d.d.decRd.readx(uint(clen))
} else {
- n.l = decByteSlice(d.r, clen, d.d.h.MaxInitLen, d.d.b[:])
+ n.l = decByteSlice(d.d.r(), clen, d.d.h.MaxInitLen, d.d.b[:])
}
default:
d.d.errorf("cannot infer value: %s: Ox%x/%d/%s", msgBadDesc, bd, bd, mpdesc(bd))
@@ -561,26 +554,26 @@ func (d *msgpackDecDriver) DecodeNaked() {
// int can be decoded from msgpack type: intXXX or uintXXX
func (d *msgpackDecDriver) DecodeInt64() (i int64) {
- if !d.bdRead {
- d.readNextBd()
+ if d.advanceNil() {
+ return
}
switch d.bd {
case mpUint8:
- i = int64(uint64(d.r.readn1()))
+ i = int64(uint64(d.d.decRd.readn1()))
case mpUint16:
- i = int64(uint64(bigen.Uint16(d.r.readx(2))))
+ i = int64(uint64(bigen.Uint16(d.d.decRd.readx(2))))
case mpUint32:
- i = int64(uint64(bigen.Uint32(d.r.readx(4))))
+ i = int64(uint64(bigen.Uint32(d.d.decRd.readx(4))))
case mpUint64:
- i = int64(bigen.Uint64(d.r.readx(8)))
+ i = int64(bigen.Uint64(d.d.decRd.readx(8)))
case mpInt8:
- i = int64(int8(d.r.readn1()))
+ i = int64(int8(d.d.decRd.readn1()))
case mpInt16:
- i = int64(int16(bigen.Uint16(d.r.readx(2))))
+ i = int64(int16(bigen.Uint16(d.d.decRd.readx(2))))
case mpInt32:
- i = int64(int32(bigen.Uint32(d.r.readx(4))))
+ i = int64(int32(bigen.Uint32(d.d.decRd.readx(4))))
case mpInt64:
- i = int64(bigen.Uint64(d.r.readx(8)))
+ i = int64(bigen.Uint64(d.d.decRd.readx(8)))
default:
switch {
case d.bd >= mpPosFixNumMin && d.bd <= mpPosFixNumMax:
@@ -598,41 +591,41 @@ func (d *msgpackDecDriver) DecodeInt64() (i int64) {
// uint can be decoded from msgpack type: intXXX or uintXXX
func (d *msgpackDecDriver) DecodeUint64() (ui uint64) {
- if !d.bdRead {
- d.readNextBd()
+ if d.advanceNil() {
+ return
}
switch d.bd {
case mpUint8:
- ui = uint64(d.r.readn1())
+ ui = uint64(d.d.decRd.readn1())
case mpUint16:
- ui = uint64(bigen.Uint16(d.r.readx(2)))
+ ui = uint64(bigen.Uint16(d.d.decRd.readx(2)))
case mpUint32:
- ui = uint64(bigen.Uint32(d.r.readx(4)))
+ ui = uint64(bigen.Uint32(d.d.decRd.readx(4)))
case mpUint64:
- ui = bigen.Uint64(d.r.readx(8))
+ ui = bigen.Uint64(d.d.decRd.readx(8))
case mpInt8:
- if i := int64(int8(d.r.readn1())); i >= 0 {
+ if i := int64(int8(d.d.decRd.readn1())); i >= 0 {
ui = uint64(i)
} else {
d.d.errorf("assigning negative signed value: %v, to unsigned type", i)
return
}
case mpInt16:
- if i := int64(int16(bigen.Uint16(d.r.readx(2)))); i >= 0 {
+ if i := int64(int16(bigen.Uint16(d.d.decRd.readx(2)))); i >= 0 {
ui = uint64(i)
} else {
d.d.errorf("assigning negative signed value: %v, to unsigned type", i)
return
}
case mpInt32:
- if i := int64(int32(bigen.Uint32(d.r.readx(4)))); i >= 0 {
+ if i := int64(int32(bigen.Uint32(d.d.decRd.readx(4)))); i >= 0 {
ui = uint64(i)
} else {
d.d.errorf("assigning negative signed value: %v, to unsigned type", i)
return
}
case mpInt64:
- if i := int64(bigen.Uint64(d.r.readx(8))); i >= 0 {
+ if i := int64(bigen.Uint64(d.d.decRd.readx(8))); i >= 0 {
ui = uint64(i)
} else {
d.d.errorf("assigning negative signed value: %v, to unsigned type", i)
@@ -656,13 +649,13 @@ func (d *msgpackDecDriver) DecodeUint64() (ui uint64) {
// float can either be decoded from msgpack type: float, double or intX
func (d *msgpackDecDriver) DecodeFloat64() (f float64) {
- if !d.bdRead {
- d.readNextBd()
+ if d.advanceNil() {
+ return
}
if d.bd == mpFloat {
- f = float64(math.Float32frombits(bigen.Uint32(d.r.readx(4))))
+ f = float64(math.Float32frombits(bigen.Uint32(d.d.decRd.readx(4))))
} else if d.bd == mpDouble {
- f = math.Float64frombits(bigen.Uint64(d.r.readx(8)))
+ f = math.Float64frombits(bigen.Uint64(d.d.decRd.readx(8)))
} else {
f = float64(d.DecodeInt64())
}
@@ -672,8 +665,8 @@ func (d *msgpackDecDriver) DecodeFloat64() (f float64) {
// bool can be decoded from bool, fixnum 0 or 1.
func (d *msgpackDecDriver) DecodeBool() (b bool) {
- if !d.bdRead {
- d.readNextBd()
+ if d.advanceNil() {
+ return
}
if d.bd == mpFalse || d.bd == 0 {
// b = false
@@ -688,54 +681,44 @@ func (d *msgpackDecDriver) DecodeBool() (b bool) {
}
func (d *msgpackDecDriver) DecodeBytes(bs []byte, zerocopy bool) (bsOut []byte) {
- if !d.bdRead {
- d.readNextBd()
+ if d.advanceNil() {
+ return
}
- // check if an "array" of uint8's (see ContainerType for how to infer if an array)
bd := d.bd
- // DecodeBytes could be from: bin str fixstr fixarray array ...
var clen int
- vt := d.ContainerType()
- switch vt {
- case valueTypeBytes:
- // valueTypeBytes may be a mpBin or an mpStr container
- if bd == mpBin8 || bd == mpBin16 || bd == mpBin32 {
- clen = d.readContainerLen(msgpackContainerBin)
- } else {
- clen = d.readContainerLen(msgpackContainerStr)
- }
- case valueTypeString:
- clen = d.readContainerLen(msgpackContainerStr)
- case valueTypeArray:
+ if bd == mpBin8 || bd == mpBin16 || bd == mpBin32 {
+ clen = d.readContainerLen(msgpackContainerBin) // binary
+ } else if bd == mpStr8 || bd == mpStr16 || bd == mpStr32 ||
+ (bd >= mpFixStrMin && bd <= mpFixStrMax) {
+ clen = d.readContainerLen(msgpackContainerStr) // string/raw
+ } else if bd == mpArray16 || bd == mpArray32 ||
+ (bd >= mpFixArrayMin && bd <= mpFixArrayMax) {
+ // check if an "array" of uint8's
if zerocopy && len(bs) == 0 {
bs = d.d.b[:]
}
- bsOut, _ = fastpathTV.DecSliceUint8V(bs, true, d.d)
- return
- default:
- d.d.errorf("invalid container type: expecting bin|str|array, got: 0x%x", uint8(vt))
+ // bsOut, _ = fastpathTV.DecSliceUint8V(bs, true, d.d)
+ slen := d.ReadArrayStart()
+ bs = usableByteSlice(bs, slen)
+ for i := 0; i < len(bs); i++ {
+ bs[i] = uint8(chkOvf.UintV(d.DecodeUint64(), 8))
+ }
+ return bs
+ } else {
+ d.d.errorf("invalid byte descriptor for decoding bytes, got: 0x%x", d.bd)
return
}
- // these are (bin|str)(8|16|32)
d.bdRead = false
- // bytes may be nil, so handle it. if nil, clen=-1.
- if clen < 0 {
- return nil
- }
if zerocopy {
- if d.br {
- return d.r.readx(uint(clen))
+ if d.d.bytes {
+ return d.d.decRd.readx(uint(clen))
} else if len(bs) == 0 {
bs = d.d.b[:]
}
}
- return decByteSlice(d.r, clen, d.h.MaxInitLen, bs)
-}
-
-func (d *msgpackDecDriver) DecodeString() (s string) {
- return string(d.DecodeBytes(d.d.b[:], true))
+ return decByteSlice(d.d.r(), clen, d.h.MaxInitLen, bs)
}
func (d *msgpackDecDriver) DecodeStringAsBytes() (s []byte) {
@@ -743,63 +726,72 @@ func (d *msgpackDecDriver) DecodeStringAsBytes() (s []byte) {
}
func (d *msgpackDecDriver) readNextBd() {
- d.bd = d.r.readn1()
+ d.bd = d.d.decRd.readn1()
d.bdRead = true
}
func (d *msgpackDecDriver) uncacheRead() {
if d.bdRead {
- d.r.unreadn1()
+ d.d.decRd.unreadn1()
d.bdRead = false
}
}
+func (d *msgpackDecDriver) advanceNil() (null bool) {
+ d.fnil = false
+ if !d.bdRead {
+ d.readNextBd()
+ }
+ if d.bd == mpNil {
+ d.bdRead = false
+ d.fnil = true
+ null = true
+ }
+ return
+}
+
+func (d *msgpackDecDriver) Nil() bool {
+ return d.fnil
+}
+
func (d *msgpackDecDriver) ContainerType() (vt valueType) {
if !d.bdRead {
d.readNextBd()
}
bd := d.bd
+ d.fnil = false
if bd == mpNil {
+ d.bdRead = false
+ d.fnil = true
return valueTypeNil
- } else if bd == mpBin8 || bd == mpBin16 || bd == mpBin32 ||
- (!d.h.RawToString &&
- (bd == mpStr8 || bd == mpStr16 || bd == mpStr32 || (bd >= mpFixStrMin && bd <= mpFixStrMax))) {
+ } else if bd == mpBin8 || bd == mpBin16 || bd == mpBin32 {
return valueTypeBytes
- } else if d.h.RawToString &&
- (bd == mpStr8 || bd == mpStr16 || bd == mpStr32 || (bd >= mpFixStrMin && bd <= mpFixStrMax)) {
- return valueTypeString
+ } else if bd == mpStr8 || bd == mpStr16 || bd == mpStr32 ||
+ (bd >= mpFixStrMin && bd <= mpFixStrMax) {
+ if d.h.WriteExt || d.h.RawToString { // UTF-8 string (new spec)
+ return valueTypeString
+ }
+ return valueTypeBytes // raw (old spec)
} else if bd == mpArray16 || bd == mpArray32 || (bd >= mpFixArrayMin && bd <= mpFixArrayMax) {
return valueTypeArray
} else if bd == mpMap16 || bd == mpMap32 || (bd >= mpFixMapMin && bd <= mpFixMapMax) {
return valueTypeMap
}
- // else {
- // d.d.errorf("isContainerType: unsupported parameter: %v", vt)
- // }
return valueTypeUnset
}
-func (d *msgpackDecDriver) TryDecodeAsNil() (v bool) {
- if !d.bdRead {
- d.readNextBd()
- }
- if d.bd == mpNil {
- d.bdRead = false
- return true
- }
- return
+func (d *msgpackDecDriver) TryNil() (v bool) {
+ return d.advanceNil()
}
func (d *msgpackDecDriver) readContainerLen(ct msgpackContainerType) (clen int) {
bd := d.bd
- if bd == mpNil {
- clen = -1 // to represent nil
- } else if bd == ct.b8 {
- clen = int(d.r.readn1())
+ if bd == ct.b8 {
+ clen = int(d.d.decRd.readn1())
} else if bd == ct.b16 {
- clen = int(bigen.Uint16(d.r.readx(2)))
+ clen = int(bigen.Uint16(d.d.decRd.readx(2)))
} else if bd == ct.b32 {
- clen = int(bigen.Uint32(d.r.readx(4)))
+ clen = int(bigen.Uint32(d.d.decRd.readx(4)))
} else if (ct.bFixMin & bd) == ct.bFixMin {
clen = int(ct.bFixMin ^ bd)
} else {
@@ -811,23 +803,21 @@ func (d *msgpackDecDriver) readContainerLen(ct msgpackContainerType) (clen int)
}
func (d *msgpackDecDriver) ReadMapStart() int {
- if !d.bdRead {
- d.readNextBd()
+ if d.advanceNil() {
+ return decContainerLenNil
}
return d.readContainerLen(msgpackContainerMap)
}
func (d *msgpackDecDriver) ReadArrayStart() int {
- if !d.bdRead {
- d.readNextBd()
+ if d.advanceNil() {
+ return decContainerLenNil
}
return d.readContainerLen(msgpackContainerList)
}
func (d *msgpackDecDriver) readExtLen() (clen int) {
switch d.bd {
- case mpNil:
- clen = -1 // to represent nil
case mpFixExt1:
clen = 1
case mpFixExt2:
@@ -839,11 +829,11 @@ func (d *msgpackDecDriver) readExtLen() (clen int) {
case mpFixExt16:
clen = 16
case mpExt8:
- clen = int(d.r.readn1())
+ clen = int(d.d.decRd.readn1())
case mpExt16:
- clen = int(bigen.Uint16(d.r.readx(2)))
+ clen = int(bigen.Uint16(d.d.decRd.readx(2)))
case mpExt32:
- clen = int(bigen.Uint32(d.r.readx(4)))
+ clen = int(bigen.Uint32(d.d.decRd.readx(4)))
default:
d.d.errorf("decoding ext bytes: found unexpected byte: %x", d.bd)
return
@@ -853,29 +843,28 @@ func (d *msgpackDecDriver) readExtLen() (clen int) {
func (d *msgpackDecDriver) DecodeTime() (t time.Time) {
// decode time from string bytes or ext
- if !d.bdRead {
- d.readNextBd()
- }
- if d.bd == mpNil {
- d.bdRead = false
+ if d.advanceNil() {
return
}
+ bd := d.bd
var clen int
- switch d.ContainerType() {
- case valueTypeBytes, valueTypeString:
- clen = d.readContainerLen(msgpackContainerStr)
- default:
+ if bd == mpBin8 || bd == mpBin16 || bd == mpBin32 {
+ clen = d.readContainerLen(msgpackContainerBin) // binary
+ } else if bd == mpStr8 || bd == mpStr16 || bd == mpStr32 ||
+ (bd >= mpFixStrMin && bd <= mpFixStrMax) {
+ clen = d.readContainerLen(msgpackContainerStr) // string/raw
+ } else {
// expect to see mpFixExt4,-1 OR mpFixExt8,-1 OR mpExt8,12,-1
d.bdRead = false
- b2 := d.r.readn1()
+ b2 := d.d.decRd.readn1()
if d.bd == mpFixExt4 && b2 == mpTimeExtTagU {
clen = 4
} else if d.bd == mpFixExt8 && b2 == mpTimeExtTagU {
clen = 8
- } else if d.bd == mpExt8 && b2 == 12 && d.r.readn1() == mpTimeExtTagU {
+ } else if d.bd == mpExt8 && b2 == 12 && d.d.decRd.readn1() == mpTimeExtTagU {
clen = 12
} else {
- d.d.errorf("invalid bytes for decoding time as extension: got 0x%x, 0x%x", d.bd, b2)
+ d.d.errorf("invalid stream for decoding time as extension: got 0x%x, 0x%x", d.bd, b2)
return
}
}
@@ -883,17 +872,17 @@ func (d *msgpackDecDriver) DecodeTime() (t time.Time) {
}
func (d *msgpackDecDriver) decodeTime(clen int) (t time.Time) {
- // bs = d.r.readx(clen)
+ // bs = d.d.decRd.readx(clen)
d.bdRead = false
switch clen {
case 4:
- t = time.Unix(int64(bigen.Uint32(d.r.readx(4))), 0).UTC()
+ t = time.Unix(int64(bigen.Uint32(d.d.decRd.readx(4))), 0).UTC()
case 8:
- tv := bigen.Uint64(d.r.readx(8))
+ tv := bigen.Uint64(d.d.decRd.readx(8))
t = time.Unix(int64(tv&0x00000003ffffffff), int64(tv>>34)).UTC()
case 12:
- nsec := bigen.Uint32(d.r.readx(4))
- sec := bigen.Uint64(d.r.readx(8))
+ nsec := bigen.Uint32(d.d.decRd.readx(4))
+ sec := bigen.Uint64(d.d.decRd.readx(8))
t = time.Unix(int64(sec), int64(nsec)).UTC()
default:
d.d.errorf("invalid length of bytes for decoding time - expecting 4 or 8 or 12, got %d", clen)
@@ -902,27 +891,28 @@ func (d *msgpackDecDriver) decodeTime(clen int) (t time.Time) {
return
}
-func (d *msgpackDecDriver) DecodeExt(rv interface{}, xtag uint64, ext Ext) (realxtag uint64) {
+func (d *msgpackDecDriver) DecodeExt(rv interface{}, xtag uint64, ext Ext) {
if xtag > 0xff {
d.d.errorf("ext: tag must be <= 0xff; got: %v", xtag)
return
}
+ if d.advanceNil() {
+ return
+ }
realxtag1, xbs := d.decodeExtV(ext != nil, uint8(xtag))
- realxtag = uint64(realxtag1)
+ realxtag := uint64(realxtag1)
if ext == nil {
re := rv.(*RawExt)
re.Tag = realxtag
- re.Data = detachZeroCopyBytes(d.br, re.Data, xbs)
+ re.Data = detachZeroCopyBytes(d.d.bytes, re.Data, xbs)
+ } else if ext == SelfExt {
+ d.d.sideDecode(rv, xbs)
} else {
ext.ReadExt(rv, xbs)
}
- return
}
func (d *msgpackDecDriver) decodeExtV(verifyTag bool, tag byte) (xtag byte, xbs []byte) {
- if !d.bdRead {
- d.readNextBd()
- }
xbd := d.bd
if xbd == mpBin8 || xbd == mpBin16 || xbd == mpBin32 {
xbs = d.DecodeBytes(nil, true)
@@ -931,15 +921,15 @@ func (d *msgpackDecDriver) decodeExtV(verifyTag bool, tag byte) (xtag byte, xbs
xbs = d.DecodeStringAsBytes()
} else {
clen := d.readExtLen()
- xtag = d.r.readn1()
+ xtag = d.d.decRd.readn1()
if verifyTag && xtag != tag {
d.d.errorf("wrong extension tag - got %b, expecting %v", xtag, tag)
return
}
- if d.br {
- xbs = d.r.readx(uint(clen))
+ if d.d.bytes {
+ xbs = d.d.decRd.readx(uint(clen))
} else {
- xbs = decByteSlice(d.r, clen, d.d.h.MaxInitLen, d.d.b[:])
+ xbs = decByteSlice(d.d.r(), clen, d.d.h.MaxInitLen, d.d.b[:])
}
}
d.bdRead = false
@@ -950,58 +940,57 @@ func (d *msgpackDecDriver) decodeExtV(verifyTag bool, tag byte) (xtag byte, xbs
//MsgpackHandle is a Handle for the Msgpack Schema-Free Encoding Format.
type MsgpackHandle struct {
+ binaryEncodingType
BasicHandle
- // RawToString controls how raw bytes are decoded into a nil interface{}.
- RawToString bool
-
// NoFixedNum says to output all signed integers as 2-bytes, never as 1-byte fixednum.
NoFixedNum bool
- // WriteExt flag supports encoding configured extensions with extension tags.
- // It also controls whether other elements of the new spec are encoded (ie Str8).
+ // WriteExt controls whether the new spec is honored.
//
- // With WriteExt=false, configured extensions are serialized as raw bytes
- // and Str8 is not encoded.
+ // With WriteExt=true, we can encode configured extensions with extension tags
+ // and encode string/[]byte/extensions in a way compatible with the new spec
+ // but incompatible with the old spec.
//
- // A stream can still be decoded into a typed value, provided an appropriate value
- // is provided, but the type cannot be inferred from the stream. If no appropriate
- // type is provided (e.g. decoding into a nil interface{}), you get back
- // a []byte or string based on the setting of RawToString.
+ // For compatibility with the old spec, set WriteExt=false.
+ //
+ // With WriteExt=false:
+ // configured extensions are serialized as raw bytes (not msgpack extensions).
+ // reserved byte descriptors like Str8 and those enabling the new msgpack Binary type
+ // are not encoded.
WriteExt bool
// PositiveIntUnsigned says to encode positive integers as unsigned.
PositiveIntUnsigned bool
- binaryEncodingType
- noElemSeparators
-
- // _ [1]uint64 // padding
+ _ [7]uint64 // padding (cache-aligned)
}
// Name returns the name of the handle: msgpack
func (h *MsgpackHandle) Name() string { return "msgpack" }
-// SetBytesExt sets an extension
-func (h *MsgpackHandle) SetBytesExt(rt reflect.Type, tag uint64, ext BytesExt) (err error) {
- return h.SetExt(rt, tag, &extWrapper{ext, interfaceExtFailer{}})
+func (h *MsgpackHandle) newEncDriver() encDriver {
+ var e = &msgpackEncDriver{h: h}
+ e.e.e = e
+ e.e.init(h)
+ e.reset()
+ return e
}
-func (h *MsgpackHandle) newEncDriver(e *Encoder) encDriver {
- return &msgpackEncDriver{e: e, w: e.w, h: h}
-}
-
-func (h *MsgpackHandle) newDecDriver(d *Decoder) decDriver {
- return &msgpackDecDriver{d: d, h: h, r: d.r, br: d.bytes}
+func (h *MsgpackHandle) newDecDriver() decDriver {
+ d := &msgpackDecDriver{h: h}
+ d.d.d = d
+ d.d.init(h)
+ d.reset()
+ return d
}
func (e *msgpackEncDriver) reset() {
- e.w = e.e.w
}
func (d *msgpackDecDriver) reset() {
- d.r, d.br = d.d.r, d.d.bytes
d.bd, d.bdRead = 0, false
+ d.fnil = false
}
//--------------------------------------------------
@@ -1062,11 +1051,7 @@ func (c *msgpackSpecRpcCodec) parseCustomHeader(expectTypeByte byte, msgid *uint
// so that the body can be decoded on its own from the stream at a later time.
const fia byte = 0x94 //four item array descriptor value
- // Not sure why the panic of EOF is swallowed above.
- // if bs1 := c.dec.r.readn1(); bs1 != fia {
- // err = fmt.Errorf("Unexpected value for array descriptor: Expecting %v. Received %v", fia, bs1)
- // return
- // }
+
var ba [1]byte
var n int
for {
diff --git a/vendor/github.com/ugorji/go/codec/rpc.go b/vendor/github.com/ugorji/go/codec/rpc.go
index 3925088..8ee2358 100644
--- a/vendor/github.com/ugorji/go/codec/rpc.go
+++ b/vendor/github.com/ugorji/go/codec/rpc.go
@@ -97,9 +97,6 @@ func (c *rpcCodec) write(obj1, obj2 interface{}, writeObj2 bool) (err error) {
if writeObj2 {
err = c.enc.Encode(obj2)
}
- // if err == nil && c.f != nil {
- // err = c.f.Flush()
- // }
}
if c.f != nil {
if err == nil {
diff --git a/vendor/github.com/ugorji/go/codec/simple.go b/vendor/github.com/ugorji/go/codec/simple.go
index 464c2f9..42bfd04 100644
--- a/vendor/github.com/ugorji/go/codec/simple.go
+++ b/vendor/github.com/ugorji/go/codec/simple.go
@@ -5,7 +5,6 @@ package codec
import (
"math"
- "reflect"
"time"
)
@@ -33,49 +32,49 @@ const (
type simpleEncDriver struct {
noBuiltInTypes
- // encNoSeparator
- e *Encoder
+ encDriverNoopContainerWriter
h *SimpleHandle
- w *encWriterSwitch
b [8]byte
- // c containerState
- encDriverTrackContainerWriter
- // encDriverNoopContainerWriter
- _ [3]uint64 // padding
+ _ [6]uint64 // padding (cache-aligned)
+ e Encoder
+}
+
+func (e *simpleEncDriver) encoder() *Encoder {
+ return &e.e
}
func (e *simpleEncDriver) EncodeNil() {
- e.w.writen1(simpleVdNil)
+ e.e.encWr.writen1(simpleVdNil)
}
func (e *simpleEncDriver) EncodeBool(b bool) {
- if e.h.EncZeroValuesAsNil && e.c != containerMapKey && !b {
+ if e.h.EncZeroValuesAsNil && e.e.c != containerMapKey && !b {
e.EncodeNil()
return
}
if b {
- e.w.writen1(simpleVdTrue)
+ e.e.encWr.writen1(simpleVdTrue)
} else {
- e.w.writen1(simpleVdFalse)
+ e.e.encWr.writen1(simpleVdFalse)
}
}
func (e *simpleEncDriver) EncodeFloat32(f float32) {
- if e.h.EncZeroValuesAsNil && e.c != containerMapKey && f == 0.0 {
+ if e.h.EncZeroValuesAsNil && e.e.c != containerMapKey && f == 0.0 {
e.EncodeNil()
return
}
- e.w.writen1(simpleVdFloat32)
- bigenHelper{e.b[:4], e.w}.writeUint32(math.Float32bits(f))
+ e.e.encWr.writen1(simpleVdFloat32)
+ bigenHelper{e.b[:4], e.e.w()}.writeUint32(math.Float32bits(f))
}
func (e *simpleEncDriver) EncodeFloat64(f float64) {
- if e.h.EncZeroValuesAsNil && e.c != containerMapKey && f == 0.0 {
+ if e.h.EncZeroValuesAsNil && e.e.c != containerMapKey && f == 0.0 {
e.EncodeNil()
return
}
- e.w.writen1(simpleVdFloat64)
- bigenHelper{e.b[:8], e.w}.writeUint64(math.Float64bits(f))
+ e.e.encWr.writen1(simpleVdFloat64)
+ bigenHelper{e.b[:8], e.e.w()}.writeUint64(math.Float64bits(f))
}
func (e *simpleEncDriver) EncodeInt(v int64) {
@@ -91,91 +90,90 @@ func (e *simpleEncDriver) EncodeUint(v uint64) {
}
func (e *simpleEncDriver) encUint(v uint64, bd uint8) {
- if e.h.EncZeroValuesAsNil && e.c != containerMapKey && v == 0 {
+ if e.h.EncZeroValuesAsNil && e.e.c != containerMapKey && v == 0 {
e.EncodeNil()
return
}
if v <= math.MaxUint8 {
- e.w.writen2(bd, uint8(v))
+ e.e.encWr.writen2(bd, uint8(v))
} else if v <= math.MaxUint16 {
- e.w.writen1(bd + 1)
- bigenHelper{e.b[:2], e.w}.writeUint16(uint16(v))
+ e.e.encWr.writen1(bd + 1)
+ bigenHelper{e.b[:2], e.e.w()}.writeUint16(uint16(v))
} else if v <= math.MaxUint32 {
- e.w.writen1(bd + 2)
- bigenHelper{e.b[:4], e.w}.writeUint32(uint32(v))
+ e.e.encWr.writen1(bd + 2)
+ bigenHelper{e.b[:4], e.e.w()}.writeUint32(uint32(v))
} else { // if v <= math.MaxUint64 {
- e.w.writen1(bd + 3)
- bigenHelper{e.b[:8], e.w}.writeUint64(v)
+ e.e.encWr.writen1(bd + 3)
+ bigenHelper{e.b[:8], e.e.w()}.writeUint64(v)
}
}
func (e *simpleEncDriver) encLen(bd byte, length int) {
if length == 0 {
- e.w.writen1(bd)
+ e.e.encWr.writen1(bd)
} else if length <= math.MaxUint8 {
- e.w.writen1(bd + 1)
- e.w.writen1(uint8(length))
+ e.e.encWr.writen1(bd + 1)
+ e.e.encWr.writen1(uint8(length))
} else if length <= math.MaxUint16 {
- e.w.writen1(bd + 2)
- bigenHelper{e.b[:2], e.w}.writeUint16(uint16(length))
+ e.e.encWr.writen1(bd + 2)
+ bigenHelper{e.b[:2], e.e.w()}.writeUint16(uint16(length))
} else if int64(length) <= math.MaxUint32 {
- e.w.writen1(bd + 3)
- bigenHelper{e.b[:4], e.w}.writeUint32(uint32(length))
+ e.e.encWr.writen1(bd + 3)
+ bigenHelper{e.b[:4], e.e.w()}.writeUint32(uint32(length))
} else {
- e.w.writen1(bd + 4)
- bigenHelper{e.b[:8], e.w}.writeUint64(uint64(length))
+ e.e.encWr.writen1(bd + 4)
+ bigenHelper{e.b[:8], e.e.w()}.writeUint64(uint64(length))
}
}
-func (e *simpleEncDriver) EncodeExt(rv interface{}, xtag uint64, ext Ext, _ *Encoder) {
- bs := ext.WriteExt(rv)
+func (e *simpleEncDriver) EncodeExt(v interface{}, xtag uint64, ext Ext) {
+ var bs []byte
+ if ext == SelfExt {
+ bs = e.e.blist.get(1024)[:0]
+ e.e.sideEncode(v, &bs)
+ } else {
+ bs = ext.WriteExt(v)
+ }
if bs == nil {
e.EncodeNil()
return
}
e.encodeExtPreamble(uint8(xtag), len(bs))
- e.w.writeb(bs)
+ e.e.encWr.writeb(bs)
+ if ext == SelfExt {
+ e.e.blist.put(bs)
+ }
}
-func (e *simpleEncDriver) EncodeRawExt(re *RawExt, _ *Encoder) {
+func (e *simpleEncDriver) EncodeRawExt(re *RawExt) {
e.encodeExtPreamble(uint8(re.Tag), len(re.Data))
- e.w.writeb(re.Data)
+ e.e.encWr.writeb(re.Data)
}
func (e *simpleEncDriver) encodeExtPreamble(xtag byte, length int) {
e.encLen(simpleVdExt, length)
- e.w.writen1(xtag)
+ e.e.encWr.writen1(xtag)
}
func (e *simpleEncDriver) WriteArrayStart(length int) {
- e.c = containerArrayStart
e.encLen(simpleVdArray, length)
}
func (e *simpleEncDriver) WriteMapStart(length int) {
- e.c = containerMapStart
e.encLen(simpleVdMap, length)
}
-// func (e *simpleEncDriver) EncodeSymbol(v string) {
-// e.EncodeString(cUTF8, v)
-// }
-
-func (e *simpleEncDriver) EncodeStringEnc(c charEncoding, v string) {
- if false && e.h.EncZeroValuesAsNil && e.c != containerMapKey && v == "" {
+func (e *simpleEncDriver) EncodeString(v string) {
+ if e.h.EncZeroValuesAsNil && e.e.c != containerMapKey && v == "" {
e.EncodeNil()
return
}
- e.encLen(simpleVdString, len(v))
- e.w.writestr(v)
-}
-
-func (e *simpleEncDriver) EncodeString(c charEncoding, v string) {
- e.EncodeStringEnc(c, v)
-}
-
-func (e *simpleEncDriver) EncodeStringBytes(c charEncoding, v []byte) {
- e.EncodeStringBytesRaw(v)
+ if e.h.StringToRaw {
+ e.encLen(simpleVdByteArray, len(v))
+ } else {
+ e.encLen(simpleVdString, len(v))
+ }
+ e.e.encWr.writestr(v)
}
func (e *simpleEncDriver) EncodeStringBytesRaw(v []byte) {
@@ -185,7 +183,7 @@ func (e *simpleEncDriver) EncodeStringBytesRaw(v []byte) {
return
}
e.encLen(simpleVdByteArray, len(v))
- e.w.writeb(v)
+ e.e.encWr.writeb(v)
}
func (e *simpleEncDriver) EncodeTime(t time.Time) {
@@ -200,45 +198,65 @@ func (e *simpleEncDriver) EncodeTime(t time.Time) {
return
}
// time.Time marshalbinary takes about 14 bytes.
- e.w.writen2(simpleVdTime, uint8(len(v)))
- e.w.writeb(v)
+ e.e.encWr.writen2(simpleVdTime, uint8(len(v)))
+ e.e.encWr.writeb(v)
}
//------------------------------------
type simpleDecDriver struct {
- d *Decoder
h *SimpleHandle
- r *decReaderSwitch
bdRead bool
bd byte
- br bool // a bytes reader?
- c containerState
- // b [scratchByteArrayLen]byte
+ fnil bool
noBuiltInTypes
- // noStreamingCodec
decDriverNoopContainerReader
- // _ [3]uint64 // padding
+ _ [6]uint64 // padding
+ d Decoder
+}
+
+func (d *simpleDecDriver) decoder() *Decoder {
+ return &d.d
}
func (d *simpleDecDriver) readNextBd() {
- d.bd = d.r.readn1()
+ d.bd = d.d.decRd.readn1()
d.bdRead = true
}
func (d *simpleDecDriver) uncacheRead() {
if d.bdRead {
- d.r.unreadn1()
+ d.d.decRd.unreadn1()
d.bdRead = false
}
}
+func (d *simpleDecDriver) advanceNil() (null bool) {
+ d.fnil = false
+ if !d.bdRead {
+ d.readNextBd()
+ }
+ if d.bd == simpleVdNil {
+ d.bdRead = false
+ d.fnil = true
+ null = true
+ }
+ return
+}
+
+func (d *simpleDecDriver) Nil() bool {
+ return d.fnil
+}
+
func (d *simpleDecDriver) ContainerType() (vt valueType) {
if !d.bdRead {
d.readNextBd()
}
+ d.fnil = false
switch d.bd {
case simpleVdNil:
+ d.bdRead = false
+ d.fnil = true
return valueTypeNil
case simpleVdByteArray, simpleVdByteArray + 1,
simpleVdByteArray + 2, simpleVdByteArray + 3, simpleVdByteArray + 4:
@@ -252,56 +270,42 @@ func (d *simpleDecDriver) ContainerType() (vt valueType) {
case simpleVdMap, simpleVdMap + 1,
simpleVdMap + 2, simpleVdMap + 3, simpleVdMap + 4:
return valueTypeMap
- // case simpleVdTime:
- // return valueTypeTime
}
- // else {
- // d.d.errorf("isContainerType: unsupported parameter: %v", vt)
- // }
return valueTypeUnset
}
-func (d *simpleDecDriver) TryDecodeAsNil() bool {
- if !d.bdRead {
- d.readNextBd()
- }
- if d.bd == simpleVdNil {
- d.bdRead = false
- return true
- }
- return false
+func (d *simpleDecDriver) TryNil() bool {
+ return d.advanceNil()
}
func (d *simpleDecDriver) decCheckInteger() (ui uint64, neg bool) {
- if !d.bdRead {
- d.readNextBd()
- }
switch d.bd {
case simpleVdPosInt:
- ui = uint64(d.r.readn1())
+ ui = uint64(d.d.decRd.readn1())
case simpleVdPosInt + 1:
- ui = uint64(bigen.Uint16(d.r.readx(2)))
+ ui = uint64(bigen.Uint16(d.d.decRd.readx(2)))
case simpleVdPosInt + 2:
- ui = uint64(bigen.Uint32(d.r.readx(4)))
+ ui = uint64(bigen.Uint32(d.d.decRd.readx(4)))
case simpleVdPosInt + 3:
- ui = uint64(bigen.Uint64(d.r.readx(8)))
+ ui = uint64(bigen.Uint64(d.d.decRd.readx(8)))
case simpleVdNegInt:
- ui = uint64(d.r.readn1())
+ ui = uint64(d.d.decRd.readn1())
neg = true
case simpleVdNegInt + 1:
- ui = uint64(bigen.Uint16(d.r.readx(2)))
+ ui = uint64(bigen.Uint16(d.d.decRd.readx(2)))
neg = true
case simpleVdNegInt + 2:
- ui = uint64(bigen.Uint32(d.r.readx(4)))
+ ui = uint64(bigen.Uint32(d.d.decRd.readx(4)))
neg = true
case simpleVdNegInt + 3:
- ui = uint64(bigen.Uint64(d.r.readx(8)))
+ ui = uint64(bigen.Uint64(d.d.decRd.readx(8)))
neg = true
default:
d.d.errorf("integer only valid from pos/neg integer1..8. Invalid descriptor: %v", d.bd)
return
}
- // don't do this check, because callers may only want the unsigned value.
+ // DO NOT do this check below, because callers may only want the unsigned value:
+ //
// if ui > math.MaxInt64 {
// d.d.errorf("decIntAny: Integer out of range for signed int64: %v", ui)
// return
@@ -310,6 +314,9 @@ func (d *simpleDecDriver) decCheckInteger() (ui uint64, neg bool) {
}
func (d *simpleDecDriver) DecodeInt64() (i int64) {
+ if d.advanceNil() {
+ return
+ }
ui, neg := d.decCheckInteger()
i = chkOvf.SignedIntV(ui)
if neg {
@@ -320,6 +327,9 @@ func (d *simpleDecDriver) DecodeInt64() (i int64) {
}
func (d *simpleDecDriver) DecodeUint64() (ui uint64) {
+ if d.advanceNil() {
+ return
+ }
ui, neg := d.decCheckInteger()
if neg {
d.d.errorf("assigning negative signed value to unsigned type")
@@ -330,13 +340,13 @@ func (d *simpleDecDriver) DecodeUint64() (ui uint64) {
}
func (d *simpleDecDriver) DecodeFloat64() (f float64) {
- if !d.bdRead {
- d.readNextBd()
+ if d.advanceNil() {
+ return
}
if d.bd == simpleVdFloat32 {
- f = float64(math.Float32frombits(bigen.Uint32(d.r.readx(4))))
+ f = float64(math.Float32frombits(bigen.Uint32(d.d.decRd.readx(4))))
} else if d.bd == simpleVdFloat64 {
- f = math.Float64frombits(bigen.Uint64(d.r.readx(8)))
+ f = math.Float64frombits(bigen.Uint64(d.d.decRd.readx(8)))
} else {
if d.bd >= simpleVdPosInt && d.bd <= simpleVdNegInt+3 {
f = float64(d.DecodeInt64())
@@ -351,12 +361,12 @@ func (d *simpleDecDriver) DecodeFloat64() (f float64) {
// bool can be decoded from bool only (single byte).
func (d *simpleDecDriver) DecodeBool() (b bool) {
- if !d.bdRead {
- d.readNextBd()
+ if d.advanceNil() {
+ return
}
- if d.bd == simpleVdTrue {
+ if d.bd == simpleVdFalse {
+ } else if d.bd == simpleVdTrue {
b = true
- } else if d.bd == simpleVdFalse {
} else {
d.d.errorf("cannot decode bool - %s: %x", msgBadDesc, d.bd)
return
@@ -366,60 +376,38 @@ func (d *simpleDecDriver) DecodeBool() (b bool) {
}
func (d *simpleDecDriver) ReadMapStart() (length int) {
- if !d.bdRead {
- d.readNextBd()
+ if d.advanceNil() {
+ return decContainerLenNil
}
d.bdRead = false
- d.c = containerMapStart
return d.decLen()
}
func (d *simpleDecDriver) ReadArrayStart() (length int) {
- if !d.bdRead {
- d.readNextBd()
+ if d.advanceNil() {
+ return decContainerLenNil
}
d.bdRead = false
- d.c = containerArrayStart
return d.decLen()
}
-func (d *simpleDecDriver) ReadArrayElem() {
- d.c = containerArrayElem
-}
-
-func (d *simpleDecDriver) ReadArrayEnd() {
- d.c = containerArrayEnd
-}
-
-func (d *simpleDecDriver) ReadMapElemKey() {
- d.c = containerMapKey
-}
-
-func (d *simpleDecDriver) ReadMapElemValue() {
- d.c = containerMapValue
-}
-
-func (d *simpleDecDriver) ReadMapEnd() {
- d.c = containerMapEnd
-}
-
func (d *simpleDecDriver) decLen() int {
switch d.bd % 8 {
case 0:
return 0
case 1:
- return int(d.r.readn1())
+ return int(d.d.decRd.readn1())
case 2:
- return int(bigen.Uint16(d.r.readx(2)))
+ return int(bigen.Uint16(d.d.decRd.readx(2)))
case 3:
- ui := uint64(bigen.Uint32(d.r.readx(4)))
+ ui := uint64(bigen.Uint32(d.d.decRd.readx(4)))
if chkOvf.Uint(ui, intBitsize) {
d.d.errorf("overflow integer: %v", ui)
return 0
}
return int(ui)
case 4:
- ui := bigen.Uint64(d.r.readx(8))
+ ui := bigen.Uint64(d.d.decRd.readx(8))
if chkOvf.Uint(ui, intBitsize) {
d.d.errorf("overflow integer: %v", ui)
return 0
@@ -430,20 +418,12 @@ func (d *simpleDecDriver) decLen() int {
return -1
}
-func (d *simpleDecDriver) DecodeString() (s string) {
- return string(d.DecodeBytes(d.d.b[:], true))
-}
-
func (d *simpleDecDriver) DecodeStringAsBytes() (s []byte) {
return d.DecodeBytes(d.d.b[:], true)
}
func (d *simpleDecDriver) DecodeBytes(bs []byte, zerocopy bool) (bsOut []byte) {
- if !d.bdRead {
- d.readNextBd()
- }
- if d.bd == simpleVdNil {
- d.bdRead = false
+ if d.advanceNil() {
return
}
// check if an "array" of uint8's (see ContainerType for how to infer if an array)
@@ -451,28 +431,29 @@ func (d *simpleDecDriver) DecodeBytes(bs []byte, zerocopy bool) (bsOut []byte) {
if len(bs) == 0 && zerocopy {
bs = d.d.b[:]
}
- bsOut, _ = fastpathTV.DecSliceUint8V(bs, true, d.d)
- return
+ // bsOut, _ = fastpathTV.DecSliceUint8V(bs, true, d.d)
+ slen := d.ReadArrayStart()
+ bs = usableByteSlice(bs, slen)
+ for i := 0; i < len(bs); i++ {
+ bs[i] = uint8(chkOvf.UintV(d.DecodeUint64(), 8))
+ }
+ return bs
}
clen := d.decLen()
d.bdRead = false
if zerocopy {
- if d.br {
- return d.r.readx(uint(clen))
+ if d.d.bytes {
+ return d.d.decRd.readx(uint(clen))
} else if len(bs) == 0 {
bs = d.d.b[:]
}
}
- return decByteSlice(d.r, clen, d.d.h.MaxInitLen, bs)
+ return decByteSlice(d.d.r(), clen, d.d.h.MaxInitLen, bs)
}
func (d *simpleDecDriver) DecodeTime() (t time.Time) {
- if !d.bdRead {
- d.readNextBd()
- }
- if d.bd == simpleVdNil {
- d.bdRead = false
+ if d.advanceNil() {
return
}
if d.bd != simpleVdTime {
@@ -480,47 +461,48 @@ func (d *simpleDecDriver) DecodeTime() (t time.Time) {
return
}
d.bdRead = false
- clen := int(d.r.readn1())
- b := d.r.readx(uint(clen))
+ clen := int(d.d.decRd.readn1())
+ b := d.d.decRd.readx(uint(clen))
if err := (&t).UnmarshalBinary(b); err != nil {
d.d.errorv(err)
}
return
}
-func (d *simpleDecDriver) DecodeExt(rv interface{}, xtag uint64, ext Ext) (realxtag uint64) {
+func (d *simpleDecDriver) DecodeExt(rv interface{}, xtag uint64, ext Ext) {
if xtag > 0xff {
d.d.errorf("ext: tag must be <= 0xff; got: %v", xtag)
return
}
+ if d.advanceNil() {
+ return
+ }
realxtag1, xbs := d.decodeExtV(ext != nil, uint8(xtag))
- realxtag = uint64(realxtag1)
+ realxtag := uint64(realxtag1)
if ext == nil {
re := rv.(*RawExt)
re.Tag = realxtag
- re.Data = detachZeroCopyBytes(d.br, re.Data, xbs)
+ re.Data = detachZeroCopyBytes(d.d.bytes, re.Data, xbs)
+ } else if ext == SelfExt {
+ d.d.sideDecode(rv, xbs)
} else {
ext.ReadExt(rv, xbs)
}
- return
}
func (d *simpleDecDriver) decodeExtV(verifyTag bool, tag byte) (xtag byte, xbs []byte) {
- if !d.bdRead {
- d.readNextBd()
- }
switch d.bd {
case simpleVdExt, simpleVdExt + 1, simpleVdExt + 2, simpleVdExt + 3, simpleVdExt + 4:
l := d.decLen()
- xtag = d.r.readn1()
+ xtag = d.d.decRd.readn1()
if verifyTag && xtag != tag {
d.d.errorf("wrong extension tag. Got %b. Expecting: %v", xtag, tag)
return
}
- if d.br {
- xbs = d.r.readx(uint(l))
+ if d.d.bytes {
+ xbs = d.d.decRd.readx(uint(l))
} else {
- xbs = decByteSlice(d.r, l, d.d.h.MaxInitLen, d.d.b[:])
+ xbs = decByteSlice(d.d.r(), l, d.d.h.MaxInitLen, d.d.b[:])
}
case simpleVdByteArray, simpleVdByteArray + 1,
simpleVdByteArray + 2, simpleVdByteArray + 3, simpleVdByteArray + 4:
@@ -538,12 +520,14 @@ func (d *simpleDecDriver) DecodeNaked() {
d.readNextBd()
}
+ d.fnil = false
n := d.d.naked()
var decodeFurther bool
switch d.bd {
case simpleVdNil:
n.v = valueTypeNil
+ d.fnil = true
case simpleVdFalse:
n.v = valueTypeBool
n.b = false
@@ -573,19 +557,18 @@ func (d *simpleDecDriver) DecodeNaked() {
case simpleVdString, simpleVdString + 1,
simpleVdString + 2, simpleVdString + 3, simpleVdString + 4:
n.v = valueTypeString
- n.s = d.DecodeString()
+ n.s = string(d.DecodeStringAsBytes())
case simpleVdByteArray, simpleVdByteArray + 1,
simpleVdByteArray + 2, simpleVdByteArray + 3, simpleVdByteArray + 4:
- n.v = valueTypeBytes
- n.l = d.DecodeBytes(nil, false)
+ decNakedReadRawBytes(d, &d.d, n, d.h.RawToString)
case simpleVdExt, simpleVdExt + 1, simpleVdExt + 2, simpleVdExt + 3, simpleVdExt + 4:
n.v = valueTypeExt
l := d.decLen()
- n.u = uint64(d.r.readn1())
- if d.br {
- n.l = d.r.readx(uint(l))
+ n.u = uint64(d.d.decRd.readn1())
+ if d.d.bytes {
+ n.l = d.d.decRd.readx(uint(l))
} else {
- n.l = decByteSlice(d.r, l, d.d.h.MaxInitLen, d.d.b[:])
+ n.l = decByteSlice(d.d.r(), l, d.d.h.MaxInitLen, d.d.b[:])
}
case simpleVdArray, simpleVdArray + 1, simpleVdArray + 2,
simpleVdArray + 3, simpleVdArray + 4:
@@ -625,42 +608,39 @@ func (d *simpleDecDriver) DecodeNaked() {
//
// The full spec will be published soon.
type SimpleHandle struct {
- BasicHandle
binaryEncodingType
- noElemSeparators
+ BasicHandle
// EncZeroValuesAsNil says to encode zero values for numbers, bool, string, etc as nil
EncZeroValuesAsNil bool
- // _ [1]uint64 // padding
+ _ [7]uint64 // padding (cache-aligned)
}
// Name returns the name of the handle: simple
func (h *SimpleHandle) Name() string { return "simple" }
-// SetBytesExt sets an extension
-func (h *SimpleHandle) SetBytesExt(rt reflect.Type, tag uint64, ext BytesExt) (err error) {
- return h.SetExt(rt, tag, &extWrapper{ext, interfaceExtFailer{}})
-}
-
-func (h *SimpleHandle) hasElemSeparators() bool { return true } // as it implements Write(Map|Array)XXX
-
-func (h *SimpleHandle) newEncDriver(e *Encoder) encDriver {
- return &simpleEncDriver{e: e, w: e.w, h: h}
+func (h *SimpleHandle) newEncDriver() encDriver {
+ var e = &simpleEncDriver{h: h}
+ e.e.e = e
+ e.e.init(h)
+ e.reset()
+ return e
}
-func (h *SimpleHandle) newDecDriver(d *Decoder) decDriver {
- return &simpleDecDriver{d: d, h: h, r: d.r, br: d.bytes}
+func (h *SimpleHandle) newDecDriver() decDriver {
+ d := &simpleDecDriver{h: h}
+ d.d.d = d
+ d.d.init(h)
+ d.reset()
+ return d
}
func (e *simpleEncDriver) reset() {
- e.c = 0
- e.w = e.e.w
}
func (d *simpleDecDriver) reset() {
- d.c = 0
- d.r, d.br = d.d.r, d.d.bytes
d.bd, d.bdRead = 0, false
+ d.fnil = false
}
var _ decDriver = (*simpleDecDriver)(nil)
diff --git a/vendor/github.com/ugorji/go/codec/xml.go b/vendor/github.com/ugorji/go/codec/xml.go
deleted file mode 100644
index 19fc36c..0000000
--- a/vendor/github.com/ugorji/go/codec/xml.go
+++ /dev/null
@@ -1,508 +0,0 @@
-// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved.
-// Use of this source code is governed by a MIT license found in the LICENSE file.
-
-// +build ignore
-
-package codec
-
-import "reflect"
-
-/*
-
-A strict Non-validating namespace-aware XML 1.0 parser and (en|de)coder.
-
-We are attempting this due to perceived issues with encoding/xml:
- - Complicated. It tried to do too much, and is not as simple to use as json.
- - Due to over-engineering, reflection is over-used AND performance suffers:
- java is 6X faster:http://fabsk.eu/blog/category/informatique/dev/golang/
- even PYTHON performs better: http://outgoing.typepad.com/outgoing/2014/07/exploring-golang.html
-
-codec framework will offer the following benefits
- - VASTLY improved performance (when using reflection-mode or codecgen)
- - simplicity and consistency: with the rest of the supported formats
- - all other benefits of codec framework (streaming, codegeneration, etc)
-
-codec is not a drop-in replacement for encoding/xml.
-It is a replacement, based on the simplicity and performance of codec.
-Look at it like JAXB for Go.
-
-Challenges:
- - Need to output XML preamble, with all namespaces at the right location in the output.
- - Each "end" block is dynamic, so we need to maintain a context-aware stack
- - How to decide when to use an attribute VS an element
- - How to handle chardata, attr, comment EXPLICITLY.
- - Should it output fragments?
- e.g. encoding a bool should just output true OR false, which is not well-formed XML.
-
-Extend the struct tag. See representative example:
- type X struct {
- ID uint8 `codec:"http://ugorji.net/x-namespace xid id,omitempty,toarray,attr,cdata"`
- // format: [namespace-uri ][namespace-prefix ]local-name, ...
- }
-
-Based on this, we encode
- - fields as elements, BUT
- encode as attributes if struct tag contains ",attr" and is a scalar (bool, number or string)
- - text as entity-escaped text, BUT encode as CDATA if struct tag contains ",cdata".
-
-To handle namespaces:
- - XMLHandle is denoted as being namespace-aware.
- Consequently, we WILL use the ns:name pair to encode and decode if defined, else use the plain name.
- - *Encoder and *Decoder know whether the Handle "prefers" namespaces.
- - add *Encoder.getEncName(*structFieldInfo).
- No one calls *structFieldInfo.indexForEncName directly anymore
- - OR better yet: indexForEncName is namespace-aware, and helper.go is all namespace-aware
- indexForEncName takes a parameter of the form namespace:local-name OR local-name
- - add *Decoder.getStructFieldInfo(encName string) // encName here is either like abc, or h1:nsabc
- by being a method on *Decoder, or maybe a method on the Handle itself.
- No one accesses .encName anymore
- - let encode.go and decode.go use these (for consistency)
- - only problem exists for gen.go, where we create a big switch on encName.
- Now, we also have to add a switch on strings.endsWith(kName, encNsName)
- - gen.go will need to have many more methods, and then double-on the 2 switch loops like:
- switch k {
- case "abc" : x.abc()
- case "def" : x.def()
- default {
- switch {
- case !nsAware: panic(...)
- case strings.endsWith(":abc"): x.abc()
- case strings.endsWith(":def"): x.def()
- default: panic(...)
- }
- }
- }
-
-The structure below accommodates this:
-
- type typeInfo struct {
- sfi []*structFieldInfo // sorted by encName
- sfins // sorted by namespace
- sfia // sorted, to have those with attributes at the top. Needed to write XML appropriately.
- sfip // unsorted
- }
- type structFieldInfo struct {
- encName
- nsEncName
- ns string
- attr bool
- cdata bool
- }
-
-indexForEncName is now an internal helper function that takes a sorted array
-(one of ti.sfins or ti.sfi). It is only used by *Encoder.getStructFieldInfo(...)
-
-There will be a separate parser from the builder.
-The parser will have a method: next() xmlToken method. It has lookahead support,
-so you can pop multiple tokens, make a determination, and push them back in the order popped.
-This will be needed to determine whether we are "nakedly" decoding a container or not.
-The stack will be implemented using a slice and push/pop happens at the [0] element.
-
-xmlToken has fields:
- - type uint8: 0 | ElementStart | ElementEnd | AttrKey | AttrVal | Text
- - value string
- - ns string
-
-SEE: http://www.xml.com/pub/a/98/10/guide0.html?page=3#ENTDECL
-
-The following are skipped when parsing:
- - External Entities (from external file)
- - Notation Declaration e.g.
- - Entity Declarations & References
- - XML Declaration (assume UTF-8)
- - XML Directive i.e.
- - Other Declarations: Notation, etc.
- - Comment
- - Processing Instruction
- - schema / DTD for validation:
- We are not a VALIDATING parser. Validation is done elsewhere.
- However, some parts of the DTD internal subset are used (SEE BELOW).
- For Attribute List Declarations e.g.
-
- We considered using the ATTLIST to get "default" value, but not to validate the contents. (VETOED)
-
-The following XML features are supported
- - Namespace
- - Element
- - Attribute
- - cdata
- - Unicode escape
-
-The following DTD (when as an internal sub-set) features are supported:
- - Internal Entities e.g.
- AND entities for the set: [<>&"']
- - Parameter entities e.g.
-
-
-At decode time, a structure containing the following is kept
- - namespace mapping
- - default attribute values
- - all internal entities (<>&"' and others written in the document)
-
-When decode starts, it parses XML namespace declarations and creates a map in the
-xmlDecDriver. While parsing, that map continuously gets updated.
-The only problem happens when a namespace declaration happens on the node that it defines.
-e.g.
-To handle this, each Element must be fully parsed at a time,
-even if it amounts to multiple tokens which are returned one at a time on request.
-
-xmlns is a special attribute name.
- - It is used to define namespaces, including the default
- - It is never returned as an AttrKey or AttrVal.
- *We may decide later to allow user to use it e.g. you want to parse the xmlns mappings into a field.*
-
-Number, bool, null, mapKey, etc can all be decoded from any xmlToken.
-This accommodates map[int]string for example.
-
-It should be possible to create a schema from the types,
-or vice versa (generate types from schema with appropriate tags).
-This is however out-of-scope from this parsing project.
-
-We should write all namespace information at the first point that it is referenced in the tree,
-and use the mapping for all child nodes and attributes. This means that state is maintained
-at a point in the tree. This also means that calls to Decode or MustDecode will reset some state.
-
-When decoding, it is important to keep track of entity references and default attribute values.
-It seems these can only be stored in the DTD components. We should honor them when decoding.
-
-Configuration for XMLHandle will look like this:
-
- XMLHandle
- DefaultNS string
- // Encoding:
- NS map[string]string // ns URI to key, used for encoding
- // Decoding: in case ENTITY declared in external schema or dtd, store info needed here
- Entities map[string]string // map of entity rep to character
-
-
-During encode, if a namespace mapping is not defined for a namespace found on a struct,
-then we create a mapping for it using nsN (where N is 1..1000000, and doesn't conflict
-with any other namespace mapping).
-
-Note that different fields in a struct can have different namespaces.
-However, all fields will default to the namespace on the _struct field (if defined).
-
-An XML document is a name, a map of attributes and a list of children.
-Consequently, we cannot "DecodeNaked" into a map[string]interface{} (for example).
-We have to "DecodeNaked" into something that resembles XML data.
-
-To support DecodeNaked (decode into nil interface{}), we have to define some "supporting" types:
- type Name struct { // Preferred. Less allocations due to conversions.
- Local string
- Space string
- }
- type Element struct {
- Name Name
- Attrs map[Name]string
- Children []interface{} // each child is either *Element or string
- }
-Only two "supporting" types are exposed for XML: Name and Element.
-
-// ------------------
-
-We considered 'type Name string' where Name is like "Space Local" (space-separated).
-We decided against it, because each creation of a name would lead to
-double allocation (first convert []byte to string, then concatenate them into a string).
-The benefit is that it is faster to read Attrs from a map. But given that Element is a value
-object, we want to eschew methods and have public exposed variables.
-
-We also considered the following, where xml types were not value objects, and we used
-intelligent accessor methods to extract information and for performance.
-*** WE DECIDED AGAINST THIS. ***
- type Attr struct {
- Name Name
- Value string
- }
- // Element is a ValueObject: There are no accessor methods.
- // Make element self-contained.
- type Element struct {
- Name Name
- attrsMap map[string]string // where key is "Space Local"
- attrs []Attr
- childrenT []string
- childrenE []Element
- childrenI []int // each child is a index into T or E.
- }
- func (x *Element) child(i) interface{} // returns string or *Element
-
-// ------------------
-
-Per XML spec and our default handling, white space is always treated as
-insignificant between elements, except in a text node. The xml:space='preserve'
-attribute is ignored.
-
-**Note: there is no xml: namespace. The xml: attributes were defined before namespaces.**
-**So treat them as just "directives" that should be interpreted to mean something**.
-
-On encoding, we support indenting aka prettifying markup in the same way we support it for json.
-
-A document or element can only be encoded/decoded from/to a struct. In this mode:
- - struct name maps to element name (or tag-info from _struct field)
- - fields are mapped to child elements or attributes
-
-A map is either encoded as attributes on current element, or as a set of child elements.
-Maps are encoded as attributes iff their keys and values are primitives (number, bool, string).
-
-A list is encoded as a set of child elements.
-
-Primitives (number, bool, string) are encoded as an element, attribute or text
-depending on the context.
-
-Extensions must encode themselves as a text string.
-
-Encoding is tough, specifically when encoding mappings, because we need to encode
-as either attribute or element. To do this, we need to default to encoding as attributes,
-and then let Encoder inform the Handle when to start encoding as nodes.
-i.e. Encoder does something like:
-
- h.EncodeMapStart()
- h.Encode(), h.Encode(), ...
- h.EncodeMapNotAttrSignal() // this is not a bool, because it's a signal
- h.Encode(), h.Encode(), ...
- h.EncodeEnd()
-
-Only XMLHandle understands this, and will set itself to start encoding as elements.
-
-This support extends to maps. For example, if a struct field is a map, and it has
-the struct tag signifying it should be attr, then all its fields are encoded as attributes.
-e.g.
-
- type X struct {
- M map[string]int `codec:"m,attr"` // encode keys as attributes named
- }
-
-Question:
- - if encoding a map, what if map keys have spaces in them???
- Then they cannot be attributes or child elements. Error.
-
-Options to consider adding later:
- - For attribute values, normalize by trimming beginning and ending white space,
- and converting every white space sequence to a single space.
- - ATTLIST restrictions are enforced.
- e.g. default value of xml:space, skipping xml:XYZ style attributes, etc.
- - Consider supporting NON-STRICT mode (e.g. to handle HTML parsing).
- Some elements e.g. br, hr, etc need not close and should be auto-closed
- ... (see http://www.w3.org/TR/html4/loose.dtd)
- An expansive set of entities are pre-defined.
- - Have easy way to create a HTML parser:
- add a HTML() method to XMLHandle, that will set Strict=false, specify AutoClose,
- and add HTML Entities to the list.
- - Support validating element/attribute XMLName before writing it.
- Keep this behind a flag, which is set to false by default (for performance).
- type XMLHandle struct {
- CheckName bool
- }
-
-Misc:
-
-ROADMAP (1 weeks):
- - build encoder (1 day)
- - build decoder (based off xmlParser) (1 day)
- - implement xmlParser (2 days).
- Look at encoding/xml for inspiration.
- - integrate and TEST (1 days)
- - write article and post it (1 day)
-
-// ---------- MORE NOTES FROM 2017-11-30 ------------
-
-when parsing
-- parse the attributes first
-- then parse the nodes
-
-basically:
-- if encoding a field: we use the field name for the wrapper
-- if encoding a non-field, then just use the element type name
-
- map[string]string ==> ... or
- ... OR
- val1val2... <- PREFERED
- []string ==> v1v2...
- string v1 ==> v1
- bool true ==> true
- float 1.0 ==> 1.0
- ...
-
- F1 map[string]string ==> abcval... OR
- val... OR
- val... <- PREFERED
- F2 []string ==> v1v2...
- F3 bool ==> true
- ...
-
-- a scalar is encoded as:
- (value) of type T ==>
- (value) of field F ==>
-- A kv-pair is encoded as:
- (key,value) ==> OR