diff --git a/baas-kubeengine/go.mod b/baas-kubeengine/go.mod
index 7f90cce9..bc40ab30 100644
--- a/baas-kubeengine/go.mod
+++ b/baas-kubeengine/go.mod
@@ -5,7 +5,7 @@ go 1.12
require (
github.com/fsnotify/fsnotify v1.4.7
github.com/gin-contrib/sessions v0.0.0-20190512062852-3cb4c4f2d615 // indirect
- github.com/gin-gonic/gin v1.4.0
+ github.com/gin-gonic/gin v1.7.0
github.com/jonluo94/baasmanager/baas-core v0.0.0
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 // indirect
github.com/spf13/viper v1.4.0
diff --git a/baas-kubeengine/go.sum b/baas-kubeengine/go.sum
index 08e56fab..003a89ce 100644
--- a/baas-kubeengine/go.sum
+++ b/baas-kubeengine/go.sum
@@ -1,6 +1,7 @@
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
github.com/Azure/go-autorest v11.1.2+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24=
+github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
@@ -33,14 +34,24 @@ github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMo
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/gin-contrib/sessions v0.0.0-20190512062852-3cb4c4f2d615 h1:2KRlm9Qh15+8BjkbOCcZtfC7aFVQd2mELjpHjrDmv1s=
github.com/gin-contrib/sessions v0.0.0-20190512062852-3cb4c4f2d615/go.mod h1:iziXm/6pvTtf7og1uxT499sel4h3S9DfwsrhNZ+REXM=
-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.4.0 h1:3tMoCCfM7ppqsR0ptz/wi1impNpT7/9wQtMZ8lr1mCQ=
+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.4.0/go.mod h1:OW2EZn3DO8Ln9oIKOvM++LBO+5UPHJJDH72/q/3rZdM=
+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/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q=
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
+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-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/gogo/protobuf v0.0.0-20171007142547-342cbe0a0415/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/gogo/protobuf v1.0.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
@@ -52,12 +63,14 @@ github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4er
github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
-github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg=
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/gomodule/redigo v2.0.0+incompatible/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4=
github.com/google/btree v0.0.0-20160524151835-7d79101e329e/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
+github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI=
github.com/google/gofuzz v1.0.0 h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw=
@@ -86,29 +99,36 @@ github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpO
github.com/imdario/mergo v0.3.5 h1:JboBksRwiiAJWvIYJVo46AfV+IAIKZpfrSzVKj42R4Q=
github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
-github.com/jonluo94/baasmanager v0.0.0-20190702074040-8270d0630ac5 h1:bN8oWr/tAl0Aj3cQ1ld7WIunkrKyWgI5yvg0hjpfsXg=
github.com/json-iterator/go v0.0.0-20180701071628-ab8a2e0c74be/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
-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/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
github.com/kidstuff/mongostore v0.0.0-20181113001930-e650cd85ee4b/go.mod h1:g2nVr8KZVXJSS97Jo8pJ0jgq29P6H7dG0oplUA86MQw=
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
+github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
+github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
+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/magiconair/properties v1.8.0 h1:LLgXmsheXeRoUOBOjtwPQCWIYqM/LU1ayDtDePerRcY=
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
-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/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
+github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/memcachier/mc v2.0.1+incompatible/go.mod h1:7bkvFE61leUBvXz+yxsOnGBQSZpBSPIMUQSmmSHvuXc=
github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE=
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
+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/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
@@ -124,6 +144,7 @@ github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
+github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso=
@@ -155,9 +176,14 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
+github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
+github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
-github.com/ugorji/go v1.1.4 h1:j4s+tAvLfL3bZyefP2SEWmhBzmuIlH/eqNuPdFPgngw=
github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=
+github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo=
+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=
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
@@ -166,8 +192,9 @@ go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20181025213731-e84da0312774/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
-golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M=
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/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
@@ -178,6 +205,7 @@ golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73r
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190206173232-65e2d4e15006/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
+golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/net v0.0.0-20190613194153-d28f0bde5980 h1:dfGZHvZk057jK2MCeWus/TowKpJ8y4AmooUzdBSR9GU=
@@ -196,8 +224,10 @@ golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5h
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f h1:25KHgbfyiSm6vwQLbM3zZIe1v9p/3ea4Rz+nnM5K/i4=
+golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f/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=
golang.org/x/text v0.3.1-0.20181227161524-e6919f6577db/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
@@ -218,10 +248,10 @@ google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZi
google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
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/inf.v0 v0.9.0 h1:3zYtXIO92bvsdS3ggAdA8Gb4Azj0YU+TVY1uGYNFA8o=
gopkg.in/inf.v0 v0.9.0/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
@@ -229,8 +259,9 @@ gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
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=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
k8s.io/api v0.0.0-20190620084959-7cf5895f2711/go.mod h1:TBhBqb1AWbBQbW3XRusr7n7E4v2+5ZY8r8sAMnyFC5A=
k8s.io/api v0.0.0-20190703205437-39734b2a72fe h1:MFaHtAyhZcfBZocN91muHSqnwiF5yfXx7yGoehneNYg=
diff --git a/baas-kubeengine/vendor/github.com/gin-contrib/sse/go.mod b/baas-kubeengine/vendor/github.com/gin-contrib/sse/go.mod
new file mode 100644
index 00000000..b9c03f47
--- /dev/null
+++ b/baas-kubeengine/vendor/github.com/gin-contrib/sse/go.mod
@@ -0,0 +1,5 @@
+module github.com/gin-contrib/sse
+
+go 1.12
+
+require github.com/stretchr/testify v1.3.0
diff --git a/baas-kubeengine/vendor/github.com/gin-contrib/sse/go.sum b/baas-kubeengine/vendor/github.com/gin-contrib/sse/go.sum
new file mode 100644
index 00000000..4347755a
--- /dev/null
+++ b/baas-kubeengine/vendor/github.com/gin-contrib/sse/go.sum
@@ -0,0 +1,7 @@
+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/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
+github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+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=
diff --git a/baas-kubeengine/vendor/github.com/gin-gonic/gin/.travis.yml b/baas-kubeengine/vendor/github.com/gin-gonic/gin/.travis.yml
index f6ec8a82..8ebae712 100644
--- a/baas-kubeengine/vendor/github.com/gin-gonic/gin/.travis.yml
+++ b/baas-kubeengine/vendor/github.com/gin-gonic/gin/.travis.yml
@@ -3,15 +3,21 @@ language: go
matrix:
fast_finish: true
include:
- - go: 1.8.x
- - go: 1.9.x
- - go: 1.10.x
- - go: 1.11.x
- env: GO111MODULE=on
- 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
- env: GO111MODULE=on
git:
depth: 10
@@ -20,7 +26,7 @@ before_install:
- if [[ "${GO111MODULE}" = "on" ]]; then mkdir "${HOME}/go"; export GOPATH="${HOME}/go"; fi
install:
- - if [[ "${GO111MODULE}" = "on" ]]; then go mod download; else make install; fi
+ - 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
diff --git a/baas-kubeengine/vendor/github.com/gin-gonic/gin/AUTHORS.md b/baas-kubeengine/vendor/github.com/gin-gonic/gin/AUTHORS.md
index dda19bcf..c634e6be 100644
--- a/baas-kubeengine/vendor/github.com/gin-gonic/gin/AUTHORS.md
+++ b/baas-kubeengine/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/baas-kubeengine/vendor/github.com/gin-gonic/gin/BENCHMARKS.md b/baas-kubeengine/vendor/github.com/gin-gonic/gin/BENCHMARKS.md
index 9a7df86a..c11ee99a 100644
--- a/baas-kubeengine/vendor/github.com/gin-gonic/gin/BENCHMARKS.md
+++ b/baas-kubeengine/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/baas-kubeengine/vendor/github.com/gin-gonic/gin/CHANGELOG.md b/baas-kubeengine/vendor/github.com/gin-gonic/gin/CHANGELOG.md
index 8ea2495d..44d62514 100644
--- a/baas-kubeengine/vendor/github.com/gin-gonic/gin/CHANGELOG.md
+++ b/baas-kubeengine/vendor/github.com/gin-gonic/gin/CHANGELOG.md
@@ -1,8 +1,145 @@
-
-### Gin 1.4.0
+# Gin ChangeLog
+
+## 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 requesta [#1829](https://github.com/gin-gonic/gin/pull/1829)
+- [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)
@@ -15,7 +152,7 @@
- [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-dispositon attachments via a new method context.Attachment [#1260](https://github.com/gin-gonic/gin/pull/1260)
+- [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)
@@ -56,7 +193,7 @@
- [NEW] Upgrade dependency libraries [#1491](https://github.com/gin-gonic/gin/pull/1491)
-### Gin 1.3.0
+## 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)
@@ -78,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
@@ -101,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
@@ -154,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
@@ -162,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
@@ -198,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
@@ -208,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
@@ -224,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
@@ -242,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
@@ -254,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/baas-kubeengine/vendor/github.com/gin-gonic/gin/CONTRIBUTING.md b/baas-kubeengine/vendor/github.com/gin-gonic/gin/CONTRIBUTING.md
index 547b777a..97daa808 100644
--- a/baas-kubeengine/vendor/github.com/gin-gonic/gin/CONTRIBUTING.md
+++ b/baas-kubeengine/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/baas-kubeengine/vendor/github.com/gin-gonic/gin/Makefile b/baas-kubeengine/vendor/github.com/gin-gonic/gin/Makefile
index 51a6b916..1a991939 100644
--- a/baas-kubeengine/vendor/github.com/gin-gonic/gin/Makefile
+++ b/baas-kubeengine/vendor/github.com/gin-gonic/gin/Makefile
@@ -1,20 +1,16 @@
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/*")
+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)
-
-all: install
-
-install: deps
- govendor sync
+TESTTAGS ?= ""
.PHONY: test
test:
echo "mode: count" > coverage.out
for d in $(TESTFOLDER); do \
- $(GO) test -v -covermode=count -coverprofile=profile.out $$d > tmp.out; \
+ $(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; \
@@ -48,11 +44,6 @@ fmt-check:
vet:
$(GO) vet $(VETPACKAGES)
-deps:
- @hash govendor > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
- $(GO) get -u github.com/kardianos/govendor; \
- fi
-
.PHONY: lint
lint:
@hash golint > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
diff --git a/baas-kubeengine/vendor/github.com/gin-gonic/gin/README.md b/baas-kubeengine/vendor/github.com/gin-gonic/gin/README.md
index 3e817a78..d4772d76 100644
--- a/baas-kubeengine/vendor/github.com/gin-gonic/gin/README.md
+++ b/baas-kubeengine/vendor/github.com/gin-gonic/gin/README.md
@@ -5,48 +5,61 @@
[![Build Status](https://travis-ci.org/gin-gonic/gin.svg)](https://travis-ci.org/gin-gonic/gin)
[![codecov](https://codecov.io/gh/gin-gonic/gin/branch/master/graph/badge.svg)](https://codecov.io/gh/gin-gonic/gin)
[![Go Report Card](https://goreportcard.com/badge/github.com/gin-gonic/gin)](https://goreportcard.com/report/github.com/gin-gonic/gin)
-[![GoDoc](https://godoc.org/github.com/gin-gonic/gin?status.svg)](https://godoc.org/github.com/gin-gonic/gin)
+[![GoDoc](https://pkg.go.dev/badge/github.com/gin-gonic/gin?status.svg)](https://pkg.go.dev/github.com/gin-gonic/gin?tab=doc)
[![Join the chat at https://gitter.im/gin-gonic/gin](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/gin-gonic/gin?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Sourcegraph](https://sourcegraph.com/github.com/gin-gonic/gin/-/badge.svg)](https://sourcegraph.com/github.com/gin-gonic/gin?badge)
[![Open Source Helpers](https://www.codetriage.com/gin-gonic/gin/badges/users.svg)](https://www.codetriage.com/gin-gonic/gin)
[![Release](https://img.shields.io/github/release/gin-gonic/gin.svg?style=flat-square)](https://github.com/gin-gonic/gin/releases)
+[![TODOs](https://badgen.net/https/api.tickgit.com/badgen/github.com/gin-gonic/gin)](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, YAML and ProtoBuf rendering](#xml-json-yaml-and-protobuf-rendering)
- - [JSONP rendering](#jsonp)
+ - [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)
@@ -55,21 +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)
- [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)
+ - [Testing](#testing)
+ - [Users](#users)
## Installation
To install Gin package, you need to install Go and set your Go workspace first.
-1. The first need [Go](https://golang.org/) installed (**version 1.8+ is required**), then you can use the below Go command to install Gin.
+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
@@ -87,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.3
-```
-
-4. Copy a starting template inside your project
-
-```sh
-$ curl https://raw.githubusercontent.com/gin-gonic/examples/master/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
@@ -142,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
```
@@ -157,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
@@ -196,8 +178,8 @@ 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)
@@ -256,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")
}
```
@@ -353,7 +347,7 @@ 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
@@ -370,14 +364,14 @@ References issue [#774](https://github.com/gin-gonic/gin/issues/774) and detail
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))
})
@@ -401,7 +395,7 @@ See the detail [example code](https://github.com/gin-gonic/examples/tree/master/
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()
@@ -411,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)))
})
@@ -509,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() {
@@ -568,44 +595,44 @@ func main() {
::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
+### Controlling Log output coloring
By default, logs output on console should be colorized depending on the detected TTY.
-Never colorize logs:
+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:
+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")
}
```
@@ -614,16 +641,16 @@ func main() {
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`, `BindXML`, `BindQuery`, `BindYAML`
+ - **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`, `ShouldBindXML`, `ShouldBindQuery`, `ShouldBindYAML`
+ - **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`.
@@ -647,12 +674,12 @@ func main() {
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"})
})
@@ -668,12 +695,12 @@ func main() {
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"})
})
@@ -685,12 +712,12 @@ func main() {
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"})
})
@@ -734,12 +761,11 @@ 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.
@@ -748,13 +774,11 @@ type Booking struct {
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
}
}
@@ -783,11 +807,14 @@ 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 registered this way.
@@ -844,9 +871,11 @@ import (
)
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() {
@@ -860,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")
}
@@ -872,7 +903,7 @@ 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
@@ -909,6 +940,43 @@ $ 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
See the [detail information](https://github.com/gin-gonic/gin/issues/129#issuecomment-124260092)
@@ -958,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")
}
@@ -991,7 +1063,7 @@ 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, YAML and ProtoBuf rendering
@@ -1076,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)
@@ -1088,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": "
",
}
@@ -1122,21 +1197,21 @@ 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")
}
@@ -1156,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
@@ -1169,6 +1262,7 @@ func main() {
}
reader := response.Body
+ defer reader.Close()
contentLength := response.ContentLength
contentType := response.Header.Get("Content-Type")
@@ -1309,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),
})
})
@@ -1344,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.
@@ -1622,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 {
@@ -1635,12 +1743,13 @@ func main() {
}
```
-### Graceful restart or stop
+### Graceful shutdown or restart
-Do you want to graceful restart or stop your web server?
-There are some ways this can be done.
+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.
-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.
+#### Third-party packages
+
+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()
@@ -1649,13 +1758,15 @@ 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](https://github.com/gin-gonic/examples/tree/master/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).
```go
// +build go1.8
@@ -1686,10 +1797,11 @@ 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)
}
}()
@@ -1698,21 +1810,20 @@ func main() {
quit := make(chan os.Signal)
// 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
+ // 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)
- }
- // catching ctx.Done(). timeout of 5 seconds.
- select {
- case <-ctx.Done():
- log.Println("timeout of 5 seconds.")
+ log.Fatal("Server forced to shutdown:", err)
}
+
log.Println("Server exiting")
}
```
@@ -1743,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
}
@@ -2012,6 +2124,39 @@ func main() {
}
```
+## 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
@@ -2068,3 +2213,5 @@ Awesome project lists using [Gin](https://github.com/gin-gonic/gin) web framewor
* [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/baas-kubeengine/vendor/github.com/gin-gonic/gin/auth.go b/baas-kubeengine/vendor/github.com/gin-gonic/gin/auth.go
index 9ed81b5d..4d8a6ce4 100644
--- a/baas-kubeengine/vendor/github.com/gin-gonic/gin/auth.go
+++ b/baas-kubeengine/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/baas-kubeengine/vendor/github.com/gin-gonic/gin/binding/binding.go b/baas-kubeengine/vendor/github.com/gin-gonic/gin/binding/binding.go
index 520c5109..5caeb581 100644
--- a/baas-kubeengine/vendor/github.com/gin-gonic/gin/binding/binding.go
+++ b/baas-kubeengine/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"
@@ -49,7 +52,8 @@ type BindingUri interface {
// 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.
@@ -78,12 +82,13 @@ var (
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
}
diff --git a/baas-kubeengine/vendor/github.com/gin-gonic/gin/binding/binding_nomsgpack.go b/baas-kubeengine/vendor/github.com/gin-gonic/gin/binding/binding_nomsgpack.go
new file mode 100644
index 00000000..9afa3dcf
--- /dev/null
+++ b/baas-kubeengine/vendor/github.com/gin-gonic/gin/binding/binding_nomsgpack.go
@@ -0,0 +1,112 @@
+// Copyright 2020 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.
+
+//go:build nomsgpack
+// +build nomsgpack
+
+package binding
+
+import "net/http"
+
+// Content-Type MIME of the most common data formats.
+const (
+ MIMEJSON = "application/json"
+ MIMEHTML = "text/html"
+ MIMEXML = "application/xml"
+ MIMEXML2 = "text/xml"
+ MIMEPlain = "text/plain"
+ MIMEPOSTForm = "application/x-www-form-urlencoded"
+ MIMEMultipartPOSTForm = "multipart/form-data"
+ MIMEPROTOBUF = "application/x-protobuf"
+ MIMEYAML = "application/x-yaml"
+)
+
+// Binding describes the interface which needs to be implemented for binding the
+// data present in the request such as JSON request body, query parameters or
+// the form POST.
+type Binding interface {
+ Name() string
+ Bind(*http.Request, interface{}) error
+}
+
+// BindingBody adds BindBody method to Binding. BindBody is similar with Bind,
+// but it reads the body from supplied bytes instead of req.Body.
+type BindingBody interface {
+ Binding
+ 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 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 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.
+ ValidateStruct(interface{}) error
+
+ // Engine returns the underlying validator engine which powers the
+ // StructValidator implementation.
+ Engine() interface{}
+}
+
+// Validator is the default validator which implements the StructValidator
+// interface. It uses https://github.com/go-playground/validator/tree/v8.18.2
+// under the hood.
+var Validator StructValidator = &defaultValidator{}
+
+// These implement the Binding interface and can be used to bind the data
+// present in the request to struct instances.
+var (
+ JSON = jsonBinding{}
+ XML = xmlBinding{}
+ Form = formBinding{}
+ Query = queryBinding{}
+ FormPost = formPostBinding{}
+ FormMultipart = formMultipartBinding{}
+ ProtoBuf = protobufBinding{}
+ 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" {
+ return Form
+ }
+
+ switch contentType {
+ case MIMEJSON:
+ return JSON
+ case MIMEXML, MIMEXML2:
+ return XML
+ case MIMEPROTOBUF:
+ return ProtoBuf
+ case MIMEYAML:
+ return YAML
+ case MIMEMultipartPOSTForm:
+ return FormMultipart
+ default: // case MIMEPOSTForm:
+ return Form
+ }
+}
+
+func validate(obj interface{}) error {
+ if Validator == nil {
+ return nil
+ }
+ return Validator.ValidateStruct(obj)
+}
diff --git a/baas-kubeengine/vendor/github.com/gin-gonic/gin/binding/default_validator.go b/baas-kubeengine/vendor/github.com/gin-gonic/gin/binding/default_validator.go
index e7a302de..c57a120f 100644
--- a/baas-kubeengine/vendor/github.com/gin-gonic/gin/binding/default_validator.go
+++ b/baas-kubeengine/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/baas-kubeengine/vendor/github.com/gin-gonic/gin/binding/form.go b/baas-kubeengine/vendor/github.com/gin-gonic/gin/binding/form.go
index 0b28aa8a..b93c34cf 100644
--- a/baas-kubeengine/vendor/github.com/gin-gonic/gin/binding/form.go
+++ b/baas-kubeengine/vendor/github.com/gin-gonic/gin/binding/form.go
@@ -5,12 +5,10 @@
package binding
import (
- "mime/multipart"
"net/http"
- "reflect"
)
-const defaultMemory = 32 * 1024 * 1024
+const defaultMemory = 32 << 20
type formBinding struct{}
type formPostBinding struct{}
@@ -63,27 +61,3 @@ func (formMultipartBinding) Bind(req *http.Request, obj interface{}) error {
return validate(obj)
}
-
-type multipartRequest http.Request
-
-var _ setter = (*multipartRequest)(nil)
-
-var (
- multipartFileHeaderStructType = reflect.TypeOf(multipart.FileHeader{})
-)
-
-// TrySet tries to set a value by the multipart request with the binding a form file
-func (r *multipartRequest) TrySet(value reflect.Value, field reflect.StructField, key string, opt setOptions) (isSetted bool, err error) {
- if value.Type() == multipartFileHeaderStructType {
- _, file, err := (*http.Request)(r).FormFile(key)
- if err != nil {
- return false, err
- }
- if file != nil {
- value.Set(reflect.ValueOf(*file))
- return true, nil
- }
- }
-
- return setByForm(value, field, r.MultipartForm.Value, key, opt)
-}
diff --git a/baas-kubeengine/vendor/github.com/gin-gonic/gin/binding/form_mapping.go b/baas-kubeengine/vendor/github.com/gin-gonic/gin/binding/form_mapping.go
index aaacf6c5..2f4e45b4 100644
--- a/baas-kubeengine/vendor/github.com/gin-gonic/gin/binding/form_mapping.go
+++ b/baas-kubeengine/vendor/github.com/gin-gonic/gin/binding/form_mapping.go
@@ -12,10 +12,11 @@ import (
"strings"
"time"
+ "github.com/gin-gonic/gin/internal/bytesconv"
"github.com/gin-gonic/gin/internal/json"
)
-var errUnknownType = errors.New("Unknown type")
+var errUnknownType = errors.New("unknown type")
func mapUri(ptr interface{}, m map[string][]string) error {
return mapFormByTag(ptr, m, "uri")
@@ -28,6 +29,21 @@ func mapForm(ptr interface{}, form map[string][]string) error {
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
+ }
+ return setFormMap(ptr, form)
+ }
+
return mappingByPtr(ptr, formSource(form), tag)
}
@@ -51,6 +67,10 @@ func mappingByPtr(ptr interface{}, setter setter, tag string) error {
}
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 {
@@ -70,12 +90,14 @@ func mapping(value reflect.Value, field reflect.StructField, setter setter, tag
return isSetted, nil
}
- ok, err := tryToSetValue(value, field, setter, tag)
- if err != nil {
- return false, err
- }
- if ok {
- return true, nil
+ 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 {
@@ -83,7 +105,8 @@ func mapping(value reflect.Value, field reflect.StructField, setter setter, tag
var isSetted bool
for i := 0; i < value.NumField(); i++ {
- if !value.Field(i).CanSet() {
+ sf := tValue.Field(i)
+ if sf.PkgPath != "" && !sf.Anonymous { // unexported
continue
}
ok, err := mapping(value.Field(i), tValue.Field(i), setter, tag)
@@ -109,9 +132,6 @@ func tryToSetValue(value reflect.Value, field reflect.StructField, setter setter
tagValue = field.Tag.Get(tag)
tagValue, opts := head(tagValue, ",")
- if tagValue == "-" { // just ignoring this field
- return false, nil
- }
if tagValue == "" { // default value is FieldName
tagValue = field.Name
}
@@ -123,9 +143,7 @@ func tryToSetValue(value reflect.Value, field reflect.StructField, setter setter
for len(opts) > 0 {
opt, opts = head(opts, ",")
- k, v := head(opt, "=")
- switch k {
- case "default":
+ if k, v := head(opt, "="); k == "default" {
setOpt.isDefaultExists = true
setOpt.defaultValue = v
}
@@ -206,9 +224,9 @@ func setWithProperType(val string, value reflect.Value, field reflect.StructFiel
case time.Time:
return setTimeField(val, field, value)
}
- return json.Unmarshal([]byte(val), value.Addr().Interface())
+ return json.Unmarshal(bytesconv.StringToBytes(val), value.Addr().Interface())
case reflect.Map:
- return json.Unmarshal([]byte(val), value.Addr().Interface())
+ return json.Unmarshal(bytesconv.StringToBytes(val), value.Addr().Interface())
default:
return errUnknownType
}
@@ -265,6 +283,24 @@ func setTimeField(val string, structField reflect.StructField, value reflect.Val
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 == "" {
value.Set(reflect.ValueOf(time.Time{}))
return nil
@@ -328,3 +364,29 @@ func head(str, sep string) (head string, tail string) {
}
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/baas-kubeengine/vendor/github.com/gin-gonic/gin/binding/header.go b/baas-kubeengine/vendor/github.com/gin-gonic/gin/binding/header.go
new file mode 100644
index 00000000..179ce4ea
--- /dev/null
+++ b/baas-kubeengine/vendor/github.com/gin-gonic/gin/binding/header.go
@@ -0,0 +1,34 @@
+package binding
+
+import (
+ "net/http"
+ "net/textproto"
+ "reflect"
+)
+
+type headerBinding struct{}
+
+func (headerBinding) Name() string {
+ return "header"
+}
+
+func (headerBinding) Bind(req *http.Request, obj interface{}) error {
+
+ if err := mapHeader(obj, req.Header); err != nil {
+ return err
+ }
+
+ return validate(obj)
+}
+
+func mapHeader(ptr interface{}, h map[string][]string) error {
+ return mappingByPtr(ptr, headerSource(h), "header")
+}
+
+type headerSource map[string][]string
+
+var _ setter = headerSource(nil)
+
+func (hs headerSource) TrySet(value reflect.Value, field reflect.StructField, tagValue string, opt setOptions) (isSetted bool, err error) {
+ return setByForm(value, field, hs, textproto.CanonicalMIMEHeaderKey(tagValue), opt)
+}
diff --git a/baas-kubeengine/vendor/github.com/gin-gonic/gin/binding/json.go b/baas-kubeengine/vendor/github.com/gin-gonic/gin/binding/json.go
index f968161b..d62e0705 100644
--- a/baas-kubeengine/vendor/github.com/gin-gonic/gin/binding/json.go
+++ b/baas-kubeengine/vendor/github.com/gin-gonic/gin/binding/json.go
@@ -18,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 {
@@ -40,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/baas-kubeengine/vendor/github.com/gin-gonic/gin/binding/msgpack.go b/baas-kubeengine/vendor/github.com/gin-gonic/gin/binding/msgpack.go
index b7f73197..2a442996 100644
--- a/baas-kubeengine/vendor/github.com/gin-gonic/gin/binding/msgpack.go
+++ b/baas-kubeengine/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/baas-kubeengine/vendor/github.com/gin-gonic/gin/binding/multipart_form_mapping.go b/baas-kubeengine/vendor/github.com/gin-gonic/gin/binding/multipart_form_mapping.go
new file mode 100644
index 00000000..f85a1aa6
--- /dev/null
+++ b/baas-kubeengine/vendor/github.com/gin-gonic/gin/binding/multipart_form_mapping.go
@@ -0,0 +1,66 @@
+// Copyright 2019 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 binding
+
+import (
+ "errors"
+ "mime/multipart"
+ "net/http"
+ "reflect"
+)
+
+type multipartRequest http.Request
+
+var _ setter = (*multipartRequest)(nil)
+
+// TrySet tries to set a value by the multipart request with the binding a form file
+func (r *multipartRequest) TrySet(value reflect.Value, field reflect.StructField, key string, opt setOptions) (isSetted bool, err error) {
+ if files := r.MultipartForm.File[key]; len(files) != 0 {
+ return setByMultipartFormFile(value, field, files)
+ }
+
+ return setByForm(value, field, r.MultipartForm.Value, key, opt)
+}
+
+func setByMultipartFormFile(value reflect.Value, field reflect.StructField, files []*multipart.FileHeader) (isSetted bool, err error) {
+ switch value.Kind() {
+ case reflect.Ptr:
+ switch value.Interface().(type) {
+ case *multipart.FileHeader:
+ value.Set(reflect.ValueOf(files[0]))
+ return true, nil
+ }
+ case reflect.Struct:
+ switch value.Interface().(type) {
+ case multipart.FileHeader:
+ value.Set(reflect.ValueOf(*files[0]))
+ return true, nil
+ }
+ case reflect.Slice:
+ slice := reflect.MakeSlice(value.Type(), len(files), len(files))
+ isSetted, err = setArrayOfMultipartFormFiles(slice, field, files)
+ if err != nil || !isSetted {
+ return isSetted, err
+ }
+ value.Set(slice)
+ return true, nil
+ case reflect.Array:
+ return setArrayOfMultipartFormFiles(value, field, files)
+ }
+ return false, errors.New("unsupported field type for multipart.FileHeader")
+}
+
+func setArrayOfMultipartFormFiles(value reflect.Value, field reflect.StructField, files []*multipart.FileHeader) (isSetted bool, err error) {
+ if value.Len() != len(files) {
+ return false, errors.New("unsupported len of array for []*multipart.FileHeader")
+ }
+ for i := range files {
+ setted, err := setByMultipartFormFile(value.Index(i), field, files[i:i+1])
+ if err != nil || !setted {
+ return setted, err
+ }
+ }
+ return true, nil
+}
diff --git a/baas-kubeengine/vendor/github.com/gin-gonic/gin/context.go b/baas-kubeengine/vendor/github.com/gin-gonic/gin/context.go
index af747a1e..1ba0fa2b 100644
--- a/baas-kubeengine/vendor/github.com/gin-gonic/gin/context.go
+++ b/baas-kubeengine/vendor/github.com/gin-gonic/gin/context.go
@@ -16,6 +16,7 @@ import (
"net/url"
"os"
"strings"
+ "sync"
"time"
"github.com/gin-contrib/sse"
@@ -33,9 +34,11 @@ const (
MIMEPOSTForm = binding.MIMEPOSTForm
MIMEMultipartPOSTForm = binding.MIMEMultipartPOSTForm
MIMEYAML = binding.MIMEYAML
- BodyBytesKey = "_gin-gonic/gin/bodybyteskey"
)
+// 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,
@@ -48,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{}
@@ -59,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
}
/************************************/
@@ -70,15 +89,25 @@ 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
@@ -87,6 +116,9 @@ func (c *Context) Copy() *Context {
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
}
@@ -111,6 +143,15 @@ 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 ***********/
/************************************/
@@ -196,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
}
@@ -249,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 {
@@ -368,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
@@ -386,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
@@ -427,16 +501,24 @@ 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
- if err := req.ParseMultipartForm(c.engine.MaxMultipartMemory); err != nil {
- if err != http.ErrNotMultipart {
- debugPrint("error on parse multipart form array: %v", err)
- }
- }
- if values := req.PostForm[key]; len(values) > 0 {
+ c.initFormCache()
+ if values := c.formCache[key]; len(values) > 0 {
return values, true
}
return []string{}, false
@@ -451,13 +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
- if err := req.ParseMultipartForm(c.engine.MaxMultipartMemory); err != nil {
- if err != http.ErrNotMultipart {
- debugPrint("error on parse multipart form map: %v", err)
- }
- }
- return c.get(req.PostForm, key)
+ c.initFormCache()
+ return c.get(c.formCache, key)
}
// get is an internal method and returns a map which satisfy conditions.
@@ -482,7 +559,11 @@ func (c *Context) FormFile(name string) (*multipart.FileHeader, error) {
return nil, err
}
}
- _, fh, err := c.Request.FormFile(name)
+ f, fh, err := c.Request.FormFile(name)
+ if err != nil {
+ return nil, err
+ }
+ f.Close()
return fh, err
}
@@ -543,6 +624,11 @@ 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 {
@@ -597,6 +683,11 @@ 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)
@@ -634,32 +725,82 @@ func (c *Context) ShouldBindBodyWith(obj interface{}, bb binding.BindingBody) (e
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.
@@ -671,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
@@ -700,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).
@@ -724,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.
@@ -737,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,
})
@@ -790,11 +937,11 @@ 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", "")
@@ -871,15 +1018,26 @@ 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))
+ c.Writer.Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=\"%s\"", filename))
http.ServeFile(c.Writer, c.Request, filepath)
}
@@ -921,6 +1079,7 @@ type Negotiate struct {
HTMLData interface{}
JSONData interface{}
XMLData interface{}
+ YAMLData interface{}
Data interface{}
}
@@ -939,6 +1098,10 @@ 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")) // nolint: errcheck
}
@@ -955,20 +1118,20 @@ func (c *Context) NegotiateFormat(offered ...string) string {
return offered[0]
}
for _, accepted := range c.Accepted {
- for _, offert := range offered {
+ 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] == '*' || offert[i] == '*' {
- return offert
+ if accepted[i] == '*' || offer[i] == '*' {
+ return offer
}
- if accepted[i] != offert[i] {
+ if accepted[i] != offer[i] {
break
}
}
if i == len(accepted) {
- return offert
+ return offer
}
}
}
@@ -984,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/baas-kubeengine/vendor/github.com/gin-gonic/gin/context_appengine.go b/baas-kubeengine/vendor/github.com/gin-gonic/gin/context_appengine.go
index 38c189a0..d5658434 100644
--- a/baas-kubeengine/vendor/github.com/gin-gonic/gin/context_appengine.go
+++ b/baas-kubeengine/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/baas-kubeengine/vendor/github.com/gin-gonic/gin/debug.go b/baas-kubeengine/vendor/github.com/gin-gonic/gin/debug.go
index 6d40a5da..4c7cd0c3 100644
--- a/baas-kubeengine/vendor/github.com/gin-gonic/gin/debug.go
+++ b/baas-kubeengine/vendor/github.com/gin-gonic/gin/debug.go
@@ -5,16 +5,14 @@
package gin
import (
- "bytes"
"fmt"
"html/template"
- "os"
"runtime"
"strconv"
"strings"
)
-const ginSupportMinGoVer = 8
+const ginSupportMinGoVer = 12
// IsDebugging returns true if the framework is running in debug mode.
// Use SetMode(gin.ReleaseMode) to disable debug mode.
@@ -39,7 +37,7 @@ func debugPrintRoute(httpMethod, absolutePath string, handlers HandlersChain) {
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())
@@ -54,7 +52,7 @@ func debugPrint(format string, values ...interface{}) {
if !strings.HasSuffix(format, "\n") {
format += "\n"
}
- fmt.Fprintf(os.Stderr, "[GIN-debug] "+format, values...)
+ fmt.Fprintf(DefaultWriter, "[GIN-debug] "+format, values...)
}
}
@@ -69,7 +67,7 @@ func getMinVer(v string) (uint64, error) {
func debugPrintWARNINGDefault() {
if v, e := getMinVer(runtime.Version()); e == nil && v <= ginSupportMinGoVer {
- debugPrint(`[WARNING] Now Gin requires Go 1.8 or later and Go 1.9 will be required soon.
+ debugPrint(`[WARNING] Now Gin requires Go 1.12+.
`)
}
@@ -98,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/baas-kubeengine/vendor/github.com/gin-gonic/gin/errors.go b/baas-kubeengine/vendor/github.com/gin-gonic/gin/errors.go
index 6070ff55..0f276c13 100644
--- a/baas-kubeengine/vendor/github.com/gin-gonic/gin/errors.go
+++ b/baas-kubeengine/vendor/github.com/gin-gonic/gin/errors.go
@@ -5,9 +5,9 @@
package gin
import (
- "bytes"
"fmt"
"reflect"
+ "strings"
"github.com/gin-gonic/gin/internal/json"
)
@@ -55,7 +55,7 @@ func (msg *Error) SetMeta(data interface{}) *Error {
// 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() {
@@ -63,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.
@@ -90,6 +90,11 @@ 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 {
@@ -135,17 +140,17 @@ 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
}
}
@@ -158,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/baas-kubeengine/vendor/github.com/gin-gonic/gin/fs.go b/baas-kubeengine/vendor/github.com/gin-gonic/gin/fs.go
index 7a6738a6..007d9b75 100644
--- a/baas-kubeengine/vendor/github.com/gin-gonic/gin/fs.go
+++ b/baas-kubeengine/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/baas-kubeengine/vendor/github.com/gin-gonic/gin/gin.go b/baas-kubeengine/vendor/github.com/gin-gonic/gin/gin.go
index 4dbe9836..03a0e127 100644
--- a/baas-kubeengine/vendor/github.com/gin-gonic/gin/gin.go
+++ b/baas-kubeengine/vendor/github.com/gin-gonic/gin/gin.go
@@ -11,26 +11,29 @@ import (
"net/http"
"os"
"path"
+ "strings"
"sync"
+ "github.com/gin-gonic/gin/internal/bytesconv"
"github.com/gin-gonic/gin/render"
)
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]
@@ -79,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
@@ -97,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
@@ -107,6 +131,8 @@ type Engine struct {
noMethod HandlersChain
pool sync.Pool
trees methodTrees
+ maxParams uint16
+ trustedCIDRs []*net.IPNet
}
var _ IRouter = &Engine{}
@@ -132,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{} {
@@ -156,7 +185,8 @@ 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.
@@ -165,9 +195,9 @@ func (engine *Engine) Delims(left, right string) *Engine {
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
}
@@ -249,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:
@@ -289,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.
@@ -313,13 +398,13 @@ 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()
- os.Chmod(file, 0777)
+ defer os.Remove(file)
+
err = http.Serve(listener, engine)
return
}
@@ -337,6 +422,15 @@ func (engine *Engine) RunFd(fd int) (err error) {
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
}
@@ -372,7 +466,10 @@ func (engine *Engine) handleHTTPRequest(c *Context) {
rPath = c.Request.URL.RawPath
unescape = engine.UnescapePathValues
}
- rPath = cleanPath(rPath)
+
+ if engine.RemoveExtraSlash {
+ rPath = cleanPath(rPath)
+ }
// Find root of the tree for the given HTTP method
t := engine.trees
@@ -382,16 +479,19 @@ func (engine *Engine) handleHTTPRequest(c *Context) {
}
root := t[i].root
// Find route in tree
- handlers, params, tsr := root.getValue(rPath, 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" && rPath != "/" {
- if tsr && engine.RedirectTrailingSlash {
+ if value.tsr && engine.RedirectTrailingSlash {
redirectTrailingSlash(c)
return
}
@@ -407,7 +507,7 @@ func (engine *Engine) handleHTTPRequest(c *Context) {
if tree.method == httpMethod {
continue
}
- if handlers, _, _ := tree.root.getValue(rPath, 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
@@ -435,7 +535,6 @@ func serveError(c *Context, code int, defaultMessage []byte) {
return
}
c.writermem.WriteHeaderNow()
- return
}
func redirectTrailingSlash(c *Context) {
@@ -444,18 +543,11 @@ func redirectTrailingSlash(c *Context) {
if prefix := path.Clean(c.Request.Header.Get("X-Forwarded-Prefix")); prefix != "." {
p = prefix + "/" + req.URL.Path
}
- code := http.StatusMovedPermanently // Permanent redirect, request with GET method
- if req.Method != "GET" {
- code = http.StatusTemporaryRedirect
- }
-
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, p, 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 {
@@ -463,15 +555,23 @@ func redirectFixedPath(c *Context, root *node, trailingSlash bool) bool {
rPath := req.URL.Path
if fixedPath, ok := root.findCaseInsensitivePath(cleanPath(rPath), 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, rPath, req.URL.String())
- http.Redirect(c.Writer, req, req.URL.String(), code)
- c.writermem.WriteHeaderNow()
+ 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/baas-kubeengine/vendor/github.com/gin-gonic/gin/go.mod b/baas-kubeengine/vendor/github.com/gin-gonic/gin/go.mod
index 1c5e995c..884ff851 100644
--- a/baas-kubeengine/vendor/github.com/gin-gonic/gin/go.mod
+++ b/baas-kubeengine/vendor/github.com/gin-gonic/gin/go.mod
@@ -1,18 +1,14 @@
module github.com/gin-gonic/gin
-go 1.12
+go 1.13
require (
- github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3
- github.com/golang/protobuf v1.3.1
- github.com/json-iterator/go v1.1.6
- github.com/mattn/go-isatty v0.0.7
- github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
- github.com/modern-go/reflect2 v1.0.1 // indirect
- github.com/stretchr/testify v1.3.0
- github.com/ugorji/go v1.1.4
- golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c
- gopkg.in/go-playground/assert.v1 v1.2.1 // indirect
- gopkg.in/go-playground/validator.v8 v8.18.2
- gopkg.in/yaml.v2 v2.2.2
+ github.com/gin-contrib/sse v0.1.0
+ github.com/go-playground/validator/v10 v10.4.1
+ github.com/golang/protobuf v1.3.3
+ github.com/json-iterator/go v1.1.9
+ github.com/mattn/go-isatty v0.0.12
+ github.com/stretchr/testify v1.4.0
+ github.com/ugorji/go/codec v1.1.7
+ gopkg.in/yaml.v2 v2.2.8
)
diff --git a/baas-kubeengine/vendor/github.com/gin-gonic/gin/go.sum b/baas-kubeengine/vendor/github.com/gin-gonic/gin/go.sum
index 58104682..a64b3319 100644
--- a/baas-kubeengine/vendor/github.com/gin-gonic/gin/go.sum
+++ b/baas-kubeengine/vendor/github.com/gin-gonic/gin/go.sum
@@ -1,36 +1,52 @@
-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/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/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg=
-github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
-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/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/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 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=
-github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
+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/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/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/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/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/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 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc=
+github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
+github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 h1:Esafd1046DLDQ0W1YjYsBW+p8U2u7vzgW2SQVmlNazg=
+github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
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.4 h1:j4s+tAvLfL3bZyefP2SEWmhBzmuIlH/eqNuPdFPgngw=
-github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=
+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 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo=
+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/net v0.0.0-20190503192946-f4e77d36d62c h1:uOCk1iQW6Vc18bnC13MfzScl+wdKBmM9Y9kU7Z83/lw=
-golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
+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-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/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/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=
+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=
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/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/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/baas-kubeengine/vendor/github.com/gin-gonic/gin/internal/bytesconv/bytesconv.go b/baas-kubeengine/vendor/github.com/gin-gonic/gin/internal/bytesconv/bytesconv.go
new file mode 100644
index 00000000..86e4c4d4
--- /dev/null
+++ b/baas-kubeengine/vendor/github.com/gin-gonic/gin/internal/bytesconv/bytesconv.go
@@ -0,0 +1,24 @@
+// Copyright 2020 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 bytesconv
+
+import (
+ "unsafe"
+)
+
+// StringToBytes converts string to byte slice without a memory allocation.
+func StringToBytes(s string) []byte {
+ return *(*[]byte)(unsafe.Pointer(
+ &struct {
+ string
+ Cap int
+ }{s, len(s)},
+ ))
+}
+
+// BytesToString converts byte slice to string without a memory allocation.
+func BytesToString(b []byte) string {
+ return *(*string)(unsafe.Pointer(&b))
+}
diff --git a/baas-kubeengine/vendor/github.com/gin-gonic/gin/internal/json/json.go b/baas-kubeengine/vendor/github.com/gin-gonic/gin/internal/json/json.go
index 480e8bff..172aeb24 100644
--- a/baas-kubeengine/vendor/github.com/gin-gonic/gin/internal/json/json.go
+++ b/baas-kubeengine/vendor/github.com/gin-gonic/gin/internal/json/json.go
@@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT style
// license that can be found in the LICENSE file.
+//go:build !jsoniter
// +build !jsoniter
package json
diff --git a/baas-kubeengine/vendor/github.com/gin-gonic/gin/internal/json/jsoniter.go b/baas-kubeengine/vendor/github.com/gin-gonic/gin/internal/json/jsoniter.go
index fabd7b84..232f8dca 100644
--- a/baas-kubeengine/vendor/github.com/gin-gonic/gin/internal/json/jsoniter.go
+++ b/baas-kubeengine/vendor/github.com/gin-gonic/gin/internal/json/jsoniter.go
@@ -2,11 +2,12 @@
// Use of this source code is governed by a MIT style
// license that can be found in the LICENSE file.
+//go:build jsoniter
// +build jsoniter
package json
-import "github.com/json-iterator/go"
+import jsoniter "github.com/json-iterator/go"
var (
json = jsoniter.ConfigCompatibleWithStandardLibrary
diff --git a/baas-kubeengine/vendor/github.com/gin-gonic/gin/logger.go b/baas-kubeengine/vendor/github.com/gin-gonic/gin/logger.go
index 5ab4639e..d361b74d 100644
--- a/baas-kubeengine/vendor/github.com/gin-gonic/gin/logger.go
+++ b/baas-kubeengine/vendor/github.com/gin-gonic/gin/logger.go
@@ -22,18 +22,19 @@ const (
forceColor
)
-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, 48, 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})
- consoleColorMode = autoColor
+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
@@ -98,19 +99,19 @@ func (p *LogFormatterParams) MethodColor() string {
method := p.Method
switch method {
- case "GET":
+ case http.MethodGet:
return blue
- case "POST":
+ case http.MethodPost:
return cyan
- case "PUT":
+ case http.MethodPut:
return yellow
- case "DELETE":
+ case http.MethodDelete:
return red
- case "PATCH":
+ case http.MethodPatch:
return green
- case "HEAD":
+ case http.MethodHead:
return magenta
- case "OPTIONS":
+ case http.MethodOptions:
return white
default:
return reset
@@ -140,7 +141,7 @@ var defaultLogFormatter = func(param LogFormatterParams) string {
// 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 %s\n%s",
+ 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,
diff --git a/baas-kubeengine/vendor/github.com/gin-gonic/gin/mode.go b/baas-kubeengine/vendor/github.com/gin-gonic/gin/mode.go
index 8aa84aa8..c8813aff 100644
--- a/baas-kubeengine/vendor/github.com/gin-gonic/gin/mode.go
+++ b/baas-kubeengine/vendor/github.com/gin-gonic/gin/mode.go
@@ -22,6 +22,7 @@ const (
// TestMode indicates gin mode is test.
TestMode = "test"
)
+
const (
debugCode = iota
releaseCode
@@ -50,19 +51,21 @@ func init() {
// 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
}
@@ -71,12 +74,18 @@ func DisableBindValidation() {
binding.Validator = nil
}
-// EnableJsonDecoderUseNumber sets true for binding.EnableDecoderUseNumberto to
+// 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/baas-kubeengine/vendor/github.com/gin-gonic/gin/path.go b/baas-kubeengine/vendor/github.com/gin-gonic/gin/path.go
index d1f59622..d42d6b9d 100644
--- a/baas-kubeengine/vendor/github.com/gin-gonic/gin/path.go
+++ b/baas-kubeengine/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/baas-kubeengine/vendor/github.com/gin-gonic/gin/recovery.go b/baas-kubeengine/vendor/github.com/gin-gonic/gin/recovery.go
index bc946c03..563f5aaa 100644
--- a/baas-kubeengine/vendor/github.com/gin-gonic/gin/recovery.go
+++ b/baas-kubeengine/vendor/github.com/gin-gonic/gin/recovery.go
@@ -26,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)
@@ -60,23 +76,23 @@ func RecoveryWithWriter(out io.Writer) HandlerFunc {
headers[idx] = current[0] + ": *"
}
}
+ headersToStr := strings.Join(headers, "\r\n")
if brokenPipe {
- logger.Printf("%s\n%s%s", err, string(httpRequest), reset)
+ 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()), strings.Join(headers, "\r\n"), err, stack, reset)
+ 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 the connection is dead, we can't write a status to it.
if brokenPipe {
+ // If the connection is dead, we can't write a status to it.
c.Error(err.(error)) // nolint: errcheck
c.Abort()
} else {
- c.AbortWithStatus(http.StatusInternalServerError)
+ handle(c, err)
}
}
}()
@@ -84,6 +100,10 @@ func RecoveryWithWriter(out io.Writer) HandlerFunc {
}
}
+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
@@ -146,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/baas-kubeengine/vendor/github.com/gin-gonic/gin/render/json.go b/baas-kubeengine/vendor/github.com/gin-gonic/gin/render/json.go
index 18f27fa9..41863093 100644
--- a/baas-kubeengine/vendor/github.com/gin-gonic/gin/render/json.go
+++ b/baas-kubeengine/vendor/github.com/gin-gonic/gin/render/json.go
@@ -10,6 +10,7 @@ import (
"html/template"
"net/http"
+ "github.com/gin-gonic/gin/internal/bytesconv"
"github.com/gin-gonic/gin/internal/json"
)
@@ -40,9 +41,6 @@ type AsciiJSON struct {
Data interface{}
}
-// SecureJSONPrefix is a string which represents SecureJSON prefix.
-type SecureJSONPrefix string
-
// PureJSON contains the given interface object.
type PureJSON struct {
Data interface{}
@@ -100,8 +98,9 @@ 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("]")) {
- _, err = 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
}
@@ -129,11 +128,11 @@ func (r JsonpJSON) Render(w http.ResponseWriter) (err error) {
}
callback := template.JSEscapeString(r.Callback)
- _, err = w.Write([]byte(callback))
+ _, err = w.Write(bytesconv.StringToBytes(callback))
if err != nil {
return err
}
- _, err = w.Write([]byte("("))
+ _, err = w.Write(bytesconv.StringToBytes("("))
if err != nil {
return err
}
@@ -141,7 +140,7 @@ func (r JsonpJSON) Render(w http.ResponseWriter) (err error) {
if err != nil {
return err
}
- _, err = w.Write([]byte(")"))
+ _, err = w.Write(bytesconv.StringToBytes(");"))
if err != nil {
return err
}
@@ -163,7 +162,7 @@ func (r AsciiJSON) Render(w http.ResponseWriter) (err error) {
}
var buffer bytes.Buffer
- for _, r := range string(ret) {
+ for _, r := range bytesconv.BytesToString(ret) {
cvt := string(r)
if r >= 128 {
cvt = fmt.Sprintf("\\u%04x", int64(r))
diff --git a/baas-kubeengine/vendor/github.com/gin-gonic/gin/render/msgpack.go b/baas-kubeengine/vendor/github.com/gin-gonic/gin/render/msgpack.go
index dc681fcf..6ef5b6e5 100644
--- a/baas-kubeengine/vendor/github.com/gin-gonic/gin/render/msgpack.go
+++ b/baas-kubeengine/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,6 +13,10 @@ import (
"github.com/ugorji/go/codec"
)
+var (
+ _ Render = MsgPack{}
+)
+
// MsgPack contains the given interface object.
type MsgPack struct {
Data interface{}
diff --git a/baas-kubeengine/vendor/github.com/gin-gonic/gin/render/reader.go b/baas-kubeengine/vendor/github.com/gin-gonic/gin/render/reader.go
index 312af741..d5282e49 100644
--- a/baas-kubeengine/vendor/github.com/gin-gonic/gin/render/reader.go
+++ b/baas-kubeengine/vendor/github.com/gin-gonic/gin/render/reader.go
@@ -21,7 +21,12 @@ 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
diff --git a/baas-kubeengine/vendor/github.com/gin-gonic/gin/render/render.go b/baas-kubeengine/vendor/github.com/gin-gonic/gin/render/render.go
index abfc79fc..bcd568bf 100644
--- a/baas-kubeengine/vendor/github.com/gin-gonic/gin/render/render.go
+++ b/baas-kubeengine/vendor/github.com/gin-gonic/gin/render/render.go
@@ -27,7 +27,6 @@ var (
_ HTMLRender = HTMLDebug{}
_ HTMLRender = HTMLProduction{}
_ Render = YAML{}
- _ Render = MsgPack{}
_ Render = Reader{}
_ Render = AsciiJSON{}
_ Render = ProtoBuf{}
diff --git a/baas-kubeengine/vendor/github.com/gin-gonic/gin/render/text.go b/baas-kubeengine/vendor/github.com/gin-gonic/gin/render/text.go
index 4e52d4c5..461b720a 100644
--- a/baas-kubeengine/vendor/github.com/gin-gonic/gin/render/text.go
+++ b/baas-kubeengine/vendor/github.com/gin-gonic/gin/render/text.go
@@ -6,8 +6,9 @@ package render
import (
"fmt"
- "io"
"net/http"
+
+ "github.com/gin-gonic/gin/internal/bytesconv"
)
// String contains the given interface object slice and its format.
@@ -35,6 +36,6 @@ func WriteString(w http.ResponseWriter, format string, data []interface{}) (err
_, err = fmt.Fprintf(w, format, data...)
return
}
- _, err = io.WriteString(w, format)
+ _, err = w.Write(bytesconv.StringToBytes(format))
return
}
diff --git a/baas-kubeengine/vendor/github.com/gin-gonic/gin/routergroup.go b/baas-kubeengine/vendor/github.com/gin-gonic/gin/routergroup.go
index a1e6c928..15d9930d 100644
--- a/baas-kubeengine/vendor/github.com/gin-gonic/gin/routergroup.go
+++ b/baas-kubeengine/vendor/github.com/gin-gonic/gin/routergroup.go
@@ -95,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()
}
@@ -187,19 +187,21 @@ func (group *RouterGroup) createStaticHandler(relativePath string, fs http.FileS
fileServer := http.StripPrefix(absolutePath, http.FileServer(fs))
return func(c *Context) {
- if _, nolisting := fs.(*onlyfilesFS); 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
- if _, err := fs.Open(file); err != nil {
+ 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/baas-kubeengine/vendor/github.com/gin-gonic/gin/tree.go b/baas-kubeengine/vendor/github.com/gin-gonic/gin/tree.go
index ada62ceb..ca753e6d 100644
--- a/baas-kubeengine/vendor/github.com/gin-gonic/gin/tree.go
+++ b/baas-kubeengine/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,301 +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]
+ }
- pathSeg := path
- if n.nType != catchAll {
- pathSeg = strings.SplitN(path, "/", 2)[0]
- }
- prefix := fullPath[:strings.Index(fullPath, pathSeg)] + n.path
- panic("'" + pathSeg +
- "' in new path '" + fullPath +
- "' conflicts with existing wildcard '" + n.path +
- "' in existing prefix '" + prefix +
- "'")
- }
+ // 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
+}
- // 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 + "'")
+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
+ }
+
+ // 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!
@@ -431,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
}
@@ -499,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)
+ }
+
+ ciPath := n.findCaseInsensitivePathRec(
+ path,
+ buf, // Preallocate enough memory for new path
+ [4]byte{}, // Empty rune buffer
+ fixTrailingSlash,
+ )
- // 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):]
+ 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")
}
}
@@ -615,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/baas-kubeengine/vendor/github.com/gin-gonic/gin/utils.go b/baas-kubeengine/vendor/github.com/gin-gonic/gin/utils.go
index f4532d56..c32f0eeb 100644
--- a/baas-kubeengine/vendor/github.com/gin-gonic/gin/utils.go
+++ b/baas-kubeengine/vendor/github.com/gin-gonic/gin/utils.go
@@ -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/baas-kubeengine/vendor/github.com/gin-gonic/gin/version.go b/baas-kubeengine/vendor/github.com/gin-gonic/gin/version.go
index 07e7859f..95b4ed14 100644
--- a/baas-kubeengine/vendor/github.com/gin-gonic/gin/version.go
+++ b/baas-kubeengine/vendor/github.com/gin-gonic/gin/version.go
@@ -5,4 +5,4 @@
package gin
// Version is the current gin framework's version.
-const Version = "v1.4.0"
+const Version = "v1.7.0"
diff --git a/baas-kubeengine/vendor/github.com/go-playground/locales/.gitignore b/baas-kubeengine/vendor/github.com/go-playground/locales/.gitignore
new file mode 100644
index 00000000..daf913b1
--- /dev/null
+++ b/baas-kubeengine/vendor/github.com/go-playground/locales/.gitignore
@@ -0,0 +1,24 @@
+# Compiled Object files, Static and Dynamic libs (Shared Objects)
+*.o
+*.a
+*.so
+
+# Folders
+_obj
+_test
+
+# Architecture specific extensions/prefixes
+*.[568vq]
+[568vq].out
+
+*.cgo1.go
+*.cgo2.c
+_cgo_defun.c
+_cgo_gotypes.go
+_cgo_export.*
+
+_testmain.go
+
+*.exe
+*.test
+*.prof
diff --git a/baas-kubeengine/vendor/github.com/go-playground/locales/.travis.yml b/baas-kubeengine/vendor/github.com/go-playground/locales/.travis.yml
new file mode 100644
index 00000000..d50237a6
--- /dev/null
+++ b/baas-kubeengine/vendor/github.com/go-playground/locales/.travis.yml
@@ -0,0 +1,26 @@
+language: go
+go:
+ - 1.13.1
+ - tip
+matrix:
+ allow_failures:
+ - go: tip
+
+notifications:
+ email:
+ recipients: dean.karn@gmail.com
+ on_success: change
+ on_failure: always
+
+before_install:
+ - go install github.com/mattn/goveralls
+
+# Only clone the most recent commit.
+git:
+ depth: 1
+
+script:
+ - go test -v -race -covermode=atomic -coverprofile=coverage.coverprofile ./...
+
+after_success: |
+ goveralls -coverprofile=coverage.coverprofile -service travis-ci -repotoken $COVERALLS_TOKEN
\ No newline at end of file
diff --git a/baas-kubeengine/vendor/github.com/go-playground/locales/LICENSE b/baas-kubeengine/vendor/github.com/go-playground/locales/LICENSE
new file mode 100644
index 00000000..75854ac4
--- /dev/null
+++ b/baas-kubeengine/vendor/github.com/go-playground/locales/LICENSE
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2016 Go Playground
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
\ No newline at end of file
diff --git a/baas-kubeengine/vendor/github.com/go-playground/locales/README.md b/baas-kubeengine/vendor/github.com/go-playground/locales/README.md
new file mode 100644
index 00000000..ba1b0680
--- /dev/null
+++ b/baas-kubeengine/vendor/github.com/go-playground/locales/README.md
@@ -0,0 +1,172 @@
+## locales
+![Project status](https://img.shields.io/badge/version-0.13.0-green.svg)
+[![Build Status](https://travis-ci.org/go-playground/locales.svg?branch=master)](https://travis-ci.org/go-playground/locales)
+[![Go Report Card](https://goreportcard.com/badge/github.com/go-playground/locales)](https://goreportcard.com/report/github.com/go-playground/locales)
+[![GoDoc](https://godoc.org/github.com/go-playground/locales?status.svg)](https://godoc.org/github.com/go-playground/locales)
+![License](https://img.shields.io/dub/l/vibe-d.svg)
+[![Gitter](https://badges.gitter.im/go-playground/locales.svg)](https://gitter.im/go-playground/locales?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
+
+Locales is a set of locales generated from the [Unicode CLDR Project](http://cldr.unicode.org/) which can be used independently or within
+an i18n package; these were built for use with, but not exclusive to, [Universal Translator](https://github.com/go-playground/universal-translator).
+
+Features
+--------
+- [x] Rules generated from the latest [CLDR](http://cldr.unicode.org/index/downloads) data, v31.0.1
+- [x] Contains Cardinal, Ordinal and Range Plural Rules
+- [x] Contains Month, Weekday and Timezone translations built in
+- [x] Contains Date & Time formatting functions
+- [x] Contains Number, Currency, Accounting and Percent formatting functions
+- [x] Supports the "Gregorian" calendar only ( my time isn't unlimited, had to draw the line somewhere )
+
+Full Tests
+--------------------
+I could sure use your help adding tests for every locale, it is a huge undertaking and I just don't have the free time to do it all at the moment;
+any help would be **greatly appreciated!!!!** please see [issue](https://github.com/go-playground/locales/issues/1) for details.
+
+Installation
+-----------
+
+Use go get
+
+```shell
+go get github.com/go-playground/locales
+```
+
+NOTES
+--------
+You'll notice most return types are []byte, this is because most of the time the results will be concatenated with a larger body
+of text and can avoid some allocations if already appending to a byte array, otherwise just cast as string.
+
+Usage
+-------
+```go
+package main
+
+import (
+ "fmt"
+ "time"
+
+ "github.com/go-playground/locales/currency"
+ "github.com/go-playground/locales/en_CA"
+)
+
+func main() {
+
+ loc, _ := time.LoadLocation("America/Toronto")
+ datetime := time.Date(2016, 02, 03, 9, 0, 1, 0, loc)
+
+ l := en_CA.New()
+
+ // Dates
+ fmt.Println(l.FmtDateFull(datetime))
+ fmt.Println(l.FmtDateLong(datetime))
+ fmt.Println(l.FmtDateMedium(datetime))
+ fmt.Println(l.FmtDateShort(datetime))
+
+ // Times
+ fmt.Println(l.FmtTimeFull(datetime))
+ fmt.Println(l.FmtTimeLong(datetime))
+ fmt.Println(l.FmtTimeMedium(datetime))
+ fmt.Println(l.FmtTimeShort(datetime))
+
+ // Months Wide
+ fmt.Println(l.MonthWide(time.January))
+ fmt.Println(l.MonthWide(time.February))
+ fmt.Println(l.MonthWide(time.March))
+ // ...
+
+ // Months Abbreviated
+ fmt.Println(l.MonthAbbreviated(time.January))
+ fmt.Println(l.MonthAbbreviated(time.February))
+ fmt.Println(l.MonthAbbreviated(time.March))
+ // ...
+
+ // Months Narrow
+ fmt.Println(l.MonthNarrow(time.January))
+ fmt.Println(l.MonthNarrow(time.February))
+ fmt.Println(l.MonthNarrow(time.March))
+ // ...
+
+ // Weekdays Wide
+ fmt.Println(l.WeekdayWide(time.Sunday))
+ fmt.Println(l.WeekdayWide(time.Monday))
+ fmt.Println(l.WeekdayWide(time.Tuesday))
+ // ...
+
+ // Weekdays Abbreviated
+ fmt.Println(l.WeekdayAbbreviated(time.Sunday))
+ fmt.Println(l.WeekdayAbbreviated(time.Monday))
+ fmt.Println(l.WeekdayAbbreviated(time.Tuesday))
+ // ...
+
+ // Weekdays Short
+ fmt.Println(l.WeekdayShort(time.Sunday))
+ fmt.Println(l.WeekdayShort(time.Monday))
+ fmt.Println(l.WeekdayShort(time.Tuesday))
+ // ...
+
+ // Weekdays Narrow
+ fmt.Println(l.WeekdayNarrow(time.Sunday))
+ fmt.Println(l.WeekdayNarrow(time.Monday))
+ fmt.Println(l.WeekdayNarrow(time.Tuesday))
+ // ...
+
+ var f64 float64
+
+ f64 = -10356.4523
+
+ // Number
+ fmt.Println(l.FmtNumber(f64, 2))
+
+ // Currency
+ fmt.Println(l.FmtCurrency(f64, 2, currency.CAD))
+ fmt.Println(l.FmtCurrency(f64, 2, currency.USD))
+
+ // Accounting
+ fmt.Println(l.FmtAccounting(f64, 2, currency.CAD))
+ fmt.Println(l.FmtAccounting(f64, 2, currency.USD))
+
+ f64 = 78.12
+
+ // Percent
+ fmt.Println(l.FmtPercent(f64, 0))
+
+ // Plural Rules for locale, so you know what rules you must cover
+ fmt.Println(l.PluralsCardinal())
+ fmt.Println(l.PluralsOrdinal())
+
+ // Cardinal Plural Rules
+ fmt.Println(l.CardinalPluralRule(1, 0))
+ fmt.Println(l.CardinalPluralRule(1.0, 0))
+ fmt.Println(l.CardinalPluralRule(1.0, 1))
+ fmt.Println(l.CardinalPluralRule(3, 0))
+
+ // Ordinal Plural Rules
+ fmt.Println(l.OrdinalPluralRule(21, 0)) // 21st
+ fmt.Println(l.OrdinalPluralRule(22, 0)) // 22nd
+ fmt.Println(l.OrdinalPluralRule(33, 0)) // 33rd
+ fmt.Println(l.OrdinalPluralRule(34, 0)) // 34th
+
+ // Range Plural Rules
+ fmt.Println(l.RangePluralRule(1, 0, 1, 0)) // 1-1
+ fmt.Println(l.RangePluralRule(1, 0, 2, 0)) // 1-2
+ fmt.Println(l.RangePluralRule(5, 0, 8, 0)) // 5-8
+}
+```
+
+NOTES:
+-------
+These rules were generated from the [Unicode CLDR Project](http://cldr.unicode.org/), if you encounter any issues
+I strongly encourage contributing to the CLDR project to get the locale information corrected and the next time
+these locales are regenerated the fix will come with.
+
+I do however realize that time constraints are often important and so there are two options:
+
+1. Create your own locale, copy, paste and modify, and ensure it complies with the `Translator` interface.
+2. Add an exception in the locale generation code directly and once regenerated, fix will be in place.
+
+Please to not make fixes inside the locale files, they WILL get overwritten when the locales are regenerated.
+
+License
+------
+Distributed under MIT License, please see license file in code for more details.
diff --git a/baas-kubeengine/vendor/github.com/go-playground/locales/currency/currency.go b/baas-kubeengine/vendor/github.com/go-playground/locales/currency/currency.go
new file mode 100644
index 00000000..cdaba596
--- /dev/null
+++ b/baas-kubeengine/vendor/github.com/go-playground/locales/currency/currency.go
@@ -0,0 +1,308 @@
+package currency
+
+// Type is the currency type associated with the locales currency enum
+type Type int
+
+// locale currencies
+const (
+ ADP Type = iota
+ AED
+ AFA
+ AFN
+ ALK
+ ALL
+ AMD
+ ANG
+ AOA
+ AOK
+ AON
+ AOR
+ ARA
+ ARL
+ ARM
+ ARP
+ ARS
+ ATS
+ AUD
+ AWG
+ AZM
+ AZN
+ BAD
+ BAM
+ BAN
+ BBD
+ BDT
+ BEC
+ BEF
+ BEL
+ BGL
+ BGM
+ BGN
+ BGO
+ BHD
+ BIF
+ BMD
+ BND
+ BOB
+ BOL
+ BOP
+ BOV
+ BRB
+ BRC
+ BRE
+ BRL
+ BRN
+ BRR
+ BRZ
+ BSD
+ BTN
+ BUK
+ BWP
+ BYB
+ BYN
+ BYR
+ BZD
+ CAD
+ CDF
+ CHE
+ CHF
+ CHW
+ CLE
+ CLF
+ CLP
+ CNH
+ CNX
+ CNY
+ COP
+ COU
+ CRC
+ CSD
+ CSK
+ CUC
+ CUP
+ CVE
+ CYP
+ CZK
+ DDM
+ DEM
+ DJF
+ DKK
+ DOP
+ DZD
+ ECS
+ ECV
+ EEK
+ EGP
+ ERN
+ ESA
+ ESB
+ ESP
+ ETB
+ EUR
+ FIM
+ FJD
+ FKP
+ FRF
+ GBP
+ GEK
+ GEL
+ GHC
+ GHS
+ GIP
+ GMD
+ GNF
+ GNS
+ GQE
+ GRD
+ GTQ
+ GWE
+ GWP
+ GYD
+ HKD
+ HNL
+ HRD
+ HRK
+ HTG
+ HUF
+ IDR
+ IEP
+ ILP
+ ILR
+ ILS
+ INR
+ IQD
+ IRR
+ ISJ
+ ISK
+ ITL
+ JMD
+ JOD
+ JPY
+ KES
+ KGS
+ KHR
+ KMF
+ KPW
+ KRH
+ KRO
+ KRW
+ KWD
+ KYD
+ KZT
+ LAK
+ LBP
+ LKR
+ LRD
+ LSL
+ LTL
+ LTT
+ LUC
+ LUF
+ LUL
+ LVL
+ LVR
+ LYD
+ MAD
+ MAF
+ MCF
+ MDC
+ MDL
+ MGA
+ MGF
+ MKD
+ MKN
+ MLF
+ MMK
+ MNT
+ MOP
+ MRO
+ MTL
+ MTP
+ MUR
+ MVP
+ MVR
+ MWK
+ MXN
+ MXP
+ MXV
+ MYR
+ MZE
+ MZM
+ MZN
+ NAD
+ NGN
+ NIC
+ NIO
+ NLG
+ NOK
+ NPR
+ NZD
+ OMR
+ PAB
+ PEI
+ PEN
+ PES
+ PGK
+ PHP
+ PKR
+ PLN
+ PLZ
+ PTE
+ PYG
+ QAR
+ RHD
+ ROL
+ RON
+ RSD
+ RUB
+ RUR
+ RWF
+ SAR
+ SBD
+ SCR
+ SDD
+ SDG
+ SDP
+ SEK
+ SGD
+ SHP
+ SIT
+ SKK
+ SLL
+ SOS
+ SRD
+ SRG
+ SSP
+ STD
+ STN
+ SUR
+ SVC
+ SYP
+ SZL
+ THB
+ TJR
+ TJS
+ TMM
+ TMT
+ TND
+ TOP
+ TPE
+ TRL
+ TRY
+ TTD
+ TWD
+ TZS
+ UAH
+ UAK
+ UGS
+ UGX
+ USD
+ USN
+ USS
+ UYI
+ UYP
+ UYU
+ UZS
+ VEB
+ VEF
+ VND
+ VNN
+ VUV
+ WST
+ XAF
+ XAG
+ XAU
+ XBA
+ XBB
+ XBC
+ XBD
+ XCD
+ XDR
+ XEU
+ XFO
+ XFU
+ XOF
+ XPD
+ XPF
+ XPT
+ XRE
+ XSU
+ XTS
+ XUA
+ XXX
+ YDD
+ YER
+ YUD
+ YUM
+ YUN
+ YUR
+ ZAL
+ ZAR
+ ZMK
+ ZMW
+ ZRN
+ ZRZ
+ ZWD
+ ZWL
+ ZWR
+)
diff --git a/baas-kubeengine/vendor/github.com/go-playground/locales/go.mod b/baas-kubeengine/vendor/github.com/go-playground/locales/go.mod
new file mode 100644
index 00000000..34ab6f23
--- /dev/null
+++ b/baas-kubeengine/vendor/github.com/go-playground/locales/go.mod
@@ -0,0 +1,5 @@
+module github.com/go-playground/locales
+
+go 1.13
+
+require golang.org/x/text v0.3.2
diff --git a/baas-kubeengine/vendor/github.com/go-playground/locales/go.sum b/baas-kubeengine/vendor/github.com/go-playground/locales/go.sum
new file mode 100644
index 00000000..63c9200f
--- /dev/null
+++ b/baas-kubeengine/vendor/github.com/go-playground/locales/go.sum
@@ -0,0 +1,3 @@
+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=
diff --git a/baas-kubeengine/vendor/github.com/go-playground/locales/logo.png b/baas-kubeengine/vendor/github.com/go-playground/locales/logo.png
new file mode 100644
index 00000000..3038276e
Binary files /dev/null and b/baas-kubeengine/vendor/github.com/go-playground/locales/logo.png differ
diff --git a/baas-kubeengine/vendor/github.com/go-playground/locales/rules.go b/baas-kubeengine/vendor/github.com/go-playground/locales/rules.go
new file mode 100644
index 00000000..92029001
--- /dev/null
+++ b/baas-kubeengine/vendor/github.com/go-playground/locales/rules.go
@@ -0,0 +1,293 @@
+package locales
+
+import (
+ "strconv"
+ "time"
+
+ "github.com/go-playground/locales/currency"
+)
+
+// // ErrBadNumberValue is returned when the number passed for
+// // plural rule determination cannot be parsed
+// type ErrBadNumberValue struct {
+// NumberValue string
+// InnerError error
+// }
+
+// // Error returns ErrBadNumberValue error string
+// func (e *ErrBadNumberValue) Error() string {
+// return fmt.Sprintf("Invalid Number Value '%s' %s", e.NumberValue, e.InnerError)
+// }
+
+// var _ error = new(ErrBadNumberValue)
+
+// PluralRule denotes the type of plural rules
+type PluralRule int
+
+// PluralRule's
+const (
+ PluralRuleUnknown PluralRule = iota
+ PluralRuleZero // zero
+ PluralRuleOne // one - singular
+ PluralRuleTwo // two - dual
+ PluralRuleFew // few - paucal
+ PluralRuleMany // many - also used for fractions if they have a separate class
+ PluralRuleOther // other - required—general plural form—also used if the language only has a single form
+)
+
+const (
+ pluralsString = "UnknownZeroOneTwoFewManyOther"
+)
+
+// Translator encapsulates an instance of a locale
+// NOTE: some values are returned as a []byte just in case the caller
+// wishes to add more and can help avoid allocations; otherwise just cast as string
+type Translator interface {
+
+ // The following Functions are for overriding, debugging or developing
+ // with a Translator Locale
+
+ // Locale returns the string value of the translator
+ Locale() string
+
+ // returns an array of cardinal plural rules associated
+ // with this translator
+ PluralsCardinal() []PluralRule
+
+ // returns an array of ordinal plural rules associated
+ // with this translator
+ PluralsOrdinal() []PluralRule
+
+ // returns an array of range plural rules associated
+ // with this translator
+ PluralsRange() []PluralRule
+
+ // returns the cardinal PluralRule given 'num' and digits/precision of 'v' for locale
+ CardinalPluralRule(num float64, v uint64) PluralRule
+
+ // returns the ordinal PluralRule given 'num' and digits/precision of 'v' for locale
+ OrdinalPluralRule(num float64, v uint64) PluralRule
+
+ // returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for locale
+ RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) PluralRule
+
+ // returns the locales abbreviated month given the 'month' provided
+ MonthAbbreviated(month time.Month) string
+
+ // returns the locales abbreviated months
+ MonthsAbbreviated() []string
+
+ // returns the locales narrow month given the 'month' provided
+ MonthNarrow(month time.Month) string
+
+ // returns the locales narrow months
+ MonthsNarrow() []string
+
+ // returns the locales wide month given the 'month' provided
+ MonthWide(month time.Month) string
+
+ // returns the locales wide months
+ MonthsWide() []string
+
+ // returns the locales abbreviated weekday given the 'weekday' provided
+ WeekdayAbbreviated(weekday time.Weekday) string
+
+ // returns the locales abbreviated weekdays
+ WeekdaysAbbreviated() []string
+
+ // returns the locales narrow weekday given the 'weekday' provided
+ WeekdayNarrow(weekday time.Weekday) string
+
+ // WeekdaysNarrowreturns the locales narrow weekdays
+ WeekdaysNarrow() []string
+
+ // returns the locales short weekday given the 'weekday' provided
+ WeekdayShort(weekday time.Weekday) string
+
+ // returns the locales short weekdays
+ WeekdaysShort() []string
+
+ // returns the locales wide weekday given the 'weekday' provided
+ WeekdayWide(weekday time.Weekday) string
+
+ // returns the locales wide weekdays
+ WeekdaysWide() []string
+
+ // The following Functions are common Formatting functionsfor the Translator's Locale
+
+ // returns 'num' with digits/precision of 'v' for locale and handles both Whole and Real numbers based on 'v'
+ FmtNumber(num float64, v uint64) string
+
+ // returns 'num' with digits/precision of 'v' for locale and handles both Whole and Real numbers based on 'v'
+ // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
+ FmtPercent(num float64, v uint64) string
+
+ // returns the currency representation of 'num' with digits/precision of 'v' for locale
+ FmtCurrency(num float64, v uint64, currency currency.Type) string
+
+ // returns the currency representation of 'num' with digits/precision of 'v' for locale
+ // in accounting notation.
+ FmtAccounting(num float64, v uint64, currency currency.Type) string
+
+ // returns the short date representation of 't' for locale
+ FmtDateShort(t time.Time) string
+
+ // returns the medium date representation of 't' for locale
+ FmtDateMedium(t time.Time) string
+
+ // returns the long date representation of 't' for locale
+ FmtDateLong(t time.Time) string
+
+ // returns the full date representation of 't' for locale
+ FmtDateFull(t time.Time) string
+
+ // returns the short time representation of 't' for locale
+ FmtTimeShort(t time.Time) string
+
+ // returns the medium time representation of 't' for locale
+ FmtTimeMedium(t time.Time) string
+
+ // returns the long time representation of 't' for locale
+ FmtTimeLong(t time.Time) string
+
+ // returns the full time representation of 't' for locale
+ FmtTimeFull(t time.Time) string
+}
+
+// String returns the string value of PluralRule
+func (p PluralRule) String() string {
+
+ switch p {
+ case PluralRuleZero:
+ return pluralsString[7:11]
+ case PluralRuleOne:
+ return pluralsString[11:14]
+ case PluralRuleTwo:
+ return pluralsString[14:17]
+ case PluralRuleFew:
+ return pluralsString[17:20]
+ case PluralRuleMany:
+ return pluralsString[20:24]
+ case PluralRuleOther:
+ return pluralsString[24:]
+ default:
+ return pluralsString[:7]
+ }
+}
+
+//
+// Precision Notes:
+//
+// must specify a precision >= 0, and here is why https://play.golang.org/p/LyL90U0Vyh
+//
+// v := float64(3.141)
+// i := float64(int64(v))
+//
+// fmt.Println(v - i)
+//
+// or
+//
+// s := strconv.FormatFloat(v-i, 'f', -1, 64)
+// fmt.Println(s)
+//
+// these will not print what you'd expect: 0.14100000000000001
+// and so this library requires a precision to be specified, or
+// inaccurate plural rules could be applied.
+//
+//
+//
+// n - absolute value of the source number (integer and decimals).
+// i - integer digits of n.
+// v - number of visible fraction digits in n, with trailing zeros.
+// w - number of visible fraction digits in n, without trailing zeros.
+// f - visible fractional digits in n, with trailing zeros.
+// t - visible fractional digits in n, without trailing zeros.
+//
+//
+// Func(num float64, v uint64) // v = digits/precision and prevents -1 as a special case as this can lead to very unexpected behaviour, see precision note's above.
+//
+// n := math.Abs(num)
+// i := int64(n)
+// v := v
+//
+//
+// w := strconv.FormatFloat(num-float64(i), 'f', int(v), 64) // then parse backwards on string until no more zero's....
+// f := strconv.FormatFloat(n, 'f', int(v), 64) // then turn everything after decimal into an int64
+// t := strconv.FormatFloat(n, 'f', int(v), 64) // then parse backwards on string until no more zero's....
+//
+//
+//
+// General Inclusion Rules
+// - v will always be available inherently
+// - all require n
+// - w requires i
+//
+
+// W returns the number of visible fraction digits in N, without trailing zeros.
+func W(n float64, v uint64) (w int64) {
+
+ s := strconv.FormatFloat(n-float64(int64(n)), 'f', int(v), 64)
+
+ // with either be '0' or '0.xxxx', so if 1 then w will be zero
+ // otherwise need to parse
+ if len(s) != 1 {
+
+ s = s[2:]
+ end := len(s) + 1
+
+ for i := end; i >= 0; i-- {
+ if s[i] != '0' {
+ end = i + 1
+ break
+ }
+ }
+
+ w = int64(len(s[:end]))
+ }
+
+ return
+}
+
+// F returns the visible fractional digits in N, with trailing zeros.
+func F(n float64, v uint64) (f int64) {
+
+ s := strconv.FormatFloat(n-float64(int64(n)), 'f', int(v), 64)
+
+ // with either be '0' or '0.xxxx', so if 1 then f will be zero
+ // otherwise need to parse
+ if len(s) != 1 {
+
+ // ignoring error, because it can't fail as we generated
+ // the string internally from a real number
+ f, _ = strconv.ParseInt(s[2:], 10, 64)
+ }
+
+ return
+}
+
+// T returns the visible fractional digits in N, without trailing zeros.
+func T(n float64, v uint64) (t int64) {
+
+ s := strconv.FormatFloat(n-float64(int64(n)), 'f', int(v), 64)
+
+ // with either be '0' or '0.xxxx', so if 1 then t will be zero
+ // otherwise need to parse
+ if len(s) != 1 {
+
+ s = s[2:]
+ end := len(s) + 1
+
+ for i := end; i >= 0; i-- {
+ if s[i] != '0' {
+ end = i + 1
+ break
+ }
+ }
+
+ // ignoring error, because it can't fail as we generated
+ // the string internally from a real number
+ t, _ = strconv.ParseInt(s[:end], 10, 64)
+ }
+
+ return
+}
diff --git a/baas-kubeengine/vendor/github.com/go-playground/universal-translator/.gitignore b/baas-kubeengine/vendor/github.com/go-playground/universal-translator/.gitignore
new file mode 100644
index 00000000..bc4e07f3
--- /dev/null
+++ b/baas-kubeengine/vendor/github.com/go-playground/universal-translator/.gitignore
@@ -0,0 +1,25 @@
+# Compiled Object files, Static and Dynamic libs (Shared Objects)
+*.o
+*.a
+*.so
+
+# Folders
+_obj
+_test
+
+# Architecture specific extensions/prefixes
+*.[568vq]
+[568vq].out
+
+*.cgo1.go
+*.cgo2.c
+_cgo_defun.c
+_cgo_gotypes.go
+_cgo_export.*
+
+_testmain.go
+
+*.exe
+*.test
+*.prof
+*.coverprofile
\ No newline at end of file
diff --git a/baas-kubeengine/vendor/github.com/go-playground/universal-translator/.travis.yml b/baas-kubeengine/vendor/github.com/go-playground/universal-translator/.travis.yml
new file mode 100644
index 00000000..39b8b923
--- /dev/null
+++ b/baas-kubeengine/vendor/github.com/go-playground/universal-translator/.travis.yml
@@ -0,0 +1,27 @@
+language: go
+go:
+ - 1.13.4
+ - tip
+matrix:
+ allow_failures:
+ - go: tip
+
+notifications:
+ email:
+ recipients: dean.karn@gmail.com
+ on_success: change
+ on_failure: always
+
+before_install:
+ - go install github.com/mattn/goveralls
+
+# Only clone the most recent commit.
+git:
+ depth: 1
+
+script:
+ - go test -v -race -covermode=atomic -coverprofile=coverage.coverprofile ./...
+
+after_success: |
+ [ $TRAVIS_GO_VERSION = 1.13.4 ] &&
+ goveralls -coverprofile=coverage.coverprofile -service travis-ci -repotoken $COVERALLS_TOKEN
\ No newline at end of file
diff --git a/baas-kubeengine/vendor/github.com/go-playground/universal-translator/LICENSE b/baas-kubeengine/vendor/github.com/go-playground/universal-translator/LICENSE
new file mode 100644
index 00000000..8d8aba15
--- /dev/null
+++ b/baas-kubeengine/vendor/github.com/go-playground/universal-translator/LICENSE
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2016 Go Playground
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/baas-kubeengine/vendor/github.com/go-playground/universal-translator/README.md b/baas-kubeengine/vendor/github.com/go-playground/universal-translator/README.md
new file mode 100644
index 00000000..071f33ab
--- /dev/null
+++ b/baas-kubeengine/vendor/github.com/go-playground/universal-translator/README.md
@@ -0,0 +1,89 @@
+## universal-translator
+![Project status](https://img.shields.io/badge/version-0.17.0-green.svg)
+[![Build Status](https://travis-ci.org/go-playground/universal-translator.svg?branch=master)](https://travis-ci.org/go-playground/universal-translator)
+[![Coverage Status](https://coveralls.io/repos/github/go-playground/universal-translator/badge.svg)](https://coveralls.io/github/go-playground/universal-translator)
+[![Go Report Card](https://goreportcard.com/badge/github.com/go-playground/universal-translator)](https://goreportcard.com/report/github.com/go-playground/universal-translator)
+[![GoDoc](https://godoc.org/github.com/go-playground/universal-translator?status.svg)](https://godoc.org/github.com/go-playground/universal-translator)
+![License](https://img.shields.io/dub/l/vibe-d.svg)
+[![Gitter](https://badges.gitter.im/go-playground/universal-translator.svg)](https://gitter.im/go-playground/universal-translator?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
+
+Universal Translator is an i18n Translator for Go/Golang using CLDR data + pluralization rules
+
+Why another i18n library?
+--------------------------
+Because none of the plural rules seem to be correct out there, including the previous implementation of this package,
+so I took it upon myself to create [locales](https://github.com/go-playground/locales) for everyone to use; this package
+is a thin wrapper around [locales](https://github.com/go-playground/locales) in order to store and translate text for
+use in your applications.
+
+Features
+--------
+- [x] Rules generated from the [CLDR](http://cldr.unicode.org/index/downloads) data, v30.0.3
+- [x] Contains Cardinal, Ordinal and Range Plural Rules
+- [x] Contains Month, Weekday and Timezone translations built in
+- [x] Contains Date & Time formatting functions
+- [x] Contains Number, Currency, Accounting and Percent formatting functions
+- [x] Supports the "Gregorian" calendar only ( my time isn't unlimited, had to draw the line somewhere )
+- [x] Support loading translations from files
+- [x] Exporting translations to file(s), mainly for getting them professionally translated
+- [ ] Code Generation for translation files -> Go code.. i.e. after it has been professionally translated
+- [ ] Tests for all languages, I need help with this, please see [here](https://github.com/go-playground/locales/issues/1)
+
+Installation
+-----------
+
+Use go get
+
+```shell
+go get github.com/go-playground/universal-translator
+```
+
+Usage & Documentation
+-------
+
+Please see https://godoc.org/github.com/go-playground/universal-translator for usage docs
+
+##### Examples:
+
+- [Basic](https://github.com/go-playground/universal-translator/tree/master/_examples/basic)
+- [Full - no files](https://github.com/go-playground/universal-translator/tree/master/_examples/full-no-files)
+- [Full - with files](https://github.com/go-playground/universal-translator/tree/master/_examples/full-with-files)
+
+File formatting
+--------------
+All types, Plain substitution, Cardinal, Ordinal and Range translations can all be contained withing the same file(s);
+they are only separated for easy viewing.
+
+##### Examples:
+
+- [Formats](https://github.com/go-playground/universal-translator/tree/master/_examples/file-formats)
+
+##### Basic Makeup
+NOTE: not all fields are needed for all translation types, see [examples](https://github.com/go-playground/universal-translator/tree/master/_examples/file-formats)
+```json
+{
+ "locale": "en",
+ "key": "days-left",
+ "trans": "You have {0} day left.",
+ "type": "Cardinal",
+ "rule": "One",
+ "override": false
+}
+```
+|Field|Description|
+|---|---|
+|locale|The locale for which the translation is for.|
+|key|The translation key that will be used to store and lookup each translation; normally it is a string or integer.|
+|trans|The actual translation text.|
+|type|The type of translation Cardinal, Ordinal, Range or "" for a plain substitution(not required to be defined if plain used)|
+|rule|The plural rule for which the translation is for eg. One, Two, Few, Many or Other.(not required to be defined if plain used)|
+|override|If you wish to override an existing translation that has already been registered, set this to 'true'. 99% of the time there is no need to define it.|
+
+Help With Tests
+---------------
+To anyone interesting in helping or contributing, I sure could use some help creating tests for each language.
+Please see issue [here](https://github.com/go-playground/locales/issues/1) for details.
+
+License
+------
+Distributed under MIT License, please see license file in code for more details.
diff --git a/baas-kubeengine/vendor/github.com/go-playground/universal-translator/errors.go b/baas-kubeengine/vendor/github.com/go-playground/universal-translator/errors.go
new file mode 100644
index 00000000..38b163b6
--- /dev/null
+++ b/baas-kubeengine/vendor/github.com/go-playground/universal-translator/errors.go
@@ -0,0 +1,148 @@
+package ut
+
+import (
+ "errors"
+ "fmt"
+
+ "github.com/go-playground/locales"
+)
+
+var (
+ // ErrUnknowTranslation indicates the translation could not be found
+ ErrUnknowTranslation = errors.New("Unknown Translation")
+)
+
+var _ error = new(ErrConflictingTranslation)
+var _ error = new(ErrRangeTranslation)
+var _ error = new(ErrOrdinalTranslation)
+var _ error = new(ErrCardinalTranslation)
+var _ error = new(ErrMissingPluralTranslation)
+var _ error = new(ErrExistingTranslator)
+
+// ErrExistingTranslator is the error representing a conflicting translator
+type ErrExistingTranslator struct {
+ locale string
+}
+
+// Error returns ErrExistingTranslator's internal error text
+func (e *ErrExistingTranslator) Error() string {
+ return fmt.Sprintf("error: conflicting translator for locale '%s'", e.locale)
+}
+
+// ErrConflictingTranslation is the error representing a conflicting translation
+type ErrConflictingTranslation struct {
+ locale string
+ key interface{}
+ rule locales.PluralRule
+ text string
+}
+
+// Error returns ErrConflictingTranslation's internal error text
+func (e *ErrConflictingTranslation) Error() string {
+
+ if _, ok := e.key.(string); !ok {
+ return fmt.Sprintf("error: conflicting key '%#v' rule '%s' with text '%s' for locale '%s', value being ignored", e.key, e.rule, e.text, e.locale)
+ }
+
+ return fmt.Sprintf("error: conflicting key '%s' rule '%s' with text '%s' for locale '%s', value being ignored", e.key, e.rule, e.text, e.locale)
+}
+
+// ErrRangeTranslation is the error representing a range translation error
+type ErrRangeTranslation struct {
+ text string
+}
+
+// Error returns ErrRangeTranslation's internal error text
+func (e *ErrRangeTranslation) Error() string {
+ return e.text
+}
+
+// ErrOrdinalTranslation is the error representing an ordinal translation error
+type ErrOrdinalTranslation struct {
+ text string
+}
+
+// Error returns ErrOrdinalTranslation's internal error text
+func (e *ErrOrdinalTranslation) Error() string {
+ return e.text
+}
+
+// ErrCardinalTranslation is the error representing a cardinal translation error
+type ErrCardinalTranslation struct {
+ text string
+}
+
+// Error returns ErrCardinalTranslation's internal error text
+func (e *ErrCardinalTranslation) Error() string {
+ return e.text
+}
+
+// ErrMissingPluralTranslation is the error signifying a missing translation given
+// the locales plural rules.
+type ErrMissingPluralTranslation struct {
+ locale string
+ key interface{}
+ rule locales.PluralRule
+ translationType string
+}
+
+// Error returns ErrMissingPluralTranslation's internal error text
+func (e *ErrMissingPluralTranslation) Error() string {
+
+ if _, ok := e.key.(string); !ok {
+ return fmt.Sprintf("error: missing '%s' plural rule '%s' for translation with key '%#v' and locale '%s'", e.translationType, e.rule, e.key, e.locale)
+ }
+
+ return fmt.Sprintf("error: missing '%s' plural rule '%s' for translation with key '%s' and locale '%s'", e.translationType, e.rule, e.key, e.locale)
+}
+
+// ErrMissingBracket is the error representing a missing bracket in a translation
+// eg. This is a {0 <-- missing ending '}'
+type ErrMissingBracket struct {
+ locale string
+ key interface{}
+ text string
+}
+
+// Error returns ErrMissingBracket error message
+func (e *ErrMissingBracket) Error() string {
+ return fmt.Sprintf("error: missing bracket '{}', in translation. locale: '%s' key: '%v' text: '%s'", e.locale, e.key, e.text)
+}
+
+// ErrBadParamSyntax is the error representing a bad parameter definition in a translation
+// eg. This is a {must-be-int}
+type ErrBadParamSyntax struct {
+ locale string
+ param string
+ key interface{}
+ text string
+}
+
+// Error returns ErrBadParamSyntax error message
+func (e *ErrBadParamSyntax) Error() string {
+ return fmt.Sprintf("error: bad parameter syntax, missing parameter '%s' in translation. locale: '%s' key: '%v' text: '%s'", e.param, e.locale, e.key, e.text)
+}
+
+// import/export errors
+
+// ErrMissingLocale is the error representing an expected locale that could
+// not be found aka locale not registered with the UniversalTranslator Instance
+type ErrMissingLocale struct {
+ locale string
+}
+
+// Error returns ErrMissingLocale's internal error text
+func (e *ErrMissingLocale) Error() string {
+ return fmt.Sprintf("error: locale '%s' not registered.", e.locale)
+}
+
+// ErrBadPluralDefinition is the error representing an incorrect plural definition
+// usually found within translations defined within files during the import process.
+type ErrBadPluralDefinition struct {
+ tl translation
+}
+
+// Error returns ErrBadPluralDefinition's internal error text
+func (e *ErrBadPluralDefinition) Error() string {
+ return fmt.Sprintf("error: bad plural definition '%#v'", e.tl)
+}
diff --git a/baas-kubeengine/vendor/github.com/go-playground/universal-translator/go.mod b/baas-kubeengine/vendor/github.com/go-playground/universal-translator/go.mod
new file mode 100644
index 00000000..8079590f
--- /dev/null
+++ b/baas-kubeengine/vendor/github.com/go-playground/universal-translator/go.mod
@@ -0,0 +1,5 @@
+module github.com/go-playground/universal-translator
+
+go 1.13
+
+require github.com/go-playground/locales v0.13.0
diff --git a/baas-kubeengine/vendor/github.com/go-playground/universal-translator/go.sum b/baas-kubeengine/vendor/github.com/go-playground/universal-translator/go.sum
new file mode 100644
index 00000000..cbbf3241
--- /dev/null
+++ b/baas-kubeengine/vendor/github.com/go-playground/universal-translator/go.sum
@@ -0,0 +1,4 @@
+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=
+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=
diff --git a/baas-kubeengine/vendor/github.com/go-playground/universal-translator/import_export.go b/baas-kubeengine/vendor/github.com/go-playground/universal-translator/import_export.go
new file mode 100644
index 00000000..7bd76f26
--- /dev/null
+++ b/baas-kubeengine/vendor/github.com/go-playground/universal-translator/import_export.go
@@ -0,0 +1,274 @@
+package ut
+
+import (
+ "encoding/json"
+ "fmt"
+ "io/ioutil"
+ "os"
+ "path/filepath"
+
+ "io"
+
+ "github.com/go-playground/locales"
+)
+
+type translation struct {
+ Locale string `json:"locale"`
+ Key interface{} `json:"key"` // either string or integer
+ Translation string `json:"trans"`
+ PluralType string `json:"type,omitempty"`
+ PluralRule string `json:"rule,omitempty"`
+ OverrideExisting bool `json:"override,omitempty"`
+}
+
+const (
+ cardinalType = "Cardinal"
+ ordinalType = "Ordinal"
+ rangeType = "Range"
+)
+
+// ImportExportFormat is the format of the file import or export
+type ImportExportFormat uint8
+
+// supported Export Formats
+const (
+ FormatJSON ImportExportFormat = iota
+)
+
+// Export writes the translations out to a file on disk.
+//
+// NOTE: this currently only works with string or int translations keys.
+func (t *UniversalTranslator) Export(format ImportExportFormat, dirname string) error {
+
+ _, err := os.Stat(dirname)
+ fmt.Println(dirname, err, os.IsNotExist(err))
+ if err != nil {
+
+ if !os.IsNotExist(err) {
+ return err
+ }
+
+ if err = os.MkdirAll(dirname, 0744); err != nil {
+ return err
+ }
+ }
+
+ // build up translations
+ var trans []translation
+ var b []byte
+ var ext string
+
+ for _, locale := range t.translators {
+
+ for k, v := range locale.(*translator).translations {
+ trans = append(trans, translation{
+ Locale: locale.Locale(),
+ Key: k,
+ Translation: v.text,
+ })
+ }
+
+ for k, pluralTrans := range locale.(*translator).cardinalTanslations {
+
+ for i, plural := range pluralTrans {
+
+ // leave enough for all plural rules
+ // but not all are set for all languages.
+ if plural == nil {
+ continue
+ }
+
+ trans = append(trans, translation{
+ Locale: locale.Locale(),
+ Key: k.(string),
+ Translation: plural.text,
+ PluralType: cardinalType,
+ PluralRule: locales.PluralRule(i).String(),
+ })
+ }
+ }
+
+ for k, pluralTrans := range locale.(*translator).ordinalTanslations {
+
+ for i, plural := range pluralTrans {
+
+ // leave enough for all plural rules
+ // but not all are set for all languages.
+ if plural == nil {
+ continue
+ }
+
+ trans = append(trans, translation{
+ Locale: locale.Locale(),
+ Key: k.(string),
+ Translation: plural.text,
+ PluralType: ordinalType,
+ PluralRule: locales.PluralRule(i).String(),
+ })
+ }
+ }
+
+ for k, pluralTrans := range locale.(*translator).rangeTanslations {
+
+ for i, plural := range pluralTrans {
+
+ // leave enough for all plural rules
+ // but not all are set for all languages.
+ if plural == nil {
+ continue
+ }
+
+ trans = append(trans, translation{
+ Locale: locale.Locale(),
+ Key: k.(string),
+ Translation: plural.text,
+ PluralType: rangeType,
+ PluralRule: locales.PluralRule(i).String(),
+ })
+ }
+ }
+
+ switch format {
+ case FormatJSON:
+ b, err = json.MarshalIndent(trans, "", " ")
+ ext = ".json"
+ }
+
+ if err != nil {
+ return err
+ }
+
+ err = ioutil.WriteFile(filepath.Join(dirname, fmt.Sprintf("%s%s", locale.Locale(), ext)), b, 0644)
+ if err != nil {
+ return err
+ }
+
+ trans = trans[0:0]
+ }
+
+ return nil
+}
+
+// Import reads the translations out of a file or directory on disk.
+//
+// NOTE: this currently only works with string or int translations keys.
+func (t *UniversalTranslator) Import(format ImportExportFormat, dirnameOrFilename string) error {
+
+ fi, err := os.Stat(dirnameOrFilename)
+ if err != nil {
+ return err
+ }
+
+ processFn := func(filename string) error {
+
+ f, err := os.Open(filename)
+ if err != nil {
+ return err
+ }
+ defer f.Close()
+
+ return t.ImportByReader(format, f)
+ }
+
+ if !fi.IsDir() {
+ return processFn(dirnameOrFilename)
+ }
+
+ // recursively go through directory
+ walker := func(path string, info os.FileInfo, err error) error {
+
+ if info.IsDir() {
+ return nil
+ }
+
+ switch format {
+ case FormatJSON:
+ // skip non JSON files
+ if filepath.Ext(info.Name()) != ".json" {
+ return nil
+ }
+ }
+
+ return processFn(path)
+ }
+
+ return filepath.Walk(dirnameOrFilename, walker)
+}
+
+// ImportByReader imports the the translations found within the contents read from the supplied reader.
+//
+// NOTE: generally used when assets have been embedded into the binary and are already in memory.
+func (t *UniversalTranslator) ImportByReader(format ImportExportFormat, reader io.Reader) error {
+
+ b, err := ioutil.ReadAll(reader)
+ if err != nil {
+ return err
+ }
+
+ var trans []translation
+
+ switch format {
+ case FormatJSON:
+ err = json.Unmarshal(b, &trans)
+ }
+
+ if err != nil {
+ return err
+ }
+
+ for _, tl := range trans {
+
+ locale, found := t.FindTranslator(tl.Locale)
+ if !found {
+ return &ErrMissingLocale{locale: tl.Locale}
+ }
+
+ pr := stringToPR(tl.PluralRule)
+
+ if pr == locales.PluralRuleUnknown {
+
+ err = locale.Add(tl.Key, tl.Translation, tl.OverrideExisting)
+ if err != nil {
+ return err
+ }
+
+ continue
+ }
+
+ switch tl.PluralType {
+ case cardinalType:
+ err = locale.AddCardinal(tl.Key, tl.Translation, pr, tl.OverrideExisting)
+ case ordinalType:
+ err = locale.AddOrdinal(tl.Key, tl.Translation, pr, tl.OverrideExisting)
+ case rangeType:
+ err = locale.AddRange(tl.Key, tl.Translation, pr, tl.OverrideExisting)
+ default:
+ return &ErrBadPluralDefinition{tl: tl}
+ }
+
+ if err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
+func stringToPR(s string) locales.PluralRule {
+
+ switch s {
+ case "One":
+ return locales.PluralRuleOne
+ case "Two":
+ return locales.PluralRuleTwo
+ case "Few":
+ return locales.PluralRuleFew
+ case "Many":
+ return locales.PluralRuleMany
+ case "Other":
+ return locales.PluralRuleOther
+ default:
+ return locales.PluralRuleUnknown
+ }
+
+}
diff --git a/baas-kubeengine/vendor/github.com/go-playground/universal-translator/logo.png b/baas-kubeengine/vendor/github.com/go-playground/universal-translator/logo.png
new file mode 100644
index 00000000..a37aa8c0
Binary files /dev/null and b/baas-kubeengine/vendor/github.com/go-playground/universal-translator/logo.png differ
diff --git a/baas-kubeengine/vendor/github.com/go-playground/universal-translator/translator.go b/baas-kubeengine/vendor/github.com/go-playground/universal-translator/translator.go
new file mode 100644
index 00000000..cfafce8a
--- /dev/null
+++ b/baas-kubeengine/vendor/github.com/go-playground/universal-translator/translator.go
@@ -0,0 +1,420 @@
+package ut
+
+import (
+ "fmt"
+ "strconv"
+ "strings"
+
+ "github.com/go-playground/locales"
+)
+
+const (
+ paramZero = "{0}"
+ paramOne = "{1}"
+ unknownTranslation = ""
+)
+
+// Translator is universal translators
+// translator instance which is a thin wrapper
+// around locales.Translator instance providing
+// some extra functionality
+type Translator interface {
+ locales.Translator
+
+ // adds a normal translation for a particular language/locale
+ // {#} is the only replacement type accepted and are ad infinitum
+ // eg. one: '{0} day left' other: '{0} days left'
+ Add(key interface{}, text string, override bool) error
+
+ // adds a cardinal plural translation for a particular language/locale
+ // {0} is the only replacement type accepted and only one variable is accepted as
+ // multiple cannot be used for a plural rule determination, unless it is a range;
+ // see AddRange below.
+ // eg. in locale 'en' one: '{0} day left' other: '{0} days left'
+ AddCardinal(key interface{}, text string, rule locales.PluralRule, override bool) error
+
+ // adds an ordinal plural translation for a particular language/locale
+ // {0} is the only replacement type accepted and only one variable is accepted as
+ // multiple cannot be used for a plural rule determination, unless it is a range;
+ // see AddRange below.
+ // eg. in locale 'en' one: '{0}st day of spring' other: '{0}nd day of spring'
+ // - 1st, 2nd, 3rd...
+ AddOrdinal(key interface{}, text string, rule locales.PluralRule, override bool) error
+
+ // adds a range plural translation for a particular language/locale
+ // {0} and {1} are the only replacement types accepted and only these are accepted.
+ // eg. in locale 'nl' one: '{0}-{1} day left' other: '{0}-{1} days left'
+ AddRange(key interface{}, text string, rule locales.PluralRule, override bool) error
+
+ // creates the translation for the locale given the 'key' and params passed in
+ T(key interface{}, params ...string) (string, error)
+
+ // creates the cardinal translation for the locale given the 'key', 'num' and 'digit' arguments
+ // and param passed in
+ C(key interface{}, num float64, digits uint64, param string) (string, error)
+
+ // creates the ordinal translation for the locale given the 'key', 'num' and 'digit' arguments
+ // and param passed in
+ O(key interface{}, num float64, digits uint64, param string) (string, error)
+
+ // creates the range translation for the locale given the 'key', 'num1', 'digit1', 'num2' and
+ // 'digit2' arguments and 'param1' and 'param2' passed in
+ R(key interface{}, num1 float64, digits1 uint64, num2 float64, digits2 uint64, param1, param2 string) (string, error)
+
+ // VerifyTranslations checks to ensures that no plural rules have been
+ // missed within the translations.
+ VerifyTranslations() error
+}
+
+var _ Translator = new(translator)
+var _ locales.Translator = new(translator)
+
+type translator struct {
+ locales.Translator
+ translations map[interface{}]*transText
+ cardinalTanslations map[interface{}][]*transText // array index is mapped to locales.PluralRule index + the locales.PluralRuleUnknown
+ ordinalTanslations map[interface{}][]*transText
+ rangeTanslations map[interface{}][]*transText
+}
+
+type transText struct {
+ text string
+ indexes []int
+}
+
+func newTranslator(trans locales.Translator) Translator {
+ return &translator{
+ Translator: trans,
+ translations: make(map[interface{}]*transText), // translation text broken up by byte index
+ cardinalTanslations: make(map[interface{}][]*transText),
+ ordinalTanslations: make(map[interface{}][]*transText),
+ rangeTanslations: make(map[interface{}][]*transText),
+ }
+}
+
+// Add adds a normal translation for a particular language/locale
+// {#} is the only replacement type accepted and are ad infinitum
+// eg. one: '{0} day left' other: '{0} days left'
+func (t *translator) Add(key interface{}, text string, override bool) error {
+
+ if _, ok := t.translations[key]; ok && !override {
+ return &ErrConflictingTranslation{locale: t.Locale(), key: key, text: text}
+ }
+
+ lb := strings.Count(text, "{")
+ rb := strings.Count(text, "}")
+
+ if lb != rb {
+ return &ErrMissingBracket{locale: t.Locale(), key: key, text: text}
+ }
+
+ trans := &transText{
+ text: text,
+ }
+
+ var idx int
+
+ for i := 0; i < lb; i++ {
+ s := "{" + strconv.Itoa(i) + "}"
+ idx = strings.Index(text, s)
+ if idx == -1 {
+ return &ErrBadParamSyntax{locale: t.Locale(), param: s, key: key, text: text}
+ }
+
+ trans.indexes = append(trans.indexes, idx)
+ trans.indexes = append(trans.indexes, idx+len(s))
+ }
+
+ t.translations[key] = trans
+
+ return nil
+}
+
+// AddCardinal adds a cardinal plural translation for a particular language/locale
+// {0} is the only replacement type accepted and only one variable is accepted as
+// multiple cannot be used for a plural rule determination, unless it is a range;
+// see AddRange below.
+// eg. in locale 'en' one: '{0} day left' other: '{0} days left'
+func (t *translator) AddCardinal(key interface{}, text string, rule locales.PluralRule, override bool) error {
+
+ var verified bool
+
+ // verify plural rule exists for locale
+ for _, pr := range t.PluralsCardinal() {
+ if pr == rule {
+ verified = true
+ break
+ }
+ }
+
+ if !verified {
+ return &ErrCardinalTranslation{text: fmt.Sprintf("error: cardinal plural rule '%s' does not exist for locale '%s' key: '%v' text: '%s'", rule, t.Locale(), key, text)}
+ }
+
+ tarr, ok := t.cardinalTanslations[key]
+ if ok {
+ // verify not adding a conflicting record
+ if len(tarr) > 0 && tarr[rule] != nil && !override {
+ return &ErrConflictingTranslation{locale: t.Locale(), key: key, rule: rule, text: text}
+ }
+
+ } else {
+ tarr = make([]*transText, 7, 7)
+ t.cardinalTanslations[key] = tarr
+ }
+
+ trans := &transText{
+ text: text,
+ indexes: make([]int, 2, 2),
+ }
+
+ tarr[rule] = trans
+
+ idx := strings.Index(text, paramZero)
+ if idx == -1 {
+ tarr[rule] = nil
+ return &ErrCardinalTranslation{text: fmt.Sprintf("error: parameter '%s' not found, may want to use 'Add' instead of 'AddCardinal'. locale: '%s' key: '%v' text: '%s'", paramZero, t.Locale(), key, text)}
+ }
+
+ trans.indexes[0] = idx
+ trans.indexes[1] = idx + len(paramZero)
+
+ return nil
+}
+
+// AddOrdinal adds an ordinal plural translation for a particular language/locale
+// {0} is the only replacement type accepted and only one variable is accepted as
+// multiple cannot be used for a plural rule determination, unless it is a range;
+// see AddRange below.
+// eg. in locale 'en' one: '{0}st day of spring' other: '{0}nd day of spring' - 1st, 2nd, 3rd...
+func (t *translator) AddOrdinal(key interface{}, text string, rule locales.PluralRule, override bool) error {
+
+ var verified bool
+
+ // verify plural rule exists for locale
+ for _, pr := range t.PluralsOrdinal() {
+ if pr == rule {
+ verified = true
+ break
+ }
+ }
+
+ if !verified {
+ return &ErrOrdinalTranslation{text: fmt.Sprintf("error: ordinal plural rule '%s' does not exist for locale '%s' key: '%v' text: '%s'", rule, t.Locale(), key, text)}
+ }
+
+ tarr, ok := t.ordinalTanslations[key]
+ if ok {
+ // verify not adding a conflicting record
+ if len(tarr) > 0 && tarr[rule] != nil && !override {
+ return &ErrConflictingTranslation{locale: t.Locale(), key: key, rule: rule, text: text}
+ }
+
+ } else {
+ tarr = make([]*transText, 7, 7)
+ t.ordinalTanslations[key] = tarr
+ }
+
+ trans := &transText{
+ text: text,
+ indexes: make([]int, 2, 2),
+ }
+
+ tarr[rule] = trans
+
+ idx := strings.Index(text, paramZero)
+ if idx == -1 {
+ tarr[rule] = nil
+ return &ErrOrdinalTranslation{text: fmt.Sprintf("error: parameter '%s' not found, may want to use 'Add' instead of 'AddOrdinal'. locale: '%s' key: '%v' text: '%s'", paramZero, t.Locale(), key, text)}
+ }
+
+ trans.indexes[0] = idx
+ trans.indexes[1] = idx + len(paramZero)
+
+ return nil
+}
+
+// AddRange adds a range plural translation for a particular language/locale
+// {0} and {1} are the only replacement types accepted and only these are accepted.
+// eg. in locale 'nl' one: '{0}-{1} day left' other: '{0}-{1} days left'
+func (t *translator) AddRange(key interface{}, text string, rule locales.PluralRule, override bool) error {
+
+ var verified bool
+
+ // verify plural rule exists for locale
+ for _, pr := range t.PluralsRange() {
+ if pr == rule {
+ verified = true
+ break
+ }
+ }
+
+ if !verified {
+ return &ErrRangeTranslation{text: fmt.Sprintf("error: range plural rule '%s' does not exist for locale '%s' key: '%v' text: '%s'", rule, t.Locale(), key, text)}
+ }
+
+ tarr, ok := t.rangeTanslations[key]
+ if ok {
+ // verify not adding a conflicting record
+ if len(tarr) > 0 && tarr[rule] != nil && !override {
+ return &ErrConflictingTranslation{locale: t.Locale(), key: key, rule: rule, text: text}
+ }
+
+ } else {
+ tarr = make([]*transText, 7, 7)
+ t.rangeTanslations[key] = tarr
+ }
+
+ trans := &transText{
+ text: text,
+ indexes: make([]int, 4, 4),
+ }
+
+ tarr[rule] = trans
+
+ idx := strings.Index(text, paramZero)
+ if idx == -1 {
+ tarr[rule] = nil
+ return &ErrRangeTranslation{text: fmt.Sprintf("error: parameter '%s' not found, are you sure you're adding a Range Translation? locale: '%s' key: '%v' text: '%s'", paramZero, t.Locale(), key, text)}
+ }
+
+ trans.indexes[0] = idx
+ trans.indexes[1] = idx + len(paramZero)
+
+ idx = strings.Index(text, paramOne)
+ if idx == -1 {
+ tarr[rule] = nil
+ return &ErrRangeTranslation{text: fmt.Sprintf("error: parameter '%s' not found, a Range Translation requires two parameters. locale: '%s' key: '%v' text: '%s'", paramOne, t.Locale(), key, text)}
+ }
+
+ trans.indexes[2] = idx
+ trans.indexes[3] = idx + len(paramOne)
+
+ return nil
+}
+
+// T creates the translation for the locale given the 'key' and params passed in
+func (t *translator) T(key interface{}, params ...string) (string, error) {
+
+ trans, ok := t.translations[key]
+ if !ok {
+ return unknownTranslation, ErrUnknowTranslation
+ }
+
+ b := make([]byte, 0, 64)
+
+ var start, end, count int
+
+ for i := 0; i < len(trans.indexes); i++ {
+ end = trans.indexes[i]
+ b = append(b, trans.text[start:end]...)
+ b = append(b, params[count]...)
+ i++
+ start = trans.indexes[i]
+ count++
+ }
+
+ b = append(b, trans.text[start:]...)
+
+ return string(b), nil
+}
+
+// C creates the cardinal translation for the locale given the 'key', 'num' and 'digit' arguments and param passed in
+func (t *translator) C(key interface{}, num float64, digits uint64, param string) (string, error) {
+
+ tarr, ok := t.cardinalTanslations[key]
+ if !ok {
+ return unknownTranslation, ErrUnknowTranslation
+ }
+
+ rule := t.CardinalPluralRule(num, digits)
+
+ trans := tarr[rule]
+
+ b := make([]byte, 0, 64)
+ b = append(b, trans.text[:trans.indexes[0]]...)
+ b = append(b, param...)
+ b = append(b, trans.text[trans.indexes[1]:]...)
+
+ return string(b), nil
+}
+
+// O creates the ordinal translation for the locale given the 'key', 'num' and 'digit' arguments and param passed in
+func (t *translator) O(key interface{}, num float64, digits uint64, param string) (string, error) {
+
+ tarr, ok := t.ordinalTanslations[key]
+ if !ok {
+ return unknownTranslation, ErrUnknowTranslation
+ }
+
+ rule := t.OrdinalPluralRule(num, digits)
+
+ trans := tarr[rule]
+
+ b := make([]byte, 0, 64)
+ b = append(b, trans.text[:trans.indexes[0]]...)
+ b = append(b, param...)
+ b = append(b, trans.text[trans.indexes[1]:]...)
+
+ return string(b), nil
+}
+
+// R creates the range translation for the locale given the 'key', 'num1', 'digit1', 'num2' and 'digit2' arguments
+// and 'param1' and 'param2' passed in
+func (t *translator) R(key interface{}, num1 float64, digits1 uint64, num2 float64, digits2 uint64, param1, param2 string) (string, error) {
+
+ tarr, ok := t.rangeTanslations[key]
+ if !ok {
+ return unknownTranslation, ErrUnknowTranslation
+ }
+
+ rule := t.RangePluralRule(num1, digits1, num2, digits2)
+
+ trans := tarr[rule]
+
+ b := make([]byte, 0, 64)
+ b = append(b, trans.text[:trans.indexes[0]]...)
+ b = append(b, param1...)
+ b = append(b, trans.text[trans.indexes[1]:trans.indexes[2]]...)
+ b = append(b, param2...)
+ b = append(b, trans.text[trans.indexes[3]:]...)
+
+ return string(b), nil
+}
+
+// VerifyTranslations checks to ensures that no plural rules have been
+// missed within the translations.
+func (t *translator) VerifyTranslations() error {
+
+ for k, v := range t.cardinalTanslations {
+
+ for _, rule := range t.PluralsCardinal() {
+
+ if v[rule] == nil {
+ return &ErrMissingPluralTranslation{locale: t.Locale(), translationType: "plural", rule: rule, key: k}
+ }
+ }
+ }
+
+ for k, v := range t.ordinalTanslations {
+
+ for _, rule := range t.PluralsOrdinal() {
+
+ if v[rule] == nil {
+ return &ErrMissingPluralTranslation{locale: t.Locale(), translationType: "ordinal", rule: rule, key: k}
+ }
+ }
+ }
+
+ for k, v := range t.rangeTanslations {
+
+ for _, rule := range t.PluralsRange() {
+
+ if v[rule] == nil {
+ return &ErrMissingPluralTranslation{locale: t.Locale(), translationType: "range", rule: rule, key: k}
+ }
+ }
+ }
+
+ return nil
+}
diff --git a/baas-kubeengine/vendor/github.com/go-playground/universal-translator/universal_translator.go b/baas-kubeengine/vendor/github.com/go-playground/universal-translator/universal_translator.go
new file mode 100644
index 00000000..dbf707f5
--- /dev/null
+++ b/baas-kubeengine/vendor/github.com/go-playground/universal-translator/universal_translator.go
@@ -0,0 +1,113 @@
+package ut
+
+import (
+ "strings"
+
+ "github.com/go-playground/locales"
+)
+
+// UniversalTranslator holds all locale & translation data
+type UniversalTranslator struct {
+ translators map[string]Translator
+ fallback Translator
+}
+
+// New returns a new UniversalTranslator instance set with
+// the fallback locale and locales it should support
+func New(fallback locales.Translator, supportedLocales ...locales.Translator) *UniversalTranslator {
+
+ t := &UniversalTranslator{
+ translators: make(map[string]Translator),
+ }
+
+ for _, v := range supportedLocales {
+
+ trans := newTranslator(v)
+ t.translators[strings.ToLower(trans.Locale())] = trans
+
+ if fallback.Locale() == v.Locale() {
+ t.fallback = trans
+ }
+ }
+
+ if t.fallback == nil && fallback != nil {
+ t.fallback = newTranslator(fallback)
+ }
+
+ return t
+}
+
+// FindTranslator trys to find a Translator based on an array of locales
+// and returns the first one it can find, otherwise returns the
+// fallback translator.
+func (t *UniversalTranslator) FindTranslator(locales ...string) (trans Translator, found bool) {
+
+ for _, locale := range locales {
+
+ if trans, found = t.translators[strings.ToLower(locale)]; found {
+ return
+ }
+ }
+
+ return t.fallback, false
+}
+
+// GetTranslator returns the specified translator for the given locale,
+// or fallback if not found
+func (t *UniversalTranslator) GetTranslator(locale string) (trans Translator, found bool) {
+
+ if trans, found = t.translators[strings.ToLower(locale)]; found {
+ return
+ }
+
+ return t.fallback, false
+}
+
+// GetFallback returns the fallback locale
+func (t *UniversalTranslator) GetFallback() Translator {
+ return t.fallback
+}
+
+// AddTranslator adds the supplied translator, if it already exists the override param
+// will be checked and if false an error will be returned, otherwise the translator will be
+// overridden; if the fallback matches the supplied translator it will be overridden as well
+// NOTE: this is normally only used when translator is embedded within a library
+func (t *UniversalTranslator) AddTranslator(translator locales.Translator, override bool) error {
+
+ lc := strings.ToLower(translator.Locale())
+ _, ok := t.translators[lc]
+ if ok && !override {
+ return &ErrExistingTranslator{locale: translator.Locale()}
+ }
+
+ trans := newTranslator(translator)
+
+ if t.fallback.Locale() == translator.Locale() {
+
+ // because it's optional to have a fallback, I don't impose that limitation
+ // don't know why you wouldn't but...
+ if !override {
+ return &ErrExistingTranslator{locale: translator.Locale()}
+ }
+
+ t.fallback = trans
+ }
+
+ t.translators[lc] = trans
+
+ return nil
+}
+
+// VerifyTranslations runs through all locales and identifies any issues
+// eg. missing plural rules for a locale
+func (t *UniversalTranslator) VerifyTranslations() (err error) {
+
+ for _, trans := range t.translators {
+ err = trans.VerifyTranslations()
+ if err != nil {
+ return
+ }
+ }
+
+ return
+}
diff --git a/baas-kubeengine/vendor/gopkg.in/go-playground/validator.v8/.gitignore b/baas-kubeengine/vendor/github.com/go-playground/validator/v10/.gitignore
similarity index 94%
rename from baas-kubeengine/vendor/gopkg.in/go-playground/validator.v8/.gitignore
rename to baas-kubeengine/vendor/github.com/go-playground/validator/v10/.gitignore
index 792ca00d..6e43fac0 100644
--- a/baas-kubeengine/vendor/gopkg.in/go-playground/validator.v8/.gitignore
+++ b/baas-kubeengine/vendor/github.com/go-playground/validator/v10/.gitignore
@@ -6,6 +6,7 @@
# Folders
_obj
_test
+bin
# Architecture specific extensions/prefixes
*.[568vq]
@@ -26,4 +27,4 @@ _testmain.go
*.out
*.txt
cover.html
-README.html
\ No newline at end of file
+README.html
diff --git a/baas-kubeengine/vendor/github.com/go-playground/validator/v10/.travis.yml b/baas-kubeengine/vendor/github.com/go-playground/validator/v10/.travis.yml
new file mode 100644
index 00000000..85a7be34
--- /dev/null
+++ b/baas-kubeengine/vendor/github.com/go-playground/validator/v10/.travis.yml
@@ -0,0 +1,29 @@
+language: go
+go:
+ - 1.15.2
+ - tip
+matrix:
+ allow_failures:
+ - go: tip
+
+notifications:
+ email:
+ recipients: dean.karn@gmail.com
+ on_success: change
+ on_failure: always
+
+before_install:
+ - go install github.com/mattn/goveralls
+ - mkdir -p $GOPATH/src/gopkg.in
+ - ln -s $GOPATH/src/github.com/$TRAVIS_REPO_SLUG $GOPATH/src/gopkg.in/validator.v9
+
+# Only clone the most recent commit.
+git:
+ depth: 1
+
+script:
+ - go test -v -race -covermode=atomic -coverprofile=coverage.coverprofile ./...
+
+after_success: |
+ [ $TRAVIS_GO_VERSION = 1.15.2 ] &&
+ goveralls -coverprofile=coverage.coverprofile -service travis-ci -repotoken $COVERALLS_TOKEN
diff --git a/baas-kubeengine/vendor/gopkg.in/go-playground/validator.v8/LICENSE b/baas-kubeengine/vendor/github.com/go-playground/validator/v10/LICENSE
similarity index 100%
rename from baas-kubeengine/vendor/gopkg.in/go-playground/validator.v8/LICENSE
rename to baas-kubeengine/vendor/github.com/go-playground/validator/v10/LICENSE
diff --git a/baas-kubeengine/vendor/github.com/go-playground/validator/v10/Makefile b/baas-kubeengine/vendor/github.com/go-playground/validator/v10/Makefile
new file mode 100644
index 00000000..19c91ed7
--- /dev/null
+++ b/baas-kubeengine/vendor/github.com/go-playground/validator/v10/Makefile
@@ -0,0 +1,18 @@
+GOCMD=GO111MODULE=on go
+
+linters-install:
+ @golangci-lint --version >/dev/null 2>&1 || { \
+ echo "installing linting tools..."; \
+ curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s v1.21.0; \
+ }
+
+lint: linters-install
+ $(PWD)/bin/golangci-lint run
+
+test:
+ $(GOCMD) test -cover -race ./...
+
+bench:
+ $(GOCMD) test -bench=. -benchmem ./...
+
+.PHONY: test lint linters-install
\ No newline at end of file
diff --git a/baas-kubeengine/vendor/github.com/go-playground/validator/v10/README.md b/baas-kubeengine/vendor/github.com/go-playground/validator/v10/README.md
new file mode 100644
index 00000000..04fbb3c8
--- /dev/null
+++ b/baas-kubeengine/vendor/github.com/go-playground/validator/v10/README.md
@@ -0,0 +1,299 @@
+Package validator
+================
+[![Join the chat at https://gitter.im/go-playground/validator](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/go-playground/validator?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
+![Project status](https://img.shields.io/badge/version-10.4.1-green.svg)
+[![Build Status](https://travis-ci.org/go-playground/validator.svg?branch=master)](https://travis-ci.org/go-playground/validator)
+[![Coverage Status](https://coveralls.io/repos/go-playground/validator/badge.svg?branch=master&service=github)](https://coveralls.io/github/go-playground/validator?branch=master)
+[![Go Report Card](https://goreportcard.com/badge/github.com/go-playground/validator)](https://goreportcard.com/report/github.com/go-playground/validator)
+[![GoDoc](https://godoc.org/github.com/go-playground/validator?status.svg)](https://pkg.go.dev/github.com/go-playground/validator/v10)
+![License](https://img.shields.io/dub/l/vibe-d.svg)
+
+Package validator implements value validations for structs and individual fields based on tags.
+
+It has the following **unique** features:
+
+- Cross Field and Cross Struct validations by using validation tags or custom validators.
+- Slice, Array and Map diving, which allows any or all levels of a multidimensional field to be validated.
+- Ability to dive into both map keys and values for validation
+- Handles type interface by determining it's underlying type prior to validation.
+- Handles custom field types such as sql driver Valuer see [Valuer](https://golang.org/src/database/sql/driver/types.go?s=1210:1293#L29)
+- Alias validation tags, which allows for mapping of several validations to a single tag for easier defining of validations on structs
+- Extraction of custom defined Field Name e.g. can specify to extract the JSON name while validating and have it available in the resulting FieldError
+- Customizable i18n aware error messages.
+- Default validator for the [gin](https://github.com/gin-gonic/gin) web framework; upgrading from v8 to v9 in gin see [here](https://github.com/go-playground/validator/tree/master/_examples/gin-upgrading-overriding)
+
+Installation
+------------
+
+Use go get.
+
+ go get github.com/go-playground/validator/v10
+
+Then import the validator package into your own code.
+
+ import "github.com/go-playground/validator/v10"
+
+Error Return Value
+-------
+
+Validation functions return type error
+
+They return type error to avoid the issue discussed in the following, where err is always != nil:
+
+* http://stackoverflow.com/a/29138676/3158232
+* https://github.com/go-playground/validator/issues/134
+
+Validator only InvalidValidationError for bad validation input, nil or ValidationErrors as type error; so, in your code all you need to do is check if the error returned is not nil, and if it's not check if error is InvalidValidationError ( if necessary, most of the time it isn't ) type cast it to type ValidationErrors like so:
+
+```go
+err := validate.Struct(mystruct)
+validationErrors := err.(validator.ValidationErrors)
+ ```
+
+Usage and documentation
+------
+
+Please see https://godoc.org/github.com/go-playground/validator for detailed usage docs.
+
+##### Examples:
+
+- [Simple](https://github.com/go-playground/validator/blob/master/_examples/simple/main.go)
+- [Custom Field Types](https://github.com/go-playground/validator/blob/master/_examples/custom/main.go)
+- [Struct Level](https://github.com/go-playground/validator/blob/master/_examples/struct-level/main.go)
+- [Translations & Custom Errors](https://github.com/go-playground/validator/blob/master/_examples/translations/main.go)
+- [Gin upgrade and/or override validator](https://github.com/go-playground/validator/tree/v9/_examples/gin-upgrading-overriding)
+- [wash - an example application putting it all together](https://github.com/bluesuncorp/wash)
+
+Baked-in Validations
+------
+
+### Fields:
+
+| Tag | Description |
+| - | - |
+| eqcsfield | Field Equals Another Field (relative)|
+| eqfield | Field Equals Another Field |
+| fieldcontains | NOT DOCUMENTED IN doc.go |
+| fieldexcludes | NOT DOCUMENTED IN doc.go |
+| gtcsfield | Field Greater Than Another Relative Field |
+| gtecsfield | Field Greater Than or Equal To Another Relative Field |
+| gtefield | Field Greater Than or Equal To Another Field |
+| gtfield | Field Greater Than Another Field |
+| ltcsfield | Less Than Another Relative Field |
+| ltecsfield | Less Than or Equal To Another Relative Field |
+| ltefield | Less Than or Equal To Another Field |
+| ltfield | Less Than Another Field |
+| necsfield | Field Does Not Equal Another Field (relative) |
+| nefield | Field Does Not Equal Another Field |
+
+### Network:
+
+| Tag | Description |
+| - | - |
+| cidr | Classless Inter-Domain Routing CIDR |
+| cidrv4 | Classless Inter-Domain Routing CIDRv4 |
+| cidrv6 | Classless Inter-Domain Routing CIDRv6 |
+| datauri | Data URL |
+| fqdn | Full Qualified Domain Name (FQDN) |
+| hostname | Hostname RFC 952 |
+| hostname_port | HostPort |
+| hostname_rfc1123 | Hostname RFC 1123 |
+| ip | Internet Protocol Address IP |
+| ip4_addr | Internet Protocol Address IPv4 |
+| ip6_addr |Internet Protocol Address IPv6 |
+| ip_addr | Internet Protocol Address IP |
+| ipv4 | Internet Protocol Address IPv4 |
+| ipv6 | Internet Protocol Address IPv6 |
+| mac | Media Access Control Address MAC |
+| tcp4_addr | Transmission Control Protocol Address TCPv4 |
+| tcp6_addr | Transmission Control Protocol Address TCPv6 |
+| tcp_addr | Transmission Control Protocol Address TCP |
+| udp4_addr | User Datagram Protocol Address UDPv4 |
+| udp6_addr | User Datagram Protocol Address UDPv6 |
+| udp_addr | User Datagram Protocol Address UDP |
+| unix_addr | Unix domain socket end point Address |
+| uri | URI String |
+| url | URL String |
+| url_encoded | URL Encoded |
+| urn_rfc2141 | Urn RFC 2141 String |
+
+### Strings:
+
+| Tag | Description |
+| - | - |
+| alpha | Alpha Only |
+| alphanum | Alphanumeric |
+| alphanumunicode | Alphanumeric Unicode |
+| alphaunicode | Alpha Unicode |
+| ascii | ASCII |
+| contains | Contains |
+| containsany | Contains Any |
+| containsrune | Contains Rune |
+| endswith | Ends With |
+| lowercase | Lowercase |
+| multibyte | Multi-Byte Characters |
+| number | NOT DOCUMENTED IN doc.go |
+| numeric | Numeric |
+| printascii | Printable ASCII |
+| startswith | Starts With |
+| uppercase | Uppercase |
+
+### Format:
+| Tag | Description |
+| - | - |
+| base64 | Base64 String |
+| base64url | Base64URL String |
+| btc_addr | Bitcoin Address |
+| btc_addr_bech32 | Bitcoin Bech32 Address (segwit) |
+| datetime | Datetime |
+| e164 | e164 formatted phone number |
+| email | E-mail String
+| eth_addr | Ethereum Address |
+| hexadecimal | Hexadecimal String |
+| hexcolor | Hexcolor String |
+| hsl | HSL String |
+| hsla | HSLA String |
+| html | HTML Tags |
+| html_encoded | HTML Encoded |
+| isbn | International Standard Book Number |
+| isbn10 | International Standard Book Number 10 |
+| isbn13 | International Standard Book Number 13 |
+| json | JSON |
+| latitude | Latitude |
+| longitude | Longitude |
+| rgb | RGB String |
+| rgba | RGBA String |
+| ssn | Social Security Number SSN |
+| uuid | Universally Unique Identifier UUID |
+| uuid3 | Universally Unique Identifier UUID v3 |
+| uuid3_rfc4122 | Universally Unique Identifier UUID v3 RFC4122 |
+| uuid4 | Universally Unique Identifier UUID v4 |
+| uuid4_rfc4122 | Universally Unique Identifier UUID v4 RFC4122 |
+| uuid5 | Universally Unique Identifier UUID v5 |
+| uuid5_rfc4122 | Universally Unique Identifier UUID v5 RFC4122 |
+| uuid_rfc4122 | Universally Unique Identifier UUID RFC4122 |
+
+### Comparisons:
+| Tag | Description |
+| - | - |
+| eq | Equals |
+| gt | Greater than|
+| gte |Greater than or equal |
+| lt | Less Than |
+| lte | Less Than or Equal |
+| ne | Not Equal |
+
+### Other:
+| Tag | Description |
+| - | - |
+| dir | Directory |
+| endswith | Ends With |
+| excludes | Excludes |
+| excludesall | Excludes All |
+| excludesrune | Excludes Rune |
+| file | File path |
+| isdefault | Is Default |
+| len | Length |
+| max | Maximum |
+| min | Minimum |
+| oneof | One Of |
+| required | Required |
+| required_if | Required If |
+| required_unless | Required Unless |
+| required_with | Required With |
+| required_with_all | Required With All |
+| required_without | Required Without |
+| required_without_all | Required Without All |
+| excluded_with | Excluded With |
+| excluded_with_all | Excluded With All |
+| excluded_without | Excluded Without |
+| excluded_without_all | Excluded Without All |
+| unique | Unique |
+
+Benchmarks
+------
+###### Run on MacBook Pro (15-inch, 2017) go version go1.10.2 darwin/amd64
+```go
+goos: darwin
+goarch: amd64
+pkg: github.com/go-playground/validator
+BenchmarkFieldSuccess-8 20000000 83.6 ns/op 0 B/op 0 allocs/op
+BenchmarkFieldSuccessParallel-8 50000000 26.8 ns/op 0 B/op 0 allocs/op
+BenchmarkFieldFailure-8 5000000 291 ns/op 208 B/op 4 allocs/op
+BenchmarkFieldFailureParallel-8 20000000 107 ns/op 208 B/op 4 allocs/op
+BenchmarkFieldArrayDiveSuccess-8 2000000 623 ns/op 201 B/op 11 allocs/op
+BenchmarkFieldArrayDiveSuccessParallel-8 10000000 237 ns/op 201 B/op 11 allocs/op
+BenchmarkFieldArrayDiveFailure-8 2000000 859 ns/op 412 B/op 16 allocs/op
+BenchmarkFieldArrayDiveFailureParallel-8 5000000 335 ns/op 413 B/op 16 allocs/op
+BenchmarkFieldMapDiveSuccess-8 1000000 1292 ns/op 432 B/op 18 allocs/op
+BenchmarkFieldMapDiveSuccessParallel-8 3000000 467 ns/op 432 B/op 18 allocs/op
+BenchmarkFieldMapDiveFailure-8 1000000 1082 ns/op 512 B/op 16 allocs/op
+BenchmarkFieldMapDiveFailureParallel-8 5000000 425 ns/op 512 B/op 16 allocs/op
+BenchmarkFieldMapDiveWithKeysSuccess-8 1000000 1539 ns/op 480 B/op 21 allocs/op
+BenchmarkFieldMapDiveWithKeysSuccessParallel-8 3000000 613 ns/op 480 B/op 21 allocs/op
+BenchmarkFieldMapDiveWithKeysFailure-8 1000000 1413 ns/op 721 B/op 21 allocs/op
+BenchmarkFieldMapDiveWithKeysFailureParallel-8 3000000 575 ns/op 721 B/op 21 allocs/op
+BenchmarkFieldCustomTypeSuccess-8 10000000 216 ns/op 32 B/op 2 allocs/op
+BenchmarkFieldCustomTypeSuccessParallel-8 20000000 82.2 ns/op 32 B/op 2 allocs/op
+BenchmarkFieldCustomTypeFailure-8 5000000 274 ns/op 208 B/op 4 allocs/op
+BenchmarkFieldCustomTypeFailureParallel-8 20000000 116 ns/op 208 B/op 4 allocs/op
+BenchmarkFieldOrTagSuccess-8 2000000 740 ns/op 16 B/op 1 allocs/op
+BenchmarkFieldOrTagSuccessParallel-8 3000000 474 ns/op 16 B/op 1 allocs/op
+BenchmarkFieldOrTagFailure-8 3000000 471 ns/op 224 B/op 5 allocs/op
+BenchmarkFieldOrTagFailureParallel-8 3000000 414 ns/op 224 B/op 5 allocs/op
+BenchmarkStructLevelValidationSuccess-8 10000000 213 ns/op 32 B/op 2 allocs/op
+BenchmarkStructLevelValidationSuccessParallel-8 20000000 91.8 ns/op 32 B/op 2 allocs/op
+BenchmarkStructLevelValidationFailure-8 3000000 473 ns/op 304 B/op 8 allocs/op
+BenchmarkStructLevelValidationFailureParallel-8 10000000 234 ns/op 304 B/op 8 allocs/op
+BenchmarkStructSimpleCustomTypeSuccess-8 5000000 385 ns/op 32 B/op 2 allocs/op
+BenchmarkStructSimpleCustomTypeSuccessParallel-8 10000000 161 ns/op 32 B/op 2 allocs/op
+BenchmarkStructSimpleCustomTypeFailure-8 2000000 640 ns/op 424 B/op 9 allocs/op
+BenchmarkStructSimpleCustomTypeFailureParallel-8 5000000 318 ns/op 440 B/op 10 allocs/op
+BenchmarkStructFilteredSuccess-8 2000000 597 ns/op 288 B/op 9 allocs/op
+BenchmarkStructFilteredSuccessParallel-8 10000000 266 ns/op 288 B/op 9 allocs/op
+BenchmarkStructFilteredFailure-8 3000000 454 ns/op 256 B/op 7 allocs/op
+BenchmarkStructFilteredFailureParallel-8 10000000 214 ns/op 256 B/op 7 allocs/op
+BenchmarkStructPartialSuccess-8 3000000 502 ns/op 256 B/op 6 allocs/op
+BenchmarkStructPartialSuccessParallel-8 10000000 225 ns/op 256 B/op 6 allocs/op
+BenchmarkStructPartialFailure-8 2000000 702 ns/op 480 B/op 11 allocs/op
+BenchmarkStructPartialFailureParallel-8 5000000 329 ns/op 480 B/op 11 allocs/op
+BenchmarkStructExceptSuccess-8 2000000 793 ns/op 496 B/op 12 allocs/op
+BenchmarkStructExceptSuccessParallel-8 10000000 193 ns/op 240 B/op 5 allocs/op
+BenchmarkStructExceptFailure-8 2000000 639 ns/op 464 B/op 10 allocs/op
+BenchmarkStructExceptFailureParallel-8 5000000 300 ns/op 464 B/op 10 allocs/op
+BenchmarkStructSimpleCrossFieldSuccess-8 3000000 417 ns/op 72 B/op 3 allocs/op
+BenchmarkStructSimpleCrossFieldSuccessParallel-8 10000000 163 ns/op 72 B/op 3 allocs/op
+BenchmarkStructSimpleCrossFieldFailure-8 2000000 645 ns/op 304 B/op 8 allocs/op
+BenchmarkStructSimpleCrossFieldFailureParallel-8 5000000 285 ns/op 304 B/op 8 allocs/op
+BenchmarkStructSimpleCrossStructCrossFieldSuccess-8 3000000 588 ns/op 80 B/op 4 allocs/op
+BenchmarkStructSimpleCrossStructCrossFieldSuccessParallel-8 10000000 221 ns/op 80 B/op 4 allocs/op
+BenchmarkStructSimpleCrossStructCrossFieldFailure-8 2000000 868 ns/op 320 B/op 9 allocs/op
+BenchmarkStructSimpleCrossStructCrossFieldFailureParallel-8 5000000 337 ns/op 320 B/op 9 allocs/op
+BenchmarkStructSimpleSuccess-8 5000000 260 ns/op 0 B/op 0 allocs/op
+BenchmarkStructSimpleSuccessParallel-8 20000000 90.6 ns/op 0 B/op 0 allocs/op
+BenchmarkStructSimpleFailure-8 2000000 619 ns/op 424 B/op 9 allocs/op
+BenchmarkStructSimpleFailureParallel-8 5000000 296 ns/op 424 B/op 9 allocs/op
+BenchmarkStructComplexSuccess-8 1000000 1454 ns/op 128 B/op 8 allocs/op
+BenchmarkStructComplexSuccessParallel-8 3000000 579 ns/op 128 B/op 8 allocs/op
+BenchmarkStructComplexFailure-8 300000 4140 ns/op 3041 B/op 53 allocs/op
+BenchmarkStructComplexFailureParallel-8 1000000 2127 ns/op 3041 B/op 53 allocs/op
+BenchmarkOneof-8 10000000 140 ns/op 0 B/op 0 allocs/op
+BenchmarkOneofParallel-8 20000000 70.1 ns/op 0 B/op 0 allocs/op
+```
+
+Complementary Software
+----------------------
+
+Here is a list of software that complements using this library either pre or post validation.
+
+* [form](https://github.com/go-playground/form) - Decodes url.Values into Go value(s) and Encodes Go value(s) into url.Values. Dual Array and Full map support.
+* [mold](https://github.com/go-playground/mold) - A general library to help modify or set data within data structures and other objects
+
+How to Contribute
+------
+
+Make a pull request...
+
+License
+------
+Distributed under MIT License, please see license file within the code for more details.
diff --git a/baas-kubeengine/vendor/github.com/go-playground/validator/v10/baked_in.go b/baas-kubeengine/vendor/github.com/go-playground/validator/v10/baked_in.go
new file mode 100644
index 00000000..6ce762d1
--- /dev/null
+++ b/baas-kubeengine/vendor/github.com/go-playground/validator/v10/baked_in.go
@@ -0,0 +1,2285 @@
+package validator
+
+import (
+ "bytes"
+ "context"
+ "crypto/sha256"
+ "encoding/hex"
+ "encoding/json"
+ "fmt"
+ "net"
+ "net/url"
+ "os"
+ "reflect"
+ "strconv"
+ "strings"
+ "sync"
+ "time"
+ "unicode/utf8"
+
+ "golang.org/x/crypto/sha3"
+
+ urn "github.com/leodido/go-urn"
+)
+
+// Func accepts a FieldLevel interface for all validation needs. The return
+// value should be true when validation succeeds.
+type Func func(fl FieldLevel) bool
+
+// FuncCtx accepts a context.Context and FieldLevel interface for all
+// validation needs. The return value should be true when validation succeeds.
+type FuncCtx func(ctx context.Context, fl FieldLevel) bool
+
+// wrapFunc wraps noramal Func makes it compatible with FuncCtx
+func wrapFunc(fn Func) FuncCtx {
+ if fn == nil {
+ return nil // be sure not to wrap a bad function.
+ }
+ return func(ctx context.Context, fl FieldLevel) bool {
+ return fn(fl)
+ }
+}
+
+var (
+ restrictedTags = map[string]struct{}{
+ diveTag: {},
+ keysTag: {},
+ endKeysTag: {},
+ structOnlyTag: {},
+ omitempty: {},
+ skipValidationTag: {},
+ utf8HexComma: {},
+ utf8Pipe: {},
+ noStructLevelTag: {},
+ requiredTag: {},
+ isdefault: {},
+ }
+
+ // BakedInAliasValidators is a default mapping of a single validation tag that
+ // defines a common or complex set of validation(s) to simplify
+ // adding validation to structs.
+ bakedInAliases = map[string]string{
+ "iscolor": "hexcolor|rgb|rgba|hsl|hsla",
+ "country_code": "iso3166_1_alpha2|iso3166_1_alpha3|iso3166_1_alpha_numeric",
+ }
+
+ // BakedInValidators is the default map of ValidationFunc
+ // you can add, remove or even replace items to suite your needs,
+ // or even disregard and use your own map if so desired.
+ bakedInValidators = map[string]Func{
+ "required": hasValue,
+ "required_if": requiredIf,
+ "required_unless": requiredUnless,
+ "required_with": requiredWith,
+ "required_with_all": requiredWithAll,
+ "required_without": requiredWithout,
+ "required_without_all": requiredWithoutAll,
+ "excluded_with": excludedWith,
+ "excluded_with_all": excludedWithAll,
+ "excluded_without": excludedWithout,
+ "excluded_without_all": excludedWithoutAll,
+ "isdefault": isDefault,
+ "len": hasLengthOf,
+ "min": hasMinOf,
+ "max": hasMaxOf,
+ "eq": isEq,
+ "ne": isNe,
+ "lt": isLt,
+ "lte": isLte,
+ "gt": isGt,
+ "gte": isGte,
+ "eqfield": isEqField,
+ "eqcsfield": isEqCrossStructField,
+ "necsfield": isNeCrossStructField,
+ "gtcsfield": isGtCrossStructField,
+ "gtecsfield": isGteCrossStructField,
+ "ltcsfield": isLtCrossStructField,
+ "ltecsfield": isLteCrossStructField,
+ "nefield": isNeField,
+ "gtefield": isGteField,
+ "gtfield": isGtField,
+ "ltefield": isLteField,
+ "ltfield": isLtField,
+ "fieldcontains": fieldContains,
+ "fieldexcludes": fieldExcludes,
+ "alpha": isAlpha,
+ "alphanum": isAlphanum,
+ "alphaunicode": isAlphaUnicode,
+ "alphanumunicode": isAlphanumUnicode,
+ "numeric": isNumeric,
+ "number": isNumber,
+ "hexadecimal": isHexadecimal,
+ "hexcolor": isHEXColor,
+ "rgb": isRGB,
+ "rgba": isRGBA,
+ "hsl": isHSL,
+ "hsla": isHSLA,
+ "e164": isE164,
+ "email": isEmail,
+ "url": isURL,
+ "uri": isURI,
+ "urn_rfc2141": isUrnRFC2141, // RFC 2141
+ "file": isFile,
+ "base64": isBase64,
+ "base64url": isBase64URL,
+ "contains": contains,
+ "containsany": containsAny,
+ "containsrune": containsRune,
+ "excludes": excludes,
+ "excludesall": excludesAll,
+ "excludesrune": excludesRune,
+ "startswith": startsWith,
+ "endswith": endsWith,
+ "startsnotwith": startsNotWith,
+ "endsnotwith": endsNotWith,
+ "isbn": isISBN,
+ "isbn10": isISBN10,
+ "isbn13": isISBN13,
+ "eth_addr": isEthereumAddress,
+ "btc_addr": isBitcoinAddress,
+ "btc_addr_bech32": isBitcoinBech32Address,
+ "uuid": isUUID,
+ "uuid3": isUUID3,
+ "uuid4": isUUID4,
+ "uuid5": isUUID5,
+ "uuid_rfc4122": isUUIDRFC4122,
+ "uuid3_rfc4122": isUUID3RFC4122,
+ "uuid4_rfc4122": isUUID4RFC4122,
+ "uuid5_rfc4122": isUUID5RFC4122,
+ "ascii": isASCII,
+ "printascii": isPrintableASCII,
+ "multibyte": hasMultiByteCharacter,
+ "datauri": isDataURI,
+ "latitude": isLatitude,
+ "longitude": isLongitude,
+ "ssn": isSSN,
+ "ipv4": isIPv4,
+ "ipv6": isIPv6,
+ "ip": isIP,
+ "cidrv4": isCIDRv4,
+ "cidrv6": isCIDRv6,
+ "cidr": isCIDR,
+ "tcp4_addr": isTCP4AddrResolvable,
+ "tcp6_addr": isTCP6AddrResolvable,
+ "tcp_addr": isTCPAddrResolvable,
+ "udp4_addr": isUDP4AddrResolvable,
+ "udp6_addr": isUDP6AddrResolvable,
+ "udp_addr": isUDPAddrResolvable,
+ "ip4_addr": isIP4AddrResolvable,
+ "ip6_addr": isIP6AddrResolvable,
+ "ip_addr": isIPAddrResolvable,
+ "unix_addr": isUnixAddrResolvable,
+ "mac": isMAC,
+ "hostname": isHostnameRFC952, // RFC 952
+ "hostname_rfc1123": isHostnameRFC1123, // RFC 1123
+ "fqdn": isFQDN,
+ "unique": isUnique,
+ "oneof": isOneOf,
+ "html": isHTML,
+ "html_encoded": isHTMLEncoded,
+ "url_encoded": isURLEncoded,
+ "dir": isDir,
+ "json": isJSON,
+ "hostname_port": isHostnamePort,
+ "lowercase": isLowercase,
+ "uppercase": isUppercase,
+ "datetime": isDatetime,
+ "timezone": isTimeZone,
+ "iso3166_1_alpha2": isIso3166Alpha2,
+ "iso3166_1_alpha3": isIso3166Alpha3,
+ "iso3166_1_alpha_numeric": isIso3166AlphaNumeric,
+ }
+)
+
+var oneofValsCache = map[string][]string{}
+var oneofValsCacheRWLock = sync.RWMutex{}
+
+func parseOneOfParam2(s string) []string {
+ oneofValsCacheRWLock.RLock()
+ vals, ok := oneofValsCache[s]
+ oneofValsCacheRWLock.RUnlock()
+ if !ok {
+ oneofValsCacheRWLock.Lock()
+ vals = splitParamsRegex.FindAllString(s, -1)
+ for i := 0; i < len(vals); i++ {
+ vals[i] = strings.Replace(vals[i], "'", "", -1)
+ }
+ oneofValsCache[s] = vals
+ oneofValsCacheRWLock.Unlock()
+ }
+ return vals
+}
+
+func isURLEncoded(fl FieldLevel) bool {
+ return uRLEncodedRegex.MatchString(fl.Field().String())
+}
+
+func isHTMLEncoded(fl FieldLevel) bool {
+ return hTMLEncodedRegex.MatchString(fl.Field().String())
+}
+
+func isHTML(fl FieldLevel) bool {
+ return hTMLRegex.MatchString(fl.Field().String())
+}
+
+func isOneOf(fl FieldLevel) bool {
+ vals := parseOneOfParam2(fl.Param())
+
+ field := fl.Field()
+
+ var v string
+ switch field.Kind() {
+ case reflect.String:
+ v = field.String()
+ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
+ v = strconv.FormatInt(field.Int(), 10)
+ case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
+ v = strconv.FormatUint(field.Uint(), 10)
+ default:
+ panic(fmt.Sprintf("Bad field type %T", field.Interface()))
+ }
+ for i := 0; i < len(vals); i++ {
+ if vals[i] == v {
+ return true
+ }
+ }
+ return false
+}
+
+// isUnique is the validation function for validating if each array|slice|map value is unique
+func isUnique(fl FieldLevel) bool {
+
+ field := fl.Field()
+ param := fl.Param()
+ v := reflect.ValueOf(struct{}{})
+
+ switch field.Kind() {
+ case reflect.Slice, reflect.Array:
+ elem := field.Type().Elem()
+ if elem.Kind() == reflect.Ptr {
+ elem = elem.Elem()
+ }
+
+ if param == "" {
+ m := reflect.MakeMap(reflect.MapOf(elem, v.Type()))
+
+ for i := 0; i < field.Len(); i++ {
+ m.SetMapIndex(reflect.Indirect(field.Index(i)), v)
+ }
+ return field.Len() == m.Len()
+ }
+
+ sf, ok := elem.FieldByName(param)
+ if !ok {
+ panic(fmt.Sprintf("Bad field name %s", param))
+ }
+
+ sfTyp := sf.Type
+ if sfTyp.Kind() == reflect.Ptr {
+ sfTyp = sfTyp.Elem()
+ }
+
+ m := reflect.MakeMap(reflect.MapOf(sfTyp, v.Type()))
+ for i := 0; i < field.Len(); i++ {
+ m.SetMapIndex(reflect.Indirect(reflect.Indirect(field.Index(i)).FieldByName(param)), v)
+ }
+ return field.Len() == m.Len()
+ case reflect.Map:
+ m := reflect.MakeMap(reflect.MapOf(field.Type().Elem(), v.Type()))
+
+ for _, k := range field.MapKeys() {
+ m.SetMapIndex(field.MapIndex(k), v)
+ }
+ return field.Len() == m.Len()
+ default:
+ panic(fmt.Sprintf("Bad field type %T", field.Interface()))
+ }
+}
+
+// IsMAC is the validation function for validating if the field's value is a valid MAC address.
+func isMAC(fl FieldLevel) bool {
+
+ _, err := net.ParseMAC(fl.Field().String())
+
+ return err == nil
+}
+
+// IsCIDRv4 is the validation function for validating if the field's value is a valid v4 CIDR address.
+func isCIDRv4(fl FieldLevel) bool {
+
+ ip, _, err := net.ParseCIDR(fl.Field().String())
+
+ return err == nil && ip.To4() != nil
+}
+
+// IsCIDRv6 is the validation function for validating if the field's value is a valid v6 CIDR address.
+func isCIDRv6(fl FieldLevel) bool {
+
+ ip, _, err := net.ParseCIDR(fl.Field().String())
+
+ return err == nil && ip.To4() == nil
+}
+
+// IsCIDR is the validation function for validating if the field's value is a valid v4 or v6 CIDR address.
+func isCIDR(fl FieldLevel) bool {
+
+ _, _, err := net.ParseCIDR(fl.Field().String())
+
+ return err == nil
+}
+
+// IsIPv4 is the validation function for validating if a value is a valid v4 IP address.
+func isIPv4(fl FieldLevel) bool {
+
+ ip := net.ParseIP(fl.Field().String())
+
+ return ip != nil && ip.To4() != nil
+}
+
+// IsIPv6 is the validation function for validating if the field's value is a valid v6 IP address.
+func isIPv6(fl FieldLevel) bool {
+
+ ip := net.ParseIP(fl.Field().String())
+
+ return ip != nil && ip.To4() == nil
+}
+
+// IsIP is the validation function for validating if the field's value is a valid v4 or v6 IP address.
+func isIP(fl FieldLevel) bool {
+
+ ip := net.ParseIP(fl.Field().String())
+
+ return ip != nil
+}
+
+// IsSSN is the validation function for validating if the field's value is a valid SSN.
+func isSSN(fl FieldLevel) bool {
+
+ field := fl.Field()
+
+ if field.Len() != 11 {
+ return false
+ }
+
+ return sSNRegex.MatchString(field.String())
+}
+
+// IsLongitude is the validation function for validating if the field's value is a valid longitude coordinate.
+func isLongitude(fl FieldLevel) bool {
+ field := fl.Field()
+
+ var v string
+ switch field.Kind() {
+ case reflect.String:
+ v = field.String()
+ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
+ v = strconv.FormatInt(field.Int(), 10)
+ case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
+ v = strconv.FormatUint(field.Uint(), 10)
+ case reflect.Float32:
+ v = strconv.FormatFloat(field.Float(), 'f', -1, 32)
+ case reflect.Float64:
+ v = strconv.FormatFloat(field.Float(), 'f', -1, 64)
+ default:
+ panic(fmt.Sprintf("Bad field type %T", field.Interface()))
+ }
+
+ return longitudeRegex.MatchString(v)
+}
+
+// IsLatitude is the validation function for validating if the field's value is a valid latitude coordinate.
+func isLatitude(fl FieldLevel) bool {
+ field := fl.Field()
+
+ var v string
+ switch field.Kind() {
+ case reflect.String:
+ v = field.String()
+ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
+ v = strconv.FormatInt(field.Int(), 10)
+ case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
+ v = strconv.FormatUint(field.Uint(), 10)
+ case reflect.Float32:
+ v = strconv.FormatFloat(field.Float(), 'f', -1, 32)
+ case reflect.Float64:
+ v = strconv.FormatFloat(field.Float(), 'f', -1, 64)
+ default:
+ panic(fmt.Sprintf("Bad field type %T", field.Interface()))
+ }
+
+ return latitudeRegex.MatchString(v)
+}
+
+// IsDataURI is the validation function for validating if the field's value is a valid data URI.
+func isDataURI(fl FieldLevel) bool {
+
+ uri := strings.SplitN(fl.Field().String(), ",", 2)
+
+ if len(uri) != 2 {
+ return false
+ }
+
+ if !dataURIRegex.MatchString(uri[0]) {
+ return false
+ }
+
+ return base64Regex.MatchString(uri[1])
+}
+
+// HasMultiByteCharacter is the validation function for validating if the field's value has a multi byte character.
+func hasMultiByteCharacter(fl FieldLevel) bool {
+
+ field := fl.Field()
+
+ if field.Len() == 0 {
+ return true
+ }
+
+ return multibyteRegex.MatchString(field.String())
+}
+
+// IsPrintableASCII is the validation function for validating if the field's value is a valid printable ASCII character.
+func isPrintableASCII(fl FieldLevel) bool {
+ return printableASCIIRegex.MatchString(fl.Field().String())
+}
+
+// IsASCII is the validation function for validating if the field's value is a valid ASCII character.
+func isASCII(fl FieldLevel) bool {
+ return aSCIIRegex.MatchString(fl.Field().String())
+}
+
+// IsUUID5 is the validation function for validating if the field's value is a valid v5 UUID.
+func isUUID5(fl FieldLevel) bool {
+ return uUID5Regex.MatchString(fl.Field().String())
+}
+
+// IsUUID4 is the validation function for validating if the field's value is a valid v4 UUID.
+func isUUID4(fl FieldLevel) bool {
+ return uUID4Regex.MatchString(fl.Field().String())
+}
+
+// IsUUID3 is the validation function for validating if the field's value is a valid v3 UUID.
+func isUUID3(fl FieldLevel) bool {
+ return uUID3Regex.MatchString(fl.Field().String())
+}
+
+// IsUUID is the validation function for validating if the field's value is a valid UUID of any version.
+func isUUID(fl FieldLevel) bool {
+ return uUIDRegex.MatchString(fl.Field().String())
+}
+
+// IsUUID5RFC4122 is the validation function for validating if the field's value is a valid RFC4122 v5 UUID.
+func isUUID5RFC4122(fl FieldLevel) bool {
+ return uUID5RFC4122Regex.MatchString(fl.Field().String())
+}
+
+// IsUUID4RFC4122 is the validation function for validating if the field's value is a valid RFC4122 v4 UUID.
+func isUUID4RFC4122(fl FieldLevel) bool {
+ return uUID4RFC4122Regex.MatchString(fl.Field().String())
+}
+
+// IsUUID3RFC4122 is the validation function for validating if the field's value is a valid RFC4122 v3 UUID.
+func isUUID3RFC4122(fl FieldLevel) bool {
+ return uUID3RFC4122Regex.MatchString(fl.Field().String())
+}
+
+// IsUUIDRFC4122 is the validation function for validating if the field's value is a valid RFC4122 UUID of any version.
+func isUUIDRFC4122(fl FieldLevel) bool {
+ return uUIDRFC4122Regex.MatchString(fl.Field().String())
+}
+
+// IsISBN is the validation function for validating if the field's value is a valid v10 or v13 ISBN.
+func isISBN(fl FieldLevel) bool {
+ return isISBN10(fl) || isISBN13(fl)
+}
+
+// IsISBN13 is the validation function for validating if the field's value is a valid v13 ISBN.
+func isISBN13(fl FieldLevel) bool {
+
+ s := strings.Replace(strings.Replace(fl.Field().String(), "-", "", 4), " ", "", 4)
+
+ if !iSBN13Regex.MatchString(s) {
+ return false
+ }
+
+ var checksum int32
+ var i int32
+
+ factor := []int32{1, 3}
+
+ for i = 0; i < 12; i++ {
+ checksum += factor[i%2] * int32(s[i]-'0')
+ }
+
+ return (int32(s[12]-'0'))-((10-(checksum%10))%10) == 0
+}
+
+// IsISBN10 is the validation function for validating if the field's value is a valid v10 ISBN.
+func isISBN10(fl FieldLevel) bool {
+
+ s := strings.Replace(strings.Replace(fl.Field().String(), "-", "", 3), " ", "", 3)
+
+ if !iSBN10Regex.MatchString(s) {
+ return false
+ }
+
+ var checksum int32
+ var i int32
+
+ for i = 0; i < 9; i++ {
+ checksum += (i + 1) * int32(s[i]-'0')
+ }
+
+ if s[9] == 'X' {
+ checksum += 10 * 10
+ } else {
+ checksum += 10 * int32(s[9]-'0')
+ }
+
+ return checksum%11 == 0
+}
+
+// IsEthereumAddress is the validation function for validating if the field's value is a valid Ethereum address.
+func isEthereumAddress(fl FieldLevel) bool {
+ address := fl.Field().String()
+
+ if !ethAddressRegex.MatchString(address) {
+ return false
+ }
+
+ if ethaddressRegexUpper.MatchString(address) || ethAddressRegexLower.MatchString(address) {
+ return true
+ }
+
+ // Checksum validation. Reference: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-55.md
+ address = address[2:] // Skip "0x" prefix.
+ h := sha3.NewLegacyKeccak256()
+ // hash.Hash's io.Writer implementation says it never returns an error. https://golang.org/pkg/hash/#Hash
+ _, _ = h.Write([]byte(strings.ToLower(address)))
+ hash := hex.EncodeToString(h.Sum(nil))
+
+ for i := 0; i < len(address); i++ {
+ if address[i] <= '9' { // Skip 0-9 digits: they don't have upper/lower-case.
+ continue
+ }
+ if hash[i] > '7' && address[i] >= 'a' || hash[i] <= '7' && address[i] <= 'F' {
+ return false
+ }
+ }
+
+ return true
+}
+
+// IsBitcoinAddress is the validation function for validating if the field's value is a valid btc address
+func isBitcoinAddress(fl FieldLevel) bool {
+ address := fl.Field().String()
+
+ if !btcAddressRegex.MatchString(address) {
+ return false
+ }
+
+ alphabet := []byte("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")
+
+ decode := [25]byte{}
+
+ for _, n := range []byte(address) {
+ d := bytes.IndexByte(alphabet, n)
+
+ for i := 24; i >= 0; i-- {
+ d += 58 * int(decode[i])
+ decode[i] = byte(d % 256)
+ d /= 256
+ }
+ }
+
+ h := sha256.New()
+ _, _ = h.Write(decode[:21])
+ d := h.Sum([]byte{})
+ h = sha256.New()
+ _, _ = h.Write(d)
+
+ validchecksum := [4]byte{}
+ computedchecksum := [4]byte{}
+
+ copy(computedchecksum[:], h.Sum(d[:0]))
+ copy(validchecksum[:], decode[21:])
+
+ return validchecksum == computedchecksum
+}
+
+// IsBitcoinBech32Address is the validation function for validating if the field's value is a valid bech32 btc address
+func isBitcoinBech32Address(fl FieldLevel) bool {
+ address := fl.Field().String()
+
+ if !btcLowerAddressRegexBech32.MatchString(address) && !btcUpperAddressRegexBech32.MatchString(address) {
+ return false
+ }
+
+ am := len(address) % 8
+
+ if am == 0 || am == 3 || am == 5 {
+ return false
+ }
+
+ address = strings.ToLower(address)
+
+ alphabet := "qpzry9x8gf2tvdw0s3jn54khce6mua7l"
+
+ hr := []int{3, 3, 0, 2, 3} // the human readable part will always be bc
+ addr := address[3:]
+ dp := make([]int, 0, len(addr))
+
+ for _, c := range addr {
+ dp = append(dp, strings.IndexRune(alphabet, c))
+ }
+
+ ver := dp[0]
+
+ if ver < 0 || ver > 16 {
+ return false
+ }
+
+ if ver == 0 {
+ if len(address) != 42 && len(address) != 62 {
+ return false
+ }
+ }
+
+ values := append(hr, dp...)
+
+ GEN := []int{0x3b6a57b2, 0x26508e6d, 0x1ea119fa, 0x3d4233dd, 0x2a1462b3}
+
+ p := 1
+
+ for _, v := range values {
+ b := p >> 25
+ p = (p&0x1ffffff)<<5 ^ v
+
+ for i := 0; i < 5; i++ {
+ if (b>>uint(i))&1 == 1 {
+ p ^= GEN[i]
+ }
+ }
+ }
+
+ if p != 1 {
+ return false
+ }
+
+ b := uint(0)
+ acc := 0
+ mv := (1 << 5) - 1
+ var sw []int
+
+ for _, v := range dp[1 : len(dp)-6] {
+ acc = (acc << 5) | v
+ b += 5
+ for b >= 8 {
+ b -= 8
+ sw = append(sw, (acc>>b)&mv)
+ }
+ }
+
+ if len(sw) < 2 || len(sw) > 40 {
+ return false
+ }
+
+ return true
+}
+
+// ExcludesRune is the validation function for validating that the field's value does not contain the rune specified within the param.
+func excludesRune(fl FieldLevel) bool {
+ return !containsRune(fl)
+}
+
+// ExcludesAll is the validation function for validating that the field's value does not contain any of the characters specified within the param.
+func excludesAll(fl FieldLevel) bool {
+ return !containsAny(fl)
+}
+
+// Excludes is the validation function for validating that the field's value does not contain the text specified within the param.
+func excludes(fl FieldLevel) bool {
+ return !contains(fl)
+}
+
+// ContainsRune is the validation function for validating that the field's value contains the rune specified within the param.
+func containsRune(fl FieldLevel) bool {
+
+ r, _ := utf8.DecodeRuneInString(fl.Param())
+
+ return strings.ContainsRune(fl.Field().String(), r)
+}
+
+// ContainsAny is the validation function for validating that the field's value contains any of the characters specified within the param.
+func containsAny(fl FieldLevel) bool {
+ return strings.ContainsAny(fl.Field().String(), fl.Param())
+}
+
+// Contains is the validation function for validating that the field's value contains the text specified within the param.
+func contains(fl FieldLevel) bool {
+ return strings.Contains(fl.Field().String(), fl.Param())
+}
+
+// StartsWith is the validation function for validating that the field's value starts with the text specified within the param.
+func startsWith(fl FieldLevel) bool {
+ return strings.HasPrefix(fl.Field().String(), fl.Param())
+}
+
+// EndsWith is the validation function for validating that the field's value ends with the text specified within the param.
+func endsWith(fl FieldLevel) bool {
+ return strings.HasSuffix(fl.Field().String(), fl.Param())
+}
+
+// StartsNotWith is the validation function for validating that the field's value does not start with the text specified within the param.
+func startsNotWith(fl FieldLevel) bool {
+ return !startsWith(fl)
+}
+
+// EndsNotWith is the validation function for validating that the field's value does not end with the text specified within the param.
+func endsNotWith(fl FieldLevel) bool {
+ return !endsWith(fl)
+}
+
+// FieldContains is the validation function for validating if the current field's value contains the field specified by the param's value.
+func fieldContains(fl FieldLevel) bool {
+ field := fl.Field()
+
+ currentField, _, ok := fl.GetStructFieldOK()
+
+ if !ok {
+ return false
+ }
+
+ return strings.Contains(field.String(), currentField.String())
+}
+
+// FieldExcludes is the validation function for validating if the current field's value excludes the field specified by the param's value.
+func fieldExcludes(fl FieldLevel) bool {
+ field := fl.Field()
+
+ currentField, _, ok := fl.GetStructFieldOK()
+ if !ok {
+ return true
+ }
+
+ return !strings.Contains(field.String(), currentField.String())
+}
+
+// IsNeField is the validation function for validating if the current field's value is not equal to the field specified by the param's value.
+func isNeField(fl FieldLevel) bool {
+
+ field := fl.Field()
+ kind := field.Kind()
+
+ currentField, currentKind, ok := fl.GetStructFieldOK()
+
+ if !ok || currentKind != kind {
+ return true
+ }
+
+ switch kind {
+
+ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
+ return field.Int() != currentField.Int()
+
+ case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
+ return field.Uint() != currentField.Uint()
+
+ case reflect.Float32, reflect.Float64:
+ return field.Float() != currentField.Float()
+
+ case reflect.Slice, reflect.Map, reflect.Array:
+ return int64(field.Len()) != int64(currentField.Len())
+
+ case reflect.Struct:
+
+ fieldType := field.Type()
+
+ // Not Same underlying type i.e. struct and time
+ if fieldType != currentField.Type() {
+ return true
+ }
+
+ if fieldType == timeType {
+
+ t := currentField.Interface().(time.Time)
+ fieldTime := field.Interface().(time.Time)
+
+ return !fieldTime.Equal(t)
+ }
+
+ }
+
+ // default reflect.String:
+ return field.String() != currentField.String()
+}
+
+// IsNe is the validation function for validating that the field's value does not equal the provided param value.
+func isNe(fl FieldLevel) bool {
+ return !isEq(fl)
+}
+
+// IsLteCrossStructField is the validation function for validating if the current field's value is less than or equal to the field, within a separate struct, specified by the param's value.
+func isLteCrossStructField(fl FieldLevel) bool {
+
+ field := fl.Field()
+ kind := field.Kind()
+
+ topField, topKind, ok := fl.GetStructFieldOK()
+ if !ok || topKind != kind {
+ return false
+ }
+
+ switch kind {
+
+ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
+ return field.Int() <= topField.Int()
+
+ case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
+ return field.Uint() <= topField.Uint()
+
+ case reflect.Float32, reflect.Float64:
+ return field.Float() <= topField.Float()
+
+ case reflect.Slice, reflect.Map, reflect.Array:
+ return int64(field.Len()) <= int64(topField.Len())
+
+ case reflect.Struct:
+
+ fieldType := field.Type()
+
+ // Not Same underlying type i.e. struct and time
+ if fieldType != topField.Type() {
+ return false
+ }
+
+ if fieldType == timeType {
+
+ fieldTime := field.Interface().(time.Time)
+ topTime := topField.Interface().(time.Time)
+
+ return fieldTime.Before(topTime) || fieldTime.Equal(topTime)
+ }
+ }
+
+ // default reflect.String:
+ return field.String() <= topField.String()
+}
+
+// IsLtCrossStructField is the validation function for validating if the current field's value is less than the field, within a separate struct, specified by the param's value.
+// NOTE: This is exposed for use within your own custom functions and not intended to be called directly.
+func isLtCrossStructField(fl FieldLevel) bool {
+
+ field := fl.Field()
+ kind := field.Kind()
+
+ topField, topKind, ok := fl.GetStructFieldOK()
+ if !ok || topKind != kind {
+ return false
+ }
+
+ switch kind {
+
+ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
+ return field.Int() < topField.Int()
+
+ case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
+ return field.Uint() < topField.Uint()
+
+ case reflect.Float32, reflect.Float64:
+ return field.Float() < topField.Float()
+
+ case reflect.Slice, reflect.Map, reflect.Array:
+ return int64(field.Len()) < int64(topField.Len())
+
+ case reflect.Struct:
+
+ fieldType := field.Type()
+
+ // Not Same underlying type i.e. struct and time
+ if fieldType != topField.Type() {
+ return false
+ }
+
+ if fieldType == timeType {
+
+ fieldTime := field.Interface().(time.Time)
+ topTime := topField.Interface().(time.Time)
+
+ return fieldTime.Before(topTime)
+ }
+ }
+
+ // default reflect.String:
+ return field.String() < topField.String()
+}
+
+// IsGteCrossStructField is the validation function for validating if the current field's value is greater than or equal to the field, within a separate struct, specified by the param's value.
+func isGteCrossStructField(fl FieldLevel) bool {
+
+ field := fl.Field()
+ kind := field.Kind()
+
+ topField, topKind, ok := fl.GetStructFieldOK()
+ if !ok || topKind != kind {
+ return false
+ }
+
+ switch kind {
+
+ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
+ return field.Int() >= topField.Int()
+
+ case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
+ return field.Uint() >= topField.Uint()
+
+ case reflect.Float32, reflect.Float64:
+ return field.Float() >= topField.Float()
+
+ case reflect.Slice, reflect.Map, reflect.Array:
+ return int64(field.Len()) >= int64(topField.Len())
+
+ case reflect.Struct:
+
+ fieldType := field.Type()
+
+ // Not Same underlying type i.e. struct and time
+ if fieldType != topField.Type() {
+ return false
+ }
+
+ if fieldType == timeType {
+
+ fieldTime := field.Interface().(time.Time)
+ topTime := topField.Interface().(time.Time)
+
+ return fieldTime.After(topTime) || fieldTime.Equal(topTime)
+ }
+ }
+
+ // default reflect.String:
+ return field.String() >= topField.String()
+}
+
+// IsGtCrossStructField is the validation function for validating if the current field's value is greater than the field, within a separate struct, specified by the param's value.
+func isGtCrossStructField(fl FieldLevel) bool {
+
+ field := fl.Field()
+ kind := field.Kind()
+
+ topField, topKind, ok := fl.GetStructFieldOK()
+ if !ok || topKind != kind {
+ return false
+ }
+
+ switch kind {
+
+ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
+ return field.Int() > topField.Int()
+
+ case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
+ return field.Uint() > topField.Uint()
+
+ case reflect.Float32, reflect.Float64:
+ return field.Float() > topField.Float()
+
+ case reflect.Slice, reflect.Map, reflect.Array:
+ return int64(field.Len()) > int64(topField.Len())
+
+ case reflect.Struct:
+
+ fieldType := field.Type()
+
+ // Not Same underlying type i.e. struct and time
+ if fieldType != topField.Type() {
+ return false
+ }
+
+ if fieldType == timeType {
+
+ fieldTime := field.Interface().(time.Time)
+ topTime := topField.Interface().(time.Time)
+
+ return fieldTime.After(topTime)
+ }
+ }
+
+ // default reflect.String:
+ return field.String() > topField.String()
+}
+
+// IsNeCrossStructField is the validation function for validating that the current field's value is not equal to the field, within a separate struct, specified by the param's value.
+func isNeCrossStructField(fl FieldLevel) bool {
+
+ field := fl.Field()
+ kind := field.Kind()
+
+ topField, currentKind, ok := fl.GetStructFieldOK()
+ if !ok || currentKind != kind {
+ return true
+ }
+
+ switch kind {
+
+ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
+ return topField.Int() != field.Int()
+
+ case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
+ return topField.Uint() != field.Uint()
+
+ case reflect.Float32, reflect.Float64:
+ return topField.Float() != field.Float()
+
+ case reflect.Slice, reflect.Map, reflect.Array:
+ return int64(topField.Len()) != int64(field.Len())
+
+ case reflect.Struct:
+
+ fieldType := field.Type()
+
+ // Not Same underlying type i.e. struct and time
+ if fieldType != topField.Type() {
+ return true
+ }
+
+ if fieldType == timeType {
+
+ t := field.Interface().(time.Time)
+ fieldTime := topField.Interface().(time.Time)
+
+ return !fieldTime.Equal(t)
+ }
+ }
+
+ // default reflect.String:
+ return topField.String() != field.String()
+}
+
+// IsEqCrossStructField is the validation function for validating that the current field's value is equal to the field, within a separate struct, specified by the param's value.
+func isEqCrossStructField(fl FieldLevel) bool {
+
+ field := fl.Field()
+ kind := field.Kind()
+
+ topField, topKind, ok := fl.GetStructFieldOK()
+ if !ok || topKind != kind {
+ return false
+ }
+
+ switch kind {
+
+ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
+ return topField.Int() == field.Int()
+
+ case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
+ return topField.Uint() == field.Uint()
+
+ case reflect.Float32, reflect.Float64:
+ return topField.Float() == field.Float()
+
+ case reflect.Slice, reflect.Map, reflect.Array:
+ return int64(topField.Len()) == int64(field.Len())
+
+ case reflect.Struct:
+
+ fieldType := field.Type()
+
+ // Not Same underlying type i.e. struct and time
+ if fieldType != topField.Type() {
+ return false
+ }
+
+ if fieldType == timeType {
+
+ t := field.Interface().(time.Time)
+ fieldTime := topField.Interface().(time.Time)
+
+ return fieldTime.Equal(t)
+ }
+ }
+
+ // default reflect.String:
+ return topField.String() == field.String()
+}
+
+// IsEqField is the validation function for validating if the current field's value is equal to the field specified by the param's value.
+func isEqField(fl FieldLevel) bool {
+
+ field := fl.Field()
+ kind := field.Kind()
+
+ currentField, currentKind, ok := fl.GetStructFieldOK()
+ if !ok || currentKind != kind {
+ return false
+ }
+
+ switch kind {
+
+ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
+ return field.Int() == currentField.Int()
+
+ case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
+ return field.Uint() == currentField.Uint()
+
+ case reflect.Float32, reflect.Float64:
+ return field.Float() == currentField.Float()
+
+ case reflect.Slice, reflect.Map, reflect.Array:
+ return int64(field.Len()) == int64(currentField.Len())
+
+ case reflect.Struct:
+
+ fieldType := field.Type()
+
+ // Not Same underlying type i.e. struct and time
+ if fieldType != currentField.Type() {
+ return false
+ }
+
+ if fieldType == timeType {
+
+ t := currentField.Interface().(time.Time)
+ fieldTime := field.Interface().(time.Time)
+
+ return fieldTime.Equal(t)
+ }
+
+ }
+
+ // default reflect.String:
+ return field.String() == currentField.String()
+}
+
+// IsEq is the validation function for validating if the current field's value is equal to the param's value.
+func isEq(fl FieldLevel) bool {
+
+ field := fl.Field()
+ param := fl.Param()
+
+ switch field.Kind() {
+
+ case reflect.String:
+ return field.String() == param
+
+ case reflect.Slice, reflect.Map, reflect.Array:
+ p := asInt(param)
+
+ return int64(field.Len()) == p
+
+ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
+ p := asIntFromType(field.Type(), param)
+
+ return field.Int() == p
+
+ case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
+ p := asUint(param)
+
+ return field.Uint() == p
+
+ case reflect.Float32, reflect.Float64:
+ p := asFloat(param)
+
+ return field.Float() == p
+
+ case reflect.Bool:
+ p := asBool(param)
+
+ return field.Bool() == p
+ }
+
+ panic(fmt.Sprintf("Bad field type %T", field.Interface()))
+}
+
+// IsBase64 is the validation function for validating if the current field's value is a valid base 64.
+func isBase64(fl FieldLevel) bool {
+ return base64Regex.MatchString(fl.Field().String())
+}
+
+// IsBase64URL is the validation function for validating if the current field's value is a valid base64 URL safe string.
+func isBase64URL(fl FieldLevel) bool {
+ return base64URLRegex.MatchString(fl.Field().String())
+}
+
+// IsURI is the validation function for validating if the current field's value is a valid URI.
+func isURI(fl FieldLevel) bool {
+
+ field := fl.Field()
+
+ switch field.Kind() {
+
+ case reflect.String:
+
+ s := field.String()
+
+ // checks needed as of Go 1.6 because of change https://github.com/golang/go/commit/617c93ce740c3c3cc28cdd1a0d712be183d0b328#diff-6c2d018290e298803c0c9419d8739885L195
+ // emulate browser and strip the '#' suffix prior to validation. see issue-#237
+ if i := strings.Index(s, "#"); i > -1 {
+ s = s[:i]
+ }
+
+ if len(s) == 0 {
+ return false
+ }
+
+ _, err := url.ParseRequestURI(s)
+
+ return err == nil
+ }
+
+ panic(fmt.Sprintf("Bad field type %T", field.Interface()))
+}
+
+// IsURL is the validation function for validating if the current field's value is a valid URL.
+func isURL(fl FieldLevel) bool {
+
+ field := fl.Field()
+
+ switch field.Kind() {
+
+ case reflect.String:
+
+ var i int
+ s := field.String()
+
+ // checks needed as of Go 1.6 because of change https://github.com/golang/go/commit/617c93ce740c3c3cc28cdd1a0d712be183d0b328#diff-6c2d018290e298803c0c9419d8739885L195
+ // emulate browser and strip the '#' suffix prior to validation. see issue-#237
+ if i = strings.Index(s, "#"); i > -1 {
+ s = s[:i]
+ }
+
+ if len(s) == 0 {
+ return false
+ }
+
+ url, err := url.ParseRequestURI(s)
+
+ if err != nil || url.Scheme == "" {
+ return false
+ }
+
+ return true
+ }
+
+ panic(fmt.Sprintf("Bad field type %T", field.Interface()))
+}
+
+// isUrnRFC2141 is the validation function for validating if the current field's value is a valid URN as per RFC 2141.
+func isUrnRFC2141(fl FieldLevel) bool {
+ field := fl.Field()
+
+ switch field.Kind() {
+
+ case reflect.String:
+
+ str := field.String()
+
+ _, match := urn.Parse([]byte(str))
+
+ return match
+ }
+
+ panic(fmt.Sprintf("Bad field type %T", field.Interface()))
+}
+
+// IsFile is the validation function for validating if the current field's value is a valid file path.
+func isFile(fl FieldLevel) bool {
+ field := fl.Field()
+
+ switch field.Kind() {
+ case reflect.String:
+ fileInfo, err := os.Stat(field.String())
+ if err != nil {
+ return false
+ }
+
+ return !fileInfo.IsDir()
+ }
+
+ panic(fmt.Sprintf("Bad field type %T", field.Interface()))
+}
+
+// IsE164 is the validation function for validating if the current field's value is a valid e.164 formatted phone number.
+func isE164(fl FieldLevel) bool {
+ return e164Regex.MatchString(fl.Field().String())
+}
+
+// IsEmail is the validation function for validating if the current field's value is a valid email address.
+func isEmail(fl FieldLevel) bool {
+ return emailRegex.MatchString(fl.Field().String())
+}
+
+// IsHSLA is the validation function for validating if the current field's value is a valid HSLA color.
+func isHSLA(fl FieldLevel) bool {
+ return hslaRegex.MatchString(fl.Field().String())
+}
+
+// IsHSL is the validation function for validating if the current field's value is a valid HSL color.
+func isHSL(fl FieldLevel) bool {
+ return hslRegex.MatchString(fl.Field().String())
+}
+
+// IsRGBA is the validation function for validating if the current field's value is a valid RGBA color.
+func isRGBA(fl FieldLevel) bool {
+ return rgbaRegex.MatchString(fl.Field().String())
+}
+
+// IsRGB is the validation function for validating if the current field's value is a valid RGB color.
+func isRGB(fl FieldLevel) bool {
+ return rgbRegex.MatchString(fl.Field().String())
+}
+
+// IsHEXColor is the validation function for validating if the current field's value is a valid HEX color.
+func isHEXColor(fl FieldLevel) bool {
+ return hexcolorRegex.MatchString(fl.Field().String())
+}
+
+// IsHexadecimal is the validation function for validating if the current field's value is a valid hexadecimal.
+func isHexadecimal(fl FieldLevel) bool {
+ return hexadecimalRegex.MatchString(fl.Field().String())
+}
+
+// IsNumber is the validation function for validating if the current field's value is a valid number.
+func isNumber(fl FieldLevel) bool {
+ switch fl.Field().Kind() {
+ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr, reflect.Float32, reflect.Float64:
+ return true
+ default:
+ return numberRegex.MatchString(fl.Field().String())
+ }
+}
+
+// IsNumeric is the validation function for validating if the current field's value is a valid numeric value.
+func isNumeric(fl FieldLevel) bool {
+ switch fl.Field().Kind() {
+ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr, reflect.Float32, reflect.Float64:
+ return true
+ default:
+ return numericRegex.MatchString(fl.Field().String())
+ }
+}
+
+// IsAlphanum is the validation function for validating if the current field's value is a valid alphanumeric value.
+func isAlphanum(fl FieldLevel) bool {
+ return alphaNumericRegex.MatchString(fl.Field().String())
+}
+
+// IsAlpha is the validation function for validating if the current field's value is a valid alpha value.
+func isAlpha(fl FieldLevel) bool {
+ return alphaRegex.MatchString(fl.Field().String())
+}
+
+// IsAlphanumUnicode is the validation function for validating if the current field's value is a valid alphanumeric unicode value.
+func isAlphanumUnicode(fl FieldLevel) bool {
+ return alphaUnicodeNumericRegex.MatchString(fl.Field().String())
+}
+
+// IsAlphaUnicode is the validation function for validating if the current field's value is a valid alpha unicode value.
+func isAlphaUnicode(fl FieldLevel) bool {
+ return alphaUnicodeRegex.MatchString(fl.Field().String())
+}
+
+// isDefault is the opposite of required aka hasValue
+func isDefault(fl FieldLevel) bool {
+ return !hasValue(fl)
+}
+
+// HasValue is the validation function for validating if the current field's value is not the default static value.
+func hasValue(fl FieldLevel) bool {
+ field := fl.Field()
+ switch field.Kind() {
+ case reflect.Slice, reflect.Map, reflect.Ptr, reflect.Interface, reflect.Chan, reflect.Func:
+ return !field.IsNil()
+ default:
+ if fl.(*validate).fldIsPointer && field.Interface() != nil {
+ return true
+ }
+ return field.IsValid() && field.Interface() != reflect.Zero(field.Type()).Interface()
+ }
+}
+
+// requireCheckField is a func for check field kind
+func requireCheckFieldKind(fl FieldLevel, param string, defaultNotFoundValue bool) bool {
+ field := fl.Field()
+ kind := field.Kind()
+ var nullable, found bool
+ if len(param) > 0 {
+ field, kind, nullable, found = fl.GetStructFieldOKAdvanced2(fl.Parent(), param)
+ if !found {
+ return defaultNotFoundValue
+ }
+ }
+ switch kind {
+ case reflect.Invalid:
+ return defaultNotFoundValue
+ case reflect.Slice, reflect.Map, reflect.Ptr, reflect.Interface, reflect.Chan, reflect.Func:
+ return field.IsNil()
+ default:
+ if nullable && field.Interface() != nil {
+ return false
+ }
+ return field.IsValid() && field.Interface() == reflect.Zero(field.Type()).Interface()
+ }
+}
+
+// requireCheckFieldValue is a func for check field value
+func requireCheckFieldValue(fl FieldLevel, param string, value string, defaultNotFoundValue bool) bool {
+ field, kind, _, found := fl.GetStructFieldOKAdvanced2(fl.Parent(), param)
+ if !found {
+ return defaultNotFoundValue
+ }
+
+ switch kind {
+
+ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
+ return field.Int() == asInt(value)
+
+ case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
+ return field.Uint() == asUint(value)
+
+ case reflect.Float32, reflect.Float64:
+ return field.Float() == asFloat(value)
+
+ case reflect.Slice, reflect.Map, reflect.Array:
+ return int64(field.Len()) == asInt(value)
+ }
+
+ // default reflect.String:
+ return field.String() == value
+}
+
+// requiredIf is the validation function
+// The field under validation must be present and not empty only if all the other specified fields are equal to the value following with the specified field.
+func requiredIf(fl FieldLevel) bool {
+ params := parseOneOfParam2(fl.Param())
+ if len(params)%2 != 0 {
+ panic(fmt.Sprintf("Bad param number for required_if %s", fl.FieldName()))
+ }
+ for i := 0; i < len(params); i += 2 {
+ if !requireCheckFieldValue(fl, params[i], params[i+1], false) {
+ return true
+ }
+ }
+ return hasValue(fl)
+}
+
+// requiredUnless is the validation function
+// The field under validation must be present and not empty only unless all the other specified fields are equal to the value following with the specified field.
+func requiredUnless(fl FieldLevel) bool {
+ params := parseOneOfParam2(fl.Param())
+ if len(params)%2 != 0 {
+ panic(fmt.Sprintf("Bad param number for required_unless %s", fl.FieldName()))
+ }
+
+ for i := 0; i < len(params); i += 2 {
+ if requireCheckFieldValue(fl, params[i], params[i+1], false) {
+ return true
+ }
+ }
+ return hasValue(fl)
+}
+
+// ExcludedWith is the validation function
+// The field under validation must not be present or is empty if any of the other specified fields are present.
+func excludedWith(fl FieldLevel) bool {
+ params := parseOneOfParam2(fl.Param())
+ for _, param := range params {
+ if !requireCheckFieldKind(fl, param, true) {
+ return !hasValue(fl)
+ }
+ }
+ return true
+}
+
+// RequiredWith is the validation function
+// The field under validation must be present and not empty only if any of the other specified fields are present.
+func requiredWith(fl FieldLevel) bool {
+ params := parseOneOfParam2(fl.Param())
+ for _, param := range params {
+ if !requireCheckFieldKind(fl, param, true) {
+ return hasValue(fl)
+ }
+ }
+ return true
+}
+
+// ExcludedWithAll is the validation function
+// The field under validation must not be present or is empty if all of the other specified fields are present.
+func excludedWithAll(fl FieldLevel) bool {
+ params := parseOneOfParam2(fl.Param())
+ for _, param := range params {
+ if requireCheckFieldKind(fl, param, true) {
+ return true
+ }
+ }
+ return !hasValue(fl)
+}
+
+// RequiredWithAll is the validation function
+// The field under validation must be present and not empty only if all of the other specified fields are present.
+func requiredWithAll(fl FieldLevel) bool {
+ params := parseOneOfParam2(fl.Param())
+ for _, param := range params {
+ if requireCheckFieldKind(fl, param, true) {
+ return true
+ }
+ }
+ return hasValue(fl)
+}
+
+// ExcludedWithout is the validation function
+// The field under validation must not be present or is empty when any of the other specified fields are not present.
+func excludedWithout(fl FieldLevel) bool {
+ if requireCheckFieldKind(fl, strings.TrimSpace(fl.Param()), true) {
+ return !hasValue(fl)
+ }
+ return true
+}
+
+// RequiredWithout is the validation function
+// The field under validation must be present and not empty only when any of the other specified fields are not present.
+func requiredWithout(fl FieldLevel) bool {
+ if requireCheckFieldKind(fl, strings.TrimSpace(fl.Param()), true) {
+ return hasValue(fl)
+ }
+ return true
+}
+
+// RequiredWithoutAll is the validation function
+// The field under validation must not be present or is empty when all of the other specified fields are not present.
+func excludedWithoutAll(fl FieldLevel) bool {
+ params := parseOneOfParam2(fl.Param())
+ for _, param := range params {
+ if !requireCheckFieldKind(fl, param, true) {
+ return true
+ }
+ }
+ return !hasValue(fl)
+}
+
+// RequiredWithoutAll is the validation function
+// The field under validation must be present and not empty only when all of the other specified fields are not present.
+func requiredWithoutAll(fl FieldLevel) bool {
+ params := parseOneOfParam2(fl.Param())
+ for _, param := range params {
+ if !requireCheckFieldKind(fl, param, true) {
+ return true
+ }
+ }
+ return hasValue(fl)
+}
+
+// IsGteField is the validation function for validating if the current field's value is greater than or equal to the field specified by the param's value.
+func isGteField(fl FieldLevel) bool {
+
+ field := fl.Field()
+ kind := field.Kind()
+
+ currentField, currentKind, ok := fl.GetStructFieldOK()
+ if !ok || currentKind != kind {
+ return false
+ }
+
+ switch kind {
+
+ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
+
+ return field.Int() >= currentField.Int()
+
+ case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
+
+ return field.Uint() >= currentField.Uint()
+
+ case reflect.Float32, reflect.Float64:
+
+ return field.Float() >= currentField.Float()
+
+ case reflect.Struct:
+
+ fieldType := field.Type()
+
+ // Not Same underlying type i.e. struct and time
+ if fieldType != currentField.Type() {
+ return false
+ }
+
+ if fieldType == timeType {
+
+ t := currentField.Interface().(time.Time)
+ fieldTime := field.Interface().(time.Time)
+
+ return fieldTime.After(t) || fieldTime.Equal(t)
+ }
+ }
+
+ // default reflect.String
+ return len(field.String()) >= len(currentField.String())
+}
+
+// IsGtField is the validation function for validating if the current field's value is greater than the field specified by the param's value.
+func isGtField(fl FieldLevel) bool {
+
+ field := fl.Field()
+ kind := field.Kind()
+
+ currentField, currentKind, ok := fl.GetStructFieldOK()
+ if !ok || currentKind != kind {
+ return false
+ }
+
+ switch kind {
+
+ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
+
+ return field.Int() > currentField.Int()
+
+ case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
+
+ return field.Uint() > currentField.Uint()
+
+ case reflect.Float32, reflect.Float64:
+
+ return field.Float() > currentField.Float()
+
+ case reflect.Struct:
+
+ fieldType := field.Type()
+
+ // Not Same underlying type i.e. struct and time
+ if fieldType != currentField.Type() {
+ return false
+ }
+
+ if fieldType == timeType {
+
+ t := currentField.Interface().(time.Time)
+ fieldTime := field.Interface().(time.Time)
+
+ return fieldTime.After(t)
+ }
+ }
+
+ // default reflect.String
+ return len(field.String()) > len(currentField.String())
+}
+
+// IsGte is the validation function for validating if the current field's value is greater than or equal to the param's value.
+func isGte(fl FieldLevel) bool {
+
+ field := fl.Field()
+ param := fl.Param()
+
+ switch field.Kind() {
+
+ case reflect.String:
+ p := asInt(param)
+
+ return int64(utf8.RuneCountInString(field.String())) >= p
+
+ case reflect.Slice, reflect.Map, reflect.Array:
+ p := asInt(param)
+
+ return int64(field.Len()) >= p
+
+ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
+ p := asIntFromType(field.Type(), param)
+
+ return field.Int() >= p
+
+ case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
+ p := asUint(param)
+
+ return field.Uint() >= p
+
+ case reflect.Float32, reflect.Float64:
+ p := asFloat(param)
+
+ return field.Float() >= p
+
+ case reflect.Struct:
+
+ if field.Type() == timeType {
+
+ now := time.Now().UTC()
+ t := field.Interface().(time.Time)
+
+ return t.After(now) || t.Equal(now)
+ }
+ }
+
+ panic(fmt.Sprintf("Bad field type %T", field.Interface()))
+}
+
+// IsGt is the validation function for validating if the current field's value is greater than the param's value.
+func isGt(fl FieldLevel) bool {
+
+ field := fl.Field()
+ param := fl.Param()
+
+ switch field.Kind() {
+
+ case reflect.String:
+ p := asInt(param)
+
+ return int64(utf8.RuneCountInString(field.String())) > p
+
+ case reflect.Slice, reflect.Map, reflect.Array:
+ p := asInt(param)
+
+ return int64(field.Len()) > p
+
+ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
+ p := asIntFromType(field.Type(), param)
+
+ return field.Int() > p
+
+ case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
+ p := asUint(param)
+
+ return field.Uint() > p
+
+ case reflect.Float32, reflect.Float64:
+ p := asFloat(param)
+
+ return field.Float() > p
+ case reflect.Struct:
+
+ if field.Type() == timeType {
+
+ return field.Interface().(time.Time).After(time.Now().UTC())
+ }
+ }
+
+ panic(fmt.Sprintf("Bad field type %T", field.Interface()))
+}
+
+// HasLengthOf is the validation function for validating if the current field's value is equal to the param's value.
+func hasLengthOf(fl FieldLevel) bool {
+
+ field := fl.Field()
+ param := fl.Param()
+
+ switch field.Kind() {
+
+ case reflect.String:
+ p := asInt(param)
+
+ return int64(utf8.RuneCountInString(field.String())) == p
+
+ case reflect.Slice, reflect.Map, reflect.Array:
+ p := asInt(param)
+
+ return int64(field.Len()) == p
+
+ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
+ p := asIntFromType(field.Type(), param)
+
+ return field.Int() == p
+
+ case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
+ p := asUint(param)
+
+ return field.Uint() == p
+
+ case reflect.Float32, reflect.Float64:
+ p := asFloat(param)
+
+ return field.Float() == p
+ }
+
+ panic(fmt.Sprintf("Bad field type %T", field.Interface()))
+}
+
+// HasMinOf is the validation function for validating if the current field's value is greater than or equal to the param's value.
+func hasMinOf(fl FieldLevel) bool {
+ return isGte(fl)
+}
+
+// IsLteField is the validation function for validating if the current field's value is less than or equal to the field specified by the param's value.
+func isLteField(fl FieldLevel) bool {
+
+ field := fl.Field()
+ kind := field.Kind()
+
+ currentField, currentKind, ok := fl.GetStructFieldOK()
+ if !ok || currentKind != kind {
+ return false
+ }
+
+ switch kind {
+
+ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
+
+ return field.Int() <= currentField.Int()
+
+ case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
+
+ return field.Uint() <= currentField.Uint()
+
+ case reflect.Float32, reflect.Float64:
+
+ return field.Float() <= currentField.Float()
+
+ case reflect.Struct:
+
+ fieldType := field.Type()
+
+ // Not Same underlying type i.e. struct and time
+ if fieldType != currentField.Type() {
+ return false
+ }
+
+ if fieldType == timeType {
+
+ t := currentField.Interface().(time.Time)
+ fieldTime := field.Interface().(time.Time)
+
+ return fieldTime.Before(t) || fieldTime.Equal(t)
+ }
+ }
+
+ // default reflect.String
+ return len(field.String()) <= len(currentField.String())
+}
+
+// IsLtField is the validation function for validating if the current field's value is less than the field specified by the param's value.
+func isLtField(fl FieldLevel) bool {
+
+ field := fl.Field()
+ kind := field.Kind()
+
+ currentField, currentKind, ok := fl.GetStructFieldOK()
+ if !ok || currentKind != kind {
+ return false
+ }
+
+ switch kind {
+
+ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
+
+ return field.Int() < currentField.Int()
+
+ case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
+
+ return field.Uint() < currentField.Uint()
+
+ case reflect.Float32, reflect.Float64:
+
+ return field.Float() < currentField.Float()
+
+ case reflect.Struct:
+
+ fieldType := field.Type()
+
+ // Not Same underlying type i.e. struct and time
+ if fieldType != currentField.Type() {
+ return false
+ }
+
+ if fieldType == timeType {
+
+ t := currentField.Interface().(time.Time)
+ fieldTime := field.Interface().(time.Time)
+
+ return fieldTime.Before(t)
+ }
+ }
+
+ // default reflect.String
+ return len(field.String()) < len(currentField.String())
+}
+
+// IsLte is the validation function for validating if the current field's value is less than or equal to the param's value.
+func isLte(fl FieldLevel) bool {
+
+ field := fl.Field()
+ param := fl.Param()
+
+ switch field.Kind() {
+
+ case reflect.String:
+ p := asInt(param)
+
+ return int64(utf8.RuneCountInString(field.String())) <= p
+
+ case reflect.Slice, reflect.Map, reflect.Array:
+ p := asInt(param)
+
+ return int64(field.Len()) <= p
+
+ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
+ p := asIntFromType(field.Type(), param)
+
+ return field.Int() <= p
+
+ case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
+ p := asUint(param)
+
+ return field.Uint() <= p
+
+ case reflect.Float32, reflect.Float64:
+ p := asFloat(param)
+
+ return field.Float() <= p
+
+ case reflect.Struct:
+
+ if field.Type() == timeType {
+
+ now := time.Now().UTC()
+ t := field.Interface().(time.Time)
+
+ return t.Before(now) || t.Equal(now)
+ }
+ }
+
+ panic(fmt.Sprintf("Bad field type %T", field.Interface()))
+}
+
+// IsLt is the validation function for validating if the current field's value is less than the param's value.
+func isLt(fl FieldLevel) bool {
+
+ field := fl.Field()
+ param := fl.Param()
+
+ switch field.Kind() {
+
+ case reflect.String:
+ p := asInt(param)
+
+ return int64(utf8.RuneCountInString(field.String())) < p
+
+ case reflect.Slice, reflect.Map, reflect.Array:
+ p := asInt(param)
+
+ return int64(field.Len()) < p
+
+ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
+ p := asIntFromType(field.Type(), param)
+
+ return field.Int() < p
+
+ case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
+ p := asUint(param)
+
+ return field.Uint() < p
+
+ case reflect.Float32, reflect.Float64:
+ p := asFloat(param)
+
+ return field.Float() < p
+
+ case reflect.Struct:
+
+ if field.Type() == timeType {
+
+ return field.Interface().(time.Time).Before(time.Now().UTC())
+ }
+ }
+
+ panic(fmt.Sprintf("Bad field type %T", field.Interface()))
+}
+
+// HasMaxOf is the validation function for validating if the current field's value is less than or equal to the param's value.
+func hasMaxOf(fl FieldLevel) bool {
+ return isLte(fl)
+}
+
+// IsTCP4AddrResolvable is the validation function for validating if the field's value is a resolvable tcp4 address.
+func isTCP4AddrResolvable(fl FieldLevel) bool {
+
+ if !isIP4Addr(fl) {
+ return false
+ }
+
+ _, err := net.ResolveTCPAddr("tcp4", fl.Field().String())
+ return err == nil
+}
+
+// IsTCP6AddrResolvable is the validation function for validating if the field's value is a resolvable tcp6 address.
+func isTCP6AddrResolvable(fl FieldLevel) bool {
+
+ if !isIP6Addr(fl) {
+ return false
+ }
+
+ _, err := net.ResolveTCPAddr("tcp6", fl.Field().String())
+
+ return err == nil
+}
+
+// IsTCPAddrResolvable is the validation function for validating if the field's value is a resolvable tcp address.
+func isTCPAddrResolvable(fl FieldLevel) bool {
+
+ if !isIP4Addr(fl) && !isIP6Addr(fl) {
+ return false
+ }
+
+ _, err := net.ResolveTCPAddr("tcp", fl.Field().String())
+
+ return err == nil
+}
+
+// IsUDP4AddrResolvable is the validation function for validating if the field's value is a resolvable udp4 address.
+func isUDP4AddrResolvable(fl FieldLevel) bool {
+
+ if !isIP4Addr(fl) {
+ return false
+ }
+
+ _, err := net.ResolveUDPAddr("udp4", fl.Field().String())
+
+ return err == nil
+}
+
+// IsUDP6AddrResolvable is the validation function for validating if the field's value is a resolvable udp6 address.
+func isUDP6AddrResolvable(fl FieldLevel) bool {
+
+ if !isIP6Addr(fl) {
+ return false
+ }
+
+ _, err := net.ResolveUDPAddr("udp6", fl.Field().String())
+
+ return err == nil
+}
+
+// IsUDPAddrResolvable is the validation function for validating if the field's value is a resolvable udp address.
+func isUDPAddrResolvable(fl FieldLevel) bool {
+
+ if !isIP4Addr(fl) && !isIP6Addr(fl) {
+ return false
+ }
+
+ _, err := net.ResolveUDPAddr("udp", fl.Field().String())
+
+ return err == nil
+}
+
+// IsIP4AddrResolvable is the validation function for validating if the field's value is a resolvable ip4 address.
+func isIP4AddrResolvable(fl FieldLevel) bool {
+
+ if !isIPv4(fl) {
+ return false
+ }
+
+ _, err := net.ResolveIPAddr("ip4", fl.Field().String())
+
+ return err == nil
+}
+
+// IsIP6AddrResolvable is the validation function for validating if the field's value is a resolvable ip6 address.
+func isIP6AddrResolvable(fl FieldLevel) bool {
+
+ if !isIPv6(fl) {
+ return false
+ }
+
+ _, err := net.ResolveIPAddr("ip6", fl.Field().String())
+
+ return err == nil
+}
+
+// IsIPAddrResolvable is the validation function for validating if the field's value is a resolvable ip address.
+func isIPAddrResolvable(fl FieldLevel) bool {
+
+ if !isIP(fl) {
+ return false
+ }
+
+ _, err := net.ResolveIPAddr("ip", fl.Field().String())
+
+ return err == nil
+}
+
+// IsUnixAddrResolvable is the validation function for validating if the field's value is a resolvable unix address.
+func isUnixAddrResolvable(fl FieldLevel) bool {
+
+ _, err := net.ResolveUnixAddr("unix", fl.Field().String())
+
+ return err == nil
+}
+
+func isIP4Addr(fl FieldLevel) bool {
+
+ val := fl.Field().String()
+
+ if idx := strings.LastIndex(val, ":"); idx != -1 {
+ val = val[0:idx]
+ }
+
+ ip := net.ParseIP(val)
+
+ return ip != nil && ip.To4() != nil
+}
+
+func isIP6Addr(fl FieldLevel) bool {
+
+ val := fl.Field().String()
+
+ if idx := strings.LastIndex(val, ":"); idx != -1 {
+ if idx != 0 && val[idx-1:idx] == "]" {
+ val = val[1 : idx-1]
+ }
+ }
+
+ ip := net.ParseIP(val)
+
+ return ip != nil && ip.To4() == nil
+}
+
+func isHostnameRFC952(fl FieldLevel) bool {
+ return hostnameRegexRFC952.MatchString(fl.Field().String())
+}
+
+func isHostnameRFC1123(fl FieldLevel) bool {
+ return hostnameRegexRFC1123.MatchString(fl.Field().String())
+}
+
+func isFQDN(fl FieldLevel) bool {
+ val := fl.Field().String()
+
+ if val == "" {
+ return false
+ }
+
+ return fqdnRegexRFC1123.MatchString(val)
+}
+
+// IsDir is the validation function for validating if the current field's value is a valid directory.
+func isDir(fl FieldLevel) bool {
+ field := fl.Field()
+
+ if field.Kind() == reflect.String {
+ fileInfo, err := os.Stat(field.String())
+ if err != nil {
+ return false
+ }
+
+ return fileInfo.IsDir()
+ }
+
+ panic(fmt.Sprintf("Bad field type %T", field.Interface()))
+}
+
+// isJSON is the validation function for validating if the current field's value is a valid json string.
+func isJSON(fl FieldLevel) bool {
+ field := fl.Field()
+
+ if field.Kind() == reflect.String {
+ val := field.String()
+ return json.Valid([]byte(val))
+ }
+
+ panic(fmt.Sprintf("Bad field type %T", field.Interface()))
+}
+
+// isHostnamePort validates a : combination for fields typically used for socket address.
+func isHostnamePort(fl FieldLevel) bool {
+ val := fl.Field().String()
+ host, port, err := net.SplitHostPort(val)
+ if err != nil {
+ return false
+ }
+ // Port must be a iny <= 65535.
+ if portNum, err := strconv.ParseInt(port, 10, 32); err != nil || portNum > 65535 || portNum < 1 {
+ return false
+ }
+
+ // If host is specified, it should match a DNS name
+ if host != "" {
+ return hostnameRegexRFC1123.MatchString(host)
+ }
+ return true
+}
+
+// isLowercase is the validation function for validating if the current field's value is a lowercase string.
+func isLowercase(fl FieldLevel) bool {
+ field := fl.Field()
+
+ if field.Kind() == reflect.String {
+ if field.String() == "" {
+ return false
+ }
+ return field.String() == strings.ToLower(field.String())
+ }
+
+ panic(fmt.Sprintf("Bad field type %T", field.Interface()))
+}
+
+// isUppercase is the validation function for validating if the current field's value is an uppercase string.
+func isUppercase(fl FieldLevel) bool {
+ field := fl.Field()
+
+ if field.Kind() == reflect.String {
+ if field.String() == "" {
+ return false
+ }
+ return field.String() == strings.ToUpper(field.String())
+ }
+
+ panic(fmt.Sprintf("Bad field type %T", field.Interface()))
+}
+
+// isDatetime is the validation function for validating if the current field's value is a valid datetime string.
+func isDatetime(fl FieldLevel) bool {
+ field := fl.Field()
+ param := fl.Param()
+
+ if field.Kind() == reflect.String {
+ _, err := time.Parse(param, field.String())
+
+ return err == nil
+ }
+
+ panic(fmt.Sprintf("Bad field type %T", field.Interface()))
+}
+
+// isTimeZone is the validation function for validating if the current field's value is a valid time zone string.
+func isTimeZone(fl FieldLevel) bool {
+ field := fl.Field()
+
+ if field.Kind() == reflect.String {
+ // empty value is converted to UTC by time.LoadLocation but disallow it as it is not a valid time zone name
+ if field.String() == "" {
+ return false
+ }
+
+ // Local value is converted to the current system time zone by time.LoadLocation but disallow it as it is not a valid time zone name
+ if strings.ToLower(field.String()) == "local" {
+ return false
+ }
+
+ _, err := time.LoadLocation(field.String())
+ return err == nil
+ }
+
+ panic(fmt.Sprintf("Bad field type %T", field.Interface()))
+}
+
+// isIso3166Alpha2 is the validation function for validating if the current field's value is a valid iso3166-1 alpha-2 country code.
+func isIso3166Alpha2(fl FieldLevel) bool {
+ val := fl.Field().String()
+ return iso3166_1_alpha2[val]
+}
+
+// isIso3166Alpha2 is the validation function for validating if the current field's value is a valid iso3166-1 alpha-3 country code.
+func isIso3166Alpha3(fl FieldLevel) bool {
+ val := fl.Field().String()
+ return iso3166_1_alpha3[val]
+}
+
+// isIso3166Alpha2 is the validation function for validating if the current field's value is a valid iso3166-1 alpha-numeric country code.
+func isIso3166AlphaNumeric(fl FieldLevel) bool {
+ field := fl.Field()
+
+ var code int
+ switch field.Kind() {
+ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
+ code = int(field.Int() % 1000)
+ case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
+ code = int(field.Uint() % 1000)
+ default:
+ panic(fmt.Sprintf("Bad field type %T", field.Interface()))
+ }
+ return iso3166_1_alpha_numeric[code]
+}
diff --git a/baas-kubeengine/vendor/gopkg.in/go-playground/validator.v8/cache.go b/baas-kubeengine/vendor/github.com/go-playground/validator/v10/cache.go
similarity index 53%
rename from baas-kubeengine/vendor/gopkg.in/go-playground/validator.v8/cache.go
rename to baas-kubeengine/vendor/github.com/go-playground/validator/v10/cache.go
index 76670c1d..0d18d6ec 100644
--- a/baas-kubeengine/vendor/gopkg.in/go-playground/validator.v8/cache.go
+++ b/baas-kubeengine/vendor/github.com/go-playground/validator/v10/cache.go
@@ -13,11 +13,19 @@ type tagType uint8
const (
typeDefault tagType = iota
typeOmitEmpty
+ typeIsDefault
typeNoStructLevel
typeStructOnly
typeDive
typeOr
- typeExists
+ typeKeys
+ typeEndKeys
+)
+
+const (
+ invalidValidation = "Invalid validation tag on field '%s'"
+ undefinedValidation = "Undefined validation function '%s' on field '%s'"
+ keysTagNotDefined = "'" + endKeysTag + "' tag encountered without a corresponding '" + keysTag + "' tag"
)
type structCache struct {
@@ -31,9 +39,7 @@ func (sc *structCache) Get(key reflect.Type) (c *cStruct, found bool) {
}
func (sc *structCache) Set(key reflect.Type, value *cStruct) {
-
m := sc.m.Load().(map[reflect.Type]*cStruct)
-
nm := make(map[reflect.Type]*cStruct, len(m)+1)
for k, v := range m {
nm[k] = v
@@ -53,9 +59,7 @@ func (tc *tagCache) Get(key string) (c *cTag, found bool) {
}
func (tc *tagCache) Set(key string, value *cTag) {
-
m := tc.m.Load().(map[string]*cTag)
-
nm := make(map[string]*cTag, len(m)+1)
for k, v := range m {
nm[k] = v
@@ -65,32 +69,36 @@ func (tc *tagCache) Set(key string, value *cTag) {
}
type cStruct struct {
- Name string
- fields map[int]*cField
- fn StructLevelFunc
+ name string
+ fields []*cField
+ fn StructLevelFuncCtx
}
type cField struct {
- Idx int
- Name string
- AltName string
- cTags *cTag
+ idx int
+ name string
+ altName string
+ namesEqual bool
+ cTags *cTag
}
type cTag struct {
- tag string
- aliasTag string
- actualAliasTag string
- param string
- hasAlias bool
- typeof tagType
- hasTag bool
- fn Func
- next *cTag
+ tag string
+ aliasTag string
+ actualAliasTag string
+ param string
+ keys *cTag // only populated when using tag's 'keys' and 'endkeys' for map key validation
+ next *cTag
+ fn FuncCtx
+ typeof tagType
+ hasTag bool
+ hasAlias bool
+ hasParam bool // true if parameter used eg. eq= where the equal sign has been set
+ isBlockEnd bool // indicates the current tag represents the last validation in the block
+ runValidationWhenNil bool
}
func (v *Validate) extractStructCache(current reflect.Value, sName string) *cStruct {
-
v.structCache.lock.Lock()
defer v.structCache.lock.Unlock() // leave as defer! because if inner panics, it will never get unlocked otherwise!
@@ -103,7 +111,7 @@ func (v *Validate) extractStructCache(current reflect.Value, sName string) *cStr
return cs
}
- cs = &cStruct{Name: sName, fields: make(map[int]*cField), fn: v.structLevelFuncs[typ]}
+ cs = &cStruct{name: sName, fields: make([]*cField, 0), fn: v.structLevelFuncs[typ]}
numFields := current.NumField()
@@ -116,7 +124,7 @@ func (v *Validate) extractStructCache(current reflect.Value, sName string) *cStr
fld = typ.Field(i)
- if !fld.Anonymous && fld.PkgPath != blank {
+ if !fld.Anonymous && len(fld.PkgPath) > 0 {
continue
}
@@ -128,12 +136,9 @@ func (v *Validate) extractStructCache(current reflect.Value, sName string) *cStr
customName = fld.Name
- if v.fieldNameTag != blank {
-
- name := strings.SplitN(fld.Tag.Get(v.fieldNameTag), ",", 2)[0]
-
- // dash check is for json "-" (aka skipValidationTag) means don't output in json
- if name != "" && name != skipValidationTag {
+ if v.hasTagNameFunc {
+ name := v.tagNameFunc(fld)
+ if len(name) > 0 {
customName = name
}
}
@@ -142,66 +147,102 @@ func (v *Validate) extractStructCache(current reflect.Value, sName string) *cStr
// and so only struct level caching can be used instead of combined with Field tag caching
if len(tag) > 0 {
- ctag, _ = v.parseFieldTagsRecursive(tag, fld.Name, blank, false)
+ ctag, _ = v.parseFieldTagsRecursive(tag, fld.Name, "", false)
} else {
// even if field doesn't have validations need cTag for traversing to potential inner/nested
// elements of the field.
ctag = new(cTag)
}
- cs.fields[i] = &cField{Idx: i, Name: fld.Name, AltName: customName, cTags: ctag}
+ cs.fields = append(cs.fields, &cField{
+ idx: i,
+ name: fld.Name,
+ altName: customName,
+ cTags: ctag,
+ namesEqual: fld.Name == customName,
+ })
}
-
v.structCache.Set(typ, cs)
-
return cs
}
func (v *Validate) parseFieldTagsRecursive(tag string, fieldName string, alias string, hasAlias bool) (firstCtag *cTag, current *cTag) {
-
var t string
- var ok bool
noAlias := len(alias) == 0
tags := strings.Split(tag, tagSeparator)
for i := 0; i < len(tags); i++ {
-
t = tags[i]
-
if noAlias {
alias = t
}
- if v.hasAliasValidators {
- // check map for alias and process new tags, otherwise process as usual
- if tagsVal, found := v.aliasValidators[t]; found {
-
- if i == 0 {
- firstCtag, current = v.parseFieldTagsRecursive(tagsVal, fieldName, t, true)
- } else {
- next, curr := v.parseFieldTagsRecursive(tagsVal, fieldName, t, true)
- current.next, current = next, curr
-
- }
+ // check map for alias and process new tags, otherwise process as usual
+ if tagsVal, found := v.aliases[t]; found {
+ if i == 0 {
+ firstCtag, current = v.parseFieldTagsRecursive(tagsVal, fieldName, t, true)
+ } else {
+ next, curr := v.parseFieldTagsRecursive(tagsVal, fieldName, t, true)
+ current.next, current = next, curr
- continue
}
+ continue
}
+ var prevTag tagType
+
if i == 0 {
- current = &cTag{aliasTag: alias, hasAlias: hasAlias, hasTag: true}
+ current = &cTag{aliasTag: alias, hasAlias: hasAlias, hasTag: true, typeof: typeDefault}
firstCtag = current
} else {
+ prevTag = current.typeof
current.next = &cTag{aliasTag: alias, hasAlias: hasAlias, hasTag: true}
current = current.next
}
switch t {
-
case diveTag:
current.typeof = typeDive
continue
+ case keysTag:
+ current.typeof = typeKeys
+
+ if i == 0 || prevTag != typeDive {
+ panic(fmt.Sprintf("'%s' tag must be immediately preceded by the '%s' tag", keysTag, diveTag))
+ }
+
+ current.typeof = typeKeys
+
+ // need to pass along only keys tag
+ // need to increment i to skip over the keys tags
+ b := make([]byte, 0, 64)
+
+ i++
+
+ for ; i < len(tags); i++ {
+
+ b = append(b, tags[i]...)
+ b = append(b, ',')
+
+ if tags[i] == endKeysTag {
+ break
+ }
+ }
+
+ current.keys, _ = v.parseFieldTagsRecursive(string(b[:len(b)-1]), fieldName, "", false)
+ continue
+
+ case endKeysTag:
+ current.typeof = typeEndKeys
+
+ // if there are more in tags then there was no keysTag defined
+ // and an error should be thrown
+ if i != len(tags)-1 {
+ panic(keysTagNotDefined)
+ }
+ return
+
case omitempty:
current.typeof = typeOmitEmpty
continue
@@ -214,19 +255,15 @@ func (v *Validate) parseFieldTagsRecursive(tag string, fieldName string, alias s
current.typeof = typeNoStructLevel
continue
- case existsTag:
- current.typeof = typeExists
- continue
-
default:
-
+ if t == isdefault {
+ current.typeof = typeIsDefault
+ }
// if a pipe character is needed within the param you must use the utf8Pipe representation "0x7C"
orVals := strings.Split(t, orSeparator)
for j := 0; j < len(orVals); j++ {
-
vals := strings.SplitN(orVals[j], tagKeySeparator, 2)
-
if noAlias {
alias = vals[0]
current.aliasTag = alias
@@ -238,14 +275,18 @@ func (v *Validate) parseFieldTagsRecursive(tag string, fieldName string, alias s
current.next = &cTag{aliasTag: alias, actualAliasTag: current.actualAliasTag, hasAlias: hasAlias, hasTag: true}
current = current.next
}
+ current.hasParam = len(vals) > 1
current.tag = vals[0]
if len(current.tag) == 0 {
panic(strings.TrimSpace(fmt.Sprintf(invalidValidation, fieldName)))
}
- if current.fn, ok = v.validationFuncs[current.tag]; !ok {
- panic(strings.TrimSpace(fmt.Sprintf(undefinedValidation, fieldName)))
+ if wrapper, ok := v.validations[current.tag]; ok {
+ current.fn = wrapper.fn
+ current.runValidationWhenNil = wrapper.runValidatinOnNil
+ } else {
+ panic(strings.TrimSpace(fmt.Sprintf(undefinedValidation, current.tag, fieldName)))
}
if len(orVals) > 1 {
@@ -256,8 +297,26 @@ func (v *Validate) parseFieldTagsRecursive(tag string, fieldName string, alias s
current.param = strings.Replace(strings.Replace(vals[1], utf8HexComma, ",", -1), utf8Pipe, "|", -1)
}
}
+ current.isBlockEnd = true
}
}
-
return
}
+
+func (v *Validate) fetchCacheTag(tag string) *cTag {
+ // find cached tag
+ ctag, found := v.tagCache.Get(tag)
+ if !found {
+ v.tagCache.lock.Lock()
+ defer v.tagCache.lock.Unlock()
+
+ // could have been multiple trying to access, but once first is done this ensures tag
+ // isn't parsed again.
+ ctag, found = v.tagCache.Get(tag)
+ if !found {
+ ctag, _ = v.parseFieldTagsRecursive(tag, "", "", false)
+ v.tagCache.Set(tag, ctag)
+ }
+ }
+ return ctag
+}
diff --git a/baas-kubeengine/vendor/github.com/go-playground/validator/v10/country_codes.go b/baas-kubeengine/vendor/github.com/go-playground/validator/v10/country_codes.go
new file mode 100644
index 00000000..ef81eada
--- /dev/null
+++ b/baas-kubeengine/vendor/github.com/go-playground/validator/v10/country_codes.go
@@ -0,0 +1,162 @@
+package validator
+
+var iso3166_1_alpha2 = map[string]bool{
+ // see: https://www.iso.org/iso-3166-country-codes.html
+ "AF": true, "AX": true, "AL": true, "DZ": true, "AS": true,
+ "AD": true, "AO": true, "AI": true, "AQ": true, "AG": true,
+ "AR": true, "AM": true, "AW": true, "AU": true, "AT": true,
+ "AZ": true, "BS": true, "BH": true, "BD": true, "BB": true,
+ "BY": true, "BE": true, "BZ": true, "BJ": true, "BM": true,
+ "BT": true, "BO": true, "BQ": true, "BA": true, "BW": true,
+ "BV": true, "BR": true, "IO": true, "BN": true, "BG": true,
+ "BF": true, "BI": true, "KH": true, "CM": true, "CA": true,
+ "CV": true, "KY": true, "CF": true, "TD": true, "CL": true,
+ "CN": true, "CX": true, "CC": true, "CO": true, "KM": true,
+ "CG": true, "CD": true, "CK": true, "CR": true, "CI": true,
+ "HR": true, "CU": true, "CW": true, "CY": true, "CZ": true,
+ "DK": true, "DJ": true, "DM": true, "DO": true, "EC": true,
+ "EG": true, "SV": true, "GQ": true, "ER": true, "EE": true,
+ "ET": true, "FK": true, "FO": true, "FJ": true, "FI": true,
+ "FR": true, "GF": true, "PF": true, "TF": true, "GA": true,
+ "GM": true, "GE": true, "DE": true, "GH": true, "GI": true,
+ "GR": true, "GL": true, "GD": true, "GP": true, "GU": true,
+ "GT": true, "GG": true, "GN": true, "GW": true, "GY": true,
+ "HT": true, "HM": true, "VA": true, "HN": true, "HK": true,
+ "HU": true, "IS": true, "IN": true, "ID": true, "IR": true,
+ "IQ": true, "IE": true, "IM": true, "IL": true, "IT": true,
+ "JM": true, "JP": true, "JE": true, "JO": true, "KZ": true,
+ "KE": true, "KI": true, "KP": true, "KR": true, "KW": true,
+ "KG": true, "LA": true, "LV": true, "LB": true, "LS": true,
+ "LR": true, "LY": true, "LI": true, "LT": true, "LU": true,
+ "MO": true, "MK": true, "MG": true, "MW": true, "MY": true,
+ "MV": true, "ML": true, "MT": true, "MH": true, "MQ": true,
+ "MR": true, "MU": true, "YT": true, "MX": true, "FM": true,
+ "MD": true, "MC": true, "MN": true, "ME": true, "MS": true,
+ "MA": true, "MZ": true, "MM": true, "NA": true, "NR": true,
+ "NP": true, "NL": true, "NC": true, "NZ": true, "NI": true,
+ "NE": true, "NG": true, "NU": true, "NF": true, "MP": true,
+ "NO": true, "OM": true, "PK": true, "PW": true, "PS": true,
+ "PA": true, "PG": true, "PY": true, "PE": true, "PH": true,
+ "PN": true, "PL": true, "PT": true, "PR": true, "QA": true,
+ "RE": true, "RO": true, "RU": true, "RW": true, "BL": true,
+ "SH": true, "KN": true, "LC": true, "MF": true, "PM": true,
+ "VC": true, "WS": true, "SM": true, "ST": true, "SA": true,
+ "SN": true, "RS": true, "SC": true, "SL": true, "SG": true,
+ "SX": true, "SK": true, "SI": true, "SB": true, "SO": true,
+ "ZA": true, "GS": true, "SS": true, "ES": true, "LK": true,
+ "SD": true, "SR": true, "SJ": true, "SZ": true, "SE": true,
+ "CH": true, "SY": true, "TW": true, "TJ": true, "TZ": true,
+ "TH": true, "TL": true, "TG": true, "TK": true, "TO": true,
+ "TT": true, "TN": true, "TR": true, "TM": true, "TC": true,
+ "TV": true, "UG": true, "UA": true, "AE": true, "GB": true,
+ "US": true, "UM": true, "UY": true, "UZ": true, "VU": true,
+ "VE": true, "VN": true, "VG": true, "VI": true, "WF": true,
+ "EH": true, "YE": true, "ZM": true, "ZW": true,
+}
+
+var iso3166_1_alpha3 = map[string]bool{
+ // see: https://www.iso.org/iso-3166-country-codes.html
+ "AFG": true, "ALB": true, "DZA": true, "ASM": true, "AND": true,
+ "AGO": true, "AIA": true, "ATA": true, "ATG": true, "ARG": true,
+ "ARM": true, "ABW": true, "AUS": true, "AUT": true, "AZE": true,
+ "BHS": true, "BHR": true, "BGD": true, "BRB": true, "BLR": true,
+ "BEL": true, "BLZ": true, "BEN": true, "BMU": true, "BTN": true,
+ "BOL": true, "BES": true, "BIH": true, "BWA": true, "BVT": true,
+ "BRA": true, "IOT": true, "BRN": true, "BGR": true, "BFA": true,
+ "BDI": true, "CPV": true, "KHM": true, "CMR": true, "CAN": true,
+ "CYM": true, "CAF": true, "TCD": true, "CHL": true, "CHN": true,
+ "CXR": true, "CCK": true, "COL": true, "COM": true, "COD": true,
+ "COG": true, "COK": true, "CRI": true, "HRV": true, "CUB": true,
+ "CUW": true, "CYP": true, "CZE": true, "CIV": true, "DNK": true,
+ "DJI": true, "DMA": true, "DOM": true, "ECU": true, "EGY": true,
+ "SLV": true, "GNQ": true, "ERI": true, "EST": true, "SWZ": true,
+ "ETH": true, "FLK": true, "FRO": true, "FJI": true, "FIN": true,
+ "FRA": true, "GUF": true, "PYF": true, "ATF": true, "GAB": true,
+ "GMB": true, "GEO": true, "DEU": true, "GHA": true, "GIB": true,
+ "GRC": true, "GRL": true, "GRD": true, "GLP": true, "GUM": true,
+ "GTM": true, "GGY": true, "GIN": true, "GNB": true, "GUY": true,
+ "HTI": true, "HMD": true, "VAT": true, "HND": true, "HKG": true,
+ "HUN": true, "ISL": true, "IND": true, "IDN": true, "IRN": true,
+ "IRQ": true, "IRL": true, "IMN": true, "ISR": true, "ITA": true,
+ "JAM": true, "JPN": true, "JEY": true, "JOR": true, "KAZ": true,
+ "KEN": true, "KIR": true, "PRK": true, "KOR": true, "KWT": true,
+ "KGZ": true, "LAO": true, "LVA": true, "LBN": true, "LSO": true,
+ "LBR": true, "LBY": true, "LIE": true, "LTU": true, "LUX": true,
+ "MAC": true, "MDG": true, "MWI": true, "MYS": true, "MDV": true,
+ "MLI": true, "MLT": true, "MHL": true, "MTQ": true, "MRT": true,
+ "MUS": true, "MYT": true, "MEX": true, "FSM": true, "MDA": true,
+ "MCO": true, "MNG": true, "MNE": true, "MSR": true, "MAR": true,
+ "MOZ": true, "MMR": true, "NAM": true, "NRU": true, "NPL": true,
+ "NLD": true, "NCL": true, "NZL": true, "NIC": true, "NER": true,
+ "NGA": true, "NIU": true, "NFK": true, "MKD": true, "MNP": true,
+ "NOR": true, "OMN": true, "PAK": true, "PLW": true, "PSE": true,
+ "PAN": true, "PNG": true, "PRY": true, "PER": true, "PHL": true,
+ "PCN": true, "POL": true, "PRT": true, "PRI": true, "QAT": true,
+ "ROU": true, "RUS": true, "RWA": true, "REU": true, "BLM": true,
+ "SHN": true, "KNA": true, "LCA": true, "MAF": true, "SPM": true,
+ "VCT": true, "WSM": true, "SMR": true, "STP": true, "SAU": true,
+ "SEN": true, "SRB": true, "SYC": true, "SLE": true, "SGP": true,
+ "SXM": true, "SVK": true, "SVN": true, "SLB": true, "SOM": true,
+ "ZAF": true, "SGS": true, "SSD": true, "ESP": true, "LKA": true,
+ "SDN": true, "SUR": true, "SJM": true, "SWE": true, "CHE": true,
+ "SYR": true, "TWN": true, "TJK": true, "TZA": true, "THA": true,
+ "TLS": true, "TGO": true, "TKL": true, "TON": true, "TTO": true,
+ "TUN": true, "TUR": true, "TKM": true, "TCA": true, "TUV": true,
+ "UGA": true, "UKR": true, "ARE": true, "GBR": true, "UMI": true,
+ "USA": true, "URY": true, "UZB": true, "VUT": true, "VEN": true,
+ "VNM": true, "VGB": true, "VIR": true, "WLF": true, "ESH": true,
+ "YEM": true, "ZMB": true, "ZWE": true, "ALA": true,
+}
+var iso3166_1_alpha_numeric = map[int]bool{
+ // see: https://www.iso.org/iso-3166-country-codes.html
+ 4: true, 8: true, 12: true, 16: true, 20: true,
+ 24: true, 660: true, 10: true, 28: true, 32: true,
+ 51: true, 533: true, 36: true, 40: true, 31: true,
+ 44: true, 48: true, 50: true, 52: true, 112: true,
+ 56: true, 84: true, 204: true, 60: true, 64: true,
+ 68: true, 535: true, 70: true, 72: true, 74: true,
+ 76: true, 86: true, 96: true, 100: true, 854: true,
+ 108: true, 132: true, 116: true, 120: true, 124: true,
+ 136: true, 140: true, 148: true, 152: true, 156: true,
+ 162: true, 166: true, 170: true, 174: true, 180: true,
+ 178: true, 184: true, 188: true, 191: true, 192: true,
+ 531: true, 196: true, 203: true, 384: true, 208: true,
+ 262: true, 212: true, 214: true, 218: true, 818: true,
+ 222: true, 226: true, 232: true, 233: true, 748: true,
+ 231: true, 238: true, 234: true, 242: true, 246: true,
+ 250: true, 254: true, 258: true, 260: true, 266: true,
+ 270: true, 268: true, 276: true, 288: true, 292: true,
+ 300: true, 304: true, 308: true, 312: true, 316: true,
+ 320: true, 831: true, 324: true, 624: true, 328: true,
+ 332: true, 334: true, 336: true, 340: true, 344: true,
+ 348: true, 352: true, 356: true, 360: true, 364: true,
+ 368: true, 372: true, 833: true, 376: true, 380: true,
+ 388: true, 392: true, 832: true, 400: true, 398: true,
+ 404: true, 296: true, 408: true, 410: true, 414: true,
+ 417: true, 418: true, 428: true, 422: true, 426: true,
+ 430: true, 434: true, 438: true, 440: true, 442: true,
+ 446: true, 450: true, 454: true, 458: true, 462: true,
+ 466: true, 470: true, 584: true, 474: true, 478: true,
+ 480: true, 175: true, 484: true, 583: true, 498: true,
+ 492: true, 496: true, 499: true, 500: true, 504: true,
+ 508: true, 104: true, 516: true, 520: true, 524: true,
+ 528: true, 540: true, 554: true, 558: true, 562: true,
+ 566: true, 570: true, 574: true, 807: true, 580: true,
+ 578: true, 512: true, 586: true, 585: true, 275: true,
+ 591: true, 598: true, 600: true, 604: true, 608: true,
+ 612: true, 616: true, 620: true, 630: true, 634: true,
+ 642: true, 643: true, 646: true, 638: true, 652: true,
+ 654: true, 659: true, 662: true, 663: true, 666: true,
+ 670: true, 882: true, 674: true, 678: true, 682: true,
+ 686: true, 688: true, 690: true, 694: true, 702: true,
+ 534: true, 703: true, 705: true, 90: true, 706: true,
+ 710: true, 239: true, 728: true, 724: true, 144: true,
+ 729: true, 740: true, 744: true, 752: true, 756: true,
+ 760: true, 158: true, 762: true, 834: true, 764: true,
+ 626: true, 768: true, 772: true, 776: true, 780: true,
+ 788: true, 792: true, 795: true, 796: true, 798: true,
+ 800: true, 804: true, 784: true, 826: true, 581: true,
+ 840: true, 858: true, 860: true, 548: true, 862: true,
+ 704: true, 92: true, 850: true, 876: true, 732: true,
+ 887: true, 894: true, 716: true, 248: true,
+}
diff --git a/baas-kubeengine/vendor/gopkg.in/go-playground/validator.v8/doc.go b/baas-kubeengine/vendor/github.com/go-playground/validator/v10/doc.go
similarity index 50%
rename from baas-kubeengine/vendor/gopkg.in/go-playground/validator.v8/doc.go
rename to baas-kubeengine/vendor/github.com/go-playground/validator/v10/doc.go
index fdede2c4..a816c20a 100644
--- a/baas-kubeengine/vendor/gopkg.in/go-playground/validator.v8/doc.go
+++ b/baas-kubeengine/vendor/github.com/go-playground/validator/v10/doc.go
@@ -5,21 +5,7 @@ based on tags.
It can also handle Cross-Field and Cross-Struct validation for nested structs
and has the ability to dive into arrays and maps of any type.
-Why not a better error message?
-Because this library intends for you to handle your own error messages.
-
-Why should I handle my own errors?
-Many reasons. We built an internationalized application and needed to know the
-field, and what validation failed so we could provide a localized error.
-
- if fieldErr.Field == "Name" {
- switch fieldErr.ErrorTag
- case "required":
- return "Translated string based on field + error"
- default:
- return "Translated string based on field"
- }
-
+see more examples https://github.com/go-playground/validator/tree/master/_examples
Validation Functions Return Type error
@@ -34,18 +20,20 @@ where err is always != nil:
http://stackoverflow.com/a/29138676/3158232
https://github.com/go-playground/validator/issues/134
-Validator only returns nil or ValidationErrors as type error; so, in your code
-all you need to do is check if the error returned is not nil, and if it's not
-type cast it to type ValidationErrors like so err.(validator.ValidationErrors).
+Validator only InvalidValidationError for bad validation input, nil or
+ValidationErrors as type error; so, in your code all you need to do is check
+if the error returned is not nil, and if it's not check if error is
+InvalidValidationError ( if necessary, most of the time it isn't ) type cast
+it to type ValidationErrors like so err.(validator.ValidationErrors).
-Custom Functions
+Custom Validation Functions
-Custom functions can be added. Example:
+Custom Validation functions can be added. Example:
// Structure
- func customFunc(v *Validate, topStruct reflect.Value, currentStructOrField reflect.Value, field reflect.Value, fieldType reflect.Type, fieldKind reflect.Kind, param string) bool {
+ func customFunc(fl validator.FieldLevel) bool {
- if whatever {
+ if fl.Field().String() == "invalid" {
return false
}
@@ -68,7 +56,7 @@ Cross-Field Validation can be done via the following tags:
- eqcsfield
- necsfield
- gtcsfield
- - ftecsfield
+ - gtecsfield
- ltcsfield
- ltecsfield
@@ -106,7 +94,7 @@ used "eqcsfield" it could be multiple levels down. Example:
// NOTE: when calling validate.Struct(val) topStruct will be the top level struct passed
// into the function
- // when calling validate.FieldWithValue(val, field, tag) val will be
+ // when calling validate.VarWithValue(val, field, tag) val will be
// whatever you pass, struct, field...
// when calling validate.Field(field, tag) val will be nil
@@ -144,7 +132,7 @@ so the above will become excludesall=0x2C.
Field `validate:"excludesall=0x2C"` // GOOD! Use the UTF-8 hex representation.
}
-Pipe ("|") is the default separator of validation tags. If you wish to
+Pipe ("|") is the 'or' validation tags deparator. If you wish to
have a pipe included within the parameter i.e. excludesall=| you will need to
use the UTF-8 hex representation 0x7C, which is replaced in the code as a pipe,
so the above will become excludesall=0x7C
@@ -170,7 +158,7 @@ handy in ignoring embedded structs from being validated. (Usage: -)
Or Operator
This is the 'or' operator allowing multiple validators to be used and
-accepted. (Usage: rbg|rgba) <-- this would allow either rgb or rgba
+accepted. (Usage: rgb|rgba) <-- this would allow either rgb or rgba
colors to be accepted. This can also be combined with 'and' for example
( Usage: omitempty,rgb|rgba)
@@ -180,7 +168,7 @@ StructOnly
When a field that is a nested struct is encountered, and contains this flag
any validation on the nested struct will be run, but none of the nested
-struct fields will be validated. This is usefull if inside of you program
+struct fields will be validated. This is useful if inside of your program
you know the struct will be valid, but need to verify it has been assigned.
NOTE: only "required" and "omitempty" can be used on a struct itself.
@@ -192,17 +180,6 @@ Same as structonly tag except that any struct level validations will not run.
Usage: nostructlevel
-Exists
-
-Is a special tag without a validation function attached. It is used when a field
-is a Pointer, Interface or Invalid and you wish to validate that it exists.
-Example: want to ensure a bool exists if you define the bool as a pointer and
-use exists it will ensure there is a value; couldn't use required as it would
-fail when the bool was false. exists will fail is the value is a Pointer, Interface
-or Invalid and is nil.
-
- Usage: exists
-
Omit Empty
Allows conditional validation, for example if a field is not set with
@@ -216,7 +193,8 @@ Dive
This tells the validator to dive into a slice, array or map and validate that
level of the slice, array or map with the validation tags that follow.
Multidimensional nesting is also supported, each level you wish to dive will
-require another dive tag.
+require another dive tag. dive has some sub-tags, 'keys' & 'endkeys', please see
+the Keys & EndKeys section just below.
Usage: dive
@@ -234,6 +212,30 @@ Example #2
// []string will be spared validation
// required will be applied to string
+Keys & EndKeys
+
+These are to be used together directly after the dive tag and tells the validator
+that anything between 'keys' and 'endkeys' applies to the keys of a map and not the
+values; think of it like the 'dive' tag, but for map keys instead of values.
+Multidimensional nesting is also supported, each level you wish to validate will
+require another 'keys' and 'endkeys' tag. These tags are only valid for maps.
+
+ Usage: dive,keys,othertagvalidation(s),endkeys,valuevalidationtags
+
+Example #1
+
+ map[string]string with validation tag "gt=0,dive,keys,eg=1|eq=2,endkeys,required"
+ // gt=0 will be applied to the map itself
+ // eg=1|eq=2 will be applied to the map keys
+ // required will be applied to map values
+
+Example #2
+
+ map[[2]string]string with validation tag "gt=0,dive,keys,dive,eq=1|eq=2,endkeys,required"
+ // gt=0 will be applied to the map itself
+ // eg=1|eq=2 will be applied to each array element in the the map keys
+ // required will be applied to map values
+
Required
This validates that the value is not the data types default zero value.
@@ -243,15 +245,127 @@ ensures the value is not nil.
Usage: required
+Required If
+
+The field under validation must be present and not empty only if all
+the other specified fields are equal to the value following the specified
+field. For strings ensures value is not "". For slices, maps, pointers,
+interfaces, channels and functions ensures the value is not nil.
+
+ Usage: required_if
+
+Examples:
+
+ // require the field if the Field1 is equal to the parameter given:
+ Usage: required_if=Field1 foobar
+
+ // require the field if the Field1 and Field2 is equal to the value respectively:
+ Usage: required_if=Field1 foo Field2 bar
+
+Required Unless
+
+The field under validation must be present and not empty unless all
+the other specified fields are equal to the value following the specified
+field. For strings ensures value is not "". For slices, maps, pointers,
+interfaces, channels and functions ensures the value is not nil.
+
+ Usage: required_unless
+
+Examples:
+
+ // require the field unless the Field1 is equal to the parameter given:
+ Usage: required_unless=Field1 foobar
+
+ // require the field unless the Field1 and Field2 is equal to the value respectively:
+ Usage: required_unless=Field1 foo Field2 bar
+
+Required With
+
+The field under validation must be present and not empty only if any
+of the other specified fields are present. For strings ensures value is
+not "". For slices, maps, pointers, interfaces, channels and functions
+ensures the value is not nil.
+
+ Usage: required_with
+
+Examples:
+
+ // require the field if the Field1 is present:
+ Usage: required_with=Field1
+
+ // require the field if the Field1 or Field2 is present:
+ Usage: required_with=Field1 Field2
+
+Required With All
+
+The field under validation must be present and not empty only if all
+of the other specified fields are present. For strings ensures value is
+not "". For slices, maps, pointers, interfaces, channels and functions
+ensures the value is not nil.
+
+ Usage: required_with_all
+
+Example:
+
+ // require the field if the Field1 and Field2 is present:
+ Usage: required_with_all=Field1 Field2
+
+Required Without
+
+The field under validation must be present and not empty only when any
+of the other specified fields are not present. For strings ensures value is
+not "". For slices, maps, pointers, interfaces, channels and functions
+ensures the value is not nil.
+
+ Usage: required_without
+
+Examples:
+
+ // require the field if the Field1 is not present:
+ Usage: required_without=Field1
+
+ // require the field if the Field1 or Field2 is not present:
+ Usage: required_without=Field1 Field2
+
+Required Without All
+
+The field under validation must be present and not empty only when all
+of the other specified fields are not present. For strings ensures value is
+not "". For slices, maps, pointers, interfaces, channels and functions
+ensures the value is not nil.
+
+ Usage: required_without_all
+
+Example:
+
+ // require the field if the Field1 and Field2 is not present:
+ Usage: required_without_all=Field1 Field2
+
+Is Default
+
+This validates that the value is the default value and is almost the
+opposite of required.
+
+ Usage: isdefault
+
Length
-For numbers, max will ensure that the value is
+For numbers, length will ensure that the value is
equal to the parameter given. For strings, it checks that
the string length is exactly that number of characters. For slices,
arrays, and maps, validates the number of items.
+Example #1
+
Usage: len=10
+Example #2 (time.Duration)
+
+For time.Duration, len will ensure that the value is equal to the duration given
+in the parameter.
+
+ Usage: len=1h30m
+
Maximum
For numbers, max will ensure that the value is
@@ -259,33 +373,81 @@ less than or equal to the parameter given. For strings, it checks
that the string length is at most that number of characters. For
slices, arrays, and maps, validates the number of items.
+Example #1
+
Usage: max=10
-Mininum
+Example #2 (time.Duration)
+
+For time.Duration, max will ensure that the value is less than or equal to the
+duration given in the parameter.
+
+ Usage: max=1h30m
+
+Minimum
For numbers, min will ensure that the value is
greater or equal to the parameter given. For strings, it checks that
the string length is at least that number of characters. For slices,
arrays, and maps, validates the number of items.
+Example #1
+
Usage: min=10
+Example #2 (time.Duration)
+
+For time.Duration, min will ensure that the value is greater than or equal to
+the duration given in the parameter.
+
+ Usage: min=1h30m
+
Equals
For strings & numbers, eq will ensure that the value is
equal to the parameter given. For slices, arrays, and maps,
validates the number of items.
+Example #1
+
Usage: eq=10
+Example #2 (time.Duration)
+
+For time.Duration, eq will ensure that the value is equal to the duration given
+in the parameter.
+
+ Usage: eq=1h30m
+
Not Equal
For strings & numbers, ne will ensure that the value is not
equal to the parameter given. For slices, arrays, and maps,
validates the number of items.
+Example #1
+
Usage: ne=10
+Example #2 (time.Duration)
+
+For time.Duration, ne will ensure that the value is not equal to the duration
+given in the parameter.
+
+ Usage: ne=1h30m
+
+One Of
+
+For strings, ints, and uints, oneof will ensure that the value
+is one of the values in the parameter. The parameter should be
+a list of values separated by whitespace. Values may be
+strings or numbers. To match strings with spaces in them, include
+the target string between single quotes.
+
+ Usage: oneof=red green
+ oneof='red green' 'blue yellow'
+ oneof=5 7 9
+
Greater Than
For numbers, this will ensure that the value is greater than the
@@ -303,11 +465,17 @@ For time.Time ensures the time value is greater than time.Now.UTC().
Usage: gt
+Example #3 (time.Duration)
+
+For time.Duration, gt will ensure that the value is greater than the duration
+given in the parameter.
+
+ Usage: gt=1h30m
+
Greater Than or Equal
Same as 'min' above. Kept both to make terminology with 'len' easier.
-
Example #1
Usage: gte=10
@@ -318,6 +486,13 @@ For time.Time ensures the time value is greater than or equal to time.Now.UTC().
Usage: gte
+Example #3 (time.Duration)
+
+For time.Duration, gte will ensure that the value is greater than or equal to
+the duration given in the parameter.
+
+ Usage: gte=1h30m
+
Less Than
For numbers, this will ensure that the value is less than the parameter given.
@@ -329,10 +504,18 @@ Example #1
Usage: lt=10
Example #2 (time.Time)
+
For time.Time ensures the time value is less than time.Now.UTC().
Usage: lt
+Example #3 (time.Duration)
+
+For time.Duration, lt will ensure that the value is less than the duration given
+in the parameter.
+
+ Usage: lt=1h30m
+
Less Than or Equal
Same as 'max' above. Kept both to make terminology with 'len' easier.
@@ -347,6 +530,13 @@ For time.Time ensures the time value is less than or equal to time.Now.UTC().
Usage: lte
+Example #3 (time.Duration)
+
+For time.Duration, lte will ensure that the value is less than or equal to the
+duration given in the parameter.
+
+ Usage: lte=1h30m
+
Field Equals Another Field
This will validate the field value against another fields value either within
@@ -360,7 +550,7 @@ Example #1:
Example #2:
// Validating by field:
- validate.FieldWithValue(password, confirmpassword, "eqfield")
+ validate.VarWithValue(password, confirmpassword, "eqfield")
Field Equals Another Field (relative)
@@ -382,7 +572,7 @@ Examples:
Usage: nefield=Color2
// Validating by field:
- validate.FieldWithValue(color1, color2, "nefield")
+ validate.VarWithValue(color1, color2, "nefield")
Field Does Not Equal Another Field (relative)
@@ -393,9 +583,9 @@ relative to the top level struct.
Field Greater Than Another Field
-Only valid for Numbers and time.Time types, this will validate the field value
-against another fields value either within a struct or passed in field.
-usage examples are for validation of a Start and End date:
+Only valid for Numbers, time.Duration and time.Time types, this will validate
+the field value against another fields value either within a struct or passed in
+field. usage examples are for validation of a Start and End date:
Example #1:
@@ -405,8 +595,7 @@ Example #1:
Example #2:
// Validating by field:
- validate.FieldWithValue(start, end, "gtfield")
-
+ validate.VarWithValue(start, end, "gtfield")
Field Greater Than Another Relative Field
@@ -417,9 +606,9 @@ relative to the top level struct.
Field Greater Than or Equal To Another Field
-Only valid for Numbers and time.Time types, this will validate the field value
-against another fields value either within a struct or passed in field.
-usage examples are for validation of a Start and End date:
+Only valid for Numbers, time.Duration and time.Time types, this will validate
+the field value against another fields value either within a struct or passed in
+field. usage examples are for validation of a Start and End date:
Example #1:
@@ -429,7 +618,7 @@ Example #1:
Example #2:
// Validating by field:
- validate.FieldWithValue(start, end, "gtefield")
+ validate.VarWithValue(start, end, "gtefield")
Field Greater Than or Equal To Another Relative Field
@@ -440,9 +629,9 @@ to the top level struct.
Less Than Another Field
-Only valid for Numbers and time.Time types, this will validate the field value
-against another fields value either within a struct or passed in field.
-usage examples are for validation of a Start and End date:
+Only valid for Numbers, time.Duration and time.Time types, this will validate
+the field value against another fields value either within a struct or passed in
+field. usage examples are for validation of a Start and End date:
Example #1:
@@ -452,7 +641,7 @@ Example #1:
Example #2:
// Validating by field:
- validate.FieldWithValue(start, end, "ltfield")
+ validate.VarWithValue(start, end, "ltfield")
Less Than Another Relative Field
@@ -463,9 +652,9 @@ to the top level struct.
Less Than or Equal To Another Field
-Only valid for Numbers and time.Time types, this will validate the field value
-against another fields value either within a struct or passed in field.
-usage examples are for validation of a Start and End date:
+Only valid for Numbers, time.Duration and time.Time types, this will validate
+the field value against another fields value either within a struct or passed in
+field. usage examples are for validation of a Start and End date:
Example #1:
@@ -475,7 +664,7 @@ Example #1:
Example #2:
// Validating by field:
- validate.FieldWithValue(start, end, "ltefield")
+ validate.VarWithValue(start, end, "ltefield")
Less Than or Equal To Another Relative Field
@@ -484,22 +673,71 @@ to the top level struct.
Usage: ltecsfield=InnerStructField.Field
+Field Contains Another Field
+
+This does the same as contains except for struct fields. It should only be used
+with string types. See the behavior of reflect.Value.String() for behavior on
+other types.
+
+ Usage: containsfield=InnerStructField.Field
+
+Field Excludes Another Field
+
+This does the same as excludes except for struct fields. It should only be used
+with string types. See the behavior of reflect.Value.String() for behavior on
+other types.
+
+ Usage: excludesfield=InnerStructField.Field
+
+Unique
+
+For arrays & slices, unique will ensure that there are no duplicates.
+For maps, unique will ensure that there are no duplicate values.
+For slices of struct, unique will ensure that there are no duplicate values
+in a field of the struct specified via a parameter.
+
+ // For arrays, slices, and maps:
+ Usage: unique
+
+ // For slices of struct:
+ Usage: unique=field
+
Alpha Only
-This validates that a string value contains alpha characters only
+This validates that a string value contains ASCII alpha characters only
Usage: alpha
Alphanumeric
-This validates that a string value contains alphanumeric characters only
+This validates that a string value contains ASCII alphanumeric characters only
Usage: alphanum
+Alpha Unicode
+
+This validates that a string value contains unicode alpha characters only
+
+ Usage: alphaunicode
+
+Alphanumeric Unicode
+
+This validates that a string value contains unicode alphanumeric characters only
+
+ Usage: alphanumunicode
+
+Number
+
+This validates that a string value contains number values only.
+For integers or float it returns true.
+
+ Usage: number
+
Numeric
This validates that a string value contains a basic numeric value.
basic excludes exponents etc...
+for integers or float it returns true.
Usage: numeric
@@ -516,6 +754,18 @@ hashtag (#)
Usage: hexcolor
+Lowercase String
+
+This validates that a string value contains only lowercase characters. An empty string is not a valid lowercase string.
+
+ Usage: lowercase
+
+Uppercase String
+
+This validates that a string value contains only uppercase characters. An empty string is not a valid uppercase string.
+
+ Usage: uppercase
+
RGB String
This validates that a string value contains a valid rgb color
@@ -540,14 +790,35 @@ This validates that a string value contains a valid hsla color
Usage: hsla
+E.164 Phone Number String
+
+This validates that a string value contains a valid E.164 Phone number
+https://en.wikipedia.org/wiki/E.164 (ex. +1123456789)
+
+ Usage: e164
+
E-mail String
This validates that a string value contains a valid email
This may not conform to all possibilities of any rfc standard, but neither
-does any email provider accept all posibilities.
+does any email provider accept all possibilities.
Usage: email
+JSON String
+
+This validates that a string value is valid JSON
+
+ Usage: json
+
+File path
+
+This validates that a string value contains a valid file path and that
+the file exists on the machine.
+This is done using os.Stat, which is a platform independent function.
+
+ Usage: file
+
URL String
This validates that a string value contains a valid url
@@ -563,6 +834,13 @@ This will accept any uri the golang request uri accepts
Usage: uri
+Urn RFC 2141 String
+
+This validataes that a string value contains a valid URN
+according to the RFC 2141 spec.
+
+ Usage: urn_rfc2141
+
Base64 String
This validates that a string value contains a valid base64 value.
@@ -572,6 +850,39 @@ this with the omitempty tag.
Usage: base64
+Base64URL String
+
+This validates that a string value contains a valid base64 URL safe value
+according the the RFC4648 spec.
+Although an empty string is a valid base64 URL safe value, this will report
+an empty string as an error, if you wish to accept an empty string as valid
+you can use this with the omitempty tag.
+
+ Usage: base64url
+
+Bitcoin Address
+
+This validates that a string value contains a valid bitcoin address.
+The format of the string is checked to ensure it matches one of the three formats
+P2PKH, P2SH and performs checksum validation.
+
+ Usage: btc_addr
+
+Bitcoin Bech32 Address (segwit)
+
+This validates that a string value contains a valid bitcoin Bech32 address as defined
+by bip-0173 (https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki)
+Special thanks to Pieter Wuille for providng reference implementations.
+
+ Usage: btc_addr_bech32
+
+Ethereum Address
+
+This validates that a string value contains a valid ethereum address.
+The format of the string is checked to ensure it matches the standard Ethereum address format.
+
+ Usage: eth_addr
+
Contains
This validates that a string value contains the substring value.
@@ -610,6 +921,30 @@ This validates that a string value does not contain the supplied rune value.
Usage: excludesrune=@
+Starts With
+
+This validates that a string value starts with the supplied string value
+
+ Usage: startswith=hello
+
+Ends With
+
+This validates that a string value ends with the supplied string value
+
+ Usage: endswith=goodbye
+
+Does Not Start With
+
+This validates that a string value does not start with the supplied string value
+
+ Usage: startsnotwith=hello
+
+Does Not End With
+
+This validates that a string value does not end with the supplied string value
+
+ Usage: endsnotwith=goodbye
+
International Standard Book Number
This validates that a string value contains a valid isbn10 or isbn13 value.
@@ -628,28 +963,27 @@ This validates that a string value contains a valid isbn13 value.
Usage: isbn13
-
Universally Unique Identifier UUID
-This validates that a string value contains a valid UUID.
+This validates that a string value contains a valid UUID. Uppercase UUID values will not pass - use `uuid_rfc4122` instead.
Usage: uuid
Universally Unique Identifier UUID v3
-This validates that a string value contains a valid version 3 UUID.
+This validates that a string value contains a valid version 3 UUID. Uppercase UUID values will not pass - use `uuid3_rfc4122` instead.
Usage: uuid3
Universally Unique Identifier UUID v4
-This validates that a string value contains a valid version 4 UUID.
+This validates that a string value contains a valid version 4 UUID. Uppercase UUID values will not pass - use `uuid4_rfc4122` instead.
Usage: uuid4
Universally Unique Identifier UUID v5
-This validates that a string value contains a valid version 5 UUID.
+This validates that a string value contains a valid version 5 UUID. Uppercase UUID values will not pass - use `uuid5_rfc4122` instead.
Usage: uuid5
@@ -665,7 +999,7 @@ Printable ASCII
This validates that a string value contains only printable ASCII characters.
NOTE: if the string is blank, this validates as true.
- Usage: asciiprint
+ Usage: printascii
Multi-Byte Characters
@@ -701,103 +1035,103 @@ This validates that a string value contains a valid U.S. Social Security Number.
Internet Protocol Address IP
-This validates that a string value contains a valid IP Adress.
+This validates that a string value contains a valid IP Address.
Usage: ip
Internet Protocol Address IPv4
-This validates that a string value contains a valid v4 IP Adress.
+This validates that a string value contains a valid v4 IP Address.
Usage: ipv4
Internet Protocol Address IPv6
-This validates that a string value contains a valid v6 IP Adress.
+This validates that a string value contains a valid v6 IP Address.
Usage: ipv6
Classless Inter-Domain Routing CIDR
-This validates that a string value contains a valid CIDR Adress.
+This validates that a string value contains a valid CIDR Address.
Usage: cidr
Classless Inter-Domain Routing CIDRv4
-This validates that a string value contains a valid v4 CIDR Adress.
+This validates that a string value contains a valid v4 CIDR Address.
Usage: cidrv4
Classless Inter-Domain Routing CIDRv6
-This validates that a string value contains a valid v6 CIDR Adress.
+This validates that a string value contains a valid v6 CIDR Address.
Usage: cidrv6
Transmission Control Protocol Address TCP
-This validates that a string value contains a valid resolvable TCP Adress.
+This validates that a string value contains a valid resolvable TCP Address.
Usage: tcp_addr
Transmission Control Protocol Address TCPv4
-This validates that a string value contains a valid resolvable v4 TCP Adress.
+This validates that a string value contains a valid resolvable v4 TCP Address.
Usage: tcp4_addr
Transmission Control Protocol Address TCPv6
-This validates that a string value contains a valid resolvable v6 TCP Adress.
+This validates that a string value contains a valid resolvable v6 TCP Address.
Usage: tcp6_addr
User Datagram Protocol Address UDP
-This validates that a string value contains a valid resolvable UDP Adress.
+This validates that a string value contains a valid resolvable UDP Address.
Usage: udp_addr
User Datagram Protocol Address UDPv4
-This validates that a string value contains a valid resolvable v4 UDP Adress.
+This validates that a string value contains a valid resolvable v4 UDP Address.
Usage: udp4_addr
User Datagram Protocol Address UDPv6
-This validates that a string value contains a valid resolvable v6 UDP Adress.
+This validates that a string value contains a valid resolvable v6 UDP Address.
Usage: udp6_addr
Internet Protocol Address IP
-This validates that a string value contains a valid resolvable IP Adress.
+This validates that a string value contains a valid resolvable IP Address.
Usage: ip_addr
Internet Protocol Address IPv4
-This validates that a string value contains a valid resolvable v4 IP Adress.
+This validates that a string value contains a valid resolvable v4 IP Address.
Usage: ip4_addr
Internet Protocol Address IPv6
-This validates that a string value contains a valid resolvable v6 IP Adress.
+This validates that a string value contains a valid resolvable v6 IP Address.
Usage: ip6_addr
Unix domain socket end point Address
-This validates that a string value contains a valid Unix Adress.
+This validates that a string value contains a valid Unix Address.
Usage: unix_addr
Media Access Control Address MAC
-This validates that a string value contains a valid MAC Adress.
+This validates that a string value contains a valid MAC Address.
Usage: mac
@@ -805,6 +1139,97 @@ Note: See Go's ParseMAC for accepted formats and types:
http://golang.org/src/net/mac.go?s=866:918#L29
+Hostname RFC 952
+
+This validates that a string value is a valid Hostname according to RFC 952 https://tools.ietf.org/html/rfc952
+
+ Usage: hostname
+
+Hostname RFC 1123
+
+This validates that a string value is a valid Hostname according to RFC 1123 https://tools.ietf.org/html/rfc1123
+
+ Usage: hostname_rfc1123 or if you want to continue to use 'hostname' in your tags, create an alias.
+
+Full Qualified Domain Name (FQDN)
+
+This validates that a string value contains a valid FQDN.
+
+ Usage: fqdn
+
+HTML Tags
+
+This validates that a string value appears to be an HTML element tag
+including those described at https://developer.mozilla.org/en-US/docs/Web/HTML/Element
+
+ Usage: html
+
+HTML Encoded
+
+This validates that a string value is a proper character reference in decimal
+or hexadecimal format
+
+ Usage: html_encoded
+
+URL Encoded
+
+This validates that a string value is percent-encoded (URL encoded) according
+to https://tools.ietf.org/html/rfc3986#section-2.1
+
+ Usage: url_encoded
+
+Directory
+
+This validates that a string value contains a valid directory and that
+it exists on the machine.
+This is done using os.Stat, which is a platform independent function.
+
+ Usage: dir
+
+HostPort
+
+This validates that a string value contains a valid DNS hostname and port that
+can be used to valiate fields typically passed to sockets and connections.
+
+ Usage: hostname_port
+
+Datetime
+
+This validates that a string value is a valid datetime based on the supplied datetime format.
+Supplied format must match the official Go time format layout as documented in https://golang.org/pkg/time/
+
+ Usage: datetime=2006-01-02
+
+Iso3166-1 alpha-2
+
+This validates that a string value is a valid country code based on iso3166-1 alpha-2 standard.
+see: https://www.iso.org/iso-3166-country-codes.html
+
+ Usage: iso3166_1_alpha2
+
+Iso3166-1 alpha-3
+
+This validates that a string value is a valid country code based on iso3166-1 alpha-3 standard.
+see: https://www.iso.org/iso-3166-country-codes.html
+
+ Usage: iso3166_1_alpha3
+
+Iso3166-1 alpha-numeric
+
+This validates that a string value is a valid country code based on iso3166-1 alpha-numeric standard.
+see: https://www.iso.org/iso-3166-country-codes.html
+
+ Usage: iso3166_1_alpha3
+
+TimeZone
+
+This validates that a string value is a valid time zone based on the time zone database present on the system.
+Although empty value and Local value are allowed by time.LoadLocation golang function, they are not allowed by this validator.
+More information on https://golang.org/pkg/time/#LoadLocation
+
+ Usage: timezone
+
+
Alias Validators and Tags
NOTE: When returning an error, the tag returned in "FieldError" will be
@@ -816,6 +1241,8 @@ Here is a list of the current built in alias tags:
"iscolor"
alias is "hexcolor|rgb|rgba|hsl|hsla" (Usage: iscolor)
+ "country_code"
+ alias is "iso3166_1_alpha2|iso3166_1_alpha3|iso3166_1_alpha_numeric" (Usage: country_code)
Validator notes:
@@ -824,7 +1251,7 @@ Validator notes:
of a regex which conflict with the validation definitions. Although
workarounds can be made, they take away from using pure regex's.
Furthermore it's quick and dirty but the regex's become harder to
- maintain and are not reusable, so it's as much a programming philosiphy
+ maintain and are not reusable, so it's as much a programming philosophy
as anything.
In place of this new validator functions should be created; a regex can
@@ -834,6 +1261,35 @@ Validator notes:
And the best reason, you can submit a pull request and we can keep on
adding to the validation library of this package!
+Non standard validators
+
+A collection of validation rules that are frequently needed but are more
+complex than the ones found in the baked in validators.
+A non standard validator must be registered manually like you would
+with your own custom validation functions.
+
+Example of registration and use:
+
+ type Test struct {
+ TestField string `validate:"yourtag"`
+ }
+
+ t := &Test{
+ TestField: "Test"
+ }
+
+ validate := validator.New()
+ validate.RegisterValidation("yourtag", validators.NotBlank)
+
+Here is a list of the current non standard validators:
+
+ NotBlank
+ This validates that the value is not blank or with length zero.
+ For strings ensures they do not contain only spaces. For channels, maps, slices and arrays
+ ensures they don't have zero length. For others, a non empty value is required.
+
+ Usage: notblank
+
Panics
This package panics when bad input is provided, this is by design, bad code like
diff --git a/baas-kubeengine/vendor/github.com/go-playground/validator/v10/errors.go b/baas-kubeengine/vendor/github.com/go-playground/validator/v10/errors.go
new file mode 100644
index 00000000..63293cf9
--- /dev/null
+++ b/baas-kubeengine/vendor/github.com/go-playground/validator/v10/errors.go
@@ -0,0 +1,275 @@
+package validator
+
+import (
+ "bytes"
+ "fmt"
+ "reflect"
+ "strings"
+
+ ut "github.com/go-playground/universal-translator"
+)
+
+const (
+ fieldErrMsg = "Key: '%s' Error:Field validation for '%s' failed on the '%s' tag"
+)
+
+// ValidationErrorsTranslations is the translation return type
+type ValidationErrorsTranslations map[string]string
+
+// InvalidValidationError describes an invalid argument passed to
+// `Struct`, `StructExcept`, StructPartial` or `Field`
+type InvalidValidationError struct {
+ Type reflect.Type
+}
+
+// Error returns InvalidValidationError message
+func (e *InvalidValidationError) Error() string {
+
+ if e.Type == nil {
+ return "validator: (nil)"
+ }
+
+ return "validator: (nil " + e.Type.String() + ")"
+}
+
+// ValidationErrors is an array of FieldError's
+// for use in custom error messages post validation.
+type ValidationErrors []FieldError
+
+// Error is intended for use in development + debugging and not intended to be a production error message.
+// It allows ValidationErrors to subscribe to the Error interface.
+// All information to create an error message specific to your application is contained within
+// the FieldError found within the ValidationErrors array
+func (ve ValidationErrors) Error() string {
+
+ buff := bytes.NewBufferString("")
+
+ var fe *fieldError
+
+ for i := 0; i < len(ve); i++ {
+
+ fe = ve[i].(*fieldError)
+ buff.WriteString(fe.Error())
+ buff.WriteString("\n")
+ }
+
+ return strings.TrimSpace(buff.String())
+}
+
+// Translate translates all of the ValidationErrors
+func (ve ValidationErrors) Translate(ut ut.Translator) ValidationErrorsTranslations {
+
+ trans := make(ValidationErrorsTranslations)
+
+ var fe *fieldError
+
+ for i := 0; i < len(ve); i++ {
+ fe = ve[i].(*fieldError)
+
+ // // in case an Anonymous struct was used, ensure that the key
+ // // would be 'Username' instead of ".Username"
+ // if len(fe.ns) > 0 && fe.ns[:1] == "." {
+ // trans[fe.ns[1:]] = fe.Translate(ut)
+ // continue
+ // }
+
+ trans[fe.ns] = fe.Translate(ut)
+ }
+
+ return trans
+}
+
+// FieldError contains all functions to get error details
+type FieldError interface {
+
+ // returns the validation tag that failed. if the
+ // validation was an alias, this will return the
+ // alias name and not the underlying tag that failed.
+ //
+ // eg. alias "iscolor": "hexcolor|rgb|rgba|hsl|hsla"
+ // will return "iscolor"
+ Tag() string
+
+ // returns the validation tag that failed, even if an
+ // alias the actual tag within the alias will be returned.
+ // If an 'or' validation fails the entire or will be returned.
+ //
+ // eg. alias "iscolor": "hexcolor|rgb|rgba|hsl|hsla"
+ // will return "hexcolor|rgb|rgba|hsl|hsla"
+ ActualTag() string
+
+ // returns the namespace for the field error, with the tag
+ // name taking precedence over the field's actual name.
+ //
+ // eg. JSON name "User.fname"
+ //
+ // See StructNamespace() for a version that returns actual names.
+ //
+ // NOTE: this field can be blank when validating a single primitive field
+ // using validate.Field(...) as there is no way to extract it's name
+ Namespace() string
+
+ // returns the namespace for the field error, with the field's
+ // actual name.
+ //
+ // eq. "User.FirstName" see Namespace for comparison
+ //
+ // NOTE: this field can be blank when validating a single primitive field
+ // using validate.Field(...) as there is no way to extract its name
+ StructNamespace() string
+
+ // returns the fields name with the tag name taking precedence over the
+ // field's actual name.
+ //
+ // eq. JSON name "fname"
+ // see StructField for comparison
+ Field() string
+
+ // returns the field's actual name from the struct, when able to determine.
+ //
+ // eq. "FirstName"
+ // see Field for comparison
+ StructField() string
+
+ // returns the actual field's value in case needed for creating the error
+ // message
+ Value() interface{}
+
+ // returns the param value, in string form for comparison; this will also
+ // help with generating an error message
+ Param() string
+
+ // Kind returns the Field's reflect Kind
+ //
+ // eg. time.Time's kind is a struct
+ Kind() reflect.Kind
+
+ // Type returns the Field's reflect Type
+ //
+ // // eg. time.Time's type is time.Time
+ Type() reflect.Type
+
+ // returns the FieldError's translated error
+ // from the provided 'ut.Translator' and registered 'TranslationFunc'
+ //
+ // NOTE: if no registered translator can be found it returns the same as
+ // calling fe.Error()
+ Translate(ut ut.Translator) string
+
+ // Error returns the FieldError's message
+ Error() string
+}
+
+// compile time interface checks
+var _ FieldError = new(fieldError)
+var _ error = new(fieldError)
+
+// fieldError contains a single field's validation error along
+// with other properties that may be needed for error message creation
+// it complies with the FieldError interface
+type fieldError struct {
+ v *Validate
+ tag string
+ actualTag string
+ ns string
+ structNs string
+ fieldLen uint8
+ structfieldLen uint8
+ value interface{}
+ param string
+ kind reflect.Kind
+ typ reflect.Type
+}
+
+// Tag returns the validation tag that failed.
+func (fe *fieldError) Tag() string {
+ return fe.tag
+}
+
+// ActualTag returns the validation tag that failed, even if an
+// alias the actual tag within the alias will be returned.
+func (fe *fieldError) ActualTag() string {
+ return fe.actualTag
+}
+
+// Namespace returns the namespace for the field error, with the tag
+// name taking precedence over the field's actual name.
+func (fe *fieldError) Namespace() string {
+ return fe.ns
+}
+
+// StructNamespace returns the namespace for the field error, with the field's
+// actual name.
+func (fe *fieldError) StructNamespace() string {
+ return fe.structNs
+}
+
+// Field returns the field's name with the tag name taking precedence over the
+// field's actual name.
+func (fe *fieldError) Field() string {
+
+ return fe.ns[len(fe.ns)-int(fe.fieldLen):]
+ // // return fe.field
+ // fld := fe.ns[len(fe.ns)-int(fe.fieldLen):]
+
+ // log.Println("FLD:", fld)
+
+ // if len(fld) > 0 && fld[:1] == "." {
+ // return fld[1:]
+ // }
+
+ // return fld
+}
+
+// returns the field's actual name from the struct, when able to determine.
+func (fe *fieldError) StructField() string {
+ // return fe.structField
+ return fe.structNs[len(fe.structNs)-int(fe.structfieldLen):]
+}
+
+// Value returns the actual field's value in case needed for creating the error
+// message
+func (fe *fieldError) Value() interface{} {
+ return fe.value
+}
+
+// Param returns the param value, in string form for comparison; this will
+// also help with generating an error message
+func (fe *fieldError) Param() string {
+ return fe.param
+}
+
+// Kind returns the Field's reflect Kind
+func (fe *fieldError) Kind() reflect.Kind {
+ return fe.kind
+}
+
+// Type returns the Field's reflect Type
+func (fe *fieldError) Type() reflect.Type {
+ return fe.typ
+}
+
+// Error returns the fieldError's error message
+func (fe *fieldError) Error() string {
+ return fmt.Sprintf(fieldErrMsg, fe.ns, fe.Field(), fe.tag)
+}
+
+// Translate returns the FieldError's translated error
+// from the provided 'ut.Translator' and registered 'TranslationFunc'
+//
+// NOTE: if no registered translation can be found, it returns the original
+// untranslated error message.
+func (fe *fieldError) Translate(ut ut.Translator) string {
+
+ m, ok := fe.v.transTagFunc[ut]
+ if !ok {
+ return fe.Error()
+ }
+
+ fn, ok := m[fe.tag]
+ if !ok {
+ return fe.Error()
+ }
+
+ return fn(ut, fe)
+}
diff --git a/baas-kubeengine/vendor/github.com/go-playground/validator/v10/field_level.go b/baas-kubeengine/vendor/github.com/go-playground/validator/v10/field_level.go
new file mode 100644
index 00000000..f0e2a9a8
--- /dev/null
+++ b/baas-kubeengine/vendor/github.com/go-playground/validator/v10/field_level.go
@@ -0,0 +1,119 @@
+package validator
+
+import "reflect"
+
+// FieldLevel contains all the information and helper functions
+// to validate a field
+type FieldLevel interface {
+ // returns the top level struct, if any
+ Top() reflect.Value
+
+ // returns the current fields parent struct, if any or
+ // the comparison value if called 'VarWithValue'
+ Parent() reflect.Value
+
+ // returns current field for validation
+ Field() reflect.Value
+
+ // returns the field's name with the tag
+ // name taking precedence over the fields actual name.
+ FieldName() string
+
+ // returns the struct field's name
+ StructFieldName() string
+
+ // returns param for validation against current field
+ Param() string
+
+ // GetTag returns the current validations tag name
+ GetTag() string
+
+ // ExtractType gets the actual underlying type of field value.
+ // It will dive into pointers, customTypes and return you the
+ // underlying value and it's kind.
+ ExtractType(field reflect.Value) (value reflect.Value, kind reflect.Kind, nullable bool)
+
+ // traverses the parent struct to retrieve a specific field denoted by the provided namespace
+ // in the param and returns the field, field kind and whether is was successful in retrieving
+ // the field at all.
+ //
+ // NOTE: when not successful ok will be false, this can happen when a nested struct is nil and so the field
+ // could not be retrieved because it didn't exist.
+ //
+ // Deprecated: Use GetStructFieldOK2() instead which also return if the value is nullable.
+ GetStructFieldOK() (reflect.Value, reflect.Kind, bool)
+
+ // GetStructFieldOKAdvanced is the same as GetStructFieldOK except that it accepts the parent struct to start looking for
+ // the field and namespace allowing more extensibility for validators.
+ //
+ // Deprecated: Use GetStructFieldOKAdvanced2() instead which also return if the value is nullable.
+ GetStructFieldOKAdvanced(val reflect.Value, namespace string) (reflect.Value, reflect.Kind, bool)
+
+ // traverses the parent struct to retrieve a specific field denoted by the provided namespace
+ // in the param and returns the field, field kind, if it's a nullable type and whether is was successful in retrieving
+ // the field at all.
+ //
+ // NOTE: when not successful ok will be false, this can happen when a nested struct is nil and so the field
+ // could not be retrieved because it didn't exist.
+ GetStructFieldOK2() (reflect.Value, reflect.Kind, bool, bool)
+
+ // GetStructFieldOKAdvanced is the same as GetStructFieldOK except that it accepts the parent struct to start looking for
+ // the field and namespace allowing more extensibility for validators.
+ GetStructFieldOKAdvanced2(val reflect.Value, namespace string) (reflect.Value, reflect.Kind, bool, bool)
+}
+
+var _ FieldLevel = new(validate)
+
+// Field returns current field for validation
+func (v *validate) Field() reflect.Value {
+ return v.flField
+}
+
+// FieldName returns the field's name with the tag
+// name taking precedence over the fields actual name.
+func (v *validate) FieldName() string {
+ return v.cf.altName
+}
+
+// GetTag returns the current validations tag name
+func (v *validate) GetTag() string {
+ return v.ct.tag
+}
+
+// StructFieldName returns the struct field's name
+func (v *validate) StructFieldName() string {
+ return v.cf.name
+}
+
+// Param returns param for validation against current field
+func (v *validate) Param() string {
+ return v.ct.param
+}
+
+// GetStructFieldOK returns Param returns param for validation against current field
+//
+// Deprecated: Use GetStructFieldOK2() instead which also return if the value is nullable.
+func (v *validate) GetStructFieldOK() (reflect.Value, reflect.Kind, bool) {
+ current, kind, _, found := v.getStructFieldOKInternal(v.slflParent, v.ct.param)
+ return current, kind, found
+}
+
+// GetStructFieldOKAdvanced is the same as GetStructFieldOK except that it accepts the parent struct to start looking for
+// the field and namespace allowing more extensibility for validators.
+//
+// Deprecated: Use GetStructFieldOKAdvanced2() instead which also return if the value is nullable.
+func (v *validate) GetStructFieldOKAdvanced(val reflect.Value, namespace string) (reflect.Value, reflect.Kind, bool) {
+ current, kind, _, found := v.GetStructFieldOKAdvanced2(val, namespace)
+ return current, kind, found
+}
+
+// GetStructFieldOK returns Param returns param for validation against current field
+func (v *validate) GetStructFieldOK2() (reflect.Value, reflect.Kind, bool, bool) {
+ return v.getStructFieldOKInternal(v.slflParent, v.ct.param)
+}
+
+// GetStructFieldOKAdvanced is the same as GetStructFieldOK except that it accepts the parent struct to start looking for
+// the field and namespace allowing more extensibility for validators.
+func (v *validate) GetStructFieldOKAdvanced2(val reflect.Value, namespace string) (reflect.Value, reflect.Kind, bool, bool) {
+ return v.getStructFieldOKInternal(val, namespace)
+}
diff --git a/baas-kubeengine/vendor/github.com/go-playground/validator/v10/go.mod b/baas-kubeengine/vendor/github.com/go-playground/validator/v10/go.mod
new file mode 100644
index 00000000..d457100e
--- /dev/null
+++ b/baas-kubeengine/vendor/github.com/go-playground/validator/v10/go.mod
@@ -0,0 +1,11 @@
+module github.com/go-playground/validator/v10
+
+go 1.13
+
+require (
+ github.com/go-playground/assert/v2 v2.0.1
+ github.com/go-playground/locales v0.13.0
+ github.com/go-playground/universal-translator v0.17.0
+ github.com/leodido/go-urn v1.2.0
+ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9
+)
diff --git a/baas-kubeengine/vendor/github.com/go-playground/validator/v10/go.sum b/baas-kubeengine/vendor/github.com/go-playground/validator/v10/go.sum
new file mode 100644
index 00000000..01526427
--- /dev/null
+++ b/baas-kubeengine/vendor/github.com/go-playground/validator/v10/go.sum
@@ -0,0 +1,28 @@
+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/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/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/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
+github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
+github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
+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-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
+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/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
+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=
+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/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
+gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
diff --git a/baas-kubeengine/vendor/gopkg.in/go-playground/validator.v8/logo.png b/baas-kubeengine/vendor/github.com/go-playground/validator/v10/logo.png
similarity index 100%
rename from baas-kubeengine/vendor/gopkg.in/go-playground/validator.v8/logo.png
rename to baas-kubeengine/vendor/github.com/go-playground/validator/v10/logo.png
diff --git a/baas-kubeengine/vendor/github.com/go-playground/validator/v10/regexes.go b/baas-kubeengine/vendor/github.com/go-playground/validator/v10/regexes.go
new file mode 100644
index 00000000..b741f4e1
--- /dev/null
+++ b/baas-kubeengine/vendor/github.com/go-playground/validator/v10/regexes.go
@@ -0,0 +1,101 @@
+package validator
+
+import "regexp"
+
+const (
+ alphaRegexString = "^[a-zA-Z]+$"
+ alphaNumericRegexString = "^[a-zA-Z0-9]+$"
+ alphaUnicodeRegexString = "^[\\p{L}]+$"
+ alphaUnicodeNumericRegexString = "^[\\p{L}\\p{N}]+$"
+ numericRegexString = "^[-+]?[0-9]+(?:\\.[0-9]+)?$"
+ numberRegexString = "^[0-9]+$"
+ hexadecimalRegexString = "^(0[xX])?[0-9a-fA-F]+$"
+ hexcolorRegexString = "^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$"
+ rgbRegexString = "^rgb\\(\\s*(?:(?:0|[1-9]\\d?|1\\d\\d?|2[0-4]\\d|25[0-5])\\s*,\\s*(?:0|[1-9]\\d?|1\\d\\d?|2[0-4]\\d|25[0-5])\\s*,\\s*(?:0|[1-9]\\d?|1\\d\\d?|2[0-4]\\d|25[0-5])|(?:0|[1-9]\\d?|1\\d\\d?|2[0-4]\\d|25[0-5])%\\s*,\\s*(?:0|[1-9]\\d?|1\\d\\d?|2[0-4]\\d|25[0-5])%\\s*,\\s*(?:0|[1-9]\\d?|1\\d\\d?|2[0-4]\\d|25[0-5])%)\\s*\\)$"
+ rgbaRegexString = "^rgba\\(\\s*(?:(?:0|[1-9]\\d?|1\\d\\d?|2[0-4]\\d|25[0-5])\\s*,\\s*(?:0|[1-9]\\d?|1\\d\\d?|2[0-4]\\d|25[0-5])\\s*,\\s*(?:0|[1-9]\\d?|1\\d\\d?|2[0-4]\\d|25[0-5])|(?:0|[1-9]\\d?|1\\d\\d?|2[0-4]\\d|25[0-5])%\\s*,\\s*(?:0|[1-9]\\d?|1\\d\\d?|2[0-4]\\d|25[0-5])%\\s*,\\s*(?:0|[1-9]\\d?|1\\d\\d?|2[0-4]\\d|25[0-5])%)\\s*,\\s*(?:(?:0.[1-9]*)|[01])\\s*\\)$"
+ hslRegexString = "^hsl\\(\\s*(?:0|[1-9]\\d?|[12]\\d\\d|3[0-5]\\d|360)\\s*,\\s*(?:(?:0|[1-9]\\d?|100)%)\\s*,\\s*(?:(?:0|[1-9]\\d?|100)%)\\s*\\)$"
+ hslaRegexString = "^hsla\\(\\s*(?:0|[1-9]\\d?|[12]\\d\\d|3[0-5]\\d|360)\\s*,\\s*(?:(?:0|[1-9]\\d?|100)%)\\s*,\\s*(?:(?:0|[1-9]\\d?|100)%)\\s*,\\s*(?:(?:0.[1-9]*)|[01])\\s*\\)$"
+ emailRegexString = "^(?:(?:(?:(?:[a-zA-Z]|\\d|[!#\\$%&'\\*\\+\\-\\/=\\?\\^_`{\\|}~]|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])+(?:\\.([a-zA-Z]|\\d|[!#\\$%&'\\*\\+\\-\\/=\\?\\^_`{\\|}~]|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])+)*)|(?:(?:\\x22)(?:(?:(?:(?:\\x20|\\x09)*(?:\\x0d\\x0a))?(?:\\x20|\\x09)+)?(?:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x7f]|\\x21|[\\x23-\\x5b]|[\\x5d-\\x7e]|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])|(?:(?:[\\x01-\\x09\\x0b\\x0c\\x0d-\\x7f]|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}]))))*(?:(?:(?:\\x20|\\x09)*(?:\\x0d\\x0a))?(\\x20|\\x09)+)?(?:\\x22))))@(?:(?:(?:[a-zA-Z]|\\d|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])|(?:(?:[a-zA-Z]|\\d|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])(?:[a-zA-Z]|\\d|-|\\.|~|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])*(?:[a-zA-Z]|\\d|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])))\\.)+(?:(?:[a-zA-Z]|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])|(?:(?:[a-zA-Z]|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])(?:[a-zA-Z]|\\d|-|\\.|~|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])*(?:[a-zA-Z]|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])))\\.?$"
+ e164RegexString = "^\\+[1-9]?[0-9]{7,14}$"
+ base64RegexString = "^(?:[A-Za-z0-9+\\/]{4})*(?:[A-Za-z0-9+\\/]{2}==|[A-Za-z0-9+\\/]{3}=|[A-Za-z0-9+\\/]{4})$"
+ base64URLRegexString = "^(?:[A-Za-z0-9-_]{4})*(?:[A-Za-z0-9-_]{2}==|[A-Za-z0-9-_]{3}=|[A-Za-z0-9-_]{4})$"
+ iSBN10RegexString = "^(?:[0-9]{9}X|[0-9]{10})$"
+ iSBN13RegexString = "^(?:(?:97(?:8|9))[0-9]{10})$"
+ uUID3RegexString = "^[0-9a-f]{8}-[0-9a-f]{4}-3[0-9a-f]{3}-[0-9a-f]{4}-[0-9a-f]{12}$"
+ uUID4RegexString = "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
+ uUID5RegexString = "^[0-9a-f]{8}-[0-9a-f]{4}-5[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
+ uUIDRegexString = "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
+ uUID3RFC4122RegexString = "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-3[0-9a-fA-F]{3}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"
+ uUID4RFC4122RegexString = "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
+ uUID5RFC4122RegexString = "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-5[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
+ uUIDRFC4122RegexString = "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"
+ aSCIIRegexString = "^[\x00-\x7F]*$"
+ printableASCIIRegexString = "^[\x20-\x7E]*$"
+ multibyteRegexString = "[^\x00-\x7F]"
+ dataURIRegexString = `^data:((?:\w+\/(?:([^;]|;[^;]).)+)?)`
+ latitudeRegexString = "^[-+]?([1-8]?\\d(\\.\\d+)?|90(\\.0+)?)$"
+ longitudeRegexString = "^[-+]?(180(\\.0+)?|((1[0-7]\\d)|([1-9]?\\d))(\\.\\d+)?)$"
+ sSNRegexString = `^[0-9]{3}[ -]?(0[1-9]|[1-9][0-9])[ -]?([1-9][0-9]{3}|[0-9][1-9][0-9]{2}|[0-9]{2}[1-9][0-9]|[0-9]{3}[1-9])$`
+ hostnameRegexStringRFC952 = `^[a-zA-Z]([a-zA-Z0-9\-]+[\.]?)*[a-zA-Z0-9]$` // https://tools.ietf.org/html/rfc952
+ hostnameRegexStringRFC1123 = `^([a-zA-Z0-9]{1}[a-zA-Z0-9_-]{0,62}){1}(\.[a-zA-Z0-9_]{1}[a-zA-Z0-9_-]{0,62})*?$` // accepts hostname starting with a digit https://tools.ietf.org/html/rfc1123
+ fqdnRegexStringRFC1123 = `^([a-zA-Z0-9]{1}[a-zA-Z0-9_-]{0,62})(\.[a-zA-Z0-9_]{1}[a-zA-Z0-9_-]{0,62})*?(\.[a-zA-Z]{1}[a-zA-Z0-9]{0,62})\.?$` // same as hostnameRegexStringRFC1123 but must contain a non numerical TLD (possibly ending with '.')
+ btcAddressRegexString = `^[13][a-km-zA-HJ-NP-Z1-9]{25,34}$` // bitcoin address
+ btcAddressUpperRegexStringBech32 = `^BC1[02-9AC-HJ-NP-Z]{7,76}$` // bitcoin bech32 address https://en.bitcoin.it/wiki/Bech32
+ btcAddressLowerRegexStringBech32 = `^bc1[02-9ac-hj-np-z]{7,76}$` // bitcoin bech32 address https://en.bitcoin.it/wiki/Bech32
+ ethAddressRegexString = `^0x[0-9a-fA-F]{40}$`
+ ethAddressUpperRegexString = `^0x[0-9A-F]{40}$`
+ ethAddressLowerRegexString = `^0x[0-9a-f]{40}$`
+ uRLEncodedRegexString = `(%[A-Fa-f0-9]{2})`
+ hTMLEncodedRegexString = `[x]?([0-9a-fA-F]{2})|(>)|(<)|(")|(&)+[;]?`
+ hTMLRegexString = `<[/]?([a-zA-Z]+).*?>`
+ splitParamsRegexString = `'[^']*'|\S+`
+)
+
+var (
+ alphaRegex = regexp.MustCompile(alphaRegexString)
+ alphaNumericRegex = regexp.MustCompile(alphaNumericRegexString)
+ alphaUnicodeRegex = regexp.MustCompile(alphaUnicodeRegexString)
+ alphaUnicodeNumericRegex = regexp.MustCompile(alphaUnicodeNumericRegexString)
+ numericRegex = regexp.MustCompile(numericRegexString)
+ numberRegex = regexp.MustCompile(numberRegexString)
+ hexadecimalRegex = regexp.MustCompile(hexadecimalRegexString)
+ hexcolorRegex = regexp.MustCompile(hexcolorRegexString)
+ rgbRegex = regexp.MustCompile(rgbRegexString)
+ rgbaRegex = regexp.MustCompile(rgbaRegexString)
+ hslRegex = regexp.MustCompile(hslRegexString)
+ hslaRegex = regexp.MustCompile(hslaRegexString)
+ e164Regex = regexp.MustCompile(e164RegexString)
+ emailRegex = regexp.MustCompile(emailRegexString)
+ base64Regex = regexp.MustCompile(base64RegexString)
+ base64URLRegex = regexp.MustCompile(base64URLRegexString)
+ iSBN10Regex = regexp.MustCompile(iSBN10RegexString)
+ iSBN13Regex = regexp.MustCompile(iSBN13RegexString)
+ uUID3Regex = regexp.MustCompile(uUID3RegexString)
+ uUID4Regex = regexp.MustCompile(uUID4RegexString)
+ uUID5Regex = regexp.MustCompile(uUID5RegexString)
+ uUIDRegex = regexp.MustCompile(uUIDRegexString)
+ uUID3RFC4122Regex = regexp.MustCompile(uUID3RFC4122RegexString)
+ uUID4RFC4122Regex = regexp.MustCompile(uUID4RFC4122RegexString)
+ uUID5RFC4122Regex = regexp.MustCompile(uUID5RFC4122RegexString)
+ uUIDRFC4122Regex = regexp.MustCompile(uUIDRFC4122RegexString)
+ aSCIIRegex = regexp.MustCompile(aSCIIRegexString)
+ printableASCIIRegex = regexp.MustCompile(printableASCIIRegexString)
+ multibyteRegex = regexp.MustCompile(multibyteRegexString)
+ dataURIRegex = regexp.MustCompile(dataURIRegexString)
+ latitudeRegex = regexp.MustCompile(latitudeRegexString)
+ longitudeRegex = regexp.MustCompile(longitudeRegexString)
+ sSNRegex = regexp.MustCompile(sSNRegexString)
+ hostnameRegexRFC952 = regexp.MustCompile(hostnameRegexStringRFC952)
+ hostnameRegexRFC1123 = regexp.MustCompile(hostnameRegexStringRFC1123)
+ fqdnRegexRFC1123 = regexp.MustCompile(fqdnRegexStringRFC1123)
+ btcAddressRegex = regexp.MustCompile(btcAddressRegexString)
+ btcUpperAddressRegexBech32 = regexp.MustCompile(btcAddressUpperRegexStringBech32)
+ btcLowerAddressRegexBech32 = regexp.MustCompile(btcAddressLowerRegexStringBech32)
+ ethAddressRegex = regexp.MustCompile(ethAddressRegexString)
+ ethaddressRegexUpper = regexp.MustCompile(ethAddressUpperRegexString)
+ ethAddressRegexLower = regexp.MustCompile(ethAddressLowerRegexString)
+ uRLEncodedRegex = regexp.MustCompile(uRLEncodedRegexString)
+ hTMLEncodedRegex = regexp.MustCompile(hTMLEncodedRegexString)
+ hTMLRegex = regexp.MustCompile(hTMLRegexString)
+ splitParamsRegex = regexp.MustCompile(splitParamsRegexString)
+)
diff --git a/baas-kubeengine/vendor/github.com/go-playground/validator/v10/struct_level.go b/baas-kubeengine/vendor/github.com/go-playground/validator/v10/struct_level.go
new file mode 100644
index 00000000..57691ee3
--- /dev/null
+++ b/baas-kubeengine/vendor/github.com/go-playground/validator/v10/struct_level.go
@@ -0,0 +1,175 @@
+package validator
+
+import (
+ "context"
+ "reflect"
+)
+
+// StructLevelFunc accepts all values needed for struct level validation
+type StructLevelFunc func(sl StructLevel)
+
+// StructLevelFuncCtx accepts all values needed for struct level validation
+// but also allows passing of contextual validation information via context.Context.
+type StructLevelFuncCtx func(ctx context.Context, sl StructLevel)
+
+// wrapStructLevelFunc wraps normal StructLevelFunc makes it compatible with StructLevelFuncCtx
+func wrapStructLevelFunc(fn StructLevelFunc) StructLevelFuncCtx {
+ return func(ctx context.Context, sl StructLevel) {
+ fn(sl)
+ }
+}
+
+// StructLevel contains all the information and helper functions
+// to validate a struct
+type StructLevel interface {
+
+ // returns the main validation object, in case one wants to call validations internally.
+ // this is so you don't have to use anonymous functions to get access to the validate
+ // instance.
+ Validator() *Validate
+
+ // returns the top level struct, if any
+ Top() reflect.Value
+
+ // returns the current fields parent struct, if any
+ Parent() reflect.Value
+
+ // returns the current struct.
+ Current() reflect.Value
+
+ // ExtractType gets the actual underlying type of field value.
+ // It will dive into pointers, customTypes and return you the
+ // underlying value and its kind.
+ ExtractType(field reflect.Value) (value reflect.Value, kind reflect.Kind, nullable bool)
+
+ // reports an error just by passing the field and tag information
+ //
+ // NOTES:
+ //
+ // fieldName and altName get appended to the existing namespace that
+ // validator is on. e.g. pass 'FirstName' or 'Names[0]' depending
+ // on the nesting
+ //
+ // tag can be an existing validation tag or just something you make up
+ // and process on the flip side it's up to you.
+ ReportError(field interface{}, fieldName, structFieldName string, tag, param string)
+
+ // reports an error just by passing ValidationErrors
+ //
+ // NOTES:
+ //
+ // relativeNamespace and relativeActualNamespace get appended to the
+ // existing namespace that validator is on.
+ // e.g. pass 'User.FirstName' or 'Users[0].FirstName' depending
+ // on the nesting. most of the time they will be blank, unless you validate
+ // at a level lower the the current field depth
+ ReportValidationErrors(relativeNamespace, relativeActualNamespace string, errs ValidationErrors)
+}
+
+var _ StructLevel = new(validate)
+
+// Top returns the top level struct
+//
+// NOTE: this can be the same as the current struct being validated
+// if not is a nested struct.
+//
+// this is only called when within Struct and Field Level validation and
+// should not be relied upon for an acurate value otherwise.
+func (v *validate) Top() reflect.Value {
+ return v.top
+}
+
+// Parent returns the current structs parent
+//
+// NOTE: this can be the same as the current struct being validated
+// if not is a nested struct.
+//
+// this is only called when within Struct and Field Level validation and
+// should not be relied upon for an acurate value otherwise.
+func (v *validate) Parent() reflect.Value {
+ return v.slflParent
+}
+
+// Current returns the current struct.
+func (v *validate) Current() reflect.Value {
+ return v.slCurrent
+}
+
+// Validator returns the main validation object, in case one want to call validations internally.
+func (v *validate) Validator() *Validate {
+ return v.v
+}
+
+// ExtractType gets the actual underlying type of field value.
+func (v *validate) ExtractType(field reflect.Value) (reflect.Value, reflect.Kind, bool) {
+ return v.extractTypeInternal(field, false)
+}
+
+// ReportError reports an error just by passing the field and tag information
+func (v *validate) ReportError(field interface{}, fieldName, structFieldName, tag, param string) {
+
+ fv, kind, _ := v.extractTypeInternal(reflect.ValueOf(field), false)
+
+ if len(structFieldName) == 0 {
+ structFieldName = fieldName
+ }
+
+ v.str1 = string(append(v.ns, fieldName...))
+
+ if v.v.hasTagNameFunc || fieldName != structFieldName {
+ v.str2 = string(append(v.actualNs, structFieldName...))
+ } else {
+ v.str2 = v.str1
+ }
+
+ if kind == reflect.Invalid {
+
+ v.errs = append(v.errs,
+ &fieldError{
+ v: v.v,
+ tag: tag,
+ actualTag: tag,
+ ns: v.str1,
+ structNs: v.str2,
+ fieldLen: uint8(len(fieldName)),
+ structfieldLen: uint8(len(structFieldName)),
+ param: param,
+ kind: kind,
+ },
+ )
+ return
+ }
+
+ v.errs = append(v.errs,
+ &fieldError{
+ v: v.v,
+ tag: tag,
+ actualTag: tag,
+ ns: v.str1,
+ structNs: v.str2,
+ fieldLen: uint8(len(fieldName)),
+ structfieldLen: uint8(len(structFieldName)),
+ value: fv.Interface(),
+ param: param,
+ kind: kind,
+ typ: fv.Type(),
+ },
+ )
+}
+
+// ReportValidationErrors reports ValidationErrors obtained from running validations within the Struct Level validation.
+//
+// NOTE: this function prepends the current namespace to the relative ones.
+func (v *validate) ReportValidationErrors(relativeNamespace, relativeStructNamespace string, errs ValidationErrors) {
+
+ var err *fieldError
+
+ for i := 0; i < len(errs); i++ {
+
+ err = errs[i].(*fieldError)
+ err.ns = string(append(append(v.ns, relativeNamespace...), err.ns...))
+ err.structNs = string(append(append(v.actualNs, relativeStructNamespace...), err.structNs...))
+
+ v.errs = append(v.errs, err)
+ }
+}
diff --git a/baas-kubeengine/vendor/github.com/go-playground/validator/v10/translations.go b/baas-kubeengine/vendor/github.com/go-playground/validator/v10/translations.go
new file mode 100644
index 00000000..4d9d75c1
--- /dev/null
+++ b/baas-kubeengine/vendor/github.com/go-playground/validator/v10/translations.go
@@ -0,0 +1,11 @@
+package validator
+
+import ut "github.com/go-playground/universal-translator"
+
+// TranslationFunc is the function type used to register or override
+// custom translations
+type TranslationFunc func(ut ut.Translator, fe FieldError) string
+
+// RegisterTranslationsFunc allows for registering of translations
+// for a 'ut.Translator' for use within the 'TranslationFunc'
+type RegisterTranslationsFunc func(ut ut.Translator) error
diff --git a/baas-kubeengine/vendor/gopkg.in/go-playground/validator.v8/util.go b/baas-kubeengine/vendor/github.com/go-playground/validator/v10/util.go
similarity index 52%
rename from baas-kubeengine/vendor/gopkg.in/go-playground/validator.v8/util.go
rename to baas-kubeengine/vendor/github.com/go-playground/validator/v10/util.go
index e8115790..56420f43 100644
--- a/baas-kubeengine/vendor/gopkg.in/go-playground/validator.v8/util.go
+++ b/baas-kubeengine/vendor/github.com/go-playground/validator/v10/util.go
@@ -4,44 +4,15 @@ import (
"reflect"
"strconv"
"strings"
+ "time"
)
-const (
- blank = ""
- namespaceSeparator = "."
- leftBracket = "["
- rightBracket = "]"
- restrictedTagChars = ".[],|=+()`~!@#$%^&*\\\"/?<>{}"
- restrictedAliasErr = "Alias '%s' either contains restricted characters or is the same as a restricted tag needed for normal operation"
- restrictedTagErr = "Tag '%s' either contains restricted characters or is the same as a restricted tag needed for normal operation"
-)
-
-var (
- restrictedTags = map[string]struct{}{
- diveTag: {},
- existsTag: {},
- structOnlyTag: {},
- omitempty: {},
- skipValidationTag: {},
- utf8HexComma: {},
- utf8Pipe: {},
- noStructLevelTag: {},
- }
-)
-
-// ExtractType gets the actual underlying type of field value.
+// extractTypeInternal gets the actual underlying type of field value.
// It will dive into pointers, customTypes and return you the
// underlying value and it's kind.
-// it is exposed for use within you Custom Functions
-func (v *Validate) ExtractType(current reflect.Value) (reflect.Value, reflect.Kind) {
-
- val, k, _ := v.extractTypeInternal(current, false)
- return val, k
-}
-
-// only exists to not break backward compatibility, needed to return the third param for a bug fix internally
-func (v *Validate) extractTypeInternal(current reflect.Value, nullable bool) (reflect.Value, reflect.Kind, bool) {
+func (v *validate) extractTypeInternal(current reflect.Value, nullable bool) (reflect.Value, reflect.Kind, bool) {
+BEGIN:
switch current.Kind() {
case reflect.Ptr:
@@ -51,7 +22,8 @@ func (v *Validate) extractTypeInternal(current reflect.Value, nullable bool) (re
return current, reflect.Ptr, nullable
}
- return v.extractTypeInternal(current.Elem(), nullable)
+ current = current.Elem()
+ goto BEGIN
case reflect.Interface:
@@ -61,17 +33,19 @@ func (v *Validate) extractTypeInternal(current reflect.Value, nullable bool) (re
return current, reflect.Interface, nullable
}
- return v.extractTypeInternal(current.Elem(), nullable)
+ current = current.Elem()
+ goto BEGIN
case reflect.Invalid:
return current, reflect.Invalid, nullable
default:
- if v.hasCustomFuncs {
+ if v.v.hasCustomFuncs {
- if fn, ok := v.customTypeFuncs[current.Type()]; ok {
- return v.extractTypeInternal(reflect.ValueOf(fn(current)), nullable)
+ if fn, ok := v.v.customFuncs[current.Type()]; ok {
+ current = reflect.ValueOf(fn(current))
+ goto BEGIN
}
}
@@ -79,35 +53,36 @@ func (v *Validate) extractTypeInternal(current reflect.Value, nullable bool) (re
}
}
-// GetStructFieldOK traverses a struct to retrieve a specific field denoted by the provided namespace and
+// getStructFieldOKInternal traverses a struct to retrieve a specific field denoted by the provided namespace and
// returns the field, field kind and whether is was successful in retrieving the field at all.
+//
// NOTE: when not successful ok will be false, this can happen when a nested struct is nil and so the field
// could not be retrieved because it didn't exist.
-func (v *Validate) GetStructFieldOK(current reflect.Value, namespace string) (reflect.Value, reflect.Kind, bool) {
-
- current, kind := v.ExtractType(current)
+func (v *validate) getStructFieldOKInternal(val reflect.Value, namespace string) (current reflect.Value, kind reflect.Kind, nullable bool, found bool) {
+BEGIN:
+ current, kind, nullable = v.ExtractType(val)
if kind == reflect.Invalid {
- return current, kind, false
+ return
}
- if namespace == blank {
- return current, kind, true
+ if namespace == "" {
+ found = true
+ return
}
switch kind {
case reflect.Ptr, reflect.Interface:
-
- return current, kind, false
+ return
case reflect.Struct:
typ := current.Type()
fld := namespace
- ns := namespace
+ var ns string
- if typ != timeType && typ != timePtrType {
+ if typ != timeType {
idx := strings.Index(namespace, namespaceSeparator)
@@ -115,7 +90,7 @@ func (v *Validate) GetStructFieldOK(current reflect.Value, namespace string) (re
fld = namespace[:idx]
ns = namespace[idx+1:]
} else {
- ns = blank
+ ns = ""
}
bracketIdx := strings.Index(fld, leftBracket)
@@ -125,9 +100,9 @@ func (v *Validate) GetStructFieldOK(current reflect.Value, namespace string) (re
ns = namespace[bracketIdx:]
}
- current = current.FieldByName(fld)
-
- return v.GetStructFieldOK(current, ns)
+ val = current.FieldByName(fld)
+ namespace = ns
+ goto BEGIN
}
case reflect.Array, reflect.Slice:
@@ -137,7 +112,7 @@ func (v *Validate) GetStructFieldOK(current reflect.Value, namespace string) (re
arrIdx, _ := strconv.Atoi(namespace[idx+1 : idx2])
if arrIdx >= current.Len() {
- return current, kind, false
+ return
}
startIdx := idx2 + 1
@@ -148,7 +123,9 @@ func (v *Validate) GetStructFieldOK(current reflect.Value, namespace string) (re
}
}
- return v.GetStructFieldOK(current.Index(arrIdx), namespace[startIdx:])
+ val = current.Index(arrIdx)
+ namespace = namespace[startIdx:]
+ goto BEGIN
case reflect.Map:
idx := strings.Index(namespace, leftBracket) + 1
@@ -167,48 +144,76 @@ func (v *Validate) GetStructFieldOK(current reflect.Value, namespace string) (re
switch current.Type().Key().Kind() {
case reflect.Int:
i, _ := strconv.Atoi(key)
- return v.GetStructFieldOK(current.MapIndex(reflect.ValueOf(i)), namespace[endIdx+1:])
+ val = current.MapIndex(reflect.ValueOf(i))
+ namespace = namespace[endIdx+1:]
+
case reflect.Int8:
i, _ := strconv.ParseInt(key, 10, 8)
- return v.GetStructFieldOK(current.MapIndex(reflect.ValueOf(int8(i))), namespace[endIdx+1:])
+ val = current.MapIndex(reflect.ValueOf(int8(i)))
+ namespace = namespace[endIdx+1:]
+
case reflect.Int16:
i, _ := strconv.ParseInt(key, 10, 16)
- return v.GetStructFieldOK(current.MapIndex(reflect.ValueOf(int16(i))), namespace[endIdx+1:])
+ val = current.MapIndex(reflect.ValueOf(int16(i)))
+ namespace = namespace[endIdx+1:]
+
case reflect.Int32:
i, _ := strconv.ParseInt(key, 10, 32)
- return v.GetStructFieldOK(current.MapIndex(reflect.ValueOf(int32(i))), namespace[endIdx+1:])
+ val = current.MapIndex(reflect.ValueOf(int32(i)))
+ namespace = namespace[endIdx+1:]
+
case reflect.Int64:
i, _ := strconv.ParseInt(key, 10, 64)
- return v.GetStructFieldOK(current.MapIndex(reflect.ValueOf(i)), namespace[endIdx+1:])
+ val = current.MapIndex(reflect.ValueOf(i))
+ namespace = namespace[endIdx+1:]
+
case reflect.Uint:
i, _ := strconv.ParseUint(key, 10, 0)
- return v.GetStructFieldOK(current.MapIndex(reflect.ValueOf(uint(i))), namespace[endIdx+1:])
+ val = current.MapIndex(reflect.ValueOf(uint(i)))
+ namespace = namespace[endIdx+1:]
+
case reflect.Uint8:
i, _ := strconv.ParseUint(key, 10, 8)
- return v.GetStructFieldOK(current.MapIndex(reflect.ValueOf(uint8(i))), namespace[endIdx+1:])
+ val = current.MapIndex(reflect.ValueOf(uint8(i)))
+ namespace = namespace[endIdx+1:]
+
case reflect.Uint16:
i, _ := strconv.ParseUint(key, 10, 16)
- return v.GetStructFieldOK(current.MapIndex(reflect.ValueOf(uint16(i))), namespace[endIdx+1:])
+ val = current.MapIndex(reflect.ValueOf(uint16(i)))
+ namespace = namespace[endIdx+1:]
+
case reflect.Uint32:
i, _ := strconv.ParseUint(key, 10, 32)
- return v.GetStructFieldOK(current.MapIndex(reflect.ValueOf(uint32(i))), namespace[endIdx+1:])
+ val = current.MapIndex(reflect.ValueOf(uint32(i)))
+ namespace = namespace[endIdx+1:]
+
case reflect.Uint64:
i, _ := strconv.ParseUint(key, 10, 64)
- return v.GetStructFieldOK(current.MapIndex(reflect.ValueOf(i)), namespace[endIdx+1:])
+ val = current.MapIndex(reflect.ValueOf(i))
+ namespace = namespace[endIdx+1:]
+
case reflect.Float32:
f, _ := strconv.ParseFloat(key, 32)
- return v.GetStructFieldOK(current.MapIndex(reflect.ValueOf(float32(f))), namespace[endIdx+1:])
+ val = current.MapIndex(reflect.ValueOf(float32(f)))
+ namespace = namespace[endIdx+1:]
+
case reflect.Float64:
f, _ := strconv.ParseFloat(key, 64)
- return v.GetStructFieldOK(current.MapIndex(reflect.ValueOf(f)), namespace[endIdx+1:])
+ val = current.MapIndex(reflect.ValueOf(f))
+ namespace = namespace[endIdx+1:]
+
case reflect.Bool:
b, _ := strconv.ParseBool(key)
- return v.GetStructFieldOK(current.MapIndex(reflect.ValueOf(b)), namespace[endIdx+1:])
+ val = current.MapIndex(reflect.ValueOf(b))
+ namespace = namespace[endIdx+1:]
// reflect.Type = string
default:
- return v.GetStructFieldOK(current.MapIndex(reflect.ValueOf(key)), namespace[endIdx+1:])
+ val = current.MapIndex(reflect.ValueOf(key))
+ namespace = namespace[endIdx+1:]
}
+
+ goto BEGIN
}
// if got here there was more namespace, cannot go any deeper
@@ -218,13 +223,34 @@ func (v *Validate) GetStructFieldOK(current reflect.Value, namespace string) (re
// asInt returns the parameter as a int64
// or panics if it can't convert
func asInt(param string) int64 {
-
i, err := strconv.ParseInt(param, 0, 64)
panicIf(err)
return i
}
+// asIntFromTimeDuration parses param as time.Duration and returns it as int64
+// or panics on error.
+func asIntFromTimeDuration(param string) int64 {
+ d, err := time.ParseDuration(param)
+ if err != nil {
+ // attempt parsing as an an integer assuming nanosecond precision
+ return asInt(param)
+ }
+ return int64(d)
+}
+
+// asIntFromType calls the proper function to parse param as int64,
+// given a field's Type t.
+func asIntFromType(t reflect.Type, param string) int64 {
+ switch t {
+ case timeDurationType:
+ return asIntFromTimeDuration(param)
+ default:
+ return asInt(param)
+ }
+}
+
// asUint returns the parameter as a uint64
// or panics if it can't convert
func asUint(param string) uint64 {
@@ -245,6 +271,16 @@ func asFloat(param string) float64 {
return i
}
+// asBool returns the parameter as a bool
+// or panics if it can't convert
+func asBool(param string) bool {
+
+ i, err := strconv.ParseBool(param)
+ panicIf(err)
+
+ return i
+}
+
func panicIf(err error) {
if err != nil {
panic(err.Error())
diff --git a/baas-kubeengine/vendor/github.com/go-playground/validator/v10/validator.go b/baas-kubeengine/vendor/github.com/go-playground/validator/v10/validator.go
new file mode 100644
index 00000000..f097f394
--- /dev/null
+++ b/baas-kubeengine/vendor/github.com/go-playground/validator/v10/validator.go
@@ -0,0 +1,477 @@
+package validator
+
+import (
+ "context"
+ "fmt"
+ "reflect"
+ "strconv"
+)
+
+// per validate construct
+type validate struct {
+ v *Validate
+ top reflect.Value
+ ns []byte
+ actualNs []byte
+ errs ValidationErrors
+ includeExclude map[string]struct{} // reset only if StructPartial or StructExcept are called, no need otherwise
+ ffn FilterFunc
+ slflParent reflect.Value // StructLevel & FieldLevel
+ slCurrent reflect.Value // StructLevel & FieldLevel
+ flField reflect.Value // StructLevel & FieldLevel
+ cf *cField // StructLevel & FieldLevel
+ ct *cTag // StructLevel & FieldLevel
+ misc []byte // misc reusable
+ str1 string // misc reusable
+ str2 string // misc reusable
+ fldIsPointer bool // StructLevel & FieldLevel
+ isPartial bool
+ hasExcludes bool
+}
+
+// parent and current will be the same the first run of validateStruct
+func (v *validate) validateStruct(ctx context.Context, parent reflect.Value, current reflect.Value, typ reflect.Type, ns []byte, structNs []byte, ct *cTag) {
+
+ cs, ok := v.v.structCache.Get(typ)
+ if !ok {
+ cs = v.v.extractStructCache(current, typ.Name())
+ }
+
+ if len(ns) == 0 && len(cs.name) != 0 {
+
+ ns = append(ns, cs.name...)
+ ns = append(ns, '.')
+
+ structNs = append(structNs, cs.name...)
+ structNs = append(structNs, '.')
+ }
+
+ // ct is nil on top level struct, and structs as fields that have no tag info
+ // so if nil or if not nil and the structonly tag isn't present
+ if ct == nil || ct.typeof != typeStructOnly {
+
+ var f *cField
+
+ for i := 0; i < len(cs.fields); i++ {
+
+ f = cs.fields[i]
+
+ if v.isPartial {
+
+ if v.ffn != nil {
+ // used with StructFiltered
+ if v.ffn(append(structNs, f.name...)) {
+ continue
+ }
+
+ } else {
+ // used with StructPartial & StructExcept
+ _, ok = v.includeExclude[string(append(structNs, f.name...))]
+
+ if (ok && v.hasExcludes) || (!ok && !v.hasExcludes) {
+ continue
+ }
+ }
+ }
+
+ v.traverseField(ctx, parent, current.Field(f.idx), ns, structNs, f, f.cTags)
+ }
+ }
+
+ // check if any struct level validations, after all field validations already checked.
+ // first iteration will have no info about nostructlevel tag, and is checked prior to
+ // calling the next iteration of validateStruct called from traverseField.
+ if cs.fn != nil {
+
+ v.slflParent = parent
+ v.slCurrent = current
+ v.ns = ns
+ v.actualNs = structNs
+
+ cs.fn(ctx, v)
+ }
+}
+
+// traverseField validates any field, be it a struct or single field, ensures it's validity and passes it along to be validated via it's tag options
+func (v *validate) traverseField(ctx context.Context, parent reflect.Value, current reflect.Value, ns []byte, structNs []byte, cf *cField, ct *cTag) {
+ var typ reflect.Type
+ var kind reflect.Kind
+
+ current, kind, v.fldIsPointer = v.extractTypeInternal(current, false)
+
+ switch kind {
+ case reflect.Ptr, reflect.Interface, reflect.Invalid:
+
+ if ct == nil {
+ return
+ }
+
+ if ct.typeof == typeOmitEmpty || ct.typeof == typeIsDefault {
+ return
+ }
+
+ if ct.hasTag {
+ if kind == reflect.Invalid {
+ v.str1 = string(append(ns, cf.altName...))
+ if v.v.hasTagNameFunc {
+ v.str2 = string(append(structNs, cf.name...))
+ } else {
+ v.str2 = v.str1
+ }
+ v.errs = append(v.errs,
+ &fieldError{
+ v: v.v,
+ tag: ct.aliasTag,
+ actualTag: ct.tag,
+ ns: v.str1,
+ structNs: v.str2,
+ fieldLen: uint8(len(cf.altName)),
+ structfieldLen: uint8(len(cf.name)),
+ param: ct.param,
+ kind: kind,
+ },
+ )
+ return
+ }
+
+ v.str1 = string(append(ns, cf.altName...))
+ if v.v.hasTagNameFunc {
+ v.str2 = string(append(structNs, cf.name...))
+ } else {
+ v.str2 = v.str1
+ }
+ if !ct.runValidationWhenNil {
+ v.errs = append(v.errs,
+ &fieldError{
+ v: v.v,
+ tag: ct.aliasTag,
+ actualTag: ct.tag,
+ ns: v.str1,
+ structNs: v.str2,
+ fieldLen: uint8(len(cf.altName)),
+ structfieldLen: uint8(len(cf.name)),
+ value: current.Interface(),
+ param: ct.param,
+ kind: kind,
+ typ: current.Type(),
+ },
+ )
+ return
+ }
+ }
+
+ case reflect.Struct:
+
+ typ = current.Type()
+
+ if typ != timeType {
+
+ if ct != nil {
+
+ if ct.typeof == typeStructOnly {
+ goto CONTINUE
+ } else if ct.typeof == typeIsDefault {
+ // set Field Level fields
+ v.slflParent = parent
+ v.flField = current
+ v.cf = cf
+ v.ct = ct
+
+ if !ct.fn(ctx, v) {
+ v.str1 = string(append(ns, cf.altName...))
+
+ if v.v.hasTagNameFunc {
+ v.str2 = string(append(structNs, cf.name...))
+ } else {
+ v.str2 = v.str1
+ }
+
+ v.errs = append(v.errs,
+ &fieldError{
+ v: v.v,
+ tag: ct.aliasTag,
+ actualTag: ct.tag,
+ ns: v.str1,
+ structNs: v.str2,
+ fieldLen: uint8(len(cf.altName)),
+ structfieldLen: uint8(len(cf.name)),
+ value: current.Interface(),
+ param: ct.param,
+ kind: kind,
+ typ: typ,
+ },
+ )
+ return
+ }
+ }
+
+ ct = ct.next
+ }
+
+ if ct != nil && ct.typeof == typeNoStructLevel {
+ return
+ }
+
+ CONTINUE:
+ // if len == 0 then validating using 'Var' or 'VarWithValue'
+ // Var - doesn't make much sense to do it that way, should call 'Struct', but no harm...
+ // VarWithField - this allows for validating against each field within the struct against a specific value
+ // pretty handy in certain situations
+ if len(cf.name) > 0 {
+ ns = append(append(ns, cf.altName...), '.')
+ structNs = append(append(structNs, cf.name...), '.')
+ }
+
+ v.validateStruct(ctx, current, current, typ, ns, structNs, ct)
+ return
+ }
+ }
+
+ if !ct.hasTag {
+ return
+ }
+
+ typ = current.Type()
+
+OUTER:
+ for {
+ if ct == nil {
+ return
+ }
+
+ switch ct.typeof {
+
+ case typeOmitEmpty:
+
+ // set Field Level fields
+ v.slflParent = parent
+ v.flField = current
+ v.cf = cf
+ v.ct = ct
+
+ if !hasValue(v) {
+ return
+ }
+
+ ct = ct.next
+ continue
+
+ case typeEndKeys:
+ return
+
+ case typeDive:
+
+ ct = ct.next
+
+ // traverse slice or map here
+ // or panic ;)
+ switch kind {
+ case reflect.Slice, reflect.Array:
+
+ var i64 int64
+ reusableCF := &cField{}
+
+ for i := 0; i < current.Len(); i++ {
+
+ i64 = int64(i)
+
+ v.misc = append(v.misc[0:0], cf.name...)
+ v.misc = append(v.misc, '[')
+ v.misc = strconv.AppendInt(v.misc, i64, 10)
+ v.misc = append(v.misc, ']')
+
+ reusableCF.name = string(v.misc)
+
+ if cf.namesEqual {
+ reusableCF.altName = reusableCF.name
+ } else {
+
+ v.misc = append(v.misc[0:0], cf.altName...)
+ v.misc = append(v.misc, '[')
+ v.misc = strconv.AppendInt(v.misc, i64, 10)
+ v.misc = append(v.misc, ']')
+
+ reusableCF.altName = string(v.misc)
+ }
+ v.traverseField(ctx, parent, current.Index(i), ns, structNs, reusableCF, ct)
+ }
+
+ case reflect.Map:
+
+ var pv string
+ reusableCF := &cField{}
+
+ for _, key := range current.MapKeys() {
+
+ pv = fmt.Sprintf("%v", key.Interface())
+
+ v.misc = append(v.misc[0:0], cf.name...)
+ v.misc = append(v.misc, '[')
+ v.misc = append(v.misc, pv...)
+ v.misc = append(v.misc, ']')
+
+ reusableCF.name = string(v.misc)
+
+ if cf.namesEqual {
+ reusableCF.altName = reusableCF.name
+ } else {
+ v.misc = append(v.misc[0:0], cf.altName...)
+ v.misc = append(v.misc, '[')
+ v.misc = append(v.misc, pv...)
+ v.misc = append(v.misc, ']')
+
+ reusableCF.altName = string(v.misc)
+ }
+
+ if ct != nil && ct.typeof == typeKeys && ct.keys != nil {
+ v.traverseField(ctx, parent, key, ns, structNs, reusableCF, ct.keys)
+ // can be nil when just keys being validated
+ if ct.next != nil {
+ v.traverseField(ctx, parent, current.MapIndex(key), ns, structNs, reusableCF, ct.next)
+ }
+ } else {
+ v.traverseField(ctx, parent, current.MapIndex(key), ns, structNs, reusableCF, ct)
+ }
+ }
+
+ default:
+ // throw error, if not a slice or map then should not have gotten here
+ // bad dive tag
+ panic("dive error! can't dive on a non slice or map")
+ }
+
+ return
+
+ case typeOr:
+
+ v.misc = v.misc[0:0]
+
+ for {
+
+ // set Field Level fields
+ v.slflParent = parent
+ v.flField = current
+ v.cf = cf
+ v.ct = ct
+
+ if ct.fn(ctx, v) {
+
+ // drain rest of the 'or' values, then continue or leave
+ for {
+
+ ct = ct.next
+
+ if ct == nil {
+ return
+ }
+
+ if ct.typeof != typeOr {
+ continue OUTER
+ }
+ }
+ }
+
+ v.misc = append(v.misc, '|')
+ v.misc = append(v.misc, ct.tag...)
+
+ if ct.hasParam {
+ v.misc = append(v.misc, '=')
+ v.misc = append(v.misc, ct.param...)
+ }
+
+ if ct.isBlockEnd || ct.next == nil {
+ // if we get here, no valid 'or' value and no more tags
+ v.str1 = string(append(ns, cf.altName...))
+
+ if v.v.hasTagNameFunc {
+ v.str2 = string(append(structNs, cf.name...))
+ } else {
+ v.str2 = v.str1
+ }
+
+ if ct.hasAlias {
+
+ v.errs = append(v.errs,
+ &fieldError{
+ v: v.v,
+ tag: ct.aliasTag,
+ actualTag: ct.actualAliasTag,
+ ns: v.str1,
+ structNs: v.str2,
+ fieldLen: uint8(len(cf.altName)),
+ structfieldLen: uint8(len(cf.name)),
+ value: current.Interface(),
+ param: ct.param,
+ kind: kind,
+ typ: typ,
+ },
+ )
+
+ } else {
+
+ tVal := string(v.misc)[1:]
+
+ v.errs = append(v.errs,
+ &fieldError{
+ v: v.v,
+ tag: tVal,
+ actualTag: tVal,
+ ns: v.str1,
+ structNs: v.str2,
+ fieldLen: uint8(len(cf.altName)),
+ structfieldLen: uint8(len(cf.name)),
+ value: current.Interface(),
+ param: ct.param,
+ kind: kind,
+ typ: typ,
+ },
+ )
+ }
+
+ return
+ }
+
+ ct = ct.next
+ }
+
+ default:
+
+ // set Field Level fields
+ v.slflParent = parent
+ v.flField = current
+ v.cf = cf
+ v.ct = ct
+
+ if !ct.fn(ctx, v) {
+
+ v.str1 = string(append(ns, cf.altName...))
+
+ if v.v.hasTagNameFunc {
+ v.str2 = string(append(structNs, cf.name...))
+ } else {
+ v.str2 = v.str1
+ }
+
+ v.errs = append(v.errs,
+ &fieldError{
+ v: v.v,
+ tag: ct.aliasTag,
+ actualTag: ct.tag,
+ ns: v.str1,
+ structNs: v.str2,
+ fieldLen: uint8(len(cf.altName)),
+ structfieldLen: uint8(len(cf.name)),
+ value: current.Interface(),
+ param: ct.param,
+ kind: kind,
+ typ: typ,
+ },
+ )
+
+ return
+ }
+ ct = ct.next
+ }
+ }
+
+}
diff --git a/baas-kubeengine/vendor/github.com/go-playground/validator/v10/validator_instance.go b/baas-kubeengine/vendor/github.com/go-playground/validator/v10/validator_instance.go
new file mode 100644
index 00000000..fe6a4877
--- /dev/null
+++ b/baas-kubeengine/vendor/github.com/go-playground/validator/v10/validator_instance.go
@@ -0,0 +1,619 @@
+package validator
+
+import (
+ "context"
+ "errors"
+ "fmt"
+ "reflect"
+ "strings"
+ "sync"
+ "time"
+
+ ut "github.com/go-playground/universal-translator"
+)
+
+const (
+ defaultTagName = "validate"
+ utf8HexComma = "0x2C"
+ utf8Pipe = "0x7C"
+ tagSeparator = ","
+ orSeparator = "|"
+ tagKeySeparator = "="
+ structOnlyTag = "structonly"
+ noStructLevelTag = "nostructlevel"
+ omitempty = "omitempty"
+ isdefault = "isdefault"
+ requiredWithoutAllTag = "required_without_all"
+ requiredWithoutTag = "required_without"
+ requiredWithTag = "required_with"
+ requiredWithAllTag = "required_with_all"
+ requiredIfTag = "required_if"
+ requiredUnlessTag = "required_unless"
+ skipValidationTag = "-"
+ diveTag = "dive"
+ keysTag = "keys"
+ endKeysTag = "endkeys"
+ requiredTag = "required"
+ namespaceSeparator = "."
+ leftBracket = "["
+ rightBracket = "]"
+ restrictedTagChars = ".[],|=+()`~!@#$%^&*\\\"/?<>{}"
+ restrictedAliasErr = "Alias '%s' either contains restricted characters or is the same as a restricted tag needed for normal operation"
+ restrictedTagErr = "Tag '%s' either contains restricted characters or is the same as a restricted tag needed for normal operation"
+)
+
+var (
+ timeDurationType = reflect.TypeOf(time.Duration(0))
+ timeType = reflect.TypeOf(time.Time{})
+
+ defaultCField = &cField{namesEqual: true}
+)
+
+// FilterFunc is the type used to filter fields using
+// StructFiltered(...) function.
+// returning true results in the field being filtered/skiped from
+// validation
+type FilterFunc func(ns []byte) bool
+
+// CustomTypeFunc allows for overriding or adding custom field type handler functions
+// field = field value of the type to return a value to be validated
+// example Valuer from sql drive see https://golang.org/src/database/sql/driver/types.go?s=1210:1293#L29
+type CustomTypeFunc func(field reflect.Value) interface{}
+
+// TagNameFunc allows for adding of a custom tag name parser
+type TagNameFunc func(field reflect.StructField) string
+
+type internalValidationFuncWrapper struct {
+ fn FuncCtx
+ runValidatinOnNil bool
+}
+
+// Validate contains the validator settings and cache
+type Validate struct {
+ tagName string
+ pool *sync.Pool
+ hasCustomFuncs bool
+ hasTagNameFunc bool
+ tagNameFunc TagNameFunc
+ structLevelFuncs map[reflect.Type]StructLevelFuncCtx
+ customFuncs map[reflect.Type]CustomTypeFunc
+ aliases map[string]string
+ validations map[string]internalValidationFuncWrapper
+ transTagFunc map[ut.Translator]map[string]TranslationFunc // map[]map[]TranslationFunc
+ tagCache *tagCache
+ structCache *structCache
+}
+
+// New returns a new instance of 'validate' with sane defaults.
+func New() *Validate {
+
+ tc := new(tagCache)
+ tc.m.Store(make(map[string]*cTag))
+
+ sc := new(structCache)
+ sc.m.Store(make(map[reflect.Type]*cStruct))
+
+ v := &Validate{
+ tagName: defaultTagName,
+ aliases: make(map[string]string, len(bakedInAliases)),
+ validations: make(map[string]internalValidationFuncWrapper, len(bakedInValidators)),
+ tagCache: tc,
+ structCache: sc,
+ }
+
+ // must copy alias validators for separate validations to be used in each validator instance
+ for k, val := range bakedInAliases {
+ v.RegisterAlias(k, val)
+ }
+
+ // must copy validators for separate validations to be used in each instance
+ for k, val := range bakedInValidators {
+
+ switch k {
+ // these require that even if the value is nil that the validation should run, omitempty still overrides this behaviour
+ case requiredIfTag, requiredUnlessTag, requiredWithTag, requiredWithAllTag, requiredWithoutTag, requiredWithoutAllTag:
+ _ = v.registerValidation(k, wrapFunc(val), true, true)
+ default:
+ // no need to error check here, baked in will always be valid
+ _ = v.registerValidation(k, wrapFunc(val), true, false)
+ }
+ }
+
+ v.pool = &sync.Pool{
+ New: func() interface{} {
+ return &validate{
+ v: v,
+ ns: make([]byte, 0, 64),
+ actualNs: make([]byte, 0, 64),
+ misc: make([]byte, 32),
+ }
+ },
+ }
+
+ return v
+}
+
+// SetTagName allows for changing of the default tag name of 'validate'
+func (v *Validate) SetTagName(name string) {
+ v.tagName = name
+}
+
+// RegisterTagNameFunc registers a function to get alternate names for StructFields.
+//
+// eg. to use the names which have been specified for JSON representations of structs, rather than normal Go field names:
+//
+// validate.RegisterTagNameFunc(func(fld reflect.StructField) string {
+// name := strings.SplitN(fld.Tag.Get("json"), ",", 2)[0]
+// if name == "-" {
+// return ""
+// }
+// return name
+// })
+func (v *Validate) RegisterTagNameFunc(fn TagNameFunc) {
+ v.tagNameFunc = fn
+ v.hasTagNameFunc = true
+}
+
+// RegisterValidation adds a validation with the given tag
+//
+// NOTES:
+// - if the key already exists, the previous validation function will be replaced.
+// - this method is not thread-safe it is intended that these all be registered prior to any validation
+func (v *Validate) RegisterValidation(tag string, fn Func, callValidationEvenIfNull ...bool) error {
+ return v.RegisterValidationCtx(tag, wrapFunc(fn), callValidationEvenIfNull...)
+}
+
+// RegisterValidationCtx does the same as RegisterValidation on accepts a FuncCtx validation
+// allowing context.Context validation support.
+func (v *Validate) RegisterValidationCtx(tag string, fn FuncCtx, callValidationEvenIfNull ...bool) error {
+ var nilCheckable bool
+ if len(callValidationEvenIfNull) > 0 {
+ nilCheckable = callValidationEvenIfNull[0]
+ }
+ return v.registerValidation(tag, fn, false, nilCheckable)
+}
+
+func (v *Validate) registerValidation(tag string, fn FuncCtx, bakedIn bool, nilCheckable bool) error {
+ if len(tag) == 0 {
+ return errors.New("Function Key cannot be empty")
+ }
+
+ if fn == nil {
+ return errors.New("Function cannot be empty")
+ }
+
+ _, ok := restrictedTags[tag]
+ if !bakedIn && (ok || strings.ContainsAny(tag, restrictedTagChars)) {
+ panic(fmt.Sprintf(restrictedTagErr, tag))
+ }
+ v.validations[tag] = internalValidationFuncWrapper{fn: fn, runValidatinOnNil: nilCheckable}
+ return nil
+}
+
+// RegisterAlias registers a mapping of a single validation tag that
+// defines a common or complex set of validation(s) to simplify adding validation
+// to structs.
+//
+// NOTE: this function is not thread-safe it is intended that these all be registered prior to any validation
+func (v *Validate) RegisterAlias(alias, tags string) {
+
+ _, ok := restrictedTags[alias]
+
+ if ok || strings.ContainsAny(alias, restrictedTagChars) {
+ panic(fmt.Sprintf(restrictedAliasErr, alias))
+ }
+
+ v.aliases[alias] = tags
+}
+
+// RegisterStructValidation registers a StructLevelFunc against a number of types.
+//
+// NOTE:
+// - this method is not thread-safe it is intended that these all be registered prior to any validation
+func (v *Validate) RegisterStructValidation(fn StructLevelFunc, types ...interface{}) {
+ v.RegisterStructValidationCtx(wrapStructLevelFunc(fn), types...)
+}
+
+// RegisterStructValidationCtx registers a StructLevelFuncCtx against a number of types and allows passing
+// of contextual validation information via context.Context.
+//
+// NOTE:
+// - this method is not thread-safe it is intended that these all be registered prior to any validation
+func (v *Validate) RegisterStructValidationCtx(fn StructLevelFuncCtx, types ...interface{}) {
+
+ if v.structLevelFuncs == nil {
+ v.structLevelFuncs = make(map[reflect.Type]StructLevelFuncCtx)
+ }
+
+ for _, t := range types {
+ tv := reflect.ValueOf(t)
+ if tv.Kind() == reflect.Ptr {
+ t = reflect.Indirect(tv).Interface()
+ }
+
+ v.structLevelFuncs[reflect.TypeOf(t)] = fn
+ }
+}
+
+// RegisterCustomTypeFunc registers a CustomTypeFunc against a number of types
+//
+// NOTE: this method is not thread-safe it is intended that these all be registered prior to any validation
+func (v *Validate) RegisterCustomTypeFunc(fn CustomTypeFunc, types ...interface{}) {
+
+ if v.customFuncs == nil {
+ v.customFuncs = make(map[reflect.Type]CustomTypeFunc)
+ }
+
+ for _, t := range types {
+ v.customFuncs[reflect.TypeOf(t)] = fn
+ }
+
+ v.hasCustomFuncs = true
+}
+
+// RegisterTranslation registers translations against the provided tag.
+func (v *Validate) RegisterTranslation(tag string, trans ut.Translator, registerFn RegisterTranslationsFunc, translationFn TranslationFunc) (err error) {
+
+ if v.transTagFunc == nil {
+ v.transTagFunc = make(map[ut.Translator]map[string]TranslationFunc)
+ }
+
+ if err = registerFn(trans); err != nil {
+ return
+ }
+
+ m, ok := v.transTagFunc[trans]
+ if !ok {
+ m = make(map[string]TranslationFunc)
+ v.transTagFunc[trans] = m
+ }
+
+ m[tag] = translationFn
+
+ return
+}
+
+// Struct validates a structs exposed fields, and automatically validates nested structs, unless otherwise specified.
+//
+// It returns InvalidValidationError for bad values passed in and nil or ValidationErrors as error otherwise.
+// You will need to assert the error if it's not nil eg. err.(validator.ValidationErrors) to access the array of errors.
+func (v *Validate) Struct(s interface{}) error {
+ return v.StructCtx(context.Background(), s)
+}
+
+// StructCtx validates a structs exposed fields, and automatically validates nested structs, unless otherwise specified
+// and also allows passing of context.Context for contextual validation information.
+//
+// It returns InvalidValidationError for bad values passed in and nil or ValidationErrors as error otherwise.
+// You will need to assert the error if it's not nil eg. err.(validator.ValidationErrors) to access the array of errors.
+func (v *Validate) StructCtx(ctx context.Context, s interface{}) (err error) {
+
+ val := reflect.ValueOf(s)
+ top := val
+
+ if val.Kind() == reflect.Ptr && !val.IsNil() {
+ val = val.Elem()
+ }
+
+ if val.Kind() != reflect.Struct || val.Type() == timeType {
+ return &InvalidValidationError{Type: reflect.TypeOf(s)}
+ }
+
+ // good to validate
+ vd := v.pool.Get().(*validate)
+ vd.top = top
+ vd.isPartial = false
+ // vd.hasExcludes = false // only need to reset in StructPartial and StructExcept
+
+ vd.validateStruct(ctx, top, val, val.Type(), vd.ns[0:0], vd.actualNs[0:0], nil)
+
+ if len(vd.errs) > 0 {
+ err = vd.errs
+ vd.errs = nil
+ }
+
+ v.pool.Put(vd)
+
+ return
+}
+
+// StructFiltered validates a structs exposed fields, that pass the FilterFunc check and automatically validates
+// nested structs, unless otherwise specified.
+//
+// It returns InvalidValidationError for bad values passed in and nil or ValidationErrors as error otherwise.
+// You will need to assert the error if it's not nil eg. err.(validator.ValidationErrors) to access the array of errors.
+func (v *Validate) StructFiltered(s interface{}, fn FilterFunc) error {
+ return v.StructFilteredCtx(context.Background(), s, fn)
+}
+
+// StructFilteredCtx validates a structs exposed fields, that pass the FilterFunc check and automatically validates
+// nested structs, unless otherwise specified and also allows passing of contextual validation information via
+// context.Context
+//
+// It returns InvalidValidationError for bad values passed in and nil or ValidationErrors as error otherwise.
+// You will need to assert the error if it's not nil eg. err.(validator.ValidationErrors) to access the array of errors.
+func (v *Validate) StructFilteredCtx(ctx context.Context, s interface{}, fn FilterFunc) (err error) {
+ val := reflect.ValueOf(s)
+ top := val
+
+ if val.Kind() == reflect.Ptr && !val.IsNil() {
+ val = val.Elem()
+ }
+
+ if val.Kind() != reflect.Struct || val.Type() == timeType {
+ return &InvalidValidationError{Type: reflect.TypeOf(s)}
+ }
+
+ // good to validate
+ vd := v.pool.Get().(*validate)
+ vd.top = top
+ vd.isPartial = true
+ vd.ffn = fn
+ // vd.hasExcludes = false // only need to reset in StructPartial and StructExcept
+
+ vd.validateStruct(ctx, top, val, val.Type(), vd.ns[0:0], vd.actualNs[0:0], nil)
+
+ if len(vd.errs) > 0 {
+ err = vd.errs
+ vd.errs = nil
+ }
+
+ v.pool.Put(vd)
+
+ return
+}
+
+// StructPartial validates the fields passed in only, ignoring all others.
+// Fields may be provided in a namespaced fashion relative to the struct provided
+// eg. NestedStruct.Field or NestedArrayField[0].Struct.Name
+//
+// It returns InvalidValidationError for bad values passed in and nil or ValidationErrors as error otherwise.
+// You will need to assert the error if it's not nil eg. err.(validator.ValidationErrors) to access the array of errors.
+func (v *Validate) StructPartial(s interface{}, fields ...string) error {
+ return v.StructPartialCtx(context.Background(), s, fields...)
+}
+
+// StructPartialCtx validates the fields passed in only, ignoring all others and allows passing of contextual
+// validation validation information via context.Context
+// Fields may be provided in a namespaced fashion relative to the struct provided
+// eg. NestedStruct.Field or NestedArrayField[0].Struct.Name
+//
+// It returns InvalidValidationError for bad values passed in and nil or ValidationErrors as error otherwise.
+// You will need to assert the error if it's not nil eg. err.(validator.ValidationErrors) to access the array of errors.
+func (v *Validate) StructPartialCtx(ctx context.Context, s interface{}, fields ...string) (err error) {
+ val := reflect.ValueOf(s)
+ top := val
+
+ if val.Kind() == reflect.Ptr && !val.IsNil() {
+ val = val.Elem()
+ }
+
+ if val.Kind() != reflect.Struct || val.Type() == timeType {
+ return &InvalidValidationError{Type: reflect.TypeOf(s)}
+ }
+
+ // good to validate
+ vd := v.pool.Get().(*validate)
+ vd.top = top
+ vd.isPartial = true
+ vd.ffn = nil
+ vd.hasExcludes = false
+ vd.includeExclude = make(map[string]struct{})
+
+ typ := val.Type()
+ name := typ.Name()
+
+ for _, k := range fields {
+
+ flds := strings.Split(k, namespaceSeparator)
+ if len(flds) > 0 {
+
+ vd.misc = append(vd.misc[0:0], name...)
+ vd.misc = append(vd.misc, '.')
+
+ for _, s := range flds {
+
+ idx := strings.Index(s, leftBracket)
+
+ if idx != -1 {
+ for idx != -1 {
+ vd.misc = append(vd.misc, s[:idx]...)
+ vd.includeExclude[string(vd.misc)] = struct{}{}
+
+ idx2 := strings.Index(s, rightBracket)
+ idx2++
+ vd.misc = append(vd.misc, s[idx:idx2]...)
+ vd.includeExclude[string(vd.misc)] = struct{}{}
+ s = s[idx2:]
+ idx = strings.Index(s, leftBracket)
+ }
+ } else {
+
+ vd.misc = append(vd.misc, s...)
+ vd.includeExclude[string(vd.misc)] = struct{}{}
+ }
+
+ vd.misc = append(vd.misc, '.')
+ }
+ }
+ }
+
+ vd.validateStruct(ctx, top, val, typ, vd.ns[0:0], vd.actualNs[0:0], nil)
+
+ if len(vd.errs) > 0 {
+ err = vd.errs
+ vd.errs = nil
+ }
+
+ v.pool.Put(vd)
+
+ return
+}
+
+// StructExcept validates all fields except the ones passed in.
+// Fields may be provided in a namespaced fashion relative to the struct provided
+// i.e. NestedStruct.Field or NestedArrayField[0].Struct.Name
+//
+// It returns InvalidValidationError for bad values passed in and nil or ValidationErrors as error otherwise.
+// You will need to assert the error if it's not nil eg. err.(validator.ValidationErrors) to access the array of errors.
+func (v *Validate) StructExcept(s interface{}, fields ...string) error {
+ return v.StructExceptCtx(context.Background(), s, fields...)
+}
+
+// StructExceptCtx validates all fields except the ones passed in and allows passing of contextual
+// validation validation information via context.Context
+// Fields may be provided in a namespaced fashion relative to the struct provided
+// i.e. NestedStruct.Field or NestedArrayField[0].Struct.Name
+//
+// It returns InvalidValidationError for bad values passed in and nil or ValidationErrors as error otherwise.
+// You will need to assert the error if it's not nil eg. err.(validator.ValidationErrors) to access the array of errors.
+func (v *Validate) StructExceptCtx(ctx context.Context, s interface{}, fields ...string) (err error) {
+ val := reflect.ValueOf(s)
+ top := val
+
+ if val.Kind() == reflect.Ptr && !val.IsNil() {
+ val = val.Elem()
+ }
+
+ if val.Kind() != reflect.Struct || val.Type() == timeType {
+ return &InvalidValidationError{Type: reflect.TypeOf(s)}
+ }
+
+ // good to validate
+ vd := v.pool.Get().(*validate)
+ vd.top = top
+ vd.isPartial = true
+ vd.ffn = nil
+ vd.hasExcludes = true
+ vd.includeExclude = make(map[string]struct{})
+
+ typ := val.Type()
+ name := typ.Name()
+
+ for _, key := range fields {
+
+ vd.misc = vd.misc[0:0]
+
+ if len(name) > 0 {
+ vd.misc = append(vd.misc, name...)
+ vd.misc = append(vd.misc, '.')
+ }
+
+ vd.misc = append(vd.misc, key...)
+ vd.includeExclude[string(vd.misc)] = struct{}{}
+ }
+
+ vd.validateStruct(ctx, top, val, typ, vd.ns[0:0], vd.actualNs[0:0], nil)
+
+ if len(vd.errs) > 0 {
+ err = vd.errs
+ vd.errs = nil
+ }
+
+ v.pool.Put(vd)
+
+ return
+}
+
+// Var validates a single variable using tag style validation.
+// eg.
+// var i int
+// validate.Var(i, "gt=1,lt=10")
+//
+// WARNING: a struct can be passed for validation eg. time.Time is a struct or
+// if you have a custom type and have registered a custom type handler, so must
+// allow it; however unforeseen validations will occur if trying to validate a
+// struct that is meant to be passed to 'validate.Struct'
+//
+// It returns InvalidValidationError for bad values passed in and nil or ValidationErrors as error otherwise.
+// You will need to assert the error if it's not nil eg. err.(validator.ValidationErrors) to access the array of errors.
+// validate Array, Slice and maps fields which may contain more than one error
+func (v *Validate) Var(field interface{}, tag string) error {
+ return v.VarCtx(context.Background(), field, tag)
+}
+
+// VarCtx validates a single variable using tag style validation and allows passing of contextual
+// validation validation information via context.Context.
+// eg.
+// var i int
+// validate.Var(i, "gt=1,lt=10")
+//
+// WARNING: a struct can be passed for validation eg. time.Time is a struct or
+// if you have a custom type and have registered a custom type handler, so must
+// allow it; however unforeseen validations will occur if trying to validate a
+// struct that is meant to be passed to 'validate.Struct'
+//
+// It returns InvalidValidationError for bad values passed in and nil or ValidationErrors as error otherwise.
+// You will need to assert the error if it's not nil eg. err.(validator.ValidationErrors) to access the array of errors.
+// validate Array, Slice and maps fields which may contain more than one error
+func (v *Validate) VarCtx(ctx context.Context, field interface{}, tag string) (err error) {
+ if len(tag) == 0 || tag == skipValidationTag {
+ return nil
+ }
+
+ ctag := v.fetchCacheTag(tag)
+ val := reflect.ValueOf(field)
+ vd := v.pool.Get().(*validate)
+ vd.top = val
+ vd.isPartial = false
+ vd.traverseField(ctx, val, val, vd.ns[0:0], vd.actualNs[0:0], defaultCField, ctag)
+
+ if len(vd.errs) > 0 {
+ err = vd.errs
+ vd.errs = nil
+ }
+ v.pool.Put(vd)
+ return
+}
+
+// VarWithValue validates a single variable, against another variable/field's value using tag style validation
+// eg.
+// s1 := "abcd"
+// s2 := "abcd"
+// validate.VarWithValue(s1, s2, "eqcsfield") // returns true
+//
+// WARNING: a struct can be passed for validation eg. time.Time is a struct or
+// if you have a custom type and have registered a custom type handler, so must
+// allow it; however unforeseen validations will occur if trying to validate a
+// struct that is meant to be passed to 'validate.Struct'
+//
+// It returns InvalidValidationError for bad values passed in and nil or ValidationErrors as error otherwise.
+// You will need to assert the error if it's not nil eg. err.(validator.ValidationErrors) to access the array of errors.
+// validate Array, Slice and maps fields which may contain more than one error
+func (v *Validate) VarWithValue(field interface{}, other interface{}, tag string) error {
+ return v.VarWithValueCtx(context.Background(), field, other, tag)
+}
+
+// VarWithValueCtx validates a single variable, against another variable/field's value using tag style validation and
+// allows passing of contextual validation validation information via context.Context.
+// eg.
+// s1 := "abcd"
+// s2 := "abcd"
+// validate.VarWithValue(s1, s2, "eqcsfield") // returns true
+//
+// WARNING: a struct can be passed for validation eg. time.Time is a struct or
+// if you have a custom type and have registered a custom type handler, so must
+// allow it; however unforeseen validations will occur if trying to validate a
+// struct that is meant to be passed to 'validate.Struct'
+//
+// It returns InvalidValidationError for bad values passed in and nil or ValidationErrors as error otherwise.
+// You will need to assert the error if it's not nil eg. err.(validator.ValidationErrors) to access the array of errors.
+// validate Array, Slice and maps fields which may contain more than one error
+func (v *Validate) VarWithValueCtx(ctx context.Context, field interface{}, other interface{}, tag string) (err error) {
+ if len(tag) == 0 || tag == skipValidationTag {
+ return nil
+ }
+ ctag := v.fetchCacheTag(tag)
+ otherVal := reflect.ValueOf(other)
+ vd := v.pool.Get().(*validate)
+ vd.top = otherVal
+ vd.isPartial = false
+ vd.traverseField(ctx, otherVal, reflect.ValueOf(field), vd.ns[0:0], vd.actualNs[0:0], defaultCField, ctag)
+
+ if len(vd.errs) > 0 {
+ err = vd.errs
+ vd.errs = nil
+ }
+ v.pool.Put(vd)
+ return
+}
diff --git a/baas-kubeengine/vendor/github.com/golang/protobuf/proto/lib.go b/baas-kubeengine/vendor/github.com/golang/protobuf/proto/lib.go
index fdd328bb..70fbda53 100644
--- a/baas-kubeengine/vendor/github.com/golang/protobuf/proto/lib.go
+++ b/baas-kubeengine/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/baas-kubeengine/vendor/github.com/golang/protobuf/proto/properties.go b/baas-kubeengine/vendor/github.com/golang/protobuf/proto/properties.go
index 79668ff5..a4b8c0cd 100644
--- a/baas-kubeengine/vendor/github.com/golang/protobuf/proto/properties.go
+++ b/baas-kubeengine/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/baas-kubeengine/vendor/github.com/golang/protobuf/proto/text.go b/baas-kubeengine/vendor/github.com/golang/protobuf/proto/text.go
index 1aaee725..d97f9b35 100644
--- a/baas-kubeengine/vendor/github.com/golang/protobuf/proto/text.go
+++ b/baas-kubeengine/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/baas-kubeengine/vendor/github.com/hashicorp/hcl/.gitignore b/baas-kubeengine/vendor/github.com/hashicorp/hcl/.gitignore
index 822fa09f..15586a2b 100644
--- a/baas-kubeengine/vendor/github.com/hashicorp/hcl/.gitignore
+++ b/baas-kubeengine/vendor/github.com/hashicorp/hcl/.gitignore
@@ -1,9 +1,9 @@
-y.output
-
-# ignore intellij files
-.idea
-*.iml
-*.ipr
-*.iws
-
-*.test
+y.output
+
+# ignore intellij files
+.idea
+*.iml
+*.ipr
+*.iws
+
+*.test
diff --git a/baas-kubeengine/vendor/github.com/hashicorp/hcl/Makefile b/baas-kubeengine/vendor/github.com/hashicorp/hcl/Makefile
index 9fafd501..84fd743f 100644
--- a/baas-kubeengine/vendor/github.com/hashicorp/hcl/Makefile
+++ b/baas-kubeengine/vendor/github.com/hashicorp/hcl/Makefile
@@ -1,18 +1,18 @@
-TEST?=./...
-
-default: test
-
-fmt: generate
- go fmt ./...
-
-test: generate
- go get -t ./...
- go test $(TEST) $(TESTARGS)
-
-generate:
- go generate ./...
-
-updatedeps:
- go get -u golang.org/x/tools/cmd/stringer
-
-.PHONY: default generate test updatedeps
+TEST?=./...
+
+default: test
+
+fmt: generate
+ go fmt ./...
+
+test: generate
+ go get -t ./...
+ go test $(TEST) $(TESTARGS)
+
+generate:
+ go generate ./...
+
+updatedeps:
+ go get -u golang.org/x/tools/cmd/stringer
+
+.PHONY: default generate test updatedeps
diff --git a/baas-kubeengine/vendor/github.com/json-iterator/go/adapter.go b/baas-kubeengine/vendor/github.com/json-iterator/go/adapter.go
index e674d0f3..92d2cc4a 100644
--- a/baas-kubeengine/vendor/github.com/json-iterator/go/adapter.go
+++ b/baas-kubeengine/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/baas-kubeengine/vendor/github.com/json-iterator/go/go.mod b/baas-kubeengine/vendor/github.com/json-iterator/go/go.mod
new file mode 100644
index 00000000..e05c42ff
--- /dev/null
+++ b/baas-kubeengine/vendor/github.com/json-iterator/go/go.mod
@@ -0,0 +1,11 @@
+module github.com/json-iterator/go
+
+go 1.12
+
+require (
+ github.com/davecgh/go-spew v1.1.1
+ github.com/google/gofuzz v1.0.0
+ github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421
+ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742
+ github.com/stretchr/testify v1.3.0
+)
diff --git a/baas-kubeengine/vendor/github.com/json-iterator/go/go.sum b/baas-kubeengine/vendor/github.com/json-iterator/go/go.sum
new file mode 100644
index 00000000..d778b5a1
--- /dev/null
+++ b/baas-kubeengine/vendor/github.com/json-iterator/go/go.sum
@@ -0,0 +1,14 @@
+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/google/gofuzz v1.0.0 h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw=
+github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
+github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc=
+github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
+github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 h1:Esafd1046DLDQ0W1YjYsBW+p8U2u7vzgW2SQVmlNazg=
+github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
+github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
+github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+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=
diff --git a/baas-kubeengine/vendor/github.com/json-iterator/go/iter.go b/baas-kubeengine/vendor/github.com/json-iterator/go/iter.go
index 95ae54fb..29b31cf7 100644
--- a/baas-kubeengine/vendor/github.com/json-iterator/go/iter.go
+++ b/baas-kubeengine/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/baas-kubeengine/vendor/github.com/json-iterator/go/iter_array.go b/baas-kubeengine/vendor/github.com/json-iterator/go/iter_array.go
index 6188cb45..204fe0e0 100644
--- a/baas-kubeengine/vendor/github.com/json-iterator/go/iter_array.go
+++ b/baas-kubeengine/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/baas-kubeengine/vendor/github.com/json-iterator/go/iter_object.go b/baas-kubeengine/vendor/github.com/json-iterator/go/iter_object.go
index 1c575767..b6513711 100644
--- a/baas-kubeengine/vendor/github.com/json-iterator/go/iter_object.go
+++ b/baas-kubeengine/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/baas-kubeengine/vendor/github.com/json-iterator/go/iter_skip.go b/baas-kubeengine/vendor/github.com/json-iterator/go/iter_skip.go
index f58beb91..e91eefb1 100644
--- a/baas-kubeengine/vendor/github.com/json-iterator/go/iter_skip.go
+++ b/baas-kubeengine/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/baas-kubeengine/vendor/github.com/json-iterator/go/iter_skip_sloppy.go b/baas-kubeengine/vendor/github.com/json-iterator/go/iter_skip_sloppy.go
index 8fcdc3b6..9303de41 100644
--- a/baas-kubeengine/vendor/github.com/json-iterator/go/iter_skip_sloppy.go
+++ b/baas-kubeengine/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/baas-kubeengine/vendor/github.com/json-iterator/go/reflect.go b/baas-kubeengine/vendor/github.com/json-iterator/go/reflect.go
index 4459e203..74974ba7 100644
--- a/baas-kubeengine/vendor/github.com/json-iterator/go/reflect.go
+++ b/baas-kubeengine/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/baas-kubeengine/vendor/github.com/json-iterator/go/reflect_extension.go b/baas-kubeengine/vendor/github.com/json-iterator/go/reflect_extension.go
index 05e8fbf1..80320cd6 100644
--- a/baas-kubeengine/vendor/github.com/json-iterator/go/reflect_extension.go
+++ b/baas-kubeengine/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/baas-kubeengine/vendor/github.com/json-iterator/go/reflect_map.go b/baas-kubeengine/vendor/github.com/json-iterator/go/reflect_map.go
index 547b4421..9e2b623f 100644
--- a/baas-kubeengine/vendor/github.com/json-iterator/go/reflect_map.go
+++ b/baas-kubeengine/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/baas-kubeengine/vendor/github.com/json-iterator/go/reflect_marshaler.go b/baas-kubeengine/vendor/github.com/json-iterator/go/reflect_marshaler.go
index fea50719..3e21f375 100644
--- a/baas-kubeengine/vendor/github.com/json-iterator/go/reflect_marshaler.go
+++ b/baas-kubeengine/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/baas-kubeengine/vendor/github.com/json-iterator/go/reflect_native.go b/baas-kubeengine/vendor/github.com/json-iterator/go/reflect_native.go
index 9042eb0c..f88722d1 100644
--- a/baas-kubeengine/vendor/github.com/json-iterator/go/reflect_native.go
+++ b/baas-kubeengine/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/baas-kubeengine/vendor/github.com/json-iterator/go/reflect_struct_decoder.go b/baas-kubeengine/vendor/github.com/json-iterator/go/reflect_struct_decoder.go
index 355d2d11..5ad5cc56 100644
--- a/baas-kubeengine/vendor/github.com/json-iterator/go/reflect_struct_decoder.go
+++ b/baas-kubeengine/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/baas-kubeengine/vendor/github.com/json-iterator/go/reflect_struct_encoder.go b/baas-kubeengine/vendor/github.com/json-iterator/go/reflect_struct_encoder.go
index d0759cf6..152e3ef5 100644
--- a/baas-kubeengine/vendor/github.com/json-iterator/go/reflect_struct_encoder.go
+++ b/baas-kubeengine/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/baas-kubeengine/vendor/github.com/json-iterator/go/stream_float.go b/baas-kubeengine/vendor/github.com/json-iterator/go/stream_float.go
index f318d2c5..826aa594 100644
--- a/baas-kubeengine/vendor/github.com/json-iterator/go/stream_float.go
+++ b/baas-kubeengine/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/baas-kubeengine/vendor/github.com/leodido/go-urn/.gitignore b/baas-kubeengine/vendor/github.com/leodido/go-urn/.gitignore
new file mode 100644
index 00000000..5bcf4bad
--- /dev/null
+++ b/baas-kubeengine/vendor/github.com/leodido/go-urn/.gitignore
@@ -0,0 +1,11 @@
+*.exe
+*.dll
+*.so
+*.dylib
+
+*.test
+
+*.out
+*.txt
+
+vendor/
\ No newline at end of file
diff --git a/baas-kubeengine/vendor/github.com/leodido/go-urn/.travis.yml b/baas-kubeengine/vendor/github.com/leodido/go-urn/.travis.yml
new file mode 100644
index 00000000..e56cf7cc
--- /dev/null
+++ b/baas-kubeengine/vendor/github.com/leodido/go-urn/.travis.yml
@@ -0,0 +1,18 @@
+language: go
+
+go:
+ - 1.9.x
+ - 1.10.x
+ - 1.11.x
+ - 1.12.x
+ - 1.13.x
+ - tip
+
+before_install:
+ - go get -t -v ./...
+
+script:
+ - go test -race -coverprofile=coverage.txt -covermode=atomic
+
+after_success:
+ - bash <(curl -s https://codecov.io/bash)
\ No newline at end of file
diff --git a/baas-kubeengine/vendor/github.com/leodido/go-urn/LICENSE b/baas-kubeengine/vendor/github.com/leodido/go-urn/LICENSE
new file mode 100644
index 00000000..8c3504a5
--- /dev/null
+++ b/baas-kubeengine/vendor/github.com/leodido/go-urn/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2018 Leonardo Di Donato
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/baas-kubeengine/vendor/github.com/leodido/go-urn/README.md b/baas-kubeengine/vendor/github.com/leodido/go-urn/README.md
new file mode 100644
index 00000000..cc902ec0
--- /dev/null
+++ b/baas-kubeengine/vendor/github.com/leodido/go-urn/README.md
@@ -0,0 +1,55 @@
+[![Build](https://img.shields.io/travis/leodido/go-urn/master.svg?style=for-the-badge)](https://travis-ci.org/leodido/go-urn) [![Coverage](https://img.shields.io/codecov/c/github/leodido/go-urn.svg?style=for-the-badge)](https://codecov.io/gh/leodido/go-urn) [![Documentation](https://img.shields.io/badge/godoc-reference-blue.svg?style=for-the-badge)](https://godoc.org/github.com/leodido/go-urn)
+
+**A parser for URNs**.
+
+> As seen on [RFC 2141](https://tools.ietf.org/html/rfc2141#ref-1).
+
+[API documentation](https://godoc.org/github.com/leodido/go-urn).
+
+## Installation
+
+```
+go get github.com/leodido/go-urn
+```
+
+## Performances
+
+This implementation results to be really fast.
+
+Usually below ½ microsecond on my machine[1](#mymachine).
+
+Notice it also performs, while parsing:
+
+1. fine-grained and informative erroring
+2. specific-string normalization
+
+```
+ok/00/urn:a:b______________________________________/-4 20000000 265 ns/op 182 B/op 6 allocs/op
+ok/01/URN:foo:a123,456_____________________________/-4 30000000 296 ns/op 200 B/op 6 allocs/op
+ok/02/urn:foo:a123%2c456___________________________/-4 20000000 331 ns/op 208 B/op 6 allocs/op
+ok/03/urn:ietf:params:scim:schemas:core:2.0:User___/-4 20000000 430 ns/op 280 B/op 6 allocs/op
+ok/04/urn:ietf:params:scim:schemas:extension:enterp/-4 20000000 411 ns/op 312 B/op 6 allocs/op
+ok/05/urn:ietf:params:scim:schemas:extension:enterp/-4 20000000 472 ns/op 344 B/op 6 allocs/op
+ok/06/urn:burnout:nss______________________________/-4 30000000 257 ns/op 192 B/op 6 allocs/op
+ok/07/urn:abcdefghilmnopqrstuvzabcdefghilm:x_______/-4 20000000 375 ns/op 213 B/op 6 allocs/op
+ok/08/urn:urnurnurn:urn____________________________/-4 30000000 265 ns/op 197 B/op 6 allocs/op
+ok/09/urn:ciao:@!=%2c(xyz)+a,b.*@g=$_'_____________/-4 20000000 307 ns/op 248 B/op 6 allocs/op
+ok/10/URN:x:abc%1dz%2f%3az_________________________/-4 30000000 259 ns/op 212 B/op 6 allocs/op
+no/11/URN:-xxx:x___________________________________/-4 20000000 445 ns/op 320 B/op 6 allocs/op
+no/12/urn::colon:nss_______________________________/-4 20000000 461 ns/op 320 B/op 6 allocs/op
+no/13/urn:abcdefghilmnopqrstuvzabcdefghilmn:specifi/-4 10000000 660 ns/op 320 B/op 6 allocs/op
+no/14/URN:a!?:x____________________________________/-4 20000000 507 ns/op 320 B/op 6 allocs/op
+no/15/urn:urn:NSS__________________________________/-4 20000000 429 ns/op 288 B/op 6 allocs/op
+no/16/urn:white_space:NSS__________________________/-4 20000000 482 ns/op 320 B/op 6 allocs/op
+no/17/urn:concat:no_spaces_________________________/-4 20000000 539 ns/op 328 B/op 7 allocs/op
+no/18/urn:a:/______________________________________/-4 20000000 470 ns/op 320 B/op 7 allocs/op
+no/19/urn:UrN:NSS__________________________________/-4 20000000 399 ns/op 288 B/op 6 allocs/op
+```
+
+---
+
+* [1]: Intel Core i7-7600U CPU @ 2.80GHz
+
+---
+
+[![Analytics](https://ga-beacon.appspot.com/UA-49657176-1/go-urn?flat)](https://github.com/igrigorik/ga-beacon)
\ No newline at end of file
diff --git a/baas-kubeengine/vendor/github.com/leodido/go-urn/go.mod b/baas-kubeengine/vendor/github.com/leodido/go-urn/go.mod
new file mode 100644
index 00000000..65bc1caf
--- /dev/null
+++ b/baas-kubeengine/vendor/github.com/leodido/go-urn/go.mod
@@ -0,0 +1,5 @@
+module github.com/leodido/go-urn
+
+go 1.13
+
+require github.com/stretchr/testify v1.4.0
diff --git a/baas-kubeengine/vendor/github.com/leodido/go-urn/go.sum b/baas-kubeengine/vendor/github.com/leodido/go-urn/go.sum
new file mode 100644
index 00000000..8fdee585
--- /dev/null
+++ b/baas-kubeengine/vendor/github.com/leodido/go-urn/go.sum
@@ -0,0 +1,11 @@
+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/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
+github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
+github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
+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/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
+gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
diff --git a/baas-kubeengine/vendor/github.com/leodido/go-urn/machine.go b/baas-kubeengine/vendor/github.com/leodido/go-urn/machine.go
new file mode 100644
index 00000000..fe5a0cc8
--- /dev/null
+++ b/baas-kubeengine/vendor/github.com/leodido/go-urn/machine.go
@@ -0,0 +1,1691 @@
+package urn
+
+import (
+ "fmt"
+)
+
+var (
+ errPrefix = "expecting the prefix to be the \"urn\" string (whatever case) [col %d]"
+ errIdentifier = "expecting the identifier to be string (1..31 alnum chars, also containing dashes but not at its start) [col %d]"
+ errSpecificString = "expecting the specific string to be a string containing alnum, hex, or others ([()+,-.:=@;$_!*']) chars [col %d]"
+ errNoUrnWithinID = "expecting the identifier to not contain the \"urn\" reserved string [col %d]"
+ errHex = "expecting the specific string hex chars to be well-formed (%%alnum{2}) [col %d]"
+ errParse = "parsing error [col %d]"
+)
+
+const start int = 1
+const firstFinal int = 44
+
+const enFail int = 46
+const enMain int = 1
+
+// Machine is the interface representing the FSM
+type Machine interface {
+ Error() error
+ Parse(input []byte) (*URN, error)
+}
+
+type machine struct {
+ data []byte
+ cs int
+ p, pe, eof, pb int
+ err error
+ tolower []int
+}
+
+// NewMachine creates a new FSM able to parse RFC 2141 strings.
+func NewMachine() Machine {
+ m := &machine{}
+
+ return m
+}
+
+// Err returns the error that occurred on the last call to Parse.
+//
+// If the result is nil, then the line was parsed successfully.
+func (m *machine) Error() error {
+ return m.err
+}
+
+func (m *machine) text() []byte {
+ return m.data[m.pb:m.p]
+}
+
+// Parse parses the input byte array as a RFC 2141 string.
+func (m *machine) Parse(input []byte) (*URN, error) {
+ m.data = input
+ m.p = 0
+ m.pb = 0
+ m.pe = len(input)
+ m.eof = len(input)
+ m.err = nil
+ m.tolower = []int{}
+ output := &URN{}
+
+ {
+ m.cs = start
+ }
+
+ {
+ if (m.p) == (m.pe) {
+ goto _testEof
+ }
+ switch m.cs {
+ case 1:
+ goto stCase1
+ case 0:
+ goto stCase0
+ case 2:
+ goto stCase2
+ case 3:
+ goto stCase3
+ case 4:
+ goto stCase4
+ case 5:
+ goto stCase5
+ case 6:
+ goto stCase6
+ case 7:
+ goto stCase7
+ case 8:
+ goto stCase8
+ case 9:
+ goto stCase9
+ case 10:
+ goto stCase10
+ case 11:
+ goto stCase11
+ case 12:
+ goto stCase12
+ case 13:
+ goto stCase13
+ case 14:
+ goto stCase14
+ case 15:
+ goto stCase15
+ case 16:
+ goto stCase16
+ case 17:
+ goto stCase17
+ case 18:
+ goto stCase18
+ case 19:
+ goto stCase19
+ case 20:
+ goto stCase20
+ case 21:
+ goto stCase21
+ case 22:
+ goto stCase22
+ case 23:
+ goto stCase23
+ case 24:
+ goto stCase24
+ case 25:
+ goto stCase25
+ case 26:
+ goto stCase26
+ case 27:
+ goto stCase27
+ case 28:
+ goto stCase28
+ case 29:
+ goto stCase29
+ case 30:
+ goto stCase30
+ case 31:
+ goto stCase31
+ case 32:
+ goto stCase32
+ case 33:
+ goto stCase33
+ case 34:
+ goto stCase34
+ case 35:
+ goto stCase35
+ case 36:
+ goto stCase36
+ case 37:
+ goto stCase37
+ case 38:
+ goto stCase38
+ case 44:
+ goto stCase44
+ case 39:
+ goto stCase39
+ case 40:
+ goto stCase40
+ case 45:
+ goto stCase45
+ case 41:
+ goto stCase41
+ case 42:
+ goto stCase42
+ case 43:
+ goto stCase43
+ case 46:
+ goto stCase46
+ }
+ goto stOut
+ stCase1:
+ switch (m.data)[(m.p)] {
+ case 85:
+ goto tr1
+ case 117:
+ goto tr1
+ }
+ goto tr0
+ tr0:
+
+ m.err = fmt.Errorf(errParse, m.p)
+ (m.p)--
+
+ {
+ goto st46
+ }
+
+ goto st0
+ tr3:
+
+ m.err = fmt.Errorf(errPrefix, m.p)
+ (m.p)--
+
+ {
+ goto st46
+ }
+
+ m.err = fmt.Errorf(errParse, m.p)
+ (m.p)--
+
+ {
+ goto st46
+ }
+
+ goto st0
+ tr6:
+
+ m.err = fmt.Errorf(errIdentifier, m.p)
+ (m.p)--
+
+ {
+ goto st46
+ }
+
+ m.err = fmt.Errorf(errParse, m.p)
+ (m.p)--
+
+ {
+ goto st46
+ }
+
+ goto st0
+ tr41:
+
+ m.err = fmt.Errorf(errSpecificString, m.p)
+ (m.p)--
+
+ {
+ goto st46
+ }
+
+ m.err = fmt.Errorf(errParse, m.p)
+ (m.p)--
+
+ {
+ goto st46
+ }
+
+ goto st0
+ tr44:
+
+ m.err = fmt.Errorf(errHex, m.p)
+ (m.p)--
+
+ {
+ goto st46
+ }
+
+ m.err = fmt.Errorf(errSpecificString, m.p)
+ (m.p)--
+
+ {
+ goto st46
+ }
+
+ m.err = fmt.Errorf(errParse, m.p)
+ (m.p)--
+
+ {
+ goto st46
+ }
+
+ goto st0
+ tr50:
+
+ m.err = fmt.Errorf(errPrefix, m.p)
+ (m.p)--
+
+ {
+ goto st46
+ }
+
+ m.err = fmt.Errorf(errIdentifier, m.p)
+ (m.p)--
+
+ {
+ goto st46
+ }
+
+ m.err = fmt.Errorf(errParse, m.p)
+ (m.p)--
+
+ {
+ goto st46
+ }
+
+ goto st0
+ tr52:
+
+ m.err = fmt.Errorf(errNoUrnWithinID, m.p)
+ (m.p)--
+
+ {
+ goto st46
+ }
+
+ m.err = fmt.Errorf(errIdentifier, m.p)
+ (m.p)--
+
+ {
+ goto st46
+ }
+
+ m.err = fmt.Errorf(errParse, m.p)
+ (m.p)--
+
+ {
+ goto st46
+ }
+
+ goto st0
+ stCase0:
+ st0:
+ m.cs = 0
+ goto _out
+ tr1:
+
+ m.pb = m.p
+
+ goto st2
+ st2:
+ if (m.p)++; (m.p) == (m.pe) {
+ goto _testEof2
+ }
+ stCase2:
+ switch (m.data)[(m.p)] {
+ case 82:
+ goto st3
+ case 114:
+ goto st3
+ }
+ goto tr0
+ st3:
+ if (m.p)++; (m.p) == (m.pe) {
+ goto _testEof3
+ }
+ stCase3:
+ switch (m.data)[(m.p)] {
+ case 78:
+ goto st4
+ case 110:
+ goto st4
+ }
+ goto tr3
+ st4:
+ if (m.p)++; (m.p) == (m.pe) {
+ goto _testEof4
+ }
+ stCase4:
+ if (m.data)[(m.p)] == 58 {
+ goto tr5
+ }
+ goto tr0
+ tr5:
+
+ output.prefix = string(m.text())
+
+ goto st5
+ st5:
+ if (m.p)++; (m.p) == (m.pe) {
+ goto _testEof5
+ }
+ stCase5:
+ switch (m.data)[(m.p)] {
+ case 85:
+ goto tr8
+ case 117:
+ goto tr8
+ }
+ switch {
+ case (m.data)[(m.p)] < 65:
+ if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 {
+ goto tr7
+ }
+ case (m.data)[(m.p)] > 90:
+ if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 {
+ goto tr7
+ }
+ default:
+ goto tr7
+ }
+ goto tr6
+ tr7:
+
+ m.pb = m.p
+
+ goto st6
+ st6:
+ if (m.p)++; (m.p) == (m.pe) {
+ goto _testEof6
+ }
+ stCase6:
+ switch (m.data)[(m.p)] {
+ case 45:
+ goto st7
+ case 58:
+ goto tr10
+ }
+ switch {
+ case (m.data)[(m.p)] < 65:
+ if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 {
+ goto st7
+ }
+ case (m.data)[(m.p)] > 90:
+ if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 {
+ goto st7
+ }
+ default:
+ goto st7
+ }
+ goto tr6
+ st7:
+ if (m.p)++; (m.p) == (m.pe) {
+ goto _testEof7
+ }
+ stCase7:
+ switch (m.data)[(m.p)] {
+ case 45:
+ goto st8
+ case 58:
+ goto tr10
+ }
+ switch {
+ case (m.data)[(m.p)] < 65:
+ if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 {
+ goto st8
+ }
+ case (m.data)[(m.p)] > 90:
+ if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 {
+ goto st8
+ }
+ default:
+ goto st8
+ }
+ goto tr6
+ st8:
+ if (m.p)++; (m.p) == (m.pe) {
+ goto _testEof8
+ }
+ stCase8:
+ switch (m.data)[(m.p)] {
+ case 45:
+ goto st9
+ case 58:
+ goto tr10
+ }
+ switch {
+ case (m.data)[(m.p)] < 65:
+ if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 {
+ goto st9
+ }
+ case (m.data)[(m.p)] > 90:
+ if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 {
+ goto st9
+ }
+ default:
+ goto st9
+ }
+ goto tr6
+ st9:
+ if (m.p)++; (m.p) == (m.pe) {
+ goto _testEof9
+ }
+ stCase9:
+ switch (m.data)[(m.p)] {
+ case 45:
+ goto st10
+ case 58:
+ goto tr10
+ }
+ switch {
+ case (m.data)[(m.p)] < 65:
+ if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 {
+ goto st10
+ }
+ case (m.data)[(m.p)] > 90:
+ if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 {
+ goto st10
+ }
+ default:
+ goto st10
+ }
+ goto tr6
+ st10:
+ if (m.p)++; (m.p) == (m.pe) {
+ goto _testEof10
+ }
+ stCase10:
+ switch (m.data)[(m.p)] {
+ case 45:
+ goto st11
+ case 58:
+ goto tr10
+ }
+ switch {
+ case (m.data)[(m.p)] < 65:
+ if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 {
+ goto st11
+ }
+ case (m.data)[(m.p)] > 90:
+ if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 {
+ goto st11
+ }
+ default:
+ goto st11
+ }
+ goto tr6
+ st11:
+ if (m.p)++; (m.p) == (m.pe) {
+ goto _testEof11
+ }
+ stCase11:
+ switch (m.data)[(m.p)] {
+ case 45:
+ goto st12
+ case 58:
+ goto tr10
+ }
+ switch {
+ case (m.data)[(m.p)] < 65:
+ if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 {
+ goto st12
+ }
+ case (m.data)[(m.p)] > 90:
+ if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 {
+ goto st12
+ }
+ default:
+ goto st12
+ }
+ goto tr6
+ st12:
+ if (m.p)++; (m.p) == (m.pe) {
+ goto _testEof12
+ }
+ stCase12:
+ switch (m.data)[(m.p)] {
+ case 45:
+ goto st13
+ case 58:
+ goto tr10
+ }
+ switch {
+ case (m.data)[(m.p)] < 65:
+ if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 {
+ goto st13
+ }
+ case (m.data)[(m.p)] > 90:
+ if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 {
+ goto st13
+ }
+ default:
+ goto st13
+ }
+ goto tr6
+ st13:
+ if (m.p)++; (m.p) == (m.pe) {
+ goto _testEof13
+ }
+ stCase13:
+ switch (m.data)[(m.p)] {
+ case 45:
+ goto st14
+ case 58:
+ goto tr10
+ }
+ switch {
+ case (m.data)[(m.p)] < 65:
+ if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 {
+ goto st14
+ }
+ case (m.data)[(m.p)] > 90:
+ if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 {
+ goto st14
+ }
+ default:
+ goto st14
+ }
+ goto tr6
+ st14:
+ if (m.p)++; (m.p) == (m.pe) {
+ goto _testEof14
+ }
+ stCase14:
+ switch (m.data)[(m.p)] {
+ case 45:
+ goto st15
+ case 58:
+ goto tr10
+ }
+ switch {
+ case (m.data)[(m.p)] < 65:
+ if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 {
+ goto st15
+ }
+ case (m.data)[(m.p)] > 90:
+ if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 {
+ goto st15
+ }
+ default:
+ goto st15
+ }
+ goto tr6
+ st15:
+ if (m.p)++; (m.p) == (m.pe) {
+ goto _testEof15
+ }
+ stCase15:
+ switch (m.data)[(m.p)] {
+ case 45:
+ goto st16
+ case 58:
+ goto tr10
+ }
+ switch {
+ case (m.data)[(m.p)] < 65:
+ if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 {
+ goto st16
+ }
+ case (m.data)[(m.p)] > 90:
+ if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 {
+ goto st16
+ }
+ default:
+ goto st16
+ }
+ goto tr6
+ st16:
+ if (m.p)++; (m.p) == (m.pe) {
+ goto _testEof16
+ }
+ stCase16:
+ switch (m.data)[(m.p)] {
+ case 45:
+ goto st17
+ case 58:
+ goto tr10
+ }
+ switch {
+ case (m.data)[(m.p)] < 65:
+ if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 {
+ goto st17
+ }
+ case (m.data)[(m.p)] > 90:
+ if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 {
+ goto st17
+ }
+ default:
+ goto st17
+ }
+ goto tr6
+ st17:
+ if (m.p)++; (m.p) == (m.pe) {
+ goto _testEof17
+ }
+ stCase17:
+ switch (m.data)[(m.p)] {
+ case 45:
+ goto st18
+ case 58:
+ goto tr10
+ }
+ switch {
+ case (m.data)[(m.p)] < 65:
+ if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 {
+ goto st18
+ }
+ case (m.data)[(m.p)] > 90:
+ if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 {
+ goto st18
+ }
+ default:
+ goto st18
+ }
+ goto tr6
+ st18:
+ if (m.p)++; (m.p) == (m.pe) {
+ goto _testEof18
+ }
+ stCase18:
+ switch (m.data)[(m.p)] {
+ case 45:
+ goto st19
+ case 58:
+ goto tr10
+ }
+ switch {
+ case (m.data)[(m.p)] < 65:
+ if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 {
+ goto st19
+ }
+ case (m.data)[(m.p)] > 90:
+ if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 {
+ goto st19
+ }
+ default:
+ goto st19
+ }
+ goto tr6
+ st19:
+ if (m.p)++; (m.p) == (m.pe) {
+ goto _testEof19
+ }
+ stCase19:
+ switch (m.data)[(m.p)] {
+ case 45:
+ goto st20
+ case 58:
+ goto tr10
+ }
+ switch {
+ case (m.data)[(m.p)] < 65:
+ if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 {
+ goto st20
+ }
+ case (m.data)[(m.p)] > 90:
+ if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 {
+ goto st20
+ }
+ default:
+ goto st20
+ }
+ goto tr6
+ st20:
+ if (m.p)++; (m.p) == (m.pe) {
+ goto _testEof20
+ }
+ stCase20:
+ switch (m.data)[(m.p)] {
+ case 45:
+ goto st21
+ case 58:
+ goto tr10
+ }
+ switch {
+ case (m.data)[(m.p)] < 65:
+ if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 {
+ goto st21
+ }
+ case (m.data)[(m.p)] > 90:
+ if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 {
+ goto st21
+ }
+ default:
+ goto st21
+ }
+ goto tr6
+ st21:
+ if (m.p)++; (m.p) == (m.pe) {
+ goto _testEof21
+ }
+ stCase21:
+ switch (m.data)[(m.p)] {
+ case 45:
+ goto st22
+ case 58:
+ goto tr10
+ }
+ switch {
+ case (m.data)[(m.p)] < 65:
+ if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 {
+ goto st22
+ }
+ case (m.data)[(m.p)] > 90:
+ if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 {
+ goto st22
+ }
+ default:
+ goto st22
+ }
+ goto tr6
+ st22:
+ if (m.p)++; (m.p) == (m.pe) {
+ goto _testEof22
+ }
+ stCase22:
+ switch (m.data)[(m.p)] {
+ case 45:
+ goto st23
+ case 58:
+ goto tr10
+ }
+ switch {
+ case (m.data)[(m.p)] < 65:
+ if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 {
+ goto st23
+ }
+ case (m.data)[(m.p)] > 90:
+ if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 {
+ goto st23
+ }
+ default:
+ goto st23
+ }
+ goto tr6
+ st23:
+ if (m.p)++; (m.p) == (m.pe) {
+ goto _testEof23
+ }
+ stCase23:
+ switch (m.data)[(m.p)] {
+ case 45:
+ goto st24
+ case 58:
+ goto tr10
+ }
+ switch {
+ case (m.data)[(m.p)] < 65:
+ if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 {
+ goto st24
+ }
+ case (m.data)[(m.p)] > 90:
+ if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 {
+ goto st24
+ }
+ default:
+ goto st24
+ }
+ goto tr6
+ st24:
+ if (m.p)++; (m.p) == (m.pe) {
+ goto _testEof24
+ }
+ stCase24:
+ switch (m.data)[(m.p)] {
+ case 45:
+ goto st25
+ case 58:
+ goto tr10
+ }
+ switch {
+ case (m.data)[(m.p)] < 65:
+ if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 {
+ goto st25
+ }
+ case (m.data)[(m.p)] > 90:
+ if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 {
+ goto st25
+ }
+ default:
+ goto st25
+ }
+ goto tr6
+ st25:
+ if (m.p)++; (m.p) == (m.pe) {
+ goto _testEof25
+ }
+ stCase25:
+ switch (m.data)[(m.p)] {
+ case 45:
+ goto st26
+ case 58:
+ goto tr10
+ }
+ switch {
+ case (m.data)[(m.p)] < 65:
+ if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 {
+ goto st26
+ }
+ case (m.data)[(m.p)] > 90:
+ if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 {
+ goto st26
+ }
+ default:
+ goto st26
+ }
+ goto tr6
+ st26:
+ if (m.p)++; (m.p) == (m.pe) {
+ goto _testEof26
+ }
+ stCase26:
+ switch (m.data)[(m.p)] {
+ case 45:
+ goto st27
+ case 58:
+ goto tr10
+ }
+ switch {
+ case (m.data)[(m.p)] < 65:
+ if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 {
+ goto st27
+ }
+ case (m.data)[(m.p)] > 90:
+ if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 {
+ goto st27
+ }
+ default:
+ goto st27
+ }
+ goto tr6
+ st27:
+ if (m.p)++; (m.p) == (m.pe) {
+ goto _testEof27
+ }
+ stCase27:
+ switch (m.data)[(m.p)] {
+ case 45:
+ goto st28
+ case 58:
+ goto tr10
+ }
+ switch {
+ case (m.data)[(m.p)] < 65:
+ if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 {
+ goto st28
+ }
+ case (m.data)[(m.p)] > 90:
+ if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 {
+ goto st28
+ }
+ default:
+ goto st28
+ }
+ goto tr6
+ st28:
+ if (m.p)++; (m.p) == (m.pe) {
+ goto _testEof28
+ }
+ stCase28:
+ switch (m.data)[(m.p)] {
+ case 45:
+ goto st29
+ case 58:
+ goto tr10
+ }
+ switch {
+ case (m.data)[(m.p)] < 65:
+ if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 {
+ goto st29
+ }
+ case (m.data)[(m.p)] > 90:
+ if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 {
+ goto st29
+ }
+ default:
+ goto st29
+ }
+ goto tr6
+ st29:
+ if (m.p)++; (m.p) == (m.pe) {
+ goto _testEof29
+ }
+ stCase29:
+ switch (m.data)[(m.p)] {
+ case 45:
+ goto st30
+ case 58:
+ goto tr10
+ }
+ switch {
+ case (m.data)[(m.p)] < 65:
+ if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 {
+ goto st30
+ }
+ case (m.data)[(m.p)] > 90:
+ if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 {
+ goto st30
+ }
+ default:
+ goto st30
+ }
+ goto tr6
+ st30:
+ if (m.p)++; (m.p) == (m.pe) {
+ goto _testEof30
+ }
+ stCase30:
+ switch (m.data)[(m.p)] {
+ case 45:
+ goto st31
+ case 58:
+ goto tr10
+ }
+ switch {
+ case (m.data)[(m.p)] < 65:
+ if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 {
+ goto st31
+ }
+ case (m.data)[(m.p)] > 90:
+ if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 {
+ goto st31
+ }
+ default:
+ goto st31
+ }
+ goto tr6
+ st31:
+ if (m.p)++; (m.p) == (m.pe) {
+ goto _testEof31
+ }
+ stCase31:
+ switch (m.data)[(m.p)] {
+ case 45:
+ goto st32
+ case 58:
+ goto tr10
+ }
+ switch {
+ case (m.data)[(m.p)] < 65:
+ if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 {
+ goto st32
+ }
+ case (m.data)[(m.p)] > 90:
+ if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 {
+ goto st32
+ }
+ default:
+ goto st32
+ }
+ goto tr6
+ st32:
+ if (m.p)++; (m.p) == (m.pe) {
+ goto _testEof32
+ }
+ stCase32:
+ switch (m.data)[(m.p)] {
+ case 45:
+ goto st33
+ case 58:
+ goto tr10
+ }
+ switch {
+ case (m.data)[(m.p)] < 65:
+ if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 {
+ goto st33
+ }
+ case (m.data)[(m.p)] > 90:
+ if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 {
+ goto st33
+ }
+ default:
+ goto st33
+ }
+ goto tr6
+ st33:
+ if (m.p)++; (m.p) == (m.pe) {
+ goto _testEof33
+ }
+ stCase33:
+ switch (m.data)[(m.p)] {
+ case 45:
+ goto st34
+ case 58:
+ goto tr10
+ }
+ switch {
+ case (m.data)[(m.p)] < 65:
+ if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 {
+ goto st34
+ }
+ case (m.data)[(m.p)] > 90:
+ if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 {
+ goto st34
+ }
+ default:
+ goto st34
+ }
+ goto tr6
+ st34:
+ if (m.p)++; (m.p) == (m.pe) {
+ goto _testEof34
+ }
+ stCase34:
+ switch (m.data)[(m.p)] {
+ case 45:
+ goto st35
+ case 58:
+ goto tr10
+ }
+ switch {
+ case (m.data)[(m.p)] < 65:
+ if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 {
+ goto st35
+ }
+ case (m.data)[(m.p)] > 90:
+ if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 {
+ goto st35
+ }
+ default:
+ goto st35
+ }
+ goto tr6
+ st35:
+ if (m.p)++; (m.p) == (m.pe) {
+ goto _testEof35
+ }
+ stCase35:
+ switch (m.data)[(m.p)] {
+ case 45:
+ goto st36
+ case 58:
+ goto tr10
+ }
+ switch {
+ case (m.data)[(m.p)] < 65:
+ if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 {
+ goto st36
+ }
+ case (m.data)[(m.p)] > 90:
+ if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 {
+ goto st36
+ }
+ default:
+ goto st36
+ }
+ goto tr6
+ st36:
+ if (m.p)++; (m.p) == (m.pe) {
+ goto _testEof36
+ }
+ stCase36:
+ switch (m.data)[(m.p)] {
+ case 45:
+ goto st37
+ case 58:
+ goto tr10
+ }
+ switch {
+ case (m.data)[(m.p)] < 65:
+ if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 {
+ goto st37
+ }
+ case (m.data)[(m.p)] > 90:
+ if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 {
+ goto st37
+ }
+ default:
+ goto st37
+ }
+ goto tr6
+ st37:
+ if (m.p)++; (m.p) == (m.pe) {
+ goto _testEof37
+ }
+ stCase37:
+ if (m.data)[(m.p)] == 58 {
+ goto tr10
+ }
+ goto tr6
+ tr10:
+
+ output.ID = string(m.text())
+
+ goto st38
+ st38:
+ if (m.p)++; (m.p) == (m.pe) {
+ goto _testEof38
+ }
+ stCase38:
+ switch (m.data)[(m.p)] {
+ case 33:
+ goto tr42
+ case 36:
+ goto tr42
+ case 37:
+ goto tr43
+ case 61:
+ goto tr42
+ case 95:
+ goto tr42
+ }
+ switch {
+ case (m.data)[(m.p)] < 48:
+ if 39 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 46 {
+ goto tr42
+ }
+ case (m.data)[(m.p)] > 59:
+ switch {
+ case (m.data)[(m.p)] > 90:
+ if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 {
+ goto tr42
+ }
+ case (m.data)[(m.p)] >= 64:
+ goto tr42
+ }
+ default:
+ goto tr42
+ }
+ goto tr41
+ tr42:
+
+ m.pb = m.p
+
+ goto st44
+ st44:
+ if (m.p)++; (m.p) == (m.pe) {
+ goto _testEof44
+ }
+ stCase44:
+ switch (m.data)[(m.p)] {
+ case 33:
+ goto st44
+ case 36:
+ goto st44
+ case 37:
+ goto st39
+ case 61:
+ goto st44
+ case 95:
+ goto st44
+ }
+ switch {
+ case (m.data)[(m.p)] < 48:
+ if 39 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 46 {
+ goto st44
+ }
+ case (m.data)[(m.p)] > 59:
+ switch {
+ case (m.data)[(m.p)] > 90:
+ if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 {
+ goto st44
+ }
+ case (m.data)[(m.p)] >= 64:
+ goto st44
+ }
+ default:
+ goto st44
+ }
+ goto tr41
+ tr43:
+
+ m.pb = m.p
+
+ goto st39
+ st39:
+ if (m.p)++; (m.p) == (m.pe) {
+ goto _testEof39
+ }
+ stCase39:
+ switch {
+ case (m.data)[(m.p)] < 65:
+ if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 {
+ goto st40
+ }
+ case (m.data)[(m.p)] > 90:
+ if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 {
+ goto st40
+ }
+ default:
+ goto tr46
+ }
+ goto tr44
+ tr46:
+
+ m.tolower = append(m.tolower, m.p-m.pb)
+
+ goto st40
+ st40:
+ if (m.p)++; (m.p) == (m.pe) {
+ goto _testEof40
+ }
+ stCase40:
+ switch {
+ case (m.data)[(m.p)] < 65:
+ if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 {
+ goto st45
+ }
+ case (m.data)[(m.p)] > 90:
+ if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 {
+ goto st45
+ }
+ default:
+ goto tr48
+ }
+ goto tr44
+ tr48:
+
+ m.tolower = append(m.tolower, m.p-m.pb)
+
+ goto st45
+ st45:
+ if (m.p)++; (m.p) == (m.pe) {
+ goto _testEof45
+ }
+ stCase45:
+ switch (m.data)[(m.p)] {
+ case 33:
+ goto st44
+ case 36:
+ goto st44
+ case 37:
+ goto st39
+ case 61:
+ goto st44
+ case 95:
+ goto st44
+ }
+ switch {
+ case (m.data)[(m.p)] < 48:
+ if 39 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 46 {
+ goto st44
+ }
+ case (m.data)[(m.p)] > 59:
+ switch {
+ case (m.data)[(m.p)] > 90:
+ if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 {
+ goto st44
+ }
+ case (m.data)[(m.p)] >= 64:
+ goto st44
+ }
+ default:
+ goto st44
+ }
+ goto tr44
+ tr8:
+
+ m.pb = m.p
+
+ goto st41
+ st41:
+ if (m.p)++; (m.p) == (m.pe) {
+ goto _testEof41
+ }
+ stCase41:
+ switch (m.data)[(m.p)] {
+ case 45:
+ goto st7
+ case 58:
+ goto tr10
+ case 82:
+ goto st42
+ case 114:
+ goto st42
+ }
+ switch {
+ case (m.data)[(m.p)] < 65:
+ if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 {
+ goto st7
+ }
+ case (m.data)[(m.p)] > 90:
+ if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 {
+ goto st7
+ }
+ default:
+ goto st7
+ }
+ goto tr6
+ st42:
+ if (m.p)++; (m.p) == (m.pe) {
+ goto _testEof42
+ }
+ stCase42:
+ switch (m.data)[(m.p)] {
+ case 45:
+ goto st8
+ case 58:
+ goto tr10
+ case 78:
+ goto st43
+ case 110:
+ goto st43
+ }
+ switch {
+ case (m.data)[(m.p)] < 65:
+ if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 {
+ goto st8
+ }
+ case (m.data)[(m.p)] > 90:
+ if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 {
+ goto st8
+ }
+ default:
+ goto st8
+ }
+ goto tr50
+ st43:
+ if (m.p)++; (m.p) == (m.pe) {
+ goto _testEof43
+ }
+ stCase43:
+ if (m.data)[(m.p)] == 45 {
+ goto st9
+ }
+ switch {
+ case (m.data)[(m.p)] < 65:
+ if 48 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 57 {
+ goto st9
+ }
+ case (m.data)[(m.p)] > 90:
+ if 97 <= (m.data)[(m.p)] && (m.data)[(m.p)] <= 122 {
+ goto st9
+ }
+ default:
+ goto st9
+ }
+ goto tr52
+ st46:
+ if (m.p)++; (m.p) == (m.pe) {
+ goto _testEof46
+ }
+ stCase46:
+ switch (m.data)[(m.p)] {
+ case 10:
+ goto st0
+ case 13:
+ goto st0
+ }
+ goto st46
+ stOut:
+ _testEof2:
+ m.cs = 2
+ goto _testEof
+ _testEof3:
+ m.cs = 3
+ goto _testEof
+ _testEof4:
+ m.cs = 4
+ goto _testEof
+ _testEof5:
+ m.cs = 5
+ goto _testEof
+ _testEof6:
+ m.cs = 6
+ goto _testEof
+ _testEof7:
+ m.cs = 7
+ goto _testEof
+ _testEof8:
+ m.cs = 8
+ goto _testEof
+ _testEof9:
+ m.cs = 9
+ goto _testEof
+ _testEof10:
+ m.cs = 10
+ goto _testEof
+ _testEof11:
+ m.cs = 11
+ goto _testEof
+ _testEof12:
+ m.cs = 12
+ goto _testEof
+ _testEof13:
+ m.cs = 13
+ goto _testEof
+ _testEof14:
+ m.cs = 14
+ goto _testEof
+ _testEof15:
+ m.cs = 15
+ goto _testEof
+ _testEof16:
+ m.cs = 16
+ goto _testEof
+ _testEof17:
+ m.cs = 17
+ goto _testEof
+ _testEof18:
+ m.cs = 18
+ goto _testEof
+ _testEof19:
+ m.cs = 19
+ goto _testEof
+ _testEof20:
+ m.cs = 20
+ goto _testEof
+ _testEof21:
+ m.cs = 21
+ goto _testEof
+ _testEof22:
+ m.cs = 22
+ goto _testEof
+ _testEof23:
+ m.cs = 23
+ goto _testEof
+ _testEof24:
+ m.cs = 24
+ goto _testEof
+ _testEof25:
+ m.cs = 25
+ goto _testEof
+ _testEof26:
+ m.cs = 26
+ goto _testEof
+ _testEof27:
+ m.cs = 27
+ goto _testEof
+ _testEof28:
+ m.cs = 28
+ goto _testEof
+ _testEof29:
+ m.cs = 29
+ goto _testEof
+ _testEof30:
+ m.cs = 30
+ goto _testEof
+ _testEof31:
+ m.cs = 31
+ goto _testEof
+ _testEof32:
+ m.cs = 32
+ goto _testEof
+ _testEof33:
+ m.cs = 33
+ goto _testEof
+ _testEof34:
+ m.cs = 34
+ goto _testEof
+ _testEof35:
+ m.cs = 35
+ goto _testEof
+ _testEof36:
+ m.cs = 36
+ goto _testEof
+ _testEof37:
+ m.cs = 37
+ goto _testEof
+ _testEof38:
+ m.cs = 38
+ goto _testEof
+ _testEof44:
+ m.cs = 44
+ goto _testEof
+ _testEof39:
+ m.cs = 39
+ goto _testEof
+ _testEof40:
+ m.cs = 40
+ goto _testEof
+ _testEof45:
+ m.cs = 45
+ goto _testEof
+ _testEof41:
+ m.cs = 41
+ goto _testEof
+ _testEof42:
+ m.cs = 42
+ goto _testEof
+ _testEof43:
+ m.cs = 43
+ goto _testEof
+ _testEof46:
+ m.cs = 46
+ goto _testEof
+
+ _testEof:
+ {
+ }
+ if (m.p) == (m.eof) {
+ switch m.cs {
+ case 44, 45:
+
+ raw := m.text()
+ output.SS = string(raw)
+ // Iterate upper letters lowering them
+ for _, i := range m.tolower {
+ raw[i] = raw[i] + 32
+ }
+ output.norm = string(raw)
+
+ case 1, 2, 4:
+
+ m.err = fmt.Errorf(errParse, m.p)
+ (m.p)--
+
+ {
+ goto st46
+ }
+
+ case 3:
+
+ m.err = fmt.Errorf(errPrefix, m.p)
+ (m.p)--
+
+ {
+ goto st46
+ }
+
+ m.err = fmt.Errorf(errParse, m.p)
+ (m.p)--
+
+ {
+ goto st46
+ }
+
+ case 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 41:
+
+ m.err = fmt.Errorf(errIdentifier, m.p)
+ (m.p)--
+
+ {
+ goto st46
+ }
+
+ m.err = fmt.Errorf(errParse, m.p)
+ (m.p)--
+
+ {
+ goto st46
+ }
+
+ case 38:
+
+ m.err = fmt.Errorf(errSpecificString, m.p)
+ (m.p)--
+
+ {
+ goto st46
+ }
+
+ m.err = fmt.Errorf(errParse, m.p)
+ (m.p)--
+
+ {
+ goto st46
+ }
+
+ case 42:
+
+ m.err = fmt.Errorf(errPrefix, m.p)
+ (m.p)--
+
+ {
+ goto st46
+ }
+
+ m.err = fmt.Errorf(errIdentifier, m.p)
+ (m.p)--
+
+ {
+ goto st46
+ }
+
+ m.err = fmt.Errorf(errParse, m.p)
+ (m.p)--
+
+ {
+ goto st46
+ }
+
+ case 43:
+
+ m.err = fmt.Errorf(errNoUrnWithinID, m.p)
+ (m.p)--
+
+ {
+ goto st46
+ }
+
+ m.err = fmt.Errorf(errIdentifier, m.p)
+ (m.p)--
+
+ {
+ goto st46
+ }
+
+ m.err = fmt.Errorf(errParse, m.p)
+ (m.p)--
+
+ {
+ goto st46
+ }
+
+ case 39, 40:
+
+ m.err = fmt.Errorf(errHex, m.p)
+ (m.p)--
+
+ {
+ goto st46
+ }
+
+ m.err = fmt.Errorf(errSpecificString, m.p)
+ (m.p)--
+
+ {
+ goto st46
+ }
+
+ m.err = fmt.Errorf(errParse, m.p)
+ (m.p)--
+
+ {
+ goto st46
+ }
+
+ }
+ }
+
+ _out:
+ {
+ }
+ }
+
+ if m.cs < firstFinal || m.cs == enFail {
+ return nil, m.err
+ }
+
+ return output, nil
+}
diff --git a/baas-kubeengine/vendor/github.com/leodido/go-urn/machine.go.rl b/baas-kubeengine/vendor/github.com/leodido/go-urn/machine.go.rl
new file mode 100644
index 00000000..3bc05a65
--- /dev/null
+++ b/baas-kubeengine/vendor/github.com/leodido/go-urn/machine.go.rl
@@ -0,0 +1,159 @@
+package urn
+
+import (
+ "fmt"
+)
+
+var (
+ errPrefix = "expecting the prefix to be the \"urn\" string (whatever case) [col %d]"
+ errIdentifier = "expecting the identifier to be string (1..31 alnum chars, also containing dashes but not at its start) [col %d]"
+ errSpecificString = "expecting the specific string to be a string containing alnum, hex, or others ([()+,-.:=@;$_!*']) chars [col %d]"
+ errNoUrnWithinID = "expecting the identifier to not contain the \"urn\" reserved string [col %d]"
+ errHex = "expecting the specific string hex chars to be well-formed (%%alnum{2}) [col %d]"
+ errParse = "parsing error [col %d]"
+)
+
+%%{
+machine urn;
+
+# unsigned alphabet
+alphtype uint8;
+
+action mark {
+ m.pb = m.p
+}
+
+action tolower {
+ m.tolower = append(m.tolower, m.p - m.pb)
+}
+
+action set_pre {
+ output.prefix = string(m.text())
+}
+
+action set_nid {
+ output.ID = string(m.text())
+}
+
+action set_nss {
+ raw := m.text()
+ output.SS = string(raw)
+ // Iterate upper letters lowering them
+ for _, i := range m.tolower {
+ raw[i] = raw[i] + 32
+ }
+ output.norm = string(raw)
+}
+
+action err_pre {
+ m.err = fmt.Errorf(errPrefix, m.p)
+ fhold;
+ fgoto fail;
+}
+
+action err_nid {
+ m.err = fmt.Errorf(errIdentifier, m.p)
+ fhold;
+ fgoto fail;
+}
+
+action err_nss {
+ m.err = fmt.Errorf(errSpecificString, m.p)
+ fhold;
+ fgoto fail;
+}
+
+action err_urn {
+ m.err = fmt.Errorf(errNoUrnWithinID, m.p)
+ fhold;
+ fgoto fail;
+}
+
+action err_hex {
+ m.err = fmt.Errorf(errHex, m.p)
+ fhold;
+ fgoto fail;
+}
+
+action err_parse {
+ m.err = fmt.Errorf(errParse, m.p)
+ fhold;
+ fgoto fail;
+}
+
+pre = ([uU][rR][nN] @err(err_pre)) >mark %set_pre;
+
+nid = (alnum >mark (alnum | '-'){0,31}) %set_nid;
+
+hex = '%' (digit | lower | upper >tolower){2} $err(err_hex);
+
+sss = (alnum | [()+,\-.:=@;$_!*']);
+
+nss = (sss | hex)+ $err(err_nss);
+
+fail := (any - [\n\r])* @err{ fgoto main; };
+
+main := (pre ':' (nid - pre %err(err_urn)) $err(err_nid) ':' nss >mark %set_nss) $err(err_parse);
+
+}%%
+
+%% write data noerror noprefix;
+
+// Machine is the interface representing the FSM
+type Machine interface {
+ Error() error
+ Parse(input []byte) (*URN, error)
+}
+
+type machine struct {
+ data []byte
+ cs int
+ p, pe, eof, pb int
+ err error
+ tolower []int
+}
+
+// NewMachine creates a new FSM able to parse RFC 2141 strings.
+func NewMachine() Machine {
+ m := &machine{}
+
+ %% access m.;
+ %% variable p m.p;
+ %% variable pe m.pe;
+ %% variable eof m.eof;
+ %% variable data m.data;
+
+ return m
+}
+
+// Err returns the error that occurred on the last call to Parse.
+//
+// If the result is nil, then the line was parsed successfully.
+func (m *machine) Error() error {
+ return m.err
+}
+
+func (m *machine) text() []byte {
+ return m.data[m.pb:m.p]
+}
+
+// Parse parses the input byte array as a RFC 2141 string.
+func (m *machine) Parse(input []byte) (*URN, error) {
+ m.data = input
+ m.p = 0
+ m.pb = 0
+ m.pe = len(input)
+ m.eof = len(input)
+ m.err = nil
+ m.tolower = []int{}
+ output := &URN{}
+
+ %% write init;
+ %% write exec;
+
+ if m.cs < first_final || m.cs == en_fail {
+ return nil, m.err
+ }
+
+ return output, nil
+}
diff --git a/baas-kubeengine/vendor/github.com/leodido/go-urn/makefile b/baas-kubeengine/vendor/github.com/leodido/go-urn/makefile
new file mode 100644
index 00000000..47026d50
--- /dev/null
+++ b/baas-kubeengine/vendor/github.com/leodido/go-urn/makefile
@@ -0,0 +1,39 @@
+SHELL := /bin/bash
+
+build: machine.go
+
+images: docs/urn.png
+
+machine.go: machine.go.rl
+ ragel -Z -G2 -e -o $@ $<
+ @sed -i '/^\/\/line/d' $@
+ @$(MAKE) -s file=$@ snake2camel
+ @gofmt -w -s $@
+
+docs/urn.dot: machine.go.rl
+ @mkdir -p docs
+ ragel -Z -e -Vp $< -o $@
+
+docs/urn.png: docs/urn.dot
+ dot $< -Tpng -o $@
+
+.PHONY: bench
+bench: *_test.go machine.go
+ go test -bench=. -benchmem -benchtime=5s ./...
+
+.PHONY: tests
+tests: *_test.go machine.go
+ go test -race -timeout 10s -coverprofile=coverage.out -covermode=atomic -v ./...
+
+.PHONY: clean
+clean:
+ @rm -rf docs
+ @rm -f machine.go
+
+.PHONY: snake2camel
+snake2camel:
+ @awk -i inplace '{ \
+ while ( match($$0, /(.*)([a-z]+[0-9]*)_([a-zA-Z0-9])(.*)/, cap) ) \
+ $$0 = cap[1] cap[2] toupper(cap[3]) cap[4]; \
+ print \
+ }' $(file)
\ No newline at end of file
diff --git a/baas-kubeengine/vendor/github.com/leodido/go-urn/urn.go b/baas-kubeengine/vendor/github.com/leodido/go-urn/urn.go
new file mode 100644
index 00000000..b903b7b3
--- /dev/null
+++ b/baas-kubeengine/vendor/github.com/leodido/go-urn/urn.go
@@ -0,0 +1,63 @@
+package urn
+
+import (
+ "strings"
+)
+
+// URN represents an Uniform Resource Name.
+//
+// The general form represented is:
+//
+// urn::
+//
+// Details at https://tools.ietf.org/html/rfc2141.
+type URN struct {
+ prefix string // Static prefix. Equal to "urn" when empty.
+ ID string // Namespace identifier
+ SS string // Namespace specific string
+ norm string // Normalized namespace specific string
+}
+
+// Normalize turns the receiving URN into its norm version.
+//
+// Which means: lowercase prefix, lowercase namespace identifier, and immutate namespace specific string chars (except tokens which are lowercased).
+func (u *URN) Normalize() *URN {
+ return &URN{
+ prefix: "urn",
+ ID: strings.ToLower(u.ID),
+ SS: u.norm,
+ }
+}
+
+// Equal checks the lexical equivalence of the current URN with another one.
+func (u *URN) Equal(x *URN) bool {
+ return *u.Normalize() == *x.Normalize()
+}
+
+// String reassembles the URN into a valid URN string.
+//
+// This requires both ID and SS fields to be non-empty.
+// Otherwise it returns an empty string.
+//
+// Default URN prefix is "urn".
+func (u *URN) String() string {
+ var res string
+ if u.ID != "" && u.SS != "" {
+ if u.prefix == "" {
+ res += "urn"
+ }
+ res += u.prefix + ":" + u.ID + ":" + u.SS
+ }
+
+ return res
+}
+
+// Parse is responsible to create an URN instance from a byte array matching the correct URN syntax.
+func Parse(u []byte) (*URN, bool) {
+ urn, err := NewMachine().Parse(u)
+ if err != nil {
+ return nil, false
+ }
+
+ return urn, true
+}
diff --git a/baas-kubeengine/vendor/github.com/mattn/go-isatty/.travis.yml b/baas-kubeengine/vendor/github.com/mattn/go-isatty/.travis.yml
index 5597e026..604314dd 100644
--- a/baas-kubeengine/vendor/github.com/mattn/go-isatty/.travis.yml
+++ b/baas-kubeengine/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/baas-kubeengine/vendor/github.com/mattn/go-isatty/README.md b/baas-kubeengine/vendor/github.com/mattn/go-isatty/README.md
index 1e69004b..38418353 100644
--- a/baas-kubeengine/vendor/github.com/mattn/go-isatty/README.md
+++ b/baas-kubeengine/vendor/github.com/mattn/go-isatty/README.md
@@ -1,7 +1,7 @@
# go-isatty
[![Godoc Reference](https://godoc.org/github.com/mattn/go-isatty?status.svg)](http://godoc.org/github.com/mattn/go-isatty)
-[![Build Status](https://travis-ci.org/mattn/go-isatty.svg?branch=master)](https://travis-ci.org/mattn/go-isatty)
+[![Codecov](https://codecov.io/gh/mattn/go-isatty/branch/master/graph/badge.svg)](https://codecov.io/gh/mattn/go-isatty)
[![Coverage Status](https://coveralls.io/repos/github/mattn/go-isatty/badge.svg?branch=master)](https://coveralls.io/github/mattn/go-isatty?branch=master)
[![Go Report Card](https://goreportcard.com/badge/mattn/go-isatty)](https://goreportcard.com/report/mattn/go-isatty)
diff --git a/baas-kubeengine/vendor/github.com/mattn/go-isatty/go.mod b/baas-kubeengine/vendor/github.com/mattn/go-isatty/go.mod
index f310320c..605c4c22 100644
--- a/baas-kubeengine/vendor/github.com/mattn/go-isatty/go.mod
+++ b/baas-kubeengine/vendor/github.com/mattn/go-isatty/go.mod
@@ -1,3 +1,5 @@
module github.com/mattn/go-isatty
-require golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223
+go 1.12
+
+require golang.org/x/sys v0.0.0-20200116001909-b77594299b42
diff --git a/baas-kubeengine/vendor/github.com/mattn/go-isatty/go.sum b/baas-kubeengine/vendor/github.com/mattn/go-isatty/go.sum
index 426c8973..912e29cb 100644
--- a/baas-kubeengine/vendor/github.com/mattn/go-isatty/go.sum
+++ b/baas-kubeengine/vendor/github.com/mattn/go-isatty/go.sum
@@ -1,2 +1,2 @@
-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/sys v0.0.0-20200116001909-b77594299b42 h1:vEOn+mP2zCOVzKckCZy6YsCtDblrpj/w7B9nxGNELpg=
+golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
diff --git a/baas-kubeengine/vendor/github.com/mattn/go-isatty/go.test.sh b/baas-kubeengine/vendor/github.com/mattn/go-isatty/go.test.sh
new file mode 100644
index 00000000..012162b0
--- /dev/null
+++ b/baas-kubeengine/vendor/github.com/mattn/go-isatty/go.test.sh
@@ -0,0 +1,12 @@
+#!/usr/bin/env bash
+
+set -e
+echo "" > coverage.txt
+
+for d in $(go list ./... | grep -v vendor); do
+ go test -race -coverprofile=profile.out -covermode=atomic "$d"
+ if [ -f profile.out ]; then
+ cat profile.out >> coverage.txt
+ rm profile.out
+ fi
+done
diff --git a/baas-kubeengine/vendor/github.com/mattn/go-isatty/isatty_android.go b/baas-kubeengine/vendor/github.com/mattn/go-isatty/isatty_android.go
deleted file mode 100644
index d3567cb5..00000000
--- a/baas-kubeengine/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/baas-kubeengine/vendor/github.com/mattn/go-isatty/isatty_bsd.go b/baas-kubeengine/vendor/github.com/mattn/go-isatty/isatty_bsd.go
index 07e93039..711f2880 100644
--- a/baas-kubeengine/vendor/github.com/mattn/go-isatty/isatty_bsd.go
+++ b/baas-kubeengine/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/baas-kubeengine/vendor/github.com/mattn/go-isatty/isatty_others.go b/baas-kubeengine/vendor/github.com/mattn/go-isatty/isatty_others.go
index f02849c5..ff714a37 100644
--- a/baas-kubeengine/vendor/github.com/mattn/go-isatty/isatty_others.go
+++ b/baas-kubeengine/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/baas-kubeengine/vendor/github.com/mattn/go-isatty/isatty_plan9.go b/baas-kubeengine/vendor/github.com/mattn/go-isatty/isatty_plan9.go
new file mode 100644
index 00000000..c5b6e0c0
--- /dev/null
+++ b/baas-kubeengine/vendor/github.com/mattn/go-isatty/isatty_plan9.go
@@ -0,0 +1,22 @@
+// +build plan9
+
+package isatty
+
+import (
+ "syscall"
+)
+
+// IsTerminal returns true if the given file descriptor is a terminal.
+func IsTerminal(fd uintptr) bool {
+ path, err := syscall.Fd2path(int(fd))
+ if err != nil {
+ return false
+ }
+ return path == "/dev/cons" || path == "/mnt/term/dev/cons"
+}
+
+// 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/baas-kubeengine/vendor/github.com/mattn/go-isatty/isatty_linux.go b/baas-kubeengine/vendor/github.com/mattn/go-isatty/isatty_tcgets.go
similarity index 92%
rename from baas-kubeengine/vendor/github.com/mattn/go-isatty/isatty_linux.go
rename to baas-kubeengine/vendor/github.com/mattn/go-isatty/isatty_tcgets.go
index 4f8af465..31a1ca97 100644
--- a/baas-kubeengine/vendor/github.com/mattn/go-isatty/isatty_linux.go
+++ b/baas-kubeengine/vendor/github.com/mattn/go-isatty/isatty_tcgets.go
@@ -1,6 +1,5 @@
-// +build linux
+// +build linux aix
// +build !appengine
-// +build !android
package isatty
diff --git a/baas-kubeengine/vendor/github.com/mattn/go-isatty/isatty_windows.go b/baas-kubeengine/vendor/github.com/mattn/go-isatty/isatty_windows.go
index af51cbca..1fa86915 100644
--- a/baas-kubeengine/vendor/github.com/mattn/go-isatty/isatty_windows.go
+++ b/baas-kubeengine/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/baas-kubeengine/vendor/github.com/mattn/go-isatty/renovate.json b/baas-kubeengine/vendor/github.com/mattn/go-isatty/renovate.json
new file mode 100644
index 00000000..5ae9d96b
--- /dev/null
+++ b/baas-kubeengine/vendor/github.com/mattn/go-isatty/renovate.json
@@ -0,0 +1,8 @@
+{
+ "extends": [
+ "config:base"
+ ],
+ "postUpdateOptions": [
+ "gomodTidy"
+ ]
+}
diff --git a/baas-kubeengine/vendor/github.com/pelletier/go-toml/example-crlf.toml b/baas-kubeengine/vendor/github.com/pelletier/go-toml/example-crlf.toml
index 3d902f28..12950a16 100644
--- a/baas-kubeengine/vendor/github.com/pelletier/go-toml/example-crlf.toml
+++ b/baas-kubeengine/vendor/github.com/pelletier/go-toml/example-crlf.toml
@@ -1,29 +1,29 @@
-# This is a TOML document. Boom.
-
-title = "TOML Example"
-
-[owner]
-name = "Tom Preston-Werner"
-organization = "GitHub"
-bio = "GitHub Cofounder & CEO\nLikes tater tots and beer."
-dob = 1979-05-27T07:32:00Z # First class dates? Why not?
-
-[database]
-server = "192.168.1.1"
-ports = [ 8001, 8001, 8002 ]
-connection_max = 5000
-enabled = true
-
-[servers]
-
- # You can indent as you please. Tabs or spaces. TOML don't care.
- [servers.alpha]
- ip = "10.0.0.1"
- dc = "eqdc10"
-
- [servers.beta]
- ip = "10.0.0.2"
- dc = "eqdc10"
-
-[clients]
-data = [ ["gamma", "delta"], [1, 2] ] # just an update to make sure parsers support it
+# This is a TOML document. Boom.
+
+title = "TOML Example"
+
+[owner]
+name = "Tom Preston-Werner"
+organization = "GitHub"
+bio = "GitHub Cofounder & CEO\nLikes tater tots and beer."
+dob = 1979-05-27T07:32:00Z # First class dates? Why not?
+
+[database]
+server = "192.168.1.1"
+ports = [ 8001, 8001, 8002 ]
+connection_max = 5000
+enabled = true
+
+[servers]
+
+ # You can indent as you please. Tabs or spaces. TOML don't care.
+ [servers.alpha]
+ ip = "10.0.0.1"
+ dc = "eqdc10"
+
+ [servers.beta]
+ ip = "10.0.0.2"
+ dc = "eqdc10"
+
+[clients]
+data = [ ["gamma", "delta"], [1, 2] ] # just an update to make sure parsers support it
diff --git a/baas-kubeengine/vendor/github.com/spf13/afero/.travis.yml b/baas-kubeengine/vendor/github.com/spf13/afero/.travis.yml
index 8fc1261c..0637db72 100644
--- a/baas-kubeengine/vendor/github.com/spf13/afero/.travis.yml
+++ b/baas-kubeengine/vendor/github.com/spf13/afero/.travis.yml
@@ -1,21 +1,21 @@
-sudo: false
-language: go
-
-go:
- - 1.9
- - "1.10"
- - tip
-
-os:
- - linux
- - osx
-
-matrix:
- allow_failures:
- - go: tip
- fast_finish: true
-
-script:
- - go build
- - go test -race -v ./...
-
+sudo: false
+language: go
+
+go:
+ - 1.9
+ - "1.10"
+ - tip
+
+os:
+ - linux
+ - osx
+
+matrix:
+ allow_failures:
+ - go: tip
+ fast_finish: true
+
+script:
+ - go build
+ - go test -race -v ./...
+
diff --git a/baas-kubeengine/vendor/github.com/ugorji/go/LICENSE b/baas-kubeengine/vendor/github.com/ugorji/go/codec/LICENSE
similarity index 100%
rename from baas-kubeengine/vendor/github.com/ugorji/go/LICENSE
rename to baas-kubeengine/vendor/github.com/ugorji/go/codec/LICENSE
diff --git a/baas-kubeengine/vendor/github.com/ugorji/go/codec/README.md b/baas-kubeengine/vendor/github.com/ugorji/go/codec/README.md
deleted file mode 100644
index 8aa68f5b..00000000
--- a/baas-kubeengine/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 and TextUnmarshaler?
- - 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/baas-kubeengine/vendor/github.com/ugorji/go/codec/binc.go b/baas-kubeengine/vendor/github.com/ugorji/go/codec/binc.go
index c9877ac7..802b32cf 100644
--- a/baas-kubeengine/vendor/github.com/ugorji/go/codec/binc.go
+++ b/baas-kubeengine/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,15 +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:
- decNakedReadRawBytes(d, d.d, n, d.h.RawToString)
+ 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)
}
@@ -943,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
@@ -985,7 +962,7 @@ func (d *bincDecDriver) DecodeNaked() {
type BincHandle struct {
BasicHandle
binaryEncodingType
- noElemSeparators
+ // noElemSeparators
// AsSymbols defines what should be encoded as symbols.
//
@@ -1007,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'}
@@ -1091,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
@@ -1123,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)
@@ -1152,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[:]))
@@ -1173,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
@@ -1199,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/baas-kubeengine/vendor/github.com/ugorji/go/codec/build.sh b/baas-kubeengine/vendor/github.com/ugorji/go/codec/build.sh
index c0853078..a71227fb 100644
--- a/baas-kubeengine/vendor/github.com/ugorji/go/codec/build.sh
+++ b/baas-kubeengine/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,60 +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
+ 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
- local c9="codecgen-scratch.go"
- local c7="$zmydir/codecgen"
true &&
echo "codecgen ... " &&
- if [[ $zforce || ! -f "$c7/codecgen" || "$c7/gen.go" -nt "$c7/codecgen" ]]; then
- echo "rebuilding codecgen ... " && ( cd codecgen && go build -o codecgen ${zargs[*]} . )
+ if [[ $zforce || ! -f "$c8" || "$c7/gen.go" -nt "$c8" ]]; then
+ echo "rebuilding codecgen ... " && ( cd codecgen && go build -o $c8 ${zargs[*]} . )
fi &&
- $c7/codecgen -rt codecgen -t 'codecgen generated' -o values_codecgen${zsfx} -d 19780 $zfin $zfin2 &&
+ $c8 -rt codecgen -t 'codecgen generated' -o values_codecgen${c5} -d 19780 $zfin $zfin2 &&
cp mammoth2_generated_test.go $c9 &&
- $c7/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
+ zforce=${makeforce}
}
_clean() {
@@ -194,6 +201,7 @@ _release() {
EOF
# # go 1.6 and below kept giving memory errors on Mac OS X during SDK build or go run execution,
# # that is fine, as we only explicitly test the last 3 releases and tip (2 years).
+ local makeforce=${zforce}
zforce=1
for i in 1.10 1.11 1.12 master
do
@@ -210,7 +218,7 @@ EOF
_tests "$@"
if [[ "$?" != 0 ]]; then return 1; fi
done
- unset zforce
+ zforce=${makeforce}
echo "++++++++ RELEASE TEST SUITES ALL PASSED ++++++++"
}
@@ -226,16 +234,16 @@ EOF
_main() {
if [[ -z "$1" ]]; then _usage; return 1; fi
local x
- unset zforce zexternal
- zargs=()
- zbenchflags=""
+ local zforce
+ local zargs=()
+ local zverbose=()
+ local zbenchflags=""
OPTIND=1
- while getopts ":ctmnrgupfvxlzdb:" flag
+ while getopts ":ctmnrgpfvlyzdb:" flag
do
case "x$flag" in
'xf') zforce=1 ;;
- 'xx') zexternal=1 ;;
- 'xv') zverbose=1 ;;
+ 'xv') zverbose+=(1) ;;
'xl') zargs+=("-gcflags"); zargs+=("-l=4") ;;
'xn') zargs+=("-gcflags"); zargs+=("-m=2") ;;
'xd') zargs+=("-race") ;;
@@ -251,13 +259,13 @@ _main() {
'xm') _make "$@" ;;
'xr') _release "$@" ;;
'xg') _go ;;
- 'xu') _githubupdate ;;
'xp') _prebuild "$@" ;;
'xc') _clean "$@" ;;
+ 'xy') _analyze_extra "$@" ;;
'xz') _analyze "$@" ;;
'xb') _bench "$@" ;;
esac
- unset zforce zexternal
+ # unset zforce zargs zbenchflags
}
[ "." = `dirname $0` ] && _main "$@"
diff --git a/baas-kubeengine/vendor/github.com/ugorji/go/codec/cbor.go b/baas-kubeengine/vendor/github.com/ugorji/go/codec/cbor.go
index 7833f9d6..d84fbb22 100644
--- a/baas-kubeengine/vendor/github.com/ugorji/go/codec/cbor.go
+++ b/baas-kubeengine/vendor/github.com/ugorji/go/codec/cbor.go
@@ -5,21 +5,22 @@ package codec
import (
"math"
- "reflect"
"time"
)
+// major
const (
cborMajorUint byte = iota
cborMajorNegInt
cborMajorBytes
- cborMajorText
+ cborMajorString
cborMajorArray
cborMajorMap
cborMajorTag
- cborMajorOther
+ cborMajorSimpleOrFloat
)
+// simple
const (
cborBdFalse byte = 0xf4 + iota
cborBdTrue
@@ -31,6 +32,7 @@ const (
cborBdFloat64
)
+// indefinite
const (
cborBdIndefiniteBytes byte = 0x5f
cborBdIndefiniteString byte = 0x7f
@@ -49,6 +51,7 @@ const (
CborStreamBreak byte = 0xff
)
+// base values
const (
cborBaseUint byte = 0x00
cborBaseNegInt byte = 0x20
@@ -60,44 +63,51 @@ const (
cborBaseSimple byte = 0xe0
)
+// const (
+// cborSelfDesrTag byte = 0xd9
+// cborSelfDesrTag2 byte = 0xd9
+// cborSelfDesrTag3 byte = 0xf7
+// )
+
func cbordesc(bd byte) string {
- 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:
- switch {
- case bd >= 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,74 +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:
- decNakedReadRawBytes(d, d.d, n, d.h.RawToString)
- 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:
- decNakedReadRawBytes(d, d.d, n, d.h.RawToString)
- 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
}
@@ -725,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
@@ -735,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/baas-kubeengine/vendor/github.com/ugorji/go/codec/decode.go b/baas-kubeengine/vendor/github.com/ugorji/go/codec/decode.go
index 1f14e7a5..a33252bd 100644
--- a/baas-kubeengine/vendor/github.com/ugorji/go/codec/decode.go
+++ b/baas-kubeengine/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,6 +260,10 @@ 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
// RawToString controls how raw bytes in a stream are decoded into a nil interface{}.
@@ -263,986 +271,136 @@ type DecodeOptions struct {
RawToString 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
-}
-
-// ------------------------------------------
-
-// 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 (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 (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 (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
- }
- 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]
- }
- }
-}
-
-// ------------------------------------
-
-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 (z *bufioDecReader) release() {
- z.buf = nil
- z.bytesBufPooler.end()
-}
-
-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)
- }
-}
-
-//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 (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 (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
-}
+// ----------------------------------------
-//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) rawExt(f *codecFnInfo, rv reflect.Value) {
+ d.d.DecodeExt(rv2i(rv), 0, nil)
}
-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) ext(f *codecFnInfo, rv reflect.Value) {
+ d.d.DecodeExt(rv2i(rv), f.xfTag, f.xfFn)
}
-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) selferUnmarshal(f *codecFnInfo, rv reflect.Value) {
+ rv2i(rv).(Selfer).CodecDecodeSelf(d)
}
-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) 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 (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)
+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)
}
- z.c = i
- return
}
-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
+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)
}
- return z.readToFill(in, accept)
}
-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) kErr(f *codecFnInfo, rv reflect.Value) {
+ d.errorf("no decoding function defined for kind %v", rv.Kind())
}
-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) raw(f *codecFnInfo, rv reflect.Value) {
+ rvSetBytes(rv, d.rawBytes())
}
-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) kString(f *codecFnInfo, rv reflect.Value) {
+ rvSetString(rv, string(d.d.DecodeStringAsBytes()))
}
-// ------------------------------------
-
-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) kBool(f *codecFnInfo, rv reflect.Value) {
+ rvSetBool(rv, d.d.DecodeBool())
}
-func (z *bytesDecReader) reset(in []byte) {
- z.b = in
- // z.a = len(in)
- z.c = 0
- z.t = 0
+func (d *Decoder) kTime(f *codecFnInfo, rv reflect.Value) {
+ rvSetTime(rv, d.d.DecodeTime())
}
-func (z *bytesDecReader) numread() uint {
- return z.c
+func (d *Decoder) kFloat32(f *codecFnInfo, rv reflect.Value) {
+ rvSetFloat32(rv, d.decodeFloat32())
}
-func (z *bytesDecReader) unreadn1() {
- if z.c == 0 || len(z.b) == 0 {
- panic(errBytesDecReaderCannotUnread)
- }
- z.c--
- // z.a++
+func (d *Decoder) kFloat64(f *codecFnInfo, rv reflect.Value) {
+ rvSetFloat64(rv, d.d.DecodeFloat64())
}
-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 (d *Decoder) kInt(f *codecFnInfo, rv reflect.Value) {
+ rvSetInt(rv, int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize)))
}
-// 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 (d *Decoder) kInt8(f *codecFnInfo, rv reflect.Value) {
+ rvSetInt8(rv, int8(chkOvf.IntV(d.d.DecodeInt64(), 8)))
}
-func (z *bytesDecReader) track() {
- z.t = z.c
+func (d *Decoder) kInt16(f *codecFnInfo, rv reflect.Value) {
+ rvSetInt16(rv, int16(chkOvf.IntV(d.d.DecodeInt64(), 16)))
}
-func (z *bytesDecReader) stopTrack() (bs []byte) {
- return z.b[z.t:z.c]
+func (d *Decoder) kInt32(f *codecFnInfo, rv reflect.Value) {
+ rvSetInt32(rv, int32(chkOvf.IntV(d.d.DecodeInt64(), 32)))
}
-// ----------------------------------------
-
-// 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) kInt64(f *codecFnInfo, rv reflect.Value) {
+ rvSetInt64(rv, d.d.DecodeInt64())
}
-func (d *Decoder) ext(f *codecFnInfo, rv reflect.Value) {
- d.d.DecodeExt(rv2i(rv), f.xfTag, f.xfFn)
+func (d *Decoder) kUint(f *codecFnInfo, rv reflect.Value) {
+ rvSetUint(rv, uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize)))
}
-func (d *Decoder) selferUnmarshal(f *codecFnInfo, rv reflect.Value) {
- rv2i(rv).(Selfer).CodecDecodeSelf(d)
+func (d *Decoder) kUintptr(f *codecFnInfo, rv reflect.Value) {
+ rvSetUintptr(rv, uintptr(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize)))
}
-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) kUint8(f *codecFnInfo, rv reflect.Value) {
+ rvSetUint8(rv, uint8(chkOvf.UintV(d.d.DecodeUint64(), 8)))
}
-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) kUint16(f *codecFnInfo, rv reflect.Value) {
+ rvSetUint16(rv, uint16(chkOvf.UintV(d.d.DecodeUint64(), 16)))
}
-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) kUint32(f *codecFnInfo, rv reflect.Value) {
+ rvSetUint32(rv, uint32(chkOvf.UintV(d.d.DecodeUint64(), 32)))
}
-func (d *Decoder) kErr(f *codecFnInfo, rv reflect.Value) {
- d.errorf("no decoding function defined for kind %v", rv.Kind())
+func (d *Decoder) kUint64(f *codecFnInfo, rv reflect.Value) {
+ rvSetUint64(rv, d.d.DecodeUint64())
}
-// 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
@@ -1257,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()
@@ -1345,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
}
@@ -1364,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)
}
@@ -1401,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
@@ -1449,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))
@@ -1461,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
@@ -1514,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)
@@ -1588,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()
@@ -1738,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
@@ -1776,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.
@@ -1944,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.
@@ -2286,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.
@@ -2326,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
}
@@ -2334,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
@@ -2395,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()
@@ -2426,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()
}
@@ -2510,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
+ }
}
}()
}
@@ -2532,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)
@@ -2639,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 = ""
@@ -2679,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()))
}
}
}
@@ -2705,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:
@@ -2733,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:
@@ -2753,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 {
@@ -2804,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) {
@@ -2827,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() {
@@ -2864,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() {
@@ -2884,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.
}
@@ -2892,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
}
@@ -2914,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
}
@@ -2978,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)
@@ -2994,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
}
@@ -3022,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
}
@@ -3040,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
@@ -3049,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 {
@@ -3092,7 +2018,6 @@ 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
diff --git a/baas-kubeengine/vendor/github.com/ugorji/go/codec/0doc.go b/baas-kubeengine/vendor/github.com/ugorji/go/codec/doc.go
similarity index 93%
rename from baas-kubeengine/vendor/github.com/ugorji/go/codec/0doc.go
rename to baas-kubeengine/vendor/github.com/ugorji/go/codec/doc.go
index 295ee346..e987fa6b 100644
--- a/baas-kubeengine/vendor/github.com/ugorji/go/codec/0doc.go
+++ b/baas-kubeengine/vendor/github.com/ugorji/go/codec/doc.go
@@ -14,15 +14,9 @@ Supported Serialization formats are:
- 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.
+This package will carefully use 'package 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.
+i.e. 'go install -tags=safe ...'.
For detailed usage information, read the primer at http://ugorji.net/blog/go-codec-primer .
@@ -32,12 +26,12 @@ 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
+ - Support for go 1.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.
+ - 100% safe mode supported, 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
@@ -62,7 +56,7 @@ Rich Feature Set includes:
(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.
+ - Code-generation for faster performance, supported in go 1.6+
- 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)
@@ -100,13 +94,16 @@ 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.
+There is also seamless support provided for registering an extension (with a tag)
+but letting the encoding mechanism default to the standard way.
+
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 type a codec.Selfer?
- 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 and TextUnmarshaler?
@@ -206,6 +203,9 @@ You can run the tag 'safe' to run tests or build in safe mode. e.g.
Running Benchmarks
+ cd bench
+ go test -bench . -benchmem -benchtime 1s
+
Please see http://github.com/ugorji/go-codec-bench .
Caveats
@@ -224,4 +224,3 @@ with some caveats. See Encode documentation.
*/
package codec
-
diff --git a/baas-kubeengine/vendor/github.com/ugorji/go/codec/encode.go b/baas-kubeengine/vendor/github.com/ugorji/go/codec/encode.go
index 8462440c..351dd2d0 100644
--- a/baas-kubeengine/vendor/github.com/ugorji/go/codec/encode.go
+++ b/baas-kubeengine/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,33 +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: use EncodeStringEnc instead
- EncodeString(c charEncoding, v string)
- // Deprecated: use EncodeStringBytesRaw instead
- EncodeStringBytes(c charEncoding, v []byte)
- EncodeStringEnc(c charEncoding, v string) // c cannot be cRAW
- // EncodeSymbol(v string)
+ 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 {
@@ -85,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.
@@ -199,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) {
@@ -467,373 +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()
+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) 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 {
- ee.WriteArrayEnd()
+ e.kSliceW(rv, ti)
}
}
-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) 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 {
+ e.kSliceW(rv, f.ti)
+ }
+ }
+}
+
+func (e *Encoder) kArray(f *codecFnInfo, rv reflect.Value) {
+ if f.ti.mbs {
+ e.kSeqWMbs(rv, f.ti)
+ } else {
+ if uint8TypId == rt2id(f.ti.elem) {
+ e.e.EncodeStringBytesRaw(rvGetArrayBytesRO(rv, e.b[:]))
+ } else {
+ e.kSeqW(rv, f.ti)
+ }
}
+}
- ee := e.e
+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.
- sfn := structFieldNode{v: rv, update: false}
- if toMap {
- ee.WriteMapStart(len(tisfi))
- if e.esep {
- for _, si := range tisfi {
- ee.WriteMapElemKey()
- e.kStructFieldKey(fti.keyType, si.encNameAsciiAlphaNum, si.encName)
- ee.WriteMapElemValue()
- e.encodeValue(sfn.field(si), nil, true)
+ // 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
}
- } else {
- for _, si := range tisfi {
- e.kStructFieldKey(fti.keyType, si.encNameAsciiAlphaNum, si.encName)
- e.encodeValue(sfn.field(si), nil, true)
+ }
+ 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
}
}
- ee.WriteMapEnd()
+ default: // consume until close
+ for b := range ch {
+ bs = append(bs, b)
+ }
+ }
+
+ e.e.EncodeStringBytesRaw(bs)
+}
+
+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 {
- ee.WriteArrayStart(len(tisfi))
- if e.esep {
- for _, si := range tisfi {
- ee.WriteArrayElem()
- e.encodeValue(sfn.field(si), nil, true)
- }
- } else {
- for _, si := range tisfi {
- e.encodeValue(sfn.field(si), nil, true)
- }
+ 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)
}
- ee.WriteArrayEnd()
+ e.mapEnd()
}
}
func (e *Encoder) kStructFieldKey(keyType valueType, encNameAsciiAlphaNum bool, encName string) {
- encStructFieldKey(encName, e.e, e.w, keyType, encNameAsciiAlphaNum, e.js)
+ 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 = fkvs[:newlen]
-
- var mflen int
- for k, v := range mf {
- if k == "" {
- delete(mf, k)
- continue
+ fkvs[newlen] = kv
+ newlen++
}
- 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()
- e.kStructFieldKey(fti.keyType, kv.v.encNameAsciiAlphaNum, kv.v.encName)
- 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]
- e.kStructFieldKey(fti.keyType, kv.v.encNameAsciiAlphaNum, kv.v.encName)
- 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.kStructFieldKey(fti.keyType, false, 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.
@@ -841,67 +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 {
- if e.h.StringToRaw {
- ee.EncodeStringBytesRaw(bytesView(mks[j].String()))
- } else {
- 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))
@@ -912,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))
@@ -930,93 +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()
- }
- if e.h.StringToRaw {
- ee.EncodeStringBytesRaw(bytesView(mksv[i].v))
- } else {
- 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]
@@ -1025,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
}
@@ -1040,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 {
@@ -1052,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
@@ -1225,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.
@@ -1259,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
}
@@ -1270,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
}
@@ -1310,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()
}
@@ -1351,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()
}
@@ -1446,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
}
@@ -1453,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
+ }
}
}()
}
@@ -1479,78 +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:
- if e.h.StringToRaw {
- e.e.EncodeStringBytesRaw(bytesView(v))
- } else {
- e.e.EncodeStringEnc(cUTF8, v)
- }
+ e.e.EncodeString(v)
case bool:
e.e.EncodeBool(v)
case int:
@@ -1583,16 +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:
- if e.h.StringToRaw {
- e.e.EncodeStringBytesRaw(bytesView(*v))
- } else {
- e.e.EncodeStringEnc(cUTF8, *v)
- }
+ e.e.EncodeString(*v)
case *bool:
e.e.EncodeBool(*v)
case *int:
@@ -1623,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
}
@@ -1653,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
}
@@ -1675,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 {
@@ -1690,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 {
@@ -1702,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.EncodeStringBytesRaw(bs)
-// }
-// }
-
func (e *Encoder) marshalUtf8(bs []byte, fnerr error) {
if fnerr != nil {
panic(fnerr)
@@ -1722,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))
}
}
@@ -1733,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)
}
}
@@ -1748,47 +1283,85 @@ 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}}
}
-func encStructFieldKey(encName string, ee encDriver, w *encWriterSwitch,
+// ---- 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.writen1('"')
- // w.writestr(encName)
- // w.writen1('"')
- // ----
- // w.writestr(`"` + encName + `"`)
- // ----
- // do concat myself, so it is faster than the generic string concat
- b := make([]byte, len(encName)+2)
- copy(b[1:], encName)
- b[0] = '"'
- b[len(b)-1] = '"'
- w.writeb(b)
+ w.writeqstr(encName)
} else { // keyType == valueTypeString
- ee.EncodeStringEnc(cUTF8, encName)
+ ee.EncodeString(encName)
}
} else if keyType == valueTypeInt {
ee.EncodeInt(m.Int(strconv.ParseInt(encName, 10, 64)))
@@ -1798,11 +1371,3 @@ func encStructFieldKey(encName string, ee encDriver, w *encWriterSwitch,
ee.EncodeFloat64(m.Float(strconv.ParseFloat(encName, 64)))
}
}
-
-// func encStringAsRawBytesMaybe(ee encDriver, s string, stringToRaw bool) {
-// if stringToRaw {
-// ee.EncodeStringBytesRaw(bytesView(s))
-// } else {
-// ee.EncodeStringEnc(cUTF8, s)
-// }
-// }
diff --git a/baas-kubeengine/vendor/github.com/ugorji/go/codec/fast-path.generated.go b/baas-kubeengine/vendor/github.com/ugorji/go/codec/fast-path.generated.go
index 9bc14bd6..e9b7f230 100644
--- a/baas-kubeengine/vendor/github.com/ugorji/go/codec/fast-path.generated.go
+++ b/baas-kubeengine/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,41 +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))
- for _, v2 := range v {
- if esep {
- ee.WriteArrayElem()
- }
- 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)
- for j, v2 := range v {
- if esep {
+ } 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(v[j])
}
- e.encode(v2)
+ e.mapEnd()
}
- ee.WriteMapEnd()
}
-
func (e *Encoder) fastpathEncSliceStringR(f *codecFnInfo, rv reflect.Value) {
if f.ti.mbs {
fastpathTV.EncAsMapSliceStringV(rv2i(rv).([]string), e)
@@ -1520,217 +880,154 @@ 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
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteArrayStart(len(v))
- for _, v2 := range v {
- if esep {
- ee.WriteArrayElem()
- }
- if e.h.StringToRaw {
- ee.EncodeStringBytesRaw(bytesView(v2))
- } else {
- ee.EncodeStringEnc(cUTF8, v2)
- }
+func (fastpathT) EncSliceStringV(v []string, e *Encoder) {
+ e.arrayStart(len(v))
+ for j := range v {
+ e.arrayElem()
+ e.e.EncodeString(v[j])
}
- ee.WriteArrayEnd()
+ e.arrayEnd()
}
-func (_ fastpathT) EncAsMapSliceStringV(v []string, e *Encoder) {
- ee, esep := e.e, e.hh.hasElemSeparators()
+func (fastpathT) EncAsMapSliceStringV(v []string, e *Encoder) {
if len(v)%2 == 1 {
e.errorf(fastpathMapBySliceErrMsg, len(v))
- return
- }
- ee.WriteMapStart(len(v) / 2)
- for j, v2 := range v {
- if esep {
+ } else {
+ e.mapStart(len(v) / 2)
+ for j := range v {
if j%2 == 0 {
- ee.WriteMapElemKey()
+ e.mapElemKey()
} else {
- ee.WriteMapElemValue()
+ e.mapElemValue()
}
+ e.e.EncodeString(v[j])
}
- if e.h.StringToRaw {
- ee.EncodeStringBytesRaw(bytesView(v2))
- } else {
- ee.EncodeStringEnc(cUTF8, v2)
- }
+ e.mapEnd()
}
- ee.WriteMapEnd()
}
-
-func (e *Encoder) fastpathEncSliceFloat32R(f *codecFnInfo, rv reflect.Value) {
+func (e *Encoder) fastpathEncSliceBytesR(f *codecFnInfo, rv reflect.Value) {
if f.ti.mbs {
- fastpathTV.EncAsMapSliceFloat32V(rv2i(rv).([]float32), e)
+ fastpathTV.EncAsMapSliceBytesV(rv2i(rv).([][]byte), e)
} else {
- fastpathTV.EncSliceFloat32V(rv2i(rv).([]float32), e)
+ fastpathTV.EncSliceBytesV(rv2i(rv).([][]byte), e)
}
}
-func (_ fastpathT) EncSliceFloat32V(v []float32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
+func (fastpathT) EncSliceBytesV(v [][]byte, e *Encoder) {
+ e.arrayStart(len(v))
+ for j := range v {
+ e.arrayElem()
+ e.e.EncodeStringBytesRaw(v[j])
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteArrayStart(len(v))
- for _, v2 := range v {
- if esep {
- ee.WriteArrayElem()
- }
- ee.EncodeFloat32(v2)
- }
- ee.WriteArrayEnd()
+ e.arrayEnd()
}
-func (_ fastpathT) EncAsMapSliceFloat32V(v []float32, 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)
- for j, v2 := range v {
- if esep {
+ } else {
+ e.mapStart(len(v) / 2)
+ for j := range v {
if j%2 == 0 {
- ee.WriteMapElemKey()
+ e.mapElemKey()
} else {
- ee.WriteMapElemValue()
+ e.mapElemValue()
}
+ e.e.EncodeStringBytesRaw(v[j])
}
- ee.EncodeFloat32(v2)
+ e.mapEnd()
}
- ee.WriteMapEnd()
}
-
-func (e *Encoder) fastpathEncSliceFloat64R(f *codecFnInfo, rv reflect.Value) {
+func (e *Encoder) fastpathEncSliceFloat32R(f *codecFnInfo, rv reflect.Value) {
if f.ti.mbs {
- fastpathTV.EncAsMapSliceFloat64V(rv2i(rv).([]float64), e)
+ fastpathTV.EncAsMapSliceFloat32V(rv2i(rv).([]float32), e)
} else {
- fastpathTV.EncSliceFloat64V(rv2i(rv).([]float64), e)
+ fastpathTV.EncSliceFloat32V(rv2i(rv).([]float32), 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))
- for _, v2 := range v {
- if esep {
- ee.WriteArrayElem()
- }
- ee.EncodeFloat64(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) EncAsMapSliceFloat64V(v []float64, 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)
- for j, v2 := range v {
- if esep {
+ } else {
+ e.mapStart(len(v) / 2)
+ for j := range v {
if j%2 == 0 {
- ee.WriteMapElemKey()
+ e.mapElemKey()
} else {
- ee.WriteMapElemValue()
+ e.mapElemValue()
}
+ e.e.EncodeFloat32(v[j])
}
- ee.EncodeFloat64(v2)
+ e.mapEnd()
}
- ee.WriteMapEnd()
}
-
-func (e *Encoder) fastpathEncSliceUintR(f *codecFnInfo, rv reflect.Value) {
+func (e *Encoder) fastpathEncSliceFloat64R(f *codecFnInfo, rv reflect.Value) {
if f.ti.mbs {
- fastpathTV.EncAsMapSliceUintV(rv2i(rv).([]uint), e)
+ fastpathTV.EncAsMapSliceFloat64V(rv2i(rv).([]float64), e)
} else {
- fastpathTV.EncSliceUintV(rv2i(rv).([]uint), e)
+ fastpathTV.EncSliceFloat64V(rv2i(rv).([]float64), e)
}
}
-func (_ fastpathT) EncSliceUintV(v []uint, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteArrayStart(len(v))
- for _, v2 := range v {
- if esep {
- ee.WriteArrayElem()
- }
- ee.EncodeUint(uint64(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) EncAsMapSliceUintV(v []uint, 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)
- for j, v2 := range v {
- if esep {
+ } else {
+ e.mapStart(len(v) / 2)
+ for j := range v {
if j%2 == 0 {
- ee.WriteMapElemKey()
+ e.mapElemKey()
} else {
- ee.WriteMapElemValue()
+ e.mapElemValue()
}
+ e.e.EncodeFloat64(v[j])
}
- ee.EncodeUint(uint64(v2))
+ e.mapEnd()
}
- ee.WriteMapEnd()
}
-
-func (e *Encoder) fastpathEncSliceUint8R(f *codecFnInfo, rv reflect.Value) {
+func (e *Encoder) fastpathEncSliceUintR(f *codecFnInfo, rv reflect.Value) {
if f.ti.mbs {
- fastpathTV.EncAsMapSliceUint8V(rv2i(rv).([]uint8), e)
+ fastpathTV.EncAsMapSliceUintV(rv2i(rv).([]uint), e)
} else {
- fastpathTV.EncSliceUint8V(rv2i(rv).([]uint8), e)
+ fastpathTV.EncSliceUintV(rv2i(rv).([]uint), e)
}
}
-func (_ fastpathT) EncSliceUint8V(v []uint8, 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))
- for _, v2 := range v {
- if esep {
- ee.WriteArrayElem()
- }
- ee.EncodeUint(uint64(v2))
- }
- ee.WriteArrayEnd()
+ e.arrayEnd()
}
-func (_ fastpathT) EncAsMapSliceUint8V(v []uint8, 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)
- for j, v2 := range v {
- if esep {
+ } else {
+ e.mapStart(len(v) / 2)
+ for j := range v {
if j%2 == 0 {
- ee.WriteMapElemKey()
+ e.mapElemKey()
} else {
- ee.WriteMapElemValue()
+ e.mapElemValue()
}
+ e.e.EncodeUint(uint64(v[j]))
}
- ee.EncodeUint(uint64(v2))
+ e.mapEnd()
}
- ee.WriteMapEnd()
}
-
func (e *Encoder) fastpathEncSliceUint16R(f *codecFnInfo, rv reflect.Value) {
if f.ti.mbs {
fastpathTV.EncAsMapSliceUint16V(rv2i(rv).([]uint16), e)
@@ -1738,41 +1035,30 @@ func (e *Encoder) fastpathEncSliceUint16R(f *codecFnInfo, rv reflect.Value) {
fastpathTV.EncSliceUint16V(rv2i(rv).([]uint16), e)
}
}
-func (_ fastpathT) EncSliceUint16V(v []uint16, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteArrayStart(len(v))
- for _, v2 := range v {
- if esep {
- ee.WriteArrayElem()
- }
- 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) EncAsMapSliceUint16V(v []uint16, 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)
- for j, v2 := range v {
- if esep {
+ } else {
+ e.mapStart(len(v) / 2)
+ for j := range v {
if j%2 == 0 {
- ee.WriteMapElemKey()
+ e.mapElemKey()
} else {
- ee.WriteMapElemValue()
+ e.mapElemValue()
}
+ e.e.EncodeUint(uint64(v[j]))
}
- ee.EncodeUint(uint64(v2))
+ e.mapEnd()
}
- ee.WriteMapEnd()
}
-
func (e *Encoder) fastpathEncSliceUint32R(f *codecFnInfo, rv reflect.Value) {
if f.ti.mbs {
fastpathTV.EncAsMapSliceUint32V(rv2i(rv).([]uint32), e)
@@ -1780,41 +1066,30 @@ func (e *Encoder) fastpathEncSliceUint32R(f *codecFnInfo, rv reflect.Value) {
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))
- for _, v2 := range v {
- if esep {
- ee.WriteArrayElem()
- }
- ee.EncodeUint(uint64(v2))
+func (fastpathT) EncSliceUint32V(v []uint32, e *Encoder) {
+ e.arrayStart(len(v))
+ for j := range v {
+ e.arrayElem()
+ e.e.EncodeUint(uint64(v[j]))
}
- ee.WriteArrayEnd()
+ e.arrayEnd()
}
-func (_ fastpathT) EncAsMapSliceUint32V(v []uint32, 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)
- for j, v2 := range v {
- if esep {
+ } else {
+ e.mapStart(len(v) / 2)
+ for j := range v {
if j%2 == 0 {
- ee.WriteMapElemKey()
+ e.mapElemKey()
} else {
- ee.WriteMapElemValue()
+ e.mapElemValue()
}
+ e.e.EncodeUint(uint64(v[j]))
}
- ee.EncodeUint(uint64(v2))
+ e.mapEnd()
}
- ee.WriteMapEnd()
}
-
func (e *Encoder) fastpathEncSliceUint64R(f *codecFnInfo, rv reflect.Value) {
if f.ti.mbs {
fastpathTV.EncAsMapSliceUint64V(rv2i(rv).([]uint64), e)
@@ -1822,125 +1097,61 @@ 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))
- for _, v2 := range v {
- if esep {
- ee.WriteArrayElem()
- }
- 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)
- for j, v2 := range v {
- if esep {
+ } else {
+ e.mapStart(len(v) / 2)
+ for j := range v {
if j%2 == 0 {
- ee.WriteMapElemKey()
+ e.mapElemKey()
} else {
- ee.WriteMapElemValue()
+ e.mapElemValue()
}
+ e.e.EncodeUint(v[j])
}
- ee.EncodeUint(uint64(v2))
+ e.mapEnd()
}
- ee.WriteMapEnd()
}
-
-func (e *Encoder) fastpathEncSliceUintptrR(f *codecFnInfo, rv reflect.Value) {
+func (e *Encoder) fastpathEncSliceIntR(f *codecFnInfo, rv reflect.Value) {
if f.ti.mbs {
- fastpathTV.EncAsMapSliceUintptrV(rv2i(rv).([]uintptr), e)
+ fastpathTV.EncAsMapSliceIntV(rv2i(rv).([]int), e)
} else {
- fastpathTV.EncSliceUintptrV(rv2i(rv).([]uintptr), e)
+ fastpathTV.EncSliceIntV(rv2i(rv).([]int), e)
}
}
-func (_ fastpathT) EncSliceUintptrV(v []uintptr, 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))
- for _, v2 := range v {
- if esep {
- ee.WriteArrayElem()
- }
- e.encode(v2)
- }
- ee.WriteArrayEnd()
+ e.arrayEnd()
}
-func (_ fastpathT) EncAsMapSliceUintptrV(v []uintptr, 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)
- for j, v2 := range v {
- if esep {
- if j%2 == 0 {
- ee.WriteMapElemKey()
- } else {
- ee.WriteMapElemValue()
- }
- }
- e.encode(v2)
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncSliceIntR(f *codecFnInfo, rv reflect.Value) {
- if f.ti.mbs {
- fastpathTV.EncAsMapSliceIntV(rv2i(rv).([]int), e)
} else {
- fastpathTV.EncSliceIntV(rv2i(rv).([]int), e)
- }
-}
-func (_ fastpathT) EncSliceIntV(v []int, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteArrayStart(len(v))
- for _, v2 := range v {
- if esep {
- ee.WriteArrayElem()
- }
- ee.EncodeInt(int64(v2))
- }
- ee.WriteArrayEnd()
-}
-func (_ fastpathT) EncAsMapSliceIntV(v []int, 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)
- 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()
}
+ e.e.EncodeInt(int64(v[j]))
}
- ee.EncodeInt(int64(v2))
+ e.mapEnd()
}
- ee.WriteMapEnd()
}
-
func (e *Encoder) fastpathEncSliceInt8R(f *codecFnInfo, rv reflect.Value) {
if f.ti.mbs {
fastpathTV.EncAsMapSliceInt8V(rv2i(rv).([]int8), e)
@@ -1948,41 +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))
- for _, v2 := range v {
- if esep {
- ee.WriteArrayElem()
- }
- 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)
- for j, v2 := range v {
- if esep {
+ } else {
+ e.mapStart(len(v) / 2)
+ for j := range v {
if j%2 == 0 {
- ee.WriteMapElemKey()
+ e.mapElemKey()
} else {
- ee.WriteMapElemValue()
+ e.mapElemValue()
}
+ e.e.EncodeInt(int64(v[j]))
}
- ee.EncodeInt(int64(v2))
+ e.mapEnd()
}
- ee.WriteMapEnd()
}
-
func (e *Encoder) fastpathEncSliceInt16R(f *codecFnInfo, rv reflect.Value) {
if f.ti.mbs {
fastpathTV.EncAsMapSliceInt16V(rv2i(rv).([]int16), e)
@@ -1990,41 +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))
- for _, v2 := range v {
- if esep {
- ee.WriteArrayElem()
- }
- 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)
- for j, v2 := range v {
- if esep {
+ } else {
+ e.mapStart(len(v) / 2)
+ for j := range v {
if j%2 == 0 {
- ee.WriteMapElemKey()
+ e.mapElemKey()
} else {
- ee.WriteMapElemValue()
+ e.mapElemValue()
}
+ e.e.EncodeInt(int64(v[j]))
}
- ee.EncodeInt(int64(v2))
+ e.mapEnd()
}
- ee.WriteMapEnd()
}
-
func (e *Encoder) fastpathEncSliceInt32R(f *codecFnInfo, rv reflect.Value) {
if f.ti.mbs {
fastpathTV.EncAsMapSliceInt32V(rv2i(rv).([]int32), e)
@@ -2032,41 +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))
- for _, v2 := range v {
- if esep {
- ee.WriteArrayElem()
- }
- 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)
- for j, v2 := range v {
- if esep {
+ } else {
+ e.mapStart(len(v) / 2)
+ for j := range v {
if j%2 == 0 {
- ee.WriteMapElemKey()
+ e.mapElemKey()
} else {
- ee.WriteMapElemValue()
+ e.mapElemValue()
}
+ e.e.EncodeInt(int64(v[j]))
}
- ee.EncodeInt(int64(v2))
+ e.mapEnd()
}
- ee.WriteMapEnd()
}
-
func (e *Encoder) fastpathEncSliceInt64R(f *codecFnInfo, rv reflect.Value) {
if f.ti.mbs {
fastpathTV.EncAsMapSliceInt64V(rv2i(rv).([]int64), e)
@@ -2074,41 +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
+func (fastpathT) EncSliceInt64V(v []int64, e *Encoder) {
+ e.arrayStart(len(v))
+ for j := range v {
+ e.arrayElem()
+ e.e.EncodeInt(v[j])
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteArrayStart(len(v))
- for _, v2 := range v {
- if esep {
- ee.WriteArrayElem()
- }
- ee.EncodeInt(int64(v2))
- }
- 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)
- for j, v2 := range v {
- if esep {
+ } else {
+ e.mapStart(len(v) / 2)
+ for j := range v {
if j%2 == 0 {
- ee.WriteMapElemKey()
+ e.mapElemKey()
} else {
- ee.WriteMapElemValue()
+ e.mapElemValue()
}
+ e.e.EncodeInt(v[j])
}
- ee.EncodeInt(int64(v2))
+ e.mapEnd()
}
- ee.WriteMapEnd()
}
-
func (e *Encoder) fastpathEncSliceBoolR(f *codecFnInfo, rv reflect.Value) {
if f.ti.mbs {
fastpathTV.EncAsMapSliceBoolV(rv2i(rv).([]bool), e)
@@ -2116,27681 +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))
- for _, v2 := range v {
- if esep {
- ee.WriteArrayElem()
- }
- 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)
- for j, v2 := range v {
- if esep {
+ } else {
+ e.mapStart(len(v) / 2)
+ for j := range v {
if j%2 == 0 {
- ee.WriteMapElemKey()
+ e.mapElemKey()
} else {
- ee.WriteMapElemValue()
+ e.mapElemValue()
}
+ e.e.EncodeBool(v[j])
}
- ee.EncodeBool(v2)
+ 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))
- for j := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- e.asis(v2[j].v)
- if esep {
- ee.WriteMapElemValue()
- }
- 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 {
for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- e.encode(k2)
- if esep {
- ee.WriteMapElemValue()
- }
+ 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))
- for j := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- e.asis(v2[j].v)
- if esep {
- ee.WriteMapElemValue()
- }
- 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 {
for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- e.encode(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- if e.h.StringToRaw {
- ee.EncodeStringBytesRaw(bytesView(v2))
- } else {
- ee.EncodeStringEnc(cUTF8, v2)
- }
+ 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))
- for j := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- e.asis(v2[j].v)
- if esep {
- ee.WriteMapElemValue()
- }
- 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 {
for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- e.encode(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v2))
+ 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))
- for j := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- e.asis(v2[j].v)
- if esep {
- ee.WriteMapElemValue()
- }
- 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 {
for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- e.encode(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v2))
+ 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))
- for j := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- e.asis(v2[j].v)
- if esep {
- ee.WriteMapElemValue()
- }
- 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 {
for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- e.encode(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v2))
+ 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))
- for j := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- e.asis(v2[j].v)
- if esep {
- ee.WriteMapElemValue()
- }
- 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 {
for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- e.encode(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v2))
+ 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))
- for j := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- e.asis(v2[j].v)
- if esep {
- ee.WriteMapElemValue()
- }
- 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 {
for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- e.encode(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v2))
+ 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))
- for j := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- e.asis(v2[j].v)
- if esep {
- ee.WriteMapElemValue()
- }
- 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 {
for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- e.encode(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- e.encode(v2)
+ 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))
- for j := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- e.asis(v2[j].v)
- if esep {
- ee.WriteMapElemValue()
- }
- 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 {
for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- e.encode(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v2))
+ 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))
- for j := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- e.asis(v2[j].v)
- if esep {
- ee.WriteMapElemValue()
- }
- 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 {
for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- e.encode(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v2))
+ 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))
- for j := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- e.asis(v2[j].v)
- if esep {
- ee.WriteMapElemValue()
- }
- 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 {
for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- e.encode(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v2))
+ 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))
- for j := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- e.asis(v2[j].v)
- if esep {
- ee.WriteMapElemValue()
- }
- 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 {
for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- e.encode(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v2))
+ 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))
- for j := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- e.asis(v2[j].v)
- if esep {
- ee.WriteMapElemValue()
- }
- 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 {
for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- e.encode(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v2))
+ 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))
- for j := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- e.asis(v2[j].v)
- if esep {
- ee.WriteMapElemValue()
- }
- 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 {
for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- e.encode(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeFloat32(v2)
+ 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))
- for j := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- e.asis(v2[j].v)
- if esep {
- ee.WriteMapElemValue()
- }
- 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 {
for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- e.encode(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeFloat64(v2)
+ 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))
- for j := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- e.asis(v2[j].v)
- if esep {
- ee.WriteMapElemValue()
- }
- 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 {
for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- e.encode(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeBool(v2)
+ 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))
+ sort.Sort(uint64Slice(v2))
for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- if e.h.StringToRaw {
- ee.EncodeStringBytesRaw(bytesView(k2))
- } else {
- ee.EncodeStringEnc(cUTF8, k2)
- }
- if esep {
- ee.WriteMapElemValue()
- }
- e.encode(v[string(k2)])
+ e.mapElemKey()
+ e.e.EncodeUint(uint64(uint(k2)))
+ e.mapElemValue()
+ e.e.EncodeUint(v[uint(k2)])
}
} else {
for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- if e.h.StringToRaw {
- ee.EncodeStringBytesRaw(bytesView(k2))
- } else {
- ee.EncodeStringEnc(cUTF8, k2)
- }
- if esep {
- ee.WriteMapElemValue()
- }
- e.encode(v2)
+ 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))
+ sort.Sort(uint64Slice(v2))
for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- if e.h.StringToRaw {
- ee.EncodeStringBytesRaw(bytesView(k2))
- } else {
- ee.EncodeStringEnc(cUTF8, k2)
- }
- if esep {
- ee.WriteMapElemValue()
- }
- if e.h.StringToRaw {
- ee.EncodeStringBytesRaw(bytesView(v[string(k2)]))
- } else {
- ee.EncodeStringEnc(cUTF8, v[string(k2)])
- }
+ e.mapElemKey()
+ e.e.EncodeUint(uint64(uint(k2)))
+ e.mapElemValue()
+ e.e.EncodeInt(int64(v[uint(k2)]))
}
} else {
for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- if e.h.StringToRaw {
- ee.EncodeStringBytesRaw(bytesView(k2))
- } else {
- ee.EncodeStringEnc(cUTF8, k2)
- }
- if esep {
- ee.WriteMapElemValue()
- }
- if e.h.StringToRaw {
- ee.EncodeStringBytesRaw(bytesView(v2))
- } else {
- ee.EncodeStringEnc(cUTF8, v2)
- }
+ 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))
+ sort.Sort(uint64Slice(v2))
for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- if e.h.StringToRaw {
- ee.EncodeStringBytesRaw(bytesView(k2))
- } else {
- ee.EncodeStringEnc(cUTF8, k2)
- }
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[string(k2)]))
+ e.mapElemKey()
+ e.e.EncodeUint(uint64(uint(k2)))
+ e.mapElemValue()
+ e.e.EncodeInt(v[uint(k2)])
}
} else {
for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- if e.h.StringToRaw {
- ee.EncodeStringBytesRaw(bytesView(k2))
- } else {
- ee.EncodeStringEnc(cUTF8, k2)
- }
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v2))
+ 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))
+ sort.Sort(uint64Slice(v2))
for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- if e.h.StringToRaw {
- ee.EncodeStringBytesRaw(bytesView(k2))
- } else {
- ee.EncodeStringEnc(cUTF8, k2)
- }
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[string(k2)]))
+ e.mapElemKey()
+ e.e.EncodeUint(uint64(uint(k2)))
+ e.mapElemValue()
+ e.e.EncodeFloat32(v[uint(k2)])
}
} else {
for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- if e.h.StringToRaw {
- ee.EncodeStringBytesRaw(bytesView(k2))
- } else {
- ee.EncodeStringEnc(cUTF8, k2)
- }
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v2))
+ 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))
+ sort.Sort(uint64Slice(v2))
for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- if e.h.StringToRaw {
- ee.EncodeStringBytesRaw(bytesView(k2))
- } else {
- ee.EncodeStringEnc(cUTF8, k2)
- }
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[string(k2)]))
+ e.mapElemKey()
+ e.e.EncodeUint(uint64(uint(k2)))
+ e.mapElemValue()
+ e.e.EncodeFloat64(v[uint(k2)])
}
} else {
for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- if e.h.StringToRaw {
- ee.EncodeStringBytesRaw(bytesView(k2))
- } else {
- ee.EncodeStringEnc(cUTF8, k2)
- }
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v2))
+ 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))
+ sort.Sort(uint64Slice(v2))
for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- if e.h.StringToRaw {
- ee.EncodeStringBytesRaw(bytesView(k2))
- } else {
- ee.EncodeStringEnc(cUTF8, k2)
- }
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[string(k2)]))
+ e.mapElemKey()
+ e.e.EncodeUint(uint64(uint(k2)))
+ e.mapElemValue()
+ e.e.EncodeBool(v[uint(k2)])
}
} else {
for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- if e.h.StringToRaw {
- ee.EncodeStringBytesRaw(bytesView(k2))
- } else {
- ee.EncodeStringEnc(cUTF8, k2)
- }
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v2))
+ 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))
+ sort.Sort(uint64Slice(v2))
for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- if e.h.StringToRaw {
- ee.EncodeStringBytesRaw(bytesView(k2))
- } else {
- ee.EncodeStringEnc(cUTF8, k2)
- }
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[string(k2)]))
+ e.mapElemKey()
+ e.e.EncodeUint(uint64(uint8(k2)))
+ e.mapElemValue()
+ e.encode(v[uint8(k2)])
}
} else {
for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- if e.h.StringToRaw {
- ee.EncodeStringBytesRaw(bytesView(k2))
- } else {
- ee.EncodeStringEnc(cUTF8, k2)
- }
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v2))
+ 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))
+ sort.Sort(uint64Slice(v2))
for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- if e.h.StringToRaw {
- ee.EncodeStringBytesRaw(bytesView(k2))
- } else {
- ee.EncodeStringEnc(cUTF8, k2)
- }
- if esep {
- ee.WriteMapElemValue()
- }
- e.encode(v[string(k2)])
+ e.mapElemKey()
+ e.e.EncodeUint(uint64(uint8(k2)))
+ e.mapElemValue()
+ e.e.EncodeString(v[uint8(k2)])
}
} else {
for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- if e.h.StringToRaw {
- ee.EncodeStringBytesRaw(bytesView(k2))
- } else {
- ee.EncodeStringEnc(cUTF8, k2)
- }
- if esep {
- ee.WriteMapElemValue()
- }
- e.encode(v2)
+ 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))
+ sort.Sort(uint64Slice(v2))
for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- if e.h.StringToRaw {
- ee.EncodeStringBytesRaw(bytesView(k2))
- } else {
- ee.EncodeStringEnc(cUTF8, k2)
- }
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[string(k2)]))
+ e.mapElemKey()
+ e.e.EncodeUint(uint64(uint8(k2)))
+ e.mapElemValue()
+ e.e.EncodeStringBytesRaw(v[uint8(k2)])
}
} else {
for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- if e.h.StringToRaw {
- ee.EncodeStringBytesRaw(bytesView(k2))
- } else {
- ee.EncodeStringEnc(cUTF8, k2)
- }
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v2))
+ 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))
+ sort.Sort(uint64Slice(v2))
for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- if e.h.StringToRaw {
- ee.EncodeStringBytesRaw(bytesView(k2))
- } else {
- ee.EncodeStringEnc(cUTF8, k2)
- }
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[string(k2)]))
+ e.mapElemKey()
+ e.e.EncodeUint(uint64(uint8(k2)))
+ e.mapElemValue()
+ e.e.EncodeUint(uint64(v[uint8(k2)]))
}
} else {
for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- if e.h.StringToRaw {
- ee.EncodeStringBytesRaw(bytesView(k2))
- } else {
- ee.EncodeStringEnc(cUTF8, k2)
- }
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v2))
+ 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))
+ sort.Sort(uint64Slice(v2))
for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- if e.h.StringToRaw {
- ee.EncodeStringBytesRaw(bytesView(k2))
- } else {
- ee.EncodeStringEnc(cUTF8, k2)
- }
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[string(k2)]))
+ e.mapElemKey()
+ e.e.EncodeUint(uint64(uint8(k2)))
+ e.mapElemValue()
+ e.e.EncodeUint(uint64(v[uint8(k2)]))
}
} else {
for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- if e.h.StringToRaw {
- ee.EncodeStringBytesRaw(bytesView(k2))
- } else {
- ee.EncodeStringEnc(cUTF8, k2)
- }
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v2))
+ 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))
+ sort.Sort(uint64Slice(v2))
for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- if e.h.StringToRaw {
- ee.EncodeStringBytesRaw(bytesView(k2))
- } else {
- ee.EncodeStringEnc(cUTF8, k2)
- }
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[string(k2)]))
+ e.mapElemKey()
+ e.e.EncodeUint(uint64(uint8(k2)))
+ e.mapElemValue()
+ e.e.EncodeUint(v[uint8(k2)])
}
} else {
for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- if e.h.StringToRaw {
- ee.EncodeStringBytesRaw(bytesView(k2))
- } else {
- ee.EncodeStringEnc(cUTF8, k2)
- }
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v2))
+ 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))
+ sort.Sort(uint64Slice(v2))
for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- if e.h.StringToRaw {
- ee.EncodeStringBytesRaw(bytesView(k2))
- } else {
- ee.EncodeStringEnc(cUTF8, k2)
- }
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[string(k2)]))
+ e.mapElemKey()
+ e.e.EncodeUint(uint64(uint8(k2)))
+ e.mapElemValue()
+ e.e.EncodeInt(int64(v[uint8(k2)]))
}
} else {
for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- if e.h.StringToRaw {
- ee.EncodeStringBytesRaw(bytesView(k2))
- } else {
- ee.EncodeStringEnc(cUTF8, k2)
- }
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v2))
+ 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))
+ sort.Sort(uint64Slice(v2))
for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- if e.h.StringToRaw {
- ee.EncodeStringBytesRaw(bytesView(k2))
- } else {
- ee.EncodeStringEnc(cUTF8, k2)
- }
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeFloat32(v[string(k2)])
+ e.mapElemKey()
+ e.e.EncodeUint(uint64(uint8(k2)))
+ e.mapElemValue()
+ e.e.EncodeInt(v[uint8(k2)])
}
} else {
for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- if e.h.StringToRaw {
- ee.EncodeStringBytesRaw(bytesView(k2))
- } else {
- ee.EncodeStringEnc(cUTF8, k2)
- }
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeFloat32(v2)
+ 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))
+ sort.Sort(uint64Slice(v2))
for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- if e.h.StringToRaw {
- ee.EncodeStringBytesRaw(bytesView(k2))
- } else {
- ee.EncodeStringEnc(cUTF8, k2)
- }
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeFloat64(v[string(k2)])
+ e.mapElemKey()
+ e.e.EncodeUint(uint64(uint8(k2)))
+ e.mapElemValue()
+ e.e.EncodeFloat32(v[uint8(k2)])
}
} else {
for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- if e.h.StringToRaw {
- ee.EncodeStringBytesRaw(bytesView(k2))
- } else {
- ee.EncodeStringEnc(cUTF8, k2)
- }
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeFloat64(v2)
+ 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))
+ sort.Sort(uint64Slice(v2))
for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- if e.h.StringToRaw {
- ee.EncodeStringBytesRaw(bytesView(k2))
- } else {
- ee.EncodeStringEnc(cUTF8, k2)
- }
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeBool(v[string(k2)])
+ e.mapElemKey()
+ e.e.EncodeUint(uint64(uint8(k2)))
+ e.mapElemValue()
+ e.e.EncodeFloat64(v[uint8(k2)])
}
} else {
for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- if e.h.StringToRaw {
- ee.EncodeStringBytesRaw(bytesView(k2))
- } else {
- ee.EncodeStringEnc(cUTF8, k2)
- }
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeBool(v2)
+ 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))
+ sort.Sort(uint64Slice(v2))
for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeFloat32(float32(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- e.encode(v[float32(k2)])
+ e.mapElemKey()
+ e.e.EncodeUint(uint64(uint8(k2)))
+ e.mapElemValue()
+ e.e.EncodeBool(v[uint8(k2)])
}
} else {
for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeFloat32(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- e.encode(v2)
+ 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))
+ sort.Sort(uint64Slice(v2))
for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeFloat32(float32(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- if e.h.StringToRaw {
- ee.EncodeStringBytesRaw(bytesView(v[float32(k2)]))
- } else {
- ee.EncodeStringEnc(cUTF8, v[float32(k2)])
- }
+ e.mapElemKey()
+ e.e.EncodeUint(k2)
+ e.mapElemValue()
+ e.encode(v[k2])
}
} else {
for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeFloat32(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- if e.h.StringToRaw {
- ee.EncodeStringBytesRaw(bytesView(v2))
- } else {
- ee.EncodeStringEnc(cUTF8, v2)
- }
+ 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))
+ sort.Sort(uint64Slice(v2))
for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeFloat32(float32(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[float32(k2)]))
+ e.mapElemKey()
+ e.e.EncodeUint(k2)
+ e.mapElemValue()
+ e.e.EncodeString(v[k2])
}
} else {
for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeFloat32(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v2))
+ 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))
+ sort.Sort(uint64Slice(v2))
for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeFloat32(float32(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[float32(k2)]))
+ e.mapElemKey()
+ e.e.EncodeUint(k2)
+ e.mapElemValue()
+ e.e.EncodeStringBytesRaw(v[k2])
}
} else {
for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeFloat32(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v2))
+ 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))
+ sort.Sort(uint64Slice(v2))
for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeFloat32(float32(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[float32(k2)]))
+ e.mapElemKey()
+ e.e.EncodeUint(k2)
+ e.mapElemValue()
+ e.e.EncodeUint(uint64(v[k2]))
}
} else {
for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeFloat32(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v2))
+ 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))
+ sort.Sort(uint64Slice(v2))
for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeFloat32(float32(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[float32(k2)]))
+ e.mapElemKey()
+ e.e.EncodeUint(k2)
+ e.mapElemValue()
+ e.e.EncodeUint(uint64(v[k2]))
}
} else {
for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeFloat32(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v2))
+ 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))
+ sort.Sort(uint64Slice(v2))
for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeFloat32(float32(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[float32(k2)]))
+ e.mapElemKey()
+ e.e.EncodeUint(k2)
+ e.mapElemValue()
+ e.e.EncodeUint(v[k2])
}
} else {
for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeFloat32(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v2))
+ 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))
+ sort.Sort(uint64Slice(v2))
for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeFloat32(float32(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- e.encode(v[float32(k2)])
+ e.mapElemKey()
+ e.e.EncodeUint(k2)
+ e.mapElemValue()
+ e.e.EncodeInt(int64(v[k2]))
}
} else {
for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeFloat32(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- e.encode(v2)
+ 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))
+ sort.Sort(uint64Slice(v2))
for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeFloat32(float32(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[float32(k2)]))
+ e.mapElemKey()
+ e.e.EncodeUint(k2)
+ e.mapElemValue()
+ e.e.EncodeInt(v[k2])
}
} else {
for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeFloat32(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v2))
+ 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))
+ sort.Sort(uint64Slice(v2))
for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeFloat32(float32(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[float32(k2)]))
+ e.mapElemKey()
+ e.e.EncodeUint(k2)
+ e.mapElemValue()
+ e.e.EncodeFloat32(v[k2])
}
} else {
for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeFloat32(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v2))
+ 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))
+ sort.Sort(uint64Slice(v2))
for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeFloat32(float32(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[float32(k2)]))
+ e.mapElemKey()
+ e.e.EncodeUint(k2)
+ e.mapElemValue()
+ e.e.EncodeFloat64(v[k2])
}
} else {
for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeFloat32(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v2))
+ 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))
+ sort.Sort(uint64Slice(v2))
for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeFloat32(float32(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[float32(k2)]))
+ e.mapElemKey()
+ e.e.EncodeUint(k2)
+ e.mapElemValue()
+ e.e.EncodeBool(v[k2])
}
} else {
for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeFloat32(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v2))
+ 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))
+ sort.Sort(int64Slice(v2))
for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeFloat32(float32(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[float32(k2)]))
+ e.mapElemKey()
+ e.e.EncodeInt(int64(int(k2)))
+ e.mapElemValue()
+ e.encode(v[int(k2)])
}
} else {
for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeFloat32(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v2))
+ 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))
+ sort.Sort(int64Slice(v2))
for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeFloat32(float32(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeFloat32(v[float32(k2)])
+ e.mapElemKey()
+ e.e.EncodeInt(int64(int(k2)))
+ e.mapElemValue()
+ e.e.EncodeString(v[int(k2)])
}
} else {
for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeFloat32(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeFloat32(v2)
+ 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))
+ sort.Sort(int64Slice(v2))
for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeFloat32(float32(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeFloat64(v[float32(k2)])
+ e.mapElemKey()
+ e.e.EncodeInt(int64(int(k2)))
+ e.mapElemValue()
+ e.e.EncodeStringBytesRaw(v[int(k2)])
}
} else {
for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeFloat32(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeFloat64(v2)
+ 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))
+ sort.Sort(int64Slice(v2))
for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeFloat32(float32(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeBool(v[float32(k2)])
+ e.mapElemKey()
+ e.e.EncodeInt(int64(int(k2)))
+ e.mapElemValue()
+ e.e.EncodeUint(uint64(v[int(k2)]))
}
} else {
for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeFloat32(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeBool(v2)
+ 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))
+ sort.Sort(int64Slice(v2))
for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeFloat64(float64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- e.encode(v[float64(k2)])
+ e.mapElemKey()
+ e.e.EncodeInt(int64(int(k2)))
+ e.mapElemValue()
+ e.e.EncodeUint(uint64(v[int(k2)]))
}
} else {
for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeFloat64(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- e.encode(v2)
+ 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))
+ sort.Sort(int64Slice(v2))
for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeFloat64(float64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- if e.h.StringToRaw {
- ee.EncodeStringBytesRaw(bytesView(v[float64(k2)]))
- } else {
- ee.EncodeStringEnc(cUTF8, v[float64(k2)])
- }
+ e.mapElemKey()
+ e.e.EncodeInt(int64(int(k2)))
+ e.mapElemValue()
+ e.e.EncodeUint(v[int(k2)])
}
} else {
for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeFloat64(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- if e.h.StringToRaw {
- ee.EncodeStringBytesRaw(bytesView(v2))
- } else {
- ee.EncodeStringEnc(cUTF8, v2)
- }
+ 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))
+ sort.Sort(int64Slice(v2))
for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeFloat64(float64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[float64(k2)]))
+ e.mapElemKey()
+ e.e.EncodeInt(int64(int(k2)))
+ e.mapElemValue()
+ e.e.EncodeInt(int64(v[int(k2)]))
}
} else {
for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeFloat64(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v2))
+ 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))
+ sort.Sort(int64Slice(v2))
for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeFloat64(float64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[float64(k2)]))
+ e.mapElemKey()
+ e.e.EncodeInt(int64(int(k2)))
+ e.mapElemValue()
+ e.e.EncodeInt(v[int(k2)])
}
} else {
for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeFloat64(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v2))
+ 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))
+ sort.Sort(int64Slice(v2))
for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeFloat64(float64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[float64(k2)]))
+ e.mapElemKey()
+ e.e.EncodeInt(int64(int(k2)))
+ e.mapElemValue()
+ e.e.EncodeFloat32(v[int(k2)])
}
} else {
for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeFloat64(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v2))
+ 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))
+ sort.Sort(int64Slice(v2))
for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeFloat64(float64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[float64(k2)]))
+ e.mapElemKey()
+ e.e.EncodeInt(int64(int(k2)))
+ e.mapElemValue()
+ e.e.EncodeFloat64(v[int(k2)])
}
} else {
for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeFloat64(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v2))
+ 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))
+ sort.Sort(int64Slice(v2))
for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeFloat64(float64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[float64(k2)]))
+ e.mapElemKey()
+ e.e.EncodeInt(int64(int(k2)))
+ e.mapElemValue()
+ e.e.EncodeBool(v[int(k2)])
}
} else {
for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeFloat64(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v2))
+ 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))
+ sort.Sort(int64Slice(v2))
for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeFloat64(float64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- e.encode(v[float64(k2)])
+ e.mapElemKey()
+ e.e.EncodeInt(k2)
+ e.mapElemValue()
+ e.encode(v[k2])
}
} else {
for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeFloat64(k2)
- if esep {
- ee.WriteMapElemValue()
- }
+ 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))
+ sort.Sort(int64Slice(v2))
for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeFloat64(float64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[float64(k2)]))
+ e.mapElemKey()
+ e.e.EncodeInt(k2)
+ e.mapElemValue()
+ e.e.EncodeString(v[k2])
}
} else {
for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeFloat64(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v2))
+ 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))
+ sort.Sort(int64Slice(v2))
for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeFloat64(float64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[float64(k2)]))
+ e.mapElemKey()
+ e.e.EncodeInt(k2)
+ e.mapElemValue()
+ e.e.EncodeStringBytesRaw(v[k2])
}
} else {
for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeFloat64(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v2))
+ 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))
+ sort.Sort(int64Slice(v2))
for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeFloat64(float64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[float64(k2)]))
+ e.mapElemKey()
+ e.e.EncodeInt(k2)
+ e.mapElemValue()
+ e.e.EncodeUint(uint64(v[k2]))
}
} else {
for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeFloat64(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v2))
+ 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))
+ sort.Sort(int64Slice(v2))
for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeFloat64(float64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[float64(k2)]))
+ e.mapElemKey()
+ e.e.EncodeInt(k2)
+ e.mapElemValue()
+ e.e.EncodeUint(uint64(v[k2]))
}
} else {
for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeFloat64(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v2))
+ 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))
+ sort.Sort(int64Slice(v2))
for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeFloat64(float64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[float64(k2)]))
+ e.mapElemKey()
+ e.e.EncodeInt(k2)
+ e.mapElemValue()
+ e.e.EncodeUint(v[k2])
}
} else {
for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeFloat64(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v2))
+ 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))
+ sort.Sort(int64Slice(v2))
for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeFloat64(float64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeFloat32(v[float64(k2)])
+ e.mapElemKey()
+ e.e.EncodeInt(k2)
+ e.mapElemValue()
+ e.e.EncodeInt(int64(v[k2]))
}
} else {
for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeFloat64(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeFloat32(v2)
+ 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))
+ sort.Sort(int64Slice(v2))
for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeFloat64(float64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeFloat64(v[float64(k2)])
+ e.mapElemKey()
+ e.e.EncodeInt(k2)
+ e.mapElemValue()
+ e.e.EncodeInt(v[k2])
}
} else {
for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeFloat64(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeFloat64(v2)
+ 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))
+ sort.Sort(int64Slice(v2))
for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeFloat64(float64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeBool(v[float64(k2)])
+ e.mapElemKey()
+ e.e.EncodeInt(k2)
+ e.mapElemValue()
+ e.e.EncodeFloat32(v[k2])
}
} else {
for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeFloat64(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeBool(v2)
+ 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))
+ sort.Sort(int64Slice(v2))
for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- e.encode(v[uint(k2)])
+ e.mapElemKey()
+ e.e.EncodeInt(k2)
+ e.mapElemValue()
+ e.e.EncodeFloat64(v[k2])
}
} else {
for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- e.encode(v2)
+ 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))
+ sort.Sort(int64Slice(v2))
for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- if e.h.StringToRaw {
- ee.EncodeStringBytesRaw(bytesView(v[uint(k2)]))
- } else {
- ee.EncodeStringEnc(cUTF8, v[uint(k2)])
- }
+ e.mapElemKey()
+ e.e.EncodeInt(k2)
+ e.mapElemValue()
+ e.e.EncodeBool(v[k2])
}
} else {
for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- if e.h.StringToRaw {
- ee.EncodeStringBytesRaw(bytesView(v2))
- } else {
- ee.EncodeStringEnc(cUTF8, v2)
- }
+ 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- 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 {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- 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 {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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
}
- }
- 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 []uint16:
+ fastpathTV.DecSliceUint16N(v, d)
+ case *[]uint16:
+ var v2 []uint16
+ if v2, changed = fastpathTV.DecSliceUint16Y(*v, d); changed {
+ *v = v2
}
- sort.Sort(uintSlice(v2))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[uint(k2)]))
+ case []uint32:
+ fastpathTV.DecSliceUint32N(v, d)
+ case *[]uint32:
+ var v2 []uint32
+ if v2, changed = fastpathTV.DecSliceUint32Y(*v, d); changed {
+ *v = v2
}
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
+ 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)
}
- ee.EncodeUint(uint64(v2))
+ 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]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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
+ 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)
}
- ee.EncodeUint(uint64(uint(k2)))
- if esep {
- ee.WriteMapElemValue()
+ 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)
}
- ee.EncodeUint(uint64(v[uint(k2)]))
+ d.mapEnd()
}
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
+ 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)
}
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
+ 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)
}
- ee.EncodeUint(uint64(v2))
+ 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]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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
+ 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)
}
- ee.EncodeUint(uint64(uint(k2)))
- if esep {
- ee.WriteMapElemValue()
+ 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)
}
- ee.EncodeUint(uint64(v[uint(k2)]))
+ d.mapEnd()
}
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
+ 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)
}
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
+ 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)
}
- ee.EncodeUint(uint64(v2))
+ 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[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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
+ 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)
}
- ee.EncodeUint(uint64(uint(k2)))
- if esep {
- ee.WriteMapElemValue()
+ 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)
}
- e.encode(v[uint(k2)])
+ d.mapEnd()
}
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
+ 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)
}
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
+ 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)
}
- e.encode(v2)
+ 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]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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
+ 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)
}
- ee.EncodeUint(uint64(uint(k2)))
- if esep {
- ee.WriteMapElemValue()
+ 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)
}
- ee.EncodeInt(int64(v[uint(k2)]))
+ d.mapEnd()
}
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
+ 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)
}
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
+ 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)
}
- ee.EncodeInt(int64(v2))
+ 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[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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
+ 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)
}
- ee.EncodeUint(uint64(uint(k2)))
- if esep {
- ee.WriteMapElemValue()
+ 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)
}
- ee.EncodeInt(int64(v[uint(k2)]))
+ d.mapEnd()
}
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
+ 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)
}
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
+ 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)
}
- ee.EncodeInt(int64(v2))
+ 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]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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
+ 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)
}
- ee.EncodeUint(uint64(uint(k2)))
- if esep {
- ee.WriteMapElemValue()
+ 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)
}
- ee.EncodeInt(int64(v[uint(k2)]))
+ d.mapEnd()
}
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
+ 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)
}
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
+ 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)
}
- ee.EncodeInt(int64(v2))
+ 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[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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
+ 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)
}
- ee.EncodeUint(uint64(uint(k2)))
- if esep {
- ee.WriteMapElemValue()
+ 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)
}
- ee.EncodeInt(int64(v[uint(k2)]))
+ d.mapEnd()
}
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
+ 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)
}
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
+ 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)
}
- ee.EncodeInt(int64(v2))
+ 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++
- }
- sort.Sort(uintSlice(v2))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint(k2)))
- if esep {
- ee.WriteMapElemValue()
+ 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)
}
- ee.EncodeInt(int64(v[uint(k2)]))
+ d.mapEnd()
}
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
+ 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)
}
- ee.EncodeInt(int64(v2))
- }
- }
- 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++
+ d.mapEnd()
}
- sort.Sort(uintSlice(v2))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint(k2)))
- if esep {
- ee.WriteMapElemValue()
+ 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)
}
- ee.EncodeFloat32(v[uint(k2)])
+ d.mapEnd()
}
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
+ 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)
}
- ee.EncodeFloat32(v2)
- }
- }
- 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++
+ d.mapEnd()
}
- sort.Sort(uintSlice(v2))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint(k2)))
- if esep {
- ee.WriteMapElemValue()
+ 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)
}
- ee.EncodeFloat64(v[uint(k2)])
+ d.mapEnd()
}
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
+ 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)
}
- ee.EncodeFloat64(v2)
- }
- }
- 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++
+ d.mapEnd()
}
- sort.Sort(uintSlice(v2))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint(k2)))
- if esep {
- ee.WriteMapElemValue()
+ 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)
}
- ee.EncodeBool(v[uint(k2)])
+ d.mapEnd()
}
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
+ 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)
}
- ee.EncodeBool(v2)
- }
- }
- 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++
+ d.mapEnd()
}
- sort.Sort(uintSlice(v2))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint8(k2)))
- if esep {
- ee.WriteMapElemValue()
+ 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)
}
- e.encode(v[uint8(k2)])
+ d.mapEnd()
}
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
+ 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)
}
- e.encode(v2)
- }
- }
- 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++
+ d.mapEnd()
}
- sort.Sort(uintSlice(v2))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint8(k2)))
- if esep {
- ee.WriteMapElemValue()
+ 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)
}
- if e.h.StringToRaw {
- ee.EncodeStringBytesRaw(bytesView(v[uint8(k2)]))
- } else {
- ee.EncodeStringEnc(cUTF8, v[uint8(k2)])
+ d.mapEnd()
+ }
+ 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)
}
+ d.mapEnd()
}
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
+ 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)
}
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
+ d.mapEnd()
+ }
+ 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)
}
- if e.h.StringToRaw {
- ee.EncodeStringBytesRaw(bytesView(v2))
- } else {
- ee.EncodeStringEnc(cUTF8, 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) 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++
+ 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
+ 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)
}
- ee.EncodeUint(uint64(uint8(k2)))
- if esep {
- ee.WriteMapElemValue()
+ 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)
}
- ee.EncodeUint(uint64(v[uint8(k2)]))
+ d.mapEnd()
}
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
+ 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)
}
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
+ 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)
}
- ee.EncodeUint(uint64(v2))
+ d.mapEnd()
}
- }
- 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++
+ 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
+ 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)
}
- ee.EncodeUint(uint64(uint8(k2)))
- if esep {
- ee.WriteMapElemValue()
+ 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)
}
- ee.EncodeUint(uint64(v[uint8(k2)]))
+ d.mapEnd()
}
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
+ 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)
}
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
+ 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)
}
- ee.EncodeUint(uint64(v2))
+ d.mapEnd()
}
- }
- 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++
+ 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
+ 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)
}
- ee.EncodeUint(uint64(uint8(k2)))
- if esep {
- ee.WriteMapElemValue()
+ 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)
}
- ee.EncodeUint(uint64(v[uint8(k2)]))
+ d.mapEnd()
}
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
+ 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)
}
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
+ 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)
}
- ee.EncodeUint(uint64(v2))
+ 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()
+ return true
}
-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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint8(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[uint8(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint8(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[uint8(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint8(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- e.encode(v[uint8(k2)])
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint8(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[uint8(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint8(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[uint8(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint8(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[uint8(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint8(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[uint8(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint8(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[uint8(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint8(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeFloat32(v[uint8(k2)])
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint8(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeFloat64(v[uint8(k2)])
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint8(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeBool(v[uint8(k2)])
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint16(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- e.encode(v[uint16(k2)])
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint16(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- if e.h.StringToRaw {
- ee.EncodeStringBytesRaw(bytesView(v[uint16(k2)]))
- } else {
- ee.EncodeStringEnc(cUTF8, v[uint16(k2)])
- }
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- if e.h.StringToRaw {
- ee.EncodeStringBytesRaw(bytesView(v2))
- } else {
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint16(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[uint16(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint16(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[uint16(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint16(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[uint16(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint16(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[uint16(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint16(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[uint16(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint16(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- e.encode(v[uint16(k2)])
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint16(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[uint16(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint16(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[uint16(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint16(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[uint16(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint16(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[uint16(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint16(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[uint16(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint16(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeFloat32(v[uint16(k2)])
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint16(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeFloat64(v[uint16(k2)])
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint16(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeBool(v[uint16(k2)])
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint32(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- e.encode(v[uint32(k2)])
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint32(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- if e.h.StringToRaw {
- ee.EncodeStringBytesRaw(bytesView(v[uint32(k2)]))
- } else {
- ee.EncodeStringEnc(cUTF8, v[uint32(k2)])
- }
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- if e.h.StringToRaw {
- ee.EncodeStringBytesRaw(bytesView(v2))
- } else {
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint32(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[uint32(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint32(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[uint32(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint32(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[uint32(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint32(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[uint32(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint32(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[uint32(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint32(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- e.encode(v[uint32(k2)])
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint32(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[uint32(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint32(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[uint32(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint32(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[uint32(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint32(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[uint32(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint32(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[uint32(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint32(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeFloat32(v[uint32(k2)])
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint32(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeFloat64(v[uint32(k2)])
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint32(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeBool(v[uint32(k2)])
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint64(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- e.encode(v[uint64(k2)])
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint64(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- if e.h.StringToRaw {
- ee.EncodeStringBytesRaw(bytesView(v[uint64(k2)]))
- } else {
- ee.EncodeStringEnc(cUTF8, v[uint64(k2)])
- }
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- if e.h.StringToRaw {
- ee.EncodeStringBytesRaw(bytesView(v2))
- } else {
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint64(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[uint64(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint64(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[uint64(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint64(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[uint64(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint64(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[uint64(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint64(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[uint64(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint64(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- e.encode(v[uint64(k2)])
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint64(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[uint64(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint64(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[uint64(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint64(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[uint64(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint64(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[uint64(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint64(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[uint64(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint64(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeFloat32(v[uint64(k2)])
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint64(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeFloat64(v[uint64(k2)])
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(uint64(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeBool(v[uint64(k2)])
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeUint(uint64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- e.encode(uintptr(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- e.encode(v[uintptr(k2)])
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- e.encode(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- e.encode(uintptr(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- if e.h.StringToRaw {
- ee.EncodeStringBytesRaw(bytesView(v[uintptr(k2)]))
- } else {
- ee.EncodeStringEnc(cUTF8, v[uintptr(k2)])
- }
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- e.encode(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- if e.h.StringToRaw {
- ee.EncodeStringBytesRaw(bytesView(v2))
- } else {
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- e.encode(uintptr(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[uintptr(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- e.encode(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- e.encode(uintptr(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[uintptr(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- e.encode(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- e.encode(uintptr(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[uintptr(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- e.encode(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- e.encode(uintptr(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[uintptr(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- e.encode(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- e.encode(uintptr(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[uintptr(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- e.encode(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- e.encode(uintptr(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- e.encode(v[uintptr(k2)])
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- e.encode(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- e.encode(uintptr(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[uintptr(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- e.encode(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- e.encode(uintptr(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[uintptr(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- e.encode(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- e.encode(uintptr(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[uintptr(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- e.encode(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- e.encode(uintptr(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[uintptr(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- e.encode(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- e.encode(uintptr(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[uintptr(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- e.encode(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- e.encode(uintptr(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeFloat32(v[uintptr(k2)])
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- e.encode(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- e.encode(uintptr(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeFloat64(v[uintptr(k2)])
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- e.encode(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- e.encode(uintptr(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeBool(v[uintptr(k2)])
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- e.encode(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- e.encode(v[int(k2)])
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- if e.h.StringToRaw {
- ee.EncodeStringBytesRaw(bytesView(v[int(k2)]))
- } else {
- ee.EncodeStringEnc(cUTF8, v[int(k2)])
- }
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- if e.h.StringToRaw {
- ee.EncodeStringBytesRaw(bytesView(v2))
- } else {
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[int(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[int(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[int(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[int(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[int(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- e.encode(v[int(k2)])
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[int(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[int(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[int(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[int(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[int(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeFloat32(v[int(k2)])
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeFloat64(v[int(k2)])
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeBool(v[int(k2)])
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int8(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- e.encode(v[int8(k2)])
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int8(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- if e.h.StringToRaw {
- ee.EncodeStringBytesRaw(bytesView(v[int8(k2)]))
- } else {
- ee.EncodeStringEnc(cUTF8, v[int8(k2)])
- }
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- if e.h.StringToRaw {
- ee.EncodeStringBytesRaw(bytesView(v2))
- } else {
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int8(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[int8(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int8(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[int8(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int8(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[int8(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int8(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[int8(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int8(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[int8(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int8(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- e.encode(v[int8(k2)])
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int8(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[int8(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int8(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[int8(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int8(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[int8(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int8(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[int8(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int8(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[int8(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int8(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeFloat32(v[int8(k2)])
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int8(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeFloat64(v[int8(k2)])
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int8(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeBool(v[int8(k2)])
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int16(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- e.encode(v[int16(k2)])
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int16(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- if e.h.StringToRaw {
- ee.EncodeStringBytesRaw(bytesView(v[int16(k2)]))
- } else {
- ee.EncodeStringEnc(cUTF8, v[int16(k2)])
- }
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- if e.h.StringToRaw {
- ee.EncodeStringBytesRaw(bytesView(v2))
- } else {
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int16(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[int16(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int16(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[int16(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int16(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[int16(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int16(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[int16(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int16(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[int16(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int16(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- e.encode(v[int16(k2)])
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int16(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[int16(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int16(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[int16(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int16(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[int16(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int16(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[int16(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int16(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[int16(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int16(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeFloat32(v[int16(k2)])
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int16(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeFloat64(v[int16(k2)])
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int16(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeBool(v[int16(k2)])
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int32(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- e.encode(v[int32(k2)])
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int32(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- if e.h.StringToRaw {
- ee.EncodeStringBytesRaw(bytesView(v[int32(k2)]))
- } else {
- ee.EncodeStringEnc(cUTF8, v[int32(k2)])
- }
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- if e.h.StringToRaw {
- ee.EncodeStringBytesRaw(bytesView(v2))
- } else {
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int32(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[int32(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int32(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[int32(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int32(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[int32(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int32(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[int32(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int32(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[int32(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int32(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- e.encode(v[int32(k2)])
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int32(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[int32(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int32(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[int32(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int32(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[int32(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int32(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[int32(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int32(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[int32(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int32(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeFloat32(v[int32(k2)])
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int32(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeFloat64(v[int32(k2)])
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int32(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeBool(v[int32(k2)])
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int64(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- e.encode(v[int64(k2)])
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int64(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- if e.h.StringToRaw {
- ee.EncodeStringBytesRaw(bytesView(v[int64(k2)]))
- } else {
- ee.EncodeStringEnc(cUTF8, v[int64(k2)])
- }
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- if e.h.StringToRaw {
- ee.EncodeStringBytesRaw(bytesView(v2))
- } else {
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int64(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[int64(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int64(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[int64(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int64(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[int64(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int64(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[int64(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int64(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[int64(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int64(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- e.encode(v[int64(k2)])
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int64(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[int64(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int64(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[int64(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int64(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[int64(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int64(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[int64(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int64(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[int64(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int64(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeFloat32(v[int64(k2)])
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int64(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeFloat64(v[int64(k2)])
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(int64(k2)))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeBool(v[int64(k2)])
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeInt(int64(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeBool(bool(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- e.encode(v[bool(k2)])
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeBool(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeBool(bool(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- if e.h.StringToRaw {
- ee.EncodeStringBytesRaw(bytesView(v[bool(k2)]))
- } else {
- ee.EncodeStringEnc(cUTF8, v[bool(k2)])
- }
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeBool(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- if e.h.StringToRaw {
- ee.EncodeStringBytesRaw(bytesView(v2))
- } else {
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeBool(bool(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[bool(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeBool(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeBool(bool(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[bool(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeBool(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeBool(bool(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[bool(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeBool(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeBool(bool(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[bool(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeBool(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeBool(bool(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v[bool(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeBool(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeBool(bool(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- e.encode(v[bool(k2)])
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeBool(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeBool(bool(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[bool(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeBool(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeBool(bool(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[bool(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeBool(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeBool(bool(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[bool(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeBool(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeBool(bool(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[bool(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeBool(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeBool(bool(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v[bool(k2)]))
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeBool(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeBool(bool(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeFloat32(v[bool(k2)])
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeBool(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeBool(bool(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeFloat64(v[bool(k2)])
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeBool(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- 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))
- for _, k2 := range v2 {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeBool(bool(k2))
- if esep {
- ee.WriteMapElemValue()
- }
- ee.EncodeBool(v[bool(k2)])
- }
- } else {
- for k2, v2 := range v {
- if esep {
- ee.WriteMapElemKey()
- }
- ee.EncodeBool(k2)
- if esep {
- ee.WriteMapElemValue()
- }
- 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
-}
-
-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 {
@@ -29801,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 {
@@ -31765,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/baas-kubeengine/vendor/github.com/ugorji/go/codec/fast-path.go.tmpl b/baas-kubeengine/vendor/github.com/ugorji/go/codec/fast-path.go.tmpl
index 7617c435..537f069d 100644
--- a/baas-kubeengine/vendor/github.com/ugorji/go/codec/fast-path.go.tmpl
+++ b/baas-kubeengine/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,52 +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))
- for _, v2 := range v {
- if esep { ee.WriteArrayElem() }
- {{ encmd .Elem "v2"}}
+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]"}}
}
- ee.WriteArrayEnd()
+ 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)
- for j, v2 := range v {
- if esep {
+ } else {
+ 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"}}
+ {{ encmd .Elem "v[j]"}}
+ }
+ e.mapEnd()
}
- ee.WriteMapEnd()
}
-{{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)
@@ -241,69 +217,81 @@ func (_ fastpathT) {{ .MethodNamePfx "Enc" false }}V(v map[{{ .MapKey }}]{{ .Ele
vp.i = k2
i++
}
- sort.Sort(bytesISlice(v2))
+ 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))
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))
for _, k2 := range v2 {
- if esep { ee.WriteMapElemKey() }
- {{if eq .MapKey "string"}} if e.h.StringToRaw {ee.EncodeStringBytesRaw(bytesView(k2))} else {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 }}
+ 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 {
+ } else {
for k2, v2 := range v {
- if esep { ee.WriteMapElemKey() }
- {{if eq .MapKey "string"}} if e.h.StringToRaw {ee.EncodeStringBytesRaw(bytesView(k2))} else {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
@@ -313,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
@@ -329,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) {
@@ -384,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 {
@@ -394,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/baas-kubeengine/vendor/github.com/ugorji/go/codec/fast-path.not.go b/baas-kubeengine/vendor/github.com/ugorji/go/codec/fast-path.not.go
index cf97db0f..6b6ac1ff 100644
--- a/baas-kubeengine/vendor/github.com/ugorji/go/codec/fast-path.not.go
+++ b/baas-kubeengine/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/baas-kubeengine/vendor/github.com/ugorji/go/codec/float.go b/baas-kubeengine/vendor/github.com/ugorji/go/codec/float.go
new file mode 100644
index 00000000..cfe3a9ec
--- /dev/null
+++ b/baas-kubeengine/vendor/github.com/ugorji/go/codec/float.go
@@ -0,0 +1,313 @@
+// 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
+
+import "strconv"
+
+// func parseFloat(b []byte, bitsize int) (f float64, err error) {
+// if bitsize == 32 {
+// return parseFloat32(b)
+// } else {
+// return parseFloat64(b)
+// }
+// }
+
+func parseFloat32(b []byte) (f float32, err error) {
+ return parseFloat32_custom(b)
+ // return parseFloat32_strconv(b)
+}
+
+func parseFloat64(b []byte) (f float64, err error) {
+ return parseFloat64_custom(b)
+ // return parseFloat64_strconv(b)
+}
+
+func parseFloat32_strconv(b []byte) (f float32, err error) {
+ f64, err := strconv.ParseFloat(stringView(b), 32)
+ f = float32(f64)
+ return
+}
+
+func parseFloat64_strconv(b []byte) (f float64, err error) {
+ return strconv.ParseFloat(stringView(b), 64)
+}
+
+// ------ parseFloat custom below --------
+
+// We assume that a lot of floating point numbers in json files will be
+// those that are handwritten, and with defined precision (in terms of number
+// of digits after decimal point), etc.
+//
+// We further assume that this ones can be written in exact format.
+//
+// strconv.ParseFloat has some unnecessary overhead which we can do without
+// for the common case:
+//
+// - expensive char-by-char check to see if underscores are in right place
+// - testing for and skipping underscores
+// - check if the string matches ignorecase +/- inf, +/- infinity, nan
+// - support for base 16 (0xFFFF...)
+//
+// The functions below will try a fast-path for floats which can be decoded
+// without any loss of precision, meaning they:
+//
+// - fits within the significand bits of the 32-bits or 64-bits
+// - exponent fits within the exponent value
+// - there is no truncation (any extra numbers are all trailing zeros)
+//
+// To figure out what the values are for maxMantDigits, use this idea below:
+//
+// 2^23 = 838 8608 (between 10^ 6 and 10^ 7) (significand bits of uint32)
+// 2^32 = 42 9496 7296 (between 10^ 9 and 10^10) (full uint32)
+// 2^52 = 4503 5996 2737 0496 (between 10^15 and 10^16) (significand bits of uint64)
+// 2^64 = 1844 6744 0737 0955 1616 (between 10^19 and 10^20) (full uint64)
+//
+// Since we only allow for up to what can comfortably fit into the significand
+// ignoring the exponent, and we only try to parse iff significand fits into the
+
+// Exact powers of 10.
+var float64pow10 = [...]float64{
+ 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9,
+ 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19,
+ 1e20, 1e21, 1e22,
+}
+var float32pow10 = [...]float32{1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10}
+
+type floatinfo struct {
+ mantbits uint8
+ expbits uint8
+ bias int16
+
+ exactPow10 int8 // Exact powers of ten are <= 10^N (32: 10, 64: 22)
+ exactInts int8 // Exact integers are <= 10^N
+
+ maxMantDigits int8 // 10^19 fits in uint64, while 10^9 fits in uint32
+}
+
+var fi32 = floatinfo{23, 8, -127, 10, 7, 9} // maxMantDigits = 9
+var fi64 = floatinfo{52, 11, -1023, 22, 15, 19} // maxMantDigits = 19
+
+const fMax64 = 1e15
+const fMax32 = 1e7
+
+const fBase = 10
+
+func parseFloatErr(b []byte) error {
+ return &strconv.NumError{
+ Func: "ParseFloat",
+ Err: strconv.ErrSyntax,
+ Num: string(b),
+ }
+}
+
+func parseFloat32_custom(b []byte) (f float32, err error) {
+ mantissa, exp, neg, trunc, bad, ok := readFloat(b, fi32)
+ _ = trunc
+ if bad {
+ return 0, parseFloatErr(b)
+ }
+ if ok {
+ // parseFloatDebug(b, 32, false, exp, trunc, ok)
+ f = float32(mantissa)
+ if neg {
+ f = -f
+ }
+ if exp != 0 {
+ indx := fExpIndx(exp)
+ if exp < 0 { // int / 10^k
+ f /= float32pow10[indx]
+ } else { // exp > 0
+ if exp > fi32.exactPow10 {
+ f *= float32pow10[exp-fi32.exactPow10]
+ if f < -fMax32 || f > fMax32 { // exponent too large - outside range
+ goto FALLBACK
+ }
+ indx = uint8(fi32.exactPow10)
+ }
+ f *= float32pow10[indx]
+ }
+ }
+ return
+ }
+FALLBACK:
+ // parseFloatDebug(b, 32, true, exp, trunc, ok)
+ return parseFloat32_strconv(b)
+}
+
+func parseFloat64_custom(b []byte) (f float64, err error) {
+ mantissa, exp, neg, trunc, bad, ok := readFloat(b, fi64)
+ _ = trunc
+ if bad {
+ return 0, parseFloatErr(b)
+ }
+ if ok {
+ f = float64(mantissa)
+ if neg {
+ f = -f
+ }
+ if exp != 0 {
+ indx := fExpIndx(exp)
+ if exp < 0 { // int / 10^k
+ f /= float64pow10[indx]
+ } else { // exp > 0
+ if exp > fi64.exactPow10 {
+ f *= float64pow10[exp-fi64.exactPow10]
+ if f < -fMax64 || f > fMax64 { // exponent too large - outside range
+ goto FALLBACK
+ }
+ indx = uint8(fi64.exactPow10)
+ }
+ f *= float64pow10[indx]
+ }
+ }
+ return
+ }
+FALLBACK:
+ return parseFloat64_strconv(b)
+}
+
+func fExpIndx(v int8) uint8 {
+ if v < 0 {
+ return uint8(-v)
+ }
+ return uint8(v)
+}
+
+func readFloat(s []byte, y floatinfo) (mantissa uint64, exp int8, neg, trunc, bad, ok bool) {
+ var i uint // make it uint, so that we eliminate bounds checking
+ var slen = uint(len(s))
+ if slen == 0 {
+ bad = true
+ return
+ }
+ switch s[0] {
+ case '+':
+ i++
+ case '-':
+ neg = true
+ i++
+ }
+
+ // we considered punting early if string has length > maxMantDigits, but this doesn't account
+ // for trailing 0's e.g. 700000000000000000000 can be encoded exactly as it is 7e20
+
+ // var sawdot, sawdigits, sawexp bool
+ var sawdot, sawexp bool
+ var nd, ndMant, dp int8
+L:
+ for ; i < slen; i++ {
+ switch s[i] {
+ case '.':
+ if sawdot {
+ bad = true
+ return
+ }
+ sawdot = true
+ dp = nd
+ case '0':
+ if nd == 0 { // ignore leading zeros
+ dp--
+ continue
+ }
+ nd++
+ if ndMant < y.maxMantDigits {
+ // mantissa = (mantissa << 1) + (mantissa << 3)
+ mantissa *= fBase
+ ndMant++
+ }
+ case '1', '2', '3', '4', '5', '6', '7', '8', '9':
+ // sawdigits = true
+ nd++
+ if ndMant < y.maxMantDigits {
+ // mantissa = (mantissa << 1) + (mantissa << 3) + uint64(s[i]-'0')
+ mantissa = mantissa*fBase + uint64(s[i]-'0')
+ // mantissa *= fBase
+ // mantissa += uint64(s[i] - '0')
+ ndMant++
+ } else {
+ trunc = true
+ return // break L
+ }
+ case 'e', 'E':
+ sawexp = true
+ break L
+ default:
+ bad = true
+ return
+ }
+ }
+ // if !sawdigits {
+ // bad = true
+ // return
+ // }
+ if !sawdot {
+ dp = nd
+ }
+
+ if sawexp {
+ i++
+ if i < slen {
+ var eneg bool
+ if s[i] == '+' {
+ i++
+ } else if s[i] == '-' {
+ i++
+ eneg = true
+ }
+ if i < slen {
+ // for exact match, exponent is 1 or 2 digits (float64: -22 to 37, float32: -1 to 17).
+ // exit quick if exponent is more than 2 digits.
+ if i+2 < slen {
+ return
+ }
+
+ var e int8
+
+ if s[i] < '0' || s[i] > '9' {
+ bad = true
+ return
+ }
+ e = e*fBase + int8(s[i]-'0') // (e << 1) + (e << 3) + int8(s[i]-'0')
+ i++
+
+ if i < slen {
+ if s[i] < '0' || s[i] > '9' {
+ bad = true
+ return
+ }
+ e = e*fBase + int8(s[i]-'0') // (e << 1) + (e << 3) + int8(s[i]-'0')
+ i++
+ }
+
+ if eneg {
+ dp -= e
+ } else {
+ dp += e
+ }
+ }
+ }
+ }
+
+ if mantissa != 0 {
+ if mantissa>>y.mantbits != 0 {
+ return
+ }
+ exp = dp - ndMant
+ if exp < -y.exactPow10 || exp > y.exactInts+y.exactPow10 { // cannot handle it
+ return
+ }
+ }
+ ok = true // && !trunc // if trunc=true, we return early (so here trunc=false)
+ return
+}
+
+// fMul10ShiftU64
+
+// func parseFloatDebug(b []byte, bitsize int, strconv bool, exp int8, trunc, ok bool) {
+// if strconv {
+// xdebugf("parseFloat%d: delegating: %s, exp: %d, trunc: %v, ok: %v", bitsize, b, exp, trunc, ok)
+// } else {
+// xdebug2f("parseFloat%d: attempting: %s, exp: %d, trunc: %v, ok: %v", bitsize, b, exp, trunc, ok)
+// }
+// }
diff --git a/baas-kubeengine/vendor/github.com/ugorji/go/codec/gen-dec-array.go.tmpl b/baas-kubeengine/vendor/github.com/ugorji/go/codec/gen-dec-array.go.tmpl
index 790e914e..d2caa0b6 100644
--- a/baas-kubeengine/vendor/github.com/ugorji/go/codec/gen-dec-array.go.tmpl
+++ b/baas-kubeengine/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/baas-kubeengine/vendor/github.com/ugorji/go/codec/gen-dec-map.go.tmpl b/baas-kubeengine/vendor/github.com/ugorji/go/codec/gen-dec-map.go.tmpl
index 8323b549..35bda4a1 100644
--- a/baas-kubeengine/vendor/github.com/ugorji/go/codec/gen-dec-map.go.tmpl
+++ b/baas-kubeengine/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/baas-kubeengine/vendor/github.com/ugorji/go/codec/gen-helper.generated.go b/baas-kubeengine/vendor/github.com/ugorji/go/codec/gen-helper.generated.go
index 2a7d1aab..d86d3af4 100644
--- a/baas-kubeengine/vendor/github.com/ugorji/go/codec/gen-helper.generated.go
+++ b/baas-kubeengine/vendor/github.com/ugorji/go/codec/gen-helper.generated.go
@@ -7,23 +7,14 @@
package codec
-import (
- "encoding"
- "reflect"
-)
+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.
//
@@ -47,56 +38,22 @@ type genHelperEncDriver struct {
encDriver
}
-func (x genHelperEncDriver) EncodeBuiltin(rt uintptr, v interface{}) {}
-func (x genHelperEncDriver) EncStructFieldKey(keyType valueType, s string) {
- encStructFieldKey(s, x.encDriver, nil, keyType, false, false)
-}
-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*
@@ -116,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*
@@ -142,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)
@@ -161,41 +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*
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) HasExtensions() bool {
- return len(f.e.h.extHandle) != 0
-}
+func (f genHelperEncoder) EncWriteMapStart(length int) { f.e.mapStart(length) }
// 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) 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 -----------------
@@ -224,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*
@@ -250,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)
}
}
@@ -260,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)
}
}
@@ -277,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
@@ -303,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*
@@ -312,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/baas-kubeengine/vendor/github.com/ugorji/go/codec/gen-helper.go.tmpl b/baas-kubeengine/vendor/github.com/ugorji/go/codec/gen-helper.go.tmpl
index f5d0634e..44652331 100644
--- a/baas-kubeengine/vendor/github.com/ugorji/go/codec/gen-helper.go.tmpl
+++ b/baas-kubeengine/vendor/github.com/ugorji/go/codec/gen-helper.go.tmpl
@@ -7,10 +7,7 @@
package codec
-import (
- "encoding"
- "reflect"
-)
+import "encoding"
// GenVersion is the current version of codecgen.
const GenVersion = {{ .Version }}
@@ -18,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.
//
@@ -47,56 +46,22 @@ type genHelperEncDriver struct {
encDriver
}
-func (x genHelperEncDriver) EncodeBuiltin(rt uintptr, v interface{}) {}
-func (x genHelperEncDriver) EncStructFieldKey(keyType valueType, s string) {
- encStructFieldKey(s, x.encDriver, nil, keyType, false, false)
-}
-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*
@@ -113,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) {
@@ -134,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 {
@@ -151,36 +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*
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) HasExtensions() bool {
- return len(f.e.h.extHandle) != 0
-}
+func (f genHelperEncoder) EncWriteMapStart(length int) { f.e.mapStart(length) }
// 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) 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 -----------------
@@ -204,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) {
@@ -226,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)
}
}
@@ -235,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 {
@@ -272,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/baas-kubeengine/vendor/github.com/ugorji/go/codec/gen.generated.go b/baas-kubeengine/vendor/github.com/ugorji/go/codec/gen.generated.go
index 8b00090a..5aca5a48 100644
--- a/baas-kubeengine/vendor/github.com/ugorji/go/codec/gen.generated.go
+++ b/baas-kubeengine/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/baas-kubeengine/vendor/github.com/ugorji/go/codec/gen.go b/baas-kubeengine/vendor/github.com/ugorji/go/codec/gen.go
index 74c4aa86..3573bc32 100644
--- a/baas-kubeengine/vendor/github.com/ugorji/go/codec/gen.go
+++ b/baas-kubeengine/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.linef("if z.EncBasicHandle().StringToRaw { r.EncodeStringBytesRaw(z.BytesView(string(%s))) } else { r.EncodeStringEnc(codecSelferCcUTF8%s, string(%s)) }", varname, x.xs, 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.linef(`if z.EncBasicHandle().StringToRaw { r.EncodeStringBytesRaw([]byte{}) } else { r.EncodeStringEnc(codecSelferCcUTF8%s, "") }`, 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,51 +1064,69 @@ 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()")
// emulate EncStructFieldKey
switch ti.keyType {
@@ -1063,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)
@@ -1115,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("}")
@@ -1124,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 {
@@ -1162,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))
@@ -1173,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")
@@ -1206,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
@@ -1232,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.
@@ -1250,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.
@@ -1259,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)
}
}
@@ -1286,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
}
@@ -1321,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 {
@@ -1333,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
@@ -1382,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)
@@ -1394,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 {
@@ -1457,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
}
@@ -1482,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
@@ -1490,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)
@@ -1501,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)
}
@@ -1563,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 {
@@ -1582,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
@@ -1603,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 {
@@ -1623,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) {
@@ -1640,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)
@@ -1684,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 + ")")
@@ -1701,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()
@@ -1721,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...)
@@ -1743,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.
@@ -1791,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:]
}
@@ -1878,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) {
@@ -1894,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":
@@ -1903,49 +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 "if e.h.StringToRaw { ee.EncodeStringBytesRaw(bytesView(" + vname + ")) " +
- "} else { 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/baas-kubeengine/vendor/github.com/ugorji/go/codec/go.mod b/baas-kubeengine/vendor/github.com/ugorji/go/codec/go.mod
new file mode 100644
index 00000000..b4760da4
--- /dev/null
+++ b/baas-kubeengine/vendor/github.com/ugorji/go/codec/go.mod
@@ -0,0 +1,5 @@
+module github.com/ugorji/go/codec
+
+require (
+github.com/ugorji/go v1.1.7
+)
diff --git a/baas-kubeengine/vendor/github.com/ugorji/go/codec/goversion_fmt_time_gte_go15.go b/baas-kubeengine/vendor/github.com/ugorji/go/codec/goversion_fmt_time_gte_go15.go
new file mode 100644
index 00000000..a3535988
--- /dev/null
+++ b/baas-kubeengine/vendor/github.com/ugorji/go/codec/goversion_fmt_time_gte_go15.go
@@ -0,0 +1,12 @@
+// 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 go1.5
+
+package codec
+
+import "time"
+
+func fmtTime(t time.Time, b []byte) []byte {
+ return t.AppendFormat(b, time.RFC3339Nano)
+}
diff --git a/baas-kubeengine/vendor/github.com/ugorji/go/codec/goversion_fmt_time_lt_go15.go b/baas-kubeengine/vendor/github.com/ugorji/go/codec/goversion_fmt_time_lt_go15.go
new file mode 100644
index 00000000..41700c32
--- /dev/null
+++ b/baas-kubeengine/vendor/github.com/ugorji/go/codec/goversion_fmt_time_lt_go15.go
@@ -0,0 +1,15 @@
+// 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 !go1.5
+
+package codec
+
+import "time"
+
+func fmtTime(t time.Time, b []byte) []byte {
+ s := t.Format(time.RFC3339Nano)
+ b = b[:len(s)]
+ copy(b, s)
+ return b
+}
diff --git a/baas-kubeengine/vendor/github.com/ugorji/go/codec/goversion_maprange_gte_go112.go b/baas-kubeengine/vendor/github.com/ugorji/go/codec/goversion_maprange_gte_go112.go
new file mode 100644
index 00000000..9931cb6e
--- /dev/null
+++ b/baas-kubeengine/vendor/github.com/ugorji/go/codec/goversion_maprange_gte_go112.go
@@ -0,0 +1,44 @@
+// 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 go1.12
+// +build safe
+
+package codec
+
+import "reflect"
+
+type mapIter struct {
+ t *reflect.MapIter
+ m reflect.Value
+ values bool
+}
+
+func (t *mapIter) ValidKV() (r bool) {
+ return true
+}
+
+func (t *mapIter) Next() (r bool) {
+ return t.t.Next()
+}
+
+func (t *mapIter) Key() reflect.Value {
+ return t.t.Key()
+}
+
+func (t *mapIter) Value() (r reflect.Value) {
+ if t.values {
+ return t.t.Value()
+ }
+ return
+}
+
+func (t *mapIter) Done() {}
+
+func mapRange(t *mapIter, m, k, v reflect.Value, values bool) {
+ *t = mapIter{
+ m: m,
+ t: m.MapRange(),
+ values: values,
+ }
+}
diff --git a/baas-kubeengine/vendor/github.com/ugorji/go/codec/goversion_maprange_lt_go112.go b/baas-kubeengine/vendor/github.com/ugorji/go/codec/goversion_maprange_lt_go112.go
new file mode 100644
index 00000000..1f020bde
--- /dev/null
+++ b/baas-kubeengine/vendor/github.com/ugorji/go/codec/goversion_maprange_lt_go112.go
@@ -0,0 +1,47 @@
+// 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 !go1.12
+// +build !go1.7 safe
+
+package codec
+
+import "reflect"
+
+type mapIter struct {
+ m reflect.Value
+ keys []reflect.Value
+ j int
+ values bool
+}
+
+func (t *mapIter) ValidKV() (r bool) {
+ return true
+}
+
+func (t *mapIter) Next() (r bool) {
+ t.j++
+ return t.j < len(t.keys)
+}
+
+func (t *mapIter) Key() reflect.Value {
+ return t.keys[t.j]
+}
+
+func (t *mapIter) Value() (r reflect.Value) {
+ if t.values {
+ return t.m.MapIndex(t.keys[t.j])
+ }
+ return
+}
+
+func (t *mapIter) Done() {}
+
+func mapRange(t *mapIter, m, k, v reflect.Value, values bool) {
+ *t = mapIter{
+ m: m,
+ keys: m.MapKeys(),
+ values: values,
+ j: -1,
+ }
+}
diff --git a/baas-kubeengine/vendor/github.com/ugorji/go/codec/helper.go b/baas-kubeengine/vendor/github.com/ugorji/go/codec/helper.go
index 8ada846b..8f7626bc 100644
--- a/baas-kubeengine/vendor/github.com/ugorji/go/codec/helper.go
+++ b/baas-kubeengine/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/baas-kubeengine/vendor/github.com/ugorji/go/codec/helper.s b/baas-kubeengine/vendor/github.com/ugorji/go/codec/helper.s
new file mode 100644
index 00000000..e69de29b
diff --git a/baas-kubeengine/vendor/github.com/ugorji/go/codec/helper_internal.go b/baas-kubeengine/vendor/github.com/ugorji/go/codec/helper_internal.go
index 0cbd665e..82d6e314 100644
--- a/baas-kubeengine/vendor/github.com/ugorji/go/codec/helper_internal.go
+++ b/baas-kubeengine/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/baas-kubeengine/vendor/github.com/ugorji/go/codec/helper_not_unsafe.go b/baas-kubeengine/vendor/github.com/ugorji/go/codec/helper_not_unsafe.go
index 74987f9f..4572c6f4 100644
--- a/baas-kubeengine/vendor/github.com/ugorji/go/codec/helper_not_unsafe.go
+++ b/baas-kubeengine/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 rv2rtid(rv reflect.Value) uintptr {
-// return reflect.ValueOf(rv.Type()).Pointer()
-// }
+func rvSetSliceLen(rv reflect.Value, length int) {
+ rv.SetLen(length)
+}
+
+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,189 +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)
+}
+
+// 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) kTime(f *codecFnInfo, rv reflect.Value) {
- e.e.EncodeTime(rv2i(rv).(time.Time))
+// ----------------
+
+func rvSliceIndex(rv reflect.Value, i int, ti *typeInfo) reflect.Value {
+ return rv.Index(i)
}
-func (e *Encoder) kString(f *codecFnInfo, rv reflect.Value) {
- s := rv.String()
- if e.h.StringToRaw {
- e.e.EncodeStringBytesRaw(bytesView(s))
+func rvGetSliceLen(rv reflect.Value) int {
+ return rv.Len()
+}
+
+func rvGetSliceCap(rv reflect.Value) int {
+ return rv.Cap()
+}
+
+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 {
- e.e.EncodeStringEnc(cUTF8, s)
+ bs = make([]byte, l)
}
+ reflect.Copy(rv4i(bs), rv)
+ return
+}
+
+func rvGetArray4Slice(rv reflect.Value) (v reflect.Value) {
+ v = rvZeroAddrK(reflectArrayOf(rvGetSliceLen(rv), rv.Type().Elem()), reflect.Array)
+ reflect.Copy(v, rv)
+ return
+}
+
+func rvGetSlice4Array(rv reflect.Value, tslice reflect.Type) (v reflect.Value) {
+ return rv.Slice(0, rv.Len())
+}
+
+func rvCopySlice(dest, src reflect.Value) {
+ reflect.Copy(dest, src)
+}
+
+// ------------
+
+func rvGetBool(rv reflect.Value) bool {
+ return rv.Bool()
+}
+
+func rvGetBytes(rv reflect.Value) []byte {
+ return rv.Bytes()
+}
+
+func rvGetTime(rv reflect.Value) time.Time {
+ return rv2i(rv).(time.Time)
+}
+
+func rvGetString(rv reflect.Value) string {
+ return rv.String()
}
-func (e *Encoder) kFloat64(f *codecFnInfo, rv reflect.Value) {
- e.e.EncodeFloat64(rv.Float())
+func rvGetFloat64(rv reflect.Value) float64 {
+ return rv.Float()
}
-func (e *Encoder) kFloat32(f *codecFnInfo, rv reflect.Value) {
- e.e.EncodeFloat32(float32(rv.Float()))
+func rvGetFloat32(rv reflect.Value) float32 {
+ return float32(rv.Float())
}
-func (e *Encoder) kInt(f *codecFnInfo, rv reflect.Value) {
- e.e.EncodeInt(rv.Int())
+func rvGetInt(rv reflect.Value) int {
+ return int(rv.Int())
}
-func (e *Encoder) kInt8(f *codecFnInfo, rv reflect.Value) {
- e.e.EncodeInt(rv.Int())
+func rvGetInt8(rv reflect.Value) int8 {
+ return int8(rv.Int())
}
-func (e *Encoder) kInt16(f *codecFnInfo, rv reflect.Value) {
- e.e.EncodeInt(rv.Int())
+func rvGetInt16(rv reflect.Value) int16 {
+ return int16(rv.Int())
}
-func (e *Encoder) kInt32(f *codecFnInfo, rv reflect.Value) {
- e.e.EncodeInt(rv.Int())
+func rvGetInt32(rv reflect.Value) int32 {
+ return int32(rv.Int())
}
-func (e *Encoder) kInt64(f *codecFnInfo, rv reflect.Value) {
- e.e.EncodeInt(rv.Int())
+func rvGetInt64(rv reflect.Value) int64 {
+ return rv.Int()
}
-func (e *Encoder) kUint(f *codecFnInfo, rv reflect.Value) {
- e.e.EncodeUint(rv.Uint())
+func rvGetUint(rv reflect.Value) uint {
+ return uint(rv.Uint())
}
-func (e *Encoder) kUint8(f *codecFnInfo, rv reflect.Value) {
- e.e.EncodeUint(rv.Uint())
+func rvGetUint8(rv reflect.Value) uint8 {
+ return uint8(rv.Uint())
}
-func (e *Encoder) kUint16(f *codecFnInfo, rv reflect.Value) {
- e.e.EncodeUint(rv.Uint())
+func rvGetUint16(rv reflect.Value) uint16 {
+ return uint16(rv.Uint())
}
-func (e *Encoder) kUint32(f *codecFnInfo, rv reflect.Value) {
- e.e.EncodeUint(rv.Uint())
+func rvGetUint32(rv reflect.Value) uint32 {
+ return uint32(rv.Uint())
}
-func (e *Encoder) kUint64(f *codecFnInfo, rv reflect.Value) {
- e.e.EncodeUint(rv.Uint())
+func rvGetUint64(rv reflect.Value) uint64 {
+ return rv.Uint()
}
-func (e *Encoder) kUintptr(f *codecFnInfo, rv reflect.Value) {
- e.e.EncodeUint(rv.Uint())
+func rvGetUintptr(rv reflect.Value) uintptr {
+ return uintptr(rv.Uint())
}
-// // 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) {}
+// ------------ map range and map indexing ----------
-// // 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 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()
+}
-// 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
-// }
-// }
+// ---------- 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/baas-kubeengine/vendor/github.com/ugorji/go/codec/helper_unsafe.go b/baas-kubeengine/vendor/github.com/ugorji/go/codec/helper_unsafe.go
index 3bc34d90..9a22ccf5 100644
--- a/baas-kubeengine/vendor/github.com/ugorji/go/codec/helper_unsafe.go
+++ b/baas-kubeengine/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,441 +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) = v
+}
+
+func rvSetFloat64(rv reflect.Value, v float64) {
+ urv := (*unsafeReflectValue)(unsafe.Pointer(&rv))
+ *(*float64)(urv.ptr) = v
+}
+
+func rvSetInt(rv reflect.Value, v int) {
urv := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- *(*float32)(urv.ptr) = float32(fv)
+ *(*int)(urv.ptr) = v
}
-func (d *Decoder) kFloat64(f *codecFnInfo, rv reflect.Value) {
+func rvSetInt8(rv reflect.Value, v int8) {
urv := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- *(*float64)(urv.ptr) = d.d.DecodeFloat64()
+ *(*int8)(urv.ptr) = v
}
-func (d *Decoder) kInt(f *codecFnInfo, rv reflect.Value) {
+func rvSetInt16(rv reflect.Value, v int16) {
urv := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- *(*int)(urv.ptr) = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize))
+ *(*int16)(urv.ptr) = v
}
-func (d *Decoder) kInt8(f *codecFnInfo, rv reflect.Value) {
+func rvSetInt32(rv reflect.Value, v int32) {
urv := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- *(*int8)(urv.ptr) = int8(chkOvf.IntV(d.d.DecodeInt64(), 8))
+ *(*int32)(urv.ptr) = v
}
-func (d *Decoder) kInt16(f *codecFnInfo, rv reflect.Value) {
+func rvSetInt64(rv reflect.Value, v int64) {
urv := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- *(*int16)(urv.ptr) = int16(chkOvf.IntV(d.d.DecodeInt64(), 16))
+ *(*int64)(urv.ptr) = v
}
-func (d *Decoder) kInt32(f *codecFnInfo, rv reflect.Value) {
+func rvSetUint(rv reflect.Value, v uint) {
urv := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- *(*int32)(urv.ptr) = int32(chkOvf.IntV(d.d.DecodeInt64(), 32))
+ *(*uint)(urv.ptr) = v
}
-func (d *Decoder) kInt64(f *codecFnInfo, rv reflect.Value) {
+func rvSetUintptr(rv reflect.Value, v uintptr) {
urv := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- *(*int64)(urv.ptr) = d.d.DecodeInt64()
+ *(*uintptr)(urv.ptr) = v
}
-func (d *Decoder) kUint(f *codecFnInfo, rv reflect.Value) {
+func rvSetUint8(rv reflect.Value, v uint8) {
urv := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- *(*uint)(urv.ptr) = uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize))
+ *(*uint8)(urv.ptr) = v
}
-func (d *Decoder) kUintptr(f *codecFnInfo, rv reflect.Value) {
+func rvSetUint16(rv reflect.Value, v uint16) {
urv := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- *(*uintptr)(urv.ptr) = uintptr(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize))
+ *(*uint16)(urv.ptr) = v
}
-func (d *Decoder) kUint8(f *codecFnInfo, rv reflect.Value) {
+func rvSetUint32(rv reflect.Value, v uint32) {
urv := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- *(*uint8)(urv.ptr) = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8))
+ *(*uint32)(urv.ptr) = v
}
-func (d *Decoder) kUint16(f *codecFnInfo, rv reflect.Value) {
+func rvSetUint64(rv reflect.Value, v uint64) {
urv := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- *(*uint16)(urv.ptr) = uint16(chkOvf.UintV(d.d.DecodeUint64(), 16))
+ *(*uint64)(urv.ptr) = v
}
-func (d *Decoder) kUint32(f *codecFnInfo, rv reflect.Value) {
+// ----------------
+
+// rvSetDirect is rv.Set for all kinds except reflect.Interface
+func rvSetDirect(rv reflect.Value, v reflect.Value) {
urv := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- *(*uint32)(urv.ptr) = uint32(chkOvf.UintV(d.d.DecodeUint64(), 32))
+ uv := (*unsafeReflectValue)(unsafe.Pointer(&v))
+ if uv.flag&unsafeFlagIndir == 0 {
+ *(*unsafe.Pointer)(urv.ptr) = uv.ptr
+ } else {
+ typedmemmove(urv.typ, urv.ptr, uv.ptr)
+ }
}
-func (d *Decoder) kUint64(f *codecFnInfo, rv reflect.Value) {
+// rvSlice returns a slice of the slice of lenth
+func rvSlice(rv reflect.Value, length int) (v reflect.Value) {
urv := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- *(*uint64)(urv.ptr) = d.d.DecodeUint64()
+ 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 (e *Encoder) kBool(f *codecFnInfo, rv reflect.Value) {
+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 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))
- s := *(*string)(v.ptr)
- if e.h.StringToRaw {
- e.e.EncodeStringBytesRaw(bytesView(s))
- } else {
- e.e.EncodeStringEnc(cUTF8, s)
- }
+ 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/baas-kubeengine/vendor/github.com/ugorji/go/codec/json.go b/baas-kubeengine/vendor/github.com/ugorji/go/codec/json.go
index 619bc5b5..7b64e02e 100644
--- a/baas-kubeengine/vendor/github.com/ugorji/go/codec/json.go
+++ b/baas-kubeengine/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/baas-kubeengine/vendor/github.com/ugorji/go/codec/mammoth-test.go.tmpl b/baas-kubeengine/vendor/github.com/ugorji/go/codec/mammoth-test.go.tmpl
index c598cc73..ba55b396 100644
--- a/baas-kubeengine/vendor/github.com/ugorji/go/codec/mammoth-test.go.tmpl
+++ b/baas-kubeengine/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/baas-kubeengine/vendor/github.com/ugorji/go/codec/msgpack.go b/baas-kubeengine/vendor/github.com/ugorji/go/codec/msgpack.go
index 85c71f22..4543337d 100644
--- a/baas-kubeengine/vendor/github.com/ugorji/go/codec/msgpack.go
+++ b/baas-kubeengine/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"
)
@@ -200,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) {
@@ -217,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) {
@@ -309,56 +308,65 @@ func (e *msgpackEncDriver) EncodeTime(t time.Time) {
}
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)
}
}
@@ -370,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(msgpackContainerRawLegacy, 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(msgpackContainerRawLegacy, slen)
+ ct = msgpackContainerRawLegacy
}
- if slen > 0 {
- e.w.writeb(bs)
+ e.writeContainerLen(ct, len(s))
+ if len(s) > 0 {
+ e.e.encWr.writestr(s)
}
}
@@ -411,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(msgpackContainerRawLegacy, 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.fixCutoff > 0 && l < int(ct.fixCutoff) {
- e.w.writen1(ct.bFixMin | byte(l))
+ e.e.encWr.writen1(ct.bFixMin | byte(l))
} else if ct.b8 > 0 && l < 256 {
- e.w.writen2(ct.b8, uint8(l))
+ 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,
@@ -462,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
@@ -470,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
@@ -479,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 {
@@ -521,15 +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.WriteExt {
+ 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:
- decNakedReadRawBytes(d, d.d, n, d.h.RawToString)
+ decNakedReadRawBytes(d, &d.d, n, d.h.RawToString)
case bd == mpArray16, bd == mpArray32, bd >= mpFixArrayMin && bd <= mpFixArrayMax:
n.v = valueTypeArray
decodeFurther = true
@@ -539,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))
@@ -563,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:
@@ -600,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)
@@ -658,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())
}
@@ -674,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
@@ -690,26 +681,30 @@ 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
}
bd := d.bd
var clen int
- if bd == mpNil {
- d.bdRead = false
- return
- } else if bd == mpBin8 || bd == mpBin16 || bd == mpBin32 {
+ if bd == mpBin8 || bd == mpBin16 || bd == mpBin32 {
clen = d.readContainerLen(msgpackContainerBin) // binary
- } else if bd == mpStr8 || bd == mpStr16 || bd == mpStr32 || (bd >= mpFixStrMin && bd <= mpFixStrMax) {
+ } 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) {
+ } 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
+ // 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
@@ -717,17 +712,13 @@ func (d *msgpackDecDriver) 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.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) {
@@ -735,15 +726,32 @@ 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) {
@@ -751,23 +759,16 @@ func (d *msgpackDecDriver) ContainerType() (vt valueType) {
d.readNextBd()
}
bd := d.bd
- // if bd == mpNil {
- // // nil
- // } else if bd == mpBin8 || bd == mpBin16 || bd == mpBin32 {
- // // binary
- // } else if bd == mpStr8 || bd == mpStr16 || bd == mpStr32 || (bd >= mpFixStrMin && bd <= mpFixStrMax) {
- // // string/raw
- // } else if bd == mpArray16 || bd == mpArray32 || (bd >= mpFixArrayMin && bd <= mpFixArrayMax) {
- // // array
- // } else if bd == mpMap16 || bd == mpMap32 || (bd >= mpFixMapMin && bd <= mpFixMapMax) {
- // // map
- // }
+ d.fnil = false
if bd == mpNil {
+ d.bdRead = false
+ d.fnil = true
return valueTypeNil
} else if bd == mpBin8 || bd == mpBin16 || bd == mpBin32 {
return valueTypeBytes
- } else if bd == mpStr8 || bd == mpStr16 || bd == mpStr32 || (bd >= mpFixStrMin && bd <= mpFixStrMax) {
- if d.h.WriteExt { // UTF-8 string (new spec)
+ } 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)
@@ -776,33 +777,21 @@ func (d *msgpackDecDriver) ContainerType() (vt valueType) {
} 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 {
@@ -814,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:
@@ -842,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
@@ -856,27 +843,25 @@ 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.advanceNil() {
+ return
}
bd := d.bd
var clen int
- if bd == mpNil {
- d.bdRead = false
- return
- } else if bd == mpBin8 || bd == mpBin16 || bd == mpBin32 {
+ if bd == mpBin8 || bd == mpBin16 || bd == mpBin32 {
clen = d.readContainerLen(msgpackContainerBin) // binary
- } else if bd == mpStr8 || bd == mpStr16 || bd == mpStr32 || (bd >= mpFixStrMin && bd <= mpFixStrMax) {
+ } 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 stream for decoding time as extension: got 0x%x, 0x%x", d.bd, b2)
@@ -887,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)
@@ -906,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)
@@ -935,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
@@ -954,6 +940,7 @@ 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
// NoFixedNum says to output all signed integers as 2-bytes, never as 1-byte fixednum.
@@ -976,35 +963,34 @@ type MsgpackHandle struct {
// 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
}
//--------------------------------------------------
@@ -1065,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/baas-kubeengine/vendor/github.com/ugorji/go/codec/prebuild.go b/baas-kubeengine/vendor/github.com/ugorji/go/codec/prebuild.go
new file mode 100644
index 00000000..7771057e
--- /dev/null
+++ b/baas-kubeengine/vendor/github.com/ugorji/go/codec/prebuild.go
@@ -0,0 +1,136 @@
+// +build prebuild
+
+package main
+
+// prebuild.go generates sort implementations for
+// various slice types and combination slice+reflect.Value types.
+//
+// The combination slice+reflect.Value types are used
+// during canonical encode, and the others are used during fast-path
+// encoding of map keys.
+
+import (
+ "bytes"
+ "go/format"
+ "io/ioutil"
+ "os"
+ "strings"
+ "text/template"
+)
+
+// genInternalSortableTypes returns the types
+// that are used for fast-path canonical's encoding of maps.
+//
+// For now, we only support the highest sizes for
+// int64, uint64, float64, bool, string, bytes.
+func genInternalSortableTypes() []string {
+ return []string{
+ "string",
+ // "float32",
+ "float64",
+ // "uint",
+ // "uint8",
+ // "uint16",
+ // "uint32",
+ "uint64",
+ "uintptr",
+ // "int",
+ // "int8",
+ // "int16",
+ // "int32",
+ "int64",
+ "bool",
+ "time",
+ "bytes",
+ }
+}
+
+// genInternalSortablePlusTypes returns the types
+// that are used for reflection-based canonical's encoding of maps.
+//
+// For now, we only support the highest sizes for
+// int64, uint64, float64, bool, string, bytes.
+func genInternalSortablePlusTypes() []string {
+ return []string{
+ "string",
+ "float64",
+ "uint64",
+ "uintptr",
+ "int64",
+ "bool",
+ "time",
+ "bytes",
+ }
+}
+
+func genTypeForShortName(s string) string {
+ switch s {
+ case "time":
+ return "time.Time"
+ case "bytes":
+ return "[]byte"
+ }
+ return s
+}
+
+func genArgs(args ...interface{}) map[string]interface{} {
+ m := make(map[string]interface{}, len(args)/2)
+ for i := 0; i < len(args); {
+ m[args[i].(string)] = args[i+1]
+ i += 2
+ }
+ return m
+}
+
+func genEndsWith(s0 string, sn ...string) bool {
+ for _, s := range sn {
+ if strings.HasSuffix(s0, s) {
+ return true
+ }
+ }
+ return false
+}
+
+func chkerr(err error) {
+ if err != nil {
+ panic(err)
+ }
+}
+
+func run(fnameIn, fnameOut string) {
+ var err error
+
+ funcs := make(template.FuncMap)
+ funcs["sortables"] = genInternalSortableTypes
+ funcs["sortablesplus"] = genInternalSortablePlusTypes
+ funcs["tshort"] = genTypeForShortName
+ funcs["endswith"] = genEndsWith
+ funcs["args"] = genArgs
+
+ t := template.New("").Funcs(funcs)
+ fin, err := os.Open(fnameIn)
+ chkerr(err)
+ defer fin.Close()
+ fout, err := os.Create(fnameOut)
+ chkerr(err)
+ defer fout.Close()
+ tmplstr, err := ioutil.ReadAll(fin)
+ chkerr(err)
+ t, err = t.Parse(string(tmplstr))
+ chkerr(err)
+ var out bytes.Buffer
+ err = t.Execute(&out, 0)
+ chkerr(err)
+ bout, err := format.Source(out.Bytes())
+ if err != nil {
+ fout.Write(out.Bytes()) // write out if error, so we can still see.
+ }
+ chkerr(err)
+ // write out if error, as much as possible, so we can still see.
+ _, err = fout.Write(bout)
+ chkerr(err)
+}
+
+func main() {
+ run("sort-slice.go.tmpl", "sort-slice.generated.go")
+}
diff --git a/baas-kubeengine/vendor/github.com/ugorji/go/codec/reader.go b/baas-kubeengine/vendor/github.com/ugorji/go/codec/reader.go
new file mode 100644
index 00000000..1c3fe88e
--- /dev/null
+++ b/baas-kubeengine/vendor/github.com/ugorji/go/codec/reader.go
@@ -0,0 +1,1017 @@
+// 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
+
+import "io"
+
+// decReader abstracts the reading source, allowing implementations that can
+// read from an io.Reader or directly off a byte slice with zero-copying.
+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 uint) []byte
+ readb([]byte)
+ readn1() uint8
+ // read up to 7 bytes at a time
+ readn(num uint8) (v [rwNLen]byte)
+ 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(accept *bitset256) (out []byte)
+ // readUntil will read, only stopping once it matches the 'stop' byte.
+ readUntil(stop byte, includeLast bool) (out []byte)
+}
+
+// ------------------------------------------------
+
+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
+
+ blist *bytesFreelist
+
+ tr []byte // buffer for tracking bytes
+ bufr []byte // buffer for readTo/readUntil
+}
+
+func (z *ioDecReaderCommon) last() byte {
+ return z.l
+}
+
+func (z *ioDecReaderCommon) reset(r io.Reader, blist *bytesFreelist) {
+ z.blist = blist
+ z.r = r
+ z.ls = unreadByteUndefined
+ z.l, z.n = 0, 0
+ z.trb = false
+}
+
+func (z *ioDecReaderCommon) numread() uint {
+ return z.n
+}
+
+func (z *ioDecReaderCommon) track() {
+ z.tr = z.blist.check(z.tr, 256)[:0]
+ z.trb = true
+}
+
+func (z *ioDecReaderCommon) stopTrack() (bs []byte) {
+ z.trb = false
+ return z.tr
+}
+
+// ------------------------------------------
+
+// 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 [64 + 16]byte // for: get struct field name, swallow valueTypeBytes, etc
+ // _ [1]uint64 // padding
+}
+
+func (z *ioDecReader) reset(r io.Reader, blist *bytesFreelist) {
+ z.ioDecReaderCommon.reset(r, blist)
+
+ z.br, _ = r.(io.ByteScanner)
+}
+
+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) {
+ if z.br != nil {
+ c, err = z.br.ReadByte()
+ if err == nil {
+ z.l = c
+ z.ls = unreadByteCanUnread
+ }
+ return
+ }
+
+ 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) {
+ if z.br != nil {
+ err = z.br.UnreadByte()
+ if err == nil {
+ z.ls = unreadByteCanRead
+ }
+ return
+ }
+
+ switch z.ls {
+ case unreadByteCanUnread:
+ z.ls = unreadByteCanRead
+ case unreadByteCanRead:
+ err = errDecUnreadByteLastByteNotRead
+ case unreadByteUndefined:
+ err = errDecUnreadByteNothingToRead
+ default:
+ err = errDecUnreadByteUnknown
+ }
+ return
+}
+
+func (z *ioDecReader) readn(num uint8) (bs [rwNLen]byte) {
+ z.readb(bs[:num])
+ // copy(bs[:], z.readx(uint(num)))
+ 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.r, 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.r, 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.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 (z *ioDecReader) readn1() (b uint8) {
+ b, err := z.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
+LOOP:
+ token, eof = z.readn1eof()
+ if eof {
+ return
+ }
+ if accept.isset(token) {
+ goto LOOP
+ }
+ return
+}
+
+func (z *ioDecReader) readTo(accept *bitset256) []byte {
+ z.bufr = z.blist.check(z.bufr, 256)[:0]
+LOOP:
+ token, eof := z.readn1eof()
+ if eof {
+ return z.bufr
+ }
+ if accept.isset(token) {
+ z.bufr = append(z.bufr, token)
+ goto LOOP
+ }
+ z.unreadn1()
+ return z.bufr
+}
+
+func (z *ioDecReader) readUntil(stop byte, includeLast bool) []byte {
+ z.bufr = z.blist.check(z.bufr, 256)[:0]
+LOOP:
+ token, eof := z.readn1eof()
+ if eof {
+ panic(io.EOF)
+ }
+ z.bufr = append(z.bufr, token)
+ if token == stop {
+ if includeLast {
+ return z.bufr
+ }
+ return z.bufr[:len(z.bufr)-1]
+ }
+ goto LOOP
+}
+
+//go:noinline
+func (z *ioDecReader) unreadn1() {
+ err := z.UnreadByte()
+ if err != nil {
+ panic(err)
+ }
+ z.n--
+ if z.trb {
+ if l := len(z.tr) - 1; l >= 0 {
+ z.tr = z.tr[:l]
+ }
+ }
+}
+
+// ------------------------------------
+
+type bufioDecReader struct {
+ ioDecReaderCommon
+
+ c uint // cursor
+ buf []byte
+}
+
+func (z *bufioDecReader) reset(r io.Reader, bufsize int, blist *bytesFreelist) {
+ z.ioDecReaderCommon.reset(r, blist)
+ z.c = 0
+ if cap(z.buf) < bufsize {
+ z.buf = blist.get(bufsize)
+ }
+ z.buf = z.buf[:0]
+}
+
+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...)
+ }
+ } else {
+ z.readbFill(p, n)
+ }
+}
+
+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) last() byte {
+ return z.buf[z.c-1]
+}
+
+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 (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 (z *bufioDecReader) readn(num uint8) (bs [rwNLen]byte) {
+ z.readb(bs[:num])
+ // copy(bs[:], z.readx(uint(num)))
+ return
+}
+
+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 (z *bufioDecReader) skip(accept *bitset256) (token byte) {
+ 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.tr = append(z.tr, z.buf[z.c:i]...) // z.doTrack(i)
+ }
+ z.c = i
+ return
+ }
+ return z.skipFill(accept)
+}
+
+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 i, 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]
+ for i, token = range z.buf {
+ // if !accept.isset(token) {
+ if accept.check(token) == 0 {
+ z.n += (uint(i) - z.c) - 1
+ z.loopFn(uint(i + 1))
+ return
+ }
+ }
+ z.n += uint(n2)
+ if z.trb {
+ z.tr = append(z.tr, z.buf...)
+ }
+ }
+}
+
+func (z *bufioDecReader) loopFn(i uint) {
+ if z.trb {
+ z.tr = append(z.tr, z.buf[z.c:i]...) // z.doTrack(i)
+ }
+ z.c = i
+}
+
+func (z *bufioDecReader) readTo(accept *bitset256) (out []byte) {
+ i := z.c
+LOOP:
+ if i < uint(len(z.buf)) {
+ // if !accept.isset(z.buf[i]) {
+ if accept.check(z.buf[i]) == 0 {
+ // inline readToLoopFn here (for performance)
+ z.n += (i - z.c) - 1
+ out = 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
+ }
+ i++
+ goto LOOP
+ }
+ return z.readToFill(accept)
+}
+
+func (z *bufioDecReader) readToFill(accept *bitset256) []byte {
+ z.bufr = z.blist.check(z.bufr, 256)[:0]
+ z.n += uint(len(z.buf)) - z.c
+ z.bufr = append(z.bufr, 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[:cap(z.buf)]
+ n2, err = z.r.Read(z.buf)
+ if n2 == 0 && err != nil {
+ if err == io.EOF {
+ return z.bufr // 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) {
+ if accept.check(token) == 0 {
+ z.n += (uint(i) - z.c) - 1
+ z.bufr = append(z.bufr, z.buf[z.c:i]...)
+ z.loopFn(uint(i))
+ return z.bufr
+ }
+ }
+ z.bufr = append(z.bufr, z.buf...)
+ z.n += uint(n2)
+ if z.trb {
+ z.tr = append(z.tr, z.buf...)
+ }
+ }
+}
+
+func (z *bufioDecReader) readUntil(stop byte, includeLast bool) (out []byte) {
+ i := z.c
+LOOP:
+ if i < uint(len(z.buf)) {
+ if z.buf[i] == stop {
+ z.n += (i - z.c) - 1
+ i++
+ out = z.buf[z.c:i]
+ if z.trb {
+ z.tr = append(z.tr, z.buf[z.c:i]...) // z.doTrack(i)
+ }
+ z.c = i
+ goto FINISH
+ }
+ i++
+ goto LOOP
+ }
+ out = z.readUntilFill(stop)
+FINISH:
+ if includeLast {
+ return
+ }
+ return out[:len(out)-1]
+}
+
+func (z *bufioDecReader) readUntilFill(stop byte) []byte {
+ z.bufr = z.blist.check(z.bufr, 256)[:0]
+ z.n += uint(len(z.buf)) - z.c
+ z.bufr = append(z.bufr, z.buf[z.c:]...)
+ if z.trb {
+ z.tr = append(z.tr, z.buf[z.c:]...)
+ }
+ for {
+ z.c = 0
+ z.buf = z.buf[0:cap(z.buf)]
+ n1, err := z.r.Read(z.buf)
+ if n1 == 0 && err != nil {
+ panic(err)
+ }
+ n2 := uint(n1)
+ z.buf = z.buf[:n2]
+ for i, token := range z.buf {
+ if token == stop {
+ z.n += (uint(i) - z.c) - 1
+ z.bufr = append(z.bufr, z.buf[z.c:i+1]...)
+ z.loopFn(uint(i + 1))
+ return z.bufr
+ }
+ }
+ z.bufr = append(z.bufr, z.buf...)
+ z.n += n2
+ if z.trb {
+ z.tr = append(z.tr, z.buf...)
+ }
+ }
+}
+
+// ------------------------------------
+
+// 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 (z *bytesDecReader) reset(in []byte) {
+ z.b = in
+ z.c = 0
+ z.t = 0
+}
+
+func (z *bytesDecReader) numread() uint {
+ return z.c
+}
+
+func (z *bytesDecReader) last() byte {
+ return z.b[z.c-1]
+}
+
+func (z *bytesDecReader) unreadn1() {
+ if z.c == 0 || len(z.b) == 0 {
+ panic(errBytesDecReaderCannotUnread)
+ }
+ z.c--
+}
+
+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.
+
+ 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) {
+ v = z.b[z.c]
+ z.c++
+ return
+}
+
+func (z *bytesDecReader) readn(num uint8) (bs [rwNLen]byte) {
+ // if z.c >= uint(len(z.b)) || z.c+uint(num) >= uint(len(z.b)) {
+ // panic(io.EOF)
+ // }
+
+ // for bounds-check elimination, reslice z.b and ensure bs is within len
+ // bb := z.b[z.c:][:num]
+ bb := z.b[z.c : z.c+uint(num)]
+ _ = bs[len(bb)-1]
+ var i int
+LOOP:
+ if i < len(bb) {
+ bs[i] = bb[i]
+ i++
+ goto LOOP
+ }
+
+ z.c += uint(num)
+ return
+}
+
+func (z *bytesDecReader) skip(accept *bitset256) (token byte) {
+ i := z.c
+LOOP:
+ // if i < uint(len(z.b)) {
+ token = z.b[i]
+ i++
+ if accept.isset(token) {
+ goto LOOP
+ }
+ z.c = i
+ return
+}
+
+func (z *bytesDecReader) readTo(accept *bitset256) (out []byte) {
+ i := z.c
+LOOP:
+ if i < uint(len(z.b)) {
+ if accept.isset(z.b[i]) {
+ i++
+ goto LOOP
+ }
+ }
+
+ out = z.b[z.c:i]
+ z.c = i
+ return // z.b[c:i]
+}
+
+func (z *bytesDecReader) readUntil(stop byte, includeLast bool) (out []byte) {
+ i := z.c
+LOOP:
+ // if i < uint(len(z.b)) {
+ if z.b[i] == stop {
+ i++
+ if includeLast {
+ out = z.b[z.c:i]
+ } else {
+ out = z.b[z.c : i-1]
+ }
+ // z.a -= (i - z.c)
+ z.c = i
+ return
+ }
+ i++
+ goto LOOP
+ // }
+ // panic(io.EOF)
+}
+
+func (z *bytesDecReader) track() {
+ z.t = z.c
+}
+
+func (z *bytesDecReader) stopTrack() (bs []byte) {
+ return z.b[z.t:z.c]
+}
+
+// --------------
+
+type decRd struct {
+ mtr bool // is maptype a known type?
+ str bool // is slicetype a known type?
+
+ be bool // is binary encoding
+ js bool // is json handle
+ jsms bool // is json handle, and MapKeyAsString
+ cbor bool // is cbor handle
+
+ bytes bool // is bytes reader
+ bufio bool // is this a bufioDecReader?
+
+ rb bytesDecReader
+ ri *ioDecReader
+ bi *bufioDecReader
+}
+
+// numread, track and stopTrack are always inlined, as they just check int fields, etc.
+
+// 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 decRd 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).
+//
+// However, up through Go 1.13, decRd's readXXX, skip and unreadXXX methods are not inlined.
+// Consequently, there is no benefit to do the xxxIO methods for decRd at this time.
+// Instead, we have a if/else-if/else block so that IO calls do not have to jump through
+// a second unnecessary function call.
+//
+// If golang inlining gets better and bytesDecReader methods can be inlined,
+// then we can revert to using these 2 functions so the bytesDecReader
+// methods are inlined and the IO paths call out to a function.
+
+func (z *decRd) numread() uint {
+ if z.bytes {
+ return z.rb.numread()
+ } else if z.bufio {
+ return z.bi.numread()
+ } else {
+ return z.ri.numread()
+ }
+}
+func (z *decRd) stopTrack() []byte {
+ if z.bytes {
+ return z.rb.stopTrack()
+ } else if z.bufio {
+ return z.bi.stopTrack()
+ } else {
+ return z.ri.stopTrack()
+ }
+}
+
+func (z *decRd) track() {
+ if z.bytes {
+ z.rb.track()
+ } else if z.bufio {
+ z.bi.track()
+ } else {
+ z.ri.track()
+ }
+}
+
+func (z *decRd) unreadn1() {
+ if z.bytes {
+ z.rb.unreadn1()
+ } else if z.bufio {
+ z.bi.unreadn1()
+ } else {
+ z.ri.unreadn1() // not inlined
+ }
+}
+
+func (z *decRd) readn(num uint8) [rwNLen]byte {
+ if z.bytes {
+ return z.rb.readn(num)
+ } else if z.bufio {
+ return z.bi.readn(num)
+ } else {
+ return z.ri.readn(num)
+ }
+}
+
+func (z *decRd) readx(n uint) []byte {
+ if z.bytes {
+ return z.rb.readx(n)
+ } else if z.bufio {
+ return z.bi.readx(n)
+ } else {
+ return z.ri.readx(n)
+ }
+}
+
+func (z *decRd) readb(s []byte) {
+ if z.bytes {
+ z.rb.readb(s)
+ } else if z.bufio {
+ z.bi.readb(s)
+ } else {
+ z.ri.readb(s)
+ }
+}
+
+func (z *decRd) readn1() uint8 {
+ if z.bytes {
+ return z.rb.readn1()
+ } else if z.bufio {
+ return z.bi.readn1()
+ } else {
+ return z.ri.readn1()
+ }
+}
+
+func (z *decRd) skip(accept *bitset256) (token byte) {
+ if z.bytes {
+ return z.rb.skip(accept)
+ } else if z.bufio {
+ return z.bi.skip(accept)
+ } else {
+ return z.ri.skip(accept)
+ }
+}
+
+func (z *decRd) readTo(accept *bitset256) (out []byte) {
+ if z.bytes {
+ return z.rb.readTo(accept)
+ } else if z.bufio {
+ return z.bi.readTo(accept)
+ } else {
+ return z.ri.readTo(accept)
+ }
+}
+
+func (z *decRd) readUntil(stop byte, includeLast bool) (out []byte) {
+ if z.bytes {
+ return z.rb.readUntil(stop, includeLast)
+ } else if z.bufio {
+ return z.bi.readUntil(stop, includeLast)
+ } else {
+ return z.ri.readUntil(stop, includeLast)
+ }
+}
+
+/*
+func (z *decRd) track() {
+ if z.bytes {
+ z.rb.track()
+ } else {
+ z.trackIO()
+ }
+}
+func (z *decRd) trackIO() {
+ if z.bufio {
+ z.bi.track()
+ } else {
+ z.ri.track()
+ }
+}
+
+func (z *decRd) unreadn1() {
+ if z.bytes {
+ z.rb.unreadn1()
+ } else {
+ z.unreadn1IO()
+ }
+}
+func (z *decRd) unreadn1IO() {
+ if z.bufio {
+ z.bi.unreadn1()
+ } else {
+ z.ri.unreadn1()
+ }
+}
+
+func (z *decRd) readn(num uint8) [rwNLen]byte {
+ if z.bytes {
+ return z.rb.readn(num)
+ }
+ return z.readnIO(num)
+}
+func (z *decRd) readnIO(num uint8) [rwNLen]byte {
+ if z.bufio {
+ return z.bi.readn(num)
+ }
+ return z.ri.readn(num)
+}
+
+func (z *decRd) readx(n uint) []byte {
+ if z.bytes {
+ return z.rb.readx(n)
+ }
+ return z.readxIO(n)
+}
+func (z *decRd) readxIO(n uint) []byte {
+ if z.bufio {
+ return z.bi.readx(n)
+ }
+ return z.ri.readx(n)
+}
+
+func (z *decRd) readb(s []byte) {
+ if z.bytes {
+ z.rb.readb(s)
+ } else {
+ z.readbIO(s)
+ }
+}
+func (z *decRd) readbIO(s []byte) {
+ if z.bufio {
+ z.bi.readb(s)
+ } else {
+ z.ri.readb(s)
+ }
+}
+
+func (z *decRd) readn1() uint8 {
+ if z.bytes {
+ return z.rb.readn1()
+ }
+ return z.readn1IO()
+}
+func (z *decRd) readn1IO() uint8 {
+ if z.bufio {
+ return z.bi.readn1()
+ }
+ return z.ri.readn1()
+}
+
+func (z *decRd) skip(accept *bitset256) (token byte) {
+ if z.bytes {
+ return z.rb.skip(accept)
+ }
+ return z.skipIO(accept)
+}
+func (z *decRd) skipIO(accept *bitset256) (token byte) {
+ if z.bufio {
+ return z.bi.skip(accept)
+ }
+ return z.ri.skip(accept)
+}
+
+func (z *decRd) readTo(accept *bitset256) (out []byte) {
+ if z.bytes {
+ return z.rb.readTo(accept)
+ }
+ return z.readToIO(accept)
+}
+func (z *decRd) readToIO(accept *bitset256) (out []byte) {
+ if z.bufio {
+ return z.bi.readTo(accept)
+ }
+ return z.ri.readTo(accept)
+}
+
+func (z *decRd) readUntil(stop byte, includeLast bool) (out []byte) {
+ if z.bytes {
+ return z.rb.readUntil(stop, includeLast)
+ }
+ return z.readUntilIO(stop, includeLast)
+}
+func (z *decRd) readUntilIO(stop byte, includeLast bool) (out []byte) {
+ if z.bufio {
+ return z.bi.readUntil(stop, includeLast)
+ }
+ return z.ri.readUntil(stop, includeLast)
+}
+*/
+
+var _ decReader = (*decRd)(nil)
diff --git a/baas-kubeengine/vendor/github.com/ugorji/go/codec/register_ext.go b/baas-kubeengine/vendor/github.com/ugorji/go/codec/register_ext.go
new file mode 100644
index 00000000..68b002cc
--- /dev/null
+++ b/baas-kubeengine/vendor/github.com/ugorji/go/codec/register_ext.go
@@ -0,0 +1,38 @@
+// 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
+
+import "reflect"
+
+// This file exists, so that the files for specific formats do not all import reflect.
+// This just helps us ensure that reflect package is isolated to a few files.
+
+// SetInterfaceExt sets an extension
+func (h *JsonHandle) SetInterfaceExt(rt reflect.Type, tag uint64, ext InterfaceExt) (err error) {
+ return h.SetExt(rt, tag, makeExt(ext))
+}
+
+// SetInterfaceExt sets an extension
+func (h *CborHandle) SetInterfaceExt(rt reflect.Type, tag uint64, ext InterfaceExt) (err error) {
+ return h.SetExt(rt, tag, makeExt(ext))
+}
+
+// SetBytesExt sets an extension
+func (h *MsgpackHandle) SetBytesExt(rt reflect.Type, tag uint64, ext BytesExt) (err error) {
+ return h.SetExt(rt, tag, makeExt(ext))
+}
+
+// SetBytesExt sets an extension
+func (h *SimpleHandle) SetBytesExt(rt reflect.Type, tag uint64, ext BytesExt) (err error) {
+ return h.SetExt(rt, tag, makeExt(ext))
+}
+
+// SetBytesExt sets an extension
+func (h *BincHandle) SetBytesExt(rt reflect.Type, tag uint64, ext BytesExt) (err error) {
+ return h.SetExt(rt, tag, makeExt(ext))
+}
+
+// func (h *XMLHandle) SetInterfaceExt(rt reflect.Type, tag uint64, ext InterfaceExt) (err error) {
+// return h.SetExt(rt, tag, &interfaceExtWrapper{InterfaceExt: ext})
+// }
diff --git a/baas-kubeengine/vendor/github.com/ugorji/go/codec/rpc.go b/baas-kubeengine/vendor/github.com/ugorji/go/codec/rpc.go
index 39250881..8ee23587 100644
--- a/baas-kubeengine/vendor/github.com/ugorji/go/codec/rpc.go
+++ b/baas-kubeengine/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/baas-kubeengine/vendor/github.com/ugorji/go/codec/simple.go b/baas-kubeengine/vendor/github.com/ugorji/go/codec/simple.go
index a3257c1a..42bfd042 100644
--- a/baas-kubeengine/vendor/github.com/ugorji/go/codec/simple.go
+++ b/baas-kubeengine/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.EncodeStringEnc(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,18 +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:
- decNakedReadRawBytes(d, d.d, n, d.h.RawToString)
+ 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:
@@ -624,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/baas-kubeengine/vendor/github.com/ugorji/go/codec/sort-slice.generated.go b/baas-kubeengine/vendor/github.com/ugorji/go/codec/sort-slice.generated.go
new file mode 100644
index 00000000..352ddfbd
--- /dev/null
+++ b/baas-kubeengine/vendor/github.com/ugorji/go/codec/sort-slice.generated.go
@@ -0,0 +1,266 @@
+// 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.
+
+// Code generated from sort-slice.go.tmpl - DO NOT EDIT.
+
+package codec
+
+import "time"
+import "reflect"
+import "bytes"
+
+type stringSlice []string
+
+func (p stringSlice) Len() int { return len(p) }
+func (p stringSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
+func (p stringSlice) Less(i, j int) bool {
+ return p[uint(i)] < p[uint(j)]
+}
+
+type float64Slice []float64
+
+func (p float64Slice) Len() int { return len(p) }
+func (p float64Slice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
+func (p float64Slice) Less(i, j int) bool {
+ return p[uint(i)] < p[uint(j)] || isNaN64(p[uint(i)]) && !isNaN64(p[uint(j)])
+}
+
+type uint64Slice []uint64
+
+func (p uint64Slice) Len() int { return len(p) }
+func (p uint64Slice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
+func (p uint64Slice) Less(i, j int) bool {
+ return p[uint(i)] < p[uint(j)]
+}
+
+type uintptrSlice []uintptr
+
+func (p uintptrSlice) Len() int { return len(p) }
+func (p uintptrSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
+func (p uintptrSlice) Less(i, j int) bool {
+ return p[uint(i)] < p[uint(j)]
+}
+
+type int64Slice []int64
+
+func (p int64Slice) Len() int { return len(p) }
+func (p int64Slice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
+func (p int64Slice) Less(i, j int) bool {
+ return p[uint(i)] < p[uint(j)]
+}
+
+type boolSlice []bool
+
+func (p boolSlice) Len() int { return len(p) }
+func (p boolSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
+func (p boolSlice) Less(i, j int) bool {
+ return !p[uint(i)] && p[uint(j)]
+}
+
+type timeSlice []time.Time
+
+func (p timeSlice) Len() int { return len(p) }
+func (p timeSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
+func (p timeSlice) Less(i, j int) bool {
+ return p[uint(i)].Before(p[uint(j)])
+}
+
+type bytesSlice [][]byte
+
+func (p bytesSlice) Len() int { return len(p) }
+func (p bytesSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
+func (p bytesSlice) Less(i, j int) bool {
+ return bytes.Compare(p[uint(i)], p[uint(j)]) == -1
+}
+
+type stringRv struct {
+ v string
+ r reflect.Value
+}
+type stringRvSlice []stringRv
+
+func (p stringRvSlice) Len() int { return len(p) }
+func (p stringRvSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
+func (p stringRvSlice) Less(i, j int) bool {
+ return p[uint(i)].v < p[uint(j)].v
+}
+
+type stringIntf struct {
+ v string
+ i interface{}
+}
+type stringIntfSlice []stringIntf
+
+func (p stringIntfSlice) Len() int { return len(p) }
+func (p stringIntfSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
+func (p stringIntfSlice) Less(i, j int) bool {
+ return p[uint(i)].v < p[uint(j)].v
+}
+
+type float64Rv struct {
+ v float64
+ r reflect.Value
+}
+type float64RvSlice []float64Rv
+
+func (p float64RvSlice) Len() int { return len(p) }
+func (p float64RvSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
+func (p float64RvSlice) Less(i, j int) bool {
+ return p[uint(i)].v < p[uint(j)].v || isNaN64(p[uint(i)].v) && !isNaN64(p[uint(j)].v)
+}
+
+type float64Intf struct {
+ v float64
+ i interface{}
+}
+type float64IntfSlice []float64Intf
+
+func (p float64IntfSlice) Len() int { return len(p) }
+func (p float64IntfSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
+func (p float64IntfSlice) Less(i, j int) bool {
+ return p[uint(i)].v < p[uint(j)].v || isNaN64(p[uint(i)].v) && !isNaN64(p[uint(j)].v)
+}
+
+type uint64Rv struct {
+ v uint64
+ r reflect.Value
+}
+type uint64RvSlice []uint64Rv
+
+func (p uint64RvSlice) Len() int { return len(p) }
+func (p uint64RvSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
+func (p uint64RvSlice) Less(i, j int) bool {
+ return p[uint(i)].v < p[uint(j)].v
+}
+
+type uint64Intf struct {
+ v uint64
+ i interface{}
+}
+type uint64IntfSlice []uint64Intf
+
+func (p uint64IntfSlice) Len() int { return len(p) }
+func (p uint64IntfSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
+func (p uint64IntfSlice) Less(i, j int) bool {
+ return p[uint(i)].v < p[uint(j)].v
+}
+
+type uintptrRv struct {
+ v uintptr
+ r reflect.Value
+}
+type uintptrRvSlice []uintptrRv
+
+func (p uintptrRvSlice) Len() int { return len(p) }
+func (p uintptrRvSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
+func (p uintptrRvSlice) Less(i, j int) bool {
+ return p[uint(i)].v < p[uint(j)].v
+}
+
+type uintptrIntf struct {
+ v uintptr
+ i interface{}
+}
+type uintptrIntfSlice []uintptrIntf
+
+func (p uintptrIntfSlice) Len() int { return len(p) }
+func (p uintptrIntfSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
+func (p uintptrIntfSlice) Less(i, j int) bool {
+ return p[uint(i)].v < p[uint(j)].v
+}
+
+type int64Rv struct {
+ v int64
+ r reflect.Value
+}
+type int64RvSlice []int64Rv
+
+func (p int64RvSlice) Len() int { return len(p) }
+func (p int64RvSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
+func (p int64RvSlice) Less(i, j int) bool {
+ return p[uint(i)].v < p[uint(j)].v
+}
+
+type int64Intf struct {
+ v int64
+ i interface{}
+}
+type int64IntfSlice []int64Intf
+
+func (p int64IntfSlice) Len() int { return len(p) }
+func (p int64IntfSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
+func (p int64IntfSlice) Less(i, j int) bool {
+ return p[uint(i)].v < p[uint(j)].v
+}
+
+type boolRv struct {
+ v bool
+ r reflect.Value
+}
+type boolRvSlice []boolRv
+
+func (p boolRvSlice) Len() int { return len(p) }
+func (p boolRvSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
+func (p boolRvSlice) Less(i, j int) bool {
+ return !p[uint(i)].v && p[uint(j)].v
+}
+
+type boolIntf struct {
+ v bool
+ i interface{}
+}
+type boolIntfSlice []boolIntf
+
+func (p boolIntfSlice) Len() int { return len(p) }
+func (p boolIntfSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
+func (p boolIntfSlice) Less(i, j int) bool {
+ return !p[uint(i)].v && p[uint(j)].v
+}
+
+type timeRv struct {
+ v time.Time
+ r reflect.Value
+}
+type timeRvSlice []timeRv
+
+func (p timeRvSlice) Len() int { return len(p) }
+func (p timeRvSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
+func (p timeRvSlice) Less(i, j int) bool {
+ return p[uint(i)].v.Before(p[uint(j)].v)
+}
+
+type timeIntf struct {
+ v time.Time
+ i interface{}
+}
+type timeIntfSlice []timeIntf
+
+func (p timeIntfSlice) Len() int { return len(p) }
+func (p timeIntfSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
+func (p timeIntfSlice) Less(i, j int) bool {
+ return p[uint(i)].v.Before(p[uint(j)].v)
+}
+
+type bytesRv struct {
+ v []byte
+ r reflect.Value
+}
+type bytesRvSlice []bytesRv
+
+func (p bytesRvSlice) Len() int { return len(p) }
+func (p bytesRvSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
+func (p bytesRvSlice) Less(i, j int) bool {
+ return bytes.Compare(p[uint(i)].v, p[uint(j)].v) == -1
+}
+
+type bytesIntf struct {
+ v []byte
+ i interface{}
+}
+type bytesIntfSlice []bytesIntf
+
+func (p bytesIntfSlice) Len() int { return len(p) }
+func (p bytesIntfSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
+func (p bytesIntfSlice) Less(i, j int) bool {
+ return bytes.Compare(p[uint(i)].v, p[uint(j)].v) == -1
+}
diff --git a/baas-kubeengine/vendor/github.com/ugorji/go/codec/sort-slice.go.tmpl b/baas-kubeengine/vendor/github.com/ugorji/go/codec/sort-slice.go.tmpl
new file mode 100644
index 00000000..95d348c9
--- /dev/null
+++ b/baas-kubeengine/vendor/github.com/ugorji/go/codec/sort-slice.go.tmpl
@@ -0,0 +1,64 @@
+// 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.
+
+// Code generated from sort-slice.go.tmpl - DO NOT EDIT.
+
+{{/*
+xxxSlice
+xxxIntf
+xxxIntfSlice
+xxxRv
+xxxRvSlice
+
+I'm now going to create them for
+- sortables
+- sortablesplus
+
+With the parameters passed in sortables or sortablesplus,
+'time, 'bytes' are special, and correspond to time.Time and []byte respectively.
+*/}}
+
+package codec
+
+import "time"
+import "reflect"
+import "bytes"
+
+{{/* func init() { _ = time.Unix } */}}
+
+{{define "T"}}
+func (p {{ .Type }}) Len() int { return len(p) }
+func (p {{ .Type }}) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] }
+func (p {{ .Type }}) Less(i, j int) bool {
+ {{ if eq .Kind "bool" }} return !p[uint(i)]{{.V}} && p[uint(j)]{{.V}}
+ {{ else if eq .Kind "float32" }} return p[uint(i)]{{.V}} < p[uint(j)]{{.V}} || isNaN32(p[uint(i)]{{.V}}) && !isNaN32(p[uint(j)]{{.V}})
+ {{ else if eq .Kind "float64" }} return p[uint(i)]{{.V}} < p[uint(j)]{{.V}} || isNaN64(p[uint(i)]{{.V}}) && !isNaN64(p[uint(j)]{{.V}})
+ {{ else if eq .Kind "time" }} return p[uint(i)]{{.V}}.Before(p[uint(j)]{{.V}})
+ {{ else if eq .Kind "bytes" }} return bytes.Compare(p[uint(i)]{{.V}}, p[uint(j)]{{.V}}) == -1
+ {{ else }} return p[uint(i)]{{.V}} < p[uint(j)]{{.V}}
+ {{ end -}}
+}
+{{end}}
+
+{{range $i, $v := sortables }}{{ $t := tshort $v }}
+type {{ $v }}Slice []{{ $t }}
+{{template "T" args "Kind" $v "Type" (print $v "Slice") "V" ""}}
+{{end}}
+
+{{range $i, $v := sortablesplus }}{{ $t := tshort $v }}
+
+type {{ $v }}Rv struct {
+ v {{ $t }}
+ r reflect.Value
+}
+type {{ $v }}RvSlice []{{ $v }}Rv
+{{template "T" args "Kind" $v "Type" (print $v "RvSlice") "V" ".v"}}
+
+type {{ $v }}Intf struct {
+ v {{ $t }}
+ i interface{}
+}
+type {{ $v }}IntfSlice []{{ $v }}Intf
+{{template "T" args "Kind" $v "Type" (print $v "IntfSlice") "V" ".v"}}
+
+{{end}}
diff --git a/baas-kubeengine/vendor/github.com/ugorji/go/codec/writer.go b/baas-kubeengine/vendor/github.com/ugorji/go/codec/writer.go
new file mode 100644
index 00000000..764790bf
--- /dev/null
+++ b/baas-kubeengine/vendor/github.com/ugorji/go/codec/writer.go
@@ -0,0 +1,267 @@
+// 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
+
+import "io"
+
+// encWriter abstracts writing to a byte array or to an io.Writer.
+type encWriter interface {
+ writeb([]byte)
+ writestr(string)
+ writeqstr(string) // write string wrapped in quotes ie "..."
+ writen1(byte)
+ writen2(byte, byte)
+ // writen will write up to 7 bytes at a time.
+ writen(b [rwNLen]byte, num uint8)
+ end()
+}
+
+// ---------------------------------------------
+
+// bufioEncWriter
+type bufioEncWriter struct {
+ w io.Writer
+
+ buf []byte
+
+ n int
+
+ b [16]byte // scratch buffer and padding (cache-aligned)
+}
+
+func (z *bufioEncWriter) reset(w io.Writer, bufsize int, blist *bytesFreelist) {
+ z.w = w
+ z.n = 0
+ if bufsize <= 0 {
+ bufsize = defEncByteBufSize
+ }
+ // bufsize must be >= 8, to accomodate writen methods (where n <= 8)
+ if bufsize <= 8 {
+ bufsize = 8
+ }
+ if cap(z.buf) < bufsize {
+ if len(z.buf) > 0 && &z.buf[0] != &z.b[0] {
+ blist.put(z.buf)
+ }
+ if len(z.b) > bufsize {
+ z.buf = z.b[:]
+ } else {
+ z.buf = blist.get(bufsize)
+ }
+ }
+ z.buf = z.buf[:cap(z.buf)]
+}
+
+//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 (z *bufioEncWriter) flush() {
+ if err := z.flushErr(); err != nil {
+ panic(err)
+ }
+}
+
+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 (z *bufioEncWriter) writeqstr(s string) {
+ // z.writen1('"')
+ // z.writestr(s)
+ // z.writen1('"')
+
+ if z.n+len(s)+2 > len(z.buf) {
+ z.flush()
+ }
+ z.buf[z.n] = '"'
+ z.n++
+LOOP:
+ a := len(z.buf) - z.n
+ if len(s)+1 > 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)
+ z.buf[z.n] = '"'
+ z.n++
+}
+
+func (z *bufioEncWriter) writen1(b1 byte) {
+ if 1 > len(z.buf)-z.n {
+ z.flush()
+ }
+ z.buf[z.n] = b1
+ z.n++
+}
+
+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 (z *bufioEncWriter) writen(b [rwNLen]byte, num uint8) {
+ if int(num) > len(z.buf)-z.n {
+ z.flush()
+ }
+ copy(z.buf[z.n:], b[:num])
+ z.n += int(num)
+}
+
+func (z *bufioEncWriter) endErr() (err error) {
+ if z.n > 0 {
+ err = z.flushErr()
+ }
+ return
+}
+
+// ---------------------------------------------
+
+// bytesEncAppender implements encWriter and can write to an byte slice.
+type bytesEncAppender struct {
+ b []byte
+ out *[]byte
+}
+
+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) writeqstr(s string) {
+ z.b = append(append(append(z.b, '"'), s...), '"')
+
+ // z.b = append(z.b, '"')
+ // z.b = append(z.b, s...)
+ // z.b = append(z.b, '"')
+}
+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) // cost: 81
+}
+func (z *bytesEncAppender) writen(s [rwNLen]byte, num uint8) {
+ // if num <= rwNLen {
+ if int(num) <= len(s) {
+ z.b = append(z.b, s[:num]...)
+ }
+}
+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
+}
+
+// --------------------------------------------------
+
+type encWr struct {
+ bytes bool // encoding to []byte
+ js bool // is json encoder?
+ be bool // is binary encoder?
+
+ c containerState
+
+ calls uint16
+
+ wb bytesEncAppender
+ wf *bufioEncWriter
+}
+
+func (z *encWr) writeb(s []byte) {
+ if z.bytes {
+ z.wb.writeb(s)
+ } else {
+ z.wf.writeb(s)
+ }
+}
+func (z *encWr) writeqstr(s string) {
+ if z.bytes {
+ z.wb.writeqstr(s)
+ } else {
+ z.wf.writeqstr(s)
+ }
+}
+func (z *encWr) writestr(s string) {
+ if z.bytes {
+ z.wb.writestr(s)
+ } else {
+ z.wf.writestr(s)
+ }
+}
+func (z *encWr) writen1(b1 byte) {
+ if z.bytes {
+ z.wb.writen1(b1)
+ } else {
+ z.wf.writen1(b1)
+ }
+}
+func (z *encWr) writen2(b1, b2 byte) {
+ if z.bytes {
+ z.wb.writen2(b1, b2)
+ } else {
+ z.wf.writen2(b1, b2)
+ }
+}
+func (z *encWr) writen(b [rwNLen]byte, num uint8) {
+ if z.bytes {
+ z.wb.writen(b, num)
+ } else {
+ z.wf.writen(b, num)
+ }
+}
+func (z *encWr) endErr() error {
+ if z.bytes {
+ return z.wb.endErr()
+ }
+ return z.wf.endErr()
+}
+
+func (z *encWr) end() {
+ if err := z.endErr(); err != nil {
+ panic(err)
+ }
+}
+
+var _ encWriter = (*encWr)(nil)
diff --git a/baas-kubeengine/vendor/github.com/ugorji/go/codec/xml.go b/baas-kubeengine/vendor/github.com/ugorji/go/codec/xml.go
deleted file mode 100644
index 19fc36ca..00000000
--- a/baas-kubeengine/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