diff --git a/Gopkg.lock b/Gopkg.lock
index 66cca511c0..5d52a899c4 100644
--- a/Gopkg.lock
+++ b/Gopkg.lock
@@ -2,15 +2,15 @@
[[projects]]
- digest = "1:4b94878e125f31ec67c892ecfe38c13211da40653281588598218f807ae72bf7"
+ digest = "1:a151d8abdc2ab0a97060ac2e7c71472dff76255d76d5e65d29dcf21cf0ae0664"
name = "github.com/360EntSecGroup-Skylar/excelize"
packages = ["."]
pruneopts = "UT"
- revision = "eb62256d165607c6877ce88efbba10c119137b3d"
- version = "v1.3.0"
+ revision = "3e004d900b103379c2d62657a3070de4a2e8585a"
+ version = "v1.4.0"
[[projects]]
- digest = "1:402c5ecf012012f4a6ff2bcc6ee903f5280e8c27f4abaebb2319716065397304"
+ digest = "1:0e1bf1a6e11f777ba0882d0c581788e3f19dcdc7f9f0e5305b13efefe73cd0d5"
name = "github.com/Azure/azure-sdk-for-go"
packages = [
"services/compute/mgmt/2018-04-01/compute",
@@ -25,11 +25,11 @@
"version",
]
pruneopts = "UT"
- revision = "4e8cbbfb1aeab140cd0fa97fd16b64ee18c3ca6a"
- version = "v19.1.0"
+ revision = "6d20bdbae88c06c36d72eb512295417693bfdf4e"
+ version = "v21.1.0"
[[projects]]
- digest = "1:b8a61bb5402d1b01ada88ccb213da33a5d29683cba5ce93813aa67d5826afe56"
+ digest = "1:469646dd53a792f7ecbe8ddfb326a356354b7727ec26d783f3d76ea069eb432a"
name = "github.com/Azure/go-autorest"
packages = [
"autorest",
@@ -43,8 +43,8 @@
"version",
]
pruneopts = "UT"
- revision = "9bc4033dd347c7f416fca46b2f42a043dc1fbdf6"
- version = "v10.15.5"
+ revision = "a88c19ef2016e095f0b6c3b451074b4663f53bed"
+ version = "v10.15.4"
[[projects]]
digest = "1:f7a3877d7116adfcdcd641f9f6ad18fc2126bd5c080d8854cc3b395a01e0b7f3"
@@ -81,12 +81,12 @@
revision = "2dd43d88c85c06c55828c86159d4583db9d41fbb"
[[projects]]
- digest = "1:66b8ed452b31eb9075bc53295952487c333a9cb555de57ed61f5664c058d9050"
+ digest = "1:6981402aef27693f4b2ec619117abd263fde29f8c1dfac46eef0f35038d37513"
name = "github.com/Shopify/sarama"
packages = ["."]
pruneopts = "UT"
- revision = "35324cf48e33d8260e1c7c18854465a904ade249"
- version = "v1.17.0"
+ revision = "ec843464b50d4c8b56403ec9d589cf41ea30e722"
+ version = "v1.19.0"
[[projects]]
digest = "1:5e9ea5618cb3451ce312505a48a563e95ce26c9ef498cd0a8833255e5e7f5c61"
@@ -107,12 +107,12 @@
version = "1.27.7"
[[projects]]
- digest = "1:fff66556e25e676b296f9f2c78853831911e6ae41d84303a9be7a534bd1c0901"
+ digest = "1:5a2d4da3f703696f4bec1ba1d363f50461b72934b1817c07ab0963496ed1c90d"
name = "github.com/aliyun/aliyun-oss-go-sdk"
packages = ["oss"]
pruneopts = "UT"
- revision = "36bf7aa2f916f274137aedd05d1d36f6a3c0f4a6"
- version = "1.9.0"
+ revision = "ddc87ec2145f324f91257266e657cd7fa0ff1c8c"
+ version = "1.9.1"
[[projects]]
digest = "1:8f5416c7f59da8600725ae1ff00a99af1da8b04c211ae6f3c8f8bcab0164f650"
@@ -123,14 +123,15 @@
version = "v1.0.1"
[[projects]]
- digest = "1:eee9386329f4fcdf8d6c0def0c9771b634bdd5ba460d888aa98c17d59b37a76c"
+ digest = "1:e64acfe8cda1955db545ede8e863c54d69f1ac6cd058df4349be4040320840fd"
name = "github.com/apache/thrift"
packages = ["lib/go/thrift"]
pruneopts = "UT"
- revision = "e59b73d3c2bf1c328ccb78e683c0462fa1a473c7"
+ revision = "327ebb6c2b6df8bf075da02ef45a2a034e9b79ba"
+ version = "0.11.0"
[[projects]]
- digest = "1:5a79e64c2a81cc6ab6e49a87e12d6d1ec86aab93edf6ff643b5b052c0142f12b"
+ digest = "1:69c83bbce91c8bbe26c02018aee83bb761b68678d33699e342171cae4108598b"
name = "github.com/aws/aws-sdk-go"
packages = [
"aws",
@@ -164,8 +165,8 @@
"service/sts",
]
pruneopts = "UT"
- revision = "85d9dfd77e6d694e83c3ac054141cb5e81eecc7f"
- version = "v1.15.43"
+ revision = "46fe04784968cd7b54e859fcce45753456f736ac"
+ version = "v1.15.52"
[[projects]]
branch = "master"
@@ -184,15 +185,15 @@
version = "v0.5.0"
[[projects]]
- digest = "1:a2486f94bda33b301614ff5cfce102b7eed4c923fa650c2b83dba1fcf2117466"
+ digest = "1:1659cb76cbd08a29826688d006e7a3d9279d6ca8a12155acb7b20164958987d3"
name = "github.com/c-bata/go-prompt"
packages = ["."]
pruneopts = "UT"
- revision = "c52492ff1b386e5c0ba5271b5eaad165fab09eca"
- version = "v0.2.2"
+ revision = "e99fbc797b795e0a7a94affc8d44f6a0350d85f0"
+ version = "v0.2.1"
[[projects]]
- digest = "1:40098afbdd06a76dee4b6bcb85a22fed81ac9d2ebaf775c91e558c80f57aaff1"
+ digest = "1:7205ab9c5433db402268526647efc47daa3236f9a85a1faba705fda12fdafd29"
name = "github.com/coredns/coredns"
packages = [
"core/dnsserver",
@@ -245,16 +246,16 @@
"request",
]
pruneopts = "UT"
- revision = "2e322f6e8a54f18c6aef9c25a7c432c291a3d9f7"
- version = "v1.2.0"
+ revision = "eb51e8bac90fac86d34c9e1cb89b04ea0936b034"
+ version = "v1.2.2"
[[projects]]
- digest = "1:a2c1d0e43bd3baaa071d1b9ed72c27d78169b2b269f71c105ac4ba34b1be4a39"
+ digest = "1:ffe9824d294da03b391f44e1ae8281281b4afc1bdaa9588c9097785e3af10cec"
name = "github.com/davecgh/go-spew"
packages = ["spew"]
pruneopts = "UT"
- revision = "346938d642f2ec3594ed81d874461961cd0faa76"
- version = "v1.1.0"
+ revision = "8991bc29aa16c548c550c7ff78260e27b9ab7c73"
+ version = "v1.1.1"
[[projects]]
digest = "1:76dc72490af7174349349838f2fe118996381b31ea83243812a97e5a0fd5ed55"
@@ -290,11 +291,11 @@
[[projects]]
branch = "master"
- digest = "1:0448d1c1a596941c608762912fe7c865f88d9ffa45afb8af1edcf1401762bf7e"
+ digest = "1:79f16588b5576b1b3cd90e48d2374cc9a1a8776862d28d8fd0f23b0e15534967"
name = "github.com/eapache/go-xerial-snappy"
packages = ["."]
pruneopts = "UT"
- revision = "040cc1a32f578808623071247fdbd5cc43f37f5f"
+ revision = "776d5712da21bc4762676d614db1d8a64f4238b0"
[[projects]]
digest = "1:444b82bfe35c83bbcaf84e310fb81a1f9ece03edfed586483c869e2c046aef69"
@@ -310,7 +311,7 @@
name = "github.com/farsightsec/golang-framestream"
packages = ["."]
pruneopts = "UT"
- revision = "c06a5734334d9629b3db143d74b47eb94ea68612"
+ revision = "d0f7ed81b7afcc56d3c1a66a0fd26a1b609675f3"
[[projects]]
digest = "1:865079840386857c809b72ce300be7580cb50d3d3129ce11bf9aa6ca2bc1934a"
@@ -329,12 +330,11 @@
revision = "3f9db97f856818214da2e1057f8ad84803971cff"
[[projects]]
- digest = "1:2cd7915ab26ede7d95b8749e6b1f933f1c6d5398030684e6505940a10f31cfda"
+ digest = "1:c45cef8e0074ea2f8176a051df38553ba997a3616f1ec2d35222b1cf9864881e"
name = "github.com/ghodss/yaml"
packages = ["."]
pruneopts = "UT"
- revision = "0ca9ea5df5451ffdf184b4428c902747c2c11cd7"
- version = "v1.0.0"
+ revision = "73d445a93680fa1a78ae23a5839bad48f32ba1ee"
[[projects]]
branch = "master"
@@ -345,23 +345,24 @@
revision = "22d885f9ecc78bf4ee5d72b937e4bbcdc58e8cae"
[[projects]]
- digest = "1:ab00ecdc9607692ffd5fb1ac21a9ba2d6cc95bae011f327022c0b1c323d218e2"
+ digest = "1:ff09f03ca12c4d23c28c596eb0738745e36c1cac111f62f64819210f40607cd2"
name = "github.com/gin-gonic/gin"
packages = [
"binding",
+ "json",
"render",
]
pruneopts = "UT"
- revision = "d459835d2b077e44f7c9b453505ee29881d5d12d"
- version = "v1.2"
+ revision = "b869fe1415e4b9eb52f247441830d502aece2d4d"
+ version = "v1.3.0"
[[projects]]
- digest = "1:5abd6a22805b1919f6a6bca0ae58b13cef1f3412812f38569978f43ef02743d4"
+ digest = "1:b98e7574fc27ec166fb31195ec72c3bd0bffd73926d3612eb4c929bc5236f75b"
name = "github.com/go-ini/ini"
packages = ["."]
pruneopts = "UT"
- revision = "5cf292cae48347c2490ac1a58fe36735fb78df7e"
- version = "v1.38.2"
+ revision = "7b294651033cd7d9e7f0d9ffa1b75ed1e198e737"
+ version = "v1.38.3"
[[projects]]
digest = "1:31a18dae27a29aa074515e43a443abfd2ba6deb6d69309d8d7ce789c45f34659"
@@ -380,15 +381,15 @@
version = "v1.4.0"
[[projects]]
- digest = "1:34e709f36fd4f868fb00dbaf8a6cab4c1ae685832d392874ba9d7c5dec2429d1"
+ digest = "1:b7a8552c62868d867795b63eaf4f45d3e92d36db82b428e680b9c95a8c33e5b1"
name = "github.com/gogo/protobuf"
packages = [
"proto",
"sortkeys",
]
pruneopts = "UT"
- revision = "636bf0302bc95575d69441b25a2603156ffdddf1"
- version = "v1.1.1"
+ revision = "342cbe0a04158f6dcb03ca0079991a51a4248c02"
+ version = "v0.5"
[[projects]]
digest = "1:94d8c9e3a4954505ca89243e2121180972eecf8e3d160f3b34a48825ddd95cc1"
@@ -416,15 +417,14 @@
version = "v1.0.0"
[[projects]]
- branch = "master"
- digest = "1:1ba1d79f2810270045c328ae5d674321db34e3aae468eb4233883b473c5c0467"
+ digest = "1:2edd2416f89b4e841df0e4a78802ce14d2bc7ad79eba1a45986e39f0f8cb7d87"
name = "github.com/golang/glog"
packages = ["."]
pruneopts = "UT"
- revision = "23def4e6c14b4da8ac2ed8007337bc5eb5007998"
+ revision = "44145f04b68cf362d9c4df2182967c2275eaefed"
[[projects]]
- digest = "1:17fe264ee908afc795734e8c4e63db2accabaf57326dbf21763a7d6b86096260"
+ digest = "1:4c0989ca0bcd10799064318923b9bc2db6b4d6338dd75f3f2d86c3511aaaf5cf"
name = "github.com/golang/protobuf"
packages = [
"proto",
@@ -434,8 +434,8 @@
"ptypes/timestamp",
]
pruneopts = "UT"
- revision = "b4deda0973fb4c70b50d226b1af49f3da59f5265"
- version = "v1.1.0"
+ revision = "aa810b61a9c79d51363740d207bb46cf8e620ed5"
+ version = "v1.2.0"
[[projects]]
branch = "master"
@@ -447,27 +447,25 @@
[[projects]]
branch = "master"
- digest = "1:9887333bbef17574b1db5f9893ea137ac44107235d624408a3ac9e0b98fbb2cb"
+ digest = "1:0bfbe13936953a98ae3cfe8ed6670d396ad81edf069a806d2f6515d7bb6950df"
name = "github.com/google/btree"
packages = ["."]
pruneopts = "UT"
- revision = "e89373fe6b4a7413d7acd6da1725b83ef713e6e4"
+ revision = "4030bb1f1f0c35b30ca7009e9ebd06849dd45306"
[[projects]]
- branch = "master"
- digest = "1:3ee90c0d94da31b442dde97c99635aaafec68d0b8a3c12ee2075c6bdabeec6bb"
+ digest = "1:41bfd4219241b7f7d6e6fdb13fc712576f1337e68e6b895136283b76928fdd66"
name = "github.com/google/gofuzz"
packages = ["."]
pruneopts = "UT"
- revision = "24818f796faf91cd76ec7bddd72458fbced7a6c1"
+ revision = "44d81051d367757e1c7c6a5a86423ece9afcf63c"
[[projects]]
- digest = "1:8f8811f9be822914c3a25c6a071e93beb4c805d7b026cbf298bc577bc1cc945b"
+ digest = "1:9f7a9e0b3f54aad2c053f778b9933263de723f6d722c68092b1eec06b95a5860"
name = "github.com/google/uuid"
packages = ["."]
pruneopts = "UT"
- revision = "064e2069ce9c359c118179501254f67d7d37ba24"
- version = "0.2"
+ revision = "7e072fc3a7be179aee6d3359e46015aa8c995314"
[[projects]]
digest = "1:65c4414eeb350c47b8de71110150d0ea8a281835b1f386eacaa3ad7325929c21"
@@ -498,11 +496,11 @@
[[projects]]
branch = "master"
- digest = "1:62db7727ec8e026e51e1b46696e0fdf6a956a701032eca4d63e311816820717c"
+ digest = "1:8ec54d9488698e9db22139250bde10e35aab02c20236e4d1c1457604c2c4fe18"
name = "github.com/googollee/go-socket.io"
packages = ["."]
pruneopts = "UT"
- revision = "f12da5711bc66c18a0724987fff7f4f3db35c70f"
+ revision = "25e1f67559cf5d0e41efbc3e0157bb952596ffc3"
[[projects]]
digest = "1:c79fb010be38a59d657c48c6ba1d003a8aa651fa56b579d959d74573b7dff8e1"
@@ -541,15 +539,14 @@
revision = "36ee7e946282a3fb1cfecd476ddc9b35d8847e42"
[[projects]]
- branch = "master"
- digest = "1:86c1210529e69d69860f2bb3ee9ccce0b595aa3f9165e7dd1388e5c612915888"
+ digest = "1:878f0defa9b853f9acfaf4a162ba450a89d0050eff084f9fe7f5bd15948f172a"
name = "github.com/gregjones/httpcache"
packages = [
".",
"diskcache",
]
pruneopts = "UT"
- revision = "9cad4c3443a7200dd6400aef47183728de563a38"
+ revision = "787624de3eb7bd915c329cba748687a3b22666a6"
[[projects]]
branch = "master"
@@ -560,20 +557,19 @@
revision = "8e809c8a86450a29b90dcc9efbf062d0fe6d9746"
[[projects]]
- branch = "master"
digest = "1:09970bb8daf100bdf11b48b72c71ef980cd2b50efbd903989b3d182956be0b83"
name = "github.com/hako/durafmt"
packages = ["."]
pruneopts = "UT"
revision = "7b7ae1e72eade09dbc9c2cfba3e6c4bae7b8bcac"
+ version = "1.0.0"
[[projects]]
- digest = "1:8eb1de8112c9924d59bf1d3e5c26f5eaa2bfc2a5fcbb92dc1c2e4546d695f277"
+ digest = "1:06ec9147400aabb0d6960dd8557638603b5f320cd4cb8a3eceaae407e782849a"
name = "github.com/imdario/mergo"
packages = ["."]
pruneopts = "UT"
- revision = "9f23e2d6bd2a77f959b2bf6acdbefd708a83a4a4"
- version = "v0.3.6"
+ revision = "6633656539c1639d9d78127b7d47c622b5d7b6dc"
[[projects]]
digest = "1:b6f4477f09f11785097a121811f3a90d8d26cab73c1aa71abda859bdf6ad2334"
@@ -602,12 +598,20 @@
revision = "0b12d6b5"
[[projects]]
- digest = "1:eaefc85d32c03e5f0c2b88ea2f79fce3d993e2c78316d21319575dd4ea9153ca"
+ digest = "1:3e551bbb3a7c0ab2a2bf4660e7fcad16db089fdcfbb44b0199e62838038623ea"
name = "github.com/json-iterator/go"
packages = ["."]
pruneopts = "UT"
- revision = "ab8a2e0c74be9d3be70b3184d9acc634935ded82"
- version = "1.1.4"
+ revision = "1624edc4454b8682399def8740d46db5e4362ba4"
+ version = "v1.1.5"
+
+[[projects]]
+ digest = "1:0a69a1c0db3591fcefb47f115b224592c8dfa4368b7ba9fae509d5e16cdc95c8"
+ name = "github.com/konsorten/go-windows-terminal-sequences"
+ packages = ["."]
+ pruneopts = "UT"
+ revision = "5c8c8bd35d3832f5d134ae1e1e375b69a4d25242"
+ version = "v1.0.1"
[[projects]]
branch = "master"
@@ -618,12 +622,12 @@
revision = "b84e30acd515aadc4b783ad4ff83aff3299bdfe0"
[[projects]]
- branch = "master"
- digest = "1:094e04c4742b596bce4455eb535d4e4365016b44016db76f8593211406d77299"
+ digest = "1:29d28429a93b076908a36420a7ecb2bf429d24c15a4b5e2c220ea00fc84b71af"
name = "github.com/kr/pty"
packages = ["."]
pruneopts = "UT"
- revision = "fa756f09eeb418bf1cc6268c66ceaad9bb98f598"
+ revision = "db8e3cd836b82e82e0a9c8edc6896967dd31374f"
+ version = "v1.1.3"
[[projects]]
digest = "1:4e878df5f4e9fd625bf9c9aac77ef7cbfa4a74c01265505527c23470c0e40300"
@@ -642,28 +646,28 @@
version = "v0.0.9"
[[projects]]
- digest = "1:d4d17353dbd05cb52a2a52b7fe1771883b682806f68db442b436294926bbfafb"
+ digest = "1:0981502f9816113c9c8c4ac301583841855c8cf4da8c72f696b3ebedf6d0e4e5"
name = "github.com/mattn/go-isatty"
packages = ["."]
pruneopts = "UT"
- revision = "0360b2af4f38e8d38c7fce2a9f4e702702d73a39"
- version = "v0.0.3"
+ revision = "6ca4dbf54d38eea1a992b3c722a76a5d1c4cb25c"
+ version = "v0.0.4"
[[projects]]
- branch = "master"
digest = "1:cdb899c199f907ac9fb50495ec71212c95cb5b0e0a8ee0800da0238036091033"
name = "github.com/mattn/go-runewidth"
packages = ["."]
pruneopts = "UT"
revision = "ce7b0b5c7b45a81508558cd1dba6bb1e4ddb51bb"
+ version = "v0.0.3"
[[projects]]
branch = "master"
- digest = "1:d775613e6db40f54d34cc8b319ee5c2df56752f9f5e55e2f6004d11684bdc8fd"
+ digest = "1:325f68c3bd3044dcf51d46e802136cd239817e1fb130b5f3466a4cec4dd427d3"
name = "github.com/mattn/go-tty"
packages = ["."]
pruneopts = "UT"
- revision = "931426f7535ac39720c8909d70ece5a41a2502a6"
+ revision = "13ff1204f104d52c3f7645ec027ecbcf9026429e"
[[projects]]
digest = "1:ff5ebae34cfbf047d505ee150de27e60570e8c394b3b8fdbb720ff6ac71985fc"
@@ -695,12 +699,12 @@
version = "v0.10.11"
[[projects]]
- digest = "1:463e4140189f8194f9121ca1c7fe3b8e9e9a2ab3d949b43c835c21034927dc62"
+ digest = "1:57689550840d285f2da9e85356a66e626592a8b6f1170d7f2482438e64fe82e3"
name = "github.com/miekg/dns"
packages = ["."]
pruneopts = "UT"
- revision = "5a2b9fab83ff0f8bfc99684bd5f43a37abe560f1"
- version = "v1.0.8"
+ revision = "d74956db7b5b20451796774572d0f5a0222e377a"
+ version = "v1.0.13"
[[projects]]
digest = "1:33422d238f147d247752996a26574ac48dcf472976eda7f5134015f06bf16563"
@@ -718,6 +722,14 @@
revision = "4b7aa43c6742a2c18fdef89dd197aaae7dac7ccd"
version = "1.0.1"
+[[projects]]
+ branch = "master"
+ digest = "1:84bd7f8a2e0bcd53ddc33c3b47c34c1fe340c8632cbe928f7f8ae10ec6ecdd62"
+ name = "github.com/mohae/deepcopy"
+ packages = ["."]
+ pruneopts = "UT"
+ revision = "c48cc78d482608239f6c4c92a4abd87eb8761c90"
+
[[projects]]
branch = "master"
digest = "1:7aefb397a53fc437c90f0fdb3e1419c751c5a3a165ced52325d5d797edf1aca6"
@@ -778,15 +790,15 @@
version = "v2.0.1"
[[projects]]
- digest = "1:29803f52611cbcc1dfe55b456e9fdac362af7248b3d29d7ea1bec0a12e71dff4"
+ digest = "1:e39a5ee8fcbec487f8fc68863ef95f2b025e0739b0e4aa55558a2b4cf8f0ecf0"
name = "github.com/pierrec/lz4"
packages = [
".",
"internal/xxh32",
]
pruneopts = "UT"
- revision = "1958fd8fff7f115e79725b1288e0b878b3e06b00"
- version = "v2.0.3"
+ revision = "635575b42742856941dbc767b44905bb9ba083f6"
+ version = "v2.0.7"
[[projects]]
branch = "master"
@@ -794,7 +806,7 @@
name = "github.com/pkg/term"
packages = ["termios"]
pruneopts = "UT"
- revision = "cda20d4ac917ad418d86e151eff439648b06185b"
+ revision = "bffc007b7fd5a70e20e28f5b7649bb84671ef436"
[[projects]]
digest = "1:0028cb19b2e4c3112225cd871870f2d9cf49b9b4276531f03438a88e94be86fe"
@@ -825,7 +837,7 @@
[[projects]]
branch = "master"
- digest = "1:e469cd65badf7694aeb44874518606d93c1d59e7735d3754ad442782437d3cc3"
+ digest = "1:63b68062b8968092eb86bedc4e68894bd096ea6b24920faca8b9dcf451f54bb5"
name = "github.com/prometheus/common"
packages = [
"expfmt",
@@ -833,11 +845,11 @@
"model",
]
pruneopts = "UT"
- revision = "7600349dcfe1abd18d72d3a1770870d9800a7801"
+ revision = "c7de2306084e37d54b8be01f3541a8464345e9a5"
[[projects]]
branch = "master"
- digest = "1:8c49953a1414305f2ff5465147ee576dd705487c35b15918fcd4efdc0cb7a290"
+ digest = "1:ef74914912f99c79434d9c09658274678bc85080ebe3ab32bec3940ebce5e1fc"
name = "github.com/prometheus/procfs"
packages = [
".",
@@ -846,7 +858,7 @@
"xfs",
]
pruneopts = "UT"
- revision = "05ee40e3a273f7245e8777337fc7b46e533a9a92"
+ revision = "185b4288413d2a0dd0806f78c90dde719829e5ae"
[[projects]]
branch = "master"
@@ -881,12 +893,12 @@
version = "1.1.0"
[[projects]]
- digest = "1:d867dfa6751c8d7a435821ad3b736310c2ed68945d05b50fb9d23aee0540c8cc"
+ digest = "1:3f53e9e4dfbb664cd62940c9c4b65a2171c66acd0b7621a1a6b8e78513525a52"
name = "github.com/sirupsen/logrus"
packages = ["."]
pruneopts = "UT"
- revision = "3e01752db0189b9157070a0e1668a620f9a85da2"
- version = "v1.0.6"
+ revision = "ad15b42461921f1fb3529b058c6786c6a45d5162"
+ version = "v1.1.1"
[[projects]]
digest = "1:9424f440bba8f7508b69414634aef3b2b3a877e522d8a4624692412805407bb7"
@@ -913,15 +925,14 @@
revision = "d188e65d659ef53fcdb0691c12f1bba64928b649"
[[projects]]
- digest = "1:98e5cda86f67cd1ac95389d98670b66dea8cae480fe6292b83bccccfe60b4106"
+ digest = "1:7b36ba7867ad2d262abedeff4c9362f2e8aa00cf6dd3254a509f24c27eb1d5b7"
name = "github.com/ugorji/go"
packages = ["codec"]
pruneopts = "UT"
- revision = "f3cacc17c85ecb7f1b6a9e373ee85d1480919868"
+ revision = "9c7f9b7a2bc3a520f7c7b30b34b7f85f47fe27b6"
[[projects]]
- branch = "master"
- digest = "1:91771429c8de08d4d9b32663ad78bfa8ee1e0a146e921d9937c117665fd0377f"
+ digest = "1:506f2f0fee9b0e75b987286233a3b0d3fbf7cb145d754b0719b672822246cbc6"
name = "github.com/vmware/govmomi"
packages = [
".",
@@ -941,11 +952,12 @@
"vim25/xml",
]
pruneopts = "UT"
- revision = "bbd99532a768d2fe369079ceda730e30726ae1a6"
+ revision = "3617f28d167d448f93f282a867870f109516d2a5"
+ version = "v0.19.0"
[[projects]]
branch = "master"
- digest = "1:2d12661fb1e092a12b9675f9cd59fb3119f03d696bd6febcb5fe2324d2639965"
+ digest = "1:71c5989353531072eeb9547066e05bdeaaf9ef0512673bca3b4b824092d70de3"
name = "golang.org/x/crypto"
packages = [
"curve25519",
@@ -960,11 +972,11 @@
"ssh/terminal",
]
pruneopts = "UT"
- revision = "c126467f60eb25f8f27e5a981f32a87e3965053f"
+ revision = "7c1a557ab941a71c619514f229f0b27ccb0c27cf"
[[projects]]
branch = "master"
- digest = "1:c945d925a3dae287abe075a89c6b09e1015da39d350eb512bb5d01ebcd7783e7"
+ digest = "1:4ab551743538ce88c540073958b2fb653ca077c5d4c3d1991d86016dd38e22f6"
name = "golang.org/x/net"
packages = [
"bpf",
@@ -981,18 +993,18 @@
"trace",
]
pruneopts = "UT"
- revision = "f4c29de78a2a91c00474a2e689954305c350adf9"
+ revision = "146acd28ed5894421fb5aac80ca93bc1b1f46f87"
[[projects]]
branch = "master"
- digest = "1:be95d758fc4d9216e5d41ff5b98b46938fba85ca5bc2ddc45a1b03e2bb10fe7c"
+ digest = "1:850d28ab022512e2cd3cf511a77f363c29e22689b4031f2050871f5de47ae4a0"
name = "golang.org/x/sys"
packages = [
"unix",
"windows",
]
pruneopts = "UT"
- revision = "e072cadbbdc8dd3d3ffa82b8b4b9304c261d9311"
+ revision = "4497e2df6f9e69048a54498c7affbbec3294ad47"
[[projects]]
digest = "1:a2ab62866c75542dd18d2b069fec854577a20211d7c0ea6ae746072a1dccdd18"
@@ -1018,31 +1030,30 @@
version = "v0.3.0"
[[projects]]
- branch = "master"
- digest = "1:c9e7a4b4d47c0ed205d257648b0e5b0440880cb728506e318f8ac7cd36270bc4"
+ digest = "1:d37b0ef2944431fe9e8ef35c6fffc8990d9e2ca300588df94a6890f3649ae365"
name = "golang.org/x/time"
packages = ["rate"]
pruneopts = "UT"
- revision = "fbb02b2291d28baffd63558aa44b4b56f178d650"
+ revision = "f51c12702a4d776e4c1fa9b0fabab841babae631"
[[projects]]
digest = "1:c25289f43ac4a68d88b02245742347c94f1e108c534dda442188015ff80669b3"
name = "google.golang.org/appengine"
packages = ["cloudsql"]
pruneopts = "UT"
- revision = "b1f26356af11148e710935ed1ac8a7f5702c7612"
- version = "v1.1.0"
+ revision = "ae0ab99deb4dc413a2b4bd6c8bdd0eb67f1e4d06"
+ version = "v1.2.0"
[[projects]]
branch = "master"
- digest = "1:077c1c599507b3b3e9156d17d36e1e61928ee9b53a5b420f10f28ebd4a0b275c"
+ digest = "1:56b0bca90b7e5d1facf5fbdacba23e4e0ce069d25381b8e2f70ef1e7ebfb9c1a"
name = "google.golang.org/genproto"
packages = ["googleapis/rpc/status"]
pruneopts = "UT"
- revision = "daca94659cb50e9f37c1b834680f2e46358f10b0"
+ revision = "af9cb2a35e7f169ec875002c1829c9b315cddc04"
[[projects]]
- digest = "1:3dd7996ce6bf52dec6a2f69fa43e7c4cefea1d4dfa3c8ab7a5f8a9f7434e239d"
+ digest = "1:ab8e92d746fb5c4c18846b0879842ac8e53b3d352449423d0924a11f1020ae1b"
name = "google.golang.org/grpc"
packages = [
".",
@@ -1073,8 +1084,8 @@
"tap",
]
pruneopts = "UT"
- revision = "32fb0ac620c32ba40a4626ddf94d90d12cce3455"
- version = "v1.14.0"
+ revision = "8dea3dc473e90c8179e519d91302d0597c0ca1d1"
+ version = "v1.15.0"
[[projects]]
digest = "1:2655728699af00d823b0a68bd7169fd241a30c04252f456b34421908701b9c3f"
@@ -1093,12 +1104,12 @@
version = "v8.18.2"
[[projects]]
- digest = "1:2d1fbdc6777e5408cabeb02bf336305e724b925ff4546ded0fa8715a7267922a"
+ digest = "1:ef72505cf098abdd34efeea032103377bec06abb61d8a06f002d5d296a4b1185"
name = "gopkg.in/inf.v0"
packages = ["."]
pruneopts = "UT"
- revision = "d2d2541c53f18d2a059457998ce2876cc8e67cbf"
- version = "v0.9.1"
+ revision = "3887ee99ecf07df5b447e9b00d9c0b2adaa9f3e4"
+ version = "v0.9.0"
[[projects]]
digest = "1:342378ac4dcb378a5448dd723f0784ae519383532f5e70ade24132c4c8693202"
@@ -1109,7 +1120,8 @@
version = "v2.2.1"
[[projects]]
- digest = "1:74142cd2275f77547c35ac51514108d9798a09aa0cf377a5c1084718ef7aa225"
+ branch = "master"
+ digest = "1:e77103eb194b363b0a5d257edd309213132ce8171fd0fd3739d47c7c9d9b9ea0"
name = "k8s.io/api"
packages = [
"admissionregistration/v1alpha1",
@@ -1143,10 +1155,11 @@
"storage/v1beta1",
]
pruneopts = "UT"
- revision = "072894a440bdee3a891dea811fe42902311cd2a3"
+ revision = "26c7a45db37856b19f05ba5aa21d2df4b81ecff3"
[[projects]]
- digest = "1:29d5abc33d8cbec19b4cd032a87d28010dd615578dd695a655fc3d5ec3ab86b6"
+ branch = "master"
+ digest = "1:45dfef2f63bde631e0e7c80f97073c94a6792ead321e6974545fe05affc866f9"
name = "k8s.io/apimachinery"
packages = [
"pkg/api/errors",
@@ -1174,19 +1187,19 @@
"pkg/util/framer",
"pkg/util/intstr",
"pkg/util/json",
+ "pkg/util/naming",
"pkg/util/net",
"pkg/util/runtime",
"pkg/util/sets",
"pkg/util/validation",
"pkg/util/validation/field",
- "pkg/util/wait",
"pkg/util/yaml",
"pkg/version",
"pkg/watch",
"third_party/forked/golang/reflect",
]
pruneopts = "UT"
- revision = "103fd098999dc9c0c88536f5c9ad2e5da39373ae"
+ revision = "56cf97ad69c72c043045c349a1badf99d9f7ef44"
[[projects]]
digest = "1:ac46cc5d5c55dd93d4844327334d2253d563d76f14d4b38a8b522b97f0f52214"
@@ -1251,11 +1264,11 @@
[[projects]]
branch = "master"
- digest = "1:49ffc35ec8d3f7789393cd132acd359e8ac1f5d38c7a2b91c484b041840c62c0"
+ digest = "1:1196c8593b21d45fc845d33f55711a716c94106936c0b618dc0f1aaaad3dbf01"
name = "yunion.io/x/jsonutils"
packages = ["."]
pruneopts = "UT"
- revision = "d1290e94d4753c1748fc7c89f472a523cc0a5c08"
+ revision = "4870efdca45d242cbfb4ad112769ed0a7c7be2e6"
[[projects]]
branch = "master"
@@ -1308,11 +1321,11 @@
[[projects]]
branch = "master"
- digest = "1:e52c4c426ba5bbb92b2d6b2f20f694ff836dde16151adaca39c86d5fb010fea9"
+ digest = "1:a22a70d0156f2b836993f4d07b38c4b1c2058d61ced4e55bb7fb77b297424a04"
name = "yunion.io/x/sqlchemy"
packages = ["."]
pruneopts = "UT"
- revision = "946ed13318f85073e55dbb8105593c710e943a31"
+ revision = "3342ff524267b69938600968f3f193fc794b309c"
[[projects]]
branch = "master"
diff --git a/Gopkg.toml b/Gopkg.toml
index a2152e65d5..4d18b52d81 100644
--- a/Gopkg.toml
+++ b/Gopkg.toml
@@ -25,18 +25,138 @@
# unused-packages = true
+[[constraint]]
+ name = "github.com/360EntSecGroup-Skylar/excelize"
+ version = "1.4.0"
+
+[[constraint]]
+ name = "github.com/Azure/azure-sdk-for-go"
+ version = "21.1.0"
+
+[[constraint]]
+ name = "github.com/Azure/go-autorest"
+ version = "10.15.4"
+
+[[constraint]]
+ branch = "master"
+ name = "github.com/Microsoft/azure-vhd-utils"
+
+[[constraint]]
+ name = "github.com/aliyun/alibaba-cloud-sdk-go"
+ version = "1.27.7"
+
+[[constraint]]
+ name = "github.com/aliyun/aliyun-oss-go-sdk"
+ version = "1.9.1"
+
+[[constraint]]
+ name = "github.com/aokoli/goutils"
+ version = "1.0.1"
+
+[[constraint]]
+ name = "github.com/aws/aws-sdk-go"
+ version = "1.15.52"
+
+[[constraint]]
+ name = "github.com/bitly/go-simplejson"
+ version = "0.5.0"
+
[[constraint]]
name = "github.com/c-bata/go-prompt"
- version = "0.2.2"
+ version = "0.2.1"
+
+[[constraint]]
+ name = "github.com/coredns/coredns"
+ version = "1.2.2"
+
+[[constraint]]
+ name = "github.com/fatih/color"
+ version = "1.7.0"
+
+[[constraint]]
+ name = "github.com/go-sql-driver/mysql"
+ version = "1.4.0"
+
+[[constraint]]
+ name = "github.com/golang-plus/uuid"
+ version = "1.0.0"
+
+[[constraint]]
+ branch = "master"
+ name = "github.com/googollee/go-socket.io"
+
+[[constraint]]
+ name = "github.com/gorilla/mux"
+ version = "1.6.2"
+
+[[constraint]]
+ branch = "master"
+ name = "github.com/gosuri/uitable"
+
+[[constraint]]
+ name = "github.com/hako/durafmt"
+ version = "1.0.0"
+
+[[constraint]]
+ name = "github.com/jinzhu/gorm"
+ version = "1.9.1"
+
+[[constraint]]
+ name = "github.com/json-iterator/go"
+ version = "1.1.5"
+
+[[constraint]]
+ name = "github.com/kr/pty"
+ version = "1.1.3"
+
+[[constraint]]
+ name = "github.com/mholt/caddy"
+ version = "0.10.11"
+
+[[constraint]]
+ name = "github.com/miekg/dns"
+ version = "1.0.13"
+
+[[constraint]]
+ branch = "master"
+ name = "github.com/moul/http2curl"
+
+[[constraint]]
+ branch = "master"
+ name = "github.com/serialx/hashring"
+
+[[constraint]]
+ name = "github.com/stretchr/testify"
+ version = "1.2.2"
+
+[[constraint]]
+ name = "github.com/vmware/govmomi"
+ version = "0.19.0"
+
+[[constraint]]
+ branch = "master"
+ name = "golang.org/x/crypto"
+
+[[constraint]]
+ name = "gopkg.in/gin-gonic/gin.v1"
+ version = "1.2.0"
+
+[[constraint]]
+ branch = "master"
+ name = "k8s.io/api"
+
+[[constraint]]
+ branch = "master"
+ name = "k8s.io/apimachinery"
+
+[[constraint]]
+ name = "k8s.io/client-go"
+ version = "8.0.0"
[[constraint]]
branch = "master"
name = "yunion.io/x/jsonutils"
-[[constraint]]
- branch = "master"
- name = "yunion.io/x/sqlchemy"
-
[[constraint]]
branch = "master"
name = "yunion.io/x/log"
@@ -45,71 +165,14 @@
branch = "master"
name = "yunion.io/x/pkg"
+[[constraint]]
+ branch = "master"
+ name = "yunion.io/x/sqlchemy"
+
[[constraint]]
branch = "master"
name = "yunion.io/x/structarg"
-# client-go v8.0.0 uses apimachinery 103fd098999dc9c0c88536f5c9ad2e5da39373ae
-# and api 072894a440bdee3a891dea811fe42902311cd2a3 (see Godep.json). go dep
-# is unable to match Godep.json automatically so have to specify here.
-[[constraint]]
- name = "k8s.io/client-go"
- version = "v8.0.0"
-[[override]]
- name = "k8s.io/apimachinery"
- revision = "103fd098999dc9c0c88536f5c9ad2e5da39373ae"
-[[override]]
- name = "k8s.io/api"
- revision = "072894a440bdee3a891dea811fe42902311cd2a3"
-
-[[override]]
- name = "github.com/apache/thrift"
- revision = "e59b73d3c2bf1c328ccb78e683c0462fa1a473c7"
-[[override]]
- name = "github.com/ugorji/go"
- revision = "f3cacc17c85ecb7f1b6a9e373ee85d1480919868"
-
-[[constraint]]
- name = "github.com/coredns/coredns"
- version = "v1.2.0"
-
[prune]
go-tests = true
unused-packages = true
-
-[[constraint]]
- branch = "master"
- name = "github.com/vmware/govmomi"
-
-
-[[constraint]]
- branch = "master"
- name = "github.com/hako/durafmt"
-
-[[constraint]]
- name = "github.com/Azure/azure-sdk-for-go"
- version = "19.1.0"
-
-[[constraint]]
- branch = "master"
- name = "github.com/googollee/go-socket.io"
-
-[[constraint]]
- branch = "master"
- name = "github.com/kr/pty"
-
-[[constraint]]
- branch = "master"
- name = "github.com/Microsoft/azure-vhd-utils"
-
-[[constraint]]
- branch = "master"
- name = "github.com/texttheater/golang-levenshtein"
-
-[[constraint]]
- name = "github.com/360EntSecGroup-Skylar/excelize"
- version = "v1.3.0"
-
-[[constraint]]
- name = "github.com/aws/aws-sdk-go"
- version = "1.15.43"
diff --git a/pkg/util/aws/aws.go b/pkg/util/aws/aws.go
index b0b265ff73..da044b068b 100644
--- a/pkg/util/aws/aws.go
+++ b/pkg/util/aws/aws.go
@@ -8,15 +8,15 @@ import (
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/ec2"
- "yunion.io/x/jsonutils"
+ "fmt"
)
const (
CLOUD_PROVIDER_AWS = models.CLOUD_PROVIDER_AWS
CLOUD_PROVIDER_AWS_CN = "AWS"
- AWS_DEFAULT_REGION = "cn-hangzhou"
- AWS_API_VERSION = "2014-05-26"
+ AWS_DEFAULT_REGION = "us-west-1"
+ AWS_API_VERSION = "2018-10-10"
)
type SAwsClient struct {
@@ -27,6 +27,15 @@ type SAwsClient struct {
iregions []cloudprovider.ICloudRegion
}
+func NewAwsClient(providerId string, providerName string, accessKey string, secret string) (*SAwsClient, error) {
+ client := SAwsClient{providerId: providerId, providerName: providerName, accessKey: accessKey, secret: secret}
+ err := client.fetchRegions()
+ if err != nil {
+ return nil, err
+ }
+ return &client, nil
+}
+
func (self *SAwsClient) getDefaultSession() (*session.Session, error) {
return session.NewSession(&sdk.Config{
Region: sdk.String(AWS_DEFAULT_REGION),
@@ -34,57 +43,125 @@ func (self *SAwsClient) getDefaultSession() (*session.Session, error) {
})
}
+func (self *SAwsClient) UpdateAccount(accessKey, secret string) error {
+ if self.accessKey != accessKey || self.secret != secret {
+ self.accessKey = accessKey
+ self.secret = secret
+ return self.fetchRegions()
+ } else {
+ return nil
+ }
+}
+
+// 用于初始化region信息
func (self *SAwsClient) fetchRegions() error {
s, err := self.getDefaultSession()
if err != nil {
return err
}
svc := ec2.New(s)
+ // https://docs.aws.amazon.com/sdk-for-go/api/service/ec2/#EC2.DescribeRegions
result, err := svc.DescribeRegions(&ec2.DescribeRegionsInput{})
+ fmt.Println(result)
if err != nil {
return err
}
- sregions := make([]SRegion, 0)
- regions := jsonutils.ParseString("")
- regions.Unmarshal(&sregions, "Regions")
+
+ regions := make([]SRegion, 0)
+ // empty iregions
+ self.iregions = self.iregions[:0]
+ for _, region := range result.Regions {
+ name := *region.RegionName
+ endpoint := *region.Endpoint
+ sregion := SRegion{client: self, RegionId: name, RegionEndpoint: endpoint}
+ regions = append(regions, sregion)
+ self.iregions = append(self.iregions, &sregion)
+ }
+
return nil
}
-func (self *SAwsClient) GetRegions() error {
- // https://docs.aws.amazon.com/sdk-for-go/api/service/ec2/#EC2.DescribeRegions
- panic("implement me")
-}
-
-func (self *SAwsClient) UpdateAccount(accessKey, secret string) error {
- return nil
-}
-
-func (self *SAwsClient) GetRegion(regionId string) *SRegion {
- return nil
+// 只是使用fetchRegions初始化好的self.iregions. 本身并不从云服务器厂商拉取region信息
+func (self *SAwsClient) GetRegions() []SRegion {
+ regions := make([]SRegion, len(self.iregions))
+ for i := 0; i < len(regions); i += 1 {
+ region := self.iregions[i].(*SRegion)
+ regions[i] = *region
+ }
+ return regions
}
func (self *SAwsClient) GetIRegions() []cloudprovider.ICloudRegion {
- panic("implement me")
+ return self.iregions
+}
+
+func (self *SAwsClient) GetRegion(regionId string) *SRegion {
+ if len(regionId) == 0 {
+ regionId = AWS_DEFAULT_REGION
+ }
+ for i := 0; i < len(self.iregions); i += 1 {
+ if self.iregions[i].GetId() == regionId {
+ return self.iregions[i].(*SRegion)
+ }
+ }
+ return nil
}
func (self *SAwsClient) GetIRegionById(id string) (cloudprovider.ICloudRegion, error) {
- panic("implement me")
+ for i := 0; i < len(self.iregions); i += 1 {
+ if self.iregions[i].GetGlobalId() == id {
+ return self.iregions[i], nil
+ }
+ }
+ return nil, cloudprovider.ErrNotFound
}
func (self *SAwsClient) GetIHostById(id string) (cloudprovider.ICloudHost, error) {
- panic("implement me")
+ for i := 0; i < len(self.iregions); i += 1 {
+ ihost, err := self.iregions[i].GetIHostById(id)
+ if err == nil {
+ return ihost, nil
+ } else if err != cloudprovider.ErrNotFound {
+ return nil, err
+ }
+ }
+ return nil, cloudprovider.ErrNotFound
}
func (self *SAwsClient) GetIVpcById(id string) (cloudprovider.ICloudVpc, error) {
- panic("implement me")
+ for i := 0; i < len(self.iregions); i += 1 {
+ ihost, err := self.iregions[i].GetIVpcById(id)
+ if err == nil {
+ return ihost, nil
+ } else if err != cloudprovider.ErrNotFound {
+ return nil, err
+ }
+ }
+ return nil, cloudprovider.ErrNotFound
}
func (self *SAwsClient) GetIStorageById(id string) (cloudprovider.ICloudStorage, error) {
- panic("implement me")
+ for i := 0; i < len(self.iregions); i += 1 {
+ ihost, err := self.iregions[i].GetIStorageById(id)
+ if err == nil {
+ return ihost, nil
+ } else if err != cloudprovider.ErrNotFound {
+ return nil, err
+ }
+ }
+ return nil, cloudprovider.ErrNotFound
}
func (self *SAwsClient) GetIStoragecacheById(id string) (cloudprovider.ICloudStoragecache, error) {
- panic("implement me")
+ for i := 0; i < len(self.iregions); i += 1 {
+ ihost, err := self.iregions[i].GetIStoragecacheById(id)
+ if err == nil {
+ return ihost, nil
+ } else if err != cloudprovider.ErrNotFound {
+ return nil, err
+ }
+ }
+ return nil, cloudprovider.ErrNotFound
}
type SAccountBalance struct {
@@ -97,13 +174,4 @@ type SAccountBalance struct {
func (self *SAwsClient) QueryAccountBalance() (*SAccountBalance, error) {
panic("implement me")
-}
-
-func NewAwsClient(providerId string, providerName string, accessKey string, secret string) (*SAwsClient, error) {
- client := SAwsClient{providerId: providerId, providerName: providerName, accessKey: accessKey, secret: secret}
- err := client.fetchRegions()
- if err != nil {
- return nil, err
- }
- return &client, nil
-}
+}
\ No newline at end of file
diff --git a/pkg/util/aws/aws_test.go b/pkg/util/aws/aws_test.go
new file mode 100644
index 0000000000..c3391515b0
--- /dev/null
+++ b/pkg/util/aws/aws_test.go
@@ -0,0 +1,2 @@
+package aws
+
diff --git a/pkg/util/aws/instancetype.go b/pkg/util/aws/instancetype.go
new file mode 100644
index 0000000000..5e71c60d21
--- /dev/null
+++ b/pkg/util/aws/instancetype.go
@@ -0,0 +1,18 @@
+package aws
+
+type SInstanceType struct {
+ CpuCoreCount int
+ MemorySize float32
+ EniQuantity int // 实例规格支持网卡数量
+ GPUAmount int
+ GPUSpec string
+ InstanceTypeFamily string
+ InstanceTypeId string
+ LocalStorageCategory string
+ LocalStorageAmount int
+ LocalStorageCapacity int64
+ InstanceBandwidthRx int
+ InstanceBandwidthTx int
+ InstancePpsRx int
+ InstancePpsTx int
+}
\ No newline at end of file
diff --git a/pkg/util/aws/provider/provider.go b/pkg/util/aws/provider/provider.go
index 57e0ccb1ba..bf5070d1ac 100644
--- a/pkg/util/aws/provider/provider.go
+++ b/pkg/util/aws/provider/provider.go
@@ -14,7 +14,11 @@ func (self *SAwsProviderFactory) GetId() string {
}
func (self *SAwsProviderFactory) GetProvider(providerId, providerName, url, account, secret string) (cloudprovider.ICloudProvider, error) {
- panic("implement me")
+ client, err := aws.NewAwsClient(providerId, providerName, account, secret)
+ if err != nil {
+ return nil, err
+ }
+ return &SAwsProvider{client: client}, nil
}
func init() {
diff --git a/pkg/util/aws/region.go b/pkg/util/aws/region.go
index 137d6bf5f9..95c9b2f095 100644
--- a/pkg/util/aws/region.go
+++ b/pkg/util/aws/region.go
@@ -1,6 +1,9 @@
package aws
-import "yunion.io/x/onecloud/pkg/cloudprovider"
+import (
+ "yunion.io/x/onecloud/pkg/cloudprovider"
+ "yunion.io/x/jsonutils"
+)
type SRegion struct {
client *SAwsClient
@@ -8,12 +11,102 @@ type SRegion struct {
izones []cloudprovider.ICloudZone
ivpcs []cloudprovider.ICloudVpc
- storageCache *SStoragecache
+ storageCache *SStoragecache
+ instanceTypes []SInstanceType
- ID string
- SubscriptionID string
- Name string
- DisplayName string
- Latitude float32
- Longitude float32
+ RegionEndpoint string
+ RegionId string // 这里为保持一致沿用阿里云RegionId的叫法, 与AWS RegionName字段对应
}
+
+func (self *SRegion) GetId() string {
+ panic("implement me")
+}
+
+func (self *SRegion) GetName() string {
+ panic("implement me")
+}
+
+func (self *SRegion) GetGlobalId() string {
+ panic("implement me")
+}
+
+func (self *SRegion) GetStatus() string {
+ panic("implement me")
+}
+
+func (self *SRegion) Refresh() error {
+ panic("implement me")
+}
+
+func (self *SRegion) IsEmulated() bool {
+ panic("implement me")
+}
+
+func (self *SRegion) GetMetadata() *jsonutils.JSONDict {
+ panic("implement me")
+}
+
+func (self *SRegion) GetLatitude() float32 {
+ panic("implement me")
+}
+
+func (self *SRegion) GetLongitude() float32 {
+ panic("implement me")
+}
+
+func (self *SRegion) GetIZones() ([]cloudprovider.ICloudZone, error) {
+ panic("implement me")
+}
+
+func (self *SRegion) GetIVpcs() ([]cloudprovider.ICloudVpc, error) {
+ panic("implement me")
+}
+
+func (self *SRegion) GetIEips() ([]cloudprovider.ICloudEIP, error) {
+ panic("implement me")
+}
+
+func (self *SRegion) GetISnapshots() ([]cloudprovider.ICloudSnapshot, error) {
+ panic("implement me")
+}
+
+func (self *SRegion) GetISnapshotById(snapshotId string) (cloudprovider.ICloudSnapshot, error) {
+ panic("implement me")
+}
+
+func (self *SRegion) GetIZoneById(id string) (cloudprovider.ICloudZone, error) {
+ panic("implement me")
+}
+
+func (self *SRegion) GetIVpcById(id string) (cloudprovider.ICloudVpc, error) {
+ panic("implement me")
+}
+
+func (self *SRegion) GetIHostById(id string) (cloudprovider.ICloudHost, error) {
+ panic("implement me")
+}
+
+func (self *SRegion) GetIStorageById(id string) (cloudprovider.ICloudStorage, error) {
+ panic("implement me")
+}
+
+func (self *SRegion) GetIStoragecacheById(id string) (cloudprovider.ICloudStoragecache, error) {
+ panic("implement me")
+}
+
+func (self *SRegion) CreateIVpc(name string, desc string, cidr string) (cloudprovider.ICloudVpc, error) {
+ panic("implement me")
+}
+
+func (self *SRegion) CreateEIP(name string, bwMbps int, chargeType string) (cloudprovider.ICloudEIP, error) {
+ panic("implement me")
+}
+
+func (self *SRegion) GetIEipById(id string) (cloudprovider.ICloudEIP, error) {
+ panic("implement me")
+}
+
+func (self *SRegion) GetProvider() string {
+ panic("implement me")
+}
+
diff --git a/vendor/github.com/360EntSecGroup-Skylar/excelize/.travis.yml b/vendor/github.com/360EntSecGroup-Skylar/excelize/.travis.yml
index f4e5c0c802..c2f0f90590 100644
--- a/vendor/github.com/360EntSecGroup-Skylar/excelize/.travis.yml
+++ b/vendor/github.com/360EntSecGroup-Skylar/excelize/.travis.yml
@@ -6,6 +6,17 @@ install:
go:
- 1.8.x
- 1.9.x
+ - 1.10.x
+ - 1.11.x
+
+os:
+ - linux
+ - osx
+
+env:
+ matrix:
+ - GOARCH=amd64
+ - GOARCH=386
script:
- go vet ./...
diff --git a/vendor/github.com/360EntSecGroup-Skylar/excelize/CONTRIBUTING.md b/vendor/github.com/360EntSecGroup-Skylar/excelize/CONTRIBUTING.md
index 27705c8145..5239a94704 100644
--- a/vendor/github.com/360EntSecGroup-Skylar/excelize/CONTRIBUTING.md
+++ b/vendor/github.com/360EntSecGroup-Skylar/excelize/CONTRIBUTING.md
@@ -25,7 +25,6 @@ Security reports are greatly appreciated and we will publicly thank you for it.
We currently do not offer a paid security bounty program, but are not
ruling it out in the future.
-
## Reporting other issues
A great way to contribute to the project is to send a detailed report when you
@@ -44,7 +43,7 @@ When reporting issues, always include the output of `go env`.
Also include the steps required to reproduce the problem if possible and
applicable. This information will help us review and fix your issue faster.
-When sending lengthy log-files, consider posting them as a gist (https://gist.github.com).
+When sending lengthy log-files, consider posting them as a gist [https://gist.github.com](https://gist.github.com).
Don't forget to remove sensitive data from your logfiles before posting (you can
replace those parts with "REDACTED").
@@ -77,9 +76,9 @@ However, there might be a way to implement that feature *on top of* excelize.
Fork the repository and make changes on your fork in a feature branch:
-- If it's a bug fix branch, name it XXXX-something where XXXX is the number of
+* If it's a bug fix branch, name it XXXX-something where XXXX is the number of
the issue.
-- If it's a feature branch, create an enhancement issue to announce
+* If it's a feature branch, create an enhancement issue to announce
your intentions, and name it XXXX-something where XXXX is the number of the
issue.
@@ -194,7 +193,7 @@ signature certifies that you wrote the patch or otherwise have the right to pass
it on as an open-source patch. The rules are pretty simple: if you can certify
the below (from [developercertificate.org](http://developercertificate.org/)):
-```
+```text
Developer Certificate of Origin
Version 1.1
@@ -242,14 +241,14 @@ Use your real name (sorry, no pseudonyms or anonymous contributions.)
If you set your `user.name` and `user.email` git configs, you can sign your
commit automatically with `git commit -s`.
-### How can I become a maintainer?
+### How can I become a maintainer
First, all maintainers have 3 things
-- They share responsibility in the project's success.
-- They have made a long-term, recurring time investment to improve the project.
-- They spend that time doing whatever needs to be done, not necessarily what
-is the most interesting or fun.
+* They share responsibility in the project's success.
+* They have made a long-term, recurring time investment to improve the project.
+* They spend that time doing whatever needs to be done, not necessarily what
+ is the most interesting or fun.
Maintainers are often under-appreciated, because their work is harder to appreciate.
It's easy to appreciate a really cool and technically advanced feature. It's harder
diff --git a/vendor/github.com/360EntSecGroup-Skylar/excelize/PULL_REQUEST_TEMPLATE.md b/vendor/github.com/360EntSecGroup-Skylar/excelize/PULL_REQUEST_TEMPLATE.md
new file mode 100644
index 0000000000..d2ac755e96
--- /dev/null
+++ b/vendor/github.com/360EntSecGroup-Skylar/excelize/PULL_REQUEST_TEMPLATE.md
@@ -0,0 +1,45 @@
+# PR Details
+
+
+
+## Description
+
+
+
+## Related Issue
+
+
+
+
+
+
+## Motivation and Context
+
+
+
+## How Has This Been Tested
+
+
+
+
+
+## Types of changes
+
+
+
+- [ ] Docs change / refactoring / dependency upgrade
+- [ ] Bug fix (non-breaking change which fixes an issue)
+- [ ] New feature (non-breaking change which adds functionality)
+- [ ] Breaking change (fix or feature that would cause existing functionality to change)
+
+## Checklist
+
+
+
+
+- [ ] My code follows the code style of this project.
+- [ ] My change requires a change to the documentation.
+- [ ] I have updated the documentation accordingly.
+- [ ] I have read the **CONTRIBUTING** document.
+- [ ] I have added tests to cover my changes.
+- [ ] All new and existing tests passed.
diff --git a/vendor/github.com/360EntSecGroup-Skylar/excelize/README.md b/vendor/github.com/360EntSecGroup-Skylar/excelize/README.md
index d9c70df634..61ac2d6bee 100644
--- a/vendor/github.com/360EntSecGroup-Skylar/excelize/README.md
+++ b/vendor/github.com/360EntSecGroup-Skylar/excelize/README.md
@@ -11,7 +11,7 @@
## Introduction
-Excelize is a library written in pure Golang and providing a set of functions that allow you to write to and read from XLSX files. Support reads and writes XLSX file generated by Microsoft Excel™ 2007 and later. Support save file without losing original charts of XLSX. This library needs Go version 1.8 or later. The full API docs can be seen using go's built-in documentation tool, or online at [godoc.org](https://godoc.org/github.com/360EntSecGroup-Skylar/excelize) and [Chinese translation](https://xuri.me/excelize/zh_cn).
+Excelize is a library written in pure Go and providing a set of functions that allow you to write to and read from XLSX files. Support reads and writes XLSX file generated by Microsoft Excel™ 2007 and later. Support save file without losing original charts of XLSX. This library needs Go version 1.8 or later. The full API docs can be seen using go's built-in documentation tool, or online at [godoc.org](https://godoc.org/github.com/360EntSecGroup-Skylar/excelize) and [docs reference](https://xuri.me/excelize/).
## Basic Usage
diff --git a/vendor/github.com/360EntSecGroup-Skylar/excelize/README_zh.md b/vendor/github.com/360EntSecGroup-Skylar/excelize/README_zh.md
index ef149b0876..49680d1c8c 100644
--- a/vendor/github.com/360EntSecGroup-Skylar/excelize/README_zh.md
+++ b/vendor/github.com/360EntSecGroup-Skylar/excelize/README_zh.md
@@ -11,7 +11,7 @@
## 简介
-Excelize 是 Go 语言编写的用于操作 Office Excel 文档类库,基于 ECMA-376 Office OpenXML 标准。可以使用它来读取、写入由 Microsoft Excel™ 2007 及以上版本创建的 XLSX 文档。相比较其他的开源类库,Excelize 支持写入原本带有图片(表)、透视表和切片器等复杂样式的文档,还支持向 Excel 文档中插入图片与图表,并且在保存后不会丢失文档原有样式,可以应用于各类报表系统中。使用本类库要求使用的 Go 语言为 1.8 或更高版本,完整的 API 使用文档请访问 [godoc.org](https://godoc.org/github.com/360EntSecGroup-Skylar/excelize) 或查看 [中文翻译](https://xuri.me/excelize/zh_cn)。
+Excelize 是 Go 语言编写的用于操作 Office Excel 文档类库,基于 ECMA-376 Office OpenXML 标准。可以使用它来读取、写入由 Microsoft Excel™ 2007 及以上版本创建的 XLSX 文档。相比较其他的开源类库,Excelize 支持写入原本带有图片(表)、透视表和切片器等复杂样式的文档,还支持向 Excel 文档中插入图片与图表,并且在保存后不会丢失文档原有样式,可以应用于各类报表系统中。使用本类库要求使用的 Go 语言为 1.8 或更高版本,完整的 API 使用文档请访问 [godoc.org](https://godoc.org/github.com/360EntSecGroup-Skylar/excelize) 或查看 [参考文档](https://xuri.me/excelize/)。
## 快速上手
diff --git a/vendor/github.com/360EntSecGroup-Skylar/excelize/cell.go b/vendor/github.com/360EntSecGroup-Skylar/excelize/cell.go
index c5cd8388e1..1277a18073 100644
--- a/vendor/github.com/360EntSecGroup-Skylar/excelize/cell.go
+++ b/vendor/github.com/360EntSecGroup-Skylar/excelize/cell.go
@@ -1,3 +1,12 @@
+// Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of
+// this source code is governed by a BSD-style license that can be found in
+// the LICENSE file.
+//
+// Package excelize providing a set of functions that allow you to write to
+// and read from XLSX files. Support reads and writes XLSX file generated by
+// Microsoft Excel™ 2007 and later. Support save file without losing original
+// charts of XLSX. This library needs Go version 1.8 or later.
+
package excelize
import (
@@ -9,7 +18,18 @@ import (
"time"
)
-// mergeCellsParser provides function to check merged cells in worksheet by
+const (
+ // STCellFormulaTypeArray defined the formula is an array formula.
+ STCellFormulaTypeArray = "array"
+ // STCellFormulaTypeDataTable defined the formula is a data table formula.
+ STCellFormulaTypeDataTable = "dataTable"
+ // STCellFormulaTypeNormal defined the formula is a regular cell formula.
+ STCellFormulaTypeNormal = "normal"
+ // STCellFormulaTypeShared defined the formula is part of a shared formula.
+ STCellFormulaTypeShared = "shared"
+)
+
+// mergeCellsParser provides a function to check merged cells in worksheet by
// given axis.
func (f *File) mergeCellsParser(xlsx *xlsxWorksheet, axis string) string {
axis = strings.ToUpper(axis)
@@ -23,8 +43,8 @@ func (f *File) mergeCellsParser(xlsx *xlsxWorksheet, axis string) string {
return axis
}
-// SetCellValue provides function to set value of a cell. The following shows
-// the supported data types:
+// SetCellValue provides a function to set value of a cell. The following
+// shows the supported data types:
//
// int
// int8
@@ -72,7 +92,7 @@ func (f *File) SetCellValue(sheet, axis string, value interface{}) {
}
}
-// setCellIntValue provides function to set int value of a cell.
+// setCellIntValue provides a function to set int value of a cell.
func (f *File) setCellIntValue(sheet, axis string, value interface{}) {
switch value.(type) {
case int:
@@ -100,7 +120,7 @@ func (f *File) setCellIntValue(sheet, axis string, value interface{}) {
}
}
-// SetCellBool provides function to set bool type value of a cell by given
+// SetCellBool provides a function to set bool type value of a cell by given
// worksheet name, cell coordinates and cell value.
func (f *File) SetCellBool(sheet, axis string, value bool) {
xlsx := f.workSheetReader(sheet)
@@ -128,10 +148,10 @@ func (f *File) SetCellBool(sheet, axis string, value bool) {
}
}
-// GetCellValue provides function to get formatted value from cell by given
-// worksheet name and axis in XLSX file. If it is possible to apply a format to
-// the cell value, it will do so, if not then an error will be returned, along
-// with the raw value of the cell.
+// GetCellValue provides a function to get formatted value from cell by given
+// worksheet name and axis in XLSX file. If it is possible to apply a format
+// to the cell value, it will do so, if not then an error will be returned,
+// along with the raw value of the cell.
func (f *File) GetCellValue(sheet, axis string) string {
xlsx := f.workSheetReader(sheet)
axis = f.mergeCellsParser(xlsx, axis)
@@ -163,9 +183,9 @@ func (f *File) GetCellValue(sheet, axis string) string {
return ""
}
-// formattedValue provides function to returns a value after formatted. If it is
-// possible to apply a format to the cell value, it will do so, if not then an
-// error will be returned, along with the raw value of the cell.
+// formattedValue provides a function to returns a value after formatted. If
+// it is possible to apply a format to the cell value, it will do so, if not
+// then an error will be returned, along with the raw value of the cell.
func (f *File) formattedValue(s int, v string) string {
if s == 0 {
return v
@@ -178,7 +198,7 @@ func (f *File) formattedValue(s int, v string) string {
return v
}
-// GetCellStyle provides function to get cell style index by given worksheet
+// GetCellStyle provides a function to get cell style index by given worksheet
// name and cell coordinates.
func (f *File) GetCellStyle(sheet, axis string) int {
xlsx := f.workSheetReader(sheet)
@@ -200,8 +220,8 @@ func (f *File) GetCellStyle(sheet, axis string) int {
return f.prepareCellStyle(xlsx, cell, xlsx.SheetData.Row[xAxis].C[yAxis].S)
}
-// GetCellFormula provides function to get formula from cell by given worksheet
-// name and axis in XLSX file.
+// GetCellFormula provides a function to get formula from cell by given
+// worksheet name and axis in XLSX file.
func (f *File) GetCellFormula(sheet, axis string) string {
xlsx := f.workSheetReader(sheet)
axis = f.mergeCellsParser(xlsx, axis)
@@ -224,6 +244,9 @@ func (f *File) GetCellFormula(sheet, axis string) string {
if xlsx.SheetData.Row[k].R == row {
for i := range xlsx.SheetData.Row[k].C {
if axis == xlsx.SheetData.Row[k].C[i].R {
+ if xlsx.SheetData.Row[k].C[i].F.T == STCellFormulaTypeShared {
+ return getSharedForumula(xlsx, xlsx.SheetData.Row[k].C[i].F.Si)
+ }
if xlsx.SheetData.Row[k].C[i].F != nil {
return xlsx.SheetData.Row[k].C[i].F.Content
}
@@ -234,7 +257,35 @@ func (f *File) GetCellFormula(sheet, axis string) string {
return ""
}
-// SetCellFormula provides function to set cell formula by given string and
+// getSharedForumula find a cell contains the same formula as another cell,
+// the "shared" value can be used for the t attribute and the si attribute can
+// be used to refer to the cell containing the formula. Two formulas are
+// considered to be the same when their respective representations in
+// R1C1-reference notation, are the same.
+//
+// Note that this function not validate ref tag to check the cell if or not in
+// allow area, and always return origin shared formula.
+func getSharedForumula(xlsx *xlsxWorksheet, si string) string {
+ for k := range xlsx.SheetData.Row {
+ for i := range xlsx.SheetData.Row[k].C {
+ if xlsx.SheetData.Row[k].C[i].F == nil {
+ continue
+ }
+ if xlsx.SheetData.Row[k].C[i].F.T != STCellFormulaTypeShared {
+ continue
+ }
+ if xlsx.SheetData.Row[k].C[i].F.Si != si {
+ continue
+ }
+ if xlsx.SheetData.Row[k].C[i].F.Ref != "" {
+ return xlsx.SheetData.Row[k].C[i].F.Content
+ }
+ }
+ }
+ return ""
+}
+
+// SetCellFormula provides a function to set cell formula by given string and
// worksheet name.
func (f *File) SetCellFormula(sheet, axis, formula string) {
xlsx := f.workSheetReader(sheet)
@@ -263,10 +314,10 @@ func (f *File) SetCellFormula(sheet, axis, formula string) {
}
}
-// SetCellHyperLink provides function to set cell hyperlink by given worksheet
-// name and link URL address. LinkType defines two types of hyperlink "External"
-// for web site or "Location" for moving to one of cell in this workbook. The
-// below is example for external link.
+// SetCellHyperLink provides a function to set cell hyperlink by given
+// worksheet name and link URL address. LinkType defines two types of
+// hyperlink "External" for web site or "Location" for moving to one of cell
+// in this workbook. The below is example for external link.
//
// xlsx.SetCellHyperLink("Sheet1", "A3", "https://github.com/360EntSecGroup-Skylar/excelize", "External")
// // Set underline and font color style for the cell.
@@ -299,10 +350,10 @@ func (f *File) SetCellHyperLink(sheet, axis, link, linkType string) {
xlsx.Hyperlinks.Hyperlink = append(xlsx.Hyperlinks.Hyperlink, hyperlink)
}
-// GetCellHyperLink provides function to get cell hyperlink by given worksheet
-// name and axis. Boolean type value link will be ture if the cell has a
-// hyperlink and the target is the address of the hyperlink. Otherwise, the
-// value of link will be false and the value of the target will be a blank
+// GetCellHyperLink provides a function to get cell hyperlink by given
+// worksheet name and axis. Boolean type value link will be ture if the cell
+// has a hyperlink and the target is the address of the hyperlink. Otherwise,
+// the value of link will be false and the value of the target will be a blank
// string. For example get hyperlink of Sheet1!H6:
//
// link, target := xlsx.GetCellHyperLink("Sheet1", "H6")
@@ -327,8 +378,8 @@ func (f *File) GetCellHyperLink(sheet, axis string) (bool, string) {
return link, target
}
-// MergeCell provides function to merge cells by given coordinate area and sheet
-// name. For example create a merged cell of D3:E9 on Sheet1:
+// MergeCell provides a function to merge cells by given coordinate area and
+// sheet name. For example create a merged cell of D3:E9 on Sheet1:
//
// xlsx.MergeCell("Sheet1", "D3", "E9")
//
@@ -387,7 +438,7 @@ func (f *File) MergeCell(sheet, hcell, vcell string) {
}
}
-// SetCellInt provides function to set int type value of a cell by given
+// SetCellInt provides a function to set int type value of a cell by given
// worksheet name, cell coordinates and cell value.
func (f *File) SetCellInt(sheet, axis string, value int) {
xlsx := f.workSheetReader(sheet)
@@ -411,7 +462,7 @@ func (f *File) SetCellInt(sheet, axis string, value int) {
xlsx.SheetData.Row[xAxis].C[yAxis].V = strconv.Itoa(value)
}
-// prepareCellStyle provides function to prepare style index of cell in
+// prepareCellStyle provides a function to prepare style index of cell in
// worksheet by given column index and style index.
func (f *File) prepareCellStyle(xlsx *xlsxWorksheet, col, style int) int {
if xlsx.Cols != nil && style == 0 {
@@ -424,8 +475,8 @@ func (f *File) prepareCellStyle(xlsx *xlsxWorksheet, col, style int) int {
return style
}
-// SetCellStr provides function to set string type value of a cell. Total number
-// of characters that a cell can contain 32767 characters.
+// SetCellStr provides a function to set string type value of a cell. Total
+// number of characters that a cell can contain 32767 characters.
func (f *File) SetCellStr(sheet, axis, value string) {
xlsx := f.workSheetReader(sheet)
axis = f.mergeCellsParser(xlsx, axis)
@@ -460,7 +511,7 @@ func (f *File) SetCellStr(sheet, axis, value string) {
xlsx.SheetData.Row[xAxis].C[yAxis].V = value
}
-// SetCellDefault provides function to set string type value of a cell as
+// SetCellDefault provides a function to set string type value of a cell as
// default format without escaping the cell.
func (f *File) SetCellDefault(sheet, axis, value string) {
xlsx := f.workSheetReader(sheet)
@@ -525,7 +576,7 @@ func (f *File) SetSheetRow(sheet, axis string, slice interface{}) {
}
}
-// checkCellInArea provides function to determine if a given coordinate is
+// checkCellInArea provides a function to determine if a given coordinate is
// within an area.
func checkCellInArea(cell, area string) bool {
cell = strings.ToUpper(cell)
diff --git a/vendor/github.com/360EntSecGroup-Skylar/excelize/chart.go b/vendor/github.com/360EntSecGroup-Skylar/excelize/chart.go
index 7a14d09aec..5353a3297c 100644
--- a/vendor/github.com/360EntSecGroup-Skylar/excelize/chart.go
+++ b/vendor/github.com/360EntSecGroup-Skylar/excelize/chart.go
@@ -1,3 +1,12 @@
+// Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of
+// this source code is governed by a BSD-style license that can be found in
+// the LICENSE file.
+//
+// Package excelize providing a set of functions that allow you to write to
+// and read from XLSX files. Support reads and writes XLSX file generated by
+// Microsoft Excel™ 2007 and later. Support save file without losing original
+// charts of XLSX. This library needs Go version 1.8 or later.
+
package excelize
import (
@@ -190,9 +199,9 @@ var (
}
)
-// parseFormatChartSet provides function to parse the format settings of the
+// parseFormatChartSet provides a function to parse the format settings of the
// chart with default value.
-func parseFormatChartSet(formatSet string) *formatChart {
+func parseFormatChartSet(formatSet string) (*formatChart, error) {
format := formatChart{
Dimension: formatChartDimension{
Width: 480,
@@ -216,8 +225,8 @@ func parseFormatChartSet(formatSet string) *formatChart {
},
ShowBlanksAs: "gap",
}
- json.Unmarshal([]byte(formatSet), &format)
- return &format
+ err := json.Unmarshal([]byte(formatSet), &format)
+ return &format, err
}
// AddChart provides the method to add chart in a sheet by given chart format
@@ -352,13 +361,18 @@ func parseFormatChartSet(formatSet string) *formatChart {
// minimum
//
// reverse_order: Specifies that the categories or values on reverse order (orientation of the chart). The reverse_order property is optional. The default value is false.
+//
// maximum: Specifies that the fixed maximum, 0 is auto. The maximum property is optional. The default value is auto.
+//
// minimum: Specifies that the fixed minimum, 0 is auto. The minimum property is optional. The default value is auto.
//
// Set chart size by dimension property. The dimension property is optional. The default width is 480, and height is 290.
//
-func (f *File) AddChart(sheet, cell, format string) {
- formatSet := parseFormatChartSet(format)
+func (f *File) AddChart(sheet, cell, format string) error {
+ formatSet, err := parseFormatChartSet(format)
+ if err != nil {
+ return err
+ }
// Read sheet data.
xlsx := f.workSheetReader(sheet)
// Add first picture for given sheet, create xl/drawings/ and xl/drawings/_rels/ folder.
@@ -371,9 +385,10 @@ func (f *File) AddChart(sheet, cell, format string) {
f.addChart(formatSet)
f.addContentTypePart(chartID, "chart")
f.addContentTypePart(drawingID, "drawings")
+ return err
}
-// countCharts provides function to get chart files count storage in the
+// countCharts provides a function to get chart files count storage in the
// folder xl/charts.
func (f *File) countCharts() int {
count := 0
@@ -385,7 +400,7 @@ func (f *File) countCharts() int {
return count
}
-// prepareDrawing provides function to prepare drawing ID and XML by given
+// prepareDrawing provides a function to prepare drawing ID and XML by given
// drawingID, worksheet name and default drawingXML.
func (f *File) prepareDrawing(xlsx *xlsxWorksheet, drawingID int, sheet, drawingXML string) (int, string) {
sheetRelationshipsDrawingXML := "../drawings/drawing" + strconv.Itoa(drawingID) + ".xml"
@@ -402,8 +417,8 @@ func (f *File) prepareDrawing(xlsx *xlsxWorksheet, drawingID int, sheet, drawing
return drawingID, drawingXML
}
-// addChart provides function to create chart as xl/charts/chart%d.xml by given
-// format sets.
+// addChart provides a function to create chart as xl/charts/chart%d.xml by
+// given format sets.
func (f *File) addChart(formatSet *formatChart) {
count := f.countCharts()
xlsxChartSpace := xlsxChartSpace{
@@ -558,7 +573,7 @@ func (f *File) addChart(formatSet *formatChart) {
f.saveFileList(media, chart)
}
-// drawBaseChart provides function to draw the c:plotArea element for bar,
+// drawBaseChart provides a function to draw the c:plotArea element for bar,
// and column series charts by given format sets.
func (f *File) drawBaseChart(formatSet *formatChart) *cPlotArea {
c := cCharts{
@@ -655,7 +670,7 @@ func (f *File) drawBaseChart(formatSet *formatChart) *cPlotArea {
return charts[formatSet.Type]
}
-// drawDoughnutChart provides function to draw the c:plotArea element for
+// drawDoughnutChart provides a function to draw the c:plotArea element for
// doughnut chart by given format sets.
func (f *File) drawDoughnutChart(formatSet *formatChart) *cPlotArea {
return &cPlotArea{
@@ -669,8 +684,8 @@ func (f *File) drawDoughnutChart(formatSet *formatChart) *cPlotArea {
}
}
-// drawLineChart provides function to draw the c:plotArea element for line chart
-// by given format sets.
+// drawLineChart provides a function to draw the c:plotArea element for line
+// chart by given format sets.
func (f *File) drawLineChart(formatSet *formatChart) *cPlotArea {
return &cPlotArea{
LineChart: &cCharts{
@@ -695,8 +710,8 @@ func (f *File) drawLineChart(formatSet *formatChart) *cPlotArea {
}
}
-// drawPieChart provides function to draw the c:plotArea element for pie chart
-// by given format sets.
+// drawPieChart provides a function to draw the c:plotArea element for pie
+// chart by given format sets.
func (f *File) drawPieChart(formatSet *formatChart) *cPlotArea {
return &cPlotArea{
PieChart: &cCharts{
@@ -708,8 +723,8 @@ func (f *File) drawPieChart(formatSet *formatChart) *cPlotArea {
}
}
-// drawPie3DChart provides function to draw the c:plotArea element for 3D pie
-// chart by given format sets.
+// drawPie3DChart provides a function to draw the c:plotArea element for 3D
+// pie chart by given format sets.
func (f *File) drawPie3DChart(formatSet *formatChart) *cPlotArea {
return &cPlotArea{
Pie3DChart: &cCharts{
@@ -721,7 +736,7 @@ func (f *File) drawPie3DChart(formatSet *formatChart) *cPlotArea {
}
}
-// drawRadarChart provides function to draw the c:plotArea element for radar
+// drawRadarChart provides a function to draw the c:plotArea element for radar
// chart by given format sets.
func (f *File) drawRadarChart(formatSet *formatChart) *cPlotArea {
return &cPlotArea{
@@ -744,8 +759,8 @@ func (f *File) drawRadarChart(formatSet *formatChart) *cPlotArea {
}
}
-// drawScatterChart provides function to draw the c:plotArea element for scatter
-// chart by given format sets.
+// drawScatterChart provides a function to draw the c:plotArea element for
+// scatter chart by given format sets.
func (f *File) drawScatterChart(formatSet *formatChart) *cPlotArea {
return &cPlotArea{
ScatterChart: &cCharts{
@@ -767,8 +782,8 @@ func (f *File) drawScatterChart(formatSet *formatChart) *cPlotArea {
}
}
-// drawChartSeries provides function to draw the c:ser element by given format
-// sets.
+// drawChartSeries provides a function to draw the c:ser element by given
+// format sets.
func (f *File) drawChartSeries(formatSet *formatChart) *[]cSer {
ser := []cSer{}
for k := range formatSet.Series {
@@ -793,7 +808,7 @@ func (f *File) drawChartSeries(formatSet *formatChart) *[]cSer {
return &ser
}
-// drawChartSeriesSpPr provides function to draw the c:spPr element by given
+// drawChartSeriesSpPr provides a function to draw the c:spPr element by given
// format sets.
func (f *File) drawChartSeriesSpPr(i int, formatSet *formatChart) *cSpPr {
spPrScatter := &cSpPr{
@@ -815,8 +830,8 @@ func (f *File) drawChartSeriesSpPr(i int, formatSet *formatChart) *cSpPr {
return chartSeriesSpPr[formatSet.Type]
}
-// drawChartSeriesDPt provides function to draw the c:dPt element by given data
-// index and format sets.
+// drawChartSeriesDPt provides a function to draw the c:dPt element by given
+// data index and format sets.
func (f *File) drawChartSeriesDPt(i int, formatSet *formatChart) []*cDPt {
dpt := []*cDPt{{
IDx: &attrValInt{Val: i},
@@ -844,8 +859,8 @@ func (f *File) drawChartSeriesDPt(i int, formatSet *formatChart) []*cDPt {
return chartSeriesDPt[formatSet.Type]
}
-// drawChartSeriesCat provides function to draw the c:cat element by given chart
-// series and format sets.
+// drawChartSeriesCat provides a function to draw the c:cat element by given
+// chart series and format sets.
func (f *File) drawChartSeriesCat(v formatChartSeries, formatSet *formatChart) *cCat {
cat := &cCat{
StrRef: &cStrRef{
@@ -856,8 +871,8 @@ func (f *File) drawChartSeriesCat(v formatChartSeries, formatSet *formatChart) *
return chartSeriesCat[formatSet.Type]
}
-// drawChartSeriesVal provides function to draw the c:val element by given chart
-// series and format sets.
+// drawChartSeriesVal provides a function to draw the c:val element by given
+// chart series and format sets.
func (f *File) drawChartSeriesVal(v formatChartSeries, formatSet *formatChart) *cVal {
val := &cVal{
NumRef: &cNumRef{
@@ -868,8 +883,8 @@ func (f *File) drawChartSeriesVal(v formatChartSeries, formatSet *formatChart) *
return chartSeriesVal[formatSet.Type]
}
-// drawChartSeriesMarker provides function to draw the c:marker element by given
-// data index and format sets.
+// drawChartSeriesMarker provides a function to draw the c:marker element by
+// given data index and format sets.
func (f *File) drawChartSeriesMarker(i int, formatSet *formatChart) *cMarker {
marker := &cMarker{
Symbol: &attrValString{Val: "circle"},
@@ -894,7 +909,7 @@ func (f *File) drawChartSeriesMarker(i int, formatSet *formatChart) *cMarker {
return chartSeriesMarker[formatSet.Type]
}
-// drawChartSeriesXVal provides function to draw the c:xVal element by given
+// drawChartSeriesXVal provides a function to draw the c:xVal element by given
// chart series and format sets.
func (f *File) drawChartSeriesXVal(v formatChartSeries, formatSet *formatChart) *cCat {
cat := &cCat{
@@ -906,7 +921,7 @@ func (f *File) drawChartSeriesXVal(v formatChartSeries, formatSet *formatChart)
return chartSeriesXVal[formatSet.Type]
}
-// drawChartSeriesYVal provides function to draw the c:yVal element by given
+// drawChartSeriesYVal provides a function to draw the c:yVal element by given
// chart series and format sets.
func (f *File) drawChartSeriesYVal(v formatChartSeries, formatSet *formatChart) *cVal {
val := &cVal{
@@ -918,8 +933,8 @@ func (f *File) drawChartSeriesYVal(v formatChartSeries, formatSet *formatChart)
return chartSeriesYVal[formatSet.Type]
}
-// drawChartDLbls provides function to draw the c:dLbls element by given format
-// sets.
+// drawChartDLbls provides a function to draw the c:dLbls element by given
+// format sets.
func (f *File) drawChartDLbls(formatSet *formatChart) *cDLbls {
return &cDLbls{
ShowLegendKey: &attrValBool{Val: formatSet.Legend.ShowLegendKey},
@@ -932,15 +947,15 @@ func (f *File) drawChartDLbls(formatSet *formatChart) *cDLbls {
}
}
-// drawChartSeriesDLbls provides function to draw the c:dLbls element by given
-// format sets.
+// drawChartSeriesDLbls provides a function to draw the c:dLbls element by
+// given format sets.
func (f *File) drawChartSeriesDLbls(formatSet *formatChart) *cDLbls {
dLbls := f.drawChartDLbls(formatSet)
chartSeriesDLbls := map[string]*cDLbls{Bar: dLbls, BarStacked: dLbls, BarPercentStacked: dLbls, Bar3DClustered: dLbls, Bar3DStacked: dLbls, Bar3DPercentStacked: dLbls, Col: dLbls, ColStacked: dLbls, ColPercentStacked: dLbls, Col3DClustered: dLbls, Col3D: dLbls, Col3DStacked: dLbls, Col3DPercentStacked: dLbls, Doughnut: dLbls, Line: dLbls, Pie: dLbls, Pie3D: dLbls, Radar: dLbls, Scatter: nil}
return chartSeriesDLbls[formatSet.Type]
}
-// drawPlotAreaCatAx provides function to draw the c:catAx element.
+// drawPlotAreaCatAx provides a function to draw the c:catAx element.
func (f *File) drawPlotAreaCatAx(formatSet *formatChart) []*cAxs {
min := &attrValFloat{Val: formatSet.XAxis.Minimum}
max := &attrValFloat{Val: formatSet.XAxis.Maximum}
@@ -979,7 +994,7 @@ func (f *File) drawPlotAreaCatAx(formatSet *formatChart) []*cAxs {
}
}
-// drawPlotAreaValAx provides function to draw the c:valAx element.
+// drawPlotAreaValAx provides a function to draw the c:valAx element.
func (f *File) drawPlotAreaValAx(formatSet *formatChart) []*cAxs {
min := &attrValFloat{Val: formatSet.YAxis.Minimum}
max := &attrValFloat{Val: formatSet.YAxis.Maximum}
@@ -1015,7 +1030,7 @@ func (f *File) drawPlotAreaValAx(formatSet *formatChart) []*cAxs {
}
}
-// drawPlotAreaSpPr provides function to draw the c:spPr element.
+// drawPlotAreaSpPr provides a function to draw the c:spPr element.
func (f *File) drawPlotAreaSpPr() *cSpPr {
return &cSpPr{
Ln: &aLn{
@@ -1034,7 +1049,7 @@ func (f *File) drawPlotAreaSpPr() *cSpPr {
}
}
-// drawPlotAreaTxPr provides function to draw the c:txPr element.
+// drawPlotAreaTxPr provides a function to draw the c:txPr element.
func (f *File) drawPlotAreaTxPr() *cTxPr {
return &cTxPr{
BodyPr: aBodyPr{
@@ -1073,8 +1088,8 @@ func (f *File) drawPlotAreaTxPr() *cTxPr {
}
}
-// drawingParser provides function to parse drawingXML. In order to solve the
-// problem that the label structure is changed after serialization and
+// drawingParser provides a function to parse drawingXML. In order to solve
+// the problem that the label structure is changed after serialization and
// deserialization, two different structures: decodeWsDr and encodeWsDr are
// defined.
func (f *File) drawingParser(drawingXML string, content *xlsxWsDr) int {
@@ -1082,7 +1097,7 @@ func (f *File) drawingParser(drawingXML string, content *xlsxWsDr) int {
_, ok := f.XLSX[drawingXML]
if ok { // Append Model
decodeWsDr := decodeWsDr{}
- xml.Unmarshal([]byte(f.readXML(drawingXML)), &decodeWsDr)
+ _ = xml.Unmarshal([]byte(f.readXML(drawingXML)), &decodeWsDr)
content.R = decodeWsDr.R
cNvPrID = len(decodeWsDr.OneCellAnchor) + len(decodeWsDr.TwoCellAnchor) + 1
for _, v := range decodeWsDr.OneCellAnchor {
@@ -1101,8 +1116,8 @@ func (f *File) drawingParser(drawingXML string, content *xlsxWsDr) int {
return cNvPrID
}
-// addDrawingChart provides function to add chart graphic frame by given sheet,
-// drawingXML, cell, width, height, relationship index and format sets.
+// addDrawingChart provides a function to add chart graphic frame by given
+// sheet, drawingXML, cell, width, height, relationship index and format sets.
func (f *File) addDrawingChart(sheet, drawingXML, cell string, width, height, rID int, formatSet *formatPicture) {
cell = strings.ToUpper(cell)
fromCol := string(strings.Map(letterOnlyMapF, cell))
diff --git a/vendor/github.com/360EntSecGroup-Skylar/excelize/col.go b/vendor/github.com/360EntSecGroup-Skylar/excelize/col.go
index 05ad0cceb8..32cda12a64 100644
--- a/vendor/github.com/360EntSecGroup-Skylar/excelize/col.go
+++ b/vendor/github.com/360EntSecGroup-Skylar/excelize/col.go
@@ -1,3 +1,12 @@
+// Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of
+// this source code is governed by a BSD-style license that can be found in
+// the LICENSE file.
+//
+// Package excelize providing a set of functions that allow you to write to
+// and read from XLSX files. Support reads and writes XLSX file generated by
+// Microsoft Excel™ 2007 and later. Support save file without losing original
+// charts of XLSX. This library needs Go version 1.8 or later.
+
package excelize
import (
@@ -121,8 +130,8 @@ func (f *File) SetColOutlineLevel(sheet, column string, level uint8) {
xlsx.Cols.Col = append(xlsx.Cols.Col, col)
}
-// SetColWidth provides function to set the width of a single column or multiple
-// columns. For example:
+// SetColWidth provides a function to set the width of a single column or
+// multiple columns. For example:
//
// xlsx := excelize.NewFile()
// xlsx.SetColWidth("Sheet1", "A", "H", 20)
@@ -259,8 +268,8 @@ func (f *File) positionObjectPixels(sheet string, colStart, rowStart, x1, y1, wi
return colStart, rowStart, xAbs, yAbs, colEnd, rowEnd, x2, y2
}
-// getColWidth provides function to get column width in pixels by given sheet
-// name and column index.
+// getColWidth provides a function to get column width in pixels by given
+// sheet name and column index.
func (f *File) getColWidth(sheet string, col int) int {
xlsx := f.workSheetReader(sheet)
if xlsx.Cols != nil {
@@ -278,8 +287,8 @@ func (f *File) getColWidth(sheet string, col int) int {
return int(defaultColWidthPixels)
}
-// GetColWidth provides function to get column width by given worksheet name and
-// column index.
+// GetColWidth provides a function to get column width by given worksheet name
+// and column index.
func (f *File) GetColWidth(sheet, column string) float64 {
col := TitleToNumber(strings.ToUpper(column)) + 1
xlsx := f.workSheetReader(sheet)
@@ -298,8 +307,8 @@ func (f *File) GetColWidth(sheet, column string) float64 {
return defaultColWidthPixels
}
-// InsertCol provides function to insert a new column before given column index.
-// For example, create a new column before column C in Sheet1:
+// InsertCol provides a function to insert a new column before given column
+// index. For example, create a new column before column C in Sheet1:
//
// xlsx.InsertCol("Sheet1", "C")
//
@@ -308,8 +317,8 @@ func (f *File) InsertCol(sheet, column string) {
f.adjustHelper(sheet, col, -1, 1)
}
-// RemoveCol provides function to remove single column by given worksheet name
-// and column index. For example, remove column C in Sheet1:
+// RemoveCol provides a function to remove single column by given worksheet
+// name and column index. For example, remove column C in Sheet1:
//
// xlsx.RemoveCol("Sheet1", "C")
//
@@ -346,10 +355,10 @@ func completeCol(xlsx *xlsxWorksheet, row, cell int) {
}
}
-// convertColWidthToPixels provieds function to convert the width of a cell from
-// user's units to pixels. Excel rounds the column width to the nearest pixel.
-// If the width hasn't been set by the user we use the default value. If the
-// column is hidden it has a value of zero.
+// convertColWidthToPixels provieds function to convert the width of a cell
+// from user's units to pixels. Excel rounds the column width to the nearest
+// pixel. If the width hasn't been set by the user we use the default value.
+// If the column is hidden it has a value of zero.
func convertColWidthToPixels(width float64) float64 {
var padding float64 = 5
var pixels float64
diff --git a/vendor/github.com/360EntSecGroup-Skylar/excelize/comment.go b/vendor/github.com/360EntSecGroup-Skylar/excelize/comment.go
index 41b4d6bae4..2bfd785da6 100644
--- a/vendor/github.com/360EntSecGroup-Skylar/excelize/comment.go
+++ b/vendor/github.com/360EntSecGroup-Skylar/excelize/comment.go
@@ -1,21 +1,61 @@
+// Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of
+// this source code is governed by a BSD-style license that can be found in
+// the LICENSE file.
+//
+// Package excelize providing a set of functions that allow you to write to
+// and read from XLSX files. Support reads and writes XLSX file generated by
+// Microsoft Excel™ 2007 and later. Support save file without losing original
+// charts of XLSX. This library needs Go version 1.8 or later.
+
package excelize
import (
"encoding/json"
"encoding/xml"
+ "fmt"
"strconv"
"strings"
)
-// parseFormatCommentsSet provides function to parse the format settings of the
-// comment with default value.
-func parseFormatCommentsSet(formatSet string) *formatComment {
+// parseFormatCommentsSet provides a function to parse the format settings of
+// the comment with default value.
+func parseFormatCommentsSet(formatSet string) (*formatComment, error) {
format := formatComment{
Author: "Author:",
Text: " ",
}
- json.Unmarshal([]byte(formatSet), &format)
- return &format
+ err := json.Unmarshal([]byte(formatSet), &format)
+ return &format, err
+}
+
+// GetComments retrieves all comments and returns a map of worksheet name to
+// the worksheet comments.
+func (f *File) GetComments() (comments map[string][]Comment) {
+ comments = map[string][]Comment{}
+ for n := range f.sheetMap {
+ commentID := f.GetSheetIndex(n)
+ commentsXML := "xl/comments" + strconv.Itoa(commentID) + ".xml"
+ c, ok := f.XLSX[commentsXML]
+ if ok {
+ d := xlsxComments{}
+ xml.Unmarshal([]byte(c), &d)
+ sheetComments := []Comment{}
+ for _, comment := range d.CommentList.Comment {
+ sheetComment := Comment{}
+ if comment.AuthorID < len(d.Authors) {
+ sheetComment.Author = d.Authors[comment.AuthorID].Author
+ }
+ sheetComment.Ref = comment.Ref
+ sheetComment.AuthorID = comment.AuthorID
+ for _, text := range comment.Text.R {
+ sheetComment.Text += text.T
+ }
+ sheetComments = append(sheetComments, sheetComment)
+ }
+ comments[n] = sheetComments
+ }
+ }
+ return
}
// AddComment provides the method to add comment in a sheet by given worksheet
@@ -25,8 +65,11 @@ func parseFormatCommentsSet(formatSet string) *formatComment {
//
// xlsx.AddComment("Sheet1", "A30", `{"author":"Excelize: ","text":"This is a comment."}`)
//
-func (f *File) AddComment(sheet, cell, format string) {
- formatSet := parseFormatCommentsSet(format)
+func (f *File) AddComment(sheet, cell, format string) error {
+ formatSet, err := parseFormatCommentsSet(format)
+ if err != nil {
+ return err
+ }
// Read sheet data.
xlsx := f.workSheetReader(sheet)
commentID := f.countComments() + 1
@@ -46,13 +89,23 @@ func (f *File) AddComment(sheet, cell, format string) {
}
commentsXML := "xl/comments" + strconv.Itoa(commentID) + ".xml"
f.addComment(commentsXML, cell, formatSet)
- f.addDrawingVML(commentID, drawingVML, cell)
+ var colCount int
+ for i, l := range strings.Split(formatSet.Text, "\n") {
+ if ll := len(l); ll > colCount {
+ if i == 0 {
+ ll += len(formatSet.Author)
+ }
+ colCount = ll
+ }
+ }
+ f.addDrawingVML(commentID, drawingVML, cell, strings.Count(formatSet.Text, "\n")+1, colCount)
f.addContentTypePart(commentID, "comments")
+ return err
}
-// addDrawingVML provides function to create comment as
+// addDrawingVML provides a function to create comment as
// xl/drawings/vmlDrawing%d.vml by given commit ID and cell.
-func (f *File) addDrawingVML(commentID int, drawingVML, cell string) {
+func (f *File) addDrawingVML(commentID int, drawingVML, cell string, lineCount, colCount int) {
col := string(strings.Map(letterOnlyMapF, cell))
row, _ := strconv.Atoi(strings.Map(intOnlyMapF, cell))
xAxis := row - 1
@@ -79,7 +132,7 @@ func (f *File) addDrawingVML(commentID int, drawingVML, cell string) {
},
VPath: &vPath{
Gradientshapeok: "t",
- Connecttype: "rect",
+ Connecttype: "miter",
},
},
}
@@ -109,10 +162,12 @@ func (f *File) addDrawingVML(commentID int, drawingVML, cell string) {
},
ClientData: &xClientData{
ObjectType: "Note",
- Anchor: "3, 15, 8, 6, 4, 54, 13, 2",
- AutoFill: "False",
- Row: xAxis,
- Column: yAxis,
+ Anchor: fmt.Sprintf(
+ "%d, 23, %d, 0, %d, %d, %d, 5",
+ 1+yAxis, 1+xAxis, 2+yAxis+lineCount, colCount+yAxis, 2+xAxis+lineCount),
+ AutoFill: "True",
+ Row: xAxis,
+ Column: yAxis,
},
}
s, _ := xml.Marshal(sp)
@@ -127,7 +182,7 @@ func (f *File) addDrawingVML(commentID int, drawingVML, cell string) {
c, ok := f.XLSX[drawingVML]
if ok {
d := decodeVmlDrawing{}
- xml.Unmarshal([]byte(c), &d)
+ _ = xml.Unmarshal([]byte(c), &d)
for _, v := range d.Shape {
s := xlsxShape{
ID: "_x0000_s1025",
@@ -145,8 +200,8 @@ func (f *File) addDrawingVML(commentID int, drawingVML, cell string) {
f.XLSX[drawingVML] = v
}
-// addComment provides function to create chart as xl/comments%d.xml by given
-// cell and format sets.
+// addComment provides a function to create chart as xl/comments%d.xml by
+// given cell and format sets.
func (f *File) addComment(commentsXML, cell string, formatSet *formatComment) {
a := formatSet.Author
t := formatSet.Text
@@ -197,7 +252,7 @@ func (f *File) addComment(commentsXML, cell string, formatSet *formatComment) {
c, ok := f.XLSX[commentsXML]
if ok {
d := xlsxComments{}
- xml.Unmarshal([]byte(c), &d)
+ _ = xml.Unmarshal([]byte(c), &d)
comments.CommentList.Comment = append(comments.CommentList.Comment, d.CommentList.Comment...)
}
comments.CommentList.Comment = append(comments.CommentList.Comment, cmt)
@@ -205,8 +260,8 @@ func (f *File) addComment(commentsXML, cell string, formatSet *formatComment) {
f.saveFileList(commentsXML, v)
}
-// countComments provides function to get comments files count storage in the
-// folder xl.
+// countComments provides a function to get comments files count storage in
+// the folder xl.
func (f *File) countComments() int {
count := 0
for k := range f.XLSX {
diff --git a/vendor/github.com/360EntSecGroup-Skylar/excelize/datavalidation.go b/vendor/github.com/360EntSecGroup-Skylar/excelize/datavalidation.go
new file mode 100644
index 0000000000..5ebd61f97c
--- /dev/null
+++ b/vendor/github.com/360EntSecGroup-Skylar/excelize/datavalidation.go
@@ -0,0 +1,233 @@
+// Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of
+// this source code is governed by a BSD-style license that can be found in
+// the LICENSE file.
+//
+// Package excelize providing a set of functions that allow you to write to
+// and read from XLSX files. Support reads and writes XLSX file generated by
+// Microsoft Excel™ 2007 and later. Support save file without losing original
+// charts of XLSX. This library needs Go version 1.8 or later.
+
+package excelize
+
+import (
+ "fmt"
+ "strings"
+)
+
+// DataValidationType defined the type of data validation.
+type DataValidationType int
+
+// Data validation types.
+const (
+ _DataValidationType = iota
+ typeNone // inline use
+ DataValidationTypeCustom
+ DataValidationTypeDate
+ DataValidationTypeDecimal
+ typeList // inline use
+ DataValidationTypeTextLeng
+ DataValidationTypeTime
+ // DataValidationTypeWhole Integer
+ DataValidationTypeWhole
+)
+
+const (
+ // dataValidationFormulaStrLen 255 characters+ 2 quotes
+ dataValidationFormulaStrLen = 257
+ // dataValidationFormulaStrLenErr
+ dataValidationFormulaStrLenErr = "data validation must be 0-255 characters"
+)
+
+// DataValidationErrorStyle defined the style of data validation error alert.
+type DataValidationErrorStyle int
+
+// Data validation error styles.
+const (
+ _ DataValidationErrorStyle = iota
+ DataValidationErrorStyleStop
+ DataValidationErrorStyleWarning
+ DataValidationErrorStyleInformation
+)
+
+// Data validation error styles.
+const (
+ styleStop = "stop"
+ styleWarning = "warning"
+ styleInformation = "information"
+)
+
+// DataValidationOperator operator enum.
+type DataValidationOperator int
+
+// Data validation operators.
+const (
+ _DataValidationOperator = iota
+ DataValidationOperatorBetween
+ DataValidationOperatorEqual
+ DataValidationOperatorGreaterThan
+ DataValidationOperatorGreaterThanOrEqual
+ DataValidationOperatorLessThan
+ DataValidationOperatorLessThanOrEqual
+ DataValidationOperatorNotBetween
+ DataValidationOperatorNotEqual
+)
+
+// NewDataValidation return data validation struct.
+func NewDataValidation(allowBlank bool) *DataValidation {
+ return &DataValidation{
+ AllowBlank: allowBlank,
+ ShowErrorMessage: false,
+ ShowInputMessage: false,
+ }
+}
+
+// SetError set error notice.
+func (dd *DataValidation) SetError(style DataValidationErrorStyle, title, msg string) {
+ dd.Error = &msg
+ dd.ErrorTitle = &title
+ strStyle := styleStop
+ switch style {
+ case DataValidationErrorStyleStop:
+ strStyle = styleStop
+ case DataValidationErrorStyleWarning:
+ strStyle = styleWarning
+ case DataValidationErrorStyleInformation:
+ strStyle = styleInformation
+
+ }
+ dd.ShowErrorMessage = true
+ dd.ErrorStyle = &strStyle
+}
+
+// SetInput set prompt notice.
+func (dd *DataValidation) SetInput(title, msg string) {
+ dd.ShowInputMessage = true
+ dd.PromptTitle = &title
+ dd.Prompt = &msg
+}
+
+// SetDropList data validation list.
+func (dd *DataValidation) SetDropList(keys []string) error {
+ dd.Formula1 = "\"" + strings.Join(keys, ",") + "\""
+ dd.Type = convDataValidationType(typeList)
+ return nil
+}
+
+// SetRange provides function to set data validation range in drop list.
+func (dd *DataValidation) SetRange(f1, f2 int, t DataValidationType, o DataValidationOperator) error {
+ formula1 := fmt.Sprintf("%d", f1)
+ formula2 := fmt.Sprintf("%d", f2)
+ if dataValidationFormulaStrLen < len(dd.Formula1) || dataValidationFormulaStrLen < len(dd.Formula2) {
+ return fmt.Errorf(dataValidationFormulaStrLenErr)
+ }
+
+ dd.Formula1 = formula1
+ dd.Formula2 = formula2
+ dd.Type = convDataValidationType(t)
+ dd.Operator = convDataValidationOperatior(o)
+ return nil
+}
+
+// SetSqrefDropList provides set data validation on a range with source
+// reference range of the worksheet by given data validation object and
+// worksheet name. The data validation object can be created by
+// NewDataValidation function. For example, set data validation on
+// Sheet1!A7:B8 with validation criteria source Sheet1!E1:E3 settings, create
+// in-cell dropdown by allowing list source:
+//
+// dvRange := excelize.NewDataValidation(true)
+// dvRange.Sqref = "A7:B8"
+// dvRange.SetSqrefDropList("E1:E3", true)
+// xlsx.AddDataValidation("Sheet1", dvRange)
+//
+func (dd *DataValidation) SetSqrefDropList(sqref string, isCurrentSheet bool) error {
+ if isCurrentSheet {
+ dd.Formula1 = sqref
+ dd.Type = convDataValidationType(typeList)
+ return nil
+ }
+ return fmt.Errorf("cross-sheet sqref cell are not supported")
+}
+
+// SetSqref provides function to set data validation range in drop list.
+func (dd *DataValidation) SetSqref(sqref string) {
+ if dd.Sqref == "" {
+ dd.Sqref = sqref
+ } else {
+ dd.Sqref = fmt.Sprintf("%s %s", dd.Sqref, sqref)
+ }
+}
+
+// convDataValidationType get excel data validation type.
+func convDataValidationType(t DataValidationType) string {
+ typeMap := map[DataValidationType]string{
+ typeNone: "none",
+ DataValidationTypeCustom: "custom",
+ DataValidationTypeDate: "date",
+ DataValidationTypeDecimal: "decimal",
+ typeList: "list",
+ DataValidationTypeTextLeng: "textLength",
+ DataValidationTypeTime: "time",
+ DataValidationTypeWhole: "whole",
+ }
+
+ return typeMap[t]
+
+}
+
+// convDataValidationOperatior get excel data validation operator.
+func convDataValidationOperatior(o DataValidationOperator) string {
+ typeMap := map[DataValidationOperator]string{
+ DataValidationOperatorBetween: "between",
+ DataValidationOperatorEqual: "equal",
+ DataValidationOperatorGreaterThan: "greaterThan",
+ DataValidationOperatorGreaterThanOrEqual: "greaterThanOrEqual",
+ DataValidationOperatorLessThan: "lessThan",
+ DataValidationOperatorLessThanOrEqual: "lessThanOrEqual",
+ DataValidationOperatorNotBetween: "notBetween",
+ DataValidationOperatorNotEqual: "notEqual",
+ }
+
+ return typeMap[o]
+
+}
+
+// AddDataValidation provides set data validation on a range of the worksheet
+// by given data validation object and worksheet name. The data validation
+// object can be created by NewDataValidation function.
+//
+// Example 1, set data validation on Sheet1!A1:B2 with validation criteria
+// settings, show error alert after invalid data is entered with "Stop" style
+// and custom title "error body":
+//
+// dvRange := excelize.NewDataValidation(true)
+// dvRange.Sqref = "A1:B2"
+// dvRange.SetRange(10, 20, excelize.DataValidationTypeWhole, excelize.DataValidationOperatorBetween)
+// dvRange.SetError(excelize.DataValidationErrorStyleStop, "error title", "error body")
+// xlsx.AddDataValidation("Sheet1", dvRange)
+//
+// Example 2, set data validation on Sheet1!A3:B4 with validation criteria
+// settings, and show input message when cell is selected:
+//
+// dvRange = excelize.NewDataValidation(true)
+// dvRange.Sqref = "A3:B4"
+// dvRange.SetRange(10, 20, excelize.DataValidationTypeWhole, excelize.DataValidationOperatorGreaterThan)
+// dvRange.SetInput("input title", "input body")
+// xlsx.AddDataValidation("Sheet1", dvRange)
+//
+// Example 3, set data validation on Sheet1!A5:B6 with validation criteria
+// settings, create in-cell dropdown by allowing list source:
+//
+// dvRange = excelize.NewDataValidation(true)
+// dvRange.Sqref = "A5:B6"
+// dvRange.SetDropList([]string{"1", "2", "3"})
+// xlsx.AddDataValidation("Sheet1", dvRange)
+//
+func (f *File) AddDataValidation(sheet string, dv *DataValidation) {
+ xlsx := f.workSheetReader(sheet)
+ if nil == xlsx.DataValidations {
+ xlsx.DataValidations = new(xlsxDataValidations)
+ }
+ xlsx.DataValidations.DataValidation = append(xlsx.DataValidations.DataValidation, dv)
+ xlsx.DataValidations.Count = len(xlsx.DataValidations.DataValidation)
+}
diff --git a/vendor/github.com/360EntSecGroup-Skylar/excelize/date.go b/vendor/github.com/360EntSecGroup-Skylar/excelize/date.go
index a49386601c..45f3040cf5 100644
--- a/vendor/github.com/360EntSecGroup-Skylar/excelize/date.go
+++ b/vendor/github.com/360EntSecGroup-Skylar/excelize/date.go
@@ -1,3 +1,12 @@
+// Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of
+// this source code is governed by a BSD-style license that can be found in
+// the LICENSE file.
+//
+// Package excelize providing a set of functions that allow you to write to
+// and read from XLSX files. Support reads and writes XLSX file generated by
+// Microsoft Excel™ 2007 and later. Support save file without losing original
+// charts of XLSX. This library needs Go version 1.8 or later.
+
package excelize
import (
@@ -8,17 +17,31 @@ import (
// timeLocationUTC defined the UTC time location.
var timeLocationUTC, _ = time.LoadLocation("UTC")
-// timeToUTCTime provides function to convert time to UTC time.
+// timeToUTCTime provides a function to convert time to UTC time.
func timeToUTCTime(t time.Time) time.Time {
return time.Date(t.Year(), t.Month(), t.Day(), t.Hour(), t.Minute(), t.Second(), t.Nanosecond(), timeLocationUTC)
}
-// timeToExcelTime provides function to convert time to Excel time.
+// timeToExcelTime provides a function to convert time to Excel time.
func timeToExcelTime(t time.Time) float64 {
- return float64(t.UnixNano())/8.64e13 + 25569.0
+ // TODO in future this should probably also handle date1904 and like TimeFromExcelTime
+ var excelTime float64
+ var deltaDays int64
+ excelTime = 0
+ deltaDays = 290 * 364
+ // check if UnixNano would be out of int64 range
+ for t.Unix() > deltaDays*24*60*60 {
+ // reduce by aprox. 290 years, which is max for int64 nanoseconds
+ delta := time.Duration(deltaDays) * 24 * time.Hour
+ excelTime = excelTime + float64(deltaDays)
+ t = t.Add(-delta)
+ }
+ // finally add remainder of UnixNano to keep nano precision
+ // and 25569 which is days between 1900 and 1970
+ return excelTime + float64(t.UnixNano())/8.64e13 + 25569.0
}
-// shiftJulianToNoon provides function to process julian date to noon.
+// shiftJulianToNoon provides a function to process julian date to noon.
func shiftJulianToNoon(julianDays, julianFraction float64) (float64, float64) {
switch {
case -0.5 < julianFraction && julianFraction < 0.5:
@@ -33,7 +56,7 @@ func shiftJulianToNoon(julianDays, julianFraction float64) (float64, float64) {
return julianDays, julianFraction
}
-// fractionOfADay provides function to return the integer values for hour,
+// fractionOfADay provides a function to return the integer values for hour,
// minutes, seconds and nanoseconds that comprised a given fraction of a day.
// values would round to 1 us.
func fractionOfADay(fraction float64) (hours, minutes, seconds, nanoseconds int) {
@@ -54,7 +77,7 @@ func fractionOfADay(fraction float64) (hours, minutes, seconds, nanoseconds int)
return
}
-// julianDateToGregorianTime provides function to convert julian date to
+// julianDateToGregorianTime provides a function to convert julian date to
// gregorian time.
func julianDateToGregorianTime(part1, part2 float64) time.Time {
part1I, part1F := math.Modf(part1)
@@ -67,12 +90,12 @@ func julianDateToGregorianTime(part1, part2 float64) time.Time {
return time.Date(year, time.Month(month), day, hours, minutes, seconds, nanoseconds, time.UTC)
}
-// By this point generations of programmers have repeated the algorithm sent to
-// the editor of "Communications of the ACM" in 1968 (published in CACM, volume
-// 11, number 10, October 1968, p.657). None of those programmers seems to have
-// found it necessary to explain the constants or variable names set out by
-// Henry F. Fliegel and Thomas C. Van Flandern. Maybe one day I'll buy that
-// jounal and expand an explanation here - that day is not today.
+// By this point generations of programmers have repeated the algorithm sent
+// to the editor of "Communications of the ACM" in 1968 (published in CACM,
+// volume 11, number 10, October 1968, p.657). None of those programmers seems
+// to have found it necessary to explain the constants or variable names set
+// out by Henry F. Fliegel and Thomas C. Van Flandern. Maybe one day I'll buy
+// that jounal and expand an explanation here - that day is not today.
func doTheFliegelAndVanFlandernAlgorithm(jd int) (day, month, year int) {
l := jd + 68569
n := (4 * l) / 146097
@@ -87,9 +110,10 @@ func doTheFliegelAndVanFlandernAlgorithm(jd int) (day, month, year int) {
return d, m, y
}
-// timeFromExcelTime provides function to convert an excelTime representation
-// (stored as a floating point number) to a time.Time.
+// timeFromExcelTime provides a function to convert an excelTime
+// representation (stored as a floating point number) to a time.Time.
func timeFromExcelTime(excelTime float64, date1904 bool) time.Time {
+ const MDD int64 = 106750 // Max time.Duration Days, aprox. 290 years
var date time.Time
var intPart = int64(excelTime)
// Excel uses Julian dates prior to March 1st 1900, and Gregorian
@@ -113,6 +137,13 @@ func timeFromExcelTime(excelTime float64, date1904 bool) time.Time {
} else {
date = time.Date(1899, 12, 30, 0, 0, 0, 0, time.UTC)
}
+
+ // Duration is limited to aprox. 290 years
+ for intPart > MDD {
+ durationDays := time.Duration(MDD) * time.Hour * 24
+ date = date.Add(durationDays)
+ intPart = intPart - MDD
+ }
durationDays := time.Duration(intPart) * time.Hour * 24
durationPart := time.Duration(dayNanoSeconds * floatPart)
return date.Add(durationDays).Add(durationPart)
diff --git a/vendor/github.com/360EntSecGroup-Skylar/excelize/excelize.go b/vendor/github.com/360EntSecGroup-Skylar/excelize/excelize.go
index f2e50c8d7c..d1f0b7f1c1 100644
--- a/vendor/github.com/360EntSecGroup-Skylar/excelize/excelize.go
+++ b/vendor/github.com/360EntSecGroup-Skylar/excelize/excelize.go
@@ -1,3 +1,13 @@
+// Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of
+// this source code is governed by a BSD-style license that can be found in
+// the LICENSE file.
+//
+// Package excelize providing a set of functions that allow you to write to
+// and read from XLSX files. Support reads and writes XLSX file generated by
+// Microsoft Excel™ 2007 and later. Support save file without losing original
+// charts of XLSX. This library needs Go version 1.8 or later.
+//
+// See https://xuri.me/excelize for more information about this package.
package excelize
import (
@@ -21,6 +31,7 @@ type File struct {
Sheet map[string]*xlsxWorksheet
SheetCount int
Styles *xlsxStyleSheet
+ Theme *xlsxTheme
WorkBook *xlsxWorkbook
WorkBookRels *xlsxWorkbookRels
XLSX map[string][]byte
@@ -66,10 +77,11 @@ func OpenReader(r io.Reader) (*File, error) {
}
f.sheetMap = f.getSheetMap()
f.Styles = f.stylesReader()
+ f.Theme = f.themeReader()
return f, nil
}
-// setDefaultTimeStyle provides function to set default numbers format for
+// setDefaultTimeStyle provides a function to set default numbers format for
// time.Time type cell value by given worksheet name, cell coordinates and
// number format code.
func (f *File) setDefaultTimeStyle(sheet, axis string, format int) {
@@ -79,8 +91,8 @@ func (f *File) setDefaultTimeStyle(sheet, axis string, format int) {
}
}
-// workSheetReader provides function to get the pointer to the structure after
-// deserialization by given worksheet name.
+// workSheetReader provides a function to get the pointer to the structure
+// after deserialization by given worksheet name.
func (f *File) workSheetReader(sheet string) *xlsxWorksheet {
name, ok := f.sheetMap[trimSheetName(sheet)]
if !ok {
@@ -88,7 +100,7 @@ func (f *File) workSheetReader(sheet string) *xlsxWorksheet {
}
if f.Sheet[name] == nil {
var xlsx xlsxWorksheet
- xml.Unmarshal(f.readXML(name), &xlsx)
+ _ = xml.Unmarshal(f.readXML(name), &xlsx)
if f.checked == nil {
f.checked = make(map[string]bool)
}
@@ -103,7 +115,7 @@ func (f *File) workSheetReader(sheet string) *xlsxWorksheet {
return f.Sheet[name]
}
-// checkSheet provides function to fill each row element and make that is
+// checkSheet provides a function to fill each row element and make that is
// continuous in a worksheet of XML.
func checkSheet(xlsx *xlsxWorksheet) {
row := len(xlsx.SheetData.Row)
@@ -131,7 +143,7 @@ func checkSheet(xlsx *xlsxWorksheet) {
xlsx.SheetData = sheetData
}
-// replaceWorkSheetsRelationshipsNameSpaceBytes provides function to replace
+// replaceWorkSheetsRelationshipsNameSpaceBytes provides a function to replace
// xl/worksheets/sheet%d.xml XML tags to self-closing for compatible Microsoft
// Office Excel 2007.
func replaceWorkSheetsRelationshipsNameSpaceBytes(workbookMarshal []byte) []byte {
@@ -180,7 +192,7 @@ func (f *File) UpdateLinkedValue() {
}
}
-// adjustHelper provides function to adjust rows and columns dimensions,
+// adjustHelper provides a function to adjust rows and columns dimensions,
// hyperlinks, merged cells and auto filter when inserting or deleting rows or
// columns.
//
@@ -202,7 +214,7 @@ func (f *File) adjustHelper(sheet string, column, row, offset int) {
checkRow(xlsx)
}
-// adjustColDimensions provides function to update column dimensions when
+// adjustColDimensions provides a function to update column dimensions when
// inserting or deleting rows or columns.
func (f *File) adjustColDimensions(xlsx *xlsxWorksheet, column, offset int) {
for i, r := range xlsx.SheetData.Row {
@@ -218,8 +230,8 @@ func (f *File) adjustColDimensions(xlsx *xlsxWorksheet, column, offset int) {
}
}
-// adjustRowDimensions provides function to update row dimensions when inserting
-// or deleting rows or columns.
+// adjustRowDimensions provides a function to update row dimensions when
+// inserting or deleting rows or columns.
func (f *File) adjustRowDimensions(xlsx *xlsxWorksheet, rowIndex, offset int) {
if rowIndex == -1 {
return
@@ -238,7 +250,7 @@ func (f *File) adjustRowDimensions(xlsx *xlsxWorksheet, rowIndex, offset int) {
}
}
-// adjustHyperlinks provides function to update hyperlinks when inserting or
+// adjustHyperlinks provides a function to update hyperlinks when inserting or
// deleting rows or columns.
func (f *File) adjustHyperlinks(sheet string, column, rowIndex, offset int) {
xlsx := f.workSheetReader(sheet)
@@ -278,8 +290,8 @@ func (f *File) adjustHyperlinks(sheet string, column, rowIndex, offset int) {
}
}
-// adjustMergeCellsHelper provides function to update merged cells when inserting or
-// deleting rows or columns.
+// adjustMergeCellsHelper provides a function to update merged cells when
+// inserting or deleting rows or columns.
func (f *File) adjustMergeCellsHelper(xlsx *xlsxWorksheet, column, rowIndex, offset int) {
if xlsx.MergeCells != nil {
for k, v := range xlsx.MergeCells.Cells {
@@ -319,8 +331,8 @@ func (f *File) adjustMergeCellsHelper(xlsx *xlsxWorksheet, column, rowIndex, off
}
}
-// adjustMergeCells provides function to update merged cells when inserting or
-// deleting rows or columns.
+// adjustMergeCells provides a function to update merged cells when inserting
+// or deleting rows or columns.
func (f *File) adjustMergeCells(xlsx *xlsxWorksheet, column, rowIndex, offset int) {
f.adjustMergeCellsHelper(xlsx, column, rowIndex, offset)
@@ -340,8 +352,8 @@ func (f *File) adjustMergeCells(xlsx *xlsxWorksheet, column, rowIndex, offset in
}
}
-// adjustAutoFilter provides function to update the auto filter when inserting
-// or deleting rows or columns.
+// adjustAutoFilter provides a function to update the auto filter when
+// inserting or deleting rows or columns.
func (f *File) adjustAutoFilter(xlsx *xlsxWorksheet, column, rowIndex, offset int) {
f.adjustAutoFilterHelper(xlsx, column, rowIndex, offset)
@@ -374,7 +386,7 @@ func (f *File) adjustAutoFilter(xlsx *xlsxWorksheet, column, rowIndex, offset in
}
}
-// adjustAutoFilterHelper provides function to update the auto filter when
+// adjustAutoFilterHelper provides a function to update the auto filter when
// inserting or deleting rows or columns.
func (f *File) adjustAutoFilterHelper(xlsx *xlsxWorksheet, column, rowIndex, offset int) {
if xlsx.AutoFilter != nil {
diff --git a/vendor/github.com/360EntSecGroup-Skylar/excelize/excelize.png b/vendor/github.com/360EntSecGroup-Skylar/excelize/excelize.png
index b4b452944c..9f220b514f 100644
Binary files a/vendor/github.com/360EntSecGroup-Skylar/excelize/excelize.png and b/vendor/github.com/360EntSecGroup-Skylar/excelize/excelize.png differ
diff --git a/vendor/github.com/360EntSecGroup-Skylar/excelize/file.go b/vendor/github.com/360EntSecGroup-Skylar/excelize/file.go
index 36af6f8811..5bfed392f6 100644
--- a/vendor/github.com/360EntSecGroup-Skylar/excelize/file.go
+++ b/vendor/github.com/360EntSecGroup-Skylar/excelize/file.go
@@ -1,3 +1,12 @@
+// Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of
+// this source code is governed by a BSD-style license that can be found in
+// the LICENSE file.
+//
+// Package excelize providing a set of functions that allow you to write to
+// and read from XLSX files. Support reads and writes XLSX file generated by
+// Microsoft Excel™ 2007 and later. Support save file without losing original
+// charts of XLSX. This library needs Go version 1.8 or later.
+
package excelize
import (
@@ -8,7 +17,7 @@ import (
"os"
)
-// NewFile provides function to create new file by default template. For
+// NewFile provides a function to create new file by default template. For
// example:
//
// xlsx := NewFile()
@@ -36,19 +45,20 @@ func NewFile() *File {
f.WorkBookRels = f.workbookRelsReader()
f.Sheet["xl/worksheets/sheet1.xml"] = f.workSheetReader("Sheet1")
f.sheetMap["Sheet1"] = "xl/worksheets/sheet1.xml"
+ f.Theme = f.themeReader()
return f
}
-// Save provides function to override the xlsx file with origin path.
+// Save provides a function to override the xlsx file with origin path.
func (f *File) Save() error {
if f.Path == "" {
- return fmt.Errorf("No path defined for file, consider File.WriteTo or File.Write")
+ return fmt.Errorf("no path defined for file, consider File.WriteTo or File.Write")
}
return f.SaveAs(f.Path)
}
-// SaveAs provides function to create or update to an xlsx file at the provided
-// path.
+// SaveAs provides a function to create or update to an xlsx file at the
+// provided path.
func (f *File) SaveAs(name string) error {
file, err := os.OpenFile(name, os.O_WRONLY|os.O_TRUNC|os.O_CREATE, 0666)
if err != nil {
@@ -58,8 +68,14 @@ func (f *File) SaveAs(name string) error {
return f.Write(file)
}
-// Write provides function to write to an io.Writer.
+// Write provides a function to write to an io.Writer.
func (f *File) Write(w io.Writer) error {
+ _, err := f.WriteTo(w)
+ return err
+}
+
+// WriteTo implements io.WriterTo to write the file.
+func (f *File) WriteTo(w io.Writer) (int64, error) {
buf := new(bytes.Buffer)
zw := zip.NewWriter(buf)
f.contentTypesWriter()
@@ -70,21 +86,17 @@ func (f *File) Write(w io.Writer) error {
for path, content := range f.XLSX {
fi, err := zw.Create(path)
if err != nil {
- return err
+ return 0, err
}
- _, err = fi.Write([]byte(content))
+ _, err = fi.Write(content)
if err != nil {
- return err
+ return 0, err
}
}
err := zw.Close()
if err != nil {
- return err
+ return 0, err
}
- if _, err := buf.WriteTo(w); err != nil {
- return err
- }
-
- return nil
+ return buf.WriteTo(w)
}
diff --git a/vendor/github.com/360EntSecGroup-Skylar/excelize/hsl.go b/vendor/github.com/360EntSecGroup-Skylar/excelize/hsl.go
new file mode 100644
index 0000000000..c30c165a5b
--- /dev/null
+++ b/vendor/github.com/360EntSecGroup-Skylar/excelize/hsl.go
@@ -0,0 +1,139 @@
+// Copyright (c) 2012 Rodrigo Moraes. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package excelize
+
+import (
+ "image/color"
+ "math"
+)
+
+// HSLModel converts any color.Color to a HSL color.
+var HSLModel = color.ModelFunc(hslModel)
+
+// HSL represents a cylindrical coordinate of points in an RGB color model.
+//
+// Values are in the range 0 to 1.
+type HSL struct {
+ H, S, L float64
+}
+
+// RGBA returns the alpha-premultiplied red, green, blue and alpha values
+// for the HSL.
+func (c HSL) RGBA() (uint32, uint32, uint32, uint32) {
+ r, g, b := HSLToRGB(c.H, c.S, c.L)
+ return uint32(r) * 0x101, uint32(g) * 0x101, uint32(b) * 0x101, 0xffff
+}
+
+// hslModel converts a color.Color to HSL.
+func hslModel(c color.Color) color.Color {
+ if _, ok := c.(HSL); ok {
+ return c
+ }
+ r, g, b, _ := c.RGBA()
+ h, s, l := RGBToHSL(uint8(r>>8), uint8(g>>8), uint8(b>>8))
+ return HSL{h, s, l}
+}
+
+// RGBToHSL converts an RGB triple to a HSL triple.
+func RGBToHSL(r, g, b uint8) (h, s, l float64) {
+ fR := float64(r) / 255
+ fG := float64(g) / 255
+ fB := float64(b) / 255
+ max := math.Max(math.Max(fR, fG), fB)
+ min := math.Min(math.Min(fR, fG), fB)
+ l = (max + min) / 2
+ if max == min {
+ // Achromatic.
+ h, s = 0, 0
+ } else {
+ // Chromatic.
+ d := max - min
+ if l > 0.5 {
+ s = d / (2.0 - max - min)
+ } else {
+ s = d / (max + min)
+ }
+ switch max {
+ case fR:
+ h = (fG - fB) / d
+ if fG < fB {
+ h += 6
+ }
+ case fG:
+ h = (fB-fR)/d + 2
+ case fB:
+ h = (fR-fG)/d + 4
+ }
+ h /= 6
+ }
+ return
+}
+
+// HSLToRGB converts an HSL triple to a RGB triple.
+func HSLToRGB(h, s, l float64) (r, g, b uint8) {
+ var fR, fG, fB float64
+ if s == 0 {
+ fR, fG, fB = l, l, l
+ } else {
+ var q float64
+ if l < 0.5 {
+ q = l * (1 + s)
+ } else {
+ q = l + s - s*l
+ }
+ p := 2*l - q
+ fR = hueToRGB(p, q, h+1.0/3)
+ fG = hueToRGB(p, q, h)
+ fB = hueToRGB(p, q, h-1.0/3)
+ }
+ r = uint8((fR * 255) + 0.5)
+ g = uint8((fG * 255) + 0.5)
+ b = uint8((fB * 255) + 0.5)
+ return
+}
+
+// hueToRGB is a helper function for HSLToRGB.
+func hueToRGB(p, q, t float64) float64 {
+ if t < 0 {
+ t++
+ }
+ if t > 1 {
+ t--
+ }
+ if t < 1.0/6 {
+ return p + (q-p)*6*t
+ }
+ if t < 0.5 {
+ return q
+ }
+ if t < 2.0/3 {
+ return p + (q-p)*(2.0/3-t)*6
+ }
+ return p
+}
diff --git a/vendor/github.com/360EntSecGroup-Skylar/excelize/lib.go b/vendor/github.com/360EntSecGroup-Skylar/excelize/lib.go
index a1687810ba..865ee29657 100644
--- a/vendor/github.com/360EntSecGroup-Skylar/excelize/lib.go
+++ b/vendor/github.com/360EntSecGroup-Skylar/excelize/lib.go
@@ -1,9 +1,17 @@
+// Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of
+// this source code is governed by a BSD-style license that can be found in
+// the LICENSE file.
+//
+// Package excelize providing a set of functions that allow you to write to
+// and read from XLSX files. Support reads and writes XLSX file generated by
+// Microsoft Excel™ 2007 and later. Support save file without losing original
+// charts of XLSX. This library needs Go version 1.8 or later.
+
package excelize
import (
"archive/zip"
"bytes"
- "encoding/gob"
"io"
"log"
"math"
@@ -26,7 +34,7 @@ func ReadZipReader(r *zip.Reader) (map[string][]byte, int, error) {
return fileList, worksheets, nil
}
-// readXML provides function to read XML content as string.
+// readXML provides a function to read XML content as string.
func (f *File) readXML(name string) []byte {
if content, ok := f.XLSX[name]; ok {
return content
@@ -34,8 +42,8 @@ func (f *File) readXML(name string) []byte {
return []byte{}
}
-// saveFileList provides function to update given file content in file list of
-// XLSX.
+// saveFileList provides a function to update given file content in file list
+// of XLSX.
func (f *File) saveFileList(name string, content []byte) {
newContent := make([]byte, 0, len(XMLHeader)+len(content))
newContent = append(newContent, []byte(XMLHeader)...)
@@ -50,12 +58,12 @@ func readFile(file *zip.File) []byte {
log.Fatal(err)
}
buff := bytes.NewBuffer(nil)
- io.Copy(buff, rc)
+ _, _ = io.Copy(buff, rc)
rc.Close()
return buff.Bytes()
}
-// ToAlphaString provides function to convert integer to Excel sheet column
+// ToAlphaString provides a function to convert integer to Excel sheet column
// title. For example convert 36 to column title AK:
//
// excelize.ToAlphaString(36)
@@ -73,9 +81,9 @@ func ToAlphaString(value int) string {
return ans
}
-// TitleToNumber provides function to convert Excel sheet column title to int
-// (this function doesn't do value check currently). For example convert AK
-// and ak to column title 36:
+// TitleToNumber provides a function to convert Excel sheet column title to
+// int (this function doesn't do value check currently). For example convert
+// AK and ak to column title 36:
//
// excelize.TitleToNumber("AK")
// excelize.TitleToNumber("ak")
@@ -115,17 +123,6 @@ func intOnlyMapF(rune rune) rune {
return -1
}
-// deepCopy provides method to creates a deep copy of whatever is passed to it
-// and returns the copy in an interface. The returned value will need to be
-// asserted to the correct type.
-func deepCopy(dst, src interface{}) error {
- var buf bytes.Buffer
- if err := gob.NewEncoder(&buf).Encode(src); err != nil {
- return err
- }
- return gob.NewDecoder(bytes.NewBuffer(buf.Bytes())).Decode(dst)
-}
-
// boolPtr returns a pointer to a bool with the given value.
func boolPtr(b bool) *bool { return &b }
@@ -137,8 +134,8 @@ func defaultTrue(b *bool) bool {
return *b
}
-// axisLowerOrEqualThan returns true if axis1 <= axis2
-// axis1/axis2 can be either a column or a row axis, e.g. "A", "AAE", "42", "1", etc.
+// axisLowerOrEqualThan returns true if axis1 <= axis2 axis1/axis2 can be
+// either a column or a row axis, e.g. "A", "AAE", "42", "1", etc.
//
// For instance, the following comparisons are all true:
//
@@ -159,7 +156,8 @@ func axisLowerOrEqualThan(axis1, axis2 string) bool {
}
}
-// getCellColRow returns the two parts of a cell identifier (its col and row) as strings
+// getCellColRow returns the two parts of a cell identifier (its col and row)
+// as strings
//
// For instance:
//
@@ -176,3 +174,12 @@ func getCellColRow(cell string) (col, row string) {
return cell, ""
}
+
+// parseFormatSet provides a method to convert format string to []byte and
+// handle empty string.
+func parseFormatSet(formatSet string) []byte {
+ if formatSet != "" {
+ return []byte(formatSet)
+ }
+ return []byte("{}")
+}
diff --git a/vendor/github.com/360EntSecGroup-Skylar/excelize/picture.go b/vendor/github.com/360EntSecGroup-Skylar/excelize/picture.go
index 6c84cddb3b..8785aaf53f 100644
--- a/vendor/github.com/360EntSecGroup-Skylar/excelize/picture.go
+++ b/vendor/github.com/360EntSecGroup-Skylar/excelize/picture.go
@@ -1,3 +1,12 @@
+// Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of
+// this source code is governed by a BSD-style license that can be found in
+// the LICENSE file.
+//
+// Package excelize providing a set of functions that allow you to write to
+// and read from XLSX files. Support reads and writes XLSX file generated by
+// Microsoft Excel™ 2007 and later. Support save file without losing original
+// charts of XLSX. This library needs Go version 1.8 or later.
+
package excelize
import (
@@ -14,9 +23,9 @@ import (
"strings"
)
-// parseFormatPictureSet provides function to parse the format settings of the
-// picture with default value.
-func parseFormatPictureSet(formatSet string) *formatPicture {
+// parseFormatPictureSet provides a function to parse the format settings of
+// the picture with default value.
+func parseFormatPictureSet(formatSet string) (*formatPicture, error) {
format := formatPicture{
FPrintsWithSheet: true,
FLocksWithSheet: false,
@@ -26,8 +35,8 @@ func parseFormatPictureSet(formatSet string) *formatPicture {
XScale: 1.0,
YScale: 1.0,
}
- json.Unmarshal([]byte(formatSet), &format)
- return &format
+ err := json.Unmarshal(parseFormatSet(formatSet), &format)
+ return &format, err
}
// AddPicture provides the method to add picture in a sheet by given picture
@@ -78,20 +87,66 @@ func parseFormatPictureSet(formatSet string) *formatPicture {
// positioning is move and size with cells.
func (f *File) AddPicture(sheet, cell, picture, format string) error {
var err error
- var drawingHyperlinkRID int
- var hyperlinkType string
// Check picture exists first.
if _, err = os.Stat(picture); os.IsNotExist(err) {
return err
}
ext, ok := supportImageTypes[path.Ext(picture)]
if !ok {
- return errors.New("Unsupported image extension")
+ return errors.New("unsupported image extension")
+ }
+ file, _ := ioutil.ReadFile(picture)
+ _, name := filepath.Split(picture)
+ return f.AddPictureFromBytes(sheet, cell, format, name, ext, file)
+}
+
+// AddPictureFromBytes provides the method to add picture in a sheet by given
+// picture format set (such as offset, scale, aspect ratio setting and print
+// settings), file base name, extension name and file bytes. For example:
+//
+// package main
+//
+// import (
+// "fmt"
+// _ "image/jpeg"
+// "io/ioutil"
+//
+// "github.com/360EntSecGroup-Skylar/excelize"
+// )
+//
+// func main() {
+// xlsx := excelize.NewFile()
+//
+// file, err := ioutil.ReadFile("./image1.jpg")
+// if err != nil {
+// fmt.Println(err)
+// }
+// err = xlsx.AddPictureFromBytes("Sheet1", "A2", "", "Excel Logo", ".jpg", file)
+// if err != nil {
+// fmt.Println(err)
+// }
+// err = xlsx.SaveAs("./Book1.xlsx")
+// if err != nil {
+// fmt.Println(err)
+// }
+// }
+//
+func (f *File) AddPictureFromBytes(sheet, cell, format, name, extension string, file []byte) error {
+ var err error
+ var drawingHyperlinkRID int
+ var hyperlinkType string
+ ext, ok := supportImageTypes[extension]
+ if !ok {
+ return errors.New("unsupported image extension")
+ }
+ formatSet, err := parseFormatPictureSet(format)
+ if err != nil {
+ return err
+ }
+ image, _, err := image.DecodeConfig(bytes.NewReader(file))
+ if err != nil {
+ return err
}
- readFile, _ := os.Open(picture)
- image, _, err := image.DecodeConfig(readFile)
- _, file := filepath.Split(picture)
- formatSet := parseFormatPictureSet(format)
// Read sheet data.
xlsx := f.workSheetReader(sheet)
// Add first picture for given sheet, create xl/drawings/ and xl/drawings/_rels/ folder.
@@ -107,13 +162,13 @@ func (f *File) AddPicture(sheet, cell, picture, format string) error {
}
drawingHyperlinkRID = f.addDrawingRelationships(drawingID, SourceRelationshipHyperLink, formatSet.Hyperlink, hyperlinkType)
}
- f.addDrawingPicture(sheet, drawingXML, cell, file, image.Width, image.Height, drawingRID, drawingHyperlinkRID, formatSet)
- f.addMedia(picture, ext)
+ f.addDrawingPicture(sheet, drawingXML, cell, name, image.Width, image.Height, drawingRID, drawingHyperlinkRID, formatSet)
+ f.addMedia(file, ext)
f.addContentTypePart(drawingID, "drawings")
return err
}
-// addSheetRelationships provides function to add
+// addSheetRelationships provides a function to add
// xl/worksheets/_rels/sheet%d.xml.rels by given worksheet name, relationship
// type and target.
func (f *File) addSheetRelationships(sheet, relType, target, targetMode string) int {
@@ -130,7 +185,7 @@ func (f *File) addSheetRelationships(sheet, relType, target, targetMode string)
_, ok = f.XLSX[rels]
if ok {
ID.Reset()
- xml.Unmarshal([]byte(f.readXML(rels)), &sheetRels)
+ _ = xml.Unmarshal([]byte(f.readXML(rels)), &sheetRels)
rID = len(sheetRels.Relationships) + 1
ID.WriteString("rId")
ID.WriteString(strconv.Itoa(rID))
@@ -146,9 +201,9 @@ func (f *File) addSheetRelationships(sheet, relType, target, targetMode string)
return rID
}
-// deleteSheetRelationships provides function to delete relationships in
-// xl/worksheets/_rels/sheet%d.xml.rels by given worksheet name and relationship
-// index.
+// deleteSheetRelationships provides a function to delete relationships in
+// xl/worksheets/_rels/sheet%d.xml.rels by given worksheet name and
+// relationship index.
func (f *File) deleteSheetRelationships(sheet, rID string) {
name, ok := f.sheetMap[trimSheetName(sheet)]
if !ok {
@@ -156,7 +211,7 @@ func (f *File) deleteSheetRelationships(sheet, rID string) {
}
var rels = "xl/worksheets/_rels/" + strings.TrimPrefix(name, "xl/worksheets/") + ".rels"
var sheetRels xlsxWorkbookRels
- xml.Unmarshal([]byte(f.readXML(rels)), &sheetRels)
+ _ = xml.Unmarshal([]byte(f.readXML(rels)), &sheetRels)
for k, v := range sheetRels.Relationships {
if v.ID == rID {
sheetRels.Relationships = append(sheetRels.Relationships[:k], sheetRels.Relationships[k+1:]...)
@@ -166,7 +221,7 @@ func (f *File) deleteSheetRelationships(sheet, rID string) {
f.saveFileList(rels, output)
}
-// addSheetLegacyDrawing provides function to add legacy drawing element to
+// addSheetLegacyDrawing provides a function to add legacy drawing element to
// xl/worksheets/sheet%d.xml by given worksheet name and relationship index.
func (f *File) addSheetLegacyDrawing(sheet string, rID int) {
xlsx := f.workSheetReader(sheet)
@@ -175,7 +230,7 @@ func (f *File) addSheetLegacyDrawing(sheet string, rID int) {
}
}
-// addSheetDrawing provides function to add drawing element to
+// addSheetDrawing provides a function to add drawing element to
// xl/worksheets/sheet%d.xml by given worksheet name and relationship index.
func (f *File) addSheetDrawing(sheet string, rID int) {
xlsx := f.workSheetReader(sheet)
@@ -184,7 +239,7 @@ func (f *File) addSheetDrawing(sheet string, rID int) {
}
}
-// addSheetPicture provides function to add picture element to
+// addSheetPicture provides a function to add picture element to
// xl/worksheets/sheet%d.xml by given worksheet name and relationship index.
func (f *File) addSheetPicture(sheet string, rID int) {
xlsx := f.workSheetReader(sheet)
@@ -193,7 +248,7 @@ func (f *File) addSheetPicture(sheet string, rID int) {
}
}
-// countDrawings provides function to get drawing files count storage in the
+// countDrawings provides a function to get drawing files count storage in the
// folder xl/drawings.
func (f *File) countDrawings() int {
count := 0
@@ -205,7 +260,7 @@ func (f *File) countDrawings() int {
return count
}
-// addDrawingPicture provides function to add picture by given sheet,
+// addDrawingPicture provides a function to add picture by given sheet,
// drawingXML, cell, file name, width, height relationship index and format
// sets.
func (f *File) addDrawingPicture(sheet, drawingXML, cell, file string, width, height, rID, hyperlinkRID int, formatSet *formatPicture) {
@@ -260,8 +315,8 @@ func (f *File) addDrawingPicture(sheet, drawingXML, cell, file string, width, he
f.saveFileList(drawingXML, output)
}
-// addDrawingRelationships provides function to add image part relationships in
-// the file xl/drawings/_rels/drawing%d.xml.rels by given drawing index,
+// addDrawingRelationships provides a function to add image part relationships
+// in the file xl/drawings/_rels/drawing%d.xml.rels by given drawing index,
// relationship type and target.
func (f *File) addDrawingRelationships(index int, relType, target, targetMode string) int {
var rels = "xl/drawings/_rels/drawing" + strconv.Itoa(index) + ".xml.rels"
@@ -273,7 +328,7 @@ func (f *File) addDrawingRelationships(index int, relType, target, targetMode st
_, ok := f.XLSX[rels]
if ok {
ID.Reset()
- xml.Unmarshal([]byte(f.readXML(rels)), &drawingRels)
+ _ = xml.Unmarshal([]byte(f.readXML(rels)), &drawingRels)
rID = len(drawingRels.Relationships) + 1
ID.WriteString("rId")
ID.WriteString(strconv.Itoa(rID))
@@ -289,8 +344,8 @@ func (f *File) addDrawingRelationships(index int, relType, target, targetMode st
return rID
}
-// countMedia provides function to get media files count storage in the folder
-// xl/media/image.
+// countMedia provides a function to get media files count storage in the
+// folder xl/media/image.
func (f *File) countMedia() int {
count := 0
for k := range f.XLSX {
@@ -301,17 +356,16 @@ func (f *File) countMedia() int {
return count
}
-// addMedia provides function to add picture into folder xl/media/image by given
-// file name and extension name.
-func (f *File) addMedia(file, ext string) {
+// addMedia provides a function to add picture into folder xl/media/image by
+// given file and extension name.
+func (f *File) addMedia(file []byte, ext string) {
count := f.countMedia()
- dat, _ := ioutil.ReadFile(file)
media := "xl/media/image" + strconv.Itoa(count+1) + ext
- f.XLSX[media] = dat
+ f.XLSX[media] = file
}
-// setContentTypePartImageExtensions provides function to set the content type
-// for relationship parts and the Main Document part.
+// setContentTypePartImageExtensions provides a function to set the content
+// type for relationship parts and the Main Document part.
func (f *File) setContentTypePartImageExtensions() {
var imageTypes = map[string]bool{"jpeg": false, "png": false, "gif": false}
content := f.contentTypesReader()
@@ -331,7 +385,7 @@ func (f *File) setContentTypePartImageExtensions() {
}
}
-// setContentTypePartVMLExtensions provides function to set the content type
+// setContentTypePartVMLExtensions provides a function to set the content type
// for relationship parts and the Main Document part.
func (f *File) setContentTypePartVMLExtensions() {
vml := false
@@ -349,8 +403,8 @@ func (f *File) setContentTypePartVMLExtensions() {
}
}
-// addContentTypePart provides function to add content type part relationships
-// in the file [Content_Types].xml by given index.
+// addContentTypePart provides a function to add content type part
+// relationships in the file [Content_Types].xml by given index.
func (f *File) addContentTypePart(index int, contentType string) {
setContentType := map[string]func(){
"comments": f.setContentTypePartVMLExtensions,
@@ -384,7 +438,7 @@ func (f *File) addContentTypePart(index int, contentType string) {
})
}
-// getSheetRelationshipsTargetByID provides function to get Target attribute
+// getSheetRelationshipsTargetByID provides a function to get Target attribute
// value in xl/worksheets/_rels/sheet%d.xml.rels by given worksheet name and
// relationship index.
func (f *File) getSheetRelationshipsTargetByID(sheet, rID string) string {
@@ -394,7 +448,7 @@ func (f *File) getSheetRelationshipsTargetByID(sheet, rID string) string {
}
var rels = "xl/worksheets/_rels/" + strings.TrimPrefix(name, "xl/worksheets/") + ".rels"
var sheetRels xlsxWorkbookRels
- xml.Unmarshal([]byte(f.readXML(rels)), &sheetRels)
+ _ = xml.Unmarshal([]byte(f.readXML(rels)), &sheetRels)
for _, v := range sheetRels.Relationships {
if v.ID == rID {
return v.Target
@@ -403,9 +457,9 @@ func (f *File) getSheetRelationshipsTargetByID(sheet, rID string) string {
return ""
}
-// GetPicture provides function to get picture base name and raw content embed
-// in XLSX by given worksheet and cell name. This function returns the file name
-// in XLSX and file contents as []byte data types. For example:
+// GetPicture provides a function to get picture base name and raw content
+// embed in XLSX by given worksheet and cell name. This function returns the
+// file name in XLSX and file contents as []byte data types. For example:
//
// xlsx, err := excelize.OpenFile("./Book1.xlsx")
// if err != nil {
@@ -431,10 +485,10 @@ func (f *File) GetPicture(sheet, cell string) (string, []byte) {
_, ok := f.XLSX[drawingXML]
if !ok {
- return "", []byte{}
+ return "", nil
}
decodeWsDr := decodeWsDr{}
- xml.Unmarshal([]byte(f.readXML(drawingXML)), &decodeWsDr)
+ _ = xml.Unmarshal([]byte(f.readXML(drawingXML)), &decodeWsDr)
cell = strings.ToUpper(cell)
fromCol := string(strings.Map(letterOnlyMapF, cell))
@@ -446,7 +500,7 @@ func (f *File) GetPicture(sheet, cell string) (string, []byte) {
for _, anchor := range decodeWsDr.TwoCellAnchor {
decodeTwoCellAnchor := decodeTwoCellAnchor{}
- xml.Unmarshal([]byte(""+anchor.Content+""), &decodeTwoCellAnchor)
+ _ = xml.Unmarshal([]byte(""+anchor.Content+""), &decodeTwoCellAnchor)
if decodeTwoCellAnchor.From != nil && decodeTwoCellAnchor.Pic != nil {
if decodeTwoCellAnchor.From.Col == col && decodeTwoCellAnchor.From.Row == row {
xlsxWorkbookRelation := f.getDrawingRelationships(drawingRelationships, decodeTwoCellAnchor.Pic.BlipFill.Blip.Embed)
@@ -460,15 +514,16 @@ func (f *File) GetPicture(sheet, cell string) (string, []byte) {
return "", []byte{}
}
-// getDrawingRelationships provides function to get drawing relationships from
-// xl/drawings/_rels/drawing%s.xml.rels by given file name and relationship ID.
+// getDrawingRelationships provides a function to get drawing relationships
+// from xl/drawings/_rels/drawing%s.xml.rels by given file name and
+// relationship ID.
func (f *File) getDrawingRelationships(rels, rID string) *xlsxWorkbookRelation {
_, ok := f.XLSX[rels]
if !ok {
return nil
}
var drawingRels xlsxWorkbookRels
- xml.Unmarshal([]byte(f.readXML(rels)), &drawingRels)
+ _ = xml.Unmarshal([]byte(f.readXML(rels)), &drawingRels)
for _, v := range drawingRels.Relationships {
if v.ID == rID {
return &v
diff --git a/vendor/github.com/360EntSecGroup-Skylar/excelize/rows.go b/vendor/github.com/360EntSecGroup-Skylar/excelize/rows.go
index 75fa7f64b2..5c384c8f09 100644
--- a/vendor/github.com/360EntSecGroup-Skylar/excelize/rows.go
+++ b/vendor/github.com/360EntSecGroup-Skylar/excelize/rows.go
@@ -1,3 +1,12 @@
+// Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of
+// this source code is governed by a BSD-style license that can be found in
+// the LICENSE file.
+//
+// Package excelize providing a set of functions that allow you to write to
+// and read from XLSX files. Support reads and writes XLSX file generated by
+// Microsoft Excel™ 2007 and later. Support save file without losing original
+// charts of XLSX. This library needs Go version 1.8 or later.
+
package excelize
import (
@@ -31,7 +40,7 @@ func (f *File) GetRows(sheet string) [][]string {
output, _ := xml.Marshal(f.Sheet[name])
f.saveFileList(name, replaceWorkSheetsRelationshipsNameSpaceBytes(output))
}
- decoder := xml.NewDecoder(bytes.NewReader(f.readXML(name)))
+ xml.NewDecoder(bytes.NewReader(f.readXML(name)))
d := f.sharedStringsReader()
var inElement string
var r xlsxRow
@@ -44,7 +53,7 @@ func (f *File) GetRows(sheet string) [][]string {
}
rows = append(rows, row)
}
- decoder = xml.NewDecoder(bytes.NewReader(f.readXML(name)))
+ decoder := xml.NewDecoder(bytes.NewReader(f.readXML(name)))
for {
token, _ := decoder.Token()
if token == nil {
@@ -55,7 +64,7 @@ func (f *File) GetRows(sheet string) [][]string {
inElement = startElement.Name.Local
if inElement == "row" {
r = xlsxRow{}
- decoder.DecodeElement(&r, &startElement)
+ _ = decoder.DecodeElement(&r, &startElement)
cr := r.R - 1
for _, colCell := range r.C {
c := TitleToNumber(strings.Map(letterOnlyMapF, colCell.R))
@@ -110,9 +119,9 @@ func (rows *Rows) Columns() []string {
}
startElement := rows.token.(xml.StartElement)
r := xlsxRow{}
- rows.decoder.DecodeElement(&r, &startElement)
+ _ = rows.decoder.DecodeElement(&r, &startElement)
d := rows.f.sharedStringsReader()
- row := make([]string, len(r.C), len(r.C))
+ row := make([]string, len(r.C))
for _, colCell := range r.C {
c := TitleToNumber(strings.Map(letterOnlyMapF, colCell.R))
val, _ := colCell.getValueFrom(rows.f, d)
@@ -132,7 +141,7 @@ func (err ErrSheetNotExist) Error() string {
// Rows return a rows iterator. For example:
//
-// rows, err := xlsx.GetRows("Sheet1")
+// rows, err := xlsx.Rows("Sheet1")
// for rows.Next() {
// for _, colCell := range rows.Columns() {
// fmt.Print(colCell, "\t")
@@ -173,7 +182,7 @@ func (f *File) getTotalRowsCols(name string) (int, int) {
inElement = startElement.Name.Local
if inElement == "row" {
r = xlsxRow{}
- decoder.DecodeElement(&r, &startElement)
+ _ = decoder.DecodeElement(&r, &startElement)
tr = r.R
for _, colCell := range r.C {
col := TitleToNumber(strings.Map(letterOnlyMapF, colCell.R))
@@ -202,7 +211,7 @@ func (f *File) SetRowHeight(sheet string, row int, height float64) {
xlsx.SheetData.Row[rowIdx].CustomHeight = true
}
-// getRowHeight provides function to get row height in pixels by given sheet
+// getRowHeight provides a function to get row height in pixels by given sheet
// name and row index.
func (f *File) getRowHeight(sheet string, row int) int {
xlsx := f.workSheetReader(sheet)
@@ -215,7 +224,7 @@ func (f *File) getRowHeight(sheet string, row int) int {
return int(defaultRowHeightPixels)
}
-// GetRowHeight provides function to get row height by given worksheet name
+// GetRowHeight provides a function to get row height by given worksheet name
// and row index. For example, get the height of the first row in Sheet1:
//
// xlsx.GetRowHeight("Sheet1", 1)
@@ -231,7 +240,7 @@ func (f *File) GetRowHeight(sheet string, row int) float64 {
return defaultRowHeightPixels
}
-// sharedStringsReader provides function to get the pointer to the structure
+// sharedStringsReader provides a function to get the pointer to the structure
// after deserialization of xl/sharedStrings.xml.
func (f *File) sharedStringsReader() *xlsxSST {
if f.SharedStrings == nil {
@@ -240,14 +249,15 @@ func (f *File) sharedStringsReader() *xlsxSST {
if len(ss) == 0 {
ss = f.readXML("xl/SharedStrings.xml")
}
- xml.Unmarshal([]byte(ss), &sharedStrings)
+ _ = xml.Unmarshal([]byte(ss), &sharedStrings)
f.SharedStrings = &sharedStrings
}
return f.SharedStrings
}
-// getValueFrom return a value from a column/row cell, this function is inteded
-// to be used with for range on rows an argument with the xlsx opened file.
+// getValueFrom return a value from a column/row cell, this function is
+// inteded to be used with for range on rows an argument with the xlsx opened
+// file.
func (xlsx *xlsxC) getValueFrom(f *File, d *xlsxSST) (string, error) {
switch xlsx.T {
case "s":
@@ -315,9 +325,9 @@ func (f *File) SetRowOutlineLevel(sheet string, rowIndex int, level uint8) {
xlsx.SheetData.Row[rowIndex].OutlineLevel = level
}
-// GetRowOutlineLevel provides a function to get outline level number of a single row by given
-// worksheet name and row index. For example, get outline number of row 2 in
-// Sheet1:
+// GetRowOutlineLevel provides a function to get outline level number of a
+// single row by given worksheet name and row index. For example, get outline
+// number of row 2 in Sheet1:
//
// xlsx.GetRowOutlineLevel("Sheet1", 2)
//
@@ -329,8 +339,8 @@ func (f *File) GetRowOutlineLevel(sheet string, rowIndex int) uint8 {
return xlsx.SheetData.Row[rowIndex].OutlineLevel
}
-// RemoveRow provides function to remove single row by given worksheet name and
-// row index. For example, remove row 3 in Sheet1:
+// RemoveRow provides a function to remove single row by given worksheet name
+// and row index. For example, remove row 3 in Sheet1:
//
// xlsx.RemoveRow("Sheet1", 2)
//
@@ -349,8 +359,8 @@ func (f *File) RemoveRow(sheet string, row int) {
}
}
-// InsertRow provides function to insert a new row before given row index. For
-// example, create a new row before row 3 in Sheet1:
+// InsertRow provides a function to insert a new row before given row index.
+// For example, create a new row before row 3 in Sheet1:
//
// xlsx.InsertRow("Sheet1", 2)
//
@@ -362,8 +372,8 @@ func (f *File) InsertRow(sheet string, row int) {
f.adjustHelper(sheet, -1, row, 1)
}
-// checkRow provides function to check and fill each column element for all rows
-// and make that is continuous in a worksheet of XML. For example:
+// checkRow provides a function to check and fill each column element for all
+// rows and make that is continuous in a worksheet of XML. For example:
//
//
//
@@ -416,7 +426,7 @@ func checkRow(xlsx *xlsxWorksheet) {
}
}
-// completeRow provides function to check and fill each column element for a
+// completeRow provides a function to check and fill each column element for a
// single row and make that is continuous in a worksheet of XML by given row
// index and axis.
func completeRow(xlsx *xlsxWorksheet, row, cell int) {
@@ -448,9 +458,9 @@ func completeRow(xlsx *xlsxWorksheet, row, cell int) {
}
}
-// convertRowHeightToPixels provides function to convert the height of a cell
-// from user's units to pixels. If the height hasn't been set by the user we use
-// the default value. If the row is hidden it has a value of zero.
+// convertRowHeightToPixels provides a function to convert the height of a
+// cell from user's units to pixels. If the height hasn't been set by the user
+// we use the default value. If the row is hidden it has a value of zero.
func convertRowHeightToPixels(height float64) float64 {
var pixels float64
if height == 0 {
diff --git a/vendor/github.com/360EntSecGroup-Skylar/excelize/shape.go b/vendor/github.com/360EntSecGroup-Skylar/excelize/shape.go
index 0b937521cc..ad87712e82 100644
--- a/vendor/github.com/360EntSecGroup-Skylar/excelize/shape.go
+++ b/vendor/github.com/360EntSecGroup-Skylar/excelize/shape.go
@@ -1,3 +1,12 @@
+// Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of
+// this source code is governed by a BSD-style license that can be found in
+// the LICENSE file.
+//
+// Package excelize providing a set of functions that allow you to write to
+// and read from XLSX files. Support reads and writes XLSX file generated by
+// Microsoft Excel™ 2007 and later. Support save file without losing original
+// charts of XLSX. This library needs Go version 1.8 or later.
+
package excelize
import (
@@ -7,9 +16,9 @@ import (
"strings"
)
-// parseFormatShapeSet provides function to parse the format settings of the
+// parseFormatShapeSet provides a function to parse the format settings of the
// shape with default value.
-func parseFormatShapeSet(formatSet string) *formatShape {
+func parseFormatShapeSet(formatSet string) (*formatShape, error) {
format := formatShape{
Width: 160,
Height: 160,
@@ -23,14 +32,14 @@ func parseFormatShapeSet(formatSet string) *formatShape {
YScale: 1.0,
},
}
- json.Unmarshal([]byte(formatSet), &format)
- return &format
+ err := json.Unmarshal([]byte(formatSet), &format)
+ return &format, err
}
// AddShape provides the method to add shape in a sheet by given worksheet
// index, shape format set (such as offset, scale, aspect ratio setting and
-// print settings) and properties set. For example, add text box (rect shape) in
-// Sheet1:
+// print settings) and properties set. For example, add text box (rect shape)
+// in Sheet1:
//
// xlsx.AddShape("Sheet1", "G6", `{"type":"rect","color":{"line":"#4286F4","fill":"#8eb9ff"},"paragraph":[{"text":"Rectangle Shape","font":{"bold":true,"italic":true,"family":"Berlin Sans FB Demi","size":36,"color":"#777777","underline":"sng"}}],"width":180,"height": 90}`)
//
@@ -245,8 +254,11 @@ func parseFormatShapeSet(formatSet string) *formatShape {
// wavyHeavy
// wavyDbl
//
-func (f *File) AddShape(sheet, cell, format string) {
- formatSet := parseFormatShapeSet(format)
+func (f *File) AddShape(sheet, cell, format string) error {
+ formatSet, err := parseFormatShapeSet(format)
+ if err != nil {
+ return err
+ }
// Read sheet data.
xlsx := f.workSheetReader(sheet)
// Add first shape for given sheet, create xl/drawings/ and xl/drawings/_rels/ folder.
@@ -266,9 +278,10 @@ func (f *File) AddShape(sheet, cell, format string) {
}
f.addDrawingShape(sheet, drawingXML, cell, formatSet)
f.addContentTypePart(drawingID, "drawings")
+ return err
}
-// addDrawingShape provides function to add preset geometry by given sheet,
+// addDrawingShape provides a function to add preset geometry by given sheet,
// drawingXMLand format sets.
func (f *File) addDrawingShape(sheet, drawingXML, cell string, formatSet *formatShape) {
textUnderlineType := map[string]bool{"none": true, "words": true, "sng": true, "dbl": true, "heavy": true, "dotted": true, "dottedHeavy": true, "dash": true, "dashHeavy": true, "dashLong": true, "dashLongHeavy": true, "dotDash": true, "dotDashHeavy": true, "dotDotDash": true, "dotDotDashHeavy": true, "wavy": true, "wavyHeavy": true, "wavyDbl": true}
@@ -393,7 +406,7 @@ func (f *File) addDrawingShape(sheet, drawingXML, cell string, formatSet *format
f.saveFileList(drawingXML, output)
}
-// setShapeRef provides function to set color with hex model by given actual
+// setShapeRef provides a function to set color with hex model by given actual
// color value.
func setShapeRef(color string, i int) *aRef {
if color == "" {
diff --git a/vendor/github.com/360EntSecGroup-Skylar/excelize/sheet.go b/vendor/github.com/360EntSecGroup-Skylar/excelize/sheet.go
index cb50d6103f..b615ae5e14 100644
--- a/vendor/github.com/360EntSecGroup-Skylar/excelize/sheet.go
+++ b/vendor/github.com/360EntSecGroup-Skylar/excelize/sheet.go
@@ -1,3 +1,12 @@
+// Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of
+// this source code is governed by a BSD-style license that can be found in
+// the LICENSE file.
+//
+// Package excelize providing a set of functions that allow you to write to
+// and read from XLSX files. Support reads and writes XLSX file generated by
+// Microsoft Excel™ 2007 and later. Support save file without losing original
+// charts of XLSX. This library needs Go version 1.8 or later.
+
package excelize
import (
@@ -5,14 +14,17 @@ import (
"encoding/json"
"encoding/xml"
"errors"
+ "io/ioutil"
"os"
"path"
"strconv"
"strings"
"unicode/utf8"
+
+ "github.com/mohae/deepcopy"
)
-// NewSheet provides function to create a new sheet by given worksheet name,
+// NewSheet provides a function to create a new sheet by given worksheet name,
// when creating a new XLSX file, the default sheet will be create, when you
// create a new file.
func (f *File) NewSheet(name string) int {
@@ -34,18 +46,18 @@ func (f *File) NewSheet(name string) int {
return f.SheetCount
}
-// contentTypesReader provides function to get the pointer to the
+// contentTypesReader provides a function to get the pointer to the
// [Content_Types].xml structure after deserialization.
func (f *File) contentTypesReader() *xlsxTypes {
if f.ContentTypes == nil {
var content xlsxTypes
- xml.Unmarshal([]byte(f.readXML("[Content_Types].xml")), &content)
+ _ = xml.Unmarshal([]byte(f.readXML("[Content_Types].xml")), &content)
f.ContentTypes = &content
}
return f.ContentTypes
}
-// contentTypesWriter provides function to save [Content_Types].xml after
+// contentTypesWriter provides a function to save [Content_Types].xml after
// serialize structure.
func (f *File) contentTypesWriter() {
if f.ContentTypes != nil {
@@ -54,18 +66,18 @@ func (f *File) contentTypesWriter() {
}
}
-// workbookReader provides function to get the pointer to the xl/workbook.xml
+// workbookReader provides a function to get the pointer to the xl/workbook.xml
// structure after deserialization.
func (f *File) workbookReader() *xlsxWorkbook {
if f.WorkBook == nil {
var content xlsxWorkbook
- xml.Unmarshal([]byte(f.readXML("xl/workbook.xml")), &content)
+ _ = xml.Unmarshal([]byte(f.readXML("xl/workbook.xml")), &content)
f.WorkBook = &content
}
return f.WorkBook
}
-// workbookWriter provides function to save xl/workbook.xml after serialize
+// workbookWriter provides a function to save xl/workbook.xml after serialize
// structure.
func (f *File) workbookWriter() {
if f.WorkBook != nil {
@@ -74,7 +86,7 @@ func (f *File) workbookWriter() {
}
}
-// worksheetWriter provides function to save xl/worksheets/sheet%d.xml after
+// worksheetWriter provides a function to save xl/worksheets/sheet%d.xml after
// serialize structure.
func (f *File) worksheetWriter() {
for path, sheet := range f.Sheet {
@@ -92,15 +104,17 @@ func (f *File) worksheetWriter() {
}
}
-// trimCell provides function to trim blank cells which created by completeCol.
+// trimCell provides a function to trim blank cells which created by completeCol.
func trimCell(column []xlsxC) []xlsxC {
- col := []xlsxC{}
+ col := make([]xlsxC, len(column))
+ i := 0
for _, c := range column {
if c.S != 0 || c.V != "" || c.F != nil || c.T != "" {
- col = append(col, c)
+ col[i] = c
+ i++
}
}
- return col
+ return col[0:i]
}
// Read and update property of contents type of XLSX.
@@ -128,25 +142,33 @@ func (f *File) setSheet(index int, name string) {
// allowed in sheet title.
func (f *File) setWorkbook(name string, rid int) {
content := f.workbookReader()
+ rID := 0
+ for _, v := range content.Sheets.Sheet {
+ t, _ := strconv.Atoi(v.SheetID)
+ if t > rID {
+ rID = t
+ }
+ }
+ rID++
content.Sheets.Sheet = append(content.Sheets.Sheet, xlsxSheet{
Name: trimSheetName(name),
- SheetID: strconv.Itoa(rid),
+ SheetID: strconv.Itoa(rID),
ID: "rId" + strconv.Itoa(rid),
})
}
-// workbookRelsReader provides function to read and unmarshal workbook
+// workbookRelsReader provides a function to read and unmarshal workbook
// relationships of XLSX file.
func (f *File) workbookRelsReader() *xlsxWorkbookRels {
if f.WorkBookRels == nil {
var content xlsxWorkbookRels
- xml.Unmarshal([]byte(f.readXML("xl/_rels/workbook.xml.rels")), &content)
+ _ = xml.Unmarshal([]byte(f.readXML("xl/_rels/workbook.xml.rels")), &content)
f.WorkBookRels = &content
}
return f.WorkBookRels
}
-// workbookRelsWriter provides function to save xl/_rels/workbook.xml.rels after
+// workbookRelsWriter provides a function to save xl/_rels/workbook.xml.rels after
// serialize structure.
func (f *File) workbookRelsWriter() {
if f.WorkBookRels != nil {
@@ -193,19 +215,13 @@ func (f *File) setAppXML() {
// library doesn't multiple namespace declarations in a single element of a
// document. This function is a horrible hack to fix that after the XML
// marshalling is completed.
-func replaceRelationshipsNameSpace(workbookMarshal string) string {
- oldXmlns := ``
- newXmlns := ``
- return strings.Replace(workbookMarshal, oldXmlns, newXmlns, -1)
-}
-
func replaceRelationshipsNameSpaceBytes(workbookMarshal []byte) []byte {
oldXmlns := []byte(``)
newXmlns := []byte(``)
return bytes.Replace(workbookMarshal, oldXmlns, newXmlns, -1)
}
-// SetActiveSheet provides function to set default active worksheet of XLSX by
+// SetActiveSheet provides a function to set default active worksheet of XLSX by
// given index. Note that active index is different with the index that got by
// function GetSheetMap, and it should be greater than 0 and less than total
// worksheet numbers.
@@ -241,7 +257,7 @@ func (f *File) SetActiveSheet(index int) {
}
}
-// GetActiveSheetIndex provides function to get active sheet of XLSX. If not
+// GetActiveSheetIndex provides a function to get active sheet of XLSX. If not
// found the active sheet will be return integer 0.
func (f *File) GetActiveSheetIndex() int {
buffer := bytes.Buffer{}
@@ -251,7 +267,7 @@ func (f *File) GetActiveSheetIndex() int {
buffer.WriteString("xl/worksheets/sheet")
buffer.WriteString(strings.TrimPrefix(v.ID, "rId"))
buffer.WriteString(".xml")
- xml.Unmarshal([]byte(f.readXML(buffer.String())), &xlsx)
+ _ = xml.Unmarshal([]byte(f.readXML(buffer.String())), &xlsx)
for _, sheetView := range xlsx.SheetViews.SheetView {
if sheetView.TabSelected {
ID, _ := strconv.Atoi(strings.TrimPrefix(v.ID, "rId"))
@@ -263,7 +279,7 @@ func (f *File) GetActiveSheetIndex() int {
return 0
}
-// SetSheetName provides function to set the worksheet name be given old and new
+// SetSheetName provides a function to set the worksheet name be given old and new
// worksheet name. Maximum 31 characters are allowed in sheet title and this
// function only changes the name of the sheet and will not update the sheet
// name in the formula or reference associated with the cell. So there may be
@@ -281,7 +297,7 @@ func (f *File) SetSheetName(oldName, newName string) {
}
}
-// GetSheetName provides function to get worksheet name of XLSX by given
+// GetSheetName provides a function to get worksheet name of XLSX by given
// worksheet index. If given sheet index is invalid, will return an empty
// string.
func (f *File) GetSheetName(index int) string {
@@ -300,7 +316,7 @@ func (f *File) GetSheetName(index int) string {
return ""
}
-// GetSheetIndex provides function to get worksheet index of XLSX by given sheet
+// GetSheetIndex provides a function to get worksheet index of XLSX by given sheet
// name. If given worksheet name is invalid, will return an integer type value
// 0.
func (f *File) GetSheetIndex(name string) int {
@@ -319,7 +335,7 @@ func (f *File) GetSheetIndex(name string) int {
return 0
}
-// GetSheetMap provides function to get worksheet name and index map of XLSX.
+// GetSheetMap provides a function to get worksheet name and index map of XLSX.
// For example:
//
// xlsx, err := excelize.OpenFile("./Book1.xlsx")
@@ -345,7 +361,7 @@ func (f *File) GetSheetMap() map[int]string {
return sheetMap
}
-// getSheetMap provides function to get worksheet name and XML file path map of
+// getSheetMap provides a function to get worksheet name and XML file path map of
// XLSX.
func (f *File) getSheetMap() map[string]string {
maps := make(map[string]string)
@@ -355,8 +371,8 @@ func (f *File) getSheetMap() map[string]string {
return maps
}
-// SetSheetBackground provides function to set background picture by given
-// worksheet name.
+// SetSheetBackground provides a function to set background picture by given
+// worksheet name and file path.
func (f *File) SetSheetBackground(sheet, picture string) error {
var err error
// Check picture exists first.
@@ -365,17 +381,18 @@ func (f *File) SetSheetBackground(sheet, picture string) error {
}
ext, ok := supportImageTypes[path.Ext(picture)]
if !ok {
- return errors.New("Unsupported image extension")
+ return errors.New("unsupported image extension")
}
pictureID := f.countMedia() + 1
rID := f.addSheetRelationships(sheet, SourceRelationshipImage, "../media/image"+strconv.Itoa(pictureID)+ext, "")
f.addSheetPicture(sheet, rID)
- f.addMedia(picture, ext)
+ file, _ := ioutil.ReadFile(picture)
+ f.addMedia(file, ext)
f.setContentTypePartImageExtensions()
return err
}
-// DeleteSheet provides function to delete worksheet in a workbook by given
+// DeleteSheet provides a function to delete worksheet in a workbook by given
// worksheet name. Use this method with caution, which will affect changes in
// references such as formulas, charts, and so on. If there is any referenced
// value of the deleted worksheet, it will cause a file error when you open it.
@@ -399,7 +416,7 @@ func (f *File) DeleteSheet(name string) {
f.SetActiveSheet(len(f.GetSheetMap()))
}
-// deleteSheetFromWorkbookRels provides function to remove worksheet
+// deleteSheetFromWorkbookRels provides a function to remove worksheet
// relationships by given relationships ID in the file
// xl/_rels/workbook.xml.rels.
func (f *File) deleteSheetFromWorkbookRels(rID string) string {
@@ -413,7 +430,7 @@ func (f *File) deleteSheetFromWorkbookRels(rID string) string {
return ""
}
-// deleteSheetFromContentTypes provides function to remove worksheet
+// deleteSheetFromContentTypes provides a function to remove worksheet
// relationships by given target name in the file [Content_Types].xml.
func (f *File) deleteSheetFromContentTypes(target string) {
content := f.contentTypesReader()
@@ -424,7 +441,7 @@ func (f *File) deleteSheetFromContentTypes(target string) {
}
}
-// CopySheet provides function to duplicate a worksheet by gave source and
+// CopySheet provides a function to duplicate a worksheet by gave source and
// target worksheet index. Note that currently doesn't support duplicate
// workbooks that contain tables, charts or pictures. For Example:
//
@@ -435,18 +452,17 @@ func (f *File) deleteSheetFromContentTypes(target string) {
//
func (f *File) CopySheet(from, to int) error {
if from < 1 || to < 1 || from == to || f.GetSheetName(from) == "" || f.GetSheetName(to) == "" {
- return errors.New("Invalid worksheet index")
+ return errors.New("invalid worksheet index")
}
f.copySheet(from, to)
return nil
}
-// copySheet provides function to duplicate a worksheet by gave source and
+// copySheet provides a function to duplicate a worksheet by gave source and
// target worksheet name.
func (f *File) copySheet(from, to int) {
sheet := f.workSheetReader("sheet" + strconv.Itoa(from))
- worksheet := xlsxWorksheet{}
- deepCopy(&worksheet, &sheet)
+ worksheet := deepcopy.Copy(sheet).(*xlsxWorksheet)
path := "xl/worksheets/sheet" + strconv.Itoa(to) + ".xml"
if len(worksheet.SheetViews.SheetView) > 0 {
worksheet.SheetViews.SheetView[0].TabSelected = false
@@ -454,7 +470,7 @@ func (f *File) copySheet(from, to int) {
worksheet.Drawing = nil
worksheet.TableParts = nil
worksheet.PageSetUp = nil
- f.Sheet[path] = &worksheet
+ f.Sheet[path] = worksheet
toRels := "xl/worksheets/_rels/sheet" + strconv.Itoa(to) + ".xml.rels"
fromRels := "xl/worksheets/_rels/sheet" + strconv.Itoa(from) + ".xml.rels"
_, ok := f.XLSX[fromRels]
@@ -463,7 +479,7 @@ func (f *File) copySheet(from, to int) {
}
}
-// SetSheetVisible provides function to set worksheet visible by given worksheet
+// SetSheetVisible provides a function to set worksheet visible by given worksheet
// name. A workbook must contain at least one visible worksheet. If the given
// worksheet has been activated, this setting will be invalidated. Sheet state
// values as defined by http://msdn.microsoft.com/en-us/library/office/documentformat.openxml.spreadsheet.sheetstatevalues.aspx
@@ -505,14 +521,14 @@ func (f *File) SetSheetVisible(name string, visible bool) {
}
}
-// parseFormatPanesSet provides function to parse the panes settings.
-func parseFormatPanesSet(formatSet string) *formatPanes {
+// parseFormatPanesSet provides a function to parse the panes settings.
+func parseFormatPanesSet(formatSet string) (*formatPanes, error) {
format := formatPanes{}
- json.Unmarshal([]byte(formatSet), &format)
- return &format
+ err := json.Unmarshal([]byte(formatSet), &format)
+ return &format, err
}
-// SetPanes provides function to create and remove freeze panes and split panes
+// SetPanes provides a function to create and remove freeze panes and split panes
// by given worksheet name and panes format set.
//
// activePane defines the pane that is active. The possible values for this
@@ -598,7 +614,7 @@ func parseFormatPanesSet(formatSet string) *formatPanes {
// xlsx.SetPanes("Sheet1", `{"freeze":false,"split":false}`)
//
func (f *File) SetPanes(sheet, panes string) {
- fs := parseFormatPanesSet(panes)
+ fs, _ := parseFormatPanesSet(panes)
xlsx := f.workSheetReader(sheet)
p := &xlsxPane{
ActivePane: fs.ActivePane,
@@ -626,7 +642,7 @@ func (f *File) SetPanes(sheet, panes string) {
xlsx.SheetViews.SheetView[len(xlsx.SheetViews.SheetView)-1].Selection = s
}
-// GetSheetVisible provides function to get worksheet visible by given worksheet
+// GetSheetVisible provides a function to get worksheet visible by given worksheet
// name. For example, get visible state of Sheet1:
//
// xlsx.GetSheetVisible("Sheet1")
@@ -644,11 +660,19 @@ func (f *File) GetSheetVisible(name string) bool {
return visible
}
-// trimSheetName provides function to trim invaild characters by given worksheet
+// trimSheetName provides a function to trim invaild characters by given worksheet
// name.
func trimSheetName(name string) string {
- r := strings.NewReplacer(":", "", "\\", "", "/", "", "?", "", "*", "", "[", "", "]", "")
- name = r.Replace(name)
+ r := []rune{}
+ for _, v := range name {
+ switch v {
+ case 58, 92, 47, 63, 42, 91, 93: // replace :\/?*[]
+ continue
+ default:
+ r = append(r, v)
+ }
+ }
+ name = string(r)
if utf8.RuneCountInString(name) > 31 {
name = string([]rune(name)[0:31])
}
diff --git a/vendor/github.com/360EntSecGroup-Skylar/excelize/sheetpr.go b/vendor/github.com/360EntSecGroup-Skylar/excelize/sheetpr.go
index 7b8df54837..e38b64e25c 100644
--- a/vendor/github.com/360EntSecGroup-Skylar/excelize/sheetpr.go
+++ b/vendor/github.com/360EntSecGroup-Skylar/excelize/sheetpr.go
@@ -1,3 +1,12 @@
+// Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of
+// this source code is governed by a BSD-style license that can be found in
+// the LICENSE file.
+//
+// Package excelize providing a set of functions that allow you to write to
+// and read from XLSX files. Support reads and writes XLSX file generated by
+// Microsoft Excel™ 2007 and later. Support save file without losing original
+// charts of XLSX. This library needs Go version 1.8 or later.
+
package excelize
// SheetPrOption is an option of a view of a worksheet. See SetSheetPrOptions().
@@ -98,7 +107,7 @@ func (o *AutoPageBreaks) getSheetPrOption(pr *xlsxSheetPr) {
*o = AutoPageBreaks(pr.PageSetUpPr.AutoPageBreaks)
}
-// SetSheetPrOptions provides function to sets worksheet properties.
+// SetSheetPrOptions provides a function to sets worksheet properties.
//
// Available options:
// CodeName(string)
@@ -120,7 +129,7 @@ func (f *File) SetSheetPrOptions(name string, opts ...SheetPrOption) error {
return nil
}
-// GetSheetPrOptions provides function to gets worksheet properties.
+// GetSheetPrOptions provides a function to gets worksheet properties.
//
// Available options:
// CodeName(string)
diff --git a/vendor/github.com/360EntSecGroup-Skylar/excelize/sheetview.go b/vendor/github.com/360EntSecGroup-Skylar/excelize/sheetview.go
index 679e915391..e76325c558 100644
--- a/vendor/github.com/360EntSecGroup-Skylar/excelize/sheetview.go
+++ b/vendor/github.com/360EntSecGroup-Skylar/excelize/sheetview.go
@@ -1,3 +1,12 @@
+// Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of
+// this source code is governed by a BSD-style license that can be found in
+// the LICENSE file.
+//
+// Package excelize providing a set of functions that allow you to write to
+// and read from XLSX files. Support reads and writes XLSX file generated by
+// Microsoft Excel™ 2007 and later. Support save file without losing original
+// charts of XLSX. This library needs Go version 1.8 or later.
+
package excelize
import "fmt"
diff --git a/vendor/github.com/360EntSecGroup-Skylar/excelize/styles.go b/vendor/github.com/360EntSecGroup-Skylar/excelize/styles.go
index daa344772f..513fc9b3a9 100644
--- a/vendor/github.com/360EntSecGroup-Skylar/excelize/styles.go
+++ b/vendor/github.com/360EntSecGroup-Skylar/excelize/styles.go
@@ -1,3 +1,12 @@
+// Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of
+// this source code is governed by a BSD-style license that can be found in
+// the LICENSE file.
+//
+// Package excelize providing a set of functions that allow you to write to
+// and read from XLSX files. Support reads and writes XLSX file generated by
+// Microsoft Excel™ 2007 and later. Support save file without losing original
+// charts of XLSX. This library needs Go version 1.8 or later.
+
package excelize
import (
@@ -10,8 +19,8 @@ import (
)
// Excel styles can reference number formats that are built-in, all of which
-// have an id less than 164. This is a possibly incomplete list comprised of as
-// many of them as I could find.
+// have an id less than 164. This is a possibly incomplete list comprised of
+// as many of them as I could find.
var builtInNumFmt = map[int]string{
0: "general",
1: "0",
@@ -798,45 +807,46 @@ var validType = map[string]string{
// criteriaType defined the list of valid criteria types.
var criteriaType = map[string]string{
- "between": "between",
- "not between": "notBetween",
- "equal to": "equal",
- "=": "equal",
- "==": "equal",
- "not equal to": "notEqual",
- "!=": "notEqual",
- "<>": "notEqual",
- "greater than": "greaterThan",
- ">": "greaterThan",
- "less than": "lessThan",
- "<": "lessThan",
+ "between": "between",
+ "not between": "notBetween",
+ "equal to": "equal",
+ "=": "equal",
+ "==": "equal",
+ "not equal to": "notEqual",
+ "!=": "notEqual",
+ "<>": "notEqual",
+ "greater than": "greaterThan",
+ ">": "greaterThan",
+ "less than": "lessThan",
+ "<": "lessThan",
"greater than or equal to": "greaterThanOrEqual",
- ">=": "greaterThanOrEqual",
- "less than or equal to": "lessThanOrEqual",
- "<=": "lessThanOrEqual",
- "containing": "containsText",
- "not containing": "notContains",
- "begins with": "beginsWith",
- "ends with": "endsWith",
- "yesterday": "yesterday",
- "today": "today",
- "last 7 days": "last7Days",
- "last week": "lastWeek",
- "this week": "thisWeek",
- "continue week": "continueWeek",
- "last month": "lastMonth",
- "this month": "thisMonth",
- "continue month": "continueMonth",
+ ">=": "greaterThanOrEqual",
+ "less than or equal to": "lessThanOrEqual",
+ "<=": "lessThanOrEqual",
+ "containing": "containsText",
+ "not containing": "notContains",
+ "begins with": "beginsWith",
+ "ends with": "endsWith",
+ "yesterday": "yesterday",
+ "today": "today",
+ "last 7 days": "last7Days",
+ "last week": "lastWeek",
+ "this week": "thisWeek",
+ "continue week": "continueWeek",
+ "last month": "lastMonth",
+ "this month": "thisMonth",
+ "continue month": "continueMonth",
}
-// formatToString provides function to return original string by given built-in
-// number formats code and cell string.
+// formatToString provides a function to return original string by given
+// built-in number formats code and cell string.
func formatToString(i int, v string) string {
return v
}
-// formatToInt provides function to convert original string to integer format as
-// string type by given built-in number formats code and cell string.
+// formatToInt provides a function to convert original string to integer
+// format as string type by given built-in number formats code and cell
+// string.
func formatToInt(i int, v string) string {
f, err := strconv.ParseFloat(v, 64)
if err != nil {
@@ -845,8 +855,9 @@ func formatToInt(i int, v string) string {
return fmt.Sprintf("%d", int(f))
}
-// formatToFloat provides function to convert original string to float format as
-// string type by given built-in number formats code and cell string.
+// formatToFloat provides a function to convert original string to float
+// format as string type by given built-in number formats code and cell
+// string.
func formatToFloat(i int, v string) string {
f, err := strconv.ParseFloat(v, 64)
if err != nil {
@@ -855,8 +866,8 @@ func formatToFloat(i int, v string) string {
return fmt.Sprintf("%.2f", f)
}
-// formatToA provides function to convert original string to special format as
-// string type by given built-in number formats code and cell string.
+// formatToA provides a function to convert original string to special format
+// as string type by given built-in number formats code and cell string.
func formatToA(i int, v string) string {
f, err := strconv.ParseFloat(v, 64)
if err != nil {
@@ -870,8 +881,8 @@ func formatToA(i int, v string) string {
return fmt.Sprintf("%d", t)
}
-// formatToB provides function to convert original string to special format as
-// string type by given built-in number formats code and cell string.
+// formatToB provides a function to convert original string to special format
+// as string type by given built-in number formats code and cell string.
func formatToB(i int, v string) string {
f, err := strconv.ParseFloat(v, 64)
if err != nil {
@@ -883,8 +894,8 @@ func formatToB(i int, v string) string {
return fmt.Sprintf("%.2f", f)
}
-// formatToC provides function to convert original string to special format as
-// string type by given built-in number formats code and cell string.
+// formatToC provides a function to convert original string to special format
+// as string type by given built-in number formats code and cell string.
func formatToC(i int, v string) string {
f, err := strconv.ParseFloat(v, 64)
if err != nil {
@@ -894,8 +905,8 @@ func formatToC(i int, v string) string {
return fmt.Sprintf("%d%%", int(f))
}
-// formatToD provides function to convert original string to special format as
-// string type by given built-in number formats code and cell string.
+// formatToD provides a function to convert original string to special format
+// as string type by given built-in number formats code and cell string.
func formatToD(i int, v string) string {
f, err := strconv.ParseFloat(v, 64)
if err != nil {
@@ -905,8 +916,8 @@ func formatToD(i int, v string) string {
return fmt.Sprintf("%.2f%%", f)
}
-// formatToE provides function to convert original string to special format as
-// string type by given built-in number formats code and cell string.
+// formatToE provides a function to convert original string to special format
+// as string type by given built-in number formats code and cell string.
func formatToE(i int, v string) string {
f, err := strconv.ParseFloat(v, 64)
if err != nil {
@@ -915,17 +926,17 @@ func formatToE(i int, v string) string {
return fmt.Sprintf("%.e", f)
}
-// parseTime provides function to returns a string parsed using time.Time.
+// parseTime provides a function to returns a string parsed using time.Time.
// Replace Excel placeholders with Go time placeholders. For example, replace
-// yyyy with 2006. These are in a specific order, due to the fact that m is used
-// in month, minute, and am/pm. It would be easier to fix that with regular
-// expressions, but if it's possible to keep this simple it would be easier to
-// maintain. Full-length month and days (e.g. March, Tuesday) have letters in
-// them that would be replaced by other characters below (such as the 'h' in
-// March, or the 'd' in Tuesday) below. First we convert them to arbitrary
-// characters unused in Excel Date formats, and then at the end, turn them to
-// what they should actually be.
-// Based off: http://www.ozgrid.com/Excel/CustomFormats.htm
+// yyyy with 2006. These are in a specific order, due to the fact that m is
+// used in month, minute, and am/pm. It would be easier to fix that with
+// regular expressions, but if it's possible to keep this simple it would be
+// easier to maintain. Full-length month and days (e.g. March, Tuesday) have
+// letters in them that would be replaced by other characters below (such as
+// the 'h' in March, or the 'd' in Tuesday) below. First we convert them to
+// arbitrary characters unused in Excel Date formats, and then at the end,
+// turn them to what they should actually be. Based off:
+// http://www.ozgrid.com/Excel/CustomFormats.htm
func parseTime(i int, v string) string {
f, err := strconv.ParseFloat(v, 64)
if err != nil {
@@ -983,18 +994,18 @@ func is12HourTime(format string) bool {
return strings.Contains(format, "am/pm") || strings.Contains(format, "AM/PM") || strings.Contains(format, "a/p") || strings.Contains(format, "A/P")
}
-// stylesReader provides function to get the pointer to the structure after
+// stylesReader provides a function to get the pointer to the structure after
// deserialization of xl/styles.xml.
func (f *File) stylesReader() *xlsxStyleSheet {
if f.Styles == nil {
var styleSheet xlsxStyleSheet
- xml.Unmarshal([]byte(f.readXML("xl/styles.xml")), &styleSheet)
+ _ = xml.Unmarshal([]byte(f.readXML("xl/styles.xml")), &styleSheet)
f.Styles = &styleSheet
}
return f.Styles
}
-// styleSheetWriter provides function to save xl/styles.xml after serialize
+// styleSheetWriter provides a function to save xl/styles.xml after serialize
// structure.
func (f *File) styleSheetWriter() {
if f.Styles != nil {
@@ -1003,7 +1014,7 @@ func (f *File) styleSheetWriter() {
}
}
-// parseFormatStyleSet provides function to parse the format settings of the
+// parseFormatStyleSet provides a function to parse the format settings of the
// cells and conditional formats.
func parseFormatStyleSet(style string) (*formatStyle, error) {
format := formatStyle{
@@ -1013,8 +1024,8 @@ func parseFormatStyleSet(style string) (*formatStyle, error) {
return &format, err
}
-// NewStyle provides function to create style for cells by given style format.
-// Note that the color field uses RGB color code.
+// NewStyle provides a function to create style for cells by given style
+// format. Note that the color field uses RGB color code.
//
// The following shows the border styles sorted by excelize index number:
//
@@ -1404,7 +1415,7 @@ func parseFormatStyleSet(style string) (*formatStyle, error) {
// 173 | $ English (New Zealand)
// 174 | $ English (Singapore)
// 175 | $ English (Trinidad & Tobago)
-// 176 | $ English (U.S. Vigin Islands)
+// 176 | $ English (U.S. Virgin Islands)
// 177 | $ English (United States)
// 178 | $ French (Canada)
// 179 | $ Hawaiian (United States)
@@ -1906,10 +1917,10 @@ func (f *File) NewStyle(style string) (int, error) {
return cellXfsID, nil
}
-// NewConditionalStyle provides function to create style for conditional format
-// by given style format. The parameters are the same as function NewStyle().
-// Note that the color field uses RGB color code and only support to set font,
-// fills, alignment and borders currently.
+// NewConditionalStyle provides a function to create style for conditional
+// format by given style format. The parameters are the same as function
+// NewStyle(). Note that the color field uses RGB color code and only support
+// to set font, fills, alignment and borders currently.
func (f *File) NewConditionalStyle(style string) (int, error) {
s := f.stylesReader()
fs, err := parseFormatStyleSet(style)
@@ -1935,7 +1946,8 @@ func (f *File) NewConditionalStyle(style string) (int, error) {
return s.Dxfs.Count - 1, nil
}
-// setFont provides function to add font style by given cell format settings.
+// setFont provides a function to add font style by given cell format
+// settings.
func setFont(formatStyle *formatStyle) *font {
fontUnderlineType := map[string]string{"single": "single", "double": "double"}
if formatStyle.Font.Size < 1 {
@@ -1963,8 +1975,8 @@ func setFont(formatStyle *formatStyle) *font {
return &f
}
-// setNumFmt provides function to check if number format code in the range of
-// built-in values.
+// setNumFmt provides a function to check if number format code in the range
+// of built-in values.
func setNumFmt(style *xlsxStyleSheet, formatStyle *formatStyle) int {
dp := "0."
numFmtID := 164 // Default custom number format code from 164.
@@ -2011,7 +2023,7 @@ func setNumFmt(style *xlsxStyleSheet, formatStyle *formatStyle) int {
return formatStyle.NumFmt
}
-// setCustomNumFmt provides function to set custom number format code.
+// setCustomNumFmt provides a function to set custom number format code.
func setCustomNumFmt(style *xlsxStyleSheet, formatStyle *formatStyle) int {
nf := xlsxNumFmt{FormatCode: *formatStyle.CustomNumFmt}
if style.NumFmts != nil {
@@ -2029,7 +2041,7 @@ func setCustomNumFmt(style *xlsxStyleSheet, formatStyle *formatStyle) int {
return nf.NumFmtID
}
-// setLangNumFmt provides function to set number format code with language.
+// setLangNumFmt provides a function to set number format code with language.
func setLangNumFmt(style *xlsxStyleSheet, formatStyle *formatStyle) int {
numFmts, ok := langNumFmt[formatStyle.Lang]
if !ok {
@@ -2056,8 +2068,8 @@ func setLangNumFmt(style *xlsxStyleSheet, formatStyle *formatStyle) int {
return nf.NumFmtID
}
-// setFills provides function to add fill elements in the styles.xml by given
-// cell format settings.
+// setFills provides a function to add fill elements in the styles.xml by
+// given cell format settings.
func setFills(formatStyle *formatStyle, fg bool) *xlsxFill {
var patterns = []string{
"none",
@@ -2137,9 +2149,10 @@ func setFills(formatStyle *formatStyle, fg bool) *xlsxFill {
return &fill
}
-// setAlignment provides function to formatting information pertaining to text
-// alignment in cells. There are a variety of choices for how text is aligned
-// both horizontally and vertically, as well as indentation settings, and so on.
+// setAlignment provides a function to formatting information pertaining to
+// text alignment in cells. There are a variety of choices for how text is
+// aligned both horizontally and vertically, as well as indentation settings,
+// and so on.
func setAlignment(formatStyle *formatStyle) *xlsxAlignment {
var alignment xlsxAlignment
if formatStyle.Alignment != nil {
@@ -2156,7 +2169,7 @@ func setAlignment(formatStyle *formatStyle) *xlsxAlignment {
return &alignment
}
-// setProtection provides function to set protection properties associated
+// setProtection provides a function to set protection properties associated
// with the cell.
func setProtection(formatStyle *formatStyle) *xlsxProtection {
var protection xlsxProtection
@@ -2167,7 +2180,7 @@ func setProtection(formatStyle *formatStyle) *xlsxProtection {
return &protection
}
-// setBorders provides function to add border elements in the styles.xml by
+// setBorders provides a function to add border elements in the styles.xml by
// given borders format settings.
func setBorders(formatStyle *formatStyle) *xlsxBorder {
var styles = []string{
@@ -2219,7 +2232,7 @@ func setBorders(formatStyle *formatStyle) *xlsxBorder {
return &border
}
-// setCellXfs provides function to set describes all of the formatting for a
+// setCellXfs provides a function to set describes all of the formatting for a
// cell.
func setCellXfs(style *xlsxStyleSheet, fontID, numFmtID, fillID, borderID int, applyAlignment, applyProtection bool, alignment *xlsxAlignment, protection *xlsxProtection) int {
var xf xlsxXf
@@ -2246,9 +2259,10 @@ func setCellXfs(style *xlsxStyleSheet, fontID, numFmtID, fillID, borderID int, a
return style.CellXfs.Count - 1
}
-// SetCellStyle provides function to add style attribute for cells by given
+// SetCellStyle provides a function to add style attribute for cells by given
// worksheet name, coordinate area and style ID. Note that diagonalDown and
-// diagonalUp type border should be use same color in the same coordinate area.
+// diagonalUp type border should be use same color in the same coordinate
+// area.
//
// For example create a borders of cell H9 on Sheet1:
//
@@ -2352,9 +2366,10 @@ func (f *File) SetCellStyle(sheet, hcell, vcell string, styleID int) {
}
}
-// SetConditionalFormat provides function to create conditional formatting rule
-// for cell value. Conditional formatting is a feature of Excel which allows you
-// to apply a format to a cell or a range of cells based on certain criteria.
+// SetConditionalFormat provides a function to create conditional formatting
+// rule for cell value. Conditional formatting is a feature of Excel which
+// allows you to apply a format to a cell or a range of cells based on certain
+// criteria.
//
// The type option is a required parameter and it has no default value.
// Allowable type values and their associated parameters are:
@@ -2407,7 +2422,7 @@ func (f *File) SetCellStyle(sheet, hcell, vcell string, styleID int) {
//
// The criteria parameter is used to set the criteria by which the cell data
// will be evaluated. It has no default value. The most common criteria as
-// applied to {'type': 'cell'} are:
+// applied to {"type":"cell"} are:
//
// between |
// not between |
@@ -2562,10 +2577,12 @@ func (f *File) SetCellStyle(sheet, hcell, vcell string, styleID int) {
//
// bar_color - Used for data_bar. Same as min_color, see above.
//
-func (f *File) SetConditionalFormat(sheet, area, formatSet string) {
+func (f *File) SetConditionalFormat(sheet, area, formatSet string) error {
var format []*formatConditional
- json.Unmarshal([]byte(formatSet), &format)
-
+ err := json.Unmarshal([]byte(formatSet), &format)
+ if err != nil {
+ return err
+ }
drawContFmtFunc := map[string]func(p int, ct string, fmtCond *formatConditional) *xlsxCfRule{
"cellIs": drawCondFmtCellIs,
"top10": drawCondFmtTop10,
@@ -2601,11 +2618,12 @@ func (f *File) SetConditionalFormat(sheet, area, formatSet string) {
SQRef: area,
CfRule: cfRule,
})
+ return err
}
-// drawCondFmtCellIs provides function to create conditional formatting rule for
-// cell value (include between, not between, equal, not equal, greater than and
-// less than) by given priority, criteria type and format settings.
+// drawCondFmtCellIs provides a function to create conditional formatting rule
+// for cell value (include between, not between, equal, not equal, greater
+// than and less than) by given priority, criteria type and format settings.
func drawCondFmtCellIs(p int, ct string, format *formatConditional) *xlsxCfRule {
c := &xlsxCfRule{
Priority: p + 1,
@@ -2626,8 +2644,8 @@ func drawCondFmtCellIs(p int, ct string, format *formatConditional) *xlsxCfRule
return c
}
-// drawCondFmtTop10 provides function to create conditional formatting rule for
-// top N (default is top 10) by given priority, criteria type and format
+// drawCondFmtTop10 provides a function to create conditional formatting rule
+// for top N (default is top 10) by given priority, criteria type and format
// settings.
func drawCondFmtTop10(p int, ct string, format *formatConditional) *xlsxCfRule {
c := &xlsxCfRule{
@@ -2644,9 +2662,9 @@ func drawCondFmtTop10(p int, ct string, format *formatConditional) *xlsxCfRule {
return c
}
-// drawCondFmtAboveAverage provides function to create conditional formatting
-// rule for above average and below average by given priority, criteria type and
-// format settings.
+// drawCondFmtAboveAverage provides a function to create conditional
+// formatting rule for above average and below average by given priority,
+// criteria type and format settings.
func drawCondFmtAboveAverage(p int, ct string, format *formatConditional) *xlsxCfRule {
return &xlsxCfRule{
Priority: p + 1,
@@ -2656,7 +2674,7 @@ func drawCondFmtAboveAverage(p int, ct string, format *formatConditional) *xlsxC
}
}
-// drawCondFmtDuplicateUniqueValues provides function to create conditional
+// drawCondFmtDuplicateUniqueValues provides a function to create conditional
// formatting rule for duplicate and unique values by given priority, criteria
// type and format settings.
func drawCondFmtDuplicateUniqueValues(p int, ct string, format *formatConditional) *xlsxCfRule {
@@ -2667,16 +2685,29 @@ func drawCondFmtDuplicateUniqueValues(p int, ct string, format *formatConditiona
}
}
-// drawCondFmtColorScale provides function to create conditional formatting rule
-// for color scale (include 2 color scale and 3 color scale) by given priority,
-// criteria type and format settings.
+// drawCondFmtColorScale provides a function to create conditional formatting
+// rule for color scale (include 2 color scale and 3 color scale) by given
+// priority, criteria type and format settings.
func drawCondFmtColorScale(p int, ct string, format *formatConditional) *xlsxCfRule {
+ minValue := format.MinValue
+ if minValue == "" {
+ minValue = "0"
+ }
+ maxValue := format.MaxValue
+ if maxValue == "" {
+ maxValue = "0"
+ }
+ midValue := format.MidValue
+ if midValue == "" {
+ midValue = "50"
+ }
+
c := &xlsxCfRule{
Priority: p + 1,
Type: "colorScale",
ColorScale: &xlsxColorScale{
Cfvo: []*xlsxCfvo{
- {Type: format.MinType},
+ {Type: format.MinType, Val: minValue},
},
Color: []*xlsxColor{
{RGB: getPaletteColor(format.MinColor)},
@@ -2684,16 +2715,16 @@ func drawCondFmtColorScale(p int, ct string, format *formatConditional) *xlsxCfR
},
}
if validType[format.Type] == "3_color_scale" {
- c.ColorScale.Cfvo = append(c.ColorScale.Cfvo, &xlsxCfvo{Type: format.MidType, Val: 50})
+ c.ColorScale.Cfvo = append(c.ColorScale.Cfvo, &xlsxCfvo{Type: format.MidType, Val: midValue})
c.ColorScale.Color = append(c.ColorScale.Color, &xlsxColor{RGB: getPaletteColor(format.MidColor)})
}
- c.ColorScale.Cfvo = append(c.ColorScale.Cfvo, &xlsxCfvo{Type: format.MaxType})
+ c.ColorScale.Cfvo = append(c.ColorScale.Cfvo, &xlsxCfvo{Type: format.MaxType, Val: maxValue})
c.ColorScale.Color = append(c.ColorScale.Color, &xlsxColor{RGB: getPaletteColor(format.MaxColor)})
return c
}
-// drawCondFmtDataBar provides function to create conditional formatting rule
-// for data bar by given priority, criteria type and format settings.
+// drawCondFmtDataBar provides a function to create conditional formatting
+// rule for data bar by given priority, criteria type and format settings.
func drawCondFmtDataBar(p int, ct string, format *formatConditional) *xlsxCfRule {
return &xlsxCfRule{
Priority: p + 1,
@@ -2705,8 +2736,8 @@ func drawCondFmtDataBar(p int, ct string, format *formatConditional) *xlsxCfRule
}
}
-// drawConfFmtExp provides function to create conditional formatting rule for
-// expression by given priority, criteria type and format settings.
+// drawConfFmtExp provides a function to create conditional formatting rule
+// for expression by given priority, criteria type and format settings.
func drawConfFmtExp(p int, ct string, format *formatConditional) *xlsxCfRule {
return &xlsxCfRule{
Priority: p + 1,
@@ -2716,7 +2747,34 @@ func drawConfFmtExp(p int, ct string, format *formatConditional) *xlsxCfRule {
}
}
-// getPaletteColor provides function to convert the RBG color by given string.
+// getPaletteColor provides a function to convert the RBG color by given
+// string.
func getPaletteColor(color string) string {
return "FF" + strings.Replace(strings.ToUpper(color), "#", "", -1)
}
+
+// themeReader provides a function to get the pointer to the xl/theme/theme1.xml
+// structure after deserialization.
+func (f *File) themeReader() *xlsxTheme {
+ var theme xlsxTheme
+ _ = xml.Unmarshal([]byte(f.readXML("xl/theme/theme1.xml")), &theme)
+ return &theme
+}
+
+// ThemeColor applied the color with tint value.
+func ThemeColor(baseColor string, tint float64) string {
+ if tint == 0 {
+ return "FF" + baseColor
+ }
+ r, _ := strconv.ParseInt(baseColor[0:2], 16, 64)
+ g, _ := strconv.ParseInt(baseColor[2:4], 16, 64)
+ b, _ := strconv.ParseInt(baseColor[4:6], 16, 64)
+ h, s, l := RGBToHSL(uint8(r), uint8(g), uint8(b))
+ if tint < 0 {
+ l *= (1 + tint)
+ } else {
+ l = l*(1-tint) + (1 - (1 - tint))
+ }
+ br, bg, bb := HSLToRGB(h, s, l)
+ return fmt.Sprintf("FF%02X%02X%02X", br, bg, bb)
+}
diff --git a/vendor/github.com/360EntSecGroup-Skylar/excelize/table.go b/vendor/github.com/360EntSecGroup-Skylar/excelize/table.go
index 5af4b048b4..02c89fa561 100644
--- a/vendor/github.com/360EntSecGroup-Skylar/excelize/table.go
+++ b/vendor/github.com/360EntSecGroup-Skylar/excelize/table.go
@@ -1,3 +1,12 @@
+// Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of
+// this source code is governed by a BSD-style license that can be found in
+// the LICENSE file.
+//
+// Package excelize providing a set of functions that allow you to write to
+// and read from XLSX files. Support reads and writes XLSX file generated by
+// Microsoft Excel™ 2007 and later. Support save file without losing original
+// charts of XLSX. This library needs Go version 1.8 or later.
+
package excelize
import (
@@ -9,15 +18,15 @@ import (
"strings"
)
-// parseFormatTableSet provides function to parse the format settings of the
+// parseFormatTableSet provides a function to parse the format settings of the
// table with default value.
-func parseFormatTableSet(formatSet string) *formatTable {
+func parseFormatTableSet(formatSet string) (*formatTable, error) {
format := formatTable{
TableStyle: "",
ShowRowStripes: true,
}
- json.Unmarshal([]byte(formatSet), &format)
- return &format
+ err := json.Unmarshal(parseFormatSet(formatSet), &format)
+ return &format, err
}
// AddTable provides the method to add table in a worksheet by given worksheet
@@ -41,8 +50,11 @@ func parseFormatTableSet(formatSet string) *formatTable {
// TableStyleMedium1 - TableStyleMedium28
// TableStyleDark1 - TableStyleDark11
//
-func (f *File) AddTable(sheet, hcell, vcell, format string) {
- formatSet := parseFormatTableSet(format)
+func (f *File) AddTable(sheet, hcell, vcell, format string) error {
+ formatSet, err := parseFormatTableSet(format)
+ if err != nil {
+ return err
+ }
hcell = strings.ToUpper(hcell)
vcell = strings.ToUpper(vcell)
// Coordinate conversion, convert C1:B3 to 2,0,1,2.
@@ -69,10 +81,11 @@ func (f *File) AddTable(sheet, hcell, vcell, format string) {
f.addSheetTable(sheet, rID)
f.addTable(sheet, tableXML, hxAxis, hyAxis, vxAxis, vyAxis, tableID, formatSet)
f.addContentTypePart(tableID, "table")
+ return err
}
-// countTables provides function to get table files count storage in the folder
-// xl/tables.
+// countTables provides a function to get table files count storage in the
+// folder xl/tables.
func (f *File) countTables() int {
count := 0
for k := range f.XLSX {
@@ -83,7 +96,7 @@ func (f *File) countTables() int {
return count
}
-// addSheetTable provides function to add tablePart element to
+// addSheetTable provides a function to add tablePart element to
// xl/worksheets/sheet%d.xml by given worksheet name and relationship index.
func (f *File) addSheetTable(sheet string, rID int) {
xlsx := f.workSheetReader(sheet)
@@ -97,8 +110,8 @@ func (f *File) addSheetTable(sheet string, rID int) {
xlsx.TableParts.TableParts = append(xlsx.TableParts.TableParts, table)
}
-// addTable provides function to add table by given worksheet name, coordinate
-// area and format set.
+// addTable provides a function to add table by given worksheet name,
+// coordinate area and format set.
func (f *File) addTable(sheet, tableXML string, hxAxis, hyAxis, vxAxis, vyAxis, i int, formatSet *formatTable) {
// Correct the minimum number of rows, the table at least two lines.
if hyAxis == vyAxis {
@@ -153,12 +166,12 @@ func (f *File) addTable(sheet, tableXML string, hxAxis, hyAxis, vxAxis, vyAxis,
f.saveFileList(tableXML, table)
}
-// parseAutoFilterSet provides function to parse the settings of the auto
+// parseAutoFilterSet provides a function to parse the settings of the auto
// filter.
-func parseAutoFilterSet(formatSet string) *formatAutoFilter {
+func parseAutoFilterSet(formatSet string) (*formatAutoFilter, error) {
format := formatAutoFilter{}
- json.Unmarshal([]byte(formatSet), &format)
- return &format
+ err := json.Unmarshal([]byte(formatSet), &format)
+ return &format, err
}
// AutoFilter provides the method to add auto filter in a worksheet by given
@@ -232,7 +245,8 @@ func parseAutoFilterSet(formatSet string) *formatAutoFilter {
// Price < 2000
//
func (f *File) AutoFilter(sheet, hcell, vcell, format string) error {
- formatSet := parseAutoFilterSet(format)
+ formatSet, _ := parseAutoFilterSet(format)
+
hcell = strings.ToUpper(hcell)
vcell = strings.ToUpper(vcell)
@@ -256,11 +270,10 @@ func (f *File) AutoFilter(sheet, hcell, vcell, format string) error {
}
ref := ToAlphaString(hxAxis) + strconv.Itoa(hyAxis+1) + ":" + ToAlphaString(vxAxis) + strconv.Itoa(vyAxis+1)
refRange := vxAxis - hxAxis
- err := f.autoFilter(sheet, ref, refRange, hxAxis, formatSet)
- return err
+ return f.autoFilter(sheet, ref, refRange, hxAxis, formatSet)
}
-// autoFilter provides function to extract the tokens from the filter
+// autoFilter provides a function to extract the tokens from the filter
// expression. The tokens are mainly non-whitespace groups.
func (f *File) autoFilter(sheet, ref string, refRange, hxAxis int, formatSet *formatAutoFilter) error {
xlsx := f.workSheetReader(sheet)
@@ -278,7 +291,7 @@ func (f *File) autoFilter(sheet, ref string, refRange, hxAxis int, formatSet *fo
col := TitleToNumber(formatSet.Column)
offset := col - hxAxis
if offset < 0 || offset > refRange {
- return fmt.Errorf("Incorrect index of column '%s'", formatSet.Column)
+ return fmt.Errorf("incorrect index of column '%s'", formatSet.Column)
}
filter.FilterColumn = &xlsxFilterColumn{
ColID: offset,
@@ -286,7 +299,7 @@ func (f *File) autoFilter(sheet, ref string, refRange, hxAxis int, formatSet *fo
re := regexp.MustCompile(`"(?:[^"]|"")*"|\S+`)
token := re.FindAllString(formatSet.Expression, -1)
if len(token) != 3 && len(token) != 7 {
- return fmt.Errorf("Incorrect number of tokens in criteria '%s'", formatSet.Expression)
+ return fmt.Errorf("incorrect number of tokens in criteria '%s'", formatSet.Expression)
}
expressions, tokens, err := f.parseFilterExpression(formatSet.Expression, token)
if err != nil {
@@ -297,8 +310,8 @@ func (f *File) autoFilter(sheet, ref string, refRange, hxAxis int, formatSet *fo
return nil
}
-// writeAutoFilter provides function to check for single or double custom filters
-// as default filters and handle them accordingly.
+// writeAutoFilter provides a function to check for single or double custom
+// filters as default filters and handle them accordingly.
func (f *File) writeAutoFilter(filter *xlsxAutoFilter, exp []int, tokens []string) {
if len(exp) == 1 && exp[0] == 2 {
// Single equality.
@@ -325,7 +338,7 @@ func (f *File) writeAutoFilter(filter *xlsxAutoFilter, exp []int, tokens []strin
}
}
-// writeCustomFilter provides function to write the element.
+// writeCustomFilter provides a function to write the element.
func (f *File) writeCustomFilter(filter *xlsxAutoFilter, operator int, val string) {
operators := map[int]string{
1: "lessThan",
@@ -349,8 +362,9 @@ func (f *File) writeCustomFilter(filter *xlsxAutoFilter, operator int, val strin
}
}
-// parseFilterExpression provides function to converts the tokens of a possibly
-// conditional expression into 1 or 2 sub expressions for further parsing.
+// parseFilterExpression provides a function to converts the tokens of a
+// possibly conditional expression into 1 or 2 sub expressions for further
+// parsing.
//
// Examples:
//
@@ -390,7 +404,7 @@ func (f *File) parseFilterExpression(expression string, tokens []string) ([]int,
return expressions, t, nil
}
-// parseFilterTokens provides function to parse the 3 tokens of a filter
+// parseFilterTokens provides a function to parse the 3 tokens of a filter
// expression and return the operator and token.
func (f *File) parseFilterTokens(expression string, tokens []string) ([]int, string, error) {
operators := map[string]int{
@@ -410,7 +424,7 @@ func (f *File) parseFilterTokens(expression string, tokens []string) ([]int, str
operator, ok := operators[strings.ToLower(tokens[1])]
if !ok {
// Convert the operator from a number to a descriptive string.
- return []int{}, "", fmt.Errorf("Unknown operator: %s", tokens[1])
+ return []int{}, "", fmt.Errorf("unknown operator: %s", tokens[1])
}
token := tokens[2]
// Special handling for Blanks/NonBlanks.
@@ -418,7 +432,7 @@ func (f *File) parseFilterTokens(expression string, tokens []string) ([]int, str
if re {
// Only allow Equals or NotEqual in this context.
if operator != 2 && operator != 5 {
- return []int{operator}, token, fmt.Errorf("The operator '%s' in expression '%s' is not valid in relation to Blanks/NonBlanks'", tokens[1], expression)
+ return []int{operator}, token, fmt.Errorf("the operator '%s' in expression '%s' is not valid in relation to Blanks/NonBlanks'", tokens[1], expression)
}
token = strings.ToLower(token)
// The operator should always be 2 (=) to flag a "simple" equality in
diff --git a/vendor/github.com/360EntSecGroup-Skylar/excelize/templates.go b/vendor/github.com/360EntSecGroup-Skylar/excelize/templates.go
index d3f82ee924..1d0655dc93 100644
--- a/vendor/github.com/360EntSecGroup-Skylar/excelize/templates.go
+++ b/vendor/github.com/360EntSecGroup-Skylar/excelize/templates.go
@@ -1,3 +1,12 @@
+// Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of
+// this source code is governed by a BSD-style license that can be found in
+// the LICENSE file.
+//
+// Package excelize providing a set of functions that allow you to write to
+// and read from XLSX files. Support reads and writes XLSX file generated by
+// Microsoft Excel™ 2007 and later. Support save file without losing original
+// charts of XLSX. This library needs Go version 1.8 or later.
+//
// This file contains default templates for XML files we don't yet populated
// based on content.
@@ -7,10 +16,12 @@ package excelize
const XMLHeader = "\n"
var (
+ // XMLHeaderByte define an XML declaration can also contain a standalone
+ // declaration.
XMLHeaderByte = []byte(XMLHeader)
)
-const templateDocpropsApp = `0Golang Excelize`
+const templateDocpropsApp = `0Go Excelize`
const templateContentTypes = ``
diff --git a/vendor/github.com/360EntSecGroup-Skylar/excelize/vmlDrawing.go b/vendor/github.com/360EntSecGroup-Skylar/excelize/vmlDrawing.go
index 307186a95e..c17dde7887 100644
--- a/vendor/github.com/360EntSecGroup-Skylar/excelize/vmlDrawing.go
+++ b/vendor/github.com/360EntSecGroup-Skylar/excelize/vmlDrawing.go
@@ -1,3 +1,12 @@
+// Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of
+// this source code is governed by a BSD-style license that can be found in
+// the LICENSE file.
+//
+// Package excelize providing a set of functions that allow you to write to
+// and read from XLSX files. Support reads and writes XLSX file generated by
+// Microsoft Excel™ 2007 and later. Support save file without losing original
+// charts of XLSX. This library needs Go version 1.8 or later.
+
package excelize
import "encoding/xml"
diff --git a/vendor/github.com/360EntSecGroup-Skylar/excelize/xmlChart.go b/vendor/github.com/360EntSecGroup-Skylar/excelize/xmlChart.go
index a263334307..78218a01d4 100644
--- a/vendor/github.com/360EntSecGroup-Skylar/excelize/xmlChart.go
+++ b/vendor/github.com/360EntSecGroup-Skylar/excelize/xmlChart.go
@@ -1,3 +1,12 @@
+// Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of
+// this source code is governed by a BSD-style license that can be found in
+// the LICENSE file.
+//
+// Package excelize providing a set of functions that allow you to write to
+// and read from XLSX files. Support reads and writes XLSX file generated by
+// Microsoft Excel™ 2007 and later. Support save file without losing original
+// charts of XLSX. This library needs Go version 1.8 or later.
+
package excelize
import "encoding/xml"
diff --git a/vendor/github.com/360EntSecGroup-Skylar/excelize/xmlComments.go b/vendor/github.com/360EntSecGroup-Skylar/excelize/xmlComments.go
index fadc9b3873..9075c8873a 100644
--- a/vendor/github.com/360EntSecGroup-Skylar/excelize/xmlComments.go
+++ b/vendor/github.com/360EntSecGroup-Skylar/excelize/xmlComments.go
@@ -1,3 +1,12 @@
+// Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of
+// this source code is governed by a BSD-style license that can be found in
+// the LICENSE file.
+//
+// Package excelize providing a set of functions that allow you to write to
+// and read from XLSX files. Support reads and writes XLSX file generated by
+// Microsoft Excel™ 2007 and later. Support save file without losing original
+// charts of XLSX. This library needs Go version 1.8 or later.
+
package excelize
import "encoding/xml"
@@ -53,3 +62,11 @@ type formatComment struct {
Author string `json:"author"`
Text string `json:"text"`
}
+
+// Comment directly maps the comment information.
+type Comment struct {
+ Author string `json:"author"`
+ AuthorID int `json:"author_id"`
+ Ref string `json:"ref"`
+ Text string `json:"text"`
+}
diff --git a/vendor/github.com/360EntSecGroup-Skylar/excelize/xmlContentTypes.go b/vendor/github.com/360EntSecGroup-Skylar/excelize/xmlContentTypes.go
index 121c6846bf..8d09d515ef 100644
--- a/vendor/github.com/360EntSecGroup-Skylar/excelize/xmlContentTypes.go
+++ b/vendor/github.com/360EntSecGroup-Skylar/excelize/xmlContentTypes.go
@@ -1,3 +1,12 @@
+// Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of
+// this source code is governed by a BSD-style license that can be found in
+// the LICENSE file.
+//
+// Package excelize providing a set of functions that allow you to write to
+// and read from XLSX files. Support reads and writes XLSX file generated by
+// Microsoft Excel™ 2007 and later. Support save file without losing original
+// charts of XLSX. This library needs Go version 1.8 or later.
+
package excelize
import "encoding/xml"
diff --git a/vendor/github.com/360EntSecGroup-Skylar/excelize/xmlDecodeDrawing.go b/vendor/github.com/360EntSecGroup-Skylar/excelize/xmlDecodeDrawing.go
index fff6b9debf..d21c3f01df 100644
--- a/vendor/github.com/360EntSecGroup-Skylar/excelize/xmlDecodeDrawing.go
+++ b/vendor/github.com/360EntSecGroup-Skylar/excelize/xmlDecodeDrawing.go
@@ -1,3 +1,12 @@
+// Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of
+// this source code is governed by a BSD-style license that can be found in
+// the LICENSE file.
+//
+// Package excelize providing a set of functions that allow you to write to
+// and read from XLSX files. Support reads and writes XLSX file generated by
+// Microsoft Excel™ 2007 and later. Support save file without losing original
+// charts of XLSX. This library needs Go version 1.8 or later.
+
package excelize
import "encoding/xml"
diff --git a/vendor/github.com/360EntSecGroup-Skylar/excelize/xmlDrawing.go b/vendor/github.com/360EntSecGroup-Skylar/excelize/xmlDrawing.go
index beb6bc94a4..6ba7d31d1f 100644
--- a/vendor/github.com/360EntSecGroup-Skylar/excelize/xmlDrawing.go
+++ b/vendor/github.com/360EntSecGroup-Skylar/excelize/xmlDrawing.go
@@ -1,3 +1,12 @@
+// Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of
+// this source code is governed by a BSD-style license that can be found in
+// the LICENSE file.
+//
+// Package excelize providing a set of functions that allow you to write to
+// and read from XLSX files. Support reads and writes XLSX file generated by
+// Microsoft Excel™ 2007 and later. Support save file without losing original
+// charts of XLSX. This library needs Go version 1.8 or later.
+
package excelize
import "encoding/xml"
diff --git a/vendor/github.com/360EntSecGroup-Skylar/excelize/xmlSharedStrings.go b/vendor/github.com/360EntSecGroup-Skylar/excelize/xmlSharedStrings.go
index c8b54a013a..782ed61ad5 100644
--- a/vendor/github.com/360EntSecGroup-Skylar/excelize/xmlSharedStrings.go
+++ b/vendor/github.com/360EntSecGroup-Skylar/excelize/xmlSharedStrings.go
@@ -1,3 +1,12 @@
+// Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of
+// this source code is governed by a BSD-style license that can be found in
+// the LICENSE file.
+//
+// Package excelize providing a set of functions that allow you to write to
+// and read from XLSX files. Support reads and writes XLSX file generated by
+// Microsoft Excel™ 2007 and later. Support save file without losing original
+// charts of XLSX. This library needs Go version 1.8 or later.
+
package excelize
import "encoding/xml"
diff --git a/vendor/github.com/360EntSecGroup-Skylar/excelize/xmlStyles.go b/vendor/github.com/360EntSecGroup-Skylar/excelize/xmlStyles.go
index 05ff22bc4d..7ba4379148 100644
--- a/vendor/github.com/360EntSecGroup-Skylar/excelize/xmlStyles.go
+++ b/vendor/github.com/360EntSecGroup-Skylar/excelize/xmlStyles.go
@@ -1,3 +1,12 @@
+// Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of
+// this source code is governed by a BSD-style license that can be found in
+// the LICENSE file.
+//
+// Package excelize providing a set of functions that allow you to write to
+// and read from XLSX files. Support reads and writes XLSX file generated by
+// Microsoft Excel™ 2007 and later. Support save file without losing original
+// charts of XLSX. This library needs Go version 1.8 or later.
+
package excelize
import "encoding/xml"
diff --git a/vendor/github.com/360EntSecGroup-Skylar/excelize/xmlTable.go b/vendor/github.com/360EntSecGroup-Skylar/excelize/xmlTable.go
index b238350267..7e155e6d72 100644
--- a/vendor/github.com/360EntSecGroup-Skylar/excelize/xmlTable.go
+++ b/vendor/github.com/360EntSecGroup-Skylar/excelize/xmlTable.go
@@ -1,3 +1,12 @@
+// Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of
+// this source code is governed by a BSD-style license that can be found in
+// the LICENSE file.
+//
+// Package excelize providing a set of functions that allow you to write to
+// and read from XLSX files. Support reads and writes XLSX file generated by
+// Microsoft Excel™ 2007 and later. Support save file without losing original
+// charts of XLSX. This library needs Go version 1.8 or later.
+
package excelize
import "encoding/xml"
diff --git a/vendor/github.com/360EntSecGroup-Skylar/excelize/xmlTheme.go b/vendor/github.com/360EntSecGroup-Skylar/excelize/xmlTheme.go
new file mode 100644
index 0000000000..b4140b6acd
--- /dev/null
+++ b/vendor/github.com/360EntSecGroup-Skylar/excelize/xmlTheme.go
@@ -0,0 +1,149 @@
+// Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of
+// this source code is governed by a BSD-style license that can be found in
+// the LICENSE file.
+//
+// Package excelize providing a set of functions that allow you to write to
+// and read from XLSX files. Support reads and writes XLSX file generated by
+// Microsoft Excel™ 2007 and later. Support save file without losing original
+// charts of XLSX. This library needs Go version 1.8 or later.
+
+package excelize
+
+import "encoding/xml"
+
+// xlsxTheme directly maps the theme element in the namespace
+// http://schemas.openxmlformats.org/drawingml/2006/main
+type xlsxTheme struct {
+ ThemeElements xlsxThemeElements `xml:"themeElements"`
+ ObjectDefaults xlsxObjectDefaults `xml:"objectDefaults"`
+ ExtraClrSchemeLst xlsxExtraClrSchemeLst `xml:"extraClrSchemeLst"`
+ ExtLst *xlsxExtLst `xml:"extLst"`
+}
+
+// objectDefaults element allows for the definition of default shape, line,
+// and textbox formatting properties. An application can use this information
+// to format a shape (or text) initially on insertion into a document.
+type xlsxObjectDefaults struct {
+ ObjectDefaults string `xml:",innerxml"`
+}
+
+// xlsxExtraClrSchemeLst element is a container for the list of extra color
+// schemes present in a document.
+type xlsxExtraClrSchemeLst struct {
+ ExtraClrSchemeLst string `xml:",innerxml"`
+}
+
+// xlsxThemeElements directly maps the element defines the theme formatting
+// options for the theme and is the workhorse of the theme. This is where the
+// bulk of the shared theme information is contained and used by a document.
+// This element contains the color scheme, font scheme, and format scheme
+// elements which define the different formatting aspects of what a theme
+// defines.
+type xlsxThemeElements struct {
+ ClrScheme xlsxClrScheme `xml:"clrScheme"`
+ FontScheme xlsxFontScheme `xml:"fontScheme"`
+ FmtScheme xlsxFmtScheme `xml:"fmtScheme"`
+}
+
+// xlsxClrScheme element specifies the theme color, stored in the document's
+// Theme part to which the value of this theme color shall be mapped. This
+// mapping enables multiple theme colors to be chained together.
+type xlsxClrScheme struct {
+ Name string `xml:"name,attr"`
+ Children []xlsxClrSchemeEl `xml:",any"`
+}
+
+// xlsxFontScheme element defines the font scheme within the theme. The font
+// scheme consists of a pair of major and minor fonts for which to use in a
+// document. The major font corresponds well with the heading areas of a
+// document, and the minor font corresponds well with the normal text or
+// paragraph areas.
+type xlsxFontScheme struct {
+ Name string `xml:"name,attr"`
+ MajorFont xlsxMajorFont `xml:"majorFont"`
+ MinorFont xlsxMinorFont `xml:"minorFont"`
+ ExtLst *xlsxExtLst `xml:"extLst"`
+}
+
+// xlsxMajorFont element defines the set of major fonts which are to be used
+// under different languages or locals.
+type xlsxMajorFont struct {
+ Children []xlsxFontSchemeEl `xml:",any"`
+}
+
+// xlsxMinorFont element defines the set of minor fonts that are to be used
+// under different languages or locals.
+type xlsxMinorFont struct {
+ Children []xlsxFontSchemeEl `xml:",any"`
+}
+
+// xlsxFmtScheme element contains the background fill styles, effect styles,
+// fill styles, and line styles which define the style matrix for a theme. The
+// style matrix consists of subtle, moderate, and intense fills, lines, and
+// effects. The background fills are not generally thought of to directly be
+// associated with the matrix, but do play a role in the style of the overall
+// document. Usually, a given object chooses a single line style, a single
+// fill style, and a single effect style in order to define the overall final
+// look of the object.
+type xlsxFmtScheme struct {
+ Name string `xml:"name,attr"`
+ FillStyleLst xlsxFillStyleLst `xml:"fillStyleLst"`
+ LnStyleLst xlsxLnStyleLst `xml:"lnStyleLst"`
+ EffectStyleLst xlsxEffectStyleLst `xml:"effectStyleLst"`
+ BgFillStyleLst xlsxBgFillStyleLst `xml:"bgFillStyleLst"`
+}
+
+// xlsxFillStyleLst element defines a set of three fill styles that are used
+// within a theme. The three fill styles are arranged in order from subtle to
+// moderate to intense.
+type xlsxFillStyleLst struct {
+ FillStyleLst string `xml:",innerxml"`
+}
+
+// xlsxLnStyleLst element defines a list of three line styles for use within a
+// theme. The three line styles are arranged in order from subtle to moderate
+// to intense versions of lines. This list makes up part of the style matrix.
+type xlsxLnStyleLst struct {
+ LnStyleLst string `xml:",innerxml"`
+}
+
+// xlsxEffectStyleLst element defines a set of three effect styles that create
+// the effect style list for a theme. The effect styles are arranged in order
+// of subtle to moderate to intense.
+type xlsxEffectStyleLst struct {
+ EffectStyleLst string `xml:",innerxml"`
+}
+
+// xlsxBgFillStyleLst element defines a list of background fills that are
+// used within a theme. The background fills consist of three fills, arranged
+// in order from subtle to moderate to intense.
+type xlsxBgFillStyleLst struct {
+ BgFillStyleLst string `xml:",innerxml"`
+}
+
+// xlsxClrScheme maps to children of the clrScheme element in the namespace
+// http://schemas.openxmlformats.org/drawingml/2006/main - currently I have
+// not checked it for completeness - it does as much as I need.
+type xlsxClrSchemeEl struct {
+ XMLName xml.Name
+ SysClr *xlsxSysClr `xml:"sysClr"`
+ SrgbClr *attrValString `xml:"srgbClr"`
+}
+
+// xlsxFontSchemeEl directly maps the major and minor font of the style's font
+// scheme.
+type xlsxFontSchemeEl struct {
+ XMLName xml.Name
+ Script string `xml:"script,attr,omitempty"`
+ Typeface string `xml:"typeface,attr"`
+ Panose string `xml:"panose,attr,omitempty"`
+ PitchFamily string `xml:"pitchFamily,attr,omitempty"`
+ Charset string `xml:"charset,attr,omitempty"`
+}
+
+// xlsxSysClr element specifies a color bound to predefined operating system
+// elements.
+type xlsxSysClr struct {
+ Val string `xml:"val,attr"`
+ LastClr string `xml:"lastClr,attr"`
+}
diff --git a/vendor/github.com/360EntSecGroup-Skylar/excelize/xmlWorkbook.go b/vendor/github.com/360EntSecGroup-Skylar/excelize/xmlWorkbook.go
index 816d5a4617..f00a0b8584 100644
--- a/vendor/github.com/360EntSecGroup-Skylar/excelize/xmlWorkbook.go
+++ b/vendor/github.com/360EntSecGroup-Skylar/excelize/xmlWorkbook.go
@@ -1,3 +1,12 @@
+// Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of
+// this source code is governed by a BSD-style license that can be found in
+// the LICENSE file.
+//
+// Package excelize providing a set of functions that allow you to write to
+// and read from XLSX files. Support reads and writes XLSX file generated by
+// Microsoft Excel™ 2007 and later. Support save file without losing original
+// charts of XLSX. This library needs Go version 1.8 or later.
+
package excelize
import "encoding/xml"
diff --git a/vendor/github.com/360EntSecGroup-Skylar/excelize/xmlWorksheet.go b/vendor/github.com/360EntSecGroup-Skylar/excelize/xmlWorksheet.go
index 37c0d18e0d..072ecce6da 100644
--- a/vendor/github.com/360EntSecGroup-Skylar/excelize/xmlWorksheet.go
+++ b/vendor/github.com/360EntSecGroup-Skylar/excelize/xmlWorksheet.go
@@ -1,3 +1,12 @@
+// Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of
+// this source code is governed by a BSD-style license that can be found in
+// the LICENSE file.
+//
+// Package excelize providing a set of functions that allow you to write to
+// and read from XLSX files. Support reads and writes XLSX file generated by
+// Microsoft Excel™ 2007 and later. Support save file without losing original
+// charts of XLSX. This library needs Go version 1.8 or later.
+
package excelize
import "encoding/xml"
@@ -18,7 +27,7 @@ type xlsxWorksheet struct {
MergeCells *xlsxMergeCells `xml:"mergeCells"`
PhoneticPr *xlsxPhoneticPr `xml:"phoneticPr"`
ConditionalFormatting []*xlsxConditionalFormatting `xml:"conditionalFormatting"`
- DataValidations *xlsxDataValidations `xml:"dataValidations"`
+ DataValidations *xlsxDataValidations `xml:"dataValidations,omitempty"`
Hyperlinks *xlsxHyperlinks `xml:"hyperlinks"`
PrintOptions *xlsxPrintOptions `xml:"printOptions"`
PageMargins *xlsxPageMargins `xml:"pageMargins"`
@@ -294,11 +303,30 @@ type xlsxMergeCells struct {
// xlsxDataValidations expresses all data validation information for cells in a
// sheet which have data validation features applied.
type xlsxDataValidations struct {
- Count int `xml:"count,attr,omitempty"`
- DisablePrompts bool `xml:"disablePrompts,attr,omitempty"`
- XWindow int `xml:"xWindow,attr,omitempty"`
- YWindow int `xml:"yWindow,attr,omitempty"`
- DataValidation string `xml:",innerxml"`
+ Count int `xml:"count,attr,omitempty"`
+ DisablePrompts bool `xml:"disablePrompts,attr,omitempty"`
+ XWindow int `xml:"xWindow,attr,omitempty"`
+ YWindow int `xml:"yWindow,attr,omitempty"`
+ DataValidation []*DataValidation `xml:"dataValidation"`
+}
+
+// DataValidation directly maps the a single item of data validation defined
+// on a range of the worksheet.
+type DataValidation struct {
+ AllowBlank bool `xml:"allowBlank,attr"`
+ Error *string `xml:"error,attr"`
+ ErrorStyle *string `xml:"errorStyle,attr"`
+ ErrorTitle *string `xml:"errorTitle,attr"`
+ Operator string `xml:"operator,attr"`
+ Prompt *string `xml:"prompt,attr"`
+ PromptTitle *string `xml:"promptTitle"`
+ ShowDropDown bool `xml:"showDropDown,attr"`
+ ShowErrorMessage bool `xml:"showErrorMessage,attr"`
+ ShowInputMessage bool `xml:"showInputMessage,attr"`
+ Sqref string `xml:"sqref,attr"`
+ Type string `xml:"type,attr"`
+ Formula1 string `xml:"formula1"`
+ Formula2 string `xml:"formula2"`
}
// xlsxC directly maps the c element in the namespace
@@ -446,7 +474,7 @@ type xlsxIconSet struct {
type xlsxCfvo struct {
Gte bool `xml:"gte,attr,omitempty"`
Type string `xml:"type,attr,omitempty"`
- Val int `xml:"val,attr"`
+ Val string `xml:"val,attr"`
ExtLst *xlsxExtLst `xml:"extLst"`
}
diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-04-01/compute/models.go b/vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-04-01/compute/models.go
index 166790d037..cc4bc86732 100644
--- a/vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-04-01/compute/models.go
+++ b/vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-04-01/compute/models.go
@@ -798,84 +798,6 @@ func PossibleVirtualMachineSizeTypesValues() []VirtualMachineSizeTypes {
// AccessURI a disk access SAS uri.
type AccessURI struct {
autorest.Response `json:"-"`
- // AccessURIOutput - Operation output data (raw JSON)
- *AccessURIOutput `json:"properties,omitempty"`
-}
-
-// MarshalJSON is the custom marshaler for AccessURI.
-func (au AccessURI) MarshalJSON() ([]byte, error) {
- objectMap := make(map[string]interface{})
- if au.AccessURIOutput != nil {
- objectMap["properties"] = au.AccessURIOutput
- }
- return json.Marshal(objectMap)
-}
-
-// UnmarshalJSON is the custom unmarshaler for AccessURI struct.
-func (au *AccessURI) UnmarshalJSON(body []byte) error {
- var m map[string]*json.RawMessage
- err := json.Unmarshal(body, &m)
- if err != nil {
- return err
- }
- for k, v := range m {
- switch k {
- case "properties":
- if v != nil {
- var accessURIOutput AccessURIOutput
- err = json.Unmarshal(*v, &accessURIOutput)
- if err != nil {
- return err
- }
- au.AccessURIOutput = &accessURIOutput
- }
- }
- }
-
- return nil
-}
-
-// AccessURIOutput azure properties, including output.
-type AccessURIOutput struct {
- // AccessURIRaw - Operation output data (raw JSON)
- *AccessURIRaw `json:"output,omitempty"`
-}
-
-// MarshalJSON is the custom marshaler for AccessURIOutput.
-func (auo AccessURIOutput) MarshalJSON() ([]byte, error) {
- objectMap := make(map[string]interface{})
- if auo.AccessURIRaw != nil {
- objectMap["output"] = auo.AccessURIRaw
- }
- return json.Marshal(objectMap)
-}
-
-// UnmarshalJSON is the custom unmarshaler for AccessURIOutput struct.
-func (auo *AccessURIOutput) UnmarshalJSON(body []byte) error {
- var m map[string]*json.RawMessage
- err := json.Unmarshal(body, &m)
- if err != nil {
- return err
- }
- for k, v := range m {
- switch k {
- case "output":
- if v != nil {
- var accessURIRaw AccessURIRaw
- err = json.Unmarshal(*v, &accessURIRaw)
- if err != nil {
- return err
- }
- auo.AccessURIRaw = &accessURIRaw
- }
- }
- }
-
- return nil
-}
-
-// AccessURIRaw a disk access SAS uri.
-type AccessURIRaw struct {
// AccessSAS - A SAS uri for accessing a disk.
AccessSAS *string `json:"accessSAS,omitempty"`
}
@@ -1290,7 +1212,7 @@ type DataDisk struct {
WriteAcceleratorEnabled *bool `json:"writeAcceleratorEnabled,omitempty"`
// CreateOption - Specifies how the virtual machine should be created.
Possible values are:
**Attach** \u2013 This value is used when you are using a specialized disk to create the virtual machine.
**FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the plan element previously described. Possible values include: 'DiskCreateOptionTypesFromImage', 'DiskCreateOptionTypesEmpty', 'DiskCreateOptionTypesAttach'
CreateOption DiskCreateOptionTypes `json:"createOption,omitempty"`
- // DiskSizeGB - Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image.
This value cannot be larger than 1023 GB
+ // DiskSizeGB - Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image.
This value cannot be larger than 1023 GB
DiskSizeGB *int32 `json:"diskSizeGB,omitempty"`
// ManagedDisk - The managed disk parameters.
ManagedDisk *ManagedDiskParameters `json:"managedDisk,omitempty"`
@@ -2718,7 +2640,7 @@ type OSDisk struct {
WriteAcceleratorEnabled *bool `json:"writeAcceleratorEnabled,omitempty"`
// CreateOption - Specifies how the virtual machine should be created.
Possible values are:
**Attach** \u2013 This value is used when you are using a specialized disk to create the virtual machine.
**FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the plan element previously described. Possible values include: 'DiskCreateOptionTypesFromImage', 'DiskCreateOptionTypesEmpty', 'DiskCreateOptionTypesAttach'
CreateOption DiskCreateOptionTypes `json:"createOption,omitempty"`
- // DiskSizeGB - Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image.
This value cannot be larger than 1023 GB
+ // DiskSizeGB - Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image.
This value cannot be larger than 1023 GB
DiskSizeGB *int32 `json:"diskSizeGB,omitempty"`
// ManagedDisk - The managed disk parameters.
ManagedDisk *ManagedDiskParameters `json:"managedDisk,omitempty"`
diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-06-01/compute/client.go b/vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-06-01/compute/client.go
index 705592e74b..b23c9ca742 100644
--- a/vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-06-01/compute/client.go
+++ b/vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-06-01/compute/client.go
@@ -1,4 +1,4 @@
-// Package compute implements the Azure ARM Compute service API version 2018-06-01.
+// Package compute implements the Azure ARM Compute service API version .
//
// Compute Client
package compute
diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-06-01/compute/containerservices.go b/vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-06-01/compute/containerservices.go
new file mode 100644
index 0000000000..b16788bfa5
--- /dev/null
+++ b/vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-06-01/compute/containerservices.go
@@ -0,0 +1,475 @@
+package compute
+
+// Copyright (c) Microsoft and contributors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+import (
+ "context"
+ "github.com/Azure/go-autorest/autorest"
+ "github.com/Azure/go-autorest/autorest/azure"
+ "github.com/Azure/go-autorest/autorest/validation"
+ "net/http"
+)
+
+// ContainerServicesClient is the compute Client
+type ContainerServicesClient struct {
+ BaseClient
+}
+
+// NewContainerServicesClient creates an instance of the ContainerServicesClient client.
+func NewContainerServicesClient(subscriptionID string) ContainerServicesClient {
+ return NewContainerServicesClientWithBaseURI(DefaultBaseURI, subscriptionID)
+}
+
+// NewContainerServicesClientWithBaseURI creates an instance of the ContainerServicesClient client.
+func NewContainerServicesClientWithBaseURI(baseURI string, subscriptionID string) ContainerServicesClient {
+ return ContainerServicesClient{NewWithBaseURI(baseURI, subscriptionID)}
+}
+
+// CreateOrUpdate creates or updates a container service with the specified configuration of orchestrator, masters, and
+// agents.
+// Parameters:
+// resourceGroupName - the name of the resource group.
+// containerServiceName - the name of the container service in the specified subscription and resource group.
+// parameters - parameters supplied to the Create or Update a Container Service operation.
+func (client ContainerServicesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, containerServiceName string, parameters ContainerService) (result ContainerServicesCreateOrUpdateFuture, err error) {
+ if err := validation.Validate([]validation.Validation{
+ {TargetValue: parameters,
+ Constraints: []validation.Constraint{{Target: "parameters.ContainerServiceProperties", Name: validation.Null, Rule: false,
+ Chain: []validation.Constraint{{Target: "parameters.ContainerServiceProperties.CustomProfile", Name: validation.Null, Rule: false,
+ Chain: []validation.Constraint{{Target: "parameters.ContainerServiceProperties.CustomProfile.Orchestrator", Name: validation.Null, Rule: true, Chain: nil}}},
+ {Target: "parameters.ContainerServiceProperties.ServicePrincipalProfile", Name: validation.Null, Rule: false,
+ Chain: []validation.Constraint{{Target: "parameters.ContainerServiceProperties.ServicePrincipalProfile.ClientID", Name: validation.Null, Rule: true, Chain: nil},
+ {Target: "parameters.ContainerServiceProperties.ServicePrincipalProfile.Secret", Name: validation.Null, Rule: true, Chain: nil},
+ }},
+ {Target: "parameters.ContainerServiceProperties.MasterProfile", Name: validation.Null, Rule: true,
+ Chain: []validation.Constraint{{Target: "parameters.ContainerServiceProperties.MasterProfile.DNSPrefix", Name: validation.Null, Rule: true, Chain: nil}}},
+ {Target: "parameters.ContainerServiceProperties.AgentPoolProfiles", Name: validation.Null, Rule: true, Chain: nil},
+ {Target: "parameters.ContainerServiceProperties.WindowsProfile", Name: validation.Null, Rule: false,
+ Chain: []validation.Constraint{{Target: "parameters.ContainerServiceProperties.WindowsProfile.AdminUsername", Name: validation.Null, Rule: true,
+ Chain: []validation.Constraint{{Target: "parameters.ContainerServiceProperties.WindowsProfile.AdminUsername", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+([._]?[a-zA-Z0-9]+)*$`, Chain: nil}}},
+ {Target: "parameters.ContainerServiceProperties.WindowsProfile.AdminPassword", Name: validation.Null, Rule: true, Chain: nil},
+ }},
+ {Target: "parameters.ContainerServiceProperties.LinuxProfile", Name: validation.Null, Rule: true,
+ Chain: []validation.Constraint{{Target: "parameters.ContainerServiceProperties.LinuxProfile.AdminUsername", Name: validation.Null, Rule: true,
+ Chain: []validation.Constraint{{Target: "parameters.ContainerServiceProperties.LinuxProfile.AdminUsername", Name: validation.Pattern, Rule: `^[a-z][a-z0-9_-]*$`, Chain: nil}}},
+ {Target: "parameters.ContainerServiceProperties.LinuxProfile.SSH", Name: validation.Null, Rule: true,
+ Chain: []validation.Constraint{{Target: "parameters.ContainerServiceProperties.LinuxProfile.SSH.PublicKeys", Name: validation.Null, Rule: true, Chain: nil}}},
+ }},
+ {Target: "parameters.ContainerServiceProperties.DiagnosticsProfile", Name: validation.Null, Rule: false,
+ Chain: []validation.Constraint{{Target: "parameters.ContainerServiceProperties.DiagnosticsProfile.VMDiagnostics", Name: validation.Null, Rule: true,
+ Chain: []validation.Constraint{{Target: "parameters.ContainerServiceProperties.DiagnosticsProfile.VMDiagnostics.Enabled", Name: validation.Null, Rule: true, Chain: nil}}},
+ }},
+ }}}}}); err != nil {
+ return result, validation.NewError("compute.ContainerServicesClient", "CreateOrUpdate", err.Error())
+ }
+
+ req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, containerServiceName, parameters)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "CreateOrUpdate", nil, "Failure preparing request")
+ return
+ }
+
+ result, err = client.CreateOrUpdateSender(req)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "CreateOrUpdate", result.Response(), "Failure sending request")
+ return
+ }
+
+ return
+}
+
+// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
+func (client ContainerServicesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, containerServiceName string, parameters ContainerService) (*http.Request, error) {
+ pathParameters := map[string]interface{}{
+ "containerServiceName": autorest.Encode("path", containerServiceName),
+ "resourceGroupName": autorest.Encode("path", resourceGroupName),
+ "subscriptionId": autorest.Encode("path", client.SubscriptionID),
+ }
+
+ const APIVersion = "2017-01-31"
+ queryParameters := map[string]interface{}{
+ "api-version": APIVersion,
+ }
+
+ preparer := autorest.CreatePreparer(
+ autorest.AsContentType("application/json; charset=utf-8"),
+ autorest.AsPut(),
+ autorest.WithBaseURL(client.BaseURI),
+ autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/containerServices/{containerServiceName}", pathParameters),
+ autorest.WithJSON(parameters),
+ autorest.WithQueryParameters(queryParameters))
+ return preparer.Prepare((&http.Request{}).WithContext(ctx))
+}
+
+// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
+// http.Response Body if it receives an error.
+func (client ContainerServicesClient) CreateOrUpdateSender(req *http.Request) (future ContainerServicesCreateOrUpdateFuture, err error) {
+ var resp *http.Response
+ resp, err = autorest.SendWithSender(client, req,
+ azure.DoRetryWithRegistration(client.Client))
+ if err != nil {
+ return
+ }
+ err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted))
+ if err != nil {
+ return
+ }
+ future.Future, err = azure.NewFutureFromResponse(resp)
+ return
+}
+
+// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
+// closes the http.Response Body.
+func (client ContainerServicesClient) CreateOrUpdateResponder(resp *http.Response) (result ContainerService, err error) {
+ err = autorest.Respond(
+ resp,
+ client.ByInspecting(),
+ azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted),
+ autorest.ByUnmarshallingJSON(&result),
+ autorest.ByClosing())
+ result.Response = autorest.Response{Response: resp}
+ return
+}
+
+// Delete deletes the specified container service in the specified subscription and resource group. The operation does
+// not delete other resources created as part of creating a container service, including storage accounts, VMs, and
+// availability sets. All the other resources created with the container service are part of the same resource group
+// and can be deleted individually.
+// Parameters:
+// resourceGroupName - the name of the resource group.
+// containerServiceName - the name of the container service in the specified subscription and resource group.
+func (client ContainerServicesClient) Delete(ctx context.Context, resourceGroupName string, containerServiceName string) (result ContainerServicesDeleteFuture, err error) {
+ req, err := client.DeletePreparer(ctx, resourceGroupName, containerServiceName)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "Delete", nil, "Failure preparing request")
+ return
+ }
+
+ result, err = client.DeleteSender(req)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "Delete", result.Response(), "Failure sending request")
+ return
+ }
+
+ return
+}
+
+// DeletePreparer prepares the Delete request.
+func (client ContainerServicesClient) DeletePreparer(ctx context.Context, resourceGroupName string, containerServiceName string) (*http.Request, error) {
+ pathParameters := map[string]interface{}{
+ "containerServiceName": autorest.Encode("path", containerServiceName),
+ "resourceGroupName": autorest.Encode("path", resourceGroupName),
+ "subscriptionId": autorest.Encode("path", client.SubscriptionID),
+ }
+
+ const APIVersion = "2017-01-31"
+ queryParameters := map[string]interface{}{
+ "api-version": APIVersion,
+ }
+
+ preparer := autorest.CreatePreparer(
+ autorest.AsDelete(),
+ autorest.WithBaseURL(client.BaseURI),
+ autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/containerServices/{containerServiceName}", pathParameters),
+ autorest.WithQueryParameters(queryParameters))
+ return preparer.Prepare((&http.Request{}).WithContext(ctx))
+}
+
+// DeleteSender sends the Delete request. The method will close the
+// http.Response Body if it receives an error.
+func (client ContainerServicesClient) DeleteSender(req *http.Request) (future ContainerServicesDeleteFuture, err error) {
+ var resp *http.Response
+ resp, err = autorest.SendWithSender(client, req,
+ azure.DoRetryWithRegistration(client.Client))
+ if err != nil {
+ return
+ }
+ err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent))
+ if err != nil {
+ return
+ }
+ future.Future, err = azure.NewFutureFromResponse(resp)
+ return
+}
+
+// DeleteResponder handles the response to the Delete request. The method always
+// closes the http.Response Body.
+func (client ContainerServicesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
+ err = autorest.Respond(
+ resp,
+ client.ByInspecting(),
+ azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
+ autorest.ByClosing())
+ result.Response = resp
+ return
+}
+
+// Get gets the properties of the specified container service in the specified subscription and resource group. The
+// operation returns the properties including state, orchestrator, number of masters and agents, and FQDNs of masters
+// and agents.
+// Parameters:
+// resourceGroupName - the name of the resource group.
+// containerServiceName - the name of the container service in the specified subscription and resource group.
+func (client ContainerServicesClient) Get(ctx context.Context, resourceGroupName string, containerServiceName string) (result ContainerService, err error) {
+ req, err := client.GetPreparer(ctx, resourceGroupName, containerServiceName)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "Get", nil, "Failure preparing request")
+ return
+ }
+
+ resp, err := client.GetSender(req)
+ if err != nil {
+ result.Response = autorest.Response{Response: resp}
+ err = autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "Get", resp, "Failure sending request")
+ return
+ }
+
+ result, err = client.GetResponder(resp)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "Get", resp, "Failure responding to request")
+ }
+
+ return
+}
+
+// GetPreparer prepares the Get request.
+func (client ContainerServicesClient) GetPreparer(ctx context.Context, resourceGroupName string, containerServiceName string) (*http.Request, error) {
+ pathParameters := map[string]interface{}{
+ "containerServiceName": autorest.Encode("path", containerServiceName),
+ "resourceGroupName": autorest.Encode("path", resourceGroupName),
+ "subscriptionId": autorest.Encode("path", client.SubscriptionID),
+ }
+
+ const APIVersion = "2017-01-31"
+ queryParameters := map[string]interface{}{
+ "api-version": APIVersion,
+ }
+
+ preparer := autorest.CreatePreparer(
+ autorest.AsGet(),
+ autorest.WithBaseURL(client.BaseURI),
+ autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/containerServices/{containerServiceName}", pathParameters),
+ autorest.WithQueryParameters(queryParameters))
+ return preparer.Prepare((&http.Request{}).WithContext(ctx))
+}
+
+// GetSender sends the Get request. The method will close the
+// http.Response Body if it receives an error.
+func (client ContainerServicesClient) GetSender(req *http.Request) (*http.Response, error) {
+ return autorest.SendWithSender(client, req,
+ azure.DoRetryWithRegistration(client.Client))
+}
+
+// GetResponder handles the response to the Get request. The method always
+// closes the http.Response Body.
+func (client ContainerServicesClient) GetResponder(resp *http.Response) (result ContainerService, err error) {
+ err = autorest.Respond(
+ resp,
+ client.ByInspecting(),
+ azure.WithErrorUnlessStatusCode(http.StatusOK),
+ autorest.ByUnmarshallingJSON(&result),
+ autorest.ByClosing())
+ result.Response = autorest.Response{Response: resp}
+ return
+}
+
+// List gets a list of container services in the specified subscription. The operation returns properties of each
+// container service including state, orchestrator, number of masters and agents, and FQDNs of masters and agents.
+func (client ContainerServicesClient) List(ctx context.Context) (result ContainerServiceListResultPage, err error) {
+ result.fn = client.listNextResults
+ req, err := client.ListPreparer(ctx)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "List", nil, "Failure preparing request")
+ return
+ }
+
+ resp, err := client.ListSender(req)
+ if err != nil {
+ result.cslr.Response = autorest.Response{Response: resp}
+ err = autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "List", resp, "Failure sending request")
+ return
+ }
+
+ result.cslr, err = client.ListResponder(resp)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "List", resp, "Failure responding to request")
+ }
+
+ return
+}
+
+// ListPreparer prepares the List request.
+func (client ContainerServicesClient) ListPreparer(ctx context.Context) (*http.Request, error) {
+ pathParameters := map[string]interface{}{
+ "subscriptionId": autorest.Encode("path", client.SubscriptionID),
+ }
+
+ const APIVersion = "2017-01-31"
+ queryParameters := map[string]interface{}{
+ "api-version": APIVersion,
+ }
+
+ preparer := autorest.CreatePreparer(
+ autorest.AsGet(),
+ autorest.WithBaseURL(client.BaseURI),
+ autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.ContainerService/containerServices", pathParameters),
+ autorest.WithQueryParameters(queryParameters))
+ return preparer.Prepare((&http.Request{}).WithContext(ctx))
+}
+
+// ListSender sends the List request. The method will close the
+// http.Response Body if it receives an error.
+func (client ContainerServicesClient) ListSender(req *http.Request) (*http.Response, error) {
+ return autorest.SendWithSender(client, req,
+ azure.DoRetryWithRegistration(client.Client))
+}
+
+// ListResponder handles the response to the List request. The method always
+// closes the http.Response Body.
+func (client ContainerServicesClient) ListResponder(resp *http.Response) (result ContainerServiceListResult, err error) {
+ err = autorest.Respond(
+ resp,
+ client.ByInspecting(),
+ azure.WithErrorUnlessStatusCode(http.StatusOK),
+ autorest.ByUnmarshallingJSON(&result),
+ autorest.ByClosing())
+ result.Response = autorest.Response{Response: resp}
+ return
+}
+
+// listNextResults retrieves the next set of results, if any.
+func (client ContainerServicesClient) listNextResults(lastResults ContainerServiceListResult) (result ContainerServiceListResult, err error) {
+ req, err := lastResults.containerServiceListResultPreparer()
+ if err != nil {
+ return result, autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "listNextResults", nil, "Failure preparing next results request")
+ }
+ if req == nil {
+ return
+ }
+ resp, err := client.ListSender(req)
+ if err != nil {
+ result.Response = autorest.Response{Response: resp}
+ return result, autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "listNextResults", resp, "Failure sending next results request")
+ }
+ result, err = client.ListResponder(resp)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "listNextResults", resp, "Failure responding to next results request")
+ }
+ return
+}
+
+// ListComplete enumerates all values, automatically crossing page boundaries as required.
+func (client ContainerServicesClient) ListComplete(ctx context.Context) (result ContainerServiceListResultIterator, err error) {
+ result.page, err = client.List(ctx)
+ return
+}
+
+// ListByResourceGroup gets a list of container services in the specified subscription and resource group. The
+// operation returns properties of each container service including state, orchestrator, number of masters and agents,
+// and FQDNs of masters and agents.
+// Parameters:
+// resourceGroupName - the name of the resource group.
+func (client ContainerServicesClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ContainerServiceListResultPage, err error) {
+ result.fn = client.listByResourceGroupNextResults
+ req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "ListByResourceGroup", nil, "Failure preparing request")
+ return
+ }
+
+ resp, err := client.ListByResourceGroupSender(req)
+ if err != nil {
+ result.cslr.Response = autorest.Response{Response: resp}
+ err = autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "ListByResourceGroup", resp, "Failure sending request")
+ return
+ }
+
+ result.cslr, err = client.ListByResourceGroupResponder(resp)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "ListByResourceGroup", resp, "Failure responding to request")
+ }
+
+ return
+}
+
+// ListByResourceGroupPreparer prepares the ListByResourceGroup request.
+func (client ContainerServicesClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) {
+ pathParameters := map[string]interface{}{
+ "resourceGroupName": autorest.Encode("path", resourceGroupName),
+ "subscriptionId": autorest.Encode("path", client.SubscriptionID),
+ }
+
+ const APIVersion = "2017-01-31"
+ queryParameters := map[string]interface{}{
+ "api-version": APIVersion,
+ }
+
+ preparer := autorest.CreatePreparer(
+ autorest.AsGet(),
+ autorest.WithBaseURL(client.BaseURI),
+ autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/containerServices", pathParameters),
+ autorest.WithQueryParameters(queryParameters))
+ return preparer.Prepare((&http.Request{}).WithContext(ctx))
+}
+
+// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the
+// http.Response Body if it receives an error.
+func (client ContainerServicesClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) {
+ return autorest.SendWithSender(client, req,
+ azure.DoRetryWithRegistration(client.Client))
+}
+
+// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always
+// closes the http.Response Body.
+func (client ContainerServicesClient) ListByResourceGroupResponder(resp *http.Response) (result ContainerServiceListResult, err error) {
+ err = autorest.Respond(
+ resp,
+ client.ByInspecting(),
+ azure.WithErrorUnlessStatusCode(http.StatusOK),
+ autorest.ByUnmarshallingJSON(&result),
+ autorest.ByClosing())
+ result.Response = autorest.Response{Response: resp}
+ return
+}
+
+// listByResourceGroupNextResults retrieves the next set of results, if any.
+func (client ContainerServicesClient) listByResourceGroupNextResults(lastResults ContainerServiceListResult) (result ContainerServiceListResult, err error) {
+ req, err := lastResults.containerServiceListResultPreparer()
+ if err != nil {
+ return result, autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request")
+ }
+ if req == nil {
+ return
+ }
+ resp, err := client.ListByResourceGroupSender(req)
+ if err != nil {
+ result.Response = autorest.Response{Response: resp}
+ return result, autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "listByResourceGroupNextResults", resp, "Failure sending next results request")
+ }
+ result, err = client.ListByResourceGroupResponder(resp)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request")
+ }
+ return
+}
+
+// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required.
+func (client ContainerServicesClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result ContainerServiceListResultIterator, err error) {
+ result.page, err = client.ListByResourceGroup(ctx, resourceGroupName)
+ return
+}
diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-06-01/compute/disks.go b/vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-06-01/compute/disks.go
new file mode 100644
index 0000000000..9cbbd79fd6
--- /dev/null
+++ b/vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-06-01/compute/disks.go
@@ -0,0 +1,692 @@
+package compute
+
+// Copyright (c) Microsoft and contributors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+import (
+ "context"
+ "github.com/Azure/go-autorest/autorest"
+ "github.com/Azure/go-autorest/autorest/azure"
+ "github.com/Azure/go-autorest/autorest/validation"
+ "net/http"
+)
+
+// DisksClient is the compute Client
+type DisksClient struct {
+ BaseClient
+}
+
+// NewDisksClient creates an instance of the DisksClient client.
+func NewDisksClient(subscriptionID string) DisksClient {
+ return NewDisksClientWithBaseURI(DefaultBaseURI, subscriptionID)
+}
+
+// NewDisksClientWithBaseURI creates an instance of the DisksClient client.
+func NewDisksClientWithBaseURI(baseURI string, subscriptionID string) DisksClient {
+ return DisksClient{NewWithBaseURI(baseURI, subscriptionID)}
+}
+
+// CreateOrUpdate creates or updates a disk.
+// Parameters:
+// resourceGroupName - the name of the resource group.
+// diskName - the name of the managed disk that is being created. The name can't be changed after the disk is
+// created. Supported characters for the name are a-z, A-Z, 0-9 and _. The maximum name length is 80
+// characters.
+// disk - disk object supplied in the body of the Put disk operation.
+func (client DisksClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, diskName string, disk Disk) (result DisksCreateOrUpdateFuture, err error) {
+ if err := validation.Validate([]validation.Validation{
+ {TargetValue: disk,
+ Constraints: []validation.Constraint{{Target: "disk.DiskProperties", Name: validation.Null, Rule: false,
+ Chain: []validation.Constraint{{Target: "disk.DiskProperties.CreationData", Name: validation.Null, Rule: true,
+ Chain: []validation.Constraint{{Target: "disk.DiskProperties.CreationData.ImageReference", Name: validation.Null, Rule: false,
+ Chain: []validation.Constraint{{Target: "disk.DiskProperties.CreationData.ImageReference.ID", Name: validation.Null, Rule: true, Chain: nil}}},
+ }},
+ {Target: "disk.DiskProperties.EncryptionSettings", Name: validation.Null, Rule: false,
+ Chain: []validation.Constraint{{Target: "disk.DiskProperties.EncryptionSettings.DiskEncryptionKey", Name: validation.Null, Rule: false,
+ Chain: []validation.Constraint{{Target: "disk.DiskProperties.EncryptionSettings.DiskEncryptionKey.SourceVault", Name: validation.Null, Rule: true, Chain: nil},
+ {Target: "disk.DiskProperties.EncryptionSettings.DiskEncryptionKey.SecretURL", Name: validation.Null, Rule: true, Chain: nil},
+ }},
+ {Target: "disk.DiskProperties.EncryptionSettings.KeyEncryptionKey", Name: validation.Null, Rule: false,
+ Chain: []validation.Constraint{{Target: "disk.DiskProperties.EncryptionSettings.KeyEncryptionKey.SourceVault", Name: validation.Null, Rule: true, Chain: nil},
+ {Target: "disk.DiskProperties.EncryptionSettings.KeyEncryptionKey.KeyURL", Name: validation.Null, Rule: true, Chain: nil},
+ }},
+ }},
+ }}}}}); err != nil {
+ return result, validation.NewError("compute.DisksClient", "CreateOrUpdate", err.Error())
+ }
+
+ req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, diskName, disk)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.DisksClient", "CreateOrUpdate", nil, "Failure preparing request")
+ return
+ }
+
+ result, err = client.CreateOrUpdateSender(req)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.DisksClient", "CreateOrUpdate", result.Response(), "Failure sending request")
+ return
+ }
+
+ return
+}
+
+// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
+func (client DisksClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, diskName string, disk Disk) (*http.Request, error) {
+ pathParameters := map[string]interface{}{
+ "diskName": autorest.Encode("path", diskName),
+ "resourceGroupName": autorest.Encode("path", resourceGroupName),
+ "subscriptionId": autorest.Encode("path", client.SubscriptionID),
+ }
+
+ const APIVersion = "2018-06-01"
+ queryParameters := map[string]interface{}{
+ "api-version": APIVersion,
+ }
+
+ preparer := autorest.CreatePreparer(
+ autorest.AsContentType("application/json; charset=utf-8"),
+ autorest.AsPut(),
+ autorest.WithBaseURL(client.BaseURI),
+ autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}", pathParameters),
+ autorest.WithJSON(disk),
+ autorest.WithQueryParameters(queryParameters))
+ return preparer.Prepare((&http.Request{}).WithContext(ctx))
+}
+
+// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
+// http.Response Body if it receives an error.
+func (client DisksClient) CreateOrUpdateSender(req *http.Request) (future DisksCreateOrUpdateFuture, err error) {
+ var resp *http.Response
+ resp, err = autorest.SendWithSender(client, req,
+ azure.DoRetryWithRegistration(client.Client))
+ if err != nil {
+ return
+ }
+ err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted))
+ if err != nil {
+ return
+ }
+ future.Future, err = azure.NewFutureFromResponse(resp)
+ return
+}
+
+// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
+// closes the http.Response Body.
+func (client DisksClient) CreateOrUpdateResponder(resp *http.Response) (result Disk, err error) {
+ err = autorest.Respond(
+ resp,
+ client.ByInspecting(),
+ azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
+ autorest.ByUnmarshallingJSON(&result),
+ autorest.ByClosing())
+ result.Response = autorest.Response{Response: resp}
+ return
+}
+
+// Delete deletes a disk.
+// Parameters:
+// resourceGroupName - the name of the resource group.
+// diskName - the name of the managed disk that is being created. The name can't be changed after the disk is
+// created. Supported characters for the name are a-z, A-Z, 0-9 and _. The maximum name length is 80
+// characters.
+func (client DisksClient) Delete(ctx context.Context, resourceGroupName string, diskName string) (result DisksDeleteFuture, err error) {
+ req, err := client.DeletePreparer(ctx, resourceGroupName, diskName)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.DisksClient", "Delete", nil, "Failure preparing request")
+ return
+ }
+
+ result, err = client.DeleteSender(req)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.DisksClient", "Delete", result.Response(), "Failure sending request")
+ return
+ }
+
+ return
+}
+
+// DeletePreparer prepares the Delete request.
+func (client DisksClient) DeletePreparer(ctx context.Context, resourceGroupName string, diskName string) (*http.Request, error) {
+ pathParameters := map[string]interface{}{
+ "diskName": autorest.Encode("path", diskName),
+ "resourceGroupName": autorest.Encode("path", resourceGroupName),
+ "subscriptionId": autorest.Encode("path", client.SubscriptionID),
+ }
+
+ const APIVersion = "2018-06-01"
+ queryParameters := map[string]interface{}{
+ "api-version": APIVersion,
+ }
+
+ preparer := autorest.CreatePreparer(
+ autorest.AsDelete(),
+ autorest.WithBaseURL(client.BaseURI),
+ autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}", pathParameters),
+ autorest.WithQueryParameters(queryParameters))
+ return preparer.Prepare((&http.Request{}).WithContext(ctx))
+}
+
+// DeleteSender sends the Delete request. The method will close the
+// http.Response Body if it receives an error.
+func (client DisksClient) DeleteSender(req *http.Request) (future DisksDeleteFuture, err error) {
+ var resp *http.Response
+ resp, err = autorest.SendWithSender(client, req,
+ azure.DoRetryWithRegistration(client.Client))
+ if err != nil {
+ return
+ }
+ err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent))
+ if err != nil {
+ return
+ }
+ future.Future, err = azure.NewFutureFromResponse(resp)
+ return
+}
+
+// DeleteResponder handles the response to the Delete request. The method always
+// closes the http.Response Body.
+func (client DisksClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
+ err = autorest.Respond(
+ resp,
+ client.ByInspecting(),
+ azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
+ autorest.ByClosing())
+ result.Response = resp
+ return
+}
+
+// Get gets information about a disk.
+// Parameters:
+// resourceGroupName - the name of the resource group.
+// diskName - the name of the managed disk that is being created. The name can't be changed after the disk is
+// created. Supported characters for the name are a-z, A-Z, 0-9 and _. The maximum name length is 80
+// characters.
+func (client DisksClient) Get(ctx context.Context, resourceGroupName string, diskName string) (result Disk, err error) {
+ req, err := client.GetPreparer(ctx, resourceGroupName, diskName)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.DisksClient", "Get", nil, "Failure preparing request")
+ return
+ }
+
+ resp, err := client.GetSender(req)
+ if err != nil {
+ result.Response = autorest.Response{Response: resp}
+ err = autorest.NewErrorWithError(err, "compute.DisksClient", "Get", resp, "Failure sending request")
+ return
+ }
+
+ result, err = client.GetResponder(resp)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.DisksClient", "Get", resp, "Failure responding to request")
+ }
+
+ return
+}
+
+// GetPreparer prepares the Get request.
+func (client DisksClient) GetPreparer(ctx context.Context, resourceGroupName string, diskName string) (*http.Request, error) {
+ pathParameters := map[string]interface{}{
+ "diskName": autorest.Encode("path", diskName),
+ "resourceGroupName": autorest.Encode("path", resourceGroupName),
+ "subscriptionId": autorest.Encode("path", client.SubscriptionID),
+ }
+
+ const APIVersion = "2018-06-01"
+ queryParameters := map[string]interface{}{
+ "api-version": APIVersion,
+ }
+
+ preparer := autorest.CreatePreparer(
+ autorest.AsGet(),
+ autorest.WithBaseURL(client.BaseURI),
+ autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}", pathParameters),
+ autorest.WithQueryParameters(queryParameters))
+ return preparer.Prepare((&http.Request{}).WithContext(ctx))
+}
+
+// GetSender sends the Get request. The method will close the
+// http.Response Body if it receives an error.
+func (client DisksClient) GetSender(req *http.Request) (*http.Response, error) {
+ return autorest.SendWithSender(client, req,
+ azure.DoRetryWithRegistration(client.Client))
+}
+
+// GetResponder handles the response to the Get request. The method always
+// closes the http.Response Body.
+func (client DisksClient) GetResponder(resp *http.Response) (result Disk, err error) {
+ err = autorest.Respond(
+ resp,
+ client.ByInspecting(),
+ azure.WithErrorUnlessStatusCode(http.StatusOK),
+ autorest.ByUnmarshallingJSON(&result),
+ autorest.ByClosing())
+ result.Response = autorest.Response{Response: resp}
+ return
+}
+
+// GrantAccess grants access to a disk.
+// Parameters:
+// resourceGroupName - the name of the resource group.
+// diskName - the name of the managed disk that is being created. The name can't be changed after the disk is
+// created. Supported characters for the name are a-z, A-Z, 0-9 and _. The maximum name length is 80
+// characters.
+// grantAccessData - access data object supplied in the body of the get disk access operation.
+func (client DisksClient) GrantAccess(ctx context.Context, resourceGroupName string, diskName string, grantAccessData GrantAccessData) (result DisksGrantAccessFuture, err error) {
+ if err := validation.Validate([]validation.Validation{
+ {TargetValue: grantAccessData,
+ Constraints: []validation.Constraint{{Target: "grantAccessData.DurationInSeconds", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
+ return result, validation.NewError("compute.DisksClient", "GrantAccess", err.Error())
+ }
+
+ req, err := client.GrantAccessPreparer(ctx, resourceGroupName, diskName, grantAccessData)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.DisksClient", "GrantAccess", nil, "Failure preparing request")
+ return
+ }
+
+ result, err = client.GrantAccessSender(req)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.DisksClient", "GrantAccess", result.Response(), "Failure sending request")
+ return
+ }
+
+ return
+}
+
+// GrantAccessPreparer prepares the GrantAccess request.
+func (client DisksClient) GrantAccessPreparer(ctx context.Context, resourceGroupName string, diskName string, grantAccessData GrantAccessData) (*http.Request, error) {
+ pathParameters := map[string]interface{}{
+ "diskName": autorest.Encode("path", diskName),
+ "resourceGroupName": autorest.Encode("path", resourceGroupName),
+ "subscriptionId": autorest.Encode("path", client.SubscriptionID),
+ }
+
+ const APIVersion = "2018-06-01"
+ queryParameters := map[string]interface{}{
+ "api-version": APIVersion,
+ }
+
+ preparer := autorest.CreatePreparer(
+ autorest.AsContentType("application/json; charset=utf-8"),
+ autorest.AsPost(),
+ autorest.WithBaseURL(client.BaseURI),
+ autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}/beginGetAccess", pathParameters),
+ autorest.WithJSON(grantAccessData),
+ autorest.WithQueryParameters(queryParameters))
+ return preparer.Prepare((&http.Request{}).WithContext(ctx))
+}
+
+// GrantAccessSender sends the GrantAccess request. The method will close the
+// http.Response Body if it receives an error.
+func (client DisksClient) GrantAccessSender(req *http.Request) (future DisksGrantAccessFuture, err error) {
+ var resp *http.Response
+ resp, err = autorest.SendWithSender(client, req,
+ azure.DoRetryWithRegistration(client.Client))
+ if err != nil {
+ return
+ }
+ err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted))
+ if err != nil {
+ return
+ }
+ future.Future, err = azure.NewFutureFromResponse(resp)
+ return
+}
+
+// GrantAccessResponder handles the response to the GrantAccess request. The method always
+// closes the http.Response Body.
+func (client DisksClient) GrantAccessResponder(resp *http.Response) (result AccessURI, err error) {
+ err = autorest.Respond(
+ resp,
+ client.ByInspecting(),
+ azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
+ autorest.ByUnmarshallingJSON(&result),
+ autorest.ByClosing())
+ result.Response = autorest.Response{Response: resp}
+ return
+}
+
+// List lists all the disks under a subscription.
+func (client DisksClient) List(ctx context.Context) (result DiskListPage, err error) {
+ result.fn = client.listNextResults
+ req, err := client.ListPreparer(ctx)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.DisksClient", "List", nil, "Failure preparing request")
+ return
+ }
+
+ resp, err := client.ListSender(req)
+ if err != nil {
+ result.dl.Response = autorest.Response{Response: resp}
+ err = autorest.NewErrorWithError(err, "compute.DisksClient", "List", resp, "Failure sending request")
+ return
+ }
+
+ result.dl, err = client.ListResponder(resp)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.DisksClient", "List", resp, "Failure responding to request")
+ }
+
+ return
+}
+
+// ListPreparer prepares the List request.
+func (client DisksClient) ListPreparer(ctx context.Context) (*http.Request, error) {
+ pathParameters := map[string]interface{}{
+ "subscriptionId": autorest.Encode("path", client.SubscriptionID),
+ }
+
+ const APIVersion = "2018-06-01"
+ queryParameters := map[string]interface{}{
+ "api-version": APIVersion,
+ }
+
+ preparer := autorest.CreatePreparer(
+ autorest.AsGet(),
+ autorest.WithBaseURL(client.BaseURI),
+ autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Compute/disks", pathParameters),
+ autorest.WithQueryParameters(queryParameters))
+ return preparer.Prepare((&http.Request{}).WithContext(ctx))
+}
+
+// ListSender sends the List request. The method will close the
+// http.Response Body if it receives an error.
+func (client DisksClient) ListSender(req *http.Request) (*http.Response, error) {
+ return autorest.SendWithSender(client, req,
+ azure.DoRetryWithRegistration(client.Client))
+}
+
+// ListResponder handles the response to the List request. The method always
+// closes the http.Response Body.
+func (client DisksClient) ListResponder(resp *http.Response) (result DiskList, err error) {
+ err = autorest.Respond(
+ resp,
+ client.ByInspecting(),
+ azure.WithErrorUnlessStatusCode(http.StatusOK),
+ autorest.ByUnmarshallingJSON(&result),
+ autorest.ByClosing())
+ result.Response = autorest.Response{Response: resp}
+ return
+}
+
+// listNextResults retrieves the next set of results, if any.
+func (client DisksClient) listNextResults(lastResults DiskList) (result DiskList, err error) {
+ req, err := lastResults.diskListPreparer()
+ if err != nil {
+ return result, autorest.NewErrorWithError(err, "compute.DisksClient", "listNextResults", nil, "Failure preparing next results request")
+ }
+ if req == nil {
+ return
+ }
+ resp, err := client.ListSender(req)
+ if err != nil {
+ result.Response = autorest.Response{Response: resp}
+ return result, autorest.NewErrorWithError(err, "compute.DisksClient", "listNextResults", resp, "Failure sending next results request")
+ }
+ result, err = client.ListResponder(resp)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.DisksClient", "listNextResults", resp, "Failure responding to next results request")
+ }
+ return
+}
+
+// ListComplete enumerates all values, automatically crossing page boundaries as required.
+func (client DisksClient) ListComplete(ctx context.Context) (result DiskListIterator, err error) {
+ result.page, err = client.List(ctx)
+ return
+}
+
+// ListByResourceGroup lists all the disks under a resource group.
+// Parameters:
+// resourceGroupName - the name of the resource group.
+func (client DisksClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result DiskListPage, err error) {
+ result.fn = client.listByResourceGroupNextResults
+ req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.DisksClient", "ListByResourceGroup", nil, "Failure preparing request")
+ return
+ }
+
+ resp, err := client.ListByResourceGroupSender(req)
+ if err != nil {
+ result.dl.Response = autorest.Response{Response: resp}
+ err = autorest.NewErrorWithError(err, "compute.DisksClient", "ListByResourceGroup", resp, "Failure sending request")
+ return
+ }
+
+ result.dl, err = client.ListByResourceGroupResponder(resp)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.DisksClient", "ListByResourceGroup", resp, "Failure responding to request")
+ }
+
+ return
+}
+
+// ListByResourceGroupPreparer prepares the ListByResourceGroup request.
+func (client DisksClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) {
+ pathParameters := map[string]interface{}{
+ "resourceGroupName": autorest.Encode("path", resourceGroupName),
+ "subscriptionId": autorest.Encode("path", client.SubscriptionID),
+ }
+
+ const APIVersion = "2018-06-01"
+ queryParameters := map[string]interface{}{
+ "api-version": APIVersion,
+ }
+
+ preparer := autorest.CreatePreparer(
+ autorest.AsGet(),
+ autorest.WithBaseURL(client.BaseURI),
+ autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks", pathParameters),
+ autorest.WithQueryParameters(queryParameters))
+ return preparer.Prepare((&http.Request{}).WithContext(ctx))
+}
+
+// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the
+// http.Response Body if it receives an error.
+func (client DisksClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) {
+ return autorest.SendWithSender(client, req,
+ azure.DoRetryWithRegistration(client.Client))
+}
+
+// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always
+// closes the http.Response Body.
+func (client DisksClient) ListByResourceGroupResponder(resp *http.Response) (result DiskList, err error) {
+ err = autorest.Respond(
+ resp,
+ client.ByInspecting(),
+ azure.WithErrorUnlessStatusCode(http.StatusOK),
+ autorest.ByUnmarshallingJSON(&result),
+ autorest.ByClosing())
+ result.Response = autorest.Response{Response: resp}
+ return
+}
+
+// listByResourceGroupNextResults retrieves the next set of results, if any.
+func (client DisksClient) listByResourceGroupNextResults(lastResults DiskList) (result DiskList, err error) {
+ req, err := lastResults.diskListPreparer()
+ if err != nil {
+ return result, autorest.NewErrorWithError(err, "compute.DisksClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request")
+ }
+ if req == nil {
+ return
+ }
+ resp, err := client.ListByResourceGroupSender(req)
+ if err != nil {
+ result.Response = autorest.Response{Response: resp}
+ return result, autorest.NewErrorWithError(err, "compute.DisksClient", "listByResourceGroupNextResults", resp, "Failure sending next results request")
+ }
+ result, err = client.ListByResourceGroupResponder(resp)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.DisksClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request")
+ }
+ return
+}
+
+// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required.
+func (client DisksClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result DiskListIterator, err error) {
+ result.page, err = client.ListByResourceGroup(ctx, resourceGroupName)
+ return
+}
+
+// RevokeAccess revokes access to a disk.
+// Parameters:
+// resourceGroupName - the name of the resource group.
+// diskName - the name of the managed disk that is being created. The name can't be changed after the disk is
+// created. Supported characters for the name are a-z, A-Z, 0-9 and _. The maximum name length is 80
+// characters.
+func (client DisksClient) RevokeAccess(ctx context.Context, resourceGroupName string, diskName string) (result DisksRevokeAccessFuture, err error) {
+ req, err := client.RevokeAccessPreparer(ctx, resourceGroupName, diskName)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.DisksClient", "RevokeAccess", nil, "Failure preparing request")
+ return
+ }
+
+ result, err = client.RevokeAccessSender(req)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.DisksClient", "RevokeAccess", result.Response(), "Failure sending request")
+ return
+ }
+
+ return
+}
+
+// RevokeAccessPreparer prepares the RevokeAccess request.
+func (client DisksClient) RevokeAccessPreparer(ctx context.Context, resourceGroupName string, diskName string) (*http.Request, error) {
+ pathParameters := map[string]interface{}{
+ "diskName": autorest.Encode("path", diskName),
+ "resourceGroupName": autorest.Encode("path", resourceGroupName),
+ "subscriptionId": autorest.Encode("path", client.SubscriptionID),
+ }
+
+ const APIVersion = "2018-06-01"
+ queryParameters := map[string]interface{}{
+ "api-version": APIVersion,
+ }
+
+ preparer := autorest.CreatePreparer(
+ autorest.AsPost(),
+ autorest.WithBaseURL(client.BaseURI),
+ autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}/endGetAccess", pathParameters),
+ autorest.WithQueryParameters(queryParameters))
+ return preparer.Prepare((&http.Request{}).WithContext(ctx))
+}
+
+// RevokeAccessSender sends the RevokeAccess request. The method will close the
+// http.Response Body if it receives an error.
+func (client DisksClient) RevokeAccessSender(req *http.Request) (future DisksRevokeAccessFuture, err error) {
+ var resp *http.Response
+ resp, err = autorest.SendWithSender(client, req,
+ azure.DoRetryWithRegistration(client.Client))
+ if err != nil {
+ return
+ }
+ err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted))
+ if err != nil {
+ return
+ }
+ future.Future, err = azure.NewFutureFromResponse(resp)
+ return
+}
+
+// RevokeAccessResponder handles the response to the RevokeAccess request. The method always
+// closes the http.Response Body.
+func (client DisksClient) RevokeAccessResponder(resp *http.Response) (result autorest.Response, err error) {
+ err = autorest.Respond(
+ resp,
+ client.ByInspecting(),
+ azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
+ autorest.ByClosing())
+ result.Response = resp
+ return
+}
+
+// Update updates (patches) a disk.
+// Parameters:
+// resourceGroupName - the name of the resource group.
+// diskName - the name of the managed disk that is being created. The name can't be changed after the disk is
+// created. Supported characters for the name are a-z, A-Z, 0-9 and _. The maximum name length is 80
+// characters.
+// disk - disk object supplied in the body of the Patch disk operation.
+func (client DisksClient) Update(ctx context.Context, resourceGroupName string, diskName string, disk DiskUpdate) (result DisksUpdateFuture, err error) {
+ req, err := client.UpdatePreparer(ctx, resourceGroupName, diskName, disk)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.DisksClient", "Update", nil, "Failure preparing request")
+ return
+ }
+
+ result, err = client.UpdateSender(req)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.DisksClient", "Update", result.Response(), "Failure sending request")
+ return
+ }
+
+ return
+}
+
+// UpdatePreparer prepares the Update request.
+func (client DisksClient) UpdatePreparer(ctx context.Context, resourceGroupName string, diskName string, disk DiskUpdate) (*http.Request, error) {
+ pathParameters := map[string]interface{}{
+ "diskName": autorest.Encode("path", diskName),
+ "resourceGroupName": autorest.Encode("path", resourceGroupName),
+ "subscriptionId": autorest.Encode("path", client.SubscriptionID),
+ }
+
+ const APIVersion = "2018-06-01"
+ queryParameters := map[string]interface{}{
+ "api-version": APIVersion,
+ }
+
+ preparer := autorest.CreatePreparer(
+ autorest.AsContentType("application/json; charset=utf-8"),
+ autorest.AsPatch(),
+ autorest.WithBaseURL(client.BaseURI),
+ autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}", pathParameters),
+ autorest.WithJSON(disk),
+ autorest.WithQueryParameters(queryParameters))
+ return preparer.Prepare((&http.Request{}).WithContext(ctx))
+}
+
+// UpdateSender sends the Update request. The method will close the
+// http.Response Body if it receives an error.
+func (client DisksClient) UpdateSender(req *http.Request) (future DisksUpdateFuture, err error) {
+ var resp *http.Response
+ resp, err = autorest.SendWithSender(client, req,
+ azure.DoRetryWithRegistration(client.Client))
+ if err != nil {
+ return
+ }
+ err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted))
+ if err != nil {
+ return
+ }
+ future.Future, err = azure.NewFutureFromResponse(resp)
+ return
+}
+
+// UpdateResponder handles the response to the Update request. The method always
+// closes the http.Response Body.
+func (client DisksClient) UpdateResponder(resp *http.Response) (result Disk, err error) {
+ err = autorest.Respond(
+ resp,
+ client.ByInspecting(),
+ azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
+ autorest.ByUnmarshallingJSON(&result),
+ autorest.ByClosing())
+ result.Response = autorest.Response{Response: resp}
+ return
+}
diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-06-01/compute/galleries.go b/vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-06-01/compute/galleries.go
index eb0e71cf29..bc55068685 100644
--- a/vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-06-01/compute/galleries.go
+++ b/vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-06-01/compute/galleries.go
@@ -39,11 +39,12 @@ func NewGalleriesClientWithBaseURI(baseURI string, subscriptionID string) Galler
return GalleriesClient{NewWithBaseURI(baseURI, subscriptionID)}
}
-// CreateOrUpdate create or update a gallery.
+// CreateOrUpdate create or update a Shared Image Gallery.
// Parameters:
// resourceGroupName - the name of the resource group.
-// galleryName - the name of the gallery.
-// gallery - parameters supplied to the create or update gallery operation.
+// galleryName - the name of the Shared Image Gallery. The allowed characters are alphabets and numbers with
+// dots and periods allowed in the middle. The maximum length is 80 characters.
+// gallery - parameters supplied to the create or update Shared Image Gallery operation.
func (client GalleriesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, galleryName string, gallery Gallery) (result GalleriesCreateOrUpdateFuture, err error) {
req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, galleryName, gallery)
if err != nil {
@@ -113,10 +114,10 @@ func (client GalleriesClient) CreateOrUpdateResponder(resp *http.Response) (resu
return
}
-// Delete delete a gallery.
+// Delete delete a Shared Image Gallery.
// Parameters:
// resourceGroupName - the name of the resource group.
-// galleryName - the name of the gallery.
+// galleryName - the name of the Shared Image Gallery to be deleted.
func (client GalleriesClient) Delete(ctx context.Context, resourceGroupName string, galleryName string) (result GalleriesDeleteFuture, err error) {
req, err := client.DeletePreparer(ctx, resourceGroupName, galleryName)
if err != nil {
@@ -183,10 +184,10 @@ func (client GalleriesClient) DeleteResponder(resp *http.Response) (result autor
return
}
-// Get retrieves information about a gallery.
+// Get retrieves information about a Shared Image Gallery.
// Parameters:
// resourceGroupName - the name of the resource group.
-// galleryName - the name of the gallery.
+// galleryName - the name of the Shared Image Gallery.
func (client GalleriesClient) Get(ctx context.Context, resourceGroupName string, galleryName string) (result Gallery, err error) {
req, err := client.GetPreparer(ctx, resourceGroupName, galleryName)
if err != nil {
diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-06-01/compute/galleryimages.go b/vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-06-01/compute/galleryimages.go
index 3d2465dd53..670ea7ee29 100644
--- a/vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-06-01/compute/galleryimages.go
+++ b/vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-06-01/compute/galleryimages.go
@@ -21,6 +21,7 @@ import (
"context"
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/azure"
+ "github.com/Azure/go-autorest/autorest/validation"
"net/http"
)
@@ -39,13 +40,27 @@ func NewGalleryImagesClientWithBaseURI(baseURI string, subscriptionID string) Ga
return GalleryImagesClient{NewWithBaseURI(baseURI, subscriptionID)}
}
-// CreateOrUpdate create or update a gallery image.
+// CreateOrUpdate create or update a gallery Image Definition.
// Parameters:
// resourceGroupName - the name of the resource group.
-// galleryName - the name of the gallery.
-// galleryImageName - the name of the gallery image.
+// galleryName - the name of the Shared Image Gallery in which the Image Definition is to be created.
+// galleryImageName - the name of the gallery Image Definition to be created or updated. The allowed characters
+// are alphabets and numbers with dots, dashes, and periods allowed in the middle. The maximum length is 80
+// characters.
// galleryImage - parameters supplied to the create or update gallery image operation.
func (client GalleryImagesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, galleryName string, galleryImageName string, galleryImage GalleryImage) (result GalleryImagesCreateOrUpdateFuture, err error) {
+ if err := validation.Validate([]validation.Validation{
+ {TargetValue: galleryImage,
+ Constraints: []validation.Constraint{{Target: "galleryImage.GalleryImageProperties", Name: validation.Null, Rule: false,
+ Chain: []validation.Constraint{{Target: "galleryImage.GalleryImageProperties.Identifier", Name: validation.Null, Rule: true,
+ Chain: []validation.Constraint{{Target: "galleryImage.GalleryImageProperties.Identifier.Publisher", Name: validation.Null, Rule: true, Chain: nil},
+ {Target: "galleryImage.GalleryImageProperties.Identifier.Offer", Name: validation.Null, Rule: true, Chain: nil},
+ {Target: "galleryImage.GalleryImageProperties.Identifier.Sku", Name: validation.Null, Rule: true, Chain: nil},
+ }},
+ }}}}}); err != nil {
+ return result, validation.NewError("compute.GalleryImagesClient", "CreateOrUpdate", err.Error())
+ }
+
req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, galleryName, galleryImageName, galleryImage)
if err != nil {
err = autorest.NewErrorWithError(err, "compute.GalleryImagesClient", "CreateOrUpdate", nil, "Failure preparing request")
@@ -118,8 +133,8 @@ func (client GalleryImagesClient) CreateOrUpdateResponder(resp *http.Response) (
// Delete delete a gallery image.
// Parameters:
// resourceGroupName - the name of the resource group.
-// galleryName - the name of the gallery.
-// galleryImageName - the name of the gallery image.
+// galleryName - the name of the Shared Image Gallery in which the Image Definition is to be deleted.
+// galleryImageName - the name of the gallery Image Definition to be deleted.
func (client GalleryImagesClient) Delete(ctx context.Context, resourceGroupName string, galleryName string, galleryImageName string) (result GalleryImagesDeleteFuture, err error) {
req, err := client.DeletePreparer(ctx, resourceGroupName, galleryName, galleryImageName)
if err != nil {
@@ -187,11 +202,11 @@ func (client GalleryImagesClient) DeleteResponder(resp *http.Response) (result a
return
}
-// Get retrieves information about a gallery image.
+// Get retrieves information about a gallery Image Definition.
// Parameters:
// resourceGroupName - the name of the resource group.
-// galleryName - the name of the gallery.
-// galleryImageName - the name of the gallery image.
+// galleryName - the name of the Shared Image Gallery from which the Image Definitions are to be retrieved.
+// galleryImageName - the name of the gallery Image Definition to be retrieved.
func (client GalleryImagesClient) Get(ctx context.Context, resourceGroupName string, galleryName string, galleryImageName string) (result GalleryImage, err error) {
req, err := client.GetPreparer(ctx, resourceGroupName, galleryName, galleryImageName)
if err != nil {
@@ -256,10 +271,10 @@ func (client GalleryImagesClient) GetResponder(resp *http.Response) (result Gall
return
}
-// ListByGallery list gallery images under a gallery.
+// ListByGallery list gallery Image Definitions in a gallery.
// Parameters:
// resourceGroupName - the name of the resource group.
-// galleryName - the name of the gallery.
+// galleryName - the name of the Shared Image Gallery from which Image Definitions are to be listed.
func (client GalleryImagesClient) ListByGallery(ctx context.Context, resourceGroupName string, galleryName string) (result GalleryImageListPage, err error) {
result.fn = client.listByGalleryNextResults
req, err := client.ListByGalleryPreparer(ctx, resourceGroupName, galleryName)
diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-06-01/compute/galleryimageversions.go b/vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-06-01/compute/galleryimageversions.go
index 02bb8ec0fa..d179443ade 100644
--- a/vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-06-01/compute/galleryimageversions.go
+++ b/vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-06-01/compute/galleryimageversions.go
@@ -21,6 +21,7 @@ import (
"context"
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/azure"
+ "github.com/Azure/go-autorest/autorest/validation"
"net/http"
)
@@ -39,16 +40,23 @@ func NewGalleryImageVersionsClientWithBaseURI(baseURI string, subscriptionID str
return GalleryImageVersionsClient{NewWithBaseURI(baseURI, subscriptionID)}
}
-// CreateOrUpdate create or update a gallery image version.
+// CreateOrUpdate create or update a gallery Image Version.
// Parameters:
// resourceGroupName - the name of the resource group.
-// galleryName - the name of the gallery.
-// galleryImageName - the name of the gallery image.
-// galleryImageVersionName - the name of the gallery image version. Needs to follow semantic version name
-// pattern: The allowed characters are digit and period. Digits must be within the range of a 32-bit integer.
-// Format: ..
-// galleryImageVersion - parameters supplied to the create or update gallery image version operation.
+// galleryName - the name of the Shared Image Gallery in which the Image Definition resides.
+// galleryImageName - the name of the gallery Image Definition in which the Image Version is to be created.
+// galleryImageVersionName - the name of the gallery Image Version to be created. Needs to follow semantic
+// version name pattern: The allowed characters are digit and period. Digits must be within the range of a
+// 32-bit integer. Format: ..
+// galleryImageVersion - parameters supplied to the create or update gallery Image Version operation.
func (client GalleryImageVersionsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, galleryName string, galleryImageName string, galleryImageVersionName string, galleryImageVersion GalleryImageVersion) (result GalleryImageVersionsCreateOrUpdateFuture, err error) {
+ if err := validation.Validate([]validation.Validation{
+ {TargetValue: galleryImageVersion,
+ Constraints: []validation.Constraint{{Target: "galleryImageVersion.GalleryImageVersionProperties", Name: validation.Null, Rule: false,
+ Chain: []validation.Constraint{{Target: "galleryImageVersion.GalleryImageVersionProperties.PublishingProfile", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil {
+ return result, validation.NewError("compute.GalleryImageVersionsClient", "CreateOrUpdate", err.Error())
+ }
+
req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, galleryName, galleryImageName, galleryImageVersionName, galleryImageVersion)
if err != nil {
err = autorest.NewErrorWithError(err, "compute.GalleryImageVersionsClient", "CreateOrUpdate", nil, "Failure preparing request")
@@ -119,12 +127,12 @@ func (client GalleryImageVersionsClient) CreateOrUpdateResponder(resp *http.Resp
return
}
-// Delete delete a gallery image version.
+// Delete delete a gallery Image Version.
// Parameters:
// resourceGroupName - the name of the resource group.
-// galleryName - the name of the gallery.
-// galleryImageName - the name of the gallery image.
-// galleryImageVersionName - the name of the gallery image version.
+// galleryName - the name of the Shared Image Gallery in which the Image Definition resides.
+// galleryImageName - the name of the gallery Image Definition in which the Image Version resides.
+// galleryImageVersionName - the name of the gallery Image Version to be deleted.
func (client GalleryImageVersionsClient) Delete(ctx context.Context, resourceGroupName string, galleryName string, galleryImageName string, galleryImageVersionName string) (result GalleryImageVersionsDeleteFuture, err error) {
req, err := client.DeletePreparer(ctx, resourceGroupName, galleryName, galleryImageName, galleryImageVersionName)
if err != nil {
@@ -193,12 +201,12 @@ func (client GalleryImageVersionsClient) DeleteResponder(resp *http.Response) (r
return
}
-// Get retrieves information about a gallery image version.
+// Get retrieves information about a gallery Image Version.
// Parameters:
// resourceGroupName - the name of the resource group.
-// galleryName - the name of the gallery.
-// galleryImageName - the name of the gallery image.
-// galleryImageVersionName - the name of the gallery image version.
+// galleryName - the name of the Shared Image Gallery in which the Image Definition resides.
+// galleryImageName - the name of the gallery Image Definition in which the Image Version resides.
+// galleryImageVersionName - the name of the gallery Image Version to be retrieved.
// expand - the expand expression to apply on the operation.
func (client GalleryImageVersionsClient) Get(ctx context.Context, resourceGroupName string, galleryName string, galleryImageName string, galleryImageVersionName string, expand ReplicationStatusTypes) (result GalleryImageVersion, err error) {
req, err := client.GetPreparer(ctx, resourceGroupName, galleryName, galleryImageName, galleryImageVersionName, expand)
@@ -268,11 +276,12 @@ func (client GalleryImageVersionsClient) GetResponder(resp *http.Response) (resu
return
}
-// ListByGalleryImage list gallery image versions under a gallery image.
+// ListByGalleryImage list gallery Image Versions in a gallery Image Definition.
// Parameters:
// resourceGroupName - the name of the resource group.
-// galleryName - the name of the gallery.
-// galleryImageName - the name of the gallery image.
+// galleryName - the name of the Shared Image Gallery in which the Image Definition resides.
+// galleryImageName - the name of the Shared Image Gallery Image Definition from which the Image Versions are
+// to be listed.
func (client GalleryImageVersionsClient) ListByGalleryImage(ctx context.Context, resourceGroupName string, galleryName string, galleryImageName string) (result GalleryImageVersionListPage, err error) {
result.fn = client.listByGalleryImageNextResults
req, err := client.ListByGalleryImagePreparer(ctx, resourceGroupName, galleryName, galleryImageName)
diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-06-01/compute/models.go b/vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-06-01/compute/models.go
index 4d40eef188..8050ddc959 100644
--- a/vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-06-01/compute/models.go
+++ b/vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-06-01/compute/models.go
@@ -26,6 +26,21 @@ import (
"net/http"
)
+// AccessLevel enumerates the values for access level.
+type AccessLevel string
+
+const (
+ // None ...
+ None AccessLevel = "None"
+ // Read ...
+ Read AccessLevel = "Read"
+)
+
+// PossibleAccessLevelValues returns an array of possible values for the AccessLevel const type.
+func PossibleAccessLevelValues() []AccessLevel {
+ return []AccessLevel{None, Read}
+}
+
// AggregatedReplicationState enumerates the values for aggregated replication state.
type AggregatedReplicationState string
@@ -45,21 +60,36 @@ func PossibleAggregatedReplicationStateValues() []AggregatedReplicationState {
return []AggregatedReplicationState{Completed, Failed, InProgress, Unknown}
}
+// AvailabilitySetSkuTypes enumerates the values for availability set sku types.
+type AvailabilitySetSkuTypes string
+
+const (
+ // Aligned ...
+ Aligned AvailabilitySetSkuTypes = "Aligned"
+ // Classic ...
+ Classic AvailabilitySetSkuTypes = "Classic"
+)
+
+// PossibleAvailabilitySetSkuTypesValues returns an array of possible values for the AvailabilitySetSkuTypes const type.
+func PossibleAvailabilitySetSkuTypesValues() []AvailabilitySetSkuTypes {
+ return []AvailabilitySetSkuTypes{Aligned, Classic}
+}
+
// CachingTypes enumerates the values for caching types.
type CachingTypes string
const (
- // None ...
- None CachingTypes = "None"
- // ReadOnly ...
- ReadOnly CachingTypes = "ReadOnly"
- // ReadWrite ...
- ReadWrite CachingTypes = "ReadWrite"
+ // CachingTypesNone ...
+ CachingTypesNone CachingTypes = "None"
+ // CachingTypesReadOnly ...
+ CachingTypesReadOnly CachingTypes = "ReadOnly"
+ // CachingTypesReadWrite ...
+ CachingTypesReadWrite CachingTypes = "ReadWrite"
)
// PossibleCachingTypesValues returns an array of possible values for the CachingTypes const type.
func PossibleCachingTypesValues() []CachingTypes {
- return []CachingTypes{None, ReadOnly, ReadWrite}
+ return []CachingTypes{CachingTypesNone, CachingTypesReadOnly, CachingTypesReadWrite}
}
// ComponentNames enumerates the values for component names.
@@ -75,21 +105,200 @@ func PossibleComponentNamesValues() []ComponentNames {
return []ComponentNames{MicrosoftWindowsShellSetup}
}
+// ContainerServiceOrchestratorTypes enumerates the values for container service orchestrator types.
+type ContainerServiceOrchestratorTypes string
+
+const (
+ // Custom ...
+ Custom ContainerServiceOrchestratorTypes = "Custom"
+ // DCOS ...
+ DCOS ContainerServiceOrchestratorTypes = "DCOS"
+ // Kubernetes ...
+ Kubernetes ContainerServiceOrchestratorTypes = "Kubernetes"
+ // Swarm ...
+ Swarm ContainerServiceOrchestratorTypes = "Swarm"
+)
+
+// PossibleContainerServiceOrchestratorTypesValues returns an array of possible values for the ContainerServiceOrchestratorTypes const type.
+func PossibleContainerServiceOrchestratorTypesValues() []ContainerServiceOrchestratorTypes {
+ return []ContainerServiceOrchestratorTypes{Custom, DCOS, Kubernetes, Swarm}
+}
+
+// ContainerServiceVMSizeTypes enumerates the values for container service vm size types.
+type ContainerServiceVMSizeTypes string
+
+const (
+ // StandardA0 ...
+ StandardA0 ContainerServiceVMSizeTypes = "Standard_A0"
+ // StandardA1 ...
+ StandardA1 ContainerServiceVMSizeTypes = "Standard_A1"
+ // StandardA10 ...
+ StandardA10 ContainerServiceVMSizeTypes = "Standard_A10"
+ // StandardA11 ...
+ StandardA11 ContainerServiceVMSizeTypes = "Standard_A11"
+ // StandardA2 ...
+ StandardA2 ContainerServiceVMSizeTypes = "Standard_A2"
+ // StandardA3 ...
+ StandardA3 ContainerServiceVMSizeTypes = "Standard_A3"
+ // StandardA4 ...
+ StandardA4 ContainerServiceVMSizeTypes = "Standard_A4"
+ // StandardA5 ...
+ StandardA5 ContainerServiceVMSizeTypes = "Standard_A5"
+ // StandardA6 ...
+ StandardA6 ContainerServiceVMSizeTypes = "Standard_A6"
+ // StandardA7 ...
+ StandardA7 ContainerServiceVMSizeTypes = "Standard_A7"
+ // StandardA8 ...
+ StandardA8 ContainerServiceVMSizeTypes = "Standard_A8"
+ // StandardA9 ...
+ StandardA9 ContainerServiceVMSizeTypes = "Standard_A9"
+ // StandardD1 ...
+ StandardD1 ContainerServiceVMSizeTypes = "Standard_D1"
+ // StandardD11 ...
+ StandardD11 ContainerServiceVMSizeTypes = "Standard_D11"
+ // StandardD11V2 ...
+ StandardD11V2 ContainerServiceVMSizeTypes = "Standard_D11_v2"
+ // StandardD12 ...
+ StandardD12 ContainerServiceVMSizeTypes = "Standard_D12"
+ // StandardD12V2 ...
+ StandardD12V2 ContainerServiceVMSizeTypes = "Standard_D12_v2"
+ // StandardD13 ...
+ StandardD13 ContainerServiceVMSizeTypes = "Standard_D13"
+ // StandardD13V2 ...
+ StandardD13V2 ContainerServiceVMSizeTypes = "Standard_D13_v2"
+ // StandardD14 ...
+ StandardD14 ContainerServiceVMSizeTypes = "Standard_D14"
+ // StandardD14V2 ...
+ StandardD14V2 ContainerServiceVMSizeTypes = "Standard_D14_v2"
+ // StandardD1V2 ...
+ StandardD1V2 ContainerServiceVMSizeTypes = "Standard_D1_v2"
+ // StandardD2 ...
+ StandardD2 ContainerServiceVMSizeTypes = "Standard_D2"
+ // StandardD2V2 ...
+ StandardD2V2 ContainerServiceVMSizeTypes = "Standard_D2_v2"
+ // StandardD3 ...
+ StandardD3 ContainerServiceVMSizeTypes = "Standard_D3"
+ // StandardD3V2 ...
+ StandardD3V2 ContainerServiceVMSizeTypes = "Standard_D3_v2"
+ // StandardD4 ...
+ StandardD4 ContainerServiceVMSizeTypes = "Standard_D4"
+ // StandardD4V2 ...
+ StandardD4V2 ContainerServiceVMSizeTypes = "Standard_D4_v2"
+ // StandardD5V2 ...
+ StandardD5V2 ContainerServiceVMSizeTypes = "Standard_D5_v2"
+ // StandardDS1 ...
+ StandardDS1 ContainerServiceVMSizeTypes = "Standard_DS1"
+ // StandardDS11 ...
+ StandardDS11 ContainerServiceVMSizeTypes = "Standard_DS11"
+ // StandardDS12 ...
+ StandardDS12 ContainerServiceVMSizeTypes = "Standard_DS12"
+ // StandardDS13 ...
+ StandardDS13 ContainerServiceVMSizeTypes = "Standard_DS13"
+ // StandardDS14 ...
+ StandardDS14 ContainerServiceVMSizeTypes = "Standard_DS14"
+ // StandardDS2 ...
+ StandardDS2 ContainerServiceVMSizeTypes = "Standard_DS2"
+ // StandardDS3 ...
+ StandardDS3 ContainerServiceVMSizeTypes = "Standard_DS3"
+ // StandardDS4 ...
+ StandardDS4 ContainerServiceVMSizeTypes = "Standard_DS4"
+ // StandardG1 ...
+ StandardG1 ContainerServiceVMSizeTypes = "Standard_G1"
+ // StandardG2 ...
+ StandardG2 ContainerServiceVMSizeTypes = "Standard_G2"
+ // StandardG3 ...
+ StandardG3 ContainerServiceVMSizeTypes = "Standard_G3"
+ // StandardG4 ...
+ StandardG4 ContainerServiceVMSizeTypes = "Standard_G4"
+ // StandardG5 ...
+ StandardG5 ContainerServiceVMSizeTypes = "Standard_G5"
+ // StandardGS1 ...
+ StandardGS1 ContainerServiceVMSizeTypes = "Standard_GS1"
+ // StandardGS2 ...
+ StandardGS2 ContainerServiceVMSizeTypes = "Standard_GS2"
+ // StandardGS3 ...
+ StandardGS3 ContainerServiceVMSizeTypes = "Standard_GS3"
+ // StandardGS4 ...
+ StandardGS4 ContainerServiceVMSizeTypes = "Standard_GS4"
+ // StandardGS5 ...
+ StandardGS5 ContainerServiceVMSizeTypes = "Standard_GS5"
+)
+
+// PossibleContainerServiceVMSizeTypesValues returns an array of possible values for the ContainerServiceVMSizeTypes const type.
+func PossibleContainerServiceVMSizeTypesValues() []ContainerServiceVMSizeTypes {
+ return []ContainerServiceVMSizeTypes{StandardA0, StandardA1, StandardA10, StandardA11, StandardA2, StandardA3, StandardA4, StandardA5, StandardA6, StandardA7, StandardA8, StandardA9, StandardD1, StandardD11, StandardD11V2, StandardD12, StandardD12V2, StandardD13, StandardD13V2, StandardD14, StandardD14V2, StandardD1V2, StandardD2, StandardD2V2, StandardD3, StandardD3V2, StandardD4, StandardD4V2, StandardD5V2, StandardDS1, StandardDS11, StandardDS12, StandardDS13, StandardDS14, StandardDS2, StandardDS3, StandardDS4, StandardG1, StandardG2, StandardG3, StandardG4, StandardG5, StandardGS1, StandardGS2, StandardGS3, StandardGS4, StandardGS5}
+}
+
+// DiffDiskOptions enumerates the values for diff disk options.
+type DiffDiskOptions string
+
+const (
+ // Local ...
+ Local DiffDiskOptions = "Local"
+)
+
+// PossibleDiffDiskOptionsValues returns an array of possible values for the DiffDiskOptions const type.
+func PossibleDiffDiskOptionsValues() []DiffDiskOptions {
+ return []DiffDiskOptions{Local}
+}
+
+// DiskCreateOption enumerates the values for disk create option.
+type DiskCreateOption string
+
+const (
+ // Attach ...
+ Attach DiskCreateOption = "Attach"
+ // Copy ...
+ Copy DiskCreateOption = "Copy"
+ // Empty ...
+ Empty DiskCreateOption = "Empty"
+ // FromImage ...
+ FromImage DiskCreateOption = "FromImage"
+ // Import ...
+ Import DiskCreateOption = "Import"
+ // Restore ...
+ Restore DiskCreateOption = "Restore"
+)
+
+// PossibleDiskCreateOptionValues returns an array of possible values for the DiskCreateOption const type.
+func PossibleDiskCreateOptionValues() []DiskCreateOption {
+ return []DiskCreateOption{Attach, Copy, Empty, FromImage, Import, Restore}
+}
+
// DiskCreateOptionTypes enumerates the values for disk create option types.
type DiskCreateOptionTypes string
const (
- // Attach ...
- Attach DiskCreateOptionTypes = "Attach"
- // Empty ...
- Empty DiskCreateOptionTypes = "Empty"
- // FromImage ...
- FromImage DiskCreateOptionTypes = "FromImage"
+ // DiskCreateOptionTypesAttach ...
+ DiskCreateOptionTypesAttach DiskCreateOptionTypes = "Attach"
+ // DiskCreateOptionTypesEmpty ...
+ DiskCreateOptionTypesEmpty DiskCreateOptionTypes = "Empty"
+ // DiskCreateOptionTypesFromImage ...
+ DiskCreateOptionTypesFromImage DiskCreateOptionTypes = "FromImage"
)
// PossibleDiskCreateOptionTypesValues returns an array of possible values for the DiskCreateOptionTypes const type.
func PossibleDiskCreateOptionTypesValues() []DiskCreateOptionTypes {
- return []DiskCreateOptionTypes{Attach, Empty, FromImage}
+ return []DiskCreateOptionTypes{DiskCreateOptionTypesAttach, DiskCreateOptionTypesEmpty, DiskCreateOptionTypesFromImage}
+}
+
+// DiskStorageAccountTypes enumerates the values for disk storage account types.
+type DiskStorageAccountTypes string
+
+const (
+ // PremiumLRS ...
+ PremiumLRS DiskStorageAccountTypes = "Premium_LRS"
+ // StandardLRS ...
+ StandardLRS DiskStorageAccountTypes = "Standard_LRS"
+ // StandardSSDLRS ...
+ StandardSSDLRS DiskStorageAccountTypes = "StandardSSD_LRS"
+ // UltraSSDLRS ...
+ UltraSSDLRS DiskStorageAccountTypes = "UltraSSD_LRS"
+)
+
+// PossibleDiskStorageAccountTypesValues returns an array of possible values for the DiskStorageAccountTypes const type.
+func PossibleDiskStorageAccountTypesValues() []DiskStorageAccountTypes {
+ return []DiskStorageAccountTypes{PremiumLRS, StandardLRS, StandardSSDLRS, UltraSSDLRS}
}
// HostCaching enumerates the values for host caching.
@@ -353,6 +562,53 @@ func PossibleResourceIdentityTypeValues() []ResourceIdentityType {
return []ResourceIdentityType{ResourceIdentityTypeNone, ResourceIdentityTypeSystemAssigned, ResourceIdentityTypeSystemAssignedUserAssigned, ResourceIdentityTypeUserAssigned}
}
+// ResourceSkuCapacityScaleType enumerates the values for resource sku capacity scale type.
+type ResourceSkuCapacityScaleType string
+
+const (
+ // ResourceSkuCapacityScaleTypeAutomatic ...
+ ResourceSkuCapacityScaleTypeAutomatic ResourceSkuCapacityScaleType = "Automatic"
+ // ResourceSkuCapacityScaleTypeManual ...
+ ResourceSkuCapacityScaleTypeManual ResourceSkuCapacityScaleType = "Manual"
+ // ResourceSkuCapacityScaleTypeNone ...
+ ResourceSkuCapacityScaleTypeNone ResourceSkuCapacityScaleType = "None"
+)
+
+// PossibleResourceSkuCapacityScaleTypeValues returns an array of possible values for the ResourceSkuCapacityScaleType const type.
+func PossibleResourceSkuCapacityScaleTypeValues() []ResourceSkuCapacityScaleType {
+ return []ResourceSkuCapacityScaleType{ResourceSkuCapacityScaleTypeAutomatic, ResourceSkuCapacityScaleTypeManual, ResourceSkuCapacityScaleTypeNone}
+}
+
+// ResourceSkuRestrictionsReasonCode enumerates the values for resource sku restrictions reason code.
+type ResourceSkuRestrictionsReasonCode string
+
+const (
+ // NotAvailableForSubscription ...
+ NotAvailableForSubscription ResourceSkuRestrictionsReasonCode = "NotAvailableForSubscription"
+ // QuotaID ...
+ QuotaID ResourceSkuRestrictionsReasonCode = "QuotaId"
+)
+
+// PossibleResourceSkuRestrictionsReasonCodeValues returns an array of possible values for the ResourceSkuRestrictionsReasonCode const type.
+func PossibleResourceSkuRestrictionsReasonCodeValues() []ResourceSkuRestrictionsReasonCode {
+ return []ResourceSkuRestrictionsReasonCode{NotAvailableForSubscription, QuotaID}
+}
+
+// ResourceSkuRestrictionsType enumerates the values for resource sku restrictions type.
+type ResourceSkuRestrictionsType string
+
+const (
+ // Location ...
+ Location ResourceSkuRestrictionsType = "Location"
+ // Zone ...
+ Zone ResourceSkuRestrictionsType = "Zone"
+)
+
+// PossibleResourceSkuRestrictionsTypeValues returns an array of possible values for the ResourceSkuRestrictionsType const type.
+func PossibleResourceSkuRestrictionsTypeValues() []ResourceSkuRestrictionsType {
+ return []ResourceSkuRestrictionsType{Location, Zone}
+}
+
// RollingUpgradeActionType enumerates the values for rolling upgrade action type.
type RollingUpgradeActionType string
@@ -387,21 +643,6 @@ func PossibleRollingUpgradeStatusCodeValues() []RollingUpgradeStatusCode {
return []RollingUpgradeStatusCode{RollingUpgradeStatusCodeCancelled, RollingUpgradeStatusCodeCompleted, RollingUpgradeStatusCodeFaulted, RollingUpgradeStatusCodeRollingForward}
}
-// ScaleTier enumerates the values for scale tier.
-type ScaleTier string
-
-const (
- // S100 ...
- S100 ScaleTier = "S100"
- // S30 ...
- S30 ScaleTier = "S30"
-)
-
-// PossibleScaleTierValues returns an array of possible values for the ScaleTier const type.
-func PossibleScaleTierValues() []ScaleTier {
- return []ScaleTier{S100, S30}
-}
-
// SettingNames enumerates the values for setting names.
type SettingNames string
@@ -417,6 +658,23 @@ func PossibleSettingNamesValues() []SettingNames {
return []SettingNames{AutoLogon, FirstLogonCommands}
}
+// SnapshotStorageAccountTypes enumerates the values for snapshot storage account types.
+type SnapshotStorageAccountTypes string
+
+const (
+ // SnapshotStorageAccountTypesPremiumLRS ...
+ SnapshotStorageAccountTypesPremiumLRS SnapshotStorageAccountTypes = "Premium_LRS"
+ // SnapshotStorageAccountTypesStandardLRS ...
+ SnapshotStorageAccountTypesStandardLRS SnapshotStorageAccountTypes = "Standard_LRS"
+ // SnapshotStorageAccountTypesStandardZRS ...
+ SnapshotStorageAccountTypesStandardZRS SnapshotStorageAccountTypes = "Standard_ZRS"
+)
+
+// PossibleSnapshotStorageAccountTypesValues returns an array of possible values for the SnapshotStorageAccountTypes const type.
+func PossibleSnapshotStorageAccountTypesValues() []SnapshotStorageAccountTypes {
+ return []SnapshotStorageAccountTypes{SnapshotStorageAccountTypesPremiumLRS, SnapshotStorageAccountTypesStandardLRS, SnapshotStorageAccountTypesStandardZRS}
+}
+
// StatusLevelTypes enumerates the values for status level types.
type StatusLevelTypes string
@@ -438,17 +696,19 @@ func PossibleStatusLevelTypesValues() []StatusLevelTypes {
type StorageAccountTypes string
const (
- // PremiumLRS ...
- PremiumLRS StorageAccountTypes = "Premium_LRS"
- // StandardLRS ...
- StandardLRS StorageAccountTypes = "Standard_LRS"
- // StandardSSDLRS ...
- StandardSSDLRS StorageAccountTypes = "StandardSSD_LRS"
+ // StorageAccountTypesPremiumLRS ...
+ StorageAccountTypesPremiumLRS StorageAccountTypes = "Premium_LRS"
+ // StorageAccountTypesStandardLRS ...
+ StorageAccountTypesStandardLRS StorageAccountTypes = "Standard_LRS"
+ // StorageAccountTypesStandardSSDLRS ...
+ StorageAccountTypesStandardSSDLRS StorageAccountTypes = "StandardSSD_LRS"
+ // StorageAccountTypesUltraSSDLRS ...
+ StorageAccountTypesUltraSSDLRS StorageAccountTypes = "UltraSSD_LRS"
)
// PossibleStorageAccountTypesValues returns an array of possible values for the StorageAccountTypes const type.
func PossibleStorageAccountTypesValues() []StorageAccountTypes {
- return []StorageAccountTypes{PremiumLRS, StandardLRS, StandardSSDLRS}
+ return []StorageAccountTypes{StorageAccountTypesPremiumLRS, StorageAccountTypesStandardLRS, StorageAccountTypesStandardSSDLRS, StorageAccountTypesUltraSSDLRS}
}
// UpgradeMode enumerates the values for upgrade mode.
@@ -553,343 +813,356 @@ func PossibleVirtualMachineScaleSetSkuScaleTypeValues() []VirtualMachineScaleSet
type VirtualMachineSizeTypes string
const (
- // BasicA0 ...
- BasicA0 VirtualMachineSizeTypes = "Basic_A0"
- // BasicA1 ...
- BasicA1 VirtualMachineSizeTypes = "Basic_A1"
- // BasicA2 ...
- BasicA2 VirtualMachineSizeTypes = "Basic_A2"
- // BasicA3 ...
- BasicA3 VirtualMachineSizeTypes = "Basic_A3"
- // BasicA4 ...
- BasicA4 VirtualMachineSizeTypes = "Basic_A4"
- // StandardA0 ...
- StandardA0 VirtualMachineSizeTypes = "Standard_A0"
- // StandardA1 ...
- StandardA1 VirtualMachineSizeTypes = "Standard_A1"
- // StandardA10 ...
- StandardA10 VirtualMachineSizeTypes = "Standard_A10"
- // StandardA11 ...
- StandardA11 VirtualMachineSizeTypes = "Standard_A11"
- // StandardA1V2 ...
- StandardA1V2 VirtualMachineSizeTypes = "Standard_A1_v2"
- // StandardA2 ...
- StandardA2 VirtualMachineSizeTypes = "Standard_A2"
- // StandardA2mV2 ...
- StandardA2mV2 VirtualMachineSizeTypes = "Standard_A2m_v2"
- // StandardA2V2 ...
- StandardA2V2 VirtualMachineSizeTypes = "Standard_A2_v2"
- // StandardA3 ...
- StandardA3 VirtualMachineSizeTypes = "Standard_A3"
- // StandardA4 ...
- StandardA4 VirtualMachineSizeTypes = "Standard_A4"
- // StandardA4mV2 ...
- StandardA4mV2 VirtualMachineSizeTypes = "Standard_A4m_v2"
- // StandardA4V2 ...
- StandardA4V2 VirtualMachineSizeTypes = "Standard_A4_v2"
- // StandardA5 ...
- StandardA5 VirtualMachineSizeTypes = "Standard_A5"
- // StandardA6 ...
- StandardA6 VirtualMachineSizeTypes = "Standard_A6"
- // StandardA7 ...
- StandardA7 VirtualMachineSizeTypes = "Standard_A7"
- // StandardA8 ...
- StandardA8 VirtualMachineSizeTypes = "Standard_A8"
- // StandardA8mV2 ...
- StandardA8mV2 VirtualMachineSizeTypes = "Standard_A8m_v2"
- // StandardA8V2 ...
- StandardA8V2 VirtualMachineSizeTypes = "Standard_A8_v2"
- // StandardA9 ...
- StandardA9 VirtualMachineSizeTypes = "Standard_A9"
- // StandardB1ms ...
- StandardB1ms VirtualMachineSizeTypes = "Standard_B1ms"
- // StandardB1s ...
- StandardB1s VirtualMachineSizeTypes = "Standard_B1s"
- // StandardB2ms ...
- StandardB2ms VirtualMachineSizeTypes = "Standard_B2ms"
- // StandardB2s ...
- StandardB2s VirtualMachineSizeTypes = "Standard_B2s"
- // StandardB4ms ...
- StandardB4ms VirtualMachineSizeTypes = "Standard_B4ms"
- // StandardB8ms ...
- StandardB8ms VirtualMachineSizeTypes = "Standard_B8ms"
- // StandardD1 ...
- StandardD1 VirtualMachineSizeTypes = "Standard_D1"
- // StandardD11 ...
- StandardD11 VirtualMachineSizeTypes = "Standard_D11"
- // StandardD11V2 ...
- StandardD11V2 VirtualMachineSizeTypes = "Standard_D11_v2"
- // StandardD12 ...
- StandardD12 VirtualMachineSizeTypes = "Standard_D12"
- // StandardD12V2 ...
- StandardD12V2 VirtualMachineSizeTypes = "Standard_D12_v2"
- // StandardD13 ...
- StandardD13 VirtualMachineSizeTypes = "Standard_D13"
- // StandardD13V2 ...
- StandardD13V2 VirtualMachineSizeTypes = "Standard_D13_v2"
- // StandardD14 ...
- StandardD14 VirtualMachineSizeTypes = "Standard_D14"
- // StandardD14V2 ...
- StandardD14V2 VirtualMachineSizeTypes = "Standard_D14_v2"
- // StandardD15V2 ...
- StandardD15V2 VirtualMachineSizeTypes = "Standard_D15_v2"
- // StandardD16sV3 ...
- StandardD16sV3 VirtualMachineSizeTypes = "Standard_D16s_v3"
- // StandardD16V3 ...
- StandardD16V3 VirtualMachineSizeTypes = "Standard_D16_v3"
- // StandardD1V2 ...
- StandardD1V2 VirtualMachineSizeTypes = "Standard_D1_v2"
- // StandardD2 ...
- StandardD2 VirtualMachineSizeTypes = "Standard_D2"
- // StandardD2sV3 ...
- StandardD2sV3 VirtualMachineSizeTypes = "Standard_D2s_v3"
- // StandardD2V2 ...
- StandardD2V2 VirtualMachineSizeTypes = "Standard_D2_v2"
- // StandardD2V3 ...
- StandardD2V3 VirtualMachineSizeTypes = "Standard_D2_v3"
- // StandardD3 ...
- StandardD3 VirtualMachineSizeTypes = "Standard_D3"
- // StandardD32sV3 ...
- StandardD32sV3 VirtualMachineSizeTypes = "Standard_D32s_v3"
- // StandardD32V3 ...
- StandardD32V3 VirtualMachineSizeTypes = "Standard_D32_v3"
- // StandardD3V2 ...
- StandardD3V2 VirtualMachineSizeTypes = "Standard_D3_v2"
- // StandardD4 ...
- StandardD4 VirtualMachineSizeTypes = "Standard_D4"
- // StandardD4sV3 ...
- StandardD4sV3 VirtualMachineSizeTypes = "Standard_D4s_v3"
- // StandardD4V2 ...
- StandardD4V2 VirtualMachineSizeTypes = "Standard_D4_v2"
- // StandardD4V3 ...
- StandardD4V3 VirtualMachineSizeTypes = "Standard_D4_v3"
- // StandardD5V2 ...
- StandardD5V2 VirtualMachineSizeTypes = "Standard_D5_v2"
- // StandardD64sV3 ...
- StandardD64sV3 VirtualMachineSizeTypes = "Standard_D64s_v3"
- // StandardD64V3 ...
- StandardD64V3 VirtualMachineSizeTypes = "Standard_D64_v3"
- // StandardD8sV3 ...
- StandardD8sV3 VirtualMachineSizeTypes = "Standard_D8s_v3"
- // StandardD8V3 ...
- StandardD8V3 VirtualMachineSizeTypes = "Standard_D8_v3"
- // StandardDS1 ...
- StandardDS1 VirtualMachineSizeTypes = "Standard_DS1"
- // StandardDS11 ...
- StandardDS11 VirtualMachineSizeTypes = "Standard_DS11"
- // StandardDS11V2 ...
- StandardDS11V2 VirtualMachineSizeTypes = "Standard_DS11_v2"
- // StandardDS12 ...
- StandardDS12 VirtualMachineSizeTypes = "Standard_DS12"
- // StandardDS12V2 ...
- StandardDS12V2 VirtualMachineSizeTypes = "Standard_DS12_v2"
- // StandardDS13 ...
- StandardDS13 VirtualMachineSizeTypes = "Standard_DS13"
- // StandardDS132V2 ...
- StandardDS132V2 VirtualMachineSizeTypes = "Standard_DS13-2_v2"
- // StandardDS134V2 ...
- StandardDS134V2 VirtualMachineSizeTypes = "Standard_DS13-4_v2"
- // StandardDS13V2 ...
- StandardDS13V2 VirtualMachineSizeTypes = "Standard_DS13_v2"
- // StandardDS14 ...
- StandardDS14 VirtualMachineSizeTypes = "Standard_DS14"
- // StandardDS144V2 ...
- StandardDS144V2 VirtualMachineSizeTypes = "Standard_DS14-4_v2"
- // StandardDS148V2 ...
- StandardDS148V2 VirtualMachineSizeTypes = "Standard_DS14-8_v2"
- // StandardDS14V2 ...
- StandardDS14V2 VirtualMachineSizeTypes = "Standard_DS14_v2"
- // StandardDS15V2 ...
- StandardDS15V2 VirtualMachineSizeTypes = "Standard_DS15_v2"
- // StandardDS1V2 ...
- StandardDS1V2 VirtualMachineSizeTypes = "Standard_DS1_v2"
- // StandardDS2 ...
- StandardDS2 VirtualMachineSizeTypes = "Standard_DS2"
- // StandardDS2V2 ...
- StandardDS2V2 VirtualMachineSizeTypes = "Standard_DS2_v2"
- // StandardDS3 ...
- StandardDS3 VirtualMachineSizeTypes = "Standard_DS3"
- // StandardDS3V2 ...
- StandardDS3V2 VirtualMachineSizeTypes = "Standard_DS3_v2"
- // StandardDS4 ...
- StandardDS4 VirtualMachineSizeTypes = "Standard_DS4"
- // StandardDS4V2 ...
- StandardDS4V2 VirtualMachineSizeTypes = "Standard_DS4_v2"
- // StandardDS5V2 ...
- StandardDS5V2 VirtualMachineSizeTypes = "Standard_DS5_v2"
- // StandardE16sV3 ...
- StandardE16sV3 VirtualMachineSizeTypes = "Standard_E16s_v3"
- // StandardE16V3 ...
- StandardE16V3 VirtualMachineSizeTypes = "Standard_E16_v3"
- // StandardE2sV3 ...
- StandardE2sV3 VirtualMachineSizeTypes = "Standard_E2s_v3"
- // StandardE2V3 ...
- StandardE2V3 VirtualMachineSizeTypes = "Standard_E2_v3"
- // StandardE3216V3 ...
- StandardE3216V3 VirtualMachineSizeTypes = "Standard_E32-16_v3"
- // StandardE328sV3 ...
- StandardE328sV3 VirtualMachineSizeTypes = "Standard_E32-8s_v3"
- // StandardE32sV3 ...
- StandardE32sV3 VirtualMachineSizeTypes = "Standard_E32s_v3"
- // StandardE32V3 ...
- StandardE32V3 VirtualMachineSizeTypes = "Standard_E32_v3"
- // StandardE4sV3 ...
- StandardE4sV3 VirtualMachineSizeTypes = "Standard_E4s_v3"
- // StandardE4V3 ...
- StandardE4V3 VirtualMachineSizeTypes = "Standard_E4_v3"
- // StandardE6416sV3 ...
- StandardE6416sV3 VirtualMachineSizeTypes = "Standard_E64-16s_v3"
- // StandardE6432sV3 ...
- StandardE6432sV3 VirtualMachineSizeTypes = "Standard_E64-32s_v3"
- // StandardE64sV3 ...
- StandardE64sV3 VirtualMachineSizeTypes = "Standard_E64s_v3"
- // StandardE64V3 ...
- StandardE64V3 VirtualMachineSizeTypes = "Standard_E64_v3"
- // StandardE8sV3 ...
- StandardE8sV3 VirtualMachineSizeTypes = "Standard_E8s_v3"
- // StandardE8V3 ...
- StandardE8V3 VirtualMachineSizeTypes = "Standard_E8_v3"
- // StandardF1 ...
- StandardF1 VirtualMachineSizeTypes = "Standard_F1"
- // StandardF16 ...
- StandardF16 VirtualMachineSizeTypes = "Standard_F16"
- // StandardF16s ...
- StandardF16s VirtualMachineSizeTypes = "Standard_F16s"
- // StandardF16sV2 ...
- StandardF16sV2 VirtualMachineSizeTypes = "Standard_F16s_v2"
- // StandardF1s ...
- StandardF1s VirtualMachineSizeTypes = "Standard_F1s"
- // StandardF2 ...
- StandardF2 VirtualMachineSizeTypes = "Standard_F2"
- // StandardF2s ...
- StandardF2s VirtualMachineSizeTypes = "Standard_F2s"
- // StandardF2sV2 ...
- StandardF2sV2 VirtualMachineSizeTypes = "Standard_F2s_v2"
- // StandardF32sV2 ...
- StandardF32sV2 VirtualMachineSizeTypes = "Standard_F32s_v2"
- // StandardF4 ...
- StandardF4 VirtualMachineSizeTypes = "Standard_F4"
- // StandardF4s ...
- StandardF4s VirtualMachineSizeTypes = "Standard_F4s"
- // StandardF4sV2 ...
- StandardF4sV2 VirtualMachineSizeTypes = "Standard_F4s_v2"
- // StandardF64sV2 ...
- StandardF64sV2 VirtualMachineSizeTypes = "Standard_F64s_v2"
- // StandardF72sV2 ...
- StandardF72sV2 VirtualMachineSizeTypes = "Standard_F72s_v2"
- // StandardF8 ...
- StandardF8 VirtualMachineSizeTypes = "Standard_F8"
- // StandardF8s ...
- StandardF8s VirtualMachineSizeTypes = "Standard_F8s"
- // StandardF8sV2 ...
- StandardF8sV2 VirtualMachineSizeTypes = "Standard_F8s_v2"
- // StandardG1 ...
- StandardG1 VirtualMachineSizeTypes = "Standard_G1"
- // StandardG2 ...
- StandardG2 VirtualMachineSizeTypes = "Standard_G2"
- // StandardG3 ...
- StandardG3 VirtualMachineSizeTypes = "Standard_G3"
- // StandardG4 ...
- StandardG4 VirtualMachineSizeTypes = "Standard_G4"
- // StandardG5 ...
- StandardG5 VirtualMachineSizeTypes = "Standard_G5"
- // StandardGS1 ...
- StandardGS1 VirtualMachineSizeTypes = "Standard_GS1"
- // StandardGS2 ...
- StandardGS2 VirtualMachineSizeTypes = "Standard_GS2"
- // StandardGS3 ...
- StandardGS3 VirtualMachineSizeTypes = "Standard_GS3"
- // StandardGS4 ...
- StandardGS4 VirtualMachineSizeTypes = "Standard_GS4"
- // StandardGS44 ...
- StandardGS44 VirtualMachineSizeTypes = "Standard_GS4-4"
- // StandardGS48 ...
- StandardGS48 VirtualMachineSizeTypes = "Standard_GS4-8"
- // StandardGS5 ...
- StandardGS5 VirtualMachineSizeTypes = "Standard_GS5"
- // StandardGS516 ...
- StandardGS516 VirtualMachineSizeTypes = "Standard_GS5-16"
- // StandardGS58 ...
- StandardGS58 VirtualMachineSizeTypes = "Standard_GS5-8"
- // StandardH16 ...
- StandardH16 VirtualMachineSizeTypes = "Standard_H16"
- // StandardH16m ...
- StandardH16m VirtualMachineSizeTypes = "Standard_H16m"
- // StandardH16mr ...
- StandardH16mr VirtualMachineSizeTypes = "Standard_H16mr"
- // StandardH16r ...
- StandardH16r VirtualMachineSizeTypes = "Standard_H16r"
- // StandardH8 ...
- StandardH8 VirtualMachineSizeTypes = "Standard_H8"
- // StandardH8m ...
- StandardH8m VirtualMachineSizeTypes = "Standard_H8m"
- // StandardL16s ...
- StandardL16s VirtualMachineSizeTypes = "Standard_L16s"
- // StandardL32s ...
- StandardL32s VirtualMachineSizeTypes = "Standard_L32s"
- // StandardL4s ...
- StandardL4s VirtualMachineSizeTypes = "Standard_L4s"
- // StandardL8s ...
- StandardL8s VirtualMachineSizeTypes = "Standard_L8s"
- // StandardM12832ms ...
- StandardM12832ms VirtualMachineSizeTypes = "Standard_M128-32ms"
- // StandardM12864ms ...
- StandardM12864ms VirtualMachineSizeTypes = "Standard_M128-64ms"
- // StandardM128ms ...
- StandardM128ms VirtualMachineSizeTypes = "Standard_M128ms"
- // StandardM128s ...
- StandardM128s VirtualMachineSizeTypes = "Standard_M128s"
- // StandardM6416ms ...
- StandardM6416ms VirtualMachineSizeTypes = "Standard_M64-16ms"
- // StandardM6432ms ...
- StandardM6432ms VirtualMachineSizeTypes = "Standard_M64-32ms"
- // StandardM64ms ...
- StandardM64ms VirtualMachineSizeTypes = "Standard_M64ms"
- // StandardM64s ...
- StandardM64s VirtualMachineSizeTypes = "Standard_M64s"
- // StandardNC12 ...
- StandardNC12 VirtualMachineSizeTypes = "Standard_NC12"
- // StandardNC12sV2 ...
- StandardNC12sV2 VirtualMachineSizeTypes = "Standard_NC12s_v2"
- // StandardNC12sV3 ...
- StandardNC12sV3 VirtualMachineSizeTypes = "Standard_NC12s_v3"
- // StandardNC24 ...
- StandardNC24 VirtualMachineSizeTypes = "Standard_NC24"
- // StandardNC24r ...
- StandardNC24r VirtualMachineSizeTypes = "Standard_NC24r"
- // StandardNC24rsV2 ...
- StandardNC24rsV2 VirtualMachineSizeTypes = "Standard_NC24rs_v2"
- // StandardNC24rsV3 ...
- StandardNC24rsV3 VirtualMachineSizeTypes = "Standard_NC24rs_v3"
- // StandardNC24sV2 ...
- StandardNC24sV2 VirtualMachineSizeTypes = "Standard_NC24s_v2"
- // StandardNC24sV3 ...
- StandardNC24sV3 VirtualMachineSizeTypes = "Standard_NC24s_v3"
- // StandardNC6 ...
- StandardNC6 VirtualMachineSizeTypes = "Standard_NC6"
- // StandardNC6sV2 ...
- StandardNC6sV2 VirtualMachineSizeTypes = "Standard_NC6s_v2"
- // StandardNC6sV3 ...
- StandardNC6sV3 VirtualMachineSizeTypes = "Standard_NC6s_v3"
- // StandardND12s ...
- StandardND12s VirtualMachineSizeTypes = "Standard_ND12s"
- // StandardND24rs ...
- StandardND24rs VirtualMachineSizeTypes = "Standard_ND24rs"
- // StandardND24s ...
- StandardND24s VirtualMachineSizeTypes = "Standard_ND24s"
- // StandardND6s ...
- StandardND6s VirtualMachineSizeTypes = "Standard_ND6s"
- // StandardNV12 ...
- StandardNV12 VirtualMachineSizeTypes = "Standard_NV12"
- // StandardNV24 ...
- StandardNV24 VirtualMachineSizeTypes = "Standard_NV24"
- // StandardNV6 ...
- StandardNV6 VirtualMachineSizeTypes = "Standard_NV6"
+ // VirtualMachineSizeTypesBasicA0 ...
+ VirtualMachineSizeTypesBasicA0 VirtualMachineSizeTypes = "Basic_A0"
+ // VirtualMachineSizeTypesBasicA1 ...
+ VirtualMachineSizeTypesBasicA1 VirtualMachineSizeTypes = "Basic_A1"
+ // VirtualMachineSizeTypesBasicA2 ...
+ VirtualMachineSizeTypesBasicA2 VirtualMachineSizeTypes = "Basic_A2"
+ // VirtualMachineSizeTypesBasicA3 ...
+ VirtualMachineSizeTypesBasicA3 VirtualMachineSizeTypes = "Basic_A3"
+ // VirtualMachineSizeTypesBasicA4 ...
+ VirtualMachineSizeTypesBasicA4 VirtualMachineSizeTypes = "Basic_A4"
+ // VirtualMachineSizeTypesStandardA0 ...
+ VirtualMachineSizeTypesStandardA0 VirtualMachineSizeTypes = "Standard_A0"
+ // VirtualMachineSizeTypesStandardA1 ...
+ VirtualMachineSizeTypesStandardA1 VirtualMachineSizeTypes = "Standard_A1"
+ // VirtualMachineSizeTypesStandardA10 ...
+ VirtualMachineSizeTypesStandardA10 VirtualMachineSizeTypes = "Standard_A10"
+ // VirtualMachineSizeTypesStandardA11 ...
+ VirtualMachineSizeTypesStandardA11 VirtualMachineSizeTypes = "Standard_A11"
+ // VirtualMachineSizeTypesStandardA1V2 ...
+ VirtualMachineSizeTypesStandardA1V2 VirtualMachineSizeTypes = "Standard_A1_v2"
+ // VirtualMachineSizeTypesStandardA2 ...
+ VirtualMachineSizeTypesStandardA2 VirtualMachineSizeTypes = "Standard_A2"
+ // VirtualMachineSizeTypesStandardA2mV2 ...
+ VirtualMachineSizeTypesStandardA2mV2 VirtualMachineSizeTypes = "Standard_A2m_v2"
+ // VirtualMachineSizeTypesStandardA2V2 ...
+ VirtualMachineSizeTypesStandardA2V2 VirtualMachineSizeTypes = "Standard_A2_v2"
+ // VirtualMachineSizeTypesStandardA3 ...
+ VirtualMachineSizeTypesStandardA3 VirtualMachineSizeTypes = "Standard_A3"
+ // VirtualMachineSizeTypesStandardA4 ...
+ VirtualMachineSizeTypesStandardA4 VirtualMachineSizeTypes = "Standard_A4"
+ // VirtualMachineSizeTypesStandardA4mV2 ...
+ VirtualMachineSizeTypesStandardA4mV2 VirtualMachineSizeTypes = "Standard_A4m_v2"
+ // VirtualMachineSizeTypesStandardA4V2 ...
+ VirtualMachineSizeTypesStandardA4V2 VirtualMachineSizeTypes = "Standard_A4_v2"
+ // VirtualMachineSizeTypesStandardA5 ...
+ VirtualMachineSizeTypesStandardA5 VirtualMachineSizeTypes = "Standard_A5"
+ // VirtualMachineSizeTypesStandardA6 ...
+ VirtualMachineSizeTypesStandardA6 VirtualMachineSizeTypes = "Standard_A6"
+ // VirtualMachineSizeTypesStandardA7 ...
+ VirtualMachineSizeTypesStandardA7 VirtualMachineSizeTypes = "Standard_A7"
+ // VirtualMachineSizeTypesStandardA8 ...
+ VirtualMachineSizeTypesStandardA8 VirtualMachineSizeTypes = "Standard_A8"
+ // VirtualMachineSizeTypesStandardA8mV2 ...
+ VirtualMachineSizeTypesStandardA8mV2 VirtualMachineSizeTypes = "Standard_A8m_v2"
+ // VirtualMachineSizeTypesStandardA8V2 ...
+ VirtualMachineSizeTypesStandardA8V2 VirtualMachineSizeTypes = "Standard_A8_v2"
+ // VirtualMachineSizeTypesStandardA9 ...
+ VirtualMachineSizeTypesStandardA9 VirtualMachineSizeTypes = "Standard_A9"
+ // VirtualMachineSizeTypesStandardB1ms ...
+ VirtualMachineSizeTypesStandardB1ms VirtualMachineSizeTypes = "Standard_B1ms"
+ // VirtualMachineSizeTypesStandardB1s ...
+ VirtualMachineSizeTypesStandardB1s VirtualMachineSizeTypes = "Standard_B1s"
+ // VirtualMachineSizeTypesStandardB2ms ...
+ VirtualMachineSizeTypesStandardB2ms VirtualMachineSizeTypes = "Standard_B2ms"
+ // VirtualMachineSizeTypesStandardB2s ...
+ VirtualMachineSizeTypesStandardB2s VirtualMachineSizeTypes = "Standard_B2s"
+ // VirtualMachineSizeTypesStandardB4ms ...
+ VirtualMachineSizeTypesStandardB4ms VirtualMachineSizeTypes = "Standard_B4ms"
+ // VirtualMachineSizeTypesStandardB8ms ...
+ VirtualMachineSizeTypesStandardB8ms VirtualMachineSizeTypes = "Standard_B8ms"
+ // VirtualMachineSizeTypesStandardD1 ...
+ VirtualMachineSizeTypesStandardD1 VirtualMachineSizeTypes = "Standard_D1"
+ // VirtualMachineSizeTypesStandardD11 ...
+ VirtualMachineSizeTypesStandardD11 VirtualMachineSizeTypes = "Standard_D11"
+ // VirtualMachineSizeTypesStandardD11V2 ...
+ VirtualMachineSizeTypesStandardD11V2 VirtualMachineSizeTypes = "Standard_D11_v2"
+ // VirtualMachineSizeTypesStandardD12 ...
+ VirtualMachineSizeTypesStandardD12 VirtualMachineSizeTypes = "Standard_D12"
+ // VirtualMachineSizeTypesStandardD12V2 ...
+ VirtualMachineSizeTypesStandardD12V2 VirtualMachineSizeTypes = "Standard_D12_v2"
+ // VirtualMachineSizeTypesStandardD13 ...
+ VirtualMachineSizeTypesStandardD13 VirtualMachineSizeTypes = "Standard_D13"
+ // VirtualMachineSizeTypesStandardD13V2 ...
+ VirtualMachineSizeTypesStandardD13V2 VirtualMachineSizeTypes = "Standard_D13_v2"
+ // VirtualMachineSizeTypesStandardD14 ...
+ VirtualMachineSizeTypesStandardD14 VirtualMachineSizeTypes = "Standard_D14"
+ // VirtualMachineSizeTypesStandardD14V2 ...
+ VirtualMachineSizeTypesStandardD14V2 VirtualMachineSizeTypes = "Standard_D14_v2"
+ // VirtualMachineSizeTypesStandardD15V2 ...
+ VirtualMachineSizeTypesStandardD15V2 VirtualMachineSizeTypes = "Standard_D15_v2"
+ // VirtualMachineSizeTypesStandardD16sV3 ...
+ VirtualMachineSizeTypesStandardD16sV3 VirtualMachineSizeTypes = "Standard_D16s_v3"
+ // VirtualMachineSizeTypesStandardD16V3 ...
+ VirtualMachineSizeTypesStandardD16V3 VirtualMachineSizeTypes = "Standard_D16_v3"
+ // VirtualMachineSizeTypesStandardD1V2 ...
+ VirtualMachineSizeTypesStandardD1V2 VirtualMachineSizeTypes = "Standard_D1_v2"
+ // VirtualMachineSizeTypesStandardD2 ...
+ VirtualMachineSizeTypesStandardD2 VirtualMachineSizeTypes = "Standard_D2"
+ // VirtualMachineSizeTypesStandardD2sV3 ...
+ VirtualMachineSizeTypesStandardD2sV3 VirtualMachineSizeTypes = "Standard_D2s_v3"
+ // VirtualMachineSizeTypesStandardD2V2 ...
+ VirtualMachineSizeTypesStandardD2V2 VirtualMachineSizeTypes = "Standard_D2_v2"
+ // VirtualMachineSizeTypesStandardD2V3 ...
+ VirtualMachineSizeTypesStandardD2V3 VirtualMachineSizeTypes = "Standard_D2_v3"
+ // VirtualMachineSizeTypesStandardD3 ...
+ VirtualMachineSizeTypesStandardD3 VirtualMachineSizeTypes = "Standard_D3"
+ // VirtualMachineSizeTypesStandardD32sV3 ...
+ VirtualMachineSizeTypesStandardD32sV3 VirtualMachineSizeTypes = "Standard_D32s_v3"
+ // VirtualMachineSizeTypesStandardD32V3 ...
+ VirtualMachineSizeTypesStandardD32V3 VirtualMachineSizeTypes = "Standard_D32_v3"
+ // VirtualMachineSizeTypesStandardD3V2 ...
+ VirtualMachineSizeTypesStandardD3V2 VirtualMachineSizeTypes = "Standard_D3_v2"
+ // VirtualMachineSizeTypesStandardD4 ...
+ VirtualMachineSizeTypesStandardD4 VirtualMachineSizeTypes = "Standard_D4"
+ // VirtualMachineSizeTypesStandardD4sV3 ...
+ VirtualMachineSizeTypesStandardD4sV3 VirtualMachineSizeTypes = "Standard_D4s_v3"
+ // VirtualMachineSizeTypesStandardD4V2 ...
+ VirtualMachineSizeTypesStandardD4V2 VirtualMachineSizeTypes = "Standard_D4_v2"
+ // VirtualMachineSizeTypesStandardD4V3 ...
+ VirtualMachineSizeTypesStandardD4V3 VirtualMachineSizeTypes = "Standard_D4_v3"
+ // VirtualMachineSizeTypesStandardD5V2 ...
+ VirtualMachineSizeTypesStandardD5V2 VirtualMachineSizeTypes = "Standard_D5_v2"
+ // VirtualMachineSizeTypesStandardD64sV3 ...
+ VirtualMachineSizeTypesStandardD64sV3 VirtualMachineSizeTypes = "Standard_D64s_v3"
+ // VirtualMachineSizeTypesStandardD64V3 ...
+ VirtualMachineSizeTypesStandardD64V3 VirtualMachineSizeTypes = "Standard_D64_v3"
+ // VirtualMachineSizeTypesStandardD8sV3 ...
+ VirtualMachineSizeTypesStandardD8sV3 VirtualMachineSizeTypes = "Standard_D8s_v3"
+ // VirtualMachineSizeTypesStandardD8V3 ...
+ VirtualMachineSizeTypesStandardD8V3 VirtualMachineSizeTypes = "Standard_D8_v3"
+ // VirtualMachineSizeTypesStandardDS1 ...
+ VirtualMachineSizeTypesStandardDS1 VirtualMachineSizeTypes = "Standard_DS1"
+ // VirtualMachineSizeTypesStandardDS11 ...
+ VirtualMachineSizeTypesStandardDS11 VirtualMachineSizeTypes = "Standard_DS11"
+ // VirtualMachineSizeTypesStandardDS11V2 ...
+ VirtualMachineSizeTypesStandardDS11V2 VirtualMachineSizeTypes = "Standard_DS11_v2"
+ // VirtualMachineSizeTypesStandardDS12 ...
+ VirtualMachineSizeTypesStandardDS12 VirtualMachineSizeTypes = "Standard_DS12"
+ // VirtualMachineSizeTypesStandardDS12V2 ...
+ VirtualMachineSizeTypesStandardDS12V2 VirtualMachineSizeTypes = "Standard_DS12_v2"
+ // VirtualMachineSizeTypesStandardDS13 ...
+ VirtualMachineSizeTypesStandardDS13 VirtualMachineSizeTypes = "Standard_DS13"
+ // VirtualMachineSizeTypesStandardDS132V2 ...
+ VirtualMachineSizeTypesStandardDS132V2 VirtualMachineSizeTypes = "Standard_DS13-2_v2"
+ // VirtualMachineSizeTypesStandardDS134V2 ...
+ VirtualMachineSizeTypesStandardDS134V2 VirtualMachineSizeTypes = "Standard_DS13-4_v2"
+ // VirtualMachineSizeTypesStandardDS13V2 ...
+ VirtualMachineSizeTypesStandardDS13V2 VirtualMachineSizeTypes = "Standard_DS13_v2"
+ // VirtualMachineSizeTypesStandardDS14 ...
+ VirtualMachineSizeTypesStandardDS14 VirtualMachineSizeTypes = "Standard_DS14"
+ // VirtualMachineSizeTypesStandardDS144V2 ...
+ VirtualMachineSizeTypesStandardDS144V2 VirtualMachineSizeTypes = "Standard_DS14-4_v2"
+ // VirtualMachineSizeTypesStandardDS148V2 ...
+ VirtualMachineSizeTypesStandardDS148V2 VirtualMachineSizeTypes = "Standard_DS14-8_v2"
+ // VirtualMachineSizeTypesStandardDS14V2 ...
+ VirtualMachineSizeTypesStandardDS14V2 VirtualMachineSizeTypes = "Standard_DS14_v2"
+ // VirtualMachineSizeTypesStandardDS15V2 ...
+ VirtualMachineSizeTypesStandardDS15V2 VirtualMachineSizeTypes = "Standard_DS15_v2"
+ // VirtualMachineSizeTypesStandardDS1V2 ...
+ VirtualMachineSizeTypesStandardDS1V2 VirtualMachineSizeTypes = "Standard_DS1_v2"
+ // VirtualMachineSizeTypesStandardDS2 ...
+ VirtualMachineSizeTypesStandardDS2 VirtualMachineSizeTypes = "Standard_DS2"
+ // VirtualMachineSizeTypesStandardDS2V2 ...
+ VirtualMachineSizeTypesStandardDS2V2 VirtualMachineSizeTypes = "Standard_DS2_v2"
+ // VirtualMachineSizeTypesStandardDS3 ...
+ VirtualMachineSizeTypesStandardDS3 VirtualMachineSizeTypes = "Standard_DS3"
+ // VirtualMachineSizeTypesStandardDS3V2 ...
+ VirtualMachineSizeTypesStandardDS3V2 VirtualMachineSizeTypes = "Standard_DS3_v2"
+ // VirtualMachineSizeTypesStandardDS4 ...
+ VirtualMachineSizeTypesStandardDS4 VirtualMachineSizeTypes = "Standard_DS4"
+ // VirtualMachineSizeTypesStandardDS4V2 ...
+ VirtualMachineSizeTypesStandardDS4V2 VirtualMachineSizeTypes = "Standard_DS4_v2"
+ // VirtualMachineSizeTypesStandardDS5V2 ...
+ VirtualMachineSizeTypesStandardDS5V2 VirtualMachineSizeTypes = "Standard_DS5_v2"
+ // VirtualMachineSizeTypesStandardE16sV3 ...
+ VirtualMachineSizeTypesStandardE16sV3 VirtualMachineSizeTypes = "Standard_E16s_v3"
+ // VirtualMachineSizeTypesStandardE16V3 ...
+ VirtualMachineSizeTypesStandardE16V3 VirtualMachineSizeTypes = "Standard_E16_v3"
+ // VirtualMachineSizeTypesStandardE2sV3 ...
+ VirtualMachineSizeTypesStandardE2sV3 VirtualMachineSizeTypes = "Standard_E2s_v3"
+ // VirtualMachineSizeTypesStandardE2V3 ...
+ VirtualMachineSizeTypesStandardE2V3 VirtualMachineSizeTypes = "Standard_E2_v3"
+ // VirtualMachineSizeTypesStandardE3216V3 ...
+ VirtualMachineSizeTypesStandardE3216V3 VirtualMachineSizeTypes = "Standard_E32-16_v3"
+ // VirtualMachineSizeTypesStandardE328sV3 ...
+ VirtualMachineSizeTypesStandardE328sV3 VirtualMachineSizeTypes = "Standard_E32-8s_v3"
+ // VirtualMachineSizeTypesStandardE32sV3 ...
+ VirtualMachineSizeTypesStandardE32sV3 VirtualMachineSizeTypes = "Standard_E32s_v3"
+ // VirtualMachineSizeTypesStandardE32V3 ...
+ VirtualMachineSizeTypesStandardE32V3 VirtualMachineSizeTypes = "Standard_E32_v3"
+ // VirtualMachineSizeTypesStandardE4sV3 ...
+ VirtualMachineSizeTypesStandardE4sV3 VirtualMachineSizeTypes = "Standard_E4s_v3"
+ // VirtualMachineSizeTypesStandardE4V3 ...
+ VirtualMachineSizeTypesStandardE4V3 VirtualMachineSizeTypes = "Standard_E4_v3"
+ // VirtualMachineSizeTypesStandardE6416sV3 ...
+ VirtualMachineSizeTypesStandardE6416sV3 VirtualMachineSizeTypes = "Standard_E64-16s_v3"
+ // VirtualMachineSizeTypesStandardE6432sV3 ...
+ VirtualMachineSizeTypesStandardE6432sV3 VirtualMachineSizeTypes = "Standard_E64-32s_v3"
+ // VirtualMachineSizeTypesStandardE64sV3 ...
+ VirtualMachineSizeTypesStandardE64sV3 VirtualMachineSizeTypes = "Standard_E64s_v3"
+ // VirtualMachineSizeTypesStandardE64V3 ...
+ VirtualMachineSizeTypesStandardE64V3 VirtualMachineSizeTypes = "Standard_E64_v3"
+ // VirtualMachineSizeTypesStandardE8sV3 ...
+ VirtualMachineSizeTypesStandardE8sV3 VirtualMachineSizeTypes = "Standard_E8s_v3"
+ // VirtualMachineSizeTypesStandardE8V3 ...
+ VirtualMachineSizeTypesStandardE8V3 VirtualMachineSizeTypes = "Standard_E8_v3"
+ // VirtualMachineSizeTypesStandardF1 ...
+ VirtualMachineSizeTypesStandardF1 VirtualMachineSizeTypes = "Standard_F1"
+ // VirtualMachineSizeTypesStandardF16 ...
+ VirtualMachineSizeTypesStandardF16 VirtualMachineSizeTypes = "Standard_F16"
+ // VirtualMachineSizeTypesStandardF16s ...
+ VirtualMachineSizeTypesStandardF16s VirtualMachineSizeTypes = "Standard_F16s"
+ // VirtualMachineSizeTypesStandardF16sV2 ...
+ VirtualMachineSizeTypesStandardF16sV2 VirtualMachineSizeTypes = "Standard_F16s_v2"
+ // VirtualMachineSizeTypesStandardF1s ...
+ VirtualMachineSizeTypesStandardF1s VirtualMachineSizeTypes = "Standard_F1s"
+ // VirtualMachineSizeTypesStandardF2 ...
+ VirtualMachineSizeTypesStandardF2 VirtualMachineSizeTypes = "Standard_F2"
+ // VirtualMachineSizeTypesStandardF2s ...
+ VirtualMachineSizeTypesStandardF2s VirtualMachineSizeTypes = "Standard_F2s"
+ // VirtualMachineSizeTypesStandardF2sV2 ...
+ VirtualMachineSizeTypesStandardF2sV2 VirtualMachineSizeTypes = "Standard_F2s_v2"
+ // VirtualMachineSizeTypesStandardF32sV2 ...
+ VirtualMachineSizeTypesStandardF32sV2 VirtualMachineSizeTypes = "Standard_F32s_v2"
+ // VirtualMachineSizeTypesStandardF4 ...
+ VirtualMachineSizeTypesStandardF4 VirtualMachineSizeTypes = "Standard_F4"
+ // VirtualMachineSizeTypesStandardF4s ...
+ VirtualMachineSizeTypesStandardF4s VirtualMachineSizeTypes = "Standard_F4s"
+ // VirtualMachineSizeTypesStandardF4sV2 ...
+ VirtualMachineSizeTypesStandardF4sV2 VirtualMachineSizeTypes = "Standard_F4s_v2"
+ // VirtualMachineSizeTypesStandardF64sV2 ...
+ VirtualMachineSizeTypesStandardF64sV2 VirtualMachineSizeTypes = "Standard_F64s_v2"
+ // VirtualMachineSizeTypesStandardF72sV2 ...
+ VirtualMachineSizeTypesStandardF72sV2 VirtualMachineSizeTypes = "Standard_F72s_v2"
+ // VirtualMachineSizeTypesStandardF8 ...
+ VirtualMachineSizeTypesStandardF8 VirtualMachineSizeTypes = "Standard_F8"
+ // VirtualMachineSizeTypesStandardF8s ...
+ VirtualMachineSizeTypesStandardF8s VirtualMachineSizeTypes = "Standard_F8s"
+ // VirtualMachineSizeTypesStandardF8sV2 ...
+ VirtualMachineSizeTypesStandardF8sV2 VirtualMachineSizeTypes = "Standard_F8s_v2"
+ // VirtualMachineSizeTypesStandardG1 ...
+ VirtualMachineSizeTypesStandardG1 VirtualMachineSizeTypes = "Standard_G1"
+ // VirtualMachineSizeTypesStandardG2 ...
+ VirtualMachineSizeTypesStandardG2 VirtualMachineSizeTypes = "Standard_G2"
+ // VirtualMachineSizeTypesStandardG3 ...
+ VirtualMachineSizeTypesStandardG3 VirtualMachineSizeTypes = "Standard_G3"
+ // VirtualMachineSizeTypesStandardG4 ...
+ VirtualMachineSizeTypesStandardG4 VirtualMachineSizeTypes = "Standard_G4"
+ // VirtualMachineSizeTypesStandardG5 ...
+ VirtualMachineSizeTypesStandardG5 VirtualMachineSizeTypes = "Standard_G5"
+ // VirtualMachineSizeTypesStandardGS1 ...
+ VirtualMachineSizeTypesStandardGS1 VirtualMachineSizeTypes = "Standard_GS1"
+ // VirtualMachineSizeTypesStandardGS2 ...
+ VirtualMachineSizeTypesStandardGS2 VirtualMachineSizeTypes = "Standard_GS2"
+ // VirtualMachineSizeTypesStandardGS3 ...
+ VirtualMachineSizeTypesStandardGS3 VirtualMachineSizeTypes = "Standard_GS3"
+ // VirtualMachineSizeTypesStandardGS4 ...
+ VirtualMachineSizeTypesStandardGS4 VirtualMachineSizeTypes = "Standard_GS4"
+ // VirtualMachineSizeTypesStandardGS44 ...
+ VirtualMachineSizeTypesStandardGS44 VirtualMachineSizeTypes = "Standard_GS4-4"
+ // VirtualMachineSizeTypesStandardGS48 ...
+ VirtualMachineSizeTypesStandardGS48 VirtualMachineSizeTypes = "Standard_GS4-8"
+ // VirtualMachineSizeTypesStandardGS5 ...
+ VirtualMachineSizeTypesStandardGS5 VirtualMachineSizeTypes = "Standard_GS5"
+ // VirtualMachineSizeTypesStandardGS516 ...
+ VirtualMachineSizeTypesStandardGS516 VirtualMachineSizeTypes = "Standard_GS5-16"
+ // VirtualMachineSizeTypesStandardGS58 ...
+ VirtualMachineSizeTypesStandardGS58 VirtualMachineSizeTypes = "Standard_GS5-8"
+ // VirtualMachineSizeTypesStandardH16 ...
+ VirtualMachineSizeTypesStandardH16 VirtualMachineSizeTypes = "Standard_H16"
+ // VirtualMachineSizeTypesStandardH16m ...
+ VirtualMachineSizeTypesStandardH16m VirtualMachineSizeTypes = "Standard_H16m"
+ // VirtualMachineSizeTypesStandardH16mr ...
+ VirtualMachineSizeTypesStandardH16mr VirtualMachineSizeTypes = "Standard_H16mr"
+ // VirtualMachineSizeTypesStandardH16r ...
+ VirtualMachineSizeTypesStandardH16r VirtualMachineSizeTypes = "Standard_H16r"
+ // VirtualMachineSizeTypesStandardH8 ...
+ VirtualMachineSizeTypesStandardH8 VirtualMachineSizeTypes = "Standard_H8"
+ // VirtualMachineSizeTypesStandardH8m ...
+ VirtualMachineSizeTypesStandardH8m VirtualMachineSizeTypes = "Standard_H8m"
+ // VirtualMachineSizeTypesStandardL16s ...
+ VirtualMachineSizeTypesStandardL16s VirtualMachineSizeTypes = "Standard_L16s"
+ // VirtualMachineSizeTypesStandardL32s ...
+ VirtualMachineSizeTypesStandardL32s VirtualMachineSizeTypes = "Standard_L32s"
+ // VirtualMachineSizeTypesStandardL4s ...
+ VirtualMachineSizeTypesStandardL4s VirtualMachineSizeTypes = "Standard_L4s"
+ // VirtualMachineSizeTypesStandardL8s ...
+ VirtualMachineSizeTypesStandardL8s VirtualMachineSizeTypes = "Standard_L8s"
+ // VirtualMachineSizeTypesStandardM12832ms ...
+ VirtualMachineSizeTypesStandardM12832ms VirtualMachineSizeTypes = "Standard_M128-32ms"
+ // VirtualMachineSizeTypesStandardM12864ms ...
+ VirtualMachineSizeTypesStandardM12864ms VirtualMachineSizeTypes = "Standard_M128-64ms"
+ // VirtualMachineSizeTypesStandardM128ms ...
+ VirtualMachineSizeTypesStandardM128ms VirtualMachineSizeTypes = "Standard_M128ms"
+ // VirtualMachineSizeTypesStandardM128s ...
+ VirtualMachineSizeTypesStandardM128s VirtualMachineSizeTypes = "Standard_M128s"
+ // VirtualMachineSizeTypesStandardM6416ms ...
+ VirtualMachineSizeTypesStandardM6416ms VirtualMachineSizeTypes = "Standard_M64-16ms"
+ // VirtualMachineSizeTypesStandardM6432ms ...
+ VirtualMachineSizeTypesStandardM6432ms VirtualMachineSizeTypes = "Standard_M64-32ms"
+ // VirtualMachineSizeTypesStandardM64ms ...
+ VirtualMachineSizeTypesStandardM64ms VirtualMachineSizeTypes = "Standard_M64ms"
+ // VirtualMachineSizeTypesStandardM64s ...
+ VirtualMachineSizeTypesStandardM64s VirtualMachineSizeTypes = "Standard_M64s"
+ // VirtualMachineSizeTypesStandardNC12 ...
+ VirtualMachineSizeTypesStandardNC12 VirtualMachineSizeTypes = "Standard_NC12"
+ // VirtualMachineSizeTypesStandardNC12sV2 ...
+ VirtualMachineSizeTypesStandardNC12sV2 VirtualMachineSizeTypes = "Standard_NC12s_v2"
+ // VirtualMachineSizeTypesStandardNC12sV3 ...
+ VirtualMachineSizeTypesStandardNC12sV3 VirtualMachineSizeTypes = "Standard_NC12s_v3"
+ // VirtualMachineSizeTypesStandardNC24 ...
+ VirtualMachineSizeTypesStandardNC24 VirtualMachineSizeTypes = "Standard_NC24"
+ // VirtualMachineSizeTypesStandardNC24r ...
+ VirtualMachineSizeTypesStandardNC24r VirtualMachineSizeTypes = "Standard_NC24r"
+ // VirtualMachineSizeTypesStandardNC24rsV2 ...
+ VirtualMachineSizeTypesStandardNC24rsV2 VirtualMachineSizeTypes = "Standard_NC24rs_v2"
+ // VirtualMachineSizeTypesStandardNC24rsV3 ...
+ VirtualMachineSizeTypesStandardNC24rsV3 VirtualMachineSizeTypes = "Standard_NC24rs_v3"
+ // VirtualMachineSizeTypesStandardNC24sV2 ...
+ VirtualMachineSizeTypesStandardNC24sV2 VirtualMachineSizeTypes = "Standard_NC24s_v2"
+ // VirtualMachineSizeTypesStandardNC24sV3 ...
+ VirtualMachineSizeTypesStandardNC24sV3 VirtualMachineSizeTypes = "Standard_NC24s_v3"
+ // VirtualMachineSizeTypesStandardNC6 ...
+ VirtualMachineSizeTypesStandardNC6 VirtualMachineSizeTypes = "Standard_NC6"
+ // VirtualMachineSizeTypesStandardNC6sV2 ...
+ VirtualMachineSizeTypesStandardNC6sV2 VirtualMachineSizeTypes = "Standard_NC6s_v2"
+ // VirtualMachineSizeTypesStandardNC6sV3 ...
+ VirtualMachineSizeTypesStandardNC6sV3 VirtualMachineSizeTypes = "Standard_NC6s_v3"
+ // VirtualMachineSizeTypesStandardND12s ...
+ VirtualMachineSizeTypesStandardND12s VirtualMachineSizeTypes = "Standard_ND12s"
+ // VirtualMachineSizeTypesStandardND24rs ...
+ VirtualMachineSizeTypesStandardND24rs VirtualMachineSizeTypes = "Standard_ND24rs"
+ // VirtualMachineSizeTypesStandardND24s ...
+ VirtualMachineSizeTypesStandardND24s VirtualMachineSizeTypes = "Standard_ND24s"
+ // VirtualMachineSizeTypesStandardND6s ...
+ VirtualMachineSizeTypesStandardND6s VirtualMachineSizeTypes = "Standard_ND6s"
+ // VirtualMachineSizeTypesStandardNV12 ...
+ VirtualMachineSizeTypesStandardNV12 VirtualMachineSizeTypes = "Standard_NV12"
+ // VirtualMachineSizeTypesStandardNV24 ...
+ VirtualMachineSizeTypesStandardNV24 VirtualMachineSizeTypes = "Standard_NV24"
+ // VirtualMachineSizeTypesStandardNV6 ...
+ VirtualMachineSizeTypesStandardNV6 VirtualMachineSizeTypes = "Standard_NV6"
)
// PossibleVirtualMachineSizeTypesValues returns an array of possible values for the VirtualMachineSizeTypes const type.
func PossibleVirtualMachineSizeTypesValues() []VirtualMachineSizeTypes {
- return []VirtualMachineSizeTypes{BasicA0, BasicA1, BasicA2, BasicA3, BasicA4, StandardA0, StandardA1, StandardA10, StandardA11, StandardA1V2, StandardA2, StandardA2mV2, StandardA2V2, StandardA3, StandardA4, StandardA4mV2, StandardA4V2, StandardA5, StandardA6, StandardA7, StandardA8, StandardA8mV2, StandardA8V2, StandardA9, StandardB1ms, StandardB1s, StandardB2ms, StandardB2s, StandardB4ms, StandardB8ms, StandardD1, StandardD11, StandardD11V2, StandardD12, StandardD12V2, StandardD13, StandardD13V2, StandardD14, StandardD14V2, StandardD15V2, StandardD16sV3, StandardD16V3, StandardD1V2, StandardD2, StandardD2sV3, StandardD2V2, StandardD2V3, StandardD3, StandardD32sV3, StandardD32V3, StandardD3V2, StandardD4, StandardD4sV3, StandardD4V2, StandardD4V3, StandardD5V2, StandardD64sV3, StandardD64V3, StandardD8sV3, StandardD8V3, StandardDS1, StandardDS11, StandardDS11V2, StandardDS12, StandardDS12V2, StandardDS13, StandardDS132V2, StandardDS134V2, StandardDS13V2, StandardDS14, StandardDS144V2, StandardDS148V2, StandardDS14V2, StandardDS15V2, StandardDS1V2, StandardDS2, StandardDS2V2, StandardDS3, StandardDS3V2, StandardDS4, StandardDS4V2, StandardDS5V2, StandardE16sV3, StandardE16V3, StandardE2sV3, StandardE2V3, StandardE3216V3, StandardE328sV3, StandardE32sV3, StandardE32V3, StandardE4sV3, StandardE4V3, StandardE6416sV3, StandardE6432sV3, StandardE64sV3, StandardE64V3, StandardE8sV3, StandardE8V3, StandardF1, StandardF16, StandardF16s, StandardF16sV2, StandardF1s, StandardF2, StandardF2s, StandardF2sV2, StandardF32sV2, StandardF4, StandardF4s, StandardF4sV2, StandardF64sV2, StandardF72sV2, StandardF8, StandardF8s, StandardF8sV2, StandardG1, StandardG2, StandardG3, StandardG4, StandardG5, StandardGS1, StandardGS2, StandardGS3, StandardGS4, StandardGS44, StandardGS48, StandardGS5, StandardGS516, StandardGS58, StandardH16, StandardH16m, StandardH16mr, StandardH16r, StandardH8, StandardH8m, StandardL16s, StandardL32s, StandardL4s, StandardL8s, StandardM12832ms, StandardM12864ms, StandardM128ms, StandardM128s, StandardM6416ms, StandardM6432ms, StandardM64ms, StandardM64s, StandardNC12, StandardNC12sV2, StandardNC12sV3, StandardNC24, StandardNC24r, StandardNC24rsV2, StandardNC24rsV3, StandardNC24sV2, StandardNC24sV3, StandardNC6, StandardNC6sV2, StandardNC6sV3, StandardND12s, StandardND24rs, StandardND24s, StandardND6s, StandardNV12, StandardNV24, StandardNV6}
+ return []VirtualMachineSizeTypes{VirtualMachineSizeTypesBasicA0, VirtualMachineSizeTypesBasicA1, VirtualMachineSizeTypesBasicA2, VirtualMachineSizeTypesBasicA3, VirtualMachineSizeTypesBasicA4, VirtualMachineSizeTypesStandardA0, VirtualMachineSizeTypesStandardA1, VirtualMachineSizeTypesStandardA10, VirtualMachineSizeTypesStandardA11, VirtualMachineSizeTypesStandardA1V2, VirtualMachineSizeTypesStandardA2, VirtualMachineSizeTypesStandardA2mV2, VirtualMachineSizeTypesStandardA2V2, VirtualMachineSizeTypesStandardA3, VirtualMachineSizeTypesStandardA4, VirtualMachineSizeTypesStandardA4mV2, VirtualMachineSizeTypesStandardA4V2, VirtualMachineSizeTypesStandardA5, VirtualMachineSizeTypesStandardA6, VirtualMachineSizeTypesStandardA7, VirtualMachineSizeTypesStandardA8, VirtualMachineSizeTypesStandardA8mV2, VirtualMachineSizeTypesStandardA8V2, VirtualMachineSizeTypesStandardA9, VirtualMachineSizeTypesStandardB1ms, VirtualMachineSizeTypesStandardB1s, VirtualMachineSizeTypesStandardB2ms, VirtualMachineSizeTypesStandardB2s, VirtualMachineSizeTypesStandardB4ms, VirtualMachineSizeTypesStandardB8ms, VirtualMachineSizeTypesStandardD1, VirtualMachineSizeTypesStandardD11, VirtualMachineSizeTypesStandardD11V2, VirtualMachineSizeTypesStandardD12, VirtualMachineSizeTypesStandardD12V2, VirtualMachineSizeTypesStandardD13, VirtualMachineSizeTypesStandardD13V2, VirtualMachineSizeTypesStandardD14, VirtualMachineSizeTypesStandardD14V2, VirtualMachineSizeTypesStandardD15V2, VirtualMachineSizeTypesStandardD16sV3, VirtualMachineSizeTypesStandardD16V3, VirtualMachineSizeTypesStandardD1V2, VirtualMachineSizeTypesStandardD2, VirtualMachineSizeTypesStandardD2sV3, VirtualMachineSizeTypesStandardD2V2, VirtualMachineSizeTypesStandardD2V3, VirtualMachineSizeTypesStandardD3, VirtualMachineSizeTypesStandardD32sV3, VirtualMachineSizeTypesStandardD32V3, VirtualMachineSizeTypesStandardD3V2, VirtualMachineSizeTypesStandardD4, VirtualMachineSizeTypesStandardD4sV3, VirtualMachineSizeTypesStandardD4V2, VirtualMachineSizeTypesStandardD4V3, VirtualMachineSizeTypesStandardD5V2, VirtualMachineSizeTypesStandardD64sV3, VirtualMachineSizeTypesStandardD64V3, VirtualMachineSizeTypesStandardD8sV3, VirtualMachineSizeTypesStandardD8V3, VirtualMachineSizeTypesStandardDS1, VirtualMachineSizeTypesStandardDS11, VirtualMachineSizeTypesStandardDS11V2, VirtualMachineSizeTypesStandardDS12, VirtualMachineSizeTypesStandardDS12V2, VirtualMachineSizeTypesStandardDS13, VirtualMachineSizeTypesStandardDS132V2, VirtualMachineSizeTypesStandardDS134V2, VirtualMachineSizeTypesStandardDS13V2, VirtualMachineSizeTypesStandardDS14, VirtualMachineSizeTypesStandardDS144V2, VirtualMachineSizeTypesStandardDS148V2, VirtualMachineSizeTypesStandardDS14V2, VirtualMachineSizeTypesStandardDS15V2, VirtualMachineSizeTypesStandardDS1V2, VirtualMachineSizeTypesStandardDS2, VirtualMachineSizeTypesStandardDS2V2, VirtualMachineSizeTypesStandardDS3, VirtualMachineSizeTypesStandardDS3V2, VirtualMachineSizeTypesStandardDS4, VirtualMachineSizeTypesStandardDS4V2, VirtualMachineSizeTypesStandardDS5V2, VirtualMachineSizeTypesStandardE16sV3, VirtualMachineSizeTypesStandardE16V3, VirtualMachineSizeTypesStandardE2sV3, VirtualMachineSizeTypesStandardE2V3, VirtualMachineSizeTypesStandardE3216V3, VirtualMachineSizeTypesStandardE328sV3, VirtualMachineSizeTypesStandardE32sV3, VirtualMachineSizeTypesStandardE32V3, VirtualMachineSizeTypesStandardE4sV3, VirtualMachineSizeTypesStandardE4V3, VirtualMachineSizeTypesStandardE6416sV3, VirtualMachineSizeTypesStandardE6432sV3, VirtualMachineSizeTypesStandardE64sV3, VirtualMachineSizeTypesStandardE64V3, VirtualMachineSizeTypesStandardE8sV3, VirtualMachineSizeTypesStandardE8V3, VirtualMachineSizeTypesStandardF1, VirtualMachineSizeTypesStandardF16, VirtualMachineSizeTypesStandardF16s, VirtualMachineSizeTypesStandardF16sV2, VirtualMachineSizeTypesStandardF1s, VirtualMachineSizeTypesStandardF2, VirtualMachineSizeTypesStandardF2s, VirtualMachineSizeTypesStandardF2sV2, VirtualMachineSizeTypesStandardF32sV2, VirtualMachineSizeTypesStandardF4, VirtualMachineSizeTypesStandardF4s, VirtualMachineSizeTypesStandardF4sV2, VirtualMachineSizeTypesStandardF64sV2, VirtualMachineSizeTypesStandardF72sV2, VirtualMachineSizeTypesStandardF8, VirtualMachineSizeTypesStandardF8s, VirtualMachineSizeTypesStandardF8sV2, VirtualMachineSizeTypesStandardG1, VirtualMachineSizeTypesStandardG2, VirtualMachineSizeTypesStandardG3, VirtualMachineSizeTypesStandardG4, VirtualMachineSizeTypesStandardG5, VirtualMachineSizeTypesStandardGS1, VirtualMachineSizeTypesStandardGS2, VirtualMachineSizeTypesStandardGS3, VirtualMachineSizeTypesStandardGS4, VirtualMachineSizeTypesStandardGS44, VirtualMachineSizeTypesStandardGS48, VirtualMachineSizeTypesStandardGS5, VirtualMachineSizeTypesStandardGS516, VirtualMachineSizeTypesStandardGS58, VirtualMachineSizeTypesStandardH16, VirtualMachineSizeTypesStandardH16m, VirtualMachineSizeTypesStandardH16mr, VirtualMachineSizeTypesStandardH16r, VirtualMachineSizeTypesStandardH8, VirtualMachineSizeTypesStandardH8m, VirtualMachineSizeTypesStandardL16s, VirtualMachineSizeTypesStandardL32s, VirtualMachineSizeTypesStandardL4s, VirtualMachineSizeTypesStandardL8s, VirtualMachineSizeTypesStandardM12832ms, VirtualMachineSizeTypesStandardM12864ms, VirtualMachineSizeTypesStandardM128ms, VirtualMachineSizeTypesStandardM128s, VirtualMachineSizeTypesStandardM6416ms, VirtualMachineSizeTypesStandardM6432ms, VirtualMachineSizeTypesStandardM64ms, VirtualMachineSizeTypesStandardM64s, VirtualMachineSizeTypesStandardNC12, VirtualMachineSizeTypesStandardNC12sV2, VirtualMachineSizeTypesStandardNC12sV3, VirtualMachineSizeTypesStandardNC24, VirtualMachineSizeTypesStandardNC24r, VirtualMachineSizeTypesStandardNC24rsV2, VirtualMachineSizeTypesStandardNC24rsV3, VirtualMachineSizeTypesStandardNC24sV2, VirtualMachineSizeTypesStandardNC24sV3, VirtualMachineSizeTypesStandardNC6, VirtualMachineSizeTypesStandardNC6sV2, VirtualMachineSizeTypesStandardNC6sV3, VirtualMachineSizeTypesStandardND12s, VirtualMachineSizeTypesStandardND24rs, VirtualMachineSizeTypesStandardND24s, VirtualMachineSizeTypesStandardND6s, VirtualMachineSizeTypesStandardNV12, VirtualMachineSizeTypesStandardNV24, VirtualMachineSizeTypesStandardNV6}
+}
+
+// AccessURI a disk access SAS uri.
+type AccessURI struct {
+ autorest.Response `json:"-"`
+ // AccessSAS - A SAS uri for accessing a disk.
+ AccessSAS *string `json:"accessSAS,omitempty"`
+}
+
+// AdditionalCapabilities enables or disables a capability on the virtual machine or virtual machine scale set.
+type AdditionalCapabilities struct {
+ // UltraSSDEnabled - The flag that enables or disables a capability to have one or more managed data disks with UltraSSD_LRS storage account type on the VM or VMSS. Managed disks with storage account type UltraSSD_LRS can be added to a virtual machine or virtual machine scale set only if this property is enabled.
+ UltraSSDEnabled *bool `json:"ultraSSDEnabled,omitempty"`
}
// AdditionalUnattendContent specifies additional XML formatted information that can be included in the
@@ -953,7 +1226,7 @@ type AutoOSUpgradePolicy struct {
type AvailabilitySet struct {
autorest.Response `json:"-"`
*AvailabilitySetProperties `json:"properties,omitempty"`
- // Sku - Sku of the availability set
+ // Sku - Sku of the availability set, only name is required to be set. See AvailabilitySetSkuTypes for possible set of values. Use 'Aligned' for virtual machines with managed disks and 'Classic' for virtual machines with unmanaged disks. Default value is 'Classic'.
Sku *Sku `json:"sku,omitempty"`
// ID - Resource Id
ID *string `json:"id,omitempty"`
@@ -1277,6 +1550,392 @@ type CloudError struct {
Error *APIError `json:"error,omitempty"`
}
+// ContainerService container service.
+type ContainerService struct {
+ autorest.Response `json:"-"`
+ *ContainerServiceProperties `json:"properties,omitempty"`
+ // ID - Resource Id
+ ID *string `json:"id,omitempty"`
+ // Name - Resource name
+ Name *string `json:"name,omitempty"`
+ // Type - Resource type
+ Type *string `json:"type,omitempty"`
+ // Location - Resource location
+ Location *string `json:"location,omitempty"`
+ // Tags - Resource tags
+ Tags map[string]*string `json:"tags"`
+}
+
+// MarshalJSON is the custom marshaler for ContainerService.
+func (cs ContainerService) MarshalJSON() ([]byte, error) {
+ objectMap := make(map[string]interface{})
+ if cs.ContainerServiceProperties != nil {
+ objectMap["properties"] = cs.ContainerServiceProperties
+ }
+ if cs.ID != nil {
+ objectMap["id"] = cs.ID
+ }
+ if cs.Name != nil {
+ objectMap["name"] = cs.Name
+ }
+ if cs.Type != nil {
+ objectMap["type"] = cs.Type
+ }
+ if cs.Location != nil {
+ objectMap["location"] = cs.Location
+ }
+ if cs.Tags != nil {
+ objectMap["tags"] = cs.Tags
+ }
+ return json.Marshal(objectMap)
+}
+
+// UnmarshalJSON is the custom unmarshaler for ContainerService struct.
+func (cs *ContainerService) UnmarshalJSON(body []byte) error {
+ var m map[string]*json.RawMessage
+ err := json.Unmarshal(body, &m)
+ if err != nil {
+ return err
+ }
+ for k, v := range m {
+ switch k {
+ case "properties":
+ if v != nil {
+ var containerServiceProperties ContainerServiceProperties
+ err = json.Unmarshal(*v, &containerServiceProperties)
+ if err != nil {
+ return err
+ }
+ cs.ContainerServiceProperties = &containerServiceProperties
+ }
+ case "id":
+ if v != nil {
+ var ID string
+ err = json.Unmarshal(*v, &ID)
+ if err != nil {
+ return err
+ }
+ cs.ID = &ID
+ }
+ case "name":
+ if v != nil {
+ var name string
+ err = json.Unmarshal(*v, &name)
+ if err != nil {
+ return err
+ }
+ cs.Name = &name
+ }
+ case "type":
+ if v != nil {
+ var typeVar string
+ err = json.Unmarshal(*v, &typeVar)
+ if err != nil {
+ return err
+ }
+ cs.Type = &typeVar
+ }
+ case "location":
+ if v != nil {
+ var location string
+ err = json.Unmarshal(*v, &location)
+ if err != nil {
+ return err
+ }
+ cs.Location = &location
+ }
+ case "tags":
+ if v != nil {
+ var tags map[string]*string
+ err = json.Unmarshal(*v, &tags)
+ if err != nil {
+ return err
+ }
+ cs.Tags = tags
+ }
+ }
+ }
+
+ return nil
+}
+
+// ContainerServiceAgentPoolProfile profile for the container service agent pool.
+type ContainerServiceAgentPoolProfile struct {
+ // Name - Unique name of the agent pool profile in the context of the subscription and resource group.
+ Name *string `json:"name,omitempty"`
+ // Count - Number of agents (VMs) to host docker containers. Allowed values must be in the range of 1 to 100 (inclusive). The default value is 1.
+ Count *int32 `json:"count,omitempty"`
+ // VMSize - Size of agent VMs. Possible values include: 'StandardA0', 'StandardA1', 'StandardA2', 'StandardA3', 'StandardA4', 'StandardA5', 'StandardA6', 'StandardA7', 'StandardA8', 'StandardA9', 'StandardA10', 'StandardA11', 'StandardD1', 'StandardD2', 'StandardD3', 'StandardD4', 'StandardD11', 'StandardD12', 'StandardD13', 'StandardD14', 'StandardD1V2', 'StandardD2V2', 'StandardD3V2', 'StandardD4V2', 'StandardD5V2', 'StandardD11V2', 'StandardD12V2', 'StandardD13V2', 'StandardD14V2', 'StandardG1', 'StandardG2', 'StandardG3', 'StandardG4', 'StandardG5', 'StandardDS1', 'StandardDS2', 'StandardDS3', 'StandardDS4', 'StandardDS11', 'StandardDS12', 'StandardDS13', 'StandardDS14', 'StandardGS1', 'StandardGS2', 'StandardGS3', 'StandardGS4', 'StandardGS5'
+ VMSize ContainerServiceVMSizeTypes `json:"vmSize,omitempty"`
+ // DNSPrefix - DNS prefix to be used to create the FQDN for the agent pool.
+ DNSPrefix *string `json:"dnsPrefix,omitempty"`
+ // Fqdn - FDQN for the agent pool.
+ Fqdn *string `json:"fqdn,omitempty"`
+}
+
+// ContainerServiceCustomProfile properties to configure a custom container service cluster.
+type ContainerServiceCustomProfile struct {
+ // Orchestrator - The name of the custom orchestrator to use.
+ Orchestrator *string `json:"orchestrator,omitempty"`
+}
+
+// ContainerServiceDiagnosticsProfile ...
+type ContainerServiceDiagnosticsProfile struct {
+ // VMDiagnostics - Profile for the container service VM diagnostic agent.
+ VMDiagnostics *ContainerServiceVMDiagnostics `json:"vmDiagnostics,omitempty"`
+}
+
+// ContainerServiceLinuxProfile profile for Linux VMs in the container service cluster.
+type ContainerServiceLinuxProfile struct {
+ // AdminUsername - The administrator username to use for Linux VMs.
+ AdminUsername *string `json:"adminUsername,omitempty"`
+ // SSH - The ssh key configuration for Linux VMs.
+ SSH *ContainerServiceSSHConfiguration `json:"ssh,omitempty"`
+}
+
+// ContainerServiceListResult the response from the List Container Services operation.
+type ContainerServiceListResult struct {
+ autorest.Response `json:"-"`
+ // Value - the list of container services.
+ Value *[]ContainerService `json:"value,omitempty"`
+ // NextLink - The URL to get the next set of container service results.
+ NextLink *string `json:"nextLink,omitempty"`
+}
+
+// ContainerServiceListResultIterator provides access to a complete listing of ContainerService values.
+type ContainerServiceListResultIterator struct {
+ i int
+ page ContainerServiceListResultPage
+}
+
+// Next advances to the next value. If there was an error making
+// the request the iterator does not advance and the error is returned.
+func (iter *ContainerServiceListResultIterator) Next() error {
+ iter.i++
+ if iter.i < len(iter.page.Values()) {
+ return nil
+ }
+ err := iter.page.Next()
+ if err != nil {
+ iter.i--
+ return err
+ }
+ iter.i = 0
+ return nil
+}
+
+// NotDone returns true if the enumeration should be started or is not yet complete.
+func (iter ContainerServiceListResultIterator) NotDone() bool {
+ return iter.page.NotDone() && iter.i < len(iter.page.Values())
+}
+
+// Response returns the raw server response from the last page request.
+func (iter ContainerServiceListResultIterator) Response() ContainerServiceListResult {
+ return iter.page.Response()
+}
+
+// Value returns the current value or a zero-initialized value if the
+// iterator has advanced beyond the end of the collection.
+func (iter ContainerServiceListResultIterator) Value() ContainerService {
+ if !iter.page.NotDone() {
+ return ContainerService{}
+ }
+ return iter.page.Values()[iter.i]
+}
+
+// IsEmpty returns true if the ListResult contains no values.
+func (cslr ContainerServiceListResult) IsEmpty() bool {
+ return cslr.Value == nil || len(*cslr.Value) == 0
+}
+
+// containerServiceListResultPreparer prepares a request to retrieve the next set of results.
+// It returns nil if no more results exist.
+func (cslr ContainerServiceListResult) containerServiceListResultPreparer() (*http.Request, error) {
+ if cslr.NextLink == nil || len(to.String(cslr.NextLink)) < 1 {
+ return nil, nil
+ }
+ return autorest.Prepare(&http.Request{},
+ autorest.AsJSON(),
+ autorest.AsGet(),
+ autorest.WithBaseURL(to.String(cslr.NextLink)))
+}
+
+// ContainerServiceListResultPage contains a page of ContainerService values.
+type ContainerServiceListResultPage struct {
+ fn func(ContainerServiceListResult) (ContainerServiceListResult, error)
+ cslr ContainerServiceListResult
+}
+
+// Next advances to the next page of values. If there was an error making
+// the request the page does not advance and the error is returned.
+func (page *ContainerServiceListResultPage) Next() error {
+ next, err := page.fn(page.cslr)
+ if err != nil {
+ return err
+ }
+ page.cslr = next
+ return nil
+}
+
+// NotDone returns true if the page enumeration should be started or is not yet complete.
+func (page ContainerServiceListResultPage) NotDone() bool {
+ return !page.cslr.IsEmpty()
+}
+
+// Response returns the raw server response from the last page request.
+func (page ContainerServiceListResultPage) Response() ContainerServiceListResult {
+ return page.cslr
+}
+
+// Values returns the slice of values for the current page or nil if there are no values.
+func (page ContainerServiceListResultPage) Values() []ContainerService {
+ if page.cslr.IsEmpty() {
+ return nil
+ }
+ return *page.cslr.Value
+}
+
+// ContainerServiceMasterProfile profile for the container service master.
+type ContainerServiceMasterProfile struct {
+ // Count - Number of masters (VMs) in the container service cluster. Allowed values are 1, 3, and 5. The default value is 1.
+ Count *int32 `json:"count,omitempty"`
+ // DNSPrefix - DNS prefix to be used to create the FQDN for master.
+ DNSPrefix *string `json:"dnsPrefix,omitempty"`
+ // Fqdn - FDQN for the master.
+ Fqdn *string `json:"fqdn,omitempty"`
+}
+
+// ContainerServiceOrchestratorProfile profile for the container service orchestrator.
+type ContainerServiceOrchestratorProfile struct {
+ // OrchestratorType - The orchestrator to use to manage container service cluster resources. Valid values are Swarm, DCOS, and Custom. Possible values include: 'Swarm', 'DCOS', 'Custom', 'Kubernetes'
+ OrchestratorType ContainerServiceOrchestratorTypes `json:"orchestratorType,omitempty"`
+}
+
+// ContainerServiceProperties properties of the container service.
+type ContainerServiceProperties struct {
+ // ProvisioningState - the current deployment or provisioning state, which only appears in the response.
+ ProvisioningState *string `json:"provisioningState,omitempty"`
+ // OrchestratorProfile - Properties of the orchestrator.
+ OrchestratorProfile *ContainerServiceOrchestratorProfile `json:"orchestratorProfile,omitempty"`
+ // CustomProfile - Properties for custom clusters.
+ CustomProfile *ContainerServiceCustomProfile `json:"customProfile,omitempty"`
+ // ServicePrincipalProfile - Properties for cluster service principals.
+ ServicePrincipalProfile *ContainerServiceServicePrincipalProfile `json:"servicePrincipalProfile,omitempty"`
+ // MasterProfile - Properties of master agents.
+ MasterProfile *ContainerServiceMasterProfile `json:"masterProfile,omitempty"`
+ // AgentPoolProfiles - Properties of the agent pool.
+ AgentPoolProfiles *[]ContainerServiceAgentPoolProfile `json:"agentPoolProfiles,omitempty"`
+ // WindowsProfile - Properties of Windows VMs.
+ WindowsProfile *ContainerServiceWindowsProfile `json:"windowsProfile,omitempty"`
+ // LinuxProfile - Properties of Linux VMs.
+ LinuxProfile *ContainerServiceLinuxProfile `json:"linuxProfile,omitempty"`
+ // DiagnosticsProfile - Properties of the diagnostic agent.
+ DiagnosticsProfile *ContainerServiceDiagnosticsProfile `json:"diagnosticsProfile,omitempty"`
+}
+
+// ContainerServicesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running
+// operation.
+type ContainerServicesCreateOrUpdateFuture struct {
+ azure.Future
+}
+
+// Result returns the result of the asynchronous operation.
+// If the operation has not completed it will return an error.
+func (future *ContainerServicesCreateOrUpdateFuture) Result(client ContainerServicesClient) (cs ContainerService, err error) {
+ var done bool
+ done, err = future.Done(client)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.ContainerServicesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure")
+ return
+ }
+ if !done {
+ err = azure.NewAsyncOpIncompleteError("compute.ContainerServicesCreateOrUpdateFuture")
+ return
+ }
+ sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
+ if cs.Response.Response, err = future.GetResult(sender); err == nil && cs.Response.Response.StatusCode != http.StatusNoContent {
+ cs, err = client.CreateOrUpdateResponder(cs.Response.Response)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.ContainerServicesCreateOrUpdateFuture", "Result", cs.Response.Response, "Failure responding to request")
+ }
+ }
+ return
+}
+
+// ContainerServicesDeleteFuture an abstraction for monitoring and retrieving the results of a long-running
+// operation.
+type ContainerServicesDeleteFuture struct {
+ azure.Future
+}
+
+// Result returns the result of the asynchronous operation.
+// If the operation has not completed it will return an error.
+func (future *ContainerServicesDeleteFuture) Result(client ContainerServicesClient) (ar autorest.Response, err error) {
+ var done bool
+ done, err = future.Done(client)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.ContainerServicesDeleteFuture", "Result", future.Response(), "Polling failure")
+ return
+ }
+ if !done {
+ err = azure.NewAsyncOpIncompleteError("compute.ContainerServicesDeleteFuture")
+ return
+ }
+ ar.Response = future.Response()
+ return
+}
+
+// ContainerServiceServicePrincipalProfile information about a service principal identity for the cluster to use
+// for manipulating Azure APIs.
+type ContainerServiceServicePrincipalProfile struct {
+ // ClientID - The ID for the service principal.
+ ClientID *string `json:"clientId,omitempty"`
+ // Secret - The secret password associated with the service principal.
+ Secret *string `json:"secret,omitempty"`
+}
+
+// ContainerServiceSSHConfiguration SSH configuration for Linux-based VMs running on Azure.
+type ContainerServiceSSHConfiguration struct {
+ // PublicKeys - the list of SSH public keys used to authenticate with Linux-based VMs.
+ PublicKeys *[]ContainerServiceSSHPublicKey `json:"publicKeys,omitempty"`
+}
+
+// ContainerServiceSSHPublicKey contains information about SSH certificate public key data.
+type ContainerServiceSSHPublicKey struct {
+ // KeyData - Certificate public key used to authenticate with VMs through SSH. The certificate must be in PEM format with or without headers.
+ KeyData *string `json:"keyData,omitempty"`
+}
+
+// ContainerServiceVMDiagnostics profile for diagnostics on the container service VMs.
+type ContainerServiceVMDiagnostics struct {
+ // Enabled - Whether the VM diagnostic agent is provisioned on the VM.
+ Enabled *bool `json:"enabled,omitempty"`
+ // StorageURI - The URI of the storage account where diagnostics are stored.
+ StorageURI *string `json:"storageUri,omitempty"`
+}
+
+// ContainerServiceWindowsProfile profile for Windows VMs in the container service cluster.
+type ContainerServiceWindowsProfile struct {
+ // AdminUsername - The administrator username to use for Windows VMs.
+ AdminUsername *string `json:"adminUsername,omitempty"`
+ // AdminPassword - The administrator password to use for Windows VMs.
+ AdminPassword *string `json:"adminPassword,omitempty"`
+}
+
+// CreationData data used when creating a disk.
+type CreationData struct {
+ // CreateOption - This enumerates the possible sources of a disk's creation. Possible values include: 'Empty', 'Attach', 'FromImage', 'Import', 'Copy', 'Restore'
+ CreateOption DiskCreateOption `json:"createOption,omitempty"`
+ // StorageAccountID - If createOption is Import, the Azure Resource Manager identifier of the storage account containing the blob to import as a disk. Required only if the blob is in a different subscription
+ StorageAccountID *string `json:"storageAccountId,omitempty"`
+ // ImageReference - Disk source information.
+ ImageReference *ImageDiskReference `json:"imageReference,omitempty"`
+ // SourceURI - If createOption is Import, this is the URI of a blob to be imported into a managed disk.
+ SourceURI *string `json:"sourceUri,omitempty"`
+ // SourceResourceID - If createOption is Copy, this is the ARM id of the source snapshot or disk.
+ SourceResourceID *string `json:"sourceResourceId,omitempty"`
+}
+
// DataDisk describes a data disk.
type DataDisk struct {
// Lun - Specifies the logical unit number of the data disk. This value is used to identify data disks within the VM and therefore must be unique for each data disk attached to a VM.
@@ -1287,13 +1946,13 @@ type DataDisk struct {
Vhd *VirtualHardDisk `json:"vhd,omitempty"`
// Image - The source user image virtual hard disk. The virtual hard disk will be copied before being attached to the virtual machine. If SourceImage is provided, the destination virtual hard drive must not exist.
Image *VirtualHardDisk `json:"image,omitempty"`
- // Caching - Specifies the caching requirements.
Possible values are:
**None**
**ReadOnly**
**ReadWrite**
Default: **None for Standard storage. ReadOnly for Premium storage**. Possible values include: 'None', 'ReadOnly', 'ReadWrite'
+ // Caching - Specifies the caching requirements.
Possible values are:
**None**
**ReadOnly**
**ReadWrite**
Default: **None for Standard storage. ReadOnly for Premium storage**. Possible values include: 'CachingTypesNone', 'CachingTypesReadOnly', 'CachingTypesReadWrite'
Caching CachingTypes `json:"caching,omitempty"`
// WriteAcceleratorEnabled - Specifies whether writeAccelerator should be enabled or disabled on the disk.
WriteAcceleratorEnabled *bool `json:"writeAcceleratorEnabled,omitempty"`
- // CreateOption - Specifies how the virtual machine should be created.
Possible values are:
**Attach** \u2013 This value is used when you are using a specialized disk to create the virtual machine.
**FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the plan element previously described. Possible values include: 'FromImage', 'Empty', 'Attach'
+ // CreateOption - Specifies how the virtual machine should be created.
Possible values are:
**Attach** \u2013 This value is used when you are using a specialized disk to create the virtual machine.
**FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the plan element previously described. Possible values include: 'DiskCreateOptionTypesFromImage', 'DiskCreateOptionTypesEmpty', 'DiskCreateOptionTypesAttach'
CreateOption DiskCreateOptionTypes `json:"createOption,omitempty"`
- // DiskSizeGB - Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image.
This value cannot be larger than 1023 GB
+ // DiskSizeGB - Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image.
This value cannot be larger than 1023 GB
DiskSizeGB *int32 `json:"diskSizeGB,omitempty"`
// ManagedDisk - The managed disk parameters.
ManagedDisk *ManagedDiskParameters `json:"managedDisk,omitempty"`
@@ -1311,12 +1970,169 @@ type DiagnosticsProfile struct {
BootDiagnostics *BootDiagnostics `json:"bootDiagnostics,omitempty"`
}
+// DiffDiskSettings describes the parameters of differencing disk settings that can be be specified for operating
+// system disk.
NOTE: The differencing disk settings can only be specified for managed disk.
+type DiffDiskSettings struct {
+ // Option - Specifies the differencing disk settings for operating system disk. Possible values include: 'Local'
+ Option DiffDiskOptions `json:"option,omitempty"`
+}
+
// Disallowed describes the disallowed disk types.
type Disallowed struct {
// DiskTypes - A list of disk types.
DiskTypes *[]string `json:"diskTypes,omitempty"`
}
+// Disk disk resource.
+type Disk struct {
+ autorest.Response `json:"-"`
+ // ManagedBy - A relative URI containing the ID of the VM that has the disk attached.
+ ManagedBy *string `json:"managedBy,omitempty"`
+ Sku *DiskSku `json:"sku,omitempty"`
+ // Zones - The Logical zone list for Disk.
+ Zones *[]string `json:"zones,omitempty"`
+ *DiskProperties `json:"properties,omitempty"`
+ // ID - Resource Id
+ ID *string `json:"id,omitempty"`
+ // Name - Resource name
+ Name *string `json:"name,omitempty"`
+ // Type - Resource type
+ Type *string `json:"type,omitempty"`
+ // Location - Resource location
+ Location *string `json:"location,omitempty"`
+ // Tags - Resource tags
+ Tags map[string]*string `json:"tags"`
+}
+
+// MarshalJSON is the custom marshaler for Disk.
+func (d Disk) MarshalJSON() ([]byte, error) {
+ objectMap := make(map[string]interface{})
+ if d.ManagedBy != nil {
+ objectMap["managedBy"] = d.ManagedBy
+ }
+ if d.Sku != nil {
+ objectMap["sku"] = d.Sku
+ }
+ if d.Zones != nil {
+ objectMap["zones"] = d.Zones
+ }
+ if d.DiskProperties != nil {
+ objectMap["properties"] = d.DiskProperties
+ }
+ if d.ID != nil {
+ objectMap["id"] = d.ID
+ }
+ if d.Name != nil {
+ objectMap["name"] = d.Name
+ }
+ if d.Type != nil {
+ objectMap["type"] = d.Type
+ }
+ if d.Location != nil {
+ objectMap["location"] = d.Location
+ }
+ if d.Tags != nil {
+ objectMap["tags"] = d.Tags
+ }
+ return json.Marshal(objectMap)
+}
+
+// UnmarshalJSON is the custom unmarshaler for Disk struct.
+func (d *Disk) UnmarshalJSON(body []byte) error {
+ var m map[string]*json.RawMessage
+ err := json.Unmarshal(body, &m)
+ if err != nil {
+ return err
+ }
+ for k, v := range m {
+ switch k {
+ case "managedBy":
+ if v != nil {
+ var managedBy string
+ err = json.Unmarshal(*v, &managedBy)
+ if err != nil {
+ return err
+ }
+ d.ManagedBy = &managedBy
+ }
+ case "sku":
+ if v != nil {
+ var sku DiskSku
+ err = json.Unmarshal(*v, &sku)
+ if err != nil {
+ return err
+ }
+ d.Sku = &sku
+ }
+ case "zones":
+ if v != nil {
+ var zones []string
+ err = json.Unmarshal(*v, &zones)
+ if err != nil {
+ return err
+ }
+ d.Zones = &zones
+ }
+ case "properties":
+ if v != nil {
+ var diskProperties DiskProperties
+ err = json.Unmarshal(*v, &diskProperties)
+ if err != nil {
+ return err
+ }
+ d.DiskProperties = &diskProperties
+ }
+ case "id":
+ if v != nil {
+ var ID string
+ err = json.Unmarshal(*v, &ID)
+ if err != nil {
+ return err
+ }
+ d.ID = &ID
+ }
+ case "name":
+ if v != nil {
+ var name string
+ err = json.Unmarshal(*v, &name)
+ if err != nil {
+ return err
+ }
+ d.Name = &name
+ }
+ case "type":
+ if v != nil {
+ var typeVar string
+ err = json.Unmarshal(*v, &typeVar)
+ if err != nil {
+ return err
+ }
+ d.Type = &typeVar
+ }
+ case "location":
+ if v != nil {
+ var location string
+ err = json.Unmarshal(*v, &location)
+ if err != nil {
+ return err
+ }
+ d.Location = &location
+ }
+ case "tags":
+ if v != nil {
+ var tags map[string]*string
+ err = json.Unmarshal(*v, &tags)
+ if err != nil {
+ return err
+ }
+ d.Tags = tags
+ }
+ }
+ }
+
+ return nil
+}
+
// DiskEncryptionSettings describes a Encryption Settings for a Disk
type DiskEncryptionSettings struct {
// DiskEncryptionKey - Specifies the location of the disk encryption key, which is a Key Vault Secret.
@@ -1337,6 +2153,353 @@ type DiskInstanceView struct {
Statuses *[]InstanceViewStatus `json:"statuses,omitempty"`
}
+// DiskList the List Disks operation response.
+type DiskList struct {
+ autorest.Response `json:"-"`
+ // Value - A list of disks.
+ Value *[]Disk `json:"value,omitempty"`
+ // NextLink - The uri to fetch the next page of disks. Call ListNext() with this to fetch the next page of disks.
+ NextLink *string `json:"nextLink,omitempty"`
+}
+
+// DiskListIterator provides access to a complete listing of Disk values.
+type DiskListIterator struct {
+ i int
+ page DiskListPage
+}
+
+// Next advances to the next value. If there was an error making
+// the request the iterator does not advance and the error is returned.
+func (iter *DiskListIterator) Next() error {
+ iter.i++
+ if iter.i < len(iter.page.Values()) {
+ return nil
+ }
+ err := iter.page.Next()
+ if err != nil {
+ iter.i--
+ return err
+ }
+ iter.i = 0
+ return nil
+}
+
+// NotDone returns true if the enumeration should be started or is not yet complete.
+func (iter DiskListIterator) NotDone() bool {
+ return iter.page.NotDone() && iter.i < len(iter.page.Values())
+}
+
+// Response returns the raw server response from the last page request.
+func (iter DiskListIterator) Response() DiskList {
+ return iter.page.Response()
+}
+
+// Value returns the current value or a zero-initialized value if the
+// iterator has advanced beyond the end of the collection.
+func (iter DiskListIterator) Value() Disk {
+ if !iter.page.NotDone() {
+ return Disk{}
+ }
+ return iter.page.Values()[iter.i]
+}
+
+// IsEmpty returns true if the ListResult contains no values.
+func (dl DiskList) IsEmpty() bool {
+ return dl.Value == nil || len(*dl.Value) == 0
+}
+
+// diskListPreparer prepares a request to retrieve the next set of results.
+// It returns nil if no more results exist.
+func (dl DiskList) diskListPreparer() (*http.Request, error) {
+ if dl.NextLink == nil || len(to.String(dl.NextLink)) < 1 {
+ return nil, nil
+ }
+ return autorest.Prepare(&http.Request{},
+ autorest.AsJSON(),
+ autorest.AsGet(),
+ autorest.WithBaseURL(to.String(dl.NextLink)))
+}
+
+// DiskListPage contains a page of Disk values.
+type DiskListPage struct {
+ fn func(DiskList) (DiskList, error)
+ dl DiskList
+}
+
+// Next advances to the next page of values. If there was an error making
+// the request the page does not advance and the error is returned.
+func (page *DiskListPage) Next() error {
+ next, err := page.fn(page.dl)
+ if err != nil {
+ return err
+ }
+ page.dl = next
+ return nil
+}
+
+// NotDone returns true if the page enumeration should be started or is not yet complete.
+func (page DiskListPage) NotDone() bool {
+ return !page.dl.IsEmpty()
+}
+
+// Response returns the raw server response from the last page request.
+func (page DiskListPage) Response() DiskList {
+ return page.dl
+}
+
+// Values returns the slice of values for the current page or nil if there are no values.
+func (page DiskListPage) Values() []Disk {
+ if page.dl.IsEmpty() {
+ return nil
+ }
+ return *page.dl.Value
+}
+
+// DiskProperties disk resource properties.
+type DiskProperties struct {
+ // TimeCreated - The time when the disk was created.
+ TimeCreated *date.Time `json:"timeCreated,omitempty"`
+ // OsType - The Operating System type. Possible values include: 'Windows', 'Linux'
+ OsType OperatingSystemTypes `json:"osType,omitempty"`
+ // CreationData - Disk source information. CreationData information cannot be changed after the disk has been created.
+ CreationData *CreationData `json:"creationData,omitempty"`
+ // DiskSizeGB - If creationData.createOption is Empty, this field is mandatory and it indicates the size of the VHD to create. If this field is present for updates or creation with other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a running VM, and can only increase the disk's size.
+ DiskSizeGB *int32 `json:"diskSizeGB,omitempty"`
+ // EncryptionSettings - Encryption settings for disk or snapshot
+ EncryptionSettings *EncryptionSettings `json:"encryptionSettings,omitempty"`
+ // ProvisioningState - The disk provisioning state.
+ ProvisioningState *string `json:"provisioningState,omitempty"`
+ // DiskIOPSReadWrite - The number of IOPS allowed for this disk; only settable for UltraSSD disks. One operation can transfer between 4k and 256k bytes.
+ DiskIOPSReadWrite *int64 `json:"diskIOPSReadWrite,omitempty"`
+ // DiskMBpsReadWrite - The bandwidth allowed for this disk; only settable for UltraSSD disks. MBps means millions of bytes per second - MB here uses the ISO notation, of powers of 10.
+ DiskMBpsReadWrite *int32 `json:"diskMBpsReadWrite,omitempty"`
+}
+
+// DisksCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running operation.
+type DisksCreateOrUpdateFuture struct {
+ azure.Future
+}
+
+// Result returns the result of the asynchronous operation.
+// If the operation has not completed it will return an error.
+func (future *DisksCreateOrUpdateFuture) Result(client DisksClient) (d Disk, err error) {
+ var done bool
+ done, err = future.Done(client)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.DisksCreateOrUpdateFuture", "Result", future.Response(), "Polling failure")
+ return
+ }
+ if !done {
+ err = azure.NewAsyncOpIncompleteError("compute.DisksCreateOrUpdateFuture")
+ return
+ }
+ sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
+ if d.Response.Response, err = future.GetResult(sender); err == nil && d.Response.Response.StatusCode != http.StatusNoContent {
+ d, err = client.CreateOrUpdateResponder(d.Response.Response)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.DisksCreateOrUpdateFuture", "Result", d.Response.Response, "Failure responding to request")
+ }
+ }
+ return
+}
+
+// DisksDeleteFuture an abstraction for monitoring and retrieving the results of a long-running operation.
+type DisksDeleteFuture struct {
+ azure.Future
+}
+
+// Result returns the result of the asynchronous operation.
+// If the operation has not completed it will return an error.
+func (future *DisksDeleteFuture) Result(client DisksClient) (ar autorest.Response, err error) {
+ var done bool
+ done, err = future.Done(client)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.DisksDeleteFuture", "Result", future.Response(), "Polling failure")
+ return
+ }
+ if !done {
+ err = azure.NewAsyncOpIncompleteError("compute.DisksDeleteFuture")
+ return
+ }
+ ar.Response = future.Response()
+ return
+}
+
+// DisksGrantAccessFuture an abstraction for monitoring and retrieving the results of a long-running operation.
+type DisksGrantAccessFuture struct {
+ azure.Future
+}
+
+// Result returns the result of the asynchronous operation.
+// If the operation has not completed it will return an error.
+func (future *DisksGrantAccessFuture) Result(client DisksClient) (au AccessURI, err error) {
+ var done bool
+ done, err = future.Done(client)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.DisksGrantAccessFuture", "Result", future.Response(), "Polling failure")
+ return
+ }
+ if !done {
+ err = azure.NewAsyncOpIncompleteError("compute.DisksGrantAccessFuture")
+ return
+ }
+ sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
+ if au.Response.Response, err = future.GetResult(sender); err == nil && au.Response.Response.StatusCode != http.StatusNoContent {
+ au, err = client.GrantAccessResponder(au.Response.Response)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.DisksGrantAccessFuture", "Result", au.Response.Response, "Failure responding to request")
+ }
+ }
+ return
+}
+
+// DiskSku the disks sku name. Can be Standard_LRS, Premium_LRS, StandardSSD_LRS, or UltraSSD_LRS.
+type DiskSku struct {
+ // Name - The sku name. Possible values include: 'StandardLRS', 'PremiumLRS', 'StandardSSDLRS', 'UltraSSDLRS'
+ Name DiskStorageAccountTypes `json:"name,omitempty"`
+ // Tier - The sku tier.
+ Tier *string `json:"tier,omitempty"`
+}
+
+// DisksRevokeAccessFuture an abstraction for monitoring and retrieving the results of a long-running operation.
+type DisksRevokeAccessFuture struct {
+ azure.Future
+}
+
+// Result returns the result of the asynchronous operation.
+// If the operation has not completed it will return an error.
+func (future *DisksRevokeAccessFuture) Result(client DisksClient) (ar autorest.Response, err error) {
+ var done bool
+ done, err = future.Done(client)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.DisksRevokeAccessFuture", "Result", future.Response(), "Polling failure")
+ return
+ }
+ if !done {
+ err = azure.NewAsyncOpIncompleteError("compute.DisksRevokeAccessFuture")
+ return
+ }
+ ar.Response = future.Response()
+ return
+}
+
+// DisksUpdateFuture an abstraction for monitoring and retrieving the results of a long-running operation.
+type DisksUpdateFuture struct {
+ azure.Future
+}
+
+// Result returns the result of the asynchronous operation.
+// If the operation has not completed it will return an error.
+func (future *DisksUpdateFuture) Result(client DisksClient) (d Disk, err error) {
+ var done bool
+ done, err = future.Done(client)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.DisksUpdateFuture", "Result", future.Response(), "Polling failure")
+ return
+ }
+ if !done {
+ err = azure.NewAsyncOpIncompleteError("compute.DisksUpdateFuture")
+ return
+ }
+ sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
+ if d.Response.Response, err = future.GetResult(sender); err == nil && d.Response.Response.StatusCode != http.StatusNoContent {
+ d, err = client.UpdateResponder(d.Response.Response)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.DisksUpdateFuture", "Result", d.Response.Response, "Failure responding to request")
+ }
+ }
+ return
+}
+
+// DiskUpdate disk update resource.
+type DiskUpdate struct {
+ *DiskUpdateProperties `json:"properties,omitempty"`
+ // Tags - Resource tags
+ Tags map[string]*string `json:"tags"`
+ Sku *DiskSku `json:"sku,omitempty"`
+}
+
+// MarshalJSON is the custom marshaler for DiskUpdate.
+func (du DiskUpdate) MarshalJSON() ([]byte, error) {
+ objectMap := make(map[string]interface{})
+ if du.DiskUpdateProperties != nil {
+ objectMap["properties"] = du.DiskUpdateProperties
+ }
+ if du.Tags != nil {
+ objectMap["tags"] = du.Tags
+ }
+ if du.Sku != nil {
+ objectMap["sku"] = du.Sku
+ }
+ return json.Marshal(objectMap)
+}
+
+// UnmarshalJSON is the custom unmarshaler for DiskUpdate struct.
+func (du *DiskUpdate) UnmarshalJSON(body []byte) error {
+ var m map[string]*json.RawMessage
+ err := json.Unmarshal(body, &m)
+ if err != nil {
+ return err
+ }
+ for k, v := range m {
+ switch k {
+ case "properties":
+ if v != nil {
+ var diskUpdateProperties DiskUpdateProperties
+ err = json.Unmarshal(*v, &diskUpdateProperties)
+ if err != nil {
+ return err
+ }
+ du.DiskUpdateProperties = &diskUpdateProperties
+ }
+ case "tags":
+ if v != nil {
+ var tags map[string]*string
+ err = json.Unmarshal(*v, &tags)
+ if err != nil {
+ return err
+ }
+ du.Tags = tags
+ }
+ case "sku":
+ if v != nil {
+ var sku DiskSku
+ err = json.Unmarshal(*v, &sku)
+ if err != nil {
+ return err
+ }
+ du.Sku = &sku
+ }
+ }
+ }
+
+ return nil
+}
+
+// DiskUpdateProperties disk resource update properties.
+type DiskUpdateProperties struct {
+ // OsType - the Operating System type. Possible values include: 'Windows', 'Linux'
+ OsType OperatingSystemTypes `json:"osType,omitempty"`
+ // DiskSizeGB - If creationData.createOption is Empty, this field is mandatory and it indicates the size of the VHD to create. If this field is present for updates or creation with other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a running VM, and can only increase the disk's size.
+ DiskSizeGB *int32 `json:"diskSizeGB,omitempty"`
+ // EncryptionSettings - Encryption settings for disk or snapshot
+ EncryptionSettings *EncryptionSettings `json:"encryptionSettings,omitempty"`
+ // DiskIOPSReadWrite - The number of IOPS allowed for this disk; only settable for UltraSSD disks. One operation can transfer between 4k and 256k bytes.
+ DiskIOPSReadWrite *int64 `json:"diskIOPSReadWrite,omitempty"`
+ // DiskMBpsReadWrite - The bandwidth allowed for this disk; only settable for UltraSSD disks. MBps means millions of bytes per second - MB here uses the ISO notation, of powers of 10.
+ DiskMBpsReadWrite *int32 `json:"diskMBpsReadWrite,omitempty"`
+}
+
+// EncryptionSettings encryption settings for disk or snapshot
+type EncryptionSettings struct {
+ // Enabled - Set this flag to true and provide DiskEncryptionKey and optional KeyEncryptionKey to enable encryption. Set this flag to false and remove DiskEncryptionKey and KeyEncryptionKey to disable encryption. If EncryptionSettings is null in the request object, the existing settings remain unchanged.
+ Enabled *bool `json:"enabled,omitempty"`
+ // DiskEncryptionKey - Key Vault Secret Url and vault id of the disk encryption key
+ DiskEncryptionKey *KeyVaultAndSecretReference `json:"diskEncryptionKey,omitempty"`
+ // KeyEncryptionKey - Key Vault Key Url and vault id of the key encryption key
+ KeyEncryptionKey *KeyVaultAndKeyReference `json:"keyEncryptionKey,omitempty"`
+}
+
// GalleriesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running
// operation.
type GalleriesCreateOrUpdateFuture struct {
@@ -1388,7 +2551,7 @@ func (future *GalleriesDeleteFuture) Result(client GalleriesClient) (ar autorest
return
}
-// Gallery specifies information about the gallery that you want to create or update.
+// Gallery specifies information about the Shared Image Gallery that you want to create or update.
type Gallery struct {
autorest.Response `json:"-"`
*GalleryProperties `json:"properties,omitempty"`
@@ -1499,21 +2662,21 @@ func (g *Gallery) UnmarshalJSON(body []byte) error {
// GalleryArtifactPublishingProfileBase describes the basic gallery artifact publishing profile.
type GalleryArtifactPublishingProfileBase struct {
- // Regions - The regions where the artifact is going to be published.
- Regions *[]string `json:"regions,omitempty"`
- Source *GalleryArtifactSource `json:"source,omitempty"`
+ // TargetRegions - The target regions where the Image Version is going to be replicated to. This property is updateable.
+ TargetRegions *[]TargetRegion `json:"targetRegions,omitempty"`
+ Source *GalleryArtifactSource `json:"source,omitempty"`
}
-// GalleryArtifactSource the source of the gallery artifact.
+// GalleryArtifactSource the source image from which the Image Version is going to be created.
type GalleryArtifactSource struct {
ManagedImage *ManagedArtifact `json:"managedImage,omitempty"`
}
// GalleryDataDiskImage this is the data disk image.
type GalleryDataDiskImage struct {
- // Lun - Specifies the logical unit number of the data disk. This value is used to identify data disks within the VM and therefore must be unique for each data disk attached to a VM.
+ // Lun - This property specifies the logical unit number of the data disk. This value is used to identify data disks within the Virtual Machine and therefore must be unique for each data disk attached to the Virtual Machine.
Lun *int32 `json:"lun,omitempty"`
- // SizeInGB - It indicates the size of the VHD to create.
+ // SizeInGB - This property indicates the size of the VHD to be created.
SizeInGB *int32 `json:"sizeInGB,omitempty"`
// HostCaching - The host caching of the disk. Valid values are 'None', 'ReadOnly', and 'ReadWrite'. Possible values include: 'HostCachingNone', 'HostCachingReadOnly', 'HostCachingReadWrite'
HostCaching HostCaching `json:"hostCaching,omitempty"`
@@ -1521,7 +2684,7 @@ type GalleryDataDiskImage struct {
// GalleryDiskImage this is the disk image base class.
type GalleryDiskImage struct {
- // SizeInGB - It indicates the size of the VHD to create.
+ // SizeInGB - This property indicates the size of the VHD to be created.
SizeInGB *int32 `json:"sizeInGB,omitempty"`
// HostCaching - The host caching of the disk. Valid values are 'None', 'ReadOnly', and 'ReadWrite'. Possible values include: 'HostCachingNone', 'HostCachingReadOnly', 'HostCachingReadWrite'
HostCaching HostCaching `json:"hostCaching,omitempty"`
@@ -1529,11 +2692,11 @@ type GalleryDiskImage struct {
// GalleryIdentifier describes the gallery unique name.
type GalleryIdentifier struct {
- // UniqueName - The unique name of the gallery
+ // UniqueName - The unique name of the Shared Image Gallery. This name is generated automatically by Azure.
UniqueName *string `json:"uniqueName,omitempty"`
}
-// GalleryImage specifies information about the gallery image that you want to create or update.
+// GalleryImage specifies information about the gallery Image Definition that you want to create or update.
type GalleryImage struct {
autorest.Response `json:"-"`
*GalleryImageProperties `json:"properties,omitempty"`
@@ -1642,22 +2805,22 @@ func (gi *GalleryImage) UnmarshalJSON(body []byte) error {
return nil
}
-// GalleryImageIdentifier this is the gallery image identifier.
+// GalleryImageIdentifier this is the gallery Image Definition identifier.
type GalleryImageIdentifier struct {
- // Publisher - The gallery image publisher name.
+ // Publisher - The name of the gallery Image Definition publisher.
Publisher *string `json:"publisher,omitempty"`
- // Offer - The gallery image offer name.
+ // Offer - The name of the gallery Image Definition offer.
Offer *string `json:"offer,omitempty"`
- // Sku - The gallery image sku name.
+ // Sku - The name of the gallery Image Definition SKU.
Sku *string `json:"sku,omitempty"`
}
// GalleryImageList the List Gallery Images operation response.
type GalleryImageList struct {
autorest.Response `json:"-"`
- // Value - A list of gallery images.
+ // Value - A list of Shared Image Gallery images.
Value *[]GalleryImage `json:"value,omitempty"`
- // NextLink - The uri to fetch the next page of gallery images. Call ListNext() with this to fetch the next page of gallery images.
+ // NextLink - The uri to fetch the next page of Image Definitions in the Shared Image Gallery. Call ListNext() with this to fetch the next page of gallery Image Definitions.
NextLink *string `json:"nextLink,omitempty"`
}
@@ -1754,21 +2917,21 @@ func (page GalleryImageListPage) Values() []GalleryImage {
return *page.gil.Value
}
-// GalleryImageProperties describes the properties of a gallery image.
+// GalleryImageProperties describes the properties of a gallery Image Definition.
type GalleryImageProperties struct {
- // Description - The description of this gallery image resource.
+ // Description - The description of this gallery Image Definition resource. This property is updateable.
Description *string `json:"description,omitempty"`
- // Eula - The Eula agreement for the gallery image.
+ // Eula - The Eula agreement for the gallery Image Definition.
Eula *string `json:"eula,omitempty"`
// PrivacyStatementURI - The privacy statement uri.
PrivacyStatementURI *string `json:"privacyStatementUri,omitempty"`
// ReleaseNoteURI - The release note uri.
ReleaseNoteURI *string `json:"releaseNoteUri,omitempty"`
- // OsType - This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD.
Possible values are:
**Windows**
**Linux**. Possible values include: 'Windows', 'Linux'
+ // OsType - This property allows you to specify the type of the OS that is included in the disk when creating a VM from a managed image.
Possible values are:
**Windows**
**Linux**. Possible values include: 'Windows', 'Linux'
OsType OperatingSystemTypes `json:"osType,omitempty"`
- // OsState - The OS State. Possible values include: 'Generalized', 'Specialized'
+ // OsState - The allowed values for OS State are 'Generalized'. Possible values include: 'Generalized', 'Specialized'
OsState OperatingSystemStateTypes `json:"osState,omitempty"`
- // EndOfLifeDate - The end of life of this gallery image.
+ // EndOfLifeDate - The end of life date of the gallery Image Definition. This property can be used for decommissioning purposes. This property is updateable.
EndOfLifeDate *date.Time `json:"endOfLifeDate,omitempty"`
Identifier *GalleryImageIdentifier `json:"identifier,omitempty"`
Recommended *RecommendedMachineConfiguration `json:"recommended,omitempty"`
@@ -1829,7 +2992,7 @@ func (future *GalleryImagesDeleteFuture) Result(client GalleryImagesClient) (ar
return
}
-// GalleryImageVersion specifies information about the gallery image version that you want to create or update.
+// GalleryImageVersion specifies information about the gallery Image Version that you want to create or update.
type GalleryImageVersion struct {
autorest.Response `json:"-"`
*GalleryImageVersionProperties `json:"properties,omitempty"`
@@ -1941,9 +3104,9 @@ func (giv *GalleryImageVersion) UnmarshalJSON(body []byte) error {
// GalleryImageVersionList the List Gallery Image version operation response.
type GalleryImageVersionList struct {
autorest.Response `json:"-"`
- // Value - A list of gallery image versions.
+ // Value - A list of gallery Image Versions.
Value *[]GalleryImageVersion `json:"value,omitempty"`
- // NextLink - The uri to fetch the next page of gallery image versions. Call ListNext() with this to fetch the next page of gallery image versions.
+ // NextLink - The uri to fetch the next page of gallery Image Versions. Call ListNext() with this to fetch the next page of gallery Image Versions.
NextLink *string `json:"nextLink,omitempty"`
}
@@ -2040,7 +3203,7 @@ func (page GalleryImageVersionListPage) Values() []GalleryImageVersion {
return *page.givl.Value
}
-// GalleryImageVersionProperties describes the properties of a gallery image version.
+// GalleryImageVersionProperties describes the properties of a gallery Image Version.
type GalleryImageVersionProperties struct {
PublishingProfile *GalleryImageVersionPublishingProfile `json:"publishingProfile,omitempty"`
// ProvisioningState - The provisioning state, which only appears in the response. Possible values include: 'ProvisioningState2Creating', 'ProvisioningState2Updating', 'ProvisioningState2Failed', 'ProvisioningState2Succeeded', 'ProvisioningState2Deleting', 'ProvisioningState2Migrating'
@@ -2049,19 +3212,19 @@ type GalleryImageVersionProperties struct {
ReplicationStatus *ReplicationStatus `json:"replicationStatus,omitempty"`
}
-// GalleryImageVersionPublishingProfile the publishing profile of a gallery image version.
+// GalleryImageVersionPublishingProfile the publishing profile of a gallery Image Version.
type GalleryImageVersionPublishingProfile struct {
- // ScaleTier - The scale tier of the gallery image version. Valid values are 'S30' and 'S100'. Possible values include: 'S30', 'S100'
- ScaleTier ScaleTier `json:"scaleTier,omitempty"`
- // ExcludeFromLatest - The flag means that if it is set to true, people deploying VMs with 'latest' as version will not use this version.
+ // ReplicaCount - The number of replicas of the Image Version to be created per region. This property would take effect for a region when regionalReplicaCount is not specified. This property is updateable.
+ ReplicaCount *int32 `json:"replicaCount,omitempty"`
+ // ExcludeFromLatest - If set to true, Virtual Machines deployed from the latest version of the Image Definition won't use this Image Version.
ExcludeFromLatest *bool `json:"excludeFromLatest,omitempty"`
- // PublishedDate - The time when the gallery image version is published.
+ // PublishedDate - The timestamp for when the gallery Image Version is published.
PublishedDate *date.Time `json:"publishedDate,omitempty"`
- // EndOfLifeDate - The end of life date of the gallery image version.
+ // EndOfLifeDate - The end of life date of the gallery Image Version. This property can be used for decommissioning purposes. This property is updateable.
EndOfLifeDate *date.Time `json:"endOfLifeDate,omitempty"`
- // Regions - The regions where the artifact is going to be published.
- Regions *[]string `json:"regions,omitempty"`
- Source *GalleryArtifactSource `json:"source,omitempty"`
+ // TargetRegions - The target regions where the Image Version is going to be replicated to. This property is updateable.
+ TargetRegions *[]TargetRegion `json:"targetRegions,omitempty"`
+ Source *GalleryArtifactSource `json:"source,omitempty"`
}
// GalleryImageVersionsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a
@@ -2116,7 +3279,7 @@ func (future *GalleryImageVersionsDeleteFuture) Result(client GalleryImageVersio
return
}
-// GalleryImageVersionStorageProfile this is the storage profile of a gallery image version.
+// GalleryImageVersionStorageProfile this is the storage profile of a gallery Image Version.
type GalleryImageVersionStorageProfile struct {
OsDiskImage *GalleryOSDiskImage `json:"osDiskImage,omitempty"`
// DataDiskImages - A list of data disk images.
@@ -2227,24 +3390,32 @@ func (page GalleryListPage) Values() []Gallery {
// GalleryOSDiskImage this is the OS disk image.
type GalleryOSDiskImage struct {
- // SizeInGB - It indicates the size of the VHD to create.
+ // SizeInGB - This property indicates the size of the VHD to be created.
SizeInGB *int32 `json:"sizeInGB,omitempty"`
// HostCaching - The host caching of the disk. Valid values are 'None', 'ReadOnly', and 'ReadWrite'. Possible values include: 'HostCachingNone', 'HostCachingReadOnly', 'HostCachingReadWrite'
HostCaching HostCaching `json:"hostCaching,omitempty"`
}
-// GalleryProperties describes the properties of a gallery.
+// GalleryProperties describes the properties of a Shared Image Gallery.
type GalleryProperties struct {
- // Description - The description of this gallery resource.
+ // Description - The description of this Shared Image Gallery resource. This property is updateable.
Description *string `json:"description,omitempty"`
Identifier *GalleryIdentifier `json:"identifier,omitempty"`
// ProvisioningState - The provisioning state, which only appears in the response. Possible values include: 'ProvisioningStateCreating', 'ProvisioningStateUpdating', 'ProvisioningStateFailed', 'ProvisioningStateSucceeded', 'ProvisioningStateDeleting', 'ProvisioningStateMigrating'
ProvisioningState ProvisioningState `json:"provisioningState,omitempty"`
}
+// GrantAccessData data used for requesting a SAS.
+type GrantAccessData struct {
+ // Access - Possible values include: 'None', 'Read'
+ Access AccessLevel `json:"access,omitempty"`
+ // DurationInSeconds - Time duration in seconds until the SAS access expires.
+ DurationInSeconds *int32 `json:"durationInSeconds,omitempty"`
+}
+
// HardwareProfile specifies the hardware settings for the virtual machine.
type HardwareProfile struct {
- // VMSize - Specifies the size of the virtual machine. For more information about virtual machine sizes, see [Sizes for virtual machines](https://docs.microsoft.com/azure/virtual-machines/virtual-machines-windows-sizes?toc=%2fazure%2fvirtual-machines%2fwindows%2ftoc.json).
The available VM sizes depend on region and availability set. For a list of available sizes use these APIs:
[List all available virtual machine sizes in an availability set](https://docs.microsoft.com/rest/api/compute/availabilitysets/listavailablesizes)
[List all available virtual machine sizes in a region](https://docs.microsoft.com/rest/api/compute/virtualmachinesizes/list)
Default: **None for Standard storage. ReadOnly for Premium storage**. Possible values include: 'None', 'ReadOnly', 'ReadWrite'
+ // Caching - Specifies the caching requirements.
Possible values are:
**None**
**ReadOnly**
**ReadWrite**
Default: **None for Standard storage. ReadOnly for Premium storage**. Possible values include: 'CachingTypesNone', 'CachingTypesReadOnly', 'CachingTypesReadWrite'
Caching CachingTypes `json:"caching,omitempty"`
// DiskSizeGB - Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image.
This value cannot be larger than 1023 GB
DiskSizeGB *int32 `json:"diskSizeGB,omitempty"`
- // StorageAccountType - Specifies the storage account type for the managed disk. Possible values are: Standard_LRS, Premium_LRS, and StandardSSD_LRS. Possible values include: 'StandardLRS', 'PremiumLRS', 'StandardSSDLRS'
+ // StorageAccountType - Specifies the storage account type for the managed disk. NOTE: UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values include: 'StorageAccountTypesStandardLRS', 'StorageAccountTypesPremiumLRS', 'StorageAccountTypesStandardSSDLRS', 'StorageAccountTypesUltraSSDLRS'
StorageAccountType StorageAccountTypes `json:"storageAccountType,omitempty"`
}
+// ImageDiskReference the source image used for creating the disk.
+type ImageDiskReference struct {
+ // ID - A relative uri containing either a Platform Imgage Repository or user image reference.
+ ID *string `json:"id,omitempty"`
+ // Lun - If the disk is created from an image's data disk, this is an index that indicates which of the data disks in the image to use. For OS disks, this field is null.
+ Lun *int32 `json:"lun,omitempty"`
+}
+
// ImageListResult the List Image operation response.
type ImageListResult struct {
autorest.Response `json:"-"`
@@ -2490,11 +3669,11 @@ type ImageOSDisk struct {
ManagedDisk *SubResource `json:"managedDisk,omitempty"`
// BlobURI - The Virtual Hard Disk.
BlobURI *string `json:"blobUri,omitempty"`
- // Caching - Specifies the caching requirements.
Possible values are:
**None**
**ReadOnly**
**ReadWrite**
Default: **None for Standard storage. ReadOnly for Premium storage**. Possible values include: 'None', 'ReadOnly', 'ReadWrite'
+ // Caching - Specifies the caching requirements.
Possible values are:
**None**
**ReadOnly**
**ReadWrite**
Default: **None for Standard storage. ReadOnly for Premium storage**. Possible values include: 'CachingTypesNone', 'CachingTypesReadOnly', 'CachingTypesReadWrite'
Caching CachingTypes `json:"caching,omitempty"`
// DiskSizeGB - Specifies the size of empty data disks in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image.
This value cannot be larger than 1023 GB
DiskSizeGB *int32 `json:"diskSizeGB,omitempty"`
- // StorageAccountType - Specifies the storage account type for the managed disk. Possible values are: Standard_LRS, Premium_LRS, and StandardSSD_LRS. Possible values include: 'StandardLRS', 'PremiumLRS', 'StandardSSDLRS'
+ // StorageAccountType - Specifies the storage account type for the managed disk. UltraSSD_LRS cannot be used with OS Disk. Possible values include: 'StorageAccountTypesStandardLRS', 'StorageAccountTypesPremiumLRS', 'StorageAccountTypesStandardSSDLRS', 'StorageAccountTypesUltraSSDLRS'
StorageAccountType StorageAccountTypes `json:"storageAccountType,omitempty"`
}
@@ -2508,7 +3687,7 @@ type ImageProperties struct {
ProvisioningState *string `json:"provisioningState,omitempty"`
}
-// ImagePurchasePlan describes the gallery image purchase plan. This is used by marketplace images.
+// ImagePurchasePlan describes the gallery Image Definition purchase plan. This is used by marketplace images.
type ImagePurchasePlan struct {
// Name - The plan ID.
Name *string `json:"name,omitempty"`
@@ -2696,6 +3875,23 @@ type InstanceViewStatus struct {
Time *date.Time `json:"time,omitempty"`
}
+// KeyVaultAndKeyReference key Vault Key Url and vault id of KeK, KeK is optional and when provided is used to
+// unwrap the encryptionKey
+type KeyVaultAndKeyReference struct {
+ // SourceVault - Resource id of the KeyVault containing the key or secret
+ SourceVault *SourceVault `json:"sourceVault,omitempty"`
+ // KeyURL - Url pointing to a key or secret in KeyVault
+ KeyURL *string `json:"keyUrl,omitempty"`
+}
+
+// KeyVaultAndSecretReference key Vault Secret Url and vault id of the encryption key
+type KeyVaultAndSecretReference struct {
+ // SourceVault - Resource id of the KeyVault containing the key or secret
+ SourceVault *SourceVault `json:"sourceVault,omitempty"`
+ // SecretURL - Url pointing to a key or secret in KeyVault
+ SecretURL *string `json:"secretUrl,omitempty"`
+}
+
// KeyVaultKeyReference describes a reference to Key Vault Key
type KeyVaultKeyReference struct {
// KeyURL - The URL referencing a key encryption key in Key Vault.
@@ -2953,7 +4149,7 @@ type ManagedArtifact struct {
// ManagedDiskParameters the parameters of a managed disk.
type ManagedDiskParameters struct {
- // StorageAccountType - Specifies the storage account type for the managed disk. Possible values are: Standard_LRS, Premium_LRS, and StandardSSD_LRS. Possible values include: 'StandardLRS', 'PremiumLRS', 'StandardSSDLRS'
+ // StorageAccountType - Specifies the storage account type for the managed disk. NOTE: UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values include: 'StorageAccountTypesStandardLRS', 'StorageAccountTypesPremiumLRS', 'StorageAccountTypesStandardSSDLRS', 'StorageAccountTypesUltraSSDLRS'
StorageAccountType StorageAccountTypes `json:"storageAccountType,omitempty"`
// ID - Resource Id
ID *string `json:"id,omitempty"`
@@ -3122,13 +4318,15 @@ type OSDisk struct {
Vhd *VirtualHardDisk `json:"vhd,omitempty"`
// Image - The source user image virtual hard disk. The virtual hard disk will be copied before being attached to the virtual machine. If SourceImage is provided, the destination virtual hard drive must not exist.
Image *VirtualHardDisk `json:"image,omitempty"`
- // Caching - Specifies the caching requirements.
Possible values are:
**None**
**ReadOnly**
**ReadWrite**
Default: **None for Standard storage. ReadOnly for Premium storage**. Possible values include: 'None', 'ReadOnly', 'ReadWrite'
+ // Caching - Specifies the caching requirements.
Possible values are:
**None**
**ReadOnly**
**ReadWrite**
Default: **None for Standard storage. ReadOnly for Premium storage**. Possible values include: 'CachingTypesNone', 'CachingTypesReadOnly', 'CachingTypesReadWrite'
Caching CachingTypes `json:"caching,omitempty"`
// WriteAcceleratorEnabled - Specifies whether writeAccelerator should be enabled or disabled on the disk.
WriteAcceleratorEnabled *bool `json:"writeAcceleratorEnabled,omitempty"`
- // CreateOption - Specifies how the virtual machine should be created.
Possible values are:
**Attach** \u2013 This value is used when you are using a specialized disk to create the virtual machine.
**FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the plan element previously described. Possible values include: 'FromImage', 'Empty', 'Attach'
+ // DiffDiskSettings - Specifies the differencing Disk Settings for the operating system disk used by the virtual machine.
+ DiffDiskSettings *DiffDiskSettings `json:"diffDiskSettings,omitempty"`
+ // CreateOption - Specifies how the virtual machine should be created.
Possible values are:
**Attach** \u2013 This value is used when you are using a specialized disk to create the virtual machine.
**FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the plan element previously described. Possible values include: 'DiskCreateOptionTypesFromImage', 'DiskCreateOptionTypesEmpty', 'DiskCreateOptionTypesAttach'
CreateOption DiskCreateOptionTypes `json:"createOption,omitempty"`
- // DiskSizeGB - Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image.
This value cannot be larger than 1023 GB
+ // DiskSizeGB - Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image.
This value cannot be larger than 1023 GB
DiskSizeGB *int32 `json:"diskSizeGB,omitempty"`
// ManagedDisk - The managed disk parameters.
ManagedDisk *ManagedDiskParameters `json:"managedDisk,omitempty"`
@@ -3185,7 +4383,8 @@ type PurchasePlan struct {
Product *string `json:"product,omitempty"`
}
-// RecommendedMachineConfiguration describes the recommended machine configuration.
+// RecommendedMachineConfiguration the properties describe the recommended machine configuration for this Image
+// Definition. These properties are updateable.
type RecommendedMachineConfiguration struct {
VCPUs *ResourceRange `json:"vCPUs,omitempty"`
Memory *ResourceRange `json:"memory,omitempty"`
@@ -3202,7 +4401,7 @@ type RecoveryWalkResponse struct {
// RegionalReplicationStatus this is the regional replication status.
type RegionalReplicationStatus struct {
- // Region - The region where the gallery image version is published to.
+ // Region - The region to which the gallery Image Version is being replicated to.
Region *string `json:"region,omitempty"`
// State - This is the regional replication state. Possible values include: 'ReplicationStateUnknown', 'ReplicationStateReplicating', 'ReplicationStateCompleted', 'ReplicationStateFailed'
State ReplicationState `json:"state,omitempty"`
@@ -3212,9 +4411,9 @@ type RegionalReplicationStatus struct {
Progress *int32 `json:"progress,omitempty"`
}
-// ReplicationStatus this is the replication status of the gallery image version.
+// ReplicationStatus this is the replication status of the gallery Image Version.
type ReplicationStatus struct {
- // AggregatedState - This is the aggregated replication status based on the regional replication status. Possible values include: 'Unknown', 'InProgress', 'Completed', 'Failed'
+ // AggregatedState - This is the aggregated replication status based on all the regional replication status flags. Possible values include: 'Unknown', 'InProgress', 'Completed', 'Failed'
AggregatedState AggregatedReplicationState `json:"aggregatedState,omitempty"`
// Summary - This is a summary of replication status for each region.
Summary *[]RegionalReplicationStatus `json:"summary,omitempty"`
@@ -3281,6 +4480,196 @@ type ResourceRange struct {
Max *int32 `json:"max,omitempty"`
}
+// ResourceSku describes an available Compute SKU.
+type ResourceSku struct {
+ // ResourceType - The type of resource the SKU applies to.
+ ResourceType *string `json:"resourceType,omitempty"`
+ // Name - The name of SKU.
+ Name *string `json:"name,omitempty"`
+ // Tier - Specifies the tier of virtual machines in a scale set.
Possible Values:
**Standard**
**Basic**
+ Tier *string `json:"tier,omitempty"`
+ // Size - The Size of the SKU.
+ Size *string `json:"size,omitempty"`
+ // Family - The Family of this particular SKU.
+ Family *string `json:"family,omitempty"`
+ // Kind - The Kind of resources that are supported in this SKU.
+ Kind *string `json:"kind,omitempty"`
+ // Capacity - Specifies the number of virtual machines in the scale set.
+ Capacity *ResourceSkuCapacity `json:"capacity,omitempty"`
+ // Locations - The set of locations that the SKU is available.
+ Locations *[]string `json:"locations,omitempty"`
+ // LocationInfo - A list of locations and availability zones in those locations where the SKU is available.
+ LocationInfo *[]ResourceSkuLocationInfo `json:"locationInfo,omitempty"`
+ // APIVersions - The api versions that support this SKU.
+ APIVersions *[]string `json:"apiVersions,omitempty"`
+ // Costs - Metadata for retrieving price info.
+ Costs *[]ResourceSkuCosts `json:"costs,omitempty"`
+ // Capabilities - A name value pair to describe the capability.
+ Capabilities *[]ResourceSkuCapabilities `json:"capabilities,omitempty"`
+ // Restrictions - The restrictions because of which SKU cannot be used. This is empty if there are no restrictions.
+ Restrictions *[]ResourceSkuRestrictions `json:"restrictions,omitempty"`
+}
+
+// ResourceSkuCapabilities describes The SKU capabilites object.
+type ResourceSkuCapabilities struct {
+ // Name - An invariant to describe the feature.
+ Name *string `json:"name,omitempty"`
+ // Value - An invariant if the feature is measured by quantity.
+ Value *string `json:"value,omitempty"`
+}
+
+// ResourceSkuCapacity describes scaling information of a SKU.
+type ResourceSkuCapacity struct {
+ // Minimum - The minimum capacity.
+ Minimum *int64 `json:"minimum,omitempty"`
+ // Maximum - The maximum capacity that can be set.
+ Maximum *int64 `json:"maximum,omitempty"`
+ // Default - The default capacity.
+ Default *int64 `json:"default,omitempty"`
+ // ScaleType - The scale type applicable to the sku. Possible values include: 'ResourceSkuCapacityScaleTypeAutomatic', 'ResourceSkuCapacityScaleTypeManual', 'ResourceSkuCapacityScaleTypeNone'
+ ScaleType ResourceSkuCapacityScaleType `json:"scaleType,omitempty"`
+}
+
+// ResourceSkuCosts describes metadata for retrieving price info.
+type ResourceSkuCosts struct {
+ // MeterID - Used for querying price from commerce.
+ MeterID *string `json:"meterID,omitempty"`
+ // Quantity - The multiplier is needed to extend the base metered cost.
+ Quantity *int64 `json:"quantity,omitempty"`
+ // ExtendedUnit - An invariant to show the extended unit.
+ ExtendedUnit *string `json:"extendedUnit,omitempty"`
+}
+
+// ResourceSkuLocationInfo ...
+type ResourceSkuLocationInfo struct {
+ // Location - Location of the SKU
+ Location *string `json:"location,omitempty"`
+ // Zones - List of availability zones where the SKU is supported.
+ Zones *[]string `json:"zones,omitempty"`
+}
+
+// ResourceSkuRestrictionInfo ...
+type ResourceSkuRestrictionInfo struct {
+ // Locations - Locations where the SKU is restricted
+ Locations *[]string `json:"locations,omitempty"`
+ // Zones - List of availability zones where the SKU is restricted.
+ Zones *[]string `json:"zones,omitempty"`
+}
+
+// ResourceSkuRestrictions describes scaling information of a SKU.
+type ResourceSkuRestrictions struct {
+ // Type - The type of restrictions. Possible values include: 'Location', 'Zone'
+ Type ResourceSkuRestrictionsType `json:"type,omitempty"`
+ // Values - The value of restrictions. If the restriction type is set to location. This would be different locations where the SKU is restricted.
+ Values *[]string `json:"values,omitempty"`
+ // RestrictionInfo - The information about the restriction where the SKU cannot be used.
+ RestrictionInfo *ResourceSkuRestrictionInfo `json:"restrictionInfo,omitempty"`
+ // ReasonCode - The reason for restriction. Possible values include: 'QuotaID', 'NotAvailableForSubscription'
+ ReasonCode ResourceSkuRestrictionsReasonCode `json:"reasonCode,omitempty"`
+}
+
+// ResourceSkusResult the Compute List Skus operation response.
+type ResourceSkusResult struct {
+ autorest.Response `json:"-"`
+ // Value - The list of skus available for the subscription.
+ Value *[]ResourceSku `json:"value,omitempty"`
+ // NextLink - The uri to fetch the next page of Compute Skus. Call ListNext() with this to fetch the next page of VMSS Skus.
+ NextLink *string `json:"nextLink,omitempty"`
+}
+
+// ResourceSkusResultIterator provides access to a complete listing of ResourceSku values.
+type ResourceSkusResultIterator struct {
+ i int
+ page ResourceSkusResultPage
+}
+
+// Next advances to the next value. If there was an error making
+// the request the iterator does not advance and the error is returned.
+func (iter *ResourceSkusResultIterator) Next() error {
+ iter.i++
+ if iter.i < len(iter.page.Values()) {
+ return nil
+ }
+ err := iter.page.Next()
+ if err != nil {
+ iter.i--
+ return err
+ }
+ iter.i = 0
+ return nil
+}
+
+// NotDone returns true if the enumeration should be started or is not yet complete.
+func (iter ResourceSkusResultIterator) NotDone() bool {
+ return iter.page.NotDone() && iter.i < len(iter.page.Values())
+}
+
+// Response returns the raw server response from the last page request.
+func (iter ResourceSkusResultIterator) Response() ResourceSkusResult {
+ return iter.page.Response()
+}
+
+// Value returns the current value or a zero-initialized value if the
+// iterator has advanced beyond the end of the collection.
+func (iter ResourceSkusResultIterator) Value() ResourceSku {
+ if !iter.page.NotDone() {
+ return ResourceSku{}
+ }
+ return iter.page.Values()[iter.i]
+}
+
+// IsEmpty returns true if the ListResult contains no values.
+func (rsr ResourceSkusResult) IsEmpty() bool {
+ return rsr.Value == nil || len(*rsr.Value) == 0
+}
+
+// resourceSkusResultPreparer prepares a request to retrieve the next set of results.
+// It returns nil if no more results exist.
+func (rsr ResourceSkusResult) resourceSkusResultPreparer() (*http.Request, error) {
+ if rsr.NextLink == nil || len(to.String(rsr.NextLink)) < 1 {
+ return nil, nil
+ }
+ return autorest.Prepare(&http.Request{},
+ autorest.AsJSON(),
+ autorest.AsGet(),
+ autorest.WithBaseURL(to.String(rsr.NextLink)))
+}
+
+// ResourceSkusResultPage contains a page of ResourceSku values.
+type ResourceSkusResultPage struct {
+ fn func(ResourceSkusResult) (ResourceSkusResult, error)
+ rsr ResourceSkusResult
+}
+
+// Next advances to the next page of values. If there was an error making
+// the request the page does not advance and the error is returned.
+func (page *ResourceSkusResultPage) Next() error {
+ next, err := page.fn(page.rsr)
+ if err != nil {
+ return err
+ }
+ page.rsr = next
+ return nil
+}
+
+// NotDone returns true if the page enumeration should be started or is not yet complete.
+func (page ResourceSkusResultPage) NotDone() bool {
+ return !page.rsr.IsEmpty()
+}
+
+// Response returns the raw server response from the last page request.
+func (page ResourceSkusResultPage) Response() ResourceSkusResult {
+ return page.rsr
+}
+
+// Values returns the slice of values for the current page or nil if there are no values.
+func (page ResourceSkusResultPage) Values() []ResourceSku {
+ if page.rsr.IsEmpty() {
+ return nil
+ }
+ return *page.rsr.Value
+}
+
// RollbackStatusInfo information about rollback on failed VM instances after a OS Upgrade operation.
type RollbackStatusInfo struct {
// SuccessfullyRolledbackInstanceCount - The number of instances which have been successfully rolled back.
@@ -3630,6 +5019,480 @@ type Sku struct {
Capacity *int64 `json:"capacity,omitempty"`
}
+// Snapshot snapshot resource.
+type Snapshot struct {
+ autorest.Response `json:"-"`
+ // ManagedBy - Unused. Always Null.
+ ManagedBy *string `json:"managedBy,omitempty"`
+ Sku *SnapshotSku `json:"sku,omitempty"`
+ *SnapshotProperties `json:"properties,omitempty"`
+ // ID - Resource Id
+ ID *string `json:"id,omitempty"`
+ // Name - Resource name
+ Name *string `json:"name,omitempty"`
+ // Type - Resource type
+ Type *string `json:"type,omitempty"`
+ // Location - Resource location
+ Location *string `json:"location,omitempty"`
+ // Tags - Resource tags
+ Tags map[string]*string `json:"tags"`
+}
+
+// MarshalJSON is the custom marshaler for Snapshot.
+func (s Snapshot) MarshalJSON() ([]byte, error) {
+ objectMap := make(map[string]interface{})
+ if s.ManagedBy != nil {
+ objectMap["managedBy"] = s.ManagedBy
+ }
+ if s.Sku != nil {
+ objectMap["sku"] = s.Sku
+ }
+ if s.SnapshotProperties != nil {
+ objectMap["properties"] = s.SnapshotProperties
+ }
+ if s.ID != nil {
+ objectMap["id"] = s.ID
+ }
+ if s.Name != nil {
+ objectMap["name"] = s.Name
+ }
+ if s.Type != nil {
+ objectMap["type"] = s.Type
+ }
+ if s.Location != nil {
+ objectMap["location"] = s.Location
+ }
+ if s.Tags != nil {
+ objectMap["tags"] = s.Tags
+ }
+ return json.Marshal(objectMap)
+}
+
+// UnmarshalJSON is the custom unmarshaler for Snapshot struct.
+func (s *Snapshot) UnmarshalJSON(body []byte) error {
+ var m map[string]*json.RawMessage
+ err := json.Unmarshal(body, &m)
+ if err != nil {
+ return err
+ }
+ for k, v := range m {
+ switch k {
+ case "managedBy":
+ if v != nil {
+ var managedBy string
+ err = json.Unmarshal(*v, &managedBy)
+ if err != nil {
+ return err
+ }
+ s.ManagedBy = &managedBy
+ }
+ case "sku":
+ if v != nil {
+ var sku SnapshotSku
+ err = json.Unmarshal(*v, &sku)
+ if err != nil {
+ return err
+ }
+ s.Sku = &sku
+ }
+ case "properties":
+ if v != nil {
+ var snapshotProperties SnapshotProperties
+ err = json.Unmarshal(*v, &snapshotProperties)
+ if err != nil {
+ return err
+ }
+ s.SnapshotProperties = &snapshotProperties
+ }
+ case "id":
+ if v != nil {
+ var ID string
+ err = json.Unmarshal(*v, &ID)
+ if err != nil {
+ return err
+ }
+ s.ID = &ID
+ }
+ case "name":
+ if v != nil {
+ var name string
+ err = json.Unmarshal(*v, &name)
+ if err != nil {
+ return err
+ }
+ s.Name = &name
+ }
+ case "type":
+ if v != nil {
+ var typeVar string
+ err = json.Unmarshal(*v, &typeVar)
+ if err != nil {
+ return err
+ }
+ s.Type = &typeVar
+ }
+ case "location":
+ if v != nil {
+ var location string
+ err = json.Unmarshal(*v, &location)
+ if err != nil {
+ return err
+ }
+ s.Location = &location
+ }
+ case "tags":
+ if v != nil {
+ var tags map[string]*string
+ err = json.Unmarshal(*v, &tags)
+ if err != nil {
+ return err
+ }
+ s.Tags = tags
+ }
+ }
+ }
+
+ return nil
+}
+
+// SnapshotList the List Snapshots operation response.
+type SnapshotList struct {
+ autorest.Response `json:"-"`
+ // Value - A list of snapshots.
+ Value *[]Snapshot `json:"value,omitempty"`
+ // NextLink - The uri to fetch the next page of snapshots. Call ListNext() with this to fetch the next page of snapshots.
+ NextLink *string `json:"nextLink,omitempty"`
+}
+
+// SnapshotListIterator provides access to a complete listing of Snapshot values.
+type SnapshotListIterator struct {
+ i int
+ page SnapshotListPage
+}
+
+// Next advances to the next value. If there was an error making
+// the request the iterator does not advance and the error is returned.
+func (iter *SnapshotListIterator) Next() error {
+ iter.i++
+ if iter.i < len(iter.page.Values()) {
+ return nil
+ }
+ err := iter.page.Next()
+ if err != nil {
+ iter.i--
+ return err
+ }
+ iter.i = 0
+ return nil
+}
+
+// NotDone returns true if the enumeration should be started or is not yet complete.
+func (iter SnapshotListIterator) NotDone() bool {
+ return iter.page.NotDone() && iter.i < len(iter.page.Values())
+}
+
+// Response returns the raw server response from the last page request.
+func (iter SnapshotListIterator) Response() SnapshotList {
+ return iter.page.Response()
+}
+
+// Value returns the current value or a zero-initialized value if the
+// iterator has advanced beyond the end of the collection.
+func (iter SnapshotListIterator) Value() Snapshot {
+ if !iter.page.NotDone() {
+ return Snapshot{}
+ }
+ return iter.page.Values()[iter.i]
+}
+
+// IsEmpty returns true if the ListResult contains no values.
+func (sl SnapshotList) IsEmpty() bool {
+ return sl.Value == nil || len(*sl.Value) == 0
+}
+
+// snapshotListPreparer prepares a request to retrieve the next set of results.
+// It returns nil if no more results exist.
+func (sl SnapshotList) snapshotListPreparer() (*http.Request, error) {
+ if sl.NextLink == nil || len(to.String(sl.NextLink)) < 1 {
+ return nil, nil
+ }
+ return autorest.Prepare(&http.Request{},
+ autorest.AsJSON(),
+ autorest.AsGet(),
+ autorest.WithBaseURL(to.String(sl.NextLink)))
+}
+
+// SnapshotListPage contains a page of Snapshot values.
+type SnapshotListPage struct {
+ fn func(SnapshotList) (SnapshotList, error)
+ sl SnapshotList
+}
+
+// Next advances to the next page of values. If there was an error making
+// the request the page does not advance and the error is returned.
+func (page *SnapshotListPage) Next() error {
+ next, err := page.fn(page.sl)
+ if err != nil {
+ return err
+ }
+ page.sl = next
+ return nil
+}
+
+// NotDone returns true if the page enumeration should be started or is not yet complete.
+func (page SnapshotListPage) NotDone() bool {
+ return !page.sl.IsEmpty()
+}
+
+// Response returns the raw server response from the last page request.
+func (page SnapshotListPage) Response() SnapshotList {
+ return page.sl
+}
+
+// Values returns the slice of values for the current page or nil if there are no values.
+func (page SnapshotListPage) Values() []Snapshot {
+ if page.sl.IsEmpty() {
+ return nil
+ }
+ return *page.sl.Value
+}
+
+// SnapshotProperties snapshot resource properties.
+type SnapshotProperties struct {
+ // TimeCreated - The time when the disk was created.
+ TimeCreated *date.Time `json:"timeCreated,omitempty"`
+ // OsType - The Operating System type. Possible values include: 'Windows', 'Linux'
+ OsType OperatingSystemTypes `json:"osType,omitempty"`
+ // CreationData - Disk source information. CreationData information cannot be changed after the disk has been created.
+ CreationData *CreationData `json:"creationData,omitempty"`
+ // DiskSizeGB - If creationData.createOption is Empty, this field is mandatory and it indicates the size of the VHD to create. If this field is present for updates or creation with other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a running VM, and can only increase the disk's size.
+ DiskSizeGB *int32 `json:"diskSizeGB,omitempty"`
+ // EncryptionSettings - Encryption settings for disk or snapshot
+ EncryptionSettings *EncryptionSettings `json:"encryptionSettings,omitempty"`
+ // ProvisioningState - The disk provisioning state.
+ ProvisioningState *string `json:"provisioningState,omitempty"`
+}
+
+// SnapshotsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running
+// operation.
+type SnapshotsCreateOrUpdateFuture struct {
+ azure.Future
+}
+
+// Result returns the result of the asynchronous operation.
+// If the operation has not completed it will return an error.
+func (future *SnapshotsCreateOrUpdateFuture) Result(client SnapshotsClient) (s Snapshot, err error) {
+ var done bool
+ done, err = future.Done(client)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.SnapshotsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure")
+ return
+ }
+ if !done {
+ err = azure.NewAsyncOpIncompleteError("compute.SnapshotsCreateOrUpdateFuture")
+ return
+ }
+ sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
+ if s.Response.Response, err = future.GetResult(sender); err == nil && s.Response.Response.StatusCode != http.StatusNoContent {
+ s, err = client.CreateOrUpdateResponder(s.Response.Response)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.SnapshotsCreateOrUpdateFuture", "Result", s.Response.Response, "Failure responding to request")
+ }
+ }
+ return
+}
+
+// SnapshotsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running operation.
+type SnapshotsDeleteFuture struct {
+ azure.Future
+}
+
+// Result returns the result of the asynchronous operation.
+// If the operation has not completed it will return an error.
+func (future *SnapshotsDeleteFuture) Result(client SnapshotsClient) (ar autorest.Response, err error) {
+ var done bool
+ done, err = future.Done(client)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.SnapshotsDeleteFuture", "Result", future.Response(), "Polling failure")
+ return
+ }
+ if !done {
+ err = azure.NewAsyncOpIncompleteError("compute.SnapshotsDeleteFuture")
+ return
+ }
+ ar.Response = future.Response()
+ return
+}
+
+// SnapshotsGrantAccessFuture an abstraction for monitoring and retrieving the results of a long-running operation.
+type SnapshotsGrantAccessFuture struct {
+ azure.Future
+}
+
+// Result returns the result of the asynchronous operation.
+// If the operation has not completed it will return an error.
+func (future *SnapshotsGrantAccessFuture) Result(client SnapshotsClient) (au AccessURI, err error) {
+ var done bool
+ done, err = future.Done(client)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.SnapshotsGrantAccessFuture", "Result", future.Response(), "Polling failure")
+ return
+ }
+ if !done {
+ err = azure.NewAsyncOpIncompleteError("compute.SnapshotsGrantAccessFuture")
+ return
+ }
+ sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
+ if au.Response.Response, err = future.GetResult(sender); err == nil && au.Response.Response.StatusCode != http.StatusNoContent {
+ au, err = client.GrantAccessResponder(au.Response.Response)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.SnapshotsGrantAccessFuture", "Result", au.Response.Response, "Failure responding to request")
+ }
+ }
+ return
+}
+
+// SnapshotSku the snapshots sku name. Can be Standard_LRS, Premium_LRS, or Standard_ZRS.
+type SnapshotSku struct {
+ // Name - The sku name. Possible values include: 'SnapshotStorageAccountTypesStandardLRS', 'SnapshotStorageAccountTypesPremiumLRS', 'SnapshotStorageAccountTypesStandardZRS'
+ Name SnapshotStorageAccountTypes `json:"name,omitempty"`
+ // Tier - The sku tier.
+ Tier *string `json:"tier,omitempty"`
+}
+
+// SnapshotsRevokeAccessFuture an abstraction for monitoring and retrieving the results of a long-running
+// operation.
+type SnapshotsRevokeAccessFuture struct {
+ azure.Future
+}
+
+// Result returns the result of the asynchronous operation.
+// If the operation has not completed it will return an error.
+func (future *SnapshotsRevokeAccessFuture) Result(client SnapshotsClient) (ar autorest.Response, err error) {
+ var done bool
+ done, err = future.Done(client)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.SnapshotsRevokeAccessFuture", "Result", future.Response(), "Polling failure")
+ return
+ }
+ if !done {
+ err = azure.NewAsyncOpIncompleteError("compute.SnapshotsRevokeAccessFuture")
+ return
+ }
+ ar.Response = future.Response()
+ return
+}
+
+// SnapshotsUpdateFuture an abstraction for monitoring and retrieving the results of a long-running operation.
+type SnapshotsUpdateFuture struct {
+ azure.Future
+}
+
+// Result returns the result of the asynchronous operation.
+// If the operation has not completed it will return an error.
+func (future *SnapshotsUpdateFuture) Result(client SnapshotsClient) (s Snapshot, err error) {
+ var done bool
+ done, err = future.Done(client)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.SnapshotsUpdateFuture", "Result", future.Response(), "Polling failure")
+ return
+ }
+ if !done {
+ err = azure.NewAsyncOpIncompleteError("compute.SnapshotsUpdateFuture")
+ return
+ }
+ sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
+ if s.Response.Response, err = future.GetResult(sender); err == nil && s.Response.Response.StatusCode != http.StatusNoContent {
+ s, err = client.UpdateResponder(s.Response.Response)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.SnapshotsUpdateFuture", "Result", s.Response.Response, "Failure responding to request")
+ }
+ }
+ return
+}
+
+// SnapshotUpdate snapshot update resource.
+type SnapshotUpdate struct {
+ *SnapshotUpdateProperties `json:"properties,omitempty"`
+ // Tags - Resource tags
+ Tags map[string]*string `json:"tags"`
+ Sku *SnapshotSku `json:"sku,omitempty"`
+}
+
+// MarshalJSON is the custom marshaler for SnapshotUpdate.
+func (su SnapshotUpdate) MarshalJSON() ([]byte, error) {
+ objectMap := make(map[string]interface{})
+ if su.SnapshotUpdateProperties != nil {
+ objectMap["properties"] = su.SnapshotUpdateProperties
+ }
+ if su.Tags != nil {
+ objectMap["tags"] = su.Tags
+ }
+ if su.Sku != nil {
+ objectMap["sku"] = su.Sku
+ }
+ return json.Marshal(objectMap)
+}
+
+// UnmarshalJSON is the custom unmarshaler for SnapshotUpdate struct.
+func (su *SnapshotUpdate) UnmarshalJSON(body []byte) error {
+ var m map[string]*json.RawMessage
+ err := json.Unmarshal(body, &m)
+ if err != nil {
+ return err
+ }
+ for k, v := range m {
+ switch k {
+ case "properties":
+ if v != nil {
+ var snapshotUpdateProperties SnapshotUpdateProperties
+ err = json.Unmarshal(*v, &snapshotUpdateProperties)
+ if err != nil {
+ return err
+ }
+ su.SnapshotUpdateProperties = &snapshotUpdateProperties
+ }
+ case "tags":
+ if v != nil {
+ var tags map[string]*string
+ err = json.Unmarshal(*v, &tags)
+ if err != nil {
+ return err
+ }
+ su.Tags = tags
+ }
+ case "sku":
+ if v != nil {
+ var sku SnapshotSku
+ err = json.Unmarshal(*v, &sku)
+ if err != nil {
+ return err
+ }
+ su.Sku = &sku
+ }
+ }
+ }
+
+ return nil
+}
+
+// SnapshotUpdateProperties snapshot resource update properties.
+type SnapshotUpdateProperties struct {
+ // OsType - the Operating System type. Possible values include: 'Windows', 'Linux'
+ OsType OperatingSystemTypes `json:"osType,omitempty"`
+ // DiskSizeGB - If creationData.createOption is Empty, this field is mandatory and it indicates the size of the VHD to create. If this field is present for updates or creation with other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a running VM, and can only increase the disk's size.
+ DiskSizeGB *int32 `json:"diskSizeGB,omitempty"`
+ // EncryptionSettings - Encryption settings for disk or snapshot
+ EncryptionSettings *EncryptionSettings `json:"encryptionSettings,omitempty"`
+}
+
+// SourceVault the vault id is an Azure Resource Manager Resoure id in the form
+// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}
+type SourceVault struct {
+ // ID - Resource Id
+ ID *string `json:"id,omitempty"`
+}
+
// SSHConfiguration SSH configuration for Linux based VMs running on Azure
type SSHConfiguration struct {
// PublicKeys - The list of SSH public keys used to authenticate with linux based VMs.
@@ -3667,6 +5530,14 @@ type SubResourceReadOnly struct {
ID *string `json:"id,omitempty"`
}
+// TargetRegion describes the target region information.
+type TargetRegion struct {
+ // Name - The name of the region.
+ Name *string `json:"name,omitempty"`
+ // RegionalReplicaCount - The number of replicas of the Image Version to be created per region. This property is updateable.
+ RegionalReplicaCount *int32 `json:"regionalReplicaCount,omitempty"`
+}
+
// ThrottledRequestsInput api request input for LogAnalytics getThrottledRequests Api.
type ThrottledRequestsInput struct {
// BlobContainerSasURI - SAS Uri of the logging blob container to which LogAnalytics Api writes output logs to.
@@ -4738,6 +6609,8 @@ type VirtualMachineProperties struct {
HardwareProfile *HardwareProfile `json:"hardwareProfile,omitempty"`
// StorageProfile - Specifies the storage settings for the virtual machine disks.
StorageProfile *StorageProfile `json:"storageProfile,omitempty"`
+ // AdditionalCapabilities - Specifies additional capabilities enabled or disabled on the virtual machine.
+ AdditionalCapabilities *AdditionalCapabilities `json:"additionalCapabilities,omitempty"`
// OsProfile - Specifies the operating system settings for the virtual machine.
OsProfile *OSProfile `json:"osProfile,omitempty"`
// NetworkProfile - Specifies the network interfaces of the virtual machine.
@@ -4927,13 +6800,13 @@ type VirtualMachineScaleSetDataDisk struct {
Name *string `json:"name,omitempty"`
// Lun - Specifies the logical unit number of the data disk. This value is used to identify data disks within the VM and therefore must be unique for each data disk attached to a VM.
Lun *int32 `json:"lun,omitempty"`
- // Caching - Specifies the caching requirements.
Possible values are:
**None**
**ReadOnly**
**ReadWrite**
Default: **None for Standard storage. ReadOnly for Premium storage**. Possible values include: 'None', 'ReadOnly', 'ReadWrite'
+ // Caching - Specifies the caching requirements.
Possible values are:
**None**
**ReadOnly**
**ReadWrite**
Default: **None for Standard storage. ReadOnly for Premium storage**. Possible values include: 'CachingTypesNone', 'CachingTypesReadOnly', 'CachingTypesReadWrite'
Caching CachingTypes `json:"caching,omitempty"`
// WriteAcceleratorEnabled - Specifies whether writeAccelerator should be enabled or disabled on the disk.
WriteAcceleratorEnabled *bool `json:"writeAcceleratorEnabled,omitempty"`
- // CreateOption - The create option. Possible values include: 'FromImage', 'Empty', 'Attach'
+ // CreateOption - The create option. Possible values include: 'DiskCreateOptionTypesFromImage', 'DiskCreateOptionTypesEmpty', 'DiskCreateOptionTypesAttach'
CreateOption DiskCreateOptionTypes `json:"createOption,omitempty"`
- // DiskSizeGB - Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image.
This value cannot be larger than 1023 GB
+ // DiskSizeGB - Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image.
This value cannot be larger than 1023 GB
DiskSizeGB *int32 `json:"diskSizeGB,omitempty"`
// ManagedDisk - The managed disk parameters.
ManagedDisk *VirtualMachineScaleSetManagedDiskParameters `json:"managedDisk,omitempty"`
@@ -5752,7 +7625,7 @@ func (page VirtualMachineScaleSetListWithLinkResultPage) Values() []VirtualMachi
// VirtualMachineScaleSetManagedDiskParameters describes the parameters of a ScaleSet managed disk.
type VirtualMachineScaleSetManagedDiskParameters struct {
- // StorageAccountType - Specifies the storage account type for the managed disk. Possible values are: Standard_LRS, Premium_LRS, and StandardSSD_LRS. Possible values include: 'StandardLRS', 'PremiumLRS', 'StandardSSDLRS'
+ // StorageAccountType - Specifies the storage account type for the managed disk. NOTE: UltraSSD_LRS can only be used with data disks, it cannot be used with OS Disk. Possible values include: 'StorageAccountTypesStandardLRS', 'StorageAccountTypesPremiumLRS', 'StorageAccountTypesStandardSSDLRS', 'StorageAccountTypesUltraSSDLRS'
StorageAccountType StorageAccountTypes `json:"storageAccountType,omitempty"`
}
@@ -5859,12 +7732,16 @@ type VirtualMachineScaleSetNetworkProfile struct {
type VirtualMachineScaleSetOSDisk struct {
// Name - The disk name.
Name *string `json:"name,omitempty"`
- // Caching - Specifies the caching requirements.
Possible values are:
**None**
**ReadOnly**
**ReadWrite**
Default: **None for Standard storage. ReadOnly for Premium storage**. Possible values include: 'None', 'ReadOnly', 'ReadWrite'
+ // Caching - Specifies the caching requirements.
Possible values are:
**None**
**ReadOnly**
**ReadWrite**
Default: **None for Standard storage. ReadOnly for Premium storage**. Possible values include: 'CachingTypesNone', 'CachingTypesReadOnly', 'CachingTypesReadWrite'
Caching CachingTypes `json:"caching,omitempty"`
// WriteAcceleratorEnabled - Specifies whether writeAccelerator should be enabled or disabled on the disk.
WriteAcceleratorEnabled *bool `json:"writeAcceleratorEnabled,omitempty"`
- // CreateOption - Specifies how the virtual machines in the scale set should be created.
The only allowed value is: **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the plan element previously described. Possible values include: 'FromImage', 'Empty', 'Attach'
+ // CreateOption - Specifies how the virtual machines in the scale set should be created.
The only allowed value is: **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the plan element previously described. Possible values include: 'DiskCreateOptionTypesFromImage', 'DiskCreateOptionTypesEmpty', 'DiskCreateOptionTypesAttach'
CreateOption DiskCreateOptionTypes `json:"createOption,omitempty"`
+ // DiffDiskSettings - Specifies the differencing Disk Settings for the operating system disk used by the virtual machine scale set.
+ DiffDiskSettings *DiffDiskSettings `json:"diffDiskSettings,omitempty"`
+ // DiskSizeGB - Specifies the size of the operating system disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image.
This value cannot be larger than 1023 GB
+ DiskSizeGB *int32 `json:"diskSizeGB,omitempty"`
// OsType - This property allows you to specify the type of the OS that is included in the disk if creating a VM from user-image or a specialized VHD.
Possible values are:
**Windows**
**Linux**. Possible values include: 'Windows', 'Linux'
OsType OperatingSystemTypes `json:"osType,omitempty"`
// Image - Specifies information about the unmanaged user image to base the scale set on.
@@ -5982,6 +7859,8 @@ type VirtualMachineScaleSetPublicIPAddressConfigurationProperties struct {
DNSSettings *VirtualMachineScaleSetPublicIPAddressConfigurationDNSSettings `json:"dnsSettings,omitempty"`
// IPTags - The list of IP tags associated with the public IP address.
IPTags *[]VirtualMachineScaleSetIPTag `json:"ipTags,omitempty"`
+ // PublicIPPrefix - The PublicIPPrefix from which to allocate publicIP addresses.
+ PublicIPPrefix *SubResource `json:"publicIPPrefix,omitempty"`
}
// VirtualMachineScaleSetRollingUpgradesCancelFuture an abstraction for monitoring and retrieving the results of a
@@ -6007,6 +7886,29 @@ func (future *VirtualMachineScaleSetRollingUpgradesCancelFuture) Result(client V
return
}
+// VirtualMachineScaleSetRollingUpgradesStartExtensionUpgradeFuture an abstraction for monitoring and retrieving
+// the results of a long-running operation.
+type VirtualMachineScaleSetRollingUpgradesStartExtensionUpgradeFuture struct {
+ azure.Future
+}
+
+// Result returns the result of the asynchronous operation.
+// If the operation has not completed it will return an error.
+func (future *VirtualMachineScaleSetRollingUpgradesStartExtensionUpgradeFuture) Result(client VirtualMachineScaleSetRollingUpgradesClient) (ar autorest.Response, err error) {
+ var done bool
+ done, err = future.Done(client)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetRollingUpgradesStartExtensionUpgradeFuture", "Result", future.Response(), "Polling failure")
+ return
+ }
+ if !done {
+ err = azure.NewAsyncOpIncompleteError("compute.VirtualMachineScaleSetRollingUpgradesStartExtensionUpgradeFuture")
+ return
+ }
+ ar.Response = future.Response()
+ return
+}
+
// VirtualMachineScaleSetRollingUpgradesStartOSUpgradeFuture an abstraction for monitoring and retrieving the
// results of a long-running operation.
type VirtualMachineScaleSetRollingUpgradesStartOSUpgradeFuture struct {
@@ -6648,10 +8550,12 @@ type VirtualMachineScaleSetUpdateNetworkProfile struct {
// VirtualMachineScaleSetUpdateOSDisk describes virtual machine scale set operating system disk Update Object. This
// should be used for Updating VMSS OS Disk.
type VirtualMachineScaleSetUpdateOSDisk struct {
- // Caching - The caching type. Possible values include: 'None', 'ReadOnly', 'ReadWrite'
+ // Caching - The caching type. Possible values include: 'CachingTypesNone', 'CachingTypesReadOnly', 'CachingTypesReadWrite'
Caching CachingTypes `json:"caching,omitempty"`
// WriteAcceleratorEnabled - Specifies whether writeAccelerator should be enabled or disabled on the disk.
WriteAcceleratorEnabled *bool `json:"writeAcceleratorEnabled,omitempty"`
+ // DiskSizeGB - Specifies the size of the operating system disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image.
This value cannot be larger than 1023 GB
+ DiskSizeGB *int32 `json:"diskSizeGB,omitempty"`
// Image - The Source User Image VirtualHardDisk. This VirtualHardDisk will be copied before using it to attach to the Virtual Machine. If SourceImage is provided, the destination VirtualHardDisk should not exist.
Image *VirtualHardDisk `json:"image,omitempty"`
// VhdContainers - The list of virtual hard disk container uris.
@@ -6784,6 +8688,8 @@ type VirtualMachineScaleSetVM struct {
Plan *Plan `json:"plan,omitempty"`
// Resources - The virtual machine child extension resources.
Resources *[]VirtualMachineExtension `json:"resources,omitempty"`
+ // Zones - The virtual machine zones.
+ Zones *[]string `json:"zones,omitempty"`
// ID - Resource Id
ID *string `json:"id,omitempty"`
// Name - Resource name
@@ -6814,6 +8720,9 @@ func (vmssv VirtualMachineScaleSetVM) MarshalJSON() ([]byte, error) {
if vmssv.Resources != nil {
objectMap["resources"] = vmssv.Resources
}
+ if vmssv.Zones != nil {
+ objectMap["zones"] = vmssv.Zones
+ }
if vmssv.ID != nil {
objectMap["id"] = vmssv.ID
}
@@ -6886,6 +8795,15 @@ func (vmssv *VirtualMachineScaleSetVM) UnmarshalJSON(body []byte) error {
}
vmssv.Resources = &resources
}
+ case "zones":
+ if v != nil {
+ var zones []string
+ err = json.Unmarshal(*v, &zones)
+ if err != nil {
+ return err
+ }
+ vmssv.Zones = &zones
+ }
case "id":
if v != nil {
var ID string
@@ -7095,6 +9013,8 @@ type VirtualMachineScaleSetVMProfile struct {
OsProfile *VirtualMachineScaleSetOSProfile `json:"osProfile,omitempty"`
// StorageProfile - Specifies the storage settings for the virtual machine disks.
StorageProfile *VirtualMachineScaleSetStorageProfile `json:"storageProfile,omitempty"`
+ // AdditionalCapabilities - Specifies additional capabilities enabled or disabled on the virtual machine in the scale set. For instance: whether the virtual machine has the capability to support attaching managed data disks with UltraSSD_LRS storage account type.
+ AdditionalCapabilities *AdditionalCapabilities `json:"additionalCapabilities,omitempty"`
// NetworkProfile - Specifies properties of the network interfaces of the virtual machines in the scale set.
NetworkProfile *VirtualMachineScaleSetNetworkProfile `json:"networkProfile,omitempty"`
// DiagnosticsProfile - Specifies the boot diagnostic settings state.
Minimum api-version: 2015-06-15.
@@ -7121,6 +9041,8 @@ type VirtualMachineScaleSetVMProperties struct {
HardwareProfile *HardwareProfile `json:"hardwareProfile,omitempty"`
// StorageProfile - Specifies the storage settings for the virtual machine disks.
StorageProfile *StorageProfile `json:"storageProfile,omitempty"`
+ // AdditionalCapabilities - Specifies additional capabilities enabled or disabled on the virtual machine in the scale set. For instance: whether the virtual machine has the capability to support attaching managed data disks with UltraSSD_LRS storage account type.
+ AdditionalCapabilities *AdditionalCapabilities `json:"additionalCapabilities,omitempty"`
// OsProfile - Specifies the operating system settings for the virtual machine.
OsProfile *OSProfile `json:"osProfile,omitempty"`
// NetworkProfile - Specifies the network interfaces of the virtual machine.
diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-06-01/compute/resourceskus.go b/vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-06-01/compute/resourceskus.go
new file mode 100644
index 0000000000..de32a3df69
--- /dev/null
+++ b/vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-06-01/compute/resourceskus.go
@@ -0,0 +1,130 @@
+package compute
+
+// Copyright (c) Microsoft and contributors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+import (
+ "context"
+ "github.com/Azure/go-autorest/autorest"
+ "github.com/Azure/go-autorest/autorest/azure"
+ "net/http"
+)
+
+// ResourceSkusClient is the compute Client
+type ResourceSkusClient struct {
+ BaseClient
+}
+
+// NewResourceSkusClient creates an instance of the ResourceSkusClient client.
+func NewResourceSkusClient(subscriptionID string) ResourceSkusClient {
+ return NewResourceSkusClientWithBaseURI(DefaultBaseURI, subscriptionID)
+}
+
+// NewResourceSkusClientWithBaseURI creates an instance of the ResourceSkusClient client.
+func NewResourceSkusClientWithBaseURI(baseURI string, subscriptionID string) ResourceSkusClient {
+ return ResourceSkusClient{NewWithBaseURI(baseURI, subscriptionID)}
+}
+
+// List gets the list of Microsoft.Compute SKUs available for your Subscription.
+func (client ResourceSkusClient) List(ctx context.Context) (result ResourceSkusResultPage, err error) {
+ result.fn = client.listNextResults
+ req, err := client.ListPreparer(ctx)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.ResourceSkusClient", "List", nil, "Failure preparing request")
+ return
+ }
+
+ resp, err := client.ListSender(req)
+ if err != nil {
+ result.rsr.Response = autorest.Response{Response: resp}
+ err = autorest.NewErrorWithError(err, "compute.ResourceSkusClient", "List", resp, "Failure sending request")
+ return
+ }
+
+ result.rsr, err = client.ListResponder(resp)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.ResourceSkusClient", "List", resp, "Failure responding to request")
+ }
+
+ return
+}
+
+// ListPreparer prepares the List request.
+func (client ResourceSkusClient) ListPreparer(ctx context.Context) (*http.Request, error) {
+ pathParameters := map[string]interface{}{
+ "subscriptionId": autorest.Encode("path", client.SubscriptionID),
+ }
+
+ const APIVersion = "2017-09-01"
+ queryParameters := map[string]interface{}{
+ "api-version": APIVersion,
+ }
+
+ preparer := autorest.CreatePreparer(
+ autorest.AsGet(),
+ autorest.WithBaseURL(client.BaseURI),
+ autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Compute/skus", pathParameters),
+ autorest.WithQueryParameters(queryParameters))
+ return preparer.Prepare((&http.Request{}).WithContext(ctx))
+}
+
+// ListSender sends the List request. The method will close the
+// http.Response Body if it receives an error.
+func (client ResourceSkusClient) ListSender(req *http.Request) (*http.Response, error) {
+ return autorest.SendWithSender(client, req,
+ azure.DoRetryWithRegistration(client.Client))
+}
+
+// ListResponder handles the response to the List request. The method always
+// closes the http.Response Body.
+func (client ResourceSkusClient) ListResponder(resp *http.Response) (result ResourceSkusResult, err error) {
+ err = autorest.Respond(
+ resp,
+ client.ByInspecting(),
+ azure.WithErrorUnlessStatusCode(http.StatusOK),
+ autorest.ByUnmarshallingJSON(&result),
+ autorest.ByClosing())
+ result.Response = autorest.Response{Response: resp}
+ return
+}
+
+// listNextResults retrieves the next set of results, if any.
+func (client ResourceSkusClient) listNextResults(lastResults ResourceSkusResult) (result ResourceSkusResult, err error) {
+ req, err := lastResults.resourceSkusResultPreparer()
+ if err != nil {
+ return result, autorest.NewErrorWithError(err, "compute.ResourceSkusClient", "listNextResults", nil, "Failure preparing next results request")
+ }
+ if req == nil {
+ return
+ }
+ resp, err := client.ListSender(req)
+ if err != nil {
+ result.Response = autorest.Response{Response: resp}
+ return result, autorest.NewErrorWithError(err, "compute.ResourceSkusClient", "listNextResults", resp, "Failure sending next results request")
+ }
+ result, err = client.ListResponder(resp)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.ResourceSkusClient", "listNextResults", resp, "Failure responding to next results request")
+ }
+ return
+}
+
+// ListComplete enumerates all values, automatically crossing page boundaries as required.
+func (client ResourceSkusClient) ListComplete(ctx context.Context) (result ResourceSkusResultIterator, err error) {
+ result.page, err = client.List(ctx)
+ return
+}
diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-06-01/compute/snapshots.go b/vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-06-01/compute/snapshots.go
new file mode 100644
index 0000000000..89e57104c4
--- /dev/null
+++ b/vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-06-01/compute/snapshots.go
@@ -0,0 +1,686 @@
+package compute
+
+// Copyright (c) Microsoft and contributors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+import (
+ "context"
+ "github.com/Azure/go-autorest/autorest"
+ "github.com/Azure/go-autorest/autorest/azure"
+ "github.com/Azure/go-autorest/autorest/validation"
+ "net/http"
+)
+
+// SnapshotsClient is the compute Client
+type SnapshotsClient struct {
+ BaseClient
+}
+
+// NewSnapshotsClient creates an instance of the SnapshotsClient client.
+func NewSnapshotsClient(subscriptionID string) SnapshotsClient {
+ return NewSnapshotsClientWithBaseURI(DefaultBaseURI, subscriptionID)
+}
+
+// NewSnapshotsClientWithBaseURI creates an instance of the SnapshotsClient client.
+func NewSnapshotsClientWithBaseURI(baseURI string, subscriptionID string) SnapshotsClient {
+ return SnapshotsClient{NewWithBaseURI(baseURI, subscriptionID)}
+}
+
+// CreateOrUpdate creates or updates a snapshot.
+// Parameters:
+// resourceGroupName - the name of the resource group.
+// snapshotName - the name of the snapshot that is being created. The name can't be changed after the snapshot
+// is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The max name length is 80 characters.
+// snapshot - snapshot object supplied in the body of the Put disk operation.
+func (client SnapshotsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, snapshotName string, snapshot Snapshot) (result SnapshotsCreateOrUpdateFuture, err error) {
+ if err := validation.Validate([]validation.Validation{
+ {TargetValue: snapshot,
+ Constraints: []validation.Constraint{{Target: "snapshot.SnapshotProperties", Name: validation.Null, Rule: false,
+ Chain: []validation.Constraint{{Target: "snapshot.SnapshotProperties.CreationData", Name: validation.Null, Rule: true,
+ Chain: []validation.Constraint{{Target: "snapshot.SnapshotProperties.CreationData.ImageReference", Name: validation.Null, Rule: false,
+ Chain: []validation.Constraint{{Target: "snapshot.SnapshotProperties.CreationData.ImageReference.ID", Name: validation.Null, Rule: true, Chain: nil}}},
+ }},
+ {Target: "snapshot.SnapshotProperties.EncryptionSettings", Name: validation.Null, Rule: false,
+ Chain: []validation.Constraint{{Target: "snapshot.SnapshotProperties.EncryptionSettings.DiskEncryptionKey", Name: validation.Null, Rule: false,
+ Chain: []validation.Constraint{{Target: "snapshot.SnapshotProperties.EncryptionSettings.DiskEncryptionKey.SourceVault", Name: validation.Null, Rule: true, Chain: nil},
+ {Target: "snapshot.SnapshotProperties.EncryptionSettings.DiskEncryptionKey.SecretURL", Name: validation.Null, Rule: true, Chain: nil},
+ }},
+ {Target: "snapshot.SnapshotProperties.EncryptionSettings.KeyEncryptionKey", Name: validation.Null, Rule: false,
+ Chain: []validation.Constraint{{Target: "snapshot.SnapshotProperties.EncryptionSettings.KeyEncryptionKey.SourceVault", Name: validation.Null, Rule: true, Chain: nil},
+ {Target: "snapshot.SnapshotProperties.EncryptionSettings.KeyEncryptionKey.KeyURL", Name: validation.Null, Rule: true, Chain: nil},
+ }},
+ }},
+ }}}}}); err != nil {
+ return result, validation.NewError("compute.SnapshotsClient", "CreateOrUpdate", err.Error())
+ }
+
+ req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, snapshotName, snapshot)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "CreateOrUpdate", nil, "Failure preparing request")
+ return
+ }
+
+ result, err = client.CreateOrUpdateSender(req)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "CreateOrUpdate", result.Response(), "Failure sending request")
+ return
+ }
+
+ return
+}
+
+// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
+func (client SnapshotsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, snapshotName string, snapshot Snapshot) (*http.Request, error) {
+ pathParameters := map[string]interface{}{
+ "resourceGroupName": autorest.Encode("path", resourceGroupName),
+ "snapshotName": autorest.Encode("path", snapshotName),
+ "subscriptionId": autorest.Encode("path", client.SubscriptionID),
+ }
+
+ const APIVersion = "2018-06-01"
+ queryParameters := map[string]interface{}{
+ "api-version": APIVersion,
+ }
+
+ preparer := autorest.CreatePreparer(
+ autorest.AsContentType("application/json; charset=utf-8"),
+ autorest.AsPut(),
+ autorest.WithBaseURL(client.BaseURI),
+ autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}", pathParameters),
+ autorest.WithJSON(snapshot),
+ autorest.WithQueryParameters(queryParameters))
+ return preparer.Prepare((&http.Request{}).WithContext(ctx))
+}
+
+// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
+// http.Response Body if it receives an error.
+func (client SnapshotsClient) CreateOrUpdateSender(req *http.Request) (future SnapshotsCreateOrUpdateFuture, err error) {
+ var resp *http.Response
+ resp, err = autorest.SendWithSender(client, req,
+ azure.DoRetryWithRegistration(client.Client))
+ if err != nil {
+ return
+ }
+ err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted))
+ if err != nil {
+ return
+ }
+ future.Future, err = azure.NewFutureFromResponse(resp)
+ return
+}
+
+// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
+// closes the http.Response Body.
+func (client SnapshotsClient) CreateOrUpdateResponder(resp *http.Response) (result Snapshot, err error) {
+ err = autorest.Respond(
+ resp,
+ client.ByInspecting(),
+ azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
+ autorest.ByUnmarshallingJSON(&result),
+ autorest.ByClosing())
+ result.Response = autorest.Response{Response: resp}
+ return
+}
+
+// Delete deletes a snapshot.
+// Parameters:
+// resourceGroupName - the name of the resource group.
+// snapshotName - the name of the snapshot that is being created. The name can't be changed after the snapshot
+// is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The max name length is 80 characters.
+func (client SnapshotsClient) Delete(ctx context.Context, resourceGroupName string, snapshotName string) (result SnapshotsDeleteFuture, err error) {
+ req, err := client.DeletePreparer(ctx, resourceGroupName, snapshotName)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "Delete", nil, "Failure preparing request")
+ return
+ }
+
+ result, err = client.DeleteSender(req)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "Delete", result.Response(), "Failure sending request")
+ return
+ }
+
+ return
+}
+
+// DeletePreparer prepares the Delete request.
+func (client SnapshotsClient) DeletePreparer(ctx context.Context, resourceGroupName string, snapshotName string) (*http.Request, error) {
+ pathParameters := map[string]interface{}{
+ "resourceGroupName": autorest.Encode("path", resourceGroupName),
+ "snapshotName": autorest.Encode("path", snapshotName),
+ "subscriptionId": autorest.Encode("path", client.SubscriptionID),
+ }
+
+ const APIVersion = "2018-06-01"
+ queryParameters := map[string]interface{}{
+ "api-version": APIVersion,
+ }
+
+ preparer := autorest.CreatePreparer(
+ autorest.AsDelete(),
+ autorest.WithBaseURL(client.BaseURI),
+ autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}", pathParameters),
+ autorest.WithQueryParameters(queryParameters))
+ return preparer.Prepare((&http.Request{}).WithContext(ctx))
+}
+
+// DeleteSender sends the Delete request. The method will close the
+// http.Response Body if it receives an error.
+func (client SnapshotsClient) DeleteSender(req *http.Request) (future SnapshotsDeleteFuture, err error) {
+ var resp *http.Response
+ resp, err = autorest.SendWithSender(client, req,
+ azure.DoRetryWithRegistration(client.Client))
+ if err != nil {
+ return
+ }
+ err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent))
+ if err != nil {
+ return
+ }
+ future.Future, err = azure.NewFutureFromResponse(resp)
+ return
+}
+
+// DeleteResponder handles the response to the Delete request. The method always
+// closes the http.Response Body.
+func (client SnapshotsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
+ err = autorest.Respond(
+ resp,
+ client.ByInspecting(),
+ azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
+ autorest.ByClosing())
+ result.Response = resp
+ return
+}
+
+// Get gets information about a snapshot.
+// Parameters:
+// resourceGroupName - the name of the resource group.
+// snapshotName - the name of the snapshot that is being created. The name can't be changed after the snapshot
+// is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The max name length is 80 characters.
+func (client SnapshotsClient) Get(ctx context.Context, resourceGroupName string, snapshotName string) (result Snapshot, err error) {
+ req, err := client.GetPreparer(ctx, resourceGroupName, snapshotName)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "Get", nil, "Failure preparing request")
+ return
+ }
+
+ resp, err := client.GetSender(req)
+ if err != nil {
+ result.Response = autorest.Response{Response: resp}
+ err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "Get", resp, "Failure sending request")
+ return
+ }
+
+ result, err = client.GetResponder(resp)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "Get", resp, "Failure responding to request")
+ }
+
+ return
+}
+
+// GetPreparer prepares the Get request.
+func (client SnapshotsClient) GetPreparer(ctx context.Context, resourceGroupName string, snapshotName string) (*http.Request, error) {
+ pathParameters := map[string]interface{}{
+ "resourceGroupName": autorest.Encode("path", resourceGroupName),
+ "snapshotName": autorest.Encode("path", snapshotName),
+ "subscriptionId": autorest.Encode("path", client.SubscriptionID),
+ }
+
+ const APIVersion = "2018-06-01"
+ queryParameters := map[string]interface{}{
+ "api-version": APIVersion,
+ }
+
+ preparer := autorest.CreatePreparer(
+ autorest.AsGet(),
+ autorest.WithBaseURL(client.BaseURI),
+ autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}", pathParameters),
+ autorest.WithQueryParameters(queryParameters))
+ return preparer.Prepare((&http.Request{}).WithContext(ctx))
+}
+
+// GetSender sends the Get request. The method will close the
+// http.Response Body if it receives an error.
+func (client SnapshotsClient) GetSender(req *http.Request) (*http.Response, error) {
+ return autorest.SendWithSender(client, req,
+ azure.DoRetryWithRegistration(client.Client))
+}
+
+// GetResponder handles the response to the Get request. The method always
+// closes the http.Response Body.
+func (client SnapshotsClient) GetResponder(resp *http.Response) (result Snapshot, err error) {
+ err = autorest.Respond(
+ resp,
+ client.ByInspecting(),
+ azure.WithErrorUnlessStatusCode(http.StatusOK),
+ autorest.ByUnmarshallingJSON(&result),
+ autorest.ByClosing())
+ result.Response = autorest.Response{Response: resp}
+ return
+}
+
+// GrantAccess grants access to a snapshot.
+// Parameters:
+// resourceGroupName - the name of the resource group.
+// snapshotName - the name of the snapshot that is being created. The name can't be changed after the snapshot
+// is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The max name length is 80 characters.
+// grantAccessData - access data object supplied in the body of the get snapshot access operation.
+func (client SnapshotsClient) GrantAccess(ctx context.Context, resourceGroupName string, snapshotName string, grantAccessData GrantAccessData) (result SnapshotsGrantAccessFuture, err error) {
+ if err := validation.Validate([]validation.Validation{
+ {TargetValue: grantAccessData,
+ Constraints: []validation.Constraint{{Target: "grantAccessData.DurationInSeconds", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
+ return result, validation.NewError("compute.SnapshotsClient", "GrantAccess", err.Error())
+ }
+
+ req, err := client.GrantAccessPreparer(ctx, resourceGroupName, snapshotName, grantAccessData)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "GrantAccess", nil, "Failure preparing request")
+ return
+ }
+
+ result, err = client.GrantAccessSender(req)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "GrantAccess", result.Response(), "Failure sending request")
+ return
+ }
+
+ return
+}
+
+// GrantAccessPreparer prepares the GrantAccess request.
+func (client SnapshotsClient) GrantAccessPreparer(ctx context.Context, resourceGroupName string, snapshotName string, grantAccessData GrantAccessData) (*http.Request, error) {
+ pathParameters := map[string]interface{}{
+ "resourceGroupName": autorest.Encode("path", resourceGroupName),
+ "snapshotName": autorest.Encode("path", snapshotName),
+ "subscriptionId": autorest.Encode("path", client.SubscriptionID),
+ }
+
+ const APIVersion = "2018-06-01"
+ queryParameters := map[string]interface{}{
+ "api-version": APIVersion,
+ }
+
+ preparer := autorest.CreatePreparer(
+ autorest.AsContentType("application/json; charset=utf-8"),
+ autorest.AsPost(),
+ autorest.WithBaseURL(client.BaseURI),
+ autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/beginGetAccess", pathParameters),
+ autorest.WithJSON(grantAccessData),
+ autorest.WithQueryParameters(queryParameters))
+ return preparer.Prepare((&http.Request{}).WithContext(ctx))
+}
+
+// GrantAccessSender sends the GrantAccess request. The method will close the
+// http.Response Body if it receives an error.
+func (client SnapshotsClient) GrantAccessSender(req *http.Request) (future SnapshotsGrantAccessFuture, err error) {
+ var resp *http.Response
+ resp, err = autorest.SendWithSender(client, req,
+ azure.DoRetryWithRegistration(client.Client))
+ if err != nil {
+ return
+ }
+ err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted))
+ if err != nil {
+ return
+ }
+ future.Future, err = azure.NewFutureFromResponse(resp)
+ return
+}
+
+// GrantAccessResponder handles the response to the GrantAccess request. The method always
+// closes the http.Response Body.
+func (client SnapshotsClient) GrantAccessResponder(resp *http.Response) (result AccessURI, err error) {
+ err = autorest.Respond(
+ resp,
+ client.ByInspecting(),
+ azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
+ autorest.ByUnmarshallingJSON(&result),
+ autorest.ByClosing())
+ result.Response = autorest.Response{Response: resp}
+ return
+}
+
+// List lists snapshots under a subscription.
+func (client SnapshotsClient) List(ctx context.Context) (result SnapshotListPage, err error) {
+ result.fn = client.listNextResults
+ req, err := client.ListPreparer(ctx)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "List", nil, "Failure preparing request")
+ return
+ }
+
+ resp, err := client.ListSender(req)
+ if err != nil {
+ result.sl.Response = autorest.Response{Response: resp}
+ err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "List", resp, "Failure sending request")
+ return
+ }
+
+ result.sl, err = client.ListResponder(resp)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "List", resp, "Failure responding to request")
+ }
+
+ return
+}
+
+// ListPreparer prepares the List request.
+func (client SnapshotsClient) ListPreparer(ctx context.Context) (*http.Request, error) {
+ pathParameters := map[string]interface{}{
+ "subscriptionId": autorest.Encode("path", client.SubscriptionID),
+ }
+
+ const APIVersion = "2018-06-01"
+ queryParameters := map[string]interface{}{
+ "api-version": APIVersion,
+ }
+
+ preparer := autorest.CreatePreparer(
+ autorest.AsGet(),
+ autorest.WithBaseURL(client.BaseURI),
+ autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Compute/snapshots", pathParameters),
+ autorest.WithQueryParameters(queryParameters))
+ return preparer.Prepare((&http.Request{}).WithContext(ctx))
+}
+
+// ListSender sends the List request. The method will close the
+// http.Response Body if it receives an error.
+func (client SnapshotsClient) ListSender(req *http.Request) (*http.Response, error) {
+ return autorest.SendWithSender(client, req,
+ azure.DoRetryWithRegistration(client.Client))
+}
+
+// ListResponder handles the response to the List request. The method always
+// closes the http.Response Body.
+func (client SnapshotsClient) ListResponder(resp *http.Response) (result SnapshotList, err error) {
+ err = autorest.Respond(
+ resp,
+ client.ByInspecting(),
+ azure.WithErrorUnlessStatusCode(http.StatusOK),
+ autorest.ByUnmarshallingJSON(&result),
+ autorest.ByClosing())
+ result.Response = autorest.Response{Response: resp}
+ return
+}
+
+// listNextResults retrieves the next set of results, if any.
+func (client SnapshotsClient) listNextResults(lastResults SnapshotList) (result SnapshotList, err error) {
+ req, err := lastResults.snapshotListPreparer()
+ if err != nil {
+ return result, autorest.NewErrorWithError(err, "compute.SnapshotsClient", "listNextResults", nil, "Failure preparing next results request")
+ }
+ if req == nil {
+ return
+ }
+ resp, err := client.ListSender(req)
+ if err != nil {
+ result.Response = autorest.Response{Response: resp}
+ return result, autorest.NewErrorWithError(err, "compute.SnapshotsClient", "listNextResults", resp, "Failure sending next results request")
+ }
+ result, err = client.ListResponder(resp)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "listNextResults", resp, "Failure responding to next results request")
+ }
+ return
+}
+
+// ListComplete enumerates all values, automatically crossing page boundaries as required.
+func (client SnapshotsClient) ListComplete(ctx context.Context) (result SnapshotListIterator, err error) {
+ result.page, err = client.List(ctx)
+ return
+}
+
+// ListByResourceGroup lists snapshots under a resource group.
+// Parameters:
+// resourceGroupName - the name of the resource group.
+func (client SnapshotsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result SnapshotListPage, err error) {
+ result.fn = client.listByResourceGroupNextResults
+ req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "ListByResourceGroup", nil, "Failure preparing request")
+ return
+ }
+
+ resp, err := client.ListByResourceGroupSender(req)
+ if err != nil {
+ result.sl.Response = autorest.Response{Response: resp}
+ err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "ListByResourceGroup", resp, "Failure sending request")
+ return
+ }
+
+ result.sl, err = client.ListByResourceGroupResponder(resp)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "ListByResourceGroup", resp, "Failure responding to request")
+ }
+
+ return
+}
+
+// ListByResourceGroupPreparer prepares the ListByResourceGroup request.
+func (client SnapshotsClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) {
+ pathParameters := map[string]interface{}{
+ "resourceGroupName": autorest.Encode("path", resourceGroupName),
+ "subscriptionId": autorest.Encode("path", client.SubscriptionID),
+ }
+
+ const APIVersion = "2018-06-01"
+ queryParameters := map[string]interface{}{
+ "api-version": APIVersion,
+ }
+
+ preparer := autorest.CreatePreparer(
+ autorest.AsGet(),
+ autorest.WithBaseURL(client.BaseURI),
+ autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots", pathParameters),
+ autorest.WithQueryParameters(queryParameters))
+ return preparer.Prepare((&http.Request{}).WithContext(ctx))
+}
+
+// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the
+// http.Response Body if it receives an error.
+func (client SnapshotsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) {
+ return autorest.SendWithSender(client, req,
+ azure.DoRetryWithRegistration(client.Client))
+}
+
+// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always
+// closes the http.Response Body.
+func (client SnapshotsClient) ListByResourceGroupResponder(resp *http.Response) (result SnapshotList, err error) {
+ err = autorest.Respond(
+ resp,
+ client.ByInspecting(),
+ azure.WithErrorUnlessStatusCode(http.StatusOK),
+ autorest.ByUnmarshallingJSON(&result),
+ autorest.ByClosing())
+ result.Response = autorest.Response{Response: resp}
+ return
+}
+
+// listByResourceGroupNextResults retrieves the next set of results, if any.
+func (client SnapshotsClient) listByResourceGroupNextResults(lastResults SnapshotList) (result SnapshotList, err error) {
+ req, err := lastResults.snapshotListPreparer()
+ if err != nil {
+ return result, autorest.NewErrorWithError(err, "compute.SnapshotsClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request")
+ }
+ if req == nil {
+ return
+ }
+ resp, err := client.ListByResourceGroupSender(req)
+ if err != nil {
+ result.Response = autorest.Response{Response: resp}
+ return result, autorest.NewErrorWithError(err, "compute.SnapshotsClient", "listByResourceGroupNextResults", resp, "Failure sending next results request")
+ }
+ result, err = client.ListByResourceGroupResponder(resp)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request")
+ }
+ return
+}
+
+// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required.
+func (client SnapshotsClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result SnapshotListIterator, err error) {
+ result.page, err = client.ListByResourceGroup(ctx, resourceGroupName)
+ return
+}
+
+// RevokeAccess revokes access to a snapshot.
+// Parameters:
+// resourceGroupName - the name of the resource group.
+// snapshotName - the name of the snapshot that is being created. The name can't be changed after the snapshot
+// is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The max name length is 80 characters.
+func (client SnapshotsClient) RevokeAccess(ctx context.Context, resourceGroupName string, snapshotName string) (result SnapshotsRevokeAccessFuture, err error) {
+ req, err := client.RevokeAccessPreparer(ctx, resourceGroupName, snapshotName)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "RevokeAccess", nil, "Failure preparing request")
+ return
+ }
+
+ result, err = client.RevokeAccessSender(req)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "RevokeAccess", result.Response(), "Failure sending request")
+ return
+ }
+
+ return
+}
+
+// RevokeAccessPreparer prepares the RevokeAccess request.
+func (client SnapshotsClient) RevokeAccessPreparer(ctx context.Context, resourceGroupName string, snapshotName string) (*http.Request, error) {
+ pathParameters := map[string]interface{}{
+ "resourceGroupName": autorest.Encode("path", resourceGroupName),
+ "snapshotName": autorest.Encode("path", snapshotName),
+ "subscriptionId": autorest.Encode("path", client.SubscriptionID),
+ }
+
+ const APIVersion = "2018-06-01"
+ queryParameters := map[string]interface{}{
+ "api-version": APIVersion,
+ }
+
+ preparer := autorest.CreatePreparer(
+ autorest.AsPost(),
+ autorest.WithBaseURL(client.BaseURI),
+ autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/endGetAccess", pathParameters),
+ autorest.WithQueryParameters(queryParameters))
+ return preparer.Prepare((&http.Request{}).WithContext(ctx))
+}
+
+// RevokeAccessSender sends the RevokeAccess request. The method will close the
+// http.Response Body if it receives an error.
+func (client SnapshotsClient) RevokeAccessSender(req *http.Request) (future SnapshotsRevokeAccessFuture, err error) {
+ var resp *http.Response
+ resp, err = autorest.SendWithSender(client, req,
+ azure.DoRetryWithRegistration(client.Client))
+ if err != nil {
+ return
+ }
+ err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted))
+ if err != nil {
+ return
+ }
+ future.Future, err = azure.NewFutureFromResponse(resp)
+ return
+}
+
+// RevokeAccessResponder handles the response to the RevokeAccess request. The method always
+// closes the http.Response Body.
+func (client SnapshotsClient) RevokeAccessResponder(resp *http.Response) (result autorest.Response, err error) {
+ err = autorest.Respond(
+ resp,
+ client.ByInspecting(),
+ azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
+ autorest.ByClosing())
+ result.Response = resp
+ return
+}
+
+// Update updates (patches) a snapshot.
+// Parameters:
+// resourceGroupName - the name of the resource group.
+// snapshotName - the name of the snapshot that is being created. The name can't be changed after the snapshot
+// is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The max name length is 80 characters.
+// snapshot - snapshot object supplied in the body of the Patch snapshot operation.
+func (client SnapshotsClient) Update(ctx context.Context, resourceGroupName string, snapshotName string, snapshot SnapshotUpdate) (result SnapshotsUpdateFuture, err error) {
+ req, err := client.UpdatePreparer(ctx, resourceGroupName, snapshotName, snapshot)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "Update", nil, "Failure preparing request")
+ return
+ }
+
+ result, err = client.UpdateSender(req)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "Update", result.Response(), "Failure sending request")
+ return
+ }
+
+ return
+}
+
+// UpdatePreparer prepares the Update request.
+func (client SnapshotsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, snapshotName string, snapshot SnapshotUpdate) (*http.Request, error) {
+ pathParameters := map[string]interface{}{
+ "resourceGroupName": autorest.Encode("path", resourceGroupName),
+ "snapshotName": autorest.Encode("path", snapshotName),
+ "subscriptionId": autorest.Encode("path", client.SubscriptionID),
+ }
+
+ const APIVersion = "2018-06-01"
+ queryParameters := map[string]interface{}{
+ "api-version": APIVersion,
+ }
+
+ preparer := autorest.CreatePreparer(
+ autorest.AsContentType("application/json; charset=utf-8"),
+ autorest.AsPatch(),
+ autorest.WithBaseURL(client.BaseURI),
+ autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}", pathParameters),
+ autorest.WithJSON(snapshot),
+ autorest.WithQueryParameters(queryParameters))
+ return preparer.Prepare((&http.Request{}).WithContext(ctx))
+}
+
+// UpdateSender sends the Update request. The method will close the
+// http.Response Body if it receives an error.
+func (client SnapshotsClient) UpdateSender(req *http.Request) (future SnapshotsUpdateFuture, err error) {
+ var resp *http.Response
+ resp, err = autorest.SendWithSender(client, req,
+ azure.DoRetryWithRegistration(client.Client))
+ if err != nil {
+ return
+ }
+ err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted))
+ if err != nil {
+ return
+ }
+ future.Future, err = azure.NewFutureFromResponse(resp)
+ return
+}
+
+// UpdateResponder handles the response to the Update request. The method always
+// closes the http.Response Body.
+func (client SnapshotsClient) UpdateResponder(resp *http.Response) (result Snapshot, err error) {
+ err = autorest.Respond(
+ resp,
+ client.ByInspecting(),
+ azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
+ autorest.ByUnmarshallingJSON(&result),
+ autorest.ByClosing())
+ result.Response = autorest.Response{Response: resp}
+ return
+}
diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-06-01/compute/virtualmachinescalesetrollingupgrades.go b/vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-06-01/compute/virtualmachinescalesetrollingupgrades.go
index 4b13e241a5..c1d1b626f9 100644
--- a/vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-06-01/compute/virtualmachinescalesetrollingupgrades.go
+++ b/vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-06-01/compute/virtualmachinescalesetrollingupgrades.go
@@ -178,6 +178,78 @@ func (client VirtualMachineScaleSetRollingUpgradesClient) GetLatestResponder(res
return
}
+// StartExtensionUpgrade starts a rolling upgrade to move all extensions for all virtual machine scale set instances to
+// the latest available extension version. Instances which are already running the latest extension versions are not
+// affected.
+// Parameters:
+// resourceGroupName - the name of the resource group.
+// VMScaleSetName - the name of the VM scale set.
+func (client VirtualMachineScaleSetRollingUpgradesClient) StartExtensionUpgrade(ctx context.Context, resourceGroupName string, VMScaleSetName string) (result VirtualMachineScaleSetRollingUpgradesStartExtensionUpgradeFuture, err error) {
+ req, err := client.StartExtensionUpgradePreparer(ctx, resourceGroupName, VMScaleSetName)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetRollingUpgradesClient", "StartExtensionUpgrade", nil, "Failure preparing request")
+ return
+ }
+
+ result, err = client.StartExtensionUpgradeSender(req)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetRollingUpgradesClient", "StartExtensionUpgrade", result.Response(), "Failure sending request")
+ return
+ }
+
+ return
+}
+
+// StartExtensionUpgradePreparer prepares the StartExtensionUpgrade request.
+func (client VirtualMachineScaleSetRollingUpgradesClient) StartExtensionUpgradePreparer(ctx context.Context, resourceGroupName string, VMScaleSetName string) (*http.Request, error) {
+ pathParameters := map[string]interface{}{
+ "resourceGroupName": autorest.Encode("path", resourceGroupName),
+ "subscriptionId": autorest.Encode("path", client.SubscriptionID),
+ "vmScaleSetName": autorest.Encode("path", VMScaleSetName),
+ }
+
+ const APIVersion = "2018-06-01"
+ queryParameters := map[string]interface{}{
+ "api-version": APIVersion,
+ }
+
+ preparer := autorest.CreatePreparer(
+ autorest.AsPost(),
+ autorest.WithBaseURL(client.BaseURI),
+ autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensionRollingUpgrade", pathParameters),
+ autorest.WithQueryParameters(queryParameters))
+ return preparer.Prepare((&http.Request{}).WithContext(ctx))
+}
+
+// StartExtensionUpgradeSender sends the StartExtensionUpgrade request. The method will close the
+// http.Response Body if it receives an error.
+func (client VirtualMachineScaleSetRollingUpgradesClient) StartExtensionUpgradeSender(req *http.Request) (future VirtualMachineScaleSetRollingUpgradesStartExtensionUpgradeFuture, err error) {
+ var resp *http.Response
+ resp, err = autorest.SendWithSender(client, req,
+ azure.DoRetryWithRegistration(client.Client))
+ if err != nil {
+ return
+ }
+ err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted))
+ if err != nil {
+ return
+ }
+ future.Future, err = azure.NewFutureFromResponse(resp)
+ return
+}
+
+// StartExtensionUpgradeResponder handles the response to the StartExtensionUpgrade request. The method always
+// closes the http.Response Body.
+func (client VirtualMachineScaleSetRollingUpgradesClient) StartExtensionUpgradeResponder(resp *http.Response) (result autorest.Response, err error) {
+ err = autorest.Respond(
+ resp,
+ client.ByInspecting(),
+ azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
+ autorest.ByClosing())
+ result.Response = resp
+ return
+}
+
// StartOSUpgrade starts a rolling upgrade to move all virtual machine scale set instances to the latest available
// Platform Image OS version. Instances which are already running the latest available OS version are not affected.
// Parameters:
diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-06-01/compute/virtualmachinescalesets.go b/vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-06-01/compute/virtualmachinescalesets.go
index bd131a1e01..69a16b80c7 100644
--- a/vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-06-01/compute/virtualmachinescalesets.go
+++ b/vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-06-01/compute/virtualmachinescalesets.go
@@ -943,7 +943,9 @@ func (client VirtualMachineScaleSetsClient) ListSkusComplete(ctx context.Context
return
}
-// PerformMaintenance perform maintenance on one or more virtual machines in a VM scale set.
+// PerformMaintenance perform maintenance on one or more virtual machines in a VM scale set. Operation on instances
+// which are not eligible for perform maintenance will be failed. Please refer to best practices for more details:
+// https://docs.microsoft.com/en-us/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-maintenance-notifications
// Parameters:
// resourceGroupName - the name of the resource group.
// VMScaleSetName - the name of the VM scale set.
diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-06-01/compute/virtualmachinesizes.go b/vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-06-01/compute/virtualmachinesizes.go
index ddfc1babd3..724c062523 100644
--- a/vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-06-01/compute/virtualmachinesizes.go
+++ b/vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-06-01/compute/virtualmachinesizes.go
@@ -40,7 +40,8 @@ func NewVirtualMachineSizesClientWithBaseURI(baseURI string, subscriptionID stri
return VirtualMachineSizesClient{NewWithBaseURI(baseURI, subscriptionID)}
}
-// List lists all available virtual machine sizes for a subscription in a location.
+// List this API is deprecated. Use [Resources
+// Skus](https://docs.microsoft.com/en-us/rest/api/compute/resourceskus/list)
// Parameters:
// location - the location upon which virtual-machine-sizes is queried.
func (client VirtualMachineSizesClient) List(ctx context.Context, location string) (result VirtualMachineSizeListResult, err error) {
diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-06-01/network/models.go b/vendor/github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-06-01/network/models.go
index f2488eb15c..27fc6a3259 100644
--- a/vendor/github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-06-01/network/models.go
+++ b/vendor/github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-06-01/network/models.go
@@ -5452,6 +5452,27 @@ type BgpSettings struct {
PeerWeight *int32 `json:"peerWeight,omitempty"`
}
+// ConfigurationDiagnosticParameters parameters to get network configuration diagnostic.
+type ConfigurationDiagnosticParameters struct {
+ // TargetResourceID - The ID of the target resource to perform network configuration diagnostic. Valid options are VM, NetworkInterface, VMSS/NetworkInterface and Application Gateway.
+ TargetResourceID *string `json:"targetResourceId,omitempty"`
+ // Queries - List of traffic queries.
+ Queries *[]TrafficQuery `json:"queries,omitempty"`
+}
+
+// ConfigurationDiagnosticResponse results of network configuration diagnostic on the target resource.
+type ConfigurationDiagnosticResponse struct {
+ autorest.Response `json:"-"`
+ // Results - List of network configuration diagnostic results.
+ Results *[]ConfigurationDiagnosticResult `json:"results,omitempty"`
+}
+
+// ConfigurationDiagnosticResult network configuration diagnostic result corresponded to provided traffic query.
+type ConfigurationDiagnosticResult struct {
+ TrafficQuery *TrafficQuery `json:"trafficQuery,omitempty"`
+ NetworkSecurityGroupResult *SecurityGroupResult `json:"networkSecurityGroupResult,omitempty"`
+}
+
// ConnectionMonitor parameters that define the operation to create a connection monitor.
type ConnectionMonitor struct {
// Location - Connection monitor location.
@@ -5853,6 +5874,16 @@ type ConnectionStateSnapshot struct {
EndTime *date.Time `json:"endTime,omitempty"`
// EvaluationState - Connectivity analysis evaluation state. Possible values include: 'NotStarted', 'InProgress', 'Completed'
EvaluationState EvaluationState `json:"evaluationState,omitempty"`
+ // AvgLatencyInMs - Average latency in ms.
+ AvgLatencyInMs *int32 `json:"avgLatencyInMs,omitempty"`
+ // MinLatencyInMs - Minimum latency in ms.
+ MinLatencyInMs *int32 `json:"minLatencyInMs,omitempty"`
+ // MaxLatencyInMs - Maximum latency in ms.
+ MaxLatencyInMs *int32 `json:"maxLatencyInMs,omitempty"`
+ // ProbesSent - The number of sent probes.
+ ProbesSent *int32 `json:"probesSent,omitempty"`
+ // ProbesFailed - The number of failed probes.
+ ProbesFailed *int32 `json:"probesFailed,omitempty"`
// Hops - List of hops between the source and the destination.
Hops *[]ConnectivityHop `json:"hops,omitempty"`
}
@@ -6487,6 +6518,20 @@ type ErrorDetails struct {
Message *string `json:"message,omitempty"`
}
+// ErrorResponse the error object.
+type ErrorResponse struct {
+ Error *ErrorDetails `json:"error,omitempty"`
+}
+
+// EvaluatedNetworkSecurityGroup results of network security group evaluation.
+type EvaluatedNetworkSecurityGroup struct {
+ // NetworkSecurityGroupID - Network security group ID.
+ NetworkSecurityGroupID *string `json:"networkSecurityGroupId,omitempty"`
+ MatchedRule *MatchedRule `json:"matchedRule,omitempty"`
+ // RulesEvaluationResult - List of network security rules evaluation results.
+ RulesEvaluationResult *[]SecurityRulesEvaluationResult `json:"rulesEvaluationResult,omitempty"`
+}
+
// ExpressRouteCircuit expressRouteCircuit resource
type ExpressRouteCircuit struct {
autorest.Response `json:"-"`
@@ -11947,6 +11992,14 @@ type LogSpecification struct {
BlobDuration *string `json:"blobDuration,omitempty"`
}
+// MatchedRule matched rule.
+type MatchedRule struct {
+ // RuleName - Name of the matched network security rule.
+ RuleName *string `json:"ruleName,omitempty"`
+ // Action - The network traffic is allowed or denied. Possible values are 'Allow' and 'Deny'.
+ Action *string `json:"action,omitempty"`
+}
+
// MetricSpecification description of metrics specification.
type MetricSpecification struct {
// Name - The name of the metric.
@@ -14833,6 +14886,14 @@ type SecurityGroupPropertiesFormat struct {
ProvisioningState *string `json:"provisioningState,omitempty"`
}
+// SecurityGroupResult network configuration diagnostic result corresponded provided traffic query.
+type SecurityGroupResult struct {
+ // SecurityRuleAccessResult - The network traffic is allowed or denied. Possible values are 'Allow' and 'Deny'. Possible values include: 'SecurityRuleAccessAllow', 'SecurityRuleAccessDeny'
+ SecurityRuleAccessResult SecurityRuleAccess `json:"securityRuleAccessResult,omitempty"`
+ // EvaluatedNetworkSecurityGroups - List of results network security groups diagnostic.
+ EvaluatedNetworkSecurityGroups *[]EvaluatedNetworkSecurityGroup `json:"evaluatedNetworkSecurityGroups,omitempty"`
+}
+
// SecurityGroupsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running
// operation.
type SecurityGroupsCreateOrUpdateFuture struct {
@@ -15208,6 +15269,22 @@ func (future *SecurityRulesDeleteFuture) Result(client SecurityRulesClient) (ar
return
}
+// SecurityRulesEvaluationResult network security rules evaluation result.
+type SecurityRulesEvaluationResult struct {
+ // Name - Name of the network security rule.
+ Name *string `json:"name,omitempty"`
+ // ProtocolMatched - Value indicating whether protocol is matched.
+ ProtocolMatched *bool `json:"protocolMatched,omitempty"`
+ // SourceMatched - Value indicating whether source is matched.
+ SourceMatched *bool `json:"sourceMatched,omitempty"`
+ // SourcePortMatched - Value indicating whether source port is matched.
+ SourcePortMatched *bool `json:"sourcePortMatched,omitempty"`
+ // DestinationMatched - Value indicating whether destination is matched.
+ DestinationMatched *bool `json:"destinationMatched,omitempty"`
+ // DestinationPortMatched - Value indicating whether destination port is matched.
+ DestinationPortMatched *bool `json:"destinationPortMatched,omitempty"`
+}
+
// ServiceEndpointPropertiesFormat the service endpoint properties.
type ServiceEndpointPropertiesFormat struct {
// Service - The type of the endpoint service.
@@ -15567,6 +15644,20 @@ type TrafficAnalyticsProperties struct {
NetworkWatcherFlowAnalyticsConfiguration *TrafficAnalyticsConfigurationProperties `json:"networkWatcherFlowAnalyticsConfiguration,omitempty"`
}
+// TrafficQuery parameters to compare with network configuration.
+type TrafficQuery struct {
+ // Direction - The direction of the traffic. Accepted values are 'Inbound' and 'Outbound'. Possible values include: 'Inbound', 'Outbound'
+ Direction Direction `json:"direction,omitempty"`
+ // Protocol - Protocol to be verified on. Accepted values are '*', TCP, UDP.
+ Protocol *string `json:"protocol,omitempty"`
+ // Source - Traffic source. Accepted values are '*', IP Address/CIDR, Service Tag.
+ Source *string `json:"source,omitempty"`
+ // Destination - Traffic destination. Accepted values are: '*', IP Address/CIDR, Service Tag.
+ Destination *string `json:"destination,omitempty"`
+ // DestinationPort - Traffice destination port. Accepted values are '*', port (for example, 3389) and port range (for example, 80-100).
+ DestinationPort *string `json:"destinationPort,omitempty"`
+}
+
// TroubleshootingDetails information gained from troubleshooting of specified resource.
type TroubleshootingDetails struct {
// ID - The id of the get troubleshoot operation.
@@ -17487,6 +17578,29 @@ func (future *VirtualNetworkGatewaysResetFuture) Result(client VirtualNetworkGat
return
}
+// VirtualNetworkGatewaysResetVpnClientSharedKeyFuture an abstraction for monitoring and retrieving the results of
+// a long-running operation.
+type VirtualNetworkGatewaysResetVpnClientSharedKeyFuture struct {
+ azure.Future
+}
+
+// Result returns the result of the asynchronous operation.
+// If the operation has not completed it will return an error.
+func (future *VirtualNetworkGatewaysResetVpnClientSharedKeyFuture) Result(client VirtualNetworkGatewaysClient) (ar autorest.Response, err error) {
+ var done bool
+ done, err = future.Done(client)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysResetVpnClientSharedKeyFuture", "Result", future.Response(), "Polling failure")
+ return
+ }
+ if !done {
+ err = azure.NewAsyncOpIncompleteError("network.VirtualNetworkGatewaysResetVpnClientSharedKeyFuture")
+ return
+ }
+ ar.Response = future.Response()
+ return
+}
+
// VirtualNetworkGatewaysSetVpnclientIpsecParametersFuture an abstraction for monitoring and retrieving the results
// of a long-running operation.
type VirtualNetworkGatewaysSetVpnclientIpsecParametersFuture struct {
@@ -19493,6 +19607,35 @@ func (future *WatchersGetFlowLogStatusFuture) Result(client WatchersClient) (fli
return
}
+// WatchersGetNetworkConfigurationDiagnosticFuture an abstraction for monitoring and retrieving the results of a
+// long-running operation.
+type WatchersGetNetworkConfigurationDiagnosticFuture struct {
+ azure.Future
+}
+
+// Result returns the result of the asynchronous operation.
+// If the operation has not completed it will return an error.
+func (future *WatchersGetNetworkConfigurationDiagnosticFuture) Result(client WatchersClient) (cdr ConfigurationDiagnosticResponse, err error) {
+ var done bool
+ done, err = future.Done(client)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "network.WatchersGetNetworkConfigurationDiagnosticFuture", "Result", future.Response(), "Polling failure")
+ return
+ }
+ if !done {
+ err = azure.NewAsyncOpIncompleteError("network.WatchersGetNetworkConfigurationDiagnosticFuture")
+ return
+ }
+ sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
+ if cdr.Response.Response, err = future.GetResult(sender); err == nil && cdr.Response.Response.StatusCode != http.StatusNoContent {
+ cdr, err = client.GetNetworkConfigurationDiagnosticResponder(cdr.Response.Response)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "network.WatchersGetNetworkConfigurationDiagnosticFuture", "Result", cdr.Response.Response, "Failure responding to request")
+ }
+ }
+ return
+}
+
// WatchersGetNextHopFuture an abstraction for monitoring and retrieving the results of a long-running operation.
type WatchersGetNextHopFuture struct {
azure.Future
diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-06-01/network/virtualnetworkgateways.go b/vendor/github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-06-01/network/virtualnetworkgateways.go
index 93daa0f71c..ba9a78be9a 100644
--- a/vendor/github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-06-01/network/virtualnetworkgateways.go
+++ b/vendor/github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-06-01/network/virtualnetworkgateways.go
@@ -1037,6 +1037,77 @@ func (client VirtualNetworkGatewaysClient) ResetResponder(resp *http.Response) (
return
}
+// ResetVpnClientSharedKey resets the VPN client shared key of the virtual network gateway in the specified resource
+// group.
+// Parameters:
+// resourceGroupName - the name of the resource group.
+// virtualNetworkGatewayName - the name of the virtual network gateway.
+func (client VirtualNetworkGatewaysClient) ResetVpnClientSharedKey(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (result VirtualNetworkGatewaysResetVpnClientSharedKeyFuture, err error) {
+ req, err := client.ResetVpnClientSharedKeyPreparer(ctx, resourceGroupName, virtualNetworkGatewayName)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "ResetVpnClientSharedKey", nil, "Failure preparing request")
+ return
+ }
+
+ result, err = client.ResetVpnClientSharedKeySender(req)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "ResetVpnClientSharedKey", result.Response(), "Failure sending request")
+ return
+ }
+
+ return
+}
+
+// ResetVpnClientSharedKeyPreparer prepares the ResetVpnClientSharedKey request.
+func (client VirtualNetworkGatewaysClient) ResetVpnClientSharedKeyPreparer(ctx context.Context, resourceGroupName string, virtualNetworkGatewayName string) (*http.Request, error) {
+ pathParameters := map[string]interface{}{
+ "resourceGroupName": autorest.Encode("path", resourceGroupName),
+ "subscriptionId": autorest.Encode("path", client.SubscriptionID),
+ "virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName),
+ }
+
+ const APIVersion = "2018-06-01"
+ queryParameters := map[string]interface{}{
+ "api-version": APIVersion,
+ }
+
+ preparer := autorest.CreatePreparer(
+ autorest.AsPost(),
+ autorest.WithBaseURL(client.BaseURI),
+ autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/resetvpnclientsharedkey", pathParameters),
+ autorest.WithQueryParameters(queryParameters))
+ return preparer.Prepare((&http.Request{}).WithContext(ctx))
+}
+
+// ResetVpnClientSharedKeySender sends the ResetVpnClientSharedKey request. The method will close the
+// http.Response Body if it receives an error.
+func (client VirtualNetworkGatewaysClient) ResetVpnClientSharedKeySender(req *http.Request) (future VirtualNetworkGatewaysResetVpnClientSharedKeyFuture, err error) {
+ var resp *http.Response
+ resp, err = autorest.SendWithSender(client, req,
+ azure.DoRetryWithRegistration(client.Client))
+ if err != nil {
+ return
+ }
+ err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted))
+ if err != nil {
+ return
+ }
+ future.Future, err = azure.NewFutureFromResponse(resp)
+ return
+}
+
+// ResetVpnClientSharedKeyResponder handles the response to the ResetVpnClientSharedKey request. The method always
+// closes the http.Response Body.
+func (client VirtualNetworkGatewaysClient) ResetVpnClientSharedKeyResponder(resp *http.Response) (result autorest.Response, err error) {
+ err = autorest.Respond(
+ resp,
+ client.ByInspecting(),
+ azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
+ autorest.ByClosing())
+ result.Response = resp
+ return
+}
+
// SetVpnclientIpsecParameters the Set VpnclientIpsecParameters operation sets the vpnclient ipsec policy for P2S
// client of virtual network gateway in the specified resource group through Network resource provider.
// Parameters:
diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-06-01/network/watchers.go b/vendor/github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-06-01/network/watchers.go
index b7cd682491..5a1813cc37 100644
--- a/vendor/github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-06-01/network/watchers.go
+++ b/vendor/github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-06-01/network/watchers.go
@@ -494,6 +494,87 @@ func (client WatchersClient) GetFlowLogStatusResponder(resp *http.Response) (res
return
}
+// GetNetworkConfigurationDiagnostic get network configuration diagnostic.
+// Parameters:
+// resourceGroupName - the name of the resource group.
+// networkWatcherName - the name of the network watcher.
+// parameters - parameters to get network configuration diagnostic.
+func (client WatchersClient) GetNetworkConfigurationDiagnostic(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters ConfigurationDiagnosticParameters) (result WatchersGetNetworkConfigurationDiagnosticFuture, err error) {
+ if err := validation.Validate([]validation.Validation{
+ {TargetValue: parameters,
+ Constraints: []validation.Constraint{{Target: "parameters.TargetResourceID", Name: validation.Null, Rule: true, Chain: nil},
+ {Target: "parameters.Queries", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
+ return result, validation.NewError("network.WatchersClient", "GetNetworkConfigurationDiagnostic", err.Error())
+ }
+
+ req, err := client.GetNetworkConfigurationDiagnosticPreparer(ctx, resourceGroupName, networkWatcherName, parameters)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "network.WatchersClient", "GetNetworkConfigurationDiagnostic", nil, "Failure preparing request")
+ return
+ }
+
+ result, err = client.GetNetworkConfigurationDiagnosticSender(req)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "network.WatchersClient", "GetNetworkConfigurationDiagnostic", result.Response(), "Failure sending request")
+ return
+ }
+
+ return
+}
+
+// GetNetworkConfigurationDiagnosticPreparer prepares the GetNetworkConfigurationDiagnostic request.
+func (client WatchersClient) GetNetworkConfigurationDiagnosticPreparer(ctx context.Context, resourceGroupName string, networkWatcherName string, parameters ConfigurationDiagnosticParameters) (*http.Request, error) {
+ pathParameters := map[string]interface{}{
+ "networkWatcherName": autorest.Encode("path", networkWatcherName),
+ "resourceGroupName": autorest.Encode("path", resourceGroupName),
+ "subscriptionId": autorest.Encode("path", client.SubscriptionID),
+ }
+
+ const APIVersion = "2018-06-01"
+ queryParameters := map[string]interface{}{
+ "api-version": APIVersion,
+ }
+
+ preparer := autorest.CreatePreparer(
+ autorest.AsContentType("application/json; charset=utf-8"),
+ autorest.AsPost(),
+ autorest.WithBaseURL(client.BaseURI),
+ autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/networkConfigurationDiagnostic", pathParameters),
+ autorest.WithJSON(parameters),
+ autorest.WithQueryParameters(queryParameters))
+ return preparer.Prepare((&http.Request{}).WithContext(ctx))
+}
+
+// GetNetworkConfigurationDiagnosticSender sends the GetNetworkConfigurationDiagnostic request. The method will close the
+// http.Response Body if it receives an error.
+func (client WatchersClient) GetNetworkConfigurationDiagnosticSender(req *http.Request) (future WatchersGetNetworkConfigurationDiagnosticFuture, err error) {
+ var resp *http.Response
+ resp, err = autorest.SendWithSender(client, req,
+ azure.DoRetryWithRegistration(client.Client))
+ if err != nil {
+ return
+ }
+ err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted))
+ if err != nil {
+ return
+ }
+ future.Future, err = azure.NewFutureFromResponse(resp)
+ return
+}
+
+// GetNetworkConfigurationDiagnosticResponder handles the response to the GetNetworkConfigurationDiagnostic request. The method always
+// closes the http.Response Body.
+func (client WatchersClient) GetNetworkConfigurationDiagnosticResponder(resp *http.Response) (result ConfigurationDiagnosticResponse, err error) {
+ err = autorest.Respond(
+ resp,
+ client.ByInspecting(),
+ azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
+ autorest.ByUnmarshallingJSON(&result),
+ autorest.ByClosing())
+ result.Response = autorest.Response{Response: resp}
+ return
+}
+
// GetNextHop gets the next hop from the specified VM.
// Parameters:
// resourceGroupName - the name of the resource group.
diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-05-01/resources/models.go b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-05-01/resources/models.go
index d43052c661..68140f69c4 100644
--- a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-05-01/resources/models.go
+++ b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-05-01/resources/models.go
@@ -1152,6 +1152,129 @@ type OnErrorDeploymentExtended struct {
DeploymentName *string `json:"deploymentName,omitempty"`
}
+// Operation microsoft.Resources operation
+type Operation struct {
+ // Name - Operation name: {provider}/{resource}/{operation}
+ Name *string `json:"name,omitempty"`
+ // Display - The object that represents the operation.
+ Display *OperationDisplay `json:"display,omitempty"`
+}
+
+// OperationDisplay the object that represents the operation.
+type OperationDisplay struct {
+ // Provider - Service provider: Microsoft.Resources
+ Provider *string `json:"provider,omitempty"`
+ // Resource - Resource on which the operation is performed: Profile, endpoint, etc.
+ Resource *string `json:"resource,omitempty"`
+ // Operation - Operation type: Read, write, delete, etc.
+ Operation *string `json:"operation,omitempty"`
+ // Description - Description of the operation.
+ Description *string `json:"description,omitempty"`
+}
+
+// OperationListResult result of the request to list Microsoft.Resources operations. It contains a list of
+// operations and a URL link to get the next set of results.
+type OperationListResult struct {
+ autorest.Response `json:"-"`
+ // Value - List of Microsoft.Resources operations.
+ Value *[]Operation `json:"value,omitempty"`
+ // NextLink - URL to get the next set of operation list results if there are any.
+ NextLink *string `json:"nextLink,omitempty"`
+}
+
+// OperationListResultIterator provides access to a complete listing of Operation values.
+type OperationListResultIterator struct {
+ i int
+ page OperationListResultPage
+}
+
+// Next advances to the next value. If there was an error making
+// the request the iterator does not advance and the error is returned.
+func (iter *OperationListResultIterator) Next() error {
+ iter.i++
+ if iter.i < len(iter.page.Values()) {
+ return nil
+ }
+ err := iter.page.Next()
+ if err != nil {
+ iter.i--
+ return err
+ }
+ iter.i = 0
+ return nil
+}
+
+// NotDone returns true if the enumeration should be started or is not yet complete.
+func (iter OperationListResultIterator) NotDone() bool {
+ return iter.page.NotDone() && iter.i < len(iter.page.Values())
+}
+
+// Response returns the raw server response from the last page request.
+func (iter OperationListResultIterator) Response() OperationListResult {
+ return iter.page.Response()
+}
+
+// Value returns the current value or a zero-initialized value if the
+// iterator has advanced beyond the end of the collection.
+func (iter OperationListResultIterator) Value() Operation {
+ if !iter.page.NotDone() {
+ return Operation{}
+ }
+ return iter.page.Values()[iter.i]
+}
+
+// IsEmpty returns true if the ListResult contains no values.
+func (olr OperationListResult) IsEmpty() bool {
+ return olr.Value == nil || len(*olr.Value) == 0
+}
+
+// operationListResultPreparer prepares a request to retrieve the next set of results.
+// It returns nil if no more results exist.
+func (olr OperationListResult) operationListResultPreparer() (*http.Request, error) {
+ if olr.NextLink == nil || len(to.String(olr.NextLink)) < 1 {
+ return nil, nil
+ }
+ return autorest.Prepare(&http.Request{},
+ autorest.AsJSON(),
+ autorest.AsGet(),
+ autorest.WithBaseURL(to.String(olr.NextLink)))
+}
+
+// OperationListResultPage contains a page of Operation values.
+type OperationListResultPage struct {
+ fn func(OperationListResult) (OperationListResult, error)
+ olr OperationListResult
+}
+
+// Next advances to the next page of values. If there was an error making
+// the request the page does not advance and the error is returned.
+func (page *OperationListResultPage) Next() error {
+ next, err := page.fn(page.olr)
+ if err != nil {
+ return err
+ }
+ page.olr = next
+ return nil
+}
+
+// NotDone returns true if the page enumeration should be started or is not yet complete.
+func (page OperationListResultPage) NotDone() bool {
+ return !page.olr.IsEmpty()
+}
+
+// Response returns the raw server response from the last page request.
+func (page OperationListResultPage) Response() OperationListResult {
+ return page.olr
+}
+
+// Values returns the slice of values for the current page or nil if there are no values.
+func (page OperationListResultPage) Values() []Operation {
+ if page.olr.IsEmpty() {
+ return nil
+ }
+ return *page.olr.Value
+}
+
// ParametersLink entity representing the reference to the deployment paramaters.
type ParametersLink struct {
// URI - The URI of the parameters file.
@@ -1297,7 +1420,7 @@ type ProviderOperationDisplayProperties struct {
Provider *string `json:"provider,omitempty"`
// Resource - Operation resource.
Resource *string `json:"resource,omitempty"`
- // Operation - Operation.
+ // Operation - Resource provider operation.
Operation *string `json:"operation,omitempty"`
// Description - Operation description.
Description *string `json:"description,omitempty"`
@@ -1338,7 +1461,7 @@ func (prt ProviderResourceType) MarshalJSON() ([]byte, error) {
return json.Marshal(objectMap)
}
-// Resource resource.
+// Resource specified resource.
type Resource struct {
// ID - Resource ID
ID *string `json:"id,omitempty"`
diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-05-01/resources/operations.go b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-05-01/resources/operations.go
new file mode 100644
index 0000000000..98dbac96bf
--- /dev/null
+++ b/vendor/github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-05-01/resources/operations.go
@@ -0,0 +1,126 @@
+package resources
+
+// Copyright (c) Microsoft and contributors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is regenerated.
+
+import (
+ "context"
+ "github.com/Azure/go-autorest/autorest"
+ "github.com/Azure/go-autorest/autorest/azure"
+ "net/http"
+)
+
+// OperationsClient is the provides operations for working with resources and resource groups.
+type OperationsClient struct {
+ BaseClient
+}
+
+// NewOperationsClient creates an instance of the OperationsClient client.
+func NewOperationsClient(subscriptionID string) OperationsClient {
+ return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID)
+}
+
+// NewOperationsClientWithBaseURI creates an instance of the OperationsClient client.
+func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient {
+ return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)}
+}
+
+// List lists all of the available Microsoft.Resources REST API operations.
+func (client OperationsClient) List(ctx context.Context) (result OperationListResultPage, err error) {
+ result.fn = client.listNextResults
+ req, err := client.ListPreparer(ctx)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "resources.OperationsClient", "List", nil, "Failure preparing request")
+ return
+ }
+
+ resp, err := client.ListSender(req)
+ if err != nil {
+ result.olr.Response = autorest.Response{Response: resp}
+ err = autorest.NewErrorWithError(err, "resources.OperationsClient", "List", resp, "Failure sending request")
+ return
+ }
+
+ result.olr, err = client.ListResponder(resp)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "resources.OperationsClient", "List", resp, "Failure responding to request")
+ }
+
+ return
+}
+
+// ListPreparer prepares the List request.
+func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) {
+ const APIVersion = "2018-05-01"
+ queryParameters := map[string]interface{}{
+ "api-version": APIVersion,
+ }
+
+ preparer := autorest.CreatePreparer(
+ autorest.AsGet(),
+ autorest.WithBaseURL(client.BaseURI),
+ autorest.WithPath("/providers/Microsoft.Resources/operations"),
+ autorest.WithQueryParameters(queryParameters))
+ return preparer.Prepare((&http.Request{}).WithContext(ctx))
+}
+
+// ListSender sends the List request. The method will close the
+// http.Response Body if it receives an error.
+func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) {
+ return autorest.SendWithSender(client, req,
+ autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
+}
+
+// ListResponder handles the response to the List request. The method always
+// closes the http.Response Body.
+func (client OperationsClient) ListResponder(resp *http.Response) (result OperationListResult, err error) {
+ err = autorest.Respond(
+ resp,
+ client.ByInspecting(),
+ azure.WithErrorUnlessStatusCode(http.StatusOK),
+ autorest.ByUnmarshallingJSON(&result),
+ autorest.ByClosing())
+ result.Response = autorest.Response{Response: resp}
+ return
+}
+
+// listNextResults retrieves the next set of results, if any.
+func (client OperationsClient) listNextResults(lastResults OperationListResult) (result OperationListResult, err error) {
+ req, err := lastResults.operationListResultPreparer()
+ if err != nil {
+ return result, autorest.NewErrorWithError(err, "resources.OperationsClient", "listNextResults", nil, "Failure preparing next results request")
+ }
+ if req == nil {
+ return
+ }
+ resp, err := client.ListSender(req)
+ if err != nil {
+ result.Response = autorest.Response{Response: resp}
+ return result, autorest.NewErrorWithError(err, "resources.OperationsClient", "listNextResults", resp, "Failure sending next results request")
+ }
+ result, err = client.ListResponder(resp)
+ if err != nil {
+ err = autorest.NewErrorWithError(err, "resources.OperationsClient", "listNextResults", resp, "Failure responding to next results request")
+ }
+ return
+}
+
+// ListComplete enumerates all values, automatically crossing page boundaries as required.
+func (client OperationsClient) ListComplete(ctx context.Context) (result OperationListResultIterator, err error) {
+ result.page, err = client.List(ctx)
+ return
+}
diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2017-10-01/storage/models.go b/vendor/github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2017-10-01/storage/models.go
index c215a75c8e..a7a286aa74 100644
--- a/vendor/github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2017-10-01/storage/models.go
+++ b/vendor/github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2017-10-01/storage/models.go
@@ -1166,7 +1166,7 @@ type Restriction struct {
Type *string `json:"type,omitempty"`
// Values - The value of restrictions. If the restriction type is set to location. This would be different locations where the SKU is restricted.
Values *[]string `json:"values,omitempty"`
- // ReasonCode - The reason for the restriction. As of now this can be “QuotaId” or “NotAvailableForSubscription”. Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The “NotAvailableForSubscription” is related to capacity at DC. Possible values include: 'QuotaID', 'NotAvailableForSubscription'
+ // ReasonCode - The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to capacity at DC. Possible values include: 'QuotaID', 'NotAvailableForSubscription'
ReasonCode ReasonCode `json:"reasonCode,omitempty"`
}
diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2018-02-01/storage/models.go b/vendor/github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2018-02-01/storage/models.go
index 6cb70114c1..f61fd25508 100644
--- a/vendor/github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2018-02-01/storage/models.go
+++ b/vendor/github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2018-02-01/storage/models.go
@@ -1676,6 +1676,8 @@ type OperationDisplay struct {
Resource *string `json:"resource,omitempty"`
// Operation - Type of operation: get, read, delete, etc.
Operation *string `json:"operation,omitempty"`
+ // Description - Description of the operation.
+ Description *string `json:"description,omitempty"`
}
// OperationListResult result of the request to list Storage operations. It contains a list of operations and a URL
@@ -1719,7 +1721,7 @@ type Restriction struct {
Type *string `json:"type,omitempty"`
// Values - The value of restrictions. If the restriction type is set to location. This would be different locations where the SKU is restricted.
Values *[]string `json:"values,omitempty"`
- // ReasonCode - The reason for the restriction. As of now this can be “QuotaId” or “NotAvailableForSubscription”. Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The “NotAvailableForSubscription” is related to capacity at DC. Possible values include: 'QuotaID', 'NotAvailableForSubscription'
+ // ReasonCode - The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to capacity at DC. Possible values include: 'QuotaID', 'NotAvailableForSubscription'
ReasonCode ReasonCode `json:"reasonCode,omitempty"`
}
diff --git a/vendor/github.com/Azure/azure-sdk-for-go/version/version.go b/vendor/github.com/Azure/azure-sdk-for-go/version/version.go
index 3153043875..a9cd65df58 100644
--- a/vendor/github.com/Azure/azure-sdk-for-go/version/version.go
+++ b/vendor/github.com/Azure/azure-sdk-for-go/version/version.go
@@ -18,4 +18,4 @@ package version
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
// Number contains the semantic version of this SDK.
-const Number = "v19.1.0"
+const Number = "v21.1.0"
diff --git a/vendor/github.com/Azure/go-autorest/autorest/sender.go b/vendor/github.com/Azure/go-autorest/autorest/sender.go
index e8893a282e..cacbd81571 100644
--- a/vendor/github.com/Azure/go-autorest/autorest/sender.go
+++ b/vendor/github.com/Azure/go-autorest/autorest/sender.go
@@ -234,7 +234,7 @@ func DoRetryForStatusCodes(attempts int, backoff time.Duration, codes ...int) Se
}
delayed := DelayWithRetryAfter(resp, r.Context().Done())
if !delayed && !DelayForBackoff(backoff, attempt, r.Context().Done()) {
- return resp, r.Context().Err()
+ return nil, r.Context().Err()
}
// don't count a 429 against the number of attempts
// so that we continue to retry until it succeeds
diff --git a/vendor/github.com/Azure/go-autorest/version/version.go b/vendor/github.com/Azure/go-autorest/version/version.go
index 94de7c51e7..ad2d6099f5 100644
--- a/vendor/github.com/Azure/go-autorest/version/version.go
+++ b/vendor/github.com/Azure/go-autorest/version/version.go
@@ -20,7 +20,7 @@ import (
)
// Number contains the semantic version of this SDK.
-const Number = "v10.15.5"
+const Number = "v10.15.4"
var (
userAgent = fmt.Sprintf("Go/%s (%s-%s) go-autorest/%s",
diff --git a/vendor/github.com/Shopify/sarama/.gitignore b/vendor/github.com/Shopify/sarama/.gitignore
index c6c482dca8..6e362e4f21 100644
--- a/vendor/github.com/Shopify/sarama/.gitignore
+++ b/vendor/github.com/Shopify/sarama/.gitignore
@@ -24,3 +24,4 @@ _testmain.go
*.exe
coverage.txt
+profile.out
diff --git a/vendor/github.com/Shopify/sarama/.travis.yml b/vendor/github.com/Shopify/sarama/.travis.yml
index ea295ec5f0..fe694e5781 100644
--- a/vendor/github.com/Shopify/sarama/.travis.yml
+++ b/vendor/github.com/Shopify/sarama/.travis.yml
@@ -1,8 +1,8 @@
language: go
go:
-- 1.8.x
-- 1.9.x
-- 1.10.x
+- 1.9.7
+- 1.10.4
+- 1.11
env:
global:
@@ -12,9 +12,9 @@ env:
- KAFKA_HOSTNAME=localhost
- DEBUG=true
matrix:
- - KAFKA_VERSION=0.11.0.2
- KAFKA_VERSION=1.0.0
- KAFKA_VERSION=1.1.0
+ - KAFKA_VERSION=2.0.0
before_install:
- export REPOSITORY_ROOT=${TRAVIS_BUILD_DIR}
@@ -28,7 +28,7 @@ script:
- make test
- make vet
- make errcheck
-- make fmt
+- if [ "$TRAVIS_GO_VERSION" = "1.11" ]; then make fmt; fi
after_success:
- bash <(curl -s https://codecov.io/bash)
diff --git a/vendor/github.com/Shopify/sarama/CHANGELOG.md b/vendor/github.com/Shopify/sarama/CHANGELOG.md
index 16d5829c99..47fb15b131 100644
--- a/vendor/github.com/Shopify/sarama/CHANGELOG.md
+++ b/vendor/github.com/Shopify/sarama/CHANGELOG.md
@@ -1,5 +1,57 @@
# Changelog
+#### Version 1.19.0 (2018-09-27)
+
+New Features:
+ - Implement a higher-level consumer group
+ ([#1099](https://github.com/Shopify/sarama/pull/1099)).
+
+Improvements:
+ - Add support for Go 1.11
+ ([#1176](https://github.com/Shopify/sarama/pull/1176)).
+
+Bug Fixes:
+ - Fix encoding of `MetadataResponse` with version 2 and higher
+ ([#1174](https://github.com/Shopify/sarama/pull/1174)).
+ - Fix race condition in mock async producer
+ ([#1174](https://github.com/Shopify/sarama/pull/1174)).
+
+#### Version 1.18.0 (2018-09-07)
+
+New Features:
+ - Make `Partitioner.RequiresConsistency` vary per-message
+ ([#1112](https://github.com/Shopify/sarama/pull/1112)).
+ - Add customizable partitioner
+ ([#1118](https://github.com/Shopify/sarama/pull/1118)).
+ - Add `ClusterAdmin` support for `CreateTopic`, `DeleteTopic`, `CreatePartitions`,
+ `DeleteRecords`, `DescribeConfig`, `AlterConfig`, `CreateACL`, `ListAcls`, `DeleteACL`
+ ([#1055](https://github.com/Shopify/sarama/pull/1055)).
+
+Improvements:
+ - Add support for Kafka 2.0.0
+ ([#1149](https://github.com/Shopify/sarama/pull/1149)).
+ - Allow setting `LocalAddr` when dialing an address to support multi-homed hosts
+ ([#1123](https://github.com/Shopify/sarama/pull/1123)).
+ - Simpler offset management
+ ([#1127](https://github.com/Shopify/sarama/pull/1127)).
+
+Bug Fixes:
+ - Fix mutation of `ProducerMessage.MetaData` when producing to Kafka
+ ([#1110](https://github.com/Shopify/sarama/pull/1110)).
+ - Fix consumer block when response did not contain all the
+ expected topic/partition blocks
+ ([#1086](https://github.com/Shopify/sarama/pull/1086)).
+ - Fix consumer block when response contains only constrol messages
+ ([#1115](https://github.com/Shopify/sarama/pull/1115)).
+ - Add timeout config for ClusterAdmin requests
+ ([#1142](https://github.com/Shopify/sarama/pull/1142)).
+ - Add version check when producing message with headers
+ ([#1117](https://github.com/Shopify/sarama/pull/1117)).
+ - Fix `MetadataRequest` for empty list of topics
+ ([#1132](https://github.com/Shopify/sarama/pull/1132)).
+ - Fix producer topic metadata on-demand fetch when topic error happens in metadata response
+ ([#1125](https://github.com/Shopify/sarama/pull/1125)).
+
#### Version 1.17.0 (2018-05-30)
New Features:
diff --git a/vendor/github.com/Shopify/sarama/Makefile b/vendor/github.com/Shopify/sarama/Makefile
index b9a453dd29..8fcf219f44 100644
--- a/vendor/github.com/Shopify/sarama/Makefile
+++ b/vendor/github.com/Shopify/sarama/Makefile
@@ -4,7 +4,7 @@ default: fmt vet errcheck test
test:
echo "" > coverage.txt
for d in `go list ./... | grep -v vendor`; do \
- go test -p 1 -v -timeout 90s -race -coverprofile=profile.out -covermode=atomic $$d || exit 1; \
+ go test -p 1 -v -timeout 240s -race -coverprofile=profile.out -covermode=atomic $$d || exit 1; \
if [ -f profile.out ]; then \
cat profile.out >> coverage.txt; \
rm profile.out; \
diff --git a/vendor/github.com/Shopify/sarama/README.md b/vendor/github.com/Shopify/sarama/README.md
index 4fc0cc600f..b99709380f 100644
--- a/vendor/github.com/Shopify/sarama/README.md
+++ b/vendor/github.com/Shopify/sarama/README.md
@@ -21,7 +21,7 @@ You might also want to look at the [Frequently Asked Questions](https://github.c
Sarama provides a "2 releases + 2 months" compatibility guarantee: we support
the two latest stable releases of Kafka and Go, and we provide a two month
grace period for older releases. This means we currently officially support
-Go 1.8 through 1.10, and Kafka 0.11 through 1.1, although older releases are
+Go 1.8 through 1.11, and Kafka 1.0 through 2.0, although older releases are
still likely to work.
Sarama follows semantic versioning and provides API stability via the gopkg.in service.
diff --git a/vendor/github.com/Shopify/sarama/admin.go b/vendor/github.com/Shopify/sarama/admin.go
new file mode 100644
index 0000000000..52725758d2
--- /dev/null
+++ b/vendor/github.com/Shopify/sarama/admin.go
@@ -0,0 +1,382 @@
+package sarama
+
+import "errors"
+
+// ClusterAdmin is the administrative client for Kafka, which supports managing and inspecting topics,
+// brokers, configurations and ACLs. The minimum broker version required is 0.10.0.0.
+// Methods with stricter requirements will specify the minimum broker version required.
+// You MUST call Close() on a client to avoid leaks
+type ClusterAdmin interface {
+ // Creates a new topic. This operation is supported by brokers with version 0.10.1.0 or higher.
+ // It may take several seconds after CreateTopic returns success for all the brokers
+ // to become aware that the topic has been created. During this time, listTopics
+ // may not return information about the new topic.The validateOnly option is supported from version 0.10.2.0.
+ CreateTopic(topic string, detail *TopicDetail, validateOnly bool) error
+
+ // Delete a topic. It may take several seconds after the DeleteTopic to returns success
+ // and for all the brokers to become aware that the topics are gone.
+ // During this time, listTopics may continue to return information about the deleted topic.
+ // If delete.topic.enable is false on the brokers, deleteTopic will mark
+ // the topic for deletion, but not actually delete them.
+ // This operation is supported by brokers with version 0.10.1.0 or higher.
+ DeleteTopic(topic string) error
+
+ // Increase the number of partitions of the topics according to the corresponding values.
+ // If partitions are increased for a topic that has a key, the partition logic or ordering of
+ // the messages will be affected. It may take several seconds after this method returns
+ // success for all the brokers to become aware that the partitions have been created.
+ // During this time, ClusterAdmin#describeTopics may not return information about the
+ // new partitions. This operation is supported by brokers with version 1.0.0 or higher.
+ CreatePartitions(topic string, count int32, assignment [][]int32, validateOnly bool) error
+
+ // Delete records whose offset is smaller than the given offset of the corresponding partition.
+ // This operation is supported by brokers with version 0.11.0.0 or higher.
+ DeleteRecords(topic string, partitionOffsets map[int32]int64) error
+
+ // Get the configuration for the specified resources.
+ // The returned configuration includes default values and the Default is true
+ // can be used to distinguish them from user supplied values.
+ // Config entries where ReadOnly is true cannot be updated.
+ // The value of config entries where Sensitive is true is always nil so
+ // sensitive information is not disclosed.
+ // This operation is supported by brokers with version 0.11.0.0 or higher.
+ DescribeConfig(resource ConfigResource) ([]ConfigEntry, error)
+
+ // Update the configuration for the specified resources with the default options.
+ // This operation is supported by brokers with version 0.11.0.0 or higher.
+ // The resources with their configs (topic is the only resource type with configs
+ // that can be updated currently Updates are not transactional so they may succeed
+ // for some resources while fail for others. The configs for a particular resource are updated automatically.
+ AlterConfig(resourceType ConfigResourceType, name string, entries map[string]*string, validateOnly bool) error
+
+ // Creates access control lists (ACLs) which are bound to specific resources.
+ // This operation is not transactional so it may succeed for some ACLs while fail for others.
+ // If you attempt to add an ACL that duplicates an existing ACL, no error will be raised, but
+ // no changes will be made. This operation is supported by brokers with version 0.11.0.0 or higher.
+ CreateACL(resource Resource, acl Acl) error
+
+ // Lists access control lists (ACLs) according to the supplied filter.
+ // it may take some time for changes made by createAcls or deleteAcls to be reflected in the output of ListAcls
+ // This operation is supported by brokers with version 0.11.0.0 or higher.
+ ListAcls(filter AclFilter) ([]ResourceAcls, error)
+
+ // Deletes access control lists (ACLs) according to the supplied filters.
+ // This operation is not transactional so it may succeed for some ACLs while fail for others.
+ // This operation is supported by brokers with version 0.11.0.0 or higher.
+ DeleteACL(filter AclFilter, validateOnly bool) ([]MatchingAcl, error)
+
+ // Close shuts down the admin and closes underlying client.
+ Close() error
+}
+
+type clusterAdmin struct {
+ client Client
+ conf *Config
+}
+
+// NewClusterAdmin creates a new ClusterAdmin using the given broker addresses and configuration.
+func NewClusterAdmin(addrs []string, conf *Config) (ClusterAdmin, error) {
+ client, err := NewClient(addrs, conf)
+ if err != nil {
+ return nil, err
+ }
+
+ //make sure we can retrieve the controller
+ _, err = client.Controller()
+ if err != nil {
+ return nil, err
+ }
+
+ ca := &clusterAdmin{
+ client: client,
+ conf: client.Config(),
+ }
+ return ca, nil
+}
+
+func (ca *clusterAdmin) Close() error {
+ return ca.client.Close()
+}
+
+func (ca *clusterAdmin) Controller() (*Broker, error) {
+ return ca.client.Controller()
+}
+
+func (ca *clusterAdmin) CreateTopic(topic string, detail *TopicDetail, validateOnly bool) error {
+
+ if topic == "" {
+ return ErrInvalidTopic
+ }
+
+ if detail == nil {
+ return errors.New("You must specify topic details")
+ }
+
+ topicDetails := make(map[string]*TopicDetail)
+ topicDetails[topic] = detail
+
+ request := &CreateTopicsRequest{
+ TopicDetails: topicDetails,
+ ValidateOnly: validateOnly,
+ Timeout: ca.conf.Admin.Timeout,
+ }
+
+ if ca.conf.Version.IsAtLeast(V0_11_0_0) {
+ request.Version = 1
+ }
+ if ca.conf.Version.IsAtLeast(V1_0_0_0) {
+ request.Version = 2
+ }
+
+ b, err := ca.Controller()
+ if err != nil {
+ return err
+ }
+
+ rsp, err := b.CreateTopics(request)
+ if err != nil {
+ return err
+ }
+
+ topicErr, ok := rsp.TopicErrors[topic]
+ if !ok {
+ return ErrIncompleteResponse
+ }
+
+ if topicErr.Err != ErrNoError {
+ return topicErr.Err
+ }
+
+ return nil
+}
+
+func (ca *clusterAdmin) DeleteTopic(topic string) error {
+
+ if topic == "" {
+ return ErrInvalidTopic
+ }
+
+ request := &DeleteTopicsRequest{
+ Topics: []string{topic},
+ Timeout: ca.conf.Admin.Timeout,
+ }
+
+ if ca.conf.Version.IsAtLeast(V0_11_0_0) {
+ request.Version = 1
+ }
+
+ b, err := ca.Controller()
+ if err != nil {
+ return err
+ }
+
+ rsp, err := b.DeleteTopics(request)
+ if err != nil {
+ return err
+ }
+
+ topicErr, ok := rsp.TopicErrorCodes[topic]
+ if !ok {
+ return ErrIncompleteResponse
+ }
+
+ if topicErr != ErrNoError {
+ return topicErr
+ }
+ return nil
+}
+
+func (ca *clusterAdmin) CreatePartitions(topic string, count int32, assignment [][]int32, validateOnly bool) error {
+ if topic == "" {
+ return ErrInvalidTopic
+ }
+
+ topicPartitions := make(map[string]*TopicPartition)
+ topicPartitions[topic] = &TopicPartition{Count: count, Assignment: assignment}
+
+ request := &CreatePartitionsRequest{
+ TopicPartitions: topicPartitions,
+ Timeout: ca.conf.Admin.Timeout,
+ }
+
+ b, err := ca.Controller()
+ if err != nil {
+ return err
+ }
+
+ rsp, err := b.CreatePartitions(request)
+ if err != nil {
+ return err
+ }
+
+ topicErr, ok := rsp.TopicPartitionErrors[topic]
+ if !ok {
+ return ErrIncompleteResponse
+ }
+
+ if topicErr.Err != ErrNoError {
+ return topicErr.Err
+ }
+
+ return nil
+}
+
+func (ca *clusterAdmin) DeleteRecords(topic string, partitionOffsets map[int32]int64) error {
+
+ if topic == "" {
+ return ErrInvalidTopic
+ }
+
+ topics := make(map[string]*DeleteRecordsRequestTopic)
+ topics[topic] = &DeleteRecordsRequestTopic{PartitionOffsets: partitionOffsets}
+ request := &DeleteRecordsRequest{
+ Topics: topics,
+ Timeout: ca.conf.Admin.Timeout,
+ }
+
+ b, err := ca.Controller()
+ if err != nil {
+ return err
+ }
+
+ rsp, err := b.DeleteRecords(request)
+ if err != nil {
+ return err
+ }
+
+ _, ok := rsp.Topics[topic]
+ if !ok {
+ return ErrIncompleteResponse
+ }
+
+ //todo since we are dealing with couple of partitions it would be good if we return slice of errors
+ //for each partition instead of one error
+ return nil
+}
+
+func (ca *clusterAdmin) DescribeConfig(resource ConfigResource) ([]ConfigEntry, error) {
+
+ var entries []ConfigEntry
+ var resources []*ConfigResource
+ resources = append(resources, &resource)
+
+ request := &DescribeConfigsRequest{
+ Resources: resources,
+ }
+
+ b, err := ca.Controller()
+ if err != nil {
+ return nil, err
+ }
+
+ rsp, err := b.DescribeConfigs(request)
+ if err != nil {
+ return nil, err
+ }
+
+ for _, rspResource := range rsp.Resources {
+ if rspResource.Name == resource.Name {
+ if rspResource.ErrorMsg != "" {
+ return nil, errors.New(rspResource.ErrorMsg)
+ }
+ for _, cfgEntry := range rspResource.Configs {
+ entries = append(entries, *cfgEntry)
+ }
+ }
+ }
+ return entries, nil
+}
+
+func (ca *clusterAdmin) AlterConfig(resourceType ConfigResourceType, name string, entries map[string]*string, validateOnly bool) error {
+
+ var resources []*AlterConfigsResource
+ resources = append(resources, &AlterConfigsResource{
+ Type: resourceType,
+ Name: name,
+ ConfigEntries: entries,
+ })
+
+ request := &AlterConfigsRequest{
+ Resources: resources,
+ ValidateOnly: validateOnly,
+ }
+
+ b, err := ca.Controller()
+ if err != nil {
+ return err
+ }
+
+ rsp, err := b.AlterConfigs(request)
+ if err != nil {
+ return err
+ }
+
+ for _, rspResource := range rsp.Resources {
+ if rspResource.Name == name {
+ if rspResource.ErrorMsg != "" {
+ return errors.New(rspResource.ErrorMsg)
+ }
+ }
+ }
+ return nil
+}
+
+func (ca *clusterAdmin) CreateACL(resource Resource, acl Acl) error {
+ var acls []*AclCreation
+ acls = append(acls, &AclCreation{resource, acl})
+ request := &CreateAclsRequest{AclCreations: acls}
+
+ b, err := ca.Controller()
+ if err != nil {
+ return err
+ }
+
+ _, err = b.CreateAcls(request)
+ return err
+}
+
+func (ca *clusterAdmin) ListAcls(filter AclFilter) ([]ResourceAcls, error) {
+
+ request := &DescribeAclsRequest{AclFilter: filter}
+
+ b, err := ca.Controller()
+ if err != nil {
+ return nil, err
+ }
+
+ rsp, err := b.DescribeAcls(request)
+ if err != nil {
+ return nil, err
+ }
+
+ var lAcls []ResourceAcls
+ for _, rAcl := range rsp.ResourceAcls {
+ lAcls = append(lAcls, *rAcl)
+ }
+ return lAcls, nil
+}
+
+func (ca *clusterAdmin) DeleteACL(filter AclFilter, validateOnly bool) ([]MatchingAcl, error) {
+ var filters []*AclFilter
+ filters = append(filters, &filter)
+ request := &DeleteAclsRequest{Filters: filters}
+
+ b, err := ca.Controller()
+ if err != nil {
+ return nil, err
+ }
+
+ rsp, err := b.DeleteAcls(request)
+ if err != nil {
+ return nil, err
+ }
+
+ var mAcls []MatchingAcl
+ for _, fr := range rsp.FilterResponses {
+ for _, mACL := range fr.MatchingAcls {
+ mAcls = append(mAcls, *mACL)
+ }
+
+ }
+ return mAcls, nil
+}
diff --git a/vendor/github.com/Shopify/sarama/async_producer.go b/vendor/github.com/Shopify/sarama/async_producer.go
index 1eff81cbf6..8972255409 100644
--- a/vendor/github.com/Shopify/sarama/async_producer.go
+++ b/vendor/github.com/Shopify/sarama/async_producer.go
@@ -145,8 +145,9 @@ type ProducerMessage struct {
// least version 0.10.0.
Timestamp time.Time
- retries int
- flags flagSet
+ retries int
+ flags flagSet
+ expectation chan *ProducerError
}
const producerMessageOverhead = 26 // the metadata overhead of CRC, flags, etc.
@@ -270,6 +271,9 @@ func (p *asyncProducer) dispatcher() {
version := 1
if p.conf.Version.IsAtLeast(V0_11_0_0) {
version = 2
+ } else if msg.Headers != nil {
+ p.returnError(msg, ConfigurationError("Producing headers requires Kafka at least v0.11"))
+ continue
}
if msg.byteSize(version) > p.conf.Producer.MaxMessageBytes {
p.returnError(msg, ErrMessageSizeTooLarge)
@@ -343,7 +347,14 @@ func (tp *topicProducer) partitionMessage(msg *ProducerMessage) error {
var partitions []int32
err := tp.breaker.Run(func() (err error) {
- if tp.partitioner.RequiresConsistency() {
+ var requiresConsistency = false
+ if ep, ok := tp.partitioner.(DynamicConsistencyPartitioner); ok {
+ requiresConsistency = ep.MessageRequiresConsistency(msg)
+ } else {
+ requiresConsistency = tp.partitioner.RequiresConsistency()
+ }
+
+ if requiresConsistency {
partitions, err = tp.parent.client.Partitions(msg.Topic)
} else {
partitions, err = tp.parent.client.WritablePartitions(msg.Topic)
diff --git a/vendor/github.com/Shopify/sarama/balance_strategy.go b/vendor/github.com/Shopify/sarama/balance_strategy.go
new file mode 100644
index 0000000000..e78988d718
--- /dev/null
+++ b/vendor/github.com/Shopify/sarama/balance_strategy.go
@@ -0,0 +1,129 @@
+package sarama
+
+import (
+ "math"
+ "sort"
+)
+
+// BalanceStrategyPlan is the results of any BalanceStrategy.Plan attempt.
+// It contains an allocation of topic/partitions by memberID in the form of
+// a `memberID -> topic -> partitions` map.
+type BalanceStrategyPlan map[string]map[string][]int32
+
+// Add assigns a topic with a number partitions to a member.
+func (p BalanceStrategyPlan) Add(memberID, topic string, partitions ...int32) {
+ if len(partitions) == 0 {
+ return
+ }
+ if _, ok := p[memberID]; !ok {
+ p[memberID] = make(map[string][]int32, 1)
+ }
+ p[memberID][topic] = append(p[memberID][topic], partitions...)
+}
+
+// --------------------------------------------------------------------
+
+// BalanceStrategy is used to balance topics and partitions
+// across memebers of a consumer group
+type BalanceStrategy interface {
+ // Name uniquely identifies the strategy.
+ Name() string
+
+ // Plan accepts a map of `memberID -> metadata` and a map of `topic -> partitions`
+ // and returns a distribution plan.
+ Plan(members map[string]ConsumerGroupMemberMetadata, topics map[string][]int32) (BalanceStrategyPlan, error)
+}
+
+// --------------------------------------------------------------------
+
+// BalanceStrategyRange is the default and assigns partitions as ranges to consumer group members.
+// Example with one topic T with six partitions (0..5) and two members (M1, M2):
+// M1: {T: [0, 1, 2]}
+// M2: {T: [3, 4, 5]}
+var BalanceStrategyRange = &balanceStrategy{
+ name: "range",
+ coreFn: func(plan BalanceStrategyPlan, memberIDs []string, topic string, partitions []int32) {
+ step := float64(len(partitions)) / float64(len(memberIDs))
+
+ for i, memberID := range memberIDs {
+ pos := float64(i)
+ min := int(math.Floor(pos*step + 0.5))
+ max := int(math.Floor((pos+1)*step + 0.5))
+ plan.Add(memberID, topic, partitions[min:max]...)
+ }
+ },
+}
+
+// BalanceStrategyRoundRobin assigns partitions to members in alternating order.
+// Example with topic T with six partitions (0..5) and two members (M1, M2):
+// M1: {T: [0, 2, 4]}
+// M2: {T: [1, 3, 5]}
+var BalanceStrategyRoundRobin = &balanceStrategy{
+ name: "roundrobin",
+ coreFn: func(plan BalanceStrategyPlan, memberIDs []string, topic string, partitions []int32) {
+ for i, part := range partitions {
+ memberID := memberIDs[i%len(memberIDs)]
+ plan.Add(memberID, topic, part)
+ }
+ },
+}
+
+// --------------------------------------------------------------------
+
+type balanceStrategy struct {
+ name string
+ coreFn func(plan BalanceStrategyPlan, memberIDs []string, topic string, partitions []int32)
+}
+
+// Name implements BalanceStrategy.
+func (s *balanceStrategy) Name() string { return s.name }
+
+// Balance implements BalanceStrategy.
+func (s *balanceStrategy) Plan(members map[string]ConsumerGroupMemberMetadata, topics map[string][]int32) (BalanceStrategyPlan, error) {
+ // Build members by topic map
+ mbt := make(map[string][]string)
+ for memberID, meta := range members {
+ for _, topic := range meta.Topics {
+ mbt[topic] = append(mbt[topic], memberID)
+ }
+ }
+
+ // Sort members for each topic
+ for topic, memberIDs := range mbt {
+ sort.Sort(&balanceStrategySortable{
+ topic: topic,
+ memberIDs: memberIDs,
+ })
+ }
+
+ // Assemble plan
+ plan := make(BalanceStrategyPlan, len(members))
+ for topic, memberIDs := range mbt {
+ s.coreFn(plan, memberIDs, topic, topics[topic])
+ }
+ return plan, nil
+}
+
+type balanceStrategySortable struct {
+ topic string
+ memberIDs []string
+}
+
+func (p balanceStrategySortable) Len() int { return len(p.memberIDs) }
+func (p balanceStrategySortable) Swap(i, j int) {
+ p.memberIDs[i], p.memberIDs[j] = p.memberIDs[j], p.memberIDs[i]
+}
+func (p balanceStrategySortable) Less(i, j int) bool {
+ return balanceStrategyHashValue(p.topic, p.memberIDs[i]) < balanceStrategyHashValue(p.topic, p.memberIDs[j])
+}
+
+func balanceStrategyHashValue(vv ...string) uint32 {
+ h := uint32(2166136261)
+ for _, s := range vv {
+ for _, c := range s {
+ h ^= uint32(c)
+ h *= 16777619
+ }
+ }
+ return h
+}
diff --git a/vendor/github.com/Shopify/sarama/broker.go b/vendor/github.com/Shopify/sarama/broker.go
index d836bee6d8..26f63d51d6 100644
--- a/vendor/github.com/Shopify/sarama/broker.go
+++ b/vendor/github.com/Shopify/sarama/broker.go
@@ -86,6 +86,7 @@ func (b *Broker) Open(conf *Config) error {
dialer := net.Dialer{
Timeout: conf.Net.DialTimeout,
KeepAlive: conf.Net.KeepAlive,
+ LocalAddr: conf.Net.LocalAddr,
}
if conf.Net.TLS.Enable {
@@ -386,17 +387,6 @@ func (b *Broker) ApiVersions(request *ApiVersionsRequest) (*ApiVersionsResponse,
return response, nil
}
-func (b *Broker) CreatePartitions(request *CreatePartitionsRequest) (*CreatePartitionsResponse, error) {
- response := new(CreatePartitionsResponse)
-
- err := b.sendAndReceive(request, response)
- if err != nil {
- return nil, err
- }
-
- return response, nil
-}
-
func (b *Broker) CreateTopics(request *CreateTopicsRequest) (*CreateTopicsResponse, error) {
response := new(CreateTopicsResponse)
@@ -419,6 +409,17 @@ func (b *Broker) DeleteTopics(request *DeleteTopicsRequest) (*DeleteTopicsRespon
return response, nil
}
+func (b *Broker) CreatePartitions(request *CreatePartitionsRequest) (*CreatePartitionsResponse, error) {
+ response := new(CreatePartitionsResponse)
+
+ err := b.sendAndReceive(request, response)
+ if err != nil {
+ return nil, err
+ }
+
+ return response, nil
+}
+
func (b *Broker) DeleteRecords(request *DeleteRecordsRequest) (*DeleteRecordsResponse, error) {
response := new(DeleteRecordsResponse)
diff --git a/vendor/github.com/Shopify/sarama/client.go b/vendor/github.com/Shopify/sarama/client.go
index 019cb43735..ad805346b4 100644
--- a/vendor/github.com/Shopify/sarama/client.go
+++ b/vendor/github.com/Shopify/sarama/client.go
@@ -17,7 +17,7 @@ type Client interface {
// altered after it has been created.
Config() *Config
- // Controller returns the cluster controller broker.
+ // Controller returns the cluster controller broker. Requires Kafka 0.10 or higher.
Controller() (*Broker, error)
// Brokers returns the current set of active brokers as retrieved from cluster metadata.
@@ -100,10 +100,11 @@ type client struct {
seedBrokers []*Broker
deadSeeds []*Broker
- controllerID int32 // cluster controller broker id
- brokers map[int32]*Broker // maps broker ids to brokers
- metadata map[string]map[int32]*PartitionMetadata // maps topics to partition ids to metadata
- coordinators map[string]int32 // Maps consumer group names to coordinating broker IDs
+ controllerID int32 // cluster controller broker id
+ brokers map[int32]*Broker // maps broker ids to brokers
+ metadata map[string]map[int32]*PartitionMetadata // maps topics to partition ids to metadata
+ metadataTopics map[string]none // topics that need to collect metadata
+ coordinators map[string]int32 // Maps consumer group names to coordinating broker IDs
// If the number of partitions is large, we can get some churn calling cachedPartitions,
// so the result is cached. It is important to update this value whenever metadata is changed
@@ -136,6 +137,7 @@ func NewClient(addrs []string, conf *Config) (Client, error) {
closed: make(chan none),
brokers: make(map[int32]*Broker),
metadata: make(map[string]map[int32]*PartitionMetadata),
+ metadataTopics: make(map[string]none),
cachedPartitionsResults: make(map[string][maxPartitionIndex][]int32),
coordinators: make(map[string]int32),
}
@@ -207,6 +209,7 @@ func (client *client) Close() error {
client.brokers = nil
client.metadata = nil
+ client.metadataTopics = nil
return nil
}
@@ -231,6 +234,22 @@ func (client *client) Topics() ([]string, error) {
return ret, nil
}
+func (client *client) MetadataTopics() ([]string, error) {
+ if client.Closed() {
+ return nil, ErrClosedClient
+ }
+
+ client.lock.RLock()
+ defer client.lock.RUnlock()
+
+ ret := make([]string, 0, len(client.metadataTopics))
+ for topic := range client.metadataTopics {
+ ret = append(ret, topic)
+ }
+
+ return ret, nil
+}
+
func (client *client) Partitions(topic string) ([]int32, error) {
if client.Closed() {
return nil, ErrClosedClient
@@ -388,6 +407,10 @@ func (client *client) Controller() (*Broker, error) {
return nil, ErrClosedClient
}
+ if !client.conf.Version.IsAtLeast(V0_10_0_0) {
+ return nil, ErrUnsupportedVersion
+ }
+
controller := client.cachedController()
if controller == nil {
if err := client.refreshMetadata(); err != nil {
@@ -645,7 +668,7 @@ func (client *client) refreshMetadata() error {
topics := []string{}
if !client.conf.Metadata.Full {
- if specificTopics, err := client.Topics(); err != nil {
+ if specificTopics, err := client.MetadataTopics(); err != nil {
return err
} else if len(specificTopics) == 0 {
return ErrNoTopicsToUpdateMetadata
@@ -728,9 +751,16 @@ func (client *client) updateMetadata(data *MetadataResponse, allKnownMetaData bo
if allKnownMetaData {
client.metadata = make(map[string]map[int32]*PartitionMetadata)
+ client.metadataTopics = make(map[string]none)
client.cachedPartitionsResults = make(map[string][maxPartitionIndex][]int32)
}
for _, topic := range data.Topics {
+ // topics must be added firstly to `metadataTopics` to guarantee that all
+ // requested topics must be recorded to keep them trackable for periodically
+ // metadata refresh.
+ if _, exists := client.metadataTopics[topic.Name]; !exists {
+ client.metadataTopics[topic.Name] = none{}
+ }
delete(client.metadata, topic.Name)
delete(client.cachedPartitionsResults, topic.Name)
diff --git a/vendor/github.com/Shopify/sarama/config.go b/vendor/github.com/Shopify/sarama/config.go
index a564b5c23e..faf11e8383 100644
--- a/vendor/github.com/Shopify/sarama/config.go
+++ b/vendor/github.com/Shopify/sarama/config.go
@@ -5,6 +5,7 @@ import (
"crypto/tls"
"fmt"
"io/ioutil"
+ "net"
"regexp"
"time"
@@ -17,6 +18,13 @@ var validID = regexp.MustCompile(`\A[A-Za-z0-9._-]+\z`)
// Config is used to pass multiple configuration options to Sarama's constructors.
type Config struct {
+ // Admin is the namespace for ClusterAdmin properties used by the administrative Kafka client.
+ Admin struct {
+ // The maximum duration the administrative Kafka client will wait for ClusterAdmin operations,
+ // including topics, brokers, configurations and ACLs (defaults to 3 seconds).
+ Timeout time.Duration
+ }
+
// Net is the namespace for network-level properties used by the Broker, and
// shared by the Client/Producer/Consumer.
Net struct {
@@ -58,6 +66,12 @@ type Config struct {
// KeepAlive specifies the keep-alive period for an active network connection.
// If zero, keep-alives are disabled. (default is 0: disabled).
KeepAlive time.Duration
+
+ // LocalAddr is the local address to use when dialing an
+ // address. The address must be of a compatible type for the
+ // network being dialed.
+ // If nil, a local address is automatically chosen.
+ LocalAddr net.Addr
}
// Metadata is the namespace for metadata management properties used by the
@@ -159,14 +173,55 @@ type Config struct {
// Consumer is the namespace for configuration related to consuming messages,
// used by the Consumer.
- //
- // Note that Sarama's Consumer type does not currently support automatic
- // consumer-group rebalancing and offset tracking. For Zookeeper-based
- // tracking (Kafka 0.8.2 and earlier), the https://github.com/wvanbergen/kafka
- // library builds on Sarama to add this support. For Kafka-based tracking
- // (Kafka 0.9 and later), the https://github.com/bsm/sarama-cluster library
- // builds on Sarama to add this support.
Consumer struct {
+
+ // Group is the namespace for configuring consumer group.
+ Group struct {
+ Session struct {
+ // The timeout used to detect consumer failures when using Kafka's group management facility.
+ // The consumer sends periodic heartbeats to indicate its liveness to the broker.
+ // If no heartbeats are received by the broker before the expiration of this session timeout,
+ // then the broker will remove this consumer from the group and initiate a rebalance.
+ // Note that the value must be in the allowable range as configured in the broker configuration
+ // by `group.min.session.timeout.ms` and `group.max.session.timeout.ms` (default 10s)
+ Timeout time.Duration
+ }
+ Heartbeat struct {
+ // The expected time between heartbeats to the consumer coordinator when using Kafka's group
+ // management facilities. Heartbeats are used to ensure that the consumer's session stays active and
+ // to facilitate rebalancing when new consumers join or leave the group.
+ // The value must be set lower than Consumer.Group.Session.Timeout, but typically should be set no
+ // higher than 1/3 of that value.
+ // It can be adjusted even lower to control the expected time for normal rebalances (default 3s)
+ Interval time.Duration
+ }
+ Rebalance struct {
+ // Strategy for allocating topic partitions to members (default BalanceStrategyRange)
+ Strategy BalanceStrategy
+ // The maximum allowed time for each worker to join the group once a rebalance has begun.
+ // This is basically a limit on the amount of time needed for all tasks to flush any pending
+ // data and commit offsets. If the timeout is exceeded, then the worker will be removed from
+ // the group, which will cause offset commit failures (default 60s).
+ Timeout time.Duration
+
+ Retry struct {
+ // When a new consumer joins a consumer group the set of consumers attempt to "rebalance"
+ // the load to assign partitions to each consumer. If the set of consumers changes while
+ // this assignment is taking place the rebalance will fail and retry. This setting controls
+ // the maximum number of attempts before giving up (default 4).
+ Max int
+ // Backoff time between retries during rebalance (default 2s)
+ Backoff time.Duration
+ }
+ }
+ Member struct {
+ // Custom metadata to include when joining the group. The user data for all joined members
+ // can be retrieved by sending a DescribeGroupRequest to the broker that is the
+ // coordinator for the group.
+ UserData []byte
+ }
+ }
+
Retry struct {
// How long to wait after a failing to read from a partition before
// trying again (default 2s).
@@ -248,6 +303,12 @@ type Config struct {
// broker version 0.9.0 or later.
// (default is 0: disabled).
Retention time.Duration
+
+ Retry struct {
+ // The total number of times to retry failing commit
+ // requests during OffsetManager shutdown (default 3).
+ Max int
+ }
}
}
@@ -279,6 +340,8 @@ type Config struct {
func NewConfig() *Config {
c := &Config{}
+ c.Admin.Timeout = 3 * time.Second
+
c.Net.MaxOpenRequests = 5
c.Net.DialTimeout = 30 * time.Second
c.Net.ReadTimeout = 30 * time.Second
@@ -307,6 +370,14 @@ func NewConfig() *Config {
c.Consumer.Return.Errors = false
c.Consumer.Offsets.CommitInterval = 1 * time.Second
c.Consumer.Offsets.Initial = OffsetNewest
+ c.Consumer.Offsets.Retry.Max = 3
+
+ c.Consumer.Group.Session.Timeout = 10 * time.Second
+ c.Consumer.Group.Heartbeat.Interval = 3 * time.Second
+ c.Consumer.Group.Rebalance.Strategy = BalanceStrategyRange
+ c.Consumer.Group.Rebalance.Timeout = 60 * time.Second
+ c.Consumer.Group.Rebalance.Retry.Max = 4
+ c.Consumer.Group.Rebalance.Retry.Backoff = 2 * time.Second
c.ClientID = defaultClientID
c.ChannelBufferSize = 256
@@ -355,6 +426,15 @@ func (c *Config) Validate() error {
if c.Consumer.Offsets.Retention%time.Millisecond != 0 {
Logger.Println("Consumer.Offsets.Retention only supports millisecond precision; nanoseconds will be truncated.")
}
+ if c.Consumer.Group.Session.Timeout%time.Millisecond != 0 {
+ Logger.Println("Consumer.Group.Session.Timeout only supports millisecond precision; nanoseconds will be truncated.")
+ }
+ if c.Consumer.Group.Heartbeat.Interval%time.Millisecond != 0 {
+ Logger.Println("Consumer.Group.Heartbeat.Interval only supports millisecond precision; nanoseconds will be truncated.")
+ }
+ if c.Consumer.Group.Rebalance.Timeout%time.Millisecond != 0 {
+ Logger.Println("Consumer.Group.Rebalance.Timeout only supports millisecond precision; nanoseconds will be truncated.")
+ }
if c.ClientID == defaultClientID {
Logger.Println("ClientID is the default of 'sarama', you should consider setting it to something application-specific.")
}
@@ -377,6 +457,12 @@ func (c *Config) Validate() error {
return ConfigurationError("Net.SASL.Password must not be empty when SASL is enabled")
}
+ // validate the Admin values
+ switch {
+ case c.Admin.Timeout <= 0:
+ return ConfigurationError("Admin.Timeout must be > 0")
+ }
+
// validate the Metadata values
switch {
case c.Metadata.Retry.Max < 0:
@@ -443,7 +529,26 @@ func (c *Config) Validate() error {
return ConfigurationError("Consumer.Offsets.CommitInterval must be > 0")
case c.Consumer.Offsets.Initial != OffsetOldest && c.Consumer.Offsets.Initial != OffsetNewest:
return ConfigurationError("Consumer.Offsets.Initial must be OffsetOldest or OffsetNewest")
+ case c.Consumer.Offsets.Retry.Max < 0:
+ return ConfigurationError("Consumer.Offsets.Retry.Max must be >= 0")
+ }
+ // validate the Consumer Group values
+ switch {
+ case c.Consumer.Group.Session.Timeout <= 2*time.Millisecond:
+ return ConfigurationError("Consumer.Group.Session.Timeout must be >= 2ms")
+ case c.Consumer.Group.Heartbeat.Interval < 1*time.Millisecond:
+ return ConfigurationError("Consumer.Group.Heartbeat.Interval must be >= 1ms")
+ case c.Consumer.Group.Heartbeat.Interval >= c.Consumer.Group.Session.Timeout:
+ return ConfigurationError("Consumer.Group.Heartbeat.Interval must be < Consumer.Group.Session.Timeout")
+ case c.Consumer.Group.Rebalance.Strategy == nil:
+ return ConfigurationError("Consumer.Group.Rebalance.Strategy must not be empty")
+ case c.Consumer.Group.Rebalance.Timeout <= time.Millisecond:
+ return ConfigurationError("Consumer.Group.Rebalance.Timeout must be >= 1ms")
+ case c.Consumer.Group.Rebalance.Retry.Max < 0:
+ return ConfigurationError("Consumer.Group.Rebalance.Retry.Max must be >= 0")
+ case c.Consumer.Group.Rebalance.Retry.Backoff < 0:
+ return ConfigurationError("Consumer.Group.Rebalance.Retry.Backoff must be >= 0")
}
// validate misc shared values
diff --git a/vendor/github.com/Shopify/sarama/consumer.go b/vendor/github.com/Shopify/sarama/consumer.go
index 96226ac5bf..33d9d143f9 100644
--- a/vendor/github.com/Shopify/sarama/consumer.go
+++ b/vendor/github.com/Shopify/sarama/consumer.go
@@ -531,7 +531,7 @@ func (child *partitionConsumer) parseRecords(batch *RecordBatch) ([]*ConsumerMes
child.offset = offset + 1
}
if len(messages) == 0 {
- return nil, ErrIncompleteResponse
+ child.offset += 1
}
return messages, nil
}
@@ -579,10 +579,6 @@ func (child *partitionConsumer) parseResponse(response *FetchResponse) ([]*Consu
messages := []*ConsumerMessage{}
for _, records := range block.RecordsSet {
- if control, err := records.isControl(); err != nil || control {
- continue
- }
-
switch records.recordsType {
case legacyRecords:
messageSetMessages, err := child.parseMessages(records.MsgSet)
@@ -596,6 +592,9 @@ func (child *partitionConsumer) parseResponse(response *FetchResponse) ([]*Consu
if err != nil {
return nil, err
}
+ if control, err := records.isControl(); err != nil || control {
+ continue
+ }
messages = append(messages, recordBatchMessages...)
default:
diff --git a/vendor/github.com/Shopify/sarama/consumer_group.go b/vendor/github.com/Shopify/sarama/consumer_group.go
new file mode 100644
index 0000000000..33a231477f
--- /dev/null
+++ b/vendor/github.com/Shopify/sarama/consumer_group.go
@@ -0,0 +1,774 @@
+package sarama
+
+import (
+ "context"
+ "errors"
+ "fmt"
+ "sort"
+ "sync"
+ "time"
+)
+
+// ErrClosedConsumerGroup is the error returned when a method is called on a consumer group that has been closed.
+var ErrClosedConsumerGroup = errors.New("kafka: tried to use a consumer group that was closed")
+
+// ConsumerGroup is responsible for dividing up processing of topics and partitions
+// over a collection of processes (the members of the consumer group).
+type ConsumerGroup interface {
+ // Consume joins a cluster of consumers for a given list of topics and
+ // starts a blocking ConsumerGroupSession through the ConsumerGroupHandler.
+ //
+ // The life-cycle of a session is represented by the following steps:
+ //
+ // 1. The consumers join the group (as explained in https://kafka.apache.org/documentation/#intro_consumers)
+ // and is assigned their "fair share" of partitions, aka 'claims'.
+ // 2. Before processing starts, the handler's Setup() hook is called to notify the user
+ // of the claims and allow any necessary preparation or alteration of state.
+ // 3. For each of the assigned claims the handler's ConsumeClaim() function is then called
+ // in a separate goroutine which requires it to be thread-safe. Any state must be carefully protected
+ // from concurrent reads/writes.
+ // 4. The session will persist until one of the ConsumeClaim() functions exits. This can be either when the
+ // parent context is cancelled or when a server-side rebalance cycle is initiated.
+ // 5. Once all the ConsumeClaim() loops have exited, the handler's Cleanup() hook is called
+ // to allow the user to perform any final tasks before a rebalance.
+ // 6. Finally, marked offsets are committed one last time before claims are released.
+ //
+ // Please note, that once a relance is triggered, sessions must be completed within
+ // Config.Consumer.Group.Rebalance.Timeout. This means that ConsumeClaim() functions must exit
+ // as quickly as possible to allow time for Cleanup() and the final offset commit. If the timeout
+ // is exceeded, the consumer will be removed from the group by Kafka, which will cause offset
+ // commit failures.
+ Consume(ctx context.Context, topics []string, handler ConsumerGroupHandler) error
+
+ // Errors returns a read channel of errors that occurred during the consumer life-cycle.
+ // By default, errors are logged and not returned over this channel.
+ // If you want to implement any custom error handling, set your config's
+ // Consumer.Return.Errors setting to true, and read from this channel.
+ Errors() <-chan error
+
+ // Close stops the ConsumerGroup and detaches any running sessions. It is required to call
+ // this function before the object passes out of scope, as it will otherwise leak memory.
+ Close() error
+}
+
+type consumerGroup struct {
+ client Client
+ ownClient bool
+
+ config *Config
+ consumer Consumer
+ groupID string
+ memberID string
+ errors chan error
+
+ lock sync.Mutex
+ closed chan none
+ closeOnce sync.Once
+}
+
+// NewConsumerGroup creates a new consumer group the given broker addresses and configuration.
+func NewConsumerGroup(addrs []string, groupID string, config *Config) (ConsumerGroup, error) {
+ client, err := NewClient(addrs, config)
+ if err != nil {
+ return nil, err
+ }
+
+ c, err := NewConsumerGroupFromClient(groupID, client)
+ if err != nil {
+ _ = client.Close()
+ return nil, err
+ }
+
+ c.(*consumerGroup).ownClient = true
+ return c, nil
+}
+
+// NewConsumerFromClient creates a new consumer group using the given client. It is still
+// necessary to call Close() on the underlying client when shutting down this consumer.
+// PLEASE NOTE: consumer groups can only re-use but not share clients.
+func NewConsumerGroupFromClient(groupID string, client Client) (ConsumerGroup, error) {
+ config := client.Config()
+ if !config.Version.IsAtLeast(V0_10_2_0) {
+ return nil, ConfigurationError("consumer groups require Version to be >= V0_10_2_0")
+ }
+
+ consumer, err := NewConsumerFromClient(client)
+ if err != nil {
+ return nil, err
+ }
+
+ return &consumerGroup{
+ client: client,
+ consumer: consumer,
+ config: config,
+ groupID: groupID,
+ errors: make(chan error, config.ChannelBufferSize),
+ closed: make(chan none),
+ }, nil
+}
+
+// Errors implements ConsumerGroup.
+func (c *consumerGroup) Errors() <-chan error { return c.errors }
+
+// Close implements ConsumerGroup.
+func (c *consumerGroup) Close() (err error) {
+ c.closeOnce.Do(func() {
+ close(c.closed)
+
+ c.lock.Lock()
+ defer c.lock.Unlock()
+
+ // leave group
+ if e := c.leave(); e != nil {
+ err = e
+ }
+
+ // drain errors
+ go func() {
+ close(c.errors)
+ }()
+ for e := range c.errors {
+ err = e
+ }
+
+ if c.ownClient {
+ if e := c.client.Close(); e != nil {
+ err = e
+ }
+ }
+ })
+ return
+}
+
+// Consume implements ConsumerGroup.
+func (c *consumerGroup) Consume(ctx context.Context, topics []string, handler ConsumerGroupHandler) error {
+ // Ensure group is not closed
+ select {
+ case <-c.closed:
+ return ErrClosedConsumerGroup
+ default:
+ }
+
+ c.lock.Lock()
+ defer c.lock.Unlock()
+
+ // Quick exit when no topics are provided
+ if len(topics) == 0 {
+ return fmt.Errorf("no topics provided")
+ }
+
+ // Refresh metadata for requested topics
+ if err := c.client.RefreshMetadata(topics...); err != nil {
+ return err
+ }
+
+ // Get coordinator
+ coordinator, err := c.client.Coordinator(c.groupID)
+ if err != nil {
+ return err
+ }
+
+ // Init session
+ sess, err := c.newSession(ctx, coordinator, topics, handler, c.config.Consumer.Group.Rebalance.Retry.Max)
+ if err == ErrClosedClient {
+ return ErrClosedConsumerGroup
+ } else if err != nil {
+ return err
+ }
+
+ // Wait for session exit signal
+ <-sess.ctx.Done()
+
+ // Gracefully release session claims
+ return sess.release(true)
+}
+
+func (c *consumerGroup) newSession(ctx context.Context, coordinator *Broker, topics []string, handler ConsumerGroupHandler, retries int) (*consumerGroupSession, error) {
+ // Join consumer group
+ join, err := c.joinGroupRequest(coordinator, topics)
+ if err != nil {
+ _ = coordinator.Close()
+ return nil, err
+ }
+ switch join.Err {
+ case ErrNoError:
+ c.memberID = join.MemberId
+ case ErrUnknownMemberId, ErrIllegalGeneration: // reset member ID and retry immediately
+ c.memberID = ""
+ return c.newSession(ctx, coordinator, topics, handler, retries)
+ case ErrRebalanceInProgress: // retry after backoff
+ if retries <= 0 {
+ return nil, join.Err
+ }
+
+ select {
+ case <-c.closed:
+ return nil, ErrClosedConsumerGroup
+ case <-time.After(c.config.Consumer.Group.Rebalance.Retry.Backoff):
+ }
+
+ return c.newSession(ctx, coordinator, topics, handler, retries-1)
+ default:
+ return nil, join.Err
+ }
+
+ // Prepare distribution plan if we joined as the leader
+ var plan BalanceStrategyPlan
+ if join.LeaderId == join.MemberId {
+ members, err := join.GetMembers()
+ if err != nil {
+ return nil, err
+ }
+
+ plan, err = c.balance(members)
+ if err != nil {
+ return nil, err
+ }
+ }
+
+ // Sync consumer group
+ sync, err := c.syncGroupRequest(coordinator, plan, join.GenerationId)
+ if err != nil {
+ _ = coordinator.Close()
+ return nil, err
+ }
+ switch sync.Err {
+ case ErrNoError:
+ case ErrUnknownMemberId, ErrIllegalGeneration: // reset member ID and retry immediately
+ c.memberID = ""
+ return c.newSession(ctx, coordinator, topics, handler, retries)
+ case ErrRebalanceInProgress: // retry after backoff
+ if retries <= 0 {
+ return nil, sync.Err
+ }
+
+ select {
+ case <-c.closed:
+ return nil, ErrClosedConsumerGroup
+ case <-time.After(c.config.Consumer.Group.Rebalance.Retry.Backoff):
+ }
+
+ return c.newSession(ctx, coordinator, topics, handler, retries-1)
+ default:
+ return nil, sync.Err
+ }
+
+ // Retrieve and sort claims
+ var claims map[string][]int32
+ if len(sync.MemberAssignment) > 0 {
+ members, err := sync.GetMemberAssignment()
+ if err != nil {
+ return nil, err
+ }
+ claims = members.Topics
+
+ for _, partitions := range claims {
+ sort.Sort(int32Slice(partitions))
+ }
+ }
+
+ return newConsumerGroupSession(c, ctx, claims, join.MemberId, join.GenerationId, handler)
+}
+
+func (c *consumerGroup) joinGroupRequest(coordinator *Broker, topics []string) (*JoinGroupResponse, error) {
+ req := &JoinGroupRequest{
+ GroupId: c.groupID,
+ MemberId: c.memberID,
+ SessionTimeout: int32(c.config.Consumer.Group.Session.Timeout / time.Millisecond),
+ ProtocolType: "consumer",
+ }
+ if c.config.Version.IsAtLeast(V0_10_1_0) {
+ req.Version = 1
+ req.RebalanceTimeout = int32(c.config.Consumer.Group.Rebalance.Timeout / time.Millisecond)
+ }
+
+ meta := &ConsumerGroupMemberMetadata{
+ Topics: topics,
+ UserData: c.config.Consumer.Group.Member.UserData,
+ }
+ strategy := c.config.Consumer.Group.Rebalance.Strategy
+ if err := req.AddGroupProtocolMetadata(strategy.Name(), meta); err != nil {
+ return nil, err
+ }
+
+ return coordinator.JoinGroup(req)
+}
+
+func (c *consumerGroup) syncGroupRequest(coordinator *Broker, plan BalanceStrategyPlan, generationID int32) (*SyncGroupResponse, error) {
+ req := &SyncGroupRequest{
+ GroupId: c.groupID,
+ MemberId: c.memberID,
+ GenerationId: generationID,
+ }
+ for memberID, topics := range plan {
+ err := req.AddGroupAssignmentMember(memberID, &ConsumerGroupMemberAssignment{
+ Topics: topics,
+ })
+ if err != nil {
+ return nil, err
+ }
+ }
+ return coordinator.SyncGroup(req)
+}
+
+func (c *consumerGroup) heartbeatRequest(coordinator *Broker, memberID string, generationID int32) (*HeartbeatResponse, error) {
+ req := &HeartbeatRequest{
+ GroupId: c.groupID,
+ MemberId: memberID,
+ GenerationId: generationID,
+ }
+
+ return coordinator.Heartbeat(req)
+}
+
+func (c *consumerGroup) balance(members map[string]ConsumerGroupMemberMetadata) (BalanceStrategyPlan, error) {
+ topics := make(map[string][]int32)
+ for _, meta := range members {
+ for _, topic := range meta.Topics {
+ topics[topic] = nil
+ }
+ }
+
+ for topic := range topics {
+ partitions, err := c.client.Partitions(topic)
+ if err != nil {
+ return nil, err
+ }
+ topics[topic] = partitions
+ }
+
+ strategy := c.config.Consumer.Group.Rebalance.Strategy
+ return strategy.Plan(members, topics)
+}
+
+// Leaves the cluster, called by Close, protected by lock.
+func (c *consumerGroup) leave() error {
+ if c.memberID == "" {
+ return nil
+ }
+
+ coordinator, err := c.client.Coordinator(c.groupID)
+ if err != nil {
+ return err
+ }
+
+ resp, err := coordinator.LeaveGroup(&LeaveGroupRequest{
+ GroupId: c.groupID,
+ MemberId: c.memberID,
+ })
+ if err != nil {
+ _ = coordinator.Close()
+ return err
+ }
+
+ // Unset memberID
+ c.memberID = ""
+
+ // Check response
+ switch resp.Err {
+ case ErrRebalanceInProgress, ErrUnknownMemberId, ErrNoError:
+ return nil
+ default:
+ return resp.Err
+ }
+}
+
+func (c *consumerGroup) handleError(err error, topic string, partition int32) {
+ select {
+ case <-c.closed:
+ return
+ default:
+ }
+
+ if _, ok := err.(*ConsumerError); !ok && topic != "" && partition > -1 {
+ err = &ConsumerError{
+ Topic: topic,
+ Partition: partition,
+ Err: err,
+ }
+ }
+
+ if c.config.Consumer.Return.Errors {
+ select {
+ case c.errors <- err:
+ default:
+ }
+ } else {
+ Logger.Println(err)
+ }
+}
+
+// --------------------------------------------------------------------
+
+// ConsumerGroupSession represents a consumer group member session.
+type ConsumerGroupSession interface {
+ // Claims returns information about the claimed partitions by topic.
+ Claims() map[string][]int32
+
+ // MemberID returns the cluster member ID.
+ MemberID() string
+
+ // GenerationID returns the current generation ID.
+ GenerationID() int32
+
+ // MarkOffset marks the provided offset, alongside a metadata string
+ // that represents the state of the partition consumer at that point in time. The
+ // metadata string can be used by another consumer to restore that state, so it
+ // can resume consumption.
+ //
+ // To follow upstream conventions, you are expected to mark the offset of the
+ // next message to read, not the last message read. Thus, when calling `MarkOffset`
+ // you should typically add one to the offset of the last consumed message.
+ //
+ // Note: calling MarkOffset does not necessarily commit the offset to the backend
+ // store immediately for efficiency reasons, and it may never be committed if
+ // your application crashes. This means that you may end up processing the same
+ // message twice, and your processing should ideally be idempotent.
+ MarkOffset(topic string, partition int32, offset int64, metadata string)
+
+ // ResetOffset resets to the provided offset, alongside a metadata string that
+ // represents the state of the partition consumer at that point in time. Reset
+ // acts as a counterpart to MarkOffset, the difference being that it allows to
+ // reset an offset to an earlier or smaller value, where MarkOffset only
+ // allows incrementing the offset. cf MarkOffset for more details.
+ ResetOffset(topic string, partition int32, offset int64, metadata string)
+
+ // MarkMessage marks a message as consumed.
+ MarkMessage(msg *ConsumerMessage, metadata string)
+
+ // Context returns the session context.
+ Context() context.Context
+}
+
+type consumerGroupSession struct {
+ parent *consumerGroup
+ memberID string
+ generationID int32
+ handler ConsumerGroupHandler
+
+ claims map[string][]int32
+ offsets *offsetManager
+ ctx context.Context
+ cancel func()
+
+ waitGroup sync.WaitGroup
+ releaseOnce sync.Once
+ hbDying, hbDead chan none
+}
+
+func newConsumerGroupSession(parent *consumerGroup, ctx context.Context, claims map[string][]int32, memberID string, generationID int32, handler ConsumerGroupHandler) (*consumerGroupSession, error) {
+ // init offset manager
+ offsets, err := newOffsetManagerFromClient(parent.groupID, memberID, generationID, parent.client)
+ if err != nil {
+ return nil, err
+ }
+
+ // init context
+ ctx, cancel := context.WithCancel(ctx)
+
+ // init session
+ sess := &consumerGroupSession{
+ parent: parent,
+ memberID: memberID,
+ generationID: generationID,
+ handler: handler,
+ offsets: offsets,
+ claims: claims,
+ ctx: ctx,
+ cancel: cancel,
+ hbDying: make(chan none),
+ hbDead: make(chan none),
+ }
+
+ // start heartbeat loop
+ go sess.heartbeatLoop()
+
+ // create a POM for each claim
+ for topic, partitions := range claims {
+ for _, partition := range partitions {
+ pom, err := offsets.ManagePartition(topic, partition)
+ if err != nil {
+ _ = sess.release(false)
+ return nil, err
+ }
+
+ // handle POM errors
+ go func(topic string, partition int32) {
+ for err := range pom.Errors() {
+ sess.parent.handleError(err, topic, partition)
+ }
+ }(topic, partition)
+ }
+ }
+
+ // perform setup
+ if err := handler.Setup(sess); err != nil {
+ _ = sess.release(true)
+ return nil, err
+ }
+
+ // start consuming
+ for topic, partitions := range claims {
+ for _, partition := range partitions {
+ sess.waitGroup.Add(1)
+
+ go func(topic string, partition int32) {
+ defer sess.waitGroup.Done()
+
+ // cancel the as session as soon as the first
+ // goroutine exits
+ defer sess.cancel()
+
+ // consume a single topic/partition, blocking
+ sess.consume(topic, partition)
+ }(topic, partition)
+ }
+ }
+ return sess, nil
+}
+
+func (s *consumerGroupSession) Claims() map[string][]int32 { return s.claims }
+func (s *consumerGroupSession) MemberID() string { return s.memberID }
+func (s *consumerGroupSession) GenerationID() int32 { return s.generationID }
+
+func (s *consumerGroupSession) MarkOffset(topic string, partition int32, offset int64, metadata string) {
+ if pom := s.offsets.findPOM(topic, partition); pom != nil {
+ pom.MarkOffset(offset, metadata)
+ }
+}
+
+func (s *consumerGroupSession) ResetOffset(topic string, partition int32, offset int64, metadata string) {
+ if pom := s.offsets.findPOM(topic, partition); pom != nil {
+ pom.ResetOffset(offset, metadata)
+ }
+}
+
+func (s *consumerGroupSession) MarkMessage(msg *ConsumerMessage, metadata string) {
+ s.MarkOffset(msg.Topic, msg.Partition, msg.Offset+1, metadata)
+}
+
+func (s *consumerGroupSession) Context() context.Context {
+ return s.ctx
+}
+
+func (s *consumerGroupSession) consume(topic string, partition int32) {
+ // quick exit if rebalance is due
+ select {
+ case <-s.ctx.Done():
+ return
+ case <-s.parent.closed:
+ return
+ default:
+ }
+
+ // get next offset
+ offset := s.parent.config.Consumer.Offsets.Initial
+ if pom := s.offsets.findPOM(topic, partition); pom != nil {
+ offset, _ = pom.NextOffset()
+ }
+
+ // create new claim
+ claim, err := newConsumerGroupClaim(s, topic, partition, offset)
+ if err != nil {
+ s.parent.handleError(err, topic, partition)
+ return
+ }
+
+ // handle errors
+ go func() {
+ for err := range claim.Errors() {
+ s.parent.handleError(err, topic, partition)
+ }
+ }()
+
+ // trigger close when session is done
+ go func() {
+ select {
+ case <-s.ctx.Done():
+ case <-s.parent.closed:
+ }
+ claim.AsyncClose()
+ }()
+
+ // start processing
+ if err := s.handler.ConsumeClaim(s, claim); err != nil {
+ s.parent.handleError(err, topic, partition)
+ }
+
+ // ensure consumer is clased & drained
+ claim.AsyncClose()
+ for _, err := range claim.waitClosed() {
+ s.parent.handleError(err, topic, partition)
+ }
+}
+
+func (s *consumerGroupSession) release(withCleanup bool) (err error) {
+ // signal release, stop heartbeat
+ s.cancel()
+
+ // wait for consumers to exit
+ s.waitGroup.Wait()
+
+ // perform release
+ s.releaseOnce.Do(func() {
+ if withCleanup {
+ if e := s.handler.Cleanup(s); e != nil {
+ s.parent.handleError(err, "", -1)
+ err = e
+ }
+ }
+
+ if e := s.offsets.Close(); e != nil {
+ err = e
+ }
+
+ close(s.hbDying)
+ <-s.hbDead
+ })
+
+ return
+}
+
+func (s *consumerGroupSession) heartbeatLoop() {
+ defer close(s.hbDead)
+ defer s.cancel() // trigger the end of the session on exit
+
+ pause := time.NewTicker(s.parent.config.Consumer.Group.Heartbeat.Interval)
+ defer pause.Stop()
+
+ retries := s.parent.config.Metadata.Retry.Max
+ for {
+ coordinator, err := s.parent.client.Coordinator(s.parent.groupID)
+ if err != nil {
+ if retries <= 0 {
+ s.parent.handleError(err, "", -1)
+ return
+ }
+
+ select {
+ case <-s.hbDying:
+ return
+ case <-time.After(s.parent.config.Metadata.Retry.Backoff):
+ retries--
+ }
+ continue
+ }
+
+ resp, err := s.parent.heartbeatRequest(coordinator, s.memberID, s.generationID)
+ if err != nil {
+ _ = coordinator.Close()
+ retries--
+ continue
+ }
+
+ switch resp.Err {
+ case ErrNoError:
+ retries = s.parent.config.Metadata.Retry.Max
+ case ErrRebalanceInProgress, ErrUnknownMemberId, ErrIllegalGeneration:
+ return
+ default:
+ s.parent.handleError(err, "", -1)
+ return
+ }
+
+ select {
+ case <-pause.C:
+ case <-s.hbDying:
+ return
+ }
+ }
+}
+
+// --------------------------------------------------------------------
+
+// ConsumerGroupHandler instances are used to handle individual topic/partition claims.
+// It also provides hooks for your consumer group session life-cycle and allow you to
+// trigger logic before or after the consume loop(s).
+//
+// PLEASE NOTE that handlers are likely be called from several goroutines concurrently,
+// ensure that all state is safely protected against race conditions.
+type ConsumerGroupHandler interface {
+ // Setup is run at the beginning of a new session, before ConsumeClaim.
+ Setup(ConsumerGroupSession) error
+
+ // Cleanup is run at the end of a session, once all ConsumeClaim goroutines have exites
+ // but before the offsets are committed for the very last time.
+ Cleanup(ConsumerGroupSession) error
+
+ // ConsumeClaim must start a consumer loop of ConsumerGroupClaim's Messages().
+ // Once the Messages() channel is closed, the Handler must finish its processing
+ // loop and exit.
+ ConsumeClaim(ConsumerGroupSession, ConsumerGroupClaim) error
+}
+
+// ConsumerGroupClaim processes Kafka messages from a given topic and partition within a consumer group.
+type ConsumerGroupClaim interface {
+ // Topic returns the consumed topic name.
+ Topic() string
+
+ // Partition returns the consumed partition.
+ Partition() int32
+
+ // InitialOffset returns the initial offset that was used as a starting point for this claim.
+ InitialOffset() int64
+
+ // HighWaterMarkOffset returns the high water mark offset of the partition,
+ // i.e. the offset that will be used for the next message that will be produced.
+ // You can use this to determine how far behind the processing is.
+ HighWaterMarkOffset() int64
+
+ // Messages returns the read channel for the messages that are returned by
+ // the broker. The messages channel will be closed when a new rebalance cycle
+ // is due. You must finish processing and mark offsets within
+ // Config.Consumer.Group.Session.Timeout before the topic/partition is eventually
+ // re-assigned to another group member.
+ Messages() <-chan *ConsumerMessage
+}
+
+type consumerGroupClaim struct {
+ topic string
+ partition int32
+ offset int64
+ PartitionConsumer
+}
+
+func newConsumerGroupClaim(sess *consumerGroupSession, topic string, partition int32, offset int64) (*consumerGroupClaim, error) {
+ pcm, err := sess.parent.consumer.ConsumePartition(topic, partition, offset)
+ if err == ErrOffsetOutOfRange {
+ offset = sess.parent.config.Consumer.Offsets.Initial
+ pcm, err = sess.parent.consumer.ConsumePartition(topic, partition, offset)
+ }
+ if err != nil {
+ return nil, err
+ }
+
+ go func() {
+ for err := range pcm.Errors() {
+ sess.parent.handleError(err, topic, partition)
+ }
+ }()
+
+ return &consumerGroupClaim{
+ topic: topic,
+ partition: partition,
+ offset: offset,
+ PartitionConsumer: pcm,
+ }, nil
+}
+
+func (c *consumerGroupClaim) Topic() string { return c.topic }
+func (c *consumerGroupClaim) Partition() int32 { return c.partition }
+func (c *consumerGroupClaim) InitialOffset() int64 { return c.offset }
+
+// Drains messages and errors, ensures the claim is fully closed.
+func (c *consumerGroupClaim) waitClosed() (errs ConsumerErrors) {
+ go func() {
+ for range c.Messages() {
+ }
+ }()
+
+ for err := range c.Errors() {
+ errs = append(errs, err)
+ }
+ return
+}
diff --git a/vendor/github.com/Shopify/sarama/dev.yml b/vendor/github.com/Shopify/sarama/dev.yml
index 294fcdb413..97eed3ad98 100644
--- a/vendor/github.com/Shopify/sarama/dev.yml
+++ b/vendor/github.com/Shopify/sarama/dev.yml
@@ -2,7 +2,7 @@ name: sarama
up:
- go:
- version: '1.9'
+ version: '1.11'
commands:
test:
diff --git a/vendor/github.com/Shopify/sarama/fetch_response.go b/vendor/github.com/Shopify/sarama/fetch_response.go
index ae91bb9eb0..dade1c47da 100644
--- a/vendor/github.com/Shopify/sarama/fetch_response.go
+++ b/vendor/github.com/Shopify/sarama/fetch_response.go
@@ -104,15 +104,26 @@ func (b *FetchResponseBlock) decode(pd packetDecoder, version int16) (err error)
return err
}
- // If we have at least one full records, we skip incomplete ones
- if partial && len(b.RecordsSet) > 0 {
- break
+ n, err := records.numRecords()
+ if err != nil {
+ return err
}
- b.RecordsSet = append(b.RecordsSet, records)
+ if n > 0 || (partial && len(b.RecordsSet) == 0) {
+ b.RecordsSet = append(b.RecordsSet, records)
- if b.Records == nil {
- b.Records = records
+ if b.Records == nil {
+ b.Records = records
+ }
+ }
+
+ overflow, err := records.isOverflow()
+ if err != nil {
+ return err
+ }
+
+ if partial || overflow {
+ break
}
}
diff --git a/vendor/github.com/Shopify/sarama/length_field.go b/vendor/github.com/Shopify/sarama/length_field.go
index 576b1a6f6f..da199a70a0 100644
--- a/vendor/github.com/Shopify/sarama/length_field.go
+++ b/vendor/github.com/Shopify/sarama/length_field.go
@@ -5,6 +5,19 @@ import "encoding/binary"
// LengthField implements the PushEncoder and PushDecoder interfaces for calculating 4-byte lengths.
type lengthField struct {
startOffset int
+ length int32
+}
+
+func (l *lengthField) decode(pd packetDecoder) error {
+ var err error
+ l.length, err = pd.getInt32()
+ if err != nil {
+ return err
+ }
+ if l.length > int32(pd.remaining()) {
+ return ErrInsufficientData
+ }
+ return nil
}
func (l *lengthField) saveOffset(in int) {
@@ -21,7 +34,7 @@ func (l *lengthField) run(curOffset int, buf []byte) error {
}
func (l *lengthField) check(curOffset int, buf []byte) error {
- if uint32(curOffset-l.startOffset-4) != binary.BigEndian.Uint32(buf[l.startOffset:]) {
+ if int32(curOffset-l.startOffset-4) != l.length {
return PacketDecodingError{"length field invalid"}
}
diff --git a/vendor/github.com/Shopify/sarama/message_set.go b/vendor/github.com/Shopify/sarama/message_set.go
index 27db52fdf1..600c7c4dfb 100644
--- a/vendor/github.com/Shopify/sarama/message_set.go
+++ b/vendor/github.com/Shopify/sarama/message_set.go
@@ -47,6 +47,7 @@ func (msb *MessageBlock) decode(pd packetDecoder) (err error) {
type MessageSet struct {
PartialTrailingMessage bool // whether the set on the wire contained an incomplete trailing MessageBlock
+ OverflowMessage bool // whether the set on the wire contained an overflow message
Messages []*MessageBlock
}
@@ -85,7 +86,12 @@ func (ms *MessageSet) decode(pd packetDecoder) (err error) {
case ErrInsufficientData:
// As an optimization the server is allowed to return a partial message at the
// end of the message set. Clients should handle this case. So we just ignore such things.
- ms.PartialTrailingMessage = true
+ if msb.Offset == -1 {
+ // This is an overflow message caused by chunked down conversion
+ ms.OverflowMessage = true
+ } else {
+ ms.PartialTrailingMessage = true
+ }
return nil
default:
return err
diff --git a/vendor/github.com/Shopify/sarama/metadata_request.go b/vendor/github.com/Shopify/sarama/metadata_request.go
index 48adfa28cb..17dc4289a3 100644
--- a/vendor/github.com/Shopify/sarama/metadata_request.go
+++ b/vendor/github.com/Shopify/sarama/metadata_request.go
@@ -10,7 +10,7 @@ func (r *MetadataRequest) encode(pe packetEncoder) error {
if r.Version < 0 || r.Version > 5 {
return PacketEncodingError{"invalid or unsupported MetadataRequest version field"}
}
- if r.Version == 0 || r.Topics != nil || len(r.Topics) > 0 {
+ if r.Version == 0 || len(r.Topics) > 0 {
err := pe.putArrayLength(len(r.Topics))
if err != nil {
return err
diff --git a/vendor/github.com/Shopify/sarama/metadata_response.go b/vendor/github.com/Shopify/sarama/metadata_response.go
index bf8a67bbc5..c402d05fa3 100644
--- a/vendor/github.com/Shopify/sarama/metadata_response.go
+++ b/vendor/github.com/Shopify/sarama/metadata_response.go
@@ -207,6 +207,10 @@ func (r *MetadataResponse) decode(pd packetDecoder, version int16) (err error) {
}
func (r *MetadataResponse) encode(pe packetEncoder) error {
+ if r.Version >= 3 {
+ pe.putInt32(r.ThrottleTimeMs)
+ }
+
err := pe.putArrayLength(len(r.Brokers))
if err != nil {
return err
@@ -218,6 +222,13 @@ func (r *MetadataResponse) encode(pe packetEncoder) error {
}
}
+ if r.Version >= 2 {
+ err := pe.putNullableString(r.ClusterID)
+ if err != nil {
+ return err
+ }
+ }
+
if r.Version >= 1 {
pe.putInt32(r.ControllerID)
}
diff --git a/vendor/github.com/Shopify/sarama/mockresponses.go b/vendor/github.com/Shopify/sarama/mockresponses.go
index 5541d32ec6..1720441996 100644
--- a/vendor/github.com/Shopify/sarama/mockresponses.go
+++ b/vendor/github.com/Shopify/sarama/mockresponses.go
@@ -538,3 +538,190 @@ func (mr *MockOffsetFetchResponse) For(reqBody versionedDecoder) encoder {
}
return res
}
+
+type MockCreateTopicsResponse struct {
+ t TestReporter
+}
+
+func NewMockCreateTopicsResponse(t TestReporter) *MockCreateTopicsResponse {
+ return &MockCreateTopicsResponse{t: t}
+}
+
+func (mr *MockCreateTopicsResponse) For(reqBody versionedDecoder) encoder {
+ req := reqBody.(*CreateTopicsRequest)
+ res := &CreateTopicsResponse{}
+ res.TopicErrors = make(map[string]*TopicError)
+
+ for topic, _ := range req.TopicDetails {
+ res.TopicErrors[topic] = &TopicError{Err: ErrNoError}
+ }
+ return res
+}
+
+type MockDeleteTopicsResponse struct {
+ t TestReporter
+}
+
+func NewMockDeleteTopicsResponse(t TestReporter) *MockDeleteTopicsResponse {
+ return &MockDeleteTopicsResponse{t: t}
+}
+
+func (mr *MockDeleteTopicsResponse) For(reqBody versionedDecoder) encoder {
+ req := reqBody.(*DeleteTopicsRequest)
+ res := &DeleteTopicsResponse{}
+ res.TopicErrorCodes = make(map[string]KError)
+
+ for _, topic := range req.Topics {
+ res.TopicErrorCodes[topic] = ErrNoError
+ }
+ return res
+}
+
+type MockCreatePartitionsResponse struct {
+ t TestReporter
+}
+
+func NewMockCreatePartitionsResponse(t TestReporter) *MockCreatePartitionsResponse {
+ return &MockCreatePartitionsResponse{t: t}
+}
+
+func (mr *MockCreatePartitionsResponse) For(reqBody versionedDecoder) encoder {
+ req := reqBody.(*CreatePartitionsRequest)
+ res := &CreatePartitionsResponse{}
+ res.TopicPartitionErrors = make(map[string]*TopicPartitionError)
+
+ for topic, _ := range req.TopicPartitions {
+ res.TopicPartitionErrors[topic] = &TopicPartitionError{Err: ErrNoError}
+ }
+ return res
+}
+
+type MockDeleteRecordsResponse struct {
+ t TestReporter
+}
+
+func NewMockDeleteRecordsResponse(t TestReporter) *MockDeleteRecordsResponse {
+ return &MockDeleteRecordsResponse{t: t}
+}
+
+func (mr *MockDeleteRecordsResponse) For(reqBody versionedDecoder) encoder {
+ req := reqBody.(*DeleteRecordsRequest)
+ res := &DeleteRecordsResponse{}
+ res.Topics = make(map[string]*DeleteRecordsResponseTopic)
+
+ for topic, deleteRecordRequestTopic := range req.Topics {
+ partitions := make(map[int32]*DeleteRecordsResponsePartition)
+ for partition, _ := range deleteRecordRequestTopic.PartitionOffsets {
+ partitions[partition] = &DeleteRecordsResponsePartition{Err: ErrNoError}
+ }
+ res.Topics[topic] = &DeleteRecordsResponseTopic{Partitions: partitions}
+ }
+ return res
+}
+
+type MockDescribeConfigsResponse struct {
+ t TestReporter
+}
+
+func NewMockDescribeConfigsResponse(t TestReporter) *MockDescribeConfigsResponse {
+ return &MockDescribeConfigsResponse{t: t}
+}
+
+func (mr *MockDescribeConfigsResponse) For(reqBody versionedDecoder) encoder {
+ req := reqBody.(*DescribeConfigsRequest)
+ res := &DescribeConfigsResponse{}
+
+ var configEntries []*ConfigEntry
+ configEntries = append(configEntries, &ConfigEntry{Name: "my_topic",
+ Value: "my_topic",
+ ReadOnly: true,
+ Default: true,
+ Sensitive: false,
+ })
+
+ for _, r := range req.Resources {
+ res.Resources = append(res.Resources, &ResourceResponse{Name: r.Name, Configs: configEntries})
+ }
+ return res
+}
+
+type MockAlterConfigsResponse struct {
+ t TestReporter
+}
+
+func NewMockAlterConfigsResponse(t TestReporter) *MockAlterConfigsResponse {
+ return &MockAlterConfigsResponse{t: t}
+}
+
+func (mr *MockAlterConfigsResponse) For(reqBody versionedDecoder) encoder {
+ req := reqBody.(*AlterConfigsRequest)
+ res := &AlterConfigsResponse{}
+
+ for _, r := range req.Resources {
+ res.Resources = append(res.Resources, &AlterConfigsResourceResponse{Name: r.Name,
+ Type: TopicResource,
+ ErrorMsg: "",
+ })
+ }
+ return res
+}
+
+type MockCreateAclsResponse struct {
+ t TestReporter
+}
+
+func NewMockCreateAclsResponse(t TestReporter) *MockCreateAclsResponse {
+ return &MockCreateAclsResponse{t: t}
+}
+
+func (mr *MockCreateAclsResponse) For(reqBody versionedDecoder) encoder {
+ req := reqBody.(*CreateAclsRequest)
+ res := &CreateAclsResponse{}
+
+ for range req.AclCreations {
+ res.AclCreationResponses = append(res.AclCreationResponses, &AclCreationResponse{Err: ErrNoError})
+ }
+ return res
+}
+
+type MockListAclsResponse struct {
+ t TestReporter
+}
+
+func NewMockListAclsResponse(t TestReporter) *MockListAclsResponse {
+ return &MockListAclsResponse{t: t}
+}
+
+func (mr *MockListAclsResponse) For(reqBody versionedDecoder) encoder {
+ req := reqBody.(*DescribeAclsRequest)
+ res := &DescribeAclsResponse{}
+
+ res.Err = ErrNoError
+ acl := &ResourceAcls{}
+ acl.Resource.ResourceName = *req.ResourceName
+ acl.Resource.ResourceType = req.ResourceType
+ acl.Acls = append(acl.Acls, &Acl{})
+ res.ResourceAcls = append(res.ResourceAcls, acl)
+
+ return res
+}
+
+type MockDeleteAclsResponse struct {
+ t TestReporter
+}
+
+func NewMockDeleteAclsResponse(t TestReporter) *MockDeleteAclsResponse {
+ return &MockDeleteAclsResponse{t: t}
+}
+
+func (mr *MockDeleteAclsResponse) For(reqBody versionedDecoder) encoder {
+ req := reqBody.(*DeleteAclsRequest)
+ res := &DeleteAclsResponse{}
+
+ for range req.Filters {
+ response := &FilterResponse{Err: ErrNoError}
+ response.MatchingAcls = append(response.MatchingAcls, &MatchingAcl{Err: ErrNoError})
+ res.FilterResponses = append(res.FilterResponses, response)
+ }
+ return res
+}
diff --git a/vendor/github.com/Shopify/sarama/offset_manager.go b/vendor/github.com/Shopify/sarama/offset_manager.go
index 6c01f959e9..8ea857f835 100644
--- a/vendor/github.com/Shopify/sarama/offset_manager.go
+++ b/vendor/github.com/Shopify/sarama/offset_manager.go
@@ -25,27 +25,49 @@ type offsetManager struct {
client Client
conf *Config
group string
+ ticker *time.Ticker
- lock sync.Mutex
- poms map[string]map[int32]*partitionOffsetManager
- boms map[*Broker]*brokerOffsetManager
+ memberID string
+ generation int32
+
+ broker *Broker
+ brokerLock sync.RWMutex
+
+ poms map[string]map[int32]*partitionOffsetManager
+ pomsLock sync.RWMutex
+
+ closeOnce sync.Once
+ closing chan none
+ closed chan none
}
// NewOffsetManagerFromClient creates a new OffsetManager from the given client.
// It is still necessary to call Close() on the underlying client when finished with the partition manager.
func NewOffsetManagerFromClient(group string, client Client) (OffsetManager, error) {
+ return newOffsetManagerFromClient(group, "", GroupGenerationUndefined, client)
+}
+
+func newOffsetManagerFromClient(group, memberID string, generation int32, client Client) (*offsetManager, error) {
// Check that we are not dealing with a closed Client before processing any other arguments
if client.Closed() {
return nil, ErrClosedClient
}
+ conf := client.Config()
om := &offsetManager{
client: client,
- conf: client.Config(),
+ conf: conf,
group: group,
+ ticker: time.NewTicker(conf.Consumer.Offsets.CommitInterval),
poms: make(map[string]map[int32]*partitionOffsetManager),
- boms: make(map[*Broker]*brokerOffsetManager),
+
+ memberID: memberID,
+ generation: generation,
+
+ closing: make(chan none),
+ closed: make(chan none),
}
+ go withRecover(om.mainLoop)
return om, nil
}
@@ -56,8 +78,8 @@ func (om *offsetManager) ManagePartition(topic string, partition int32) (Partiti
return nil, err
}
- om.lock.Lock()
- defer om.lock.Unlock()
+ om.pomsLock.Lock()
+ defer om.pomsLock.Unlock()
topicManagers := om.poms[topic]
if topicManagers == nil {
@@ -74,53 +96,307 @@ func (om *offsetManager) ManagePartition(topic string, partition int32) (Partiti
}
func (om *offsetManager) Close() error {
+ om.closeOnce.Do(func() {
+ // exit the mainLoop
+ close(om.closing)
+ <-om.closed
+
+ // mark all POMs as closed
+ om.asyncClosePOMs()
+
+ // flush one last time
+ for attempt := 0; attempt <= om.conf.Consumer.Offsets.Retry.Max; attempt++ {
+ om.flushToBroker()
+ if om.releasePOMs(false) == 0 {
+ break
+ }
+ }
+
+ om.releasePOMs(true)
+ om.brokerLock.Lock()
+ om.broker = nil
+ om.brokerLock.Unlock()
+ })
return nil
}
-func (om *offsetManager) refBrokerOffsetManager(broker *Broker) *brokerOffsetManager {
- om.lock.Lock()
- defer om.lock.Unlock()
-
- bom := om.boms[broker]
- if bom == nil {
- bom = om.newBrokerOffsetManager(broker)
- om.boms[broker] = bom
+func (om *offsetManager) fetchInitialOffset(topic string, partition int32, retries int) (int64, string, error) {
+ broker, err := om.coordinator()
+ if err != nil {
+ if retries <= 0 {
+ return 0, "", err
+ }
+ return om.fetchInitialOffset(topic, partition, retries-1)
}
- bom.refs++
+ req := new(OffsetFetchRequest)
+ req.Version = 1
+ req.ConsumerGroup = om.group
+ req.AddPartition(topic, partition)
- return bom
+ resp, err := broker.FetchOffset(req)
+ if err != nil {
+ if retries <= 0 {
+ return 0, "", err
+ }
+ om.releaseCoordinator(broker)
+ return om.fetchInitialOffset(topic, partition, retries-1)
+ }
+
+ block := resp.GetBlock(topic, partition)
+ if block == nil {
+ return 0, "", ErrIncompleteResponse
+ }
+
+ switch block.Err {
+ case ErrNoError:
+ return block.Offset, block.Metadata, nil
+ case ErrNotCoordinatorForConsumer:
+ if retries <= 0 {
+ return 0, "", block.Err
+ }
+ om.releaseCoordinator(broker)
+ return om.fetchInitialOffset(topic, partition, retries-1)
+ case ErrOffsetsLoadInProgress:
+ if retries <= 0 {
+ return 0, "", block.Err
+ }
+ select {
+ case <-om.closing:
+ return 0, "", block.Err
+ case <-time.After(om.conf.Metadata.Retry.Backoff):
+ }
+ return om.fetchInitialOffset(topic, partition, retries-1)
+ default:
+ return 0, "", block.Err
+ }
}
-func (om *offsetManager) unrefBrokerOffsetManager(bom *brokerOffsetManager) {
- om.lock.Lock()
- defer om.lock.Unlock()
+func (om *offsetManager) coordinator() (*Broker, error) {
+ om.brokerLock.RLock()
+ broker := om.broker
+ om.brokerLock.RUnlock()
- bom.refs--
+ if broker != nil {
+ return broker, nil
+ }
- if bom.refs == 0 {
- close(bom.updateSubscriptions)
- if om.boms[bom.broker] == bom {
- delete(om.boms, bom.broker)
+ om.brokerLock.Lock()
+ defer om.brokerLock.Unlock()
+
+ if broker := om.broker; broker != nil {
+ return broker, nil
+ }
+
+ if err := om.client.RefreshCoordinator(om.group); err != nil {
+ return nil, err
+ }
+
+ broker, err := om.client.Coordinator(om.group)
+ if err != nil {
+ return nil, err
+ }
+
+ om.broker = broker
+ return broker, nil
+}
+
+func (om *offsetManager) releaseCoordinator(b *Broker) {
+ om.brokerLock.Lock()
+ if om.broker == b {
+ om.broker = nil
+ }
+ om.brokerLock.Unlock()
+}
+
+func (om *offsetManager) mainLoop() {
+ defer om.ticker.Stop()
+ defer close(om.closed)
+
+ for {
+ select {
+ case <-om.ticker.C:
+ om.flushToBroker()
+ om.releasePOMs(false)
+ case <-om.closing:
+ return
}
}
}
-func (om *offsetManager) abandonBroker(bom *brokerOffsetManager) {
- om.lock.Lock()
- defer om.lock.Unlock()
+func (om *offsetManager) flushToBroker() {
+ req := om.constructRequest()
+ if req == nil {
+ return
+ }
- delete(om.boms, bom.broker)
+ broker, err := om.coordinator()
+ if err != nil {
+ om.handleError(err)
+ return
+ }
+
+ resp, err := broker.CommitOffset(req)
+ if err != nil {
+ om.handleError(err)
+ om.releaseCoordinator(broker)
+ _ = broker.Close()
+ return
+ }
+
+ om.handleResponse(broker, req, resp)
}
-func (om *offsetManager) abandonPartitionOffsetManager(pom *partitionOffsetManager) {
- om.lock.Lock()
- defer om.lock.Unlock()
+func (om *offsetManager) constructRequest() *OffsetCommitRequest {
+ var r *OffsetCommitRequest
+ var perPartitionTimestamp int64
+ if om.conf.Consumer.Offsets.Retention == 0 {
+ perPartitionTimestamp = ReceiveTime
+ r = &OffsetCommitRequest{
+ Version: 1,
+ ConsumerGroup: om.group,
+ ConsumerID: om.memberID,
+ ConsumerGroupGeneration: om.generation,
+ }
+ } else {
+ r = &OffsetCommitRequest{
+ Version: 2,
+ RetentionTime: int64(om.conf.Consumer.Offsets.Retention / time.Millisecond),
+ ConsumerGroup: om.group,
+ ConsumerID: om.memberID,
+ ConsumerGroupGeneration: om.generation,
+ }
- delete(om.poms[pom.topic], pom.partition)
- if len(om.poms[pom.topic]) == 0 {
- delete(om.poms, pom.topic)
}
+
+ om.pomsLock.RLock()
+ defer om.pomsLock.RUnlock()
+
+ for _, topicManagers := range om.poms {
+ for _, pom := range topicManagers {
+ pom.lock.Lock()
+ if pom.dirty {
+ r.AddBlock(pom.topic, pom.partition, pom.offset, perPartitionTimestamp, pom.metadata)
+ }
+ pom.lock.Unlock()
+ }
+ }
+
+ if len(r.blocks) > 0 {
+ return r
+ }
+
+ return nil
+}
+
+func (om *offsetManager) handleResponse(broker *Broker, req *OffsetCommitRequest, resp *OffsetCommitResponse) {
+ om.pomsLock.RLock()
+ defer om.pomsLock.RUnlock()
+
+ for _, topicManagers := range om.poms {
+ for _, pom := range topicManagers {
+ if req.blocks[pom.topic] == nil || req.blocks[pom.topic][pom.partition] == nil {
+ continue
+ }
+
+ var err KError
+ var ok bool
+
+ if resp.Errors[pom.topic] == nil {
+ pom.handleError(ErrIncompleteResponse)
+ continue
+ }
+ if err, ok = resp.Errors[pom.topic][pom.partition]; !ok {
+ pom.handleError(ErrIncompleteResponse)
+ continue
+ }
+
+ switch err {
+ case ErrNoError:
+ block := req.blocks[pom.topic][pom.partition]
+ pom.updateCommitted(block.offset, block.metadata)
+ case ErrNotLeaderForPartition, ErrLeaderNotAvailable,
+ ErrConsumerCoordinatorNotAvailable, ErrNotCoordinatorForConsumer:
+ // not a critical error, we just need to redispatch
+ om.releaseCoordinator(broker)
+ case ErrOffsetMetadataTooLarge, ErrInvalidCommitOffsetSize:
+ // nothing we can do about this, just tell the user and carry on
+ pom.handleError(err)
+ case ErrOffsetsLoadInProgress:
+ // nothing wrong but we didn't commit, we'll get it next time round
+ break
+ case ErrUnknownTopicOrPartition:
+ // let the user know *and* try redispatching - if topic-auto-create is
+ // enabled, redispatching should trigger a metadata req and create the
+ // topic; if not then re-dispatching won't help, but we've let the user
+ // know and it shouldn't hurt either (see https://github.com/Shopify/sarama/issues/706)
+ fallthrough
+ default:
+ // dunno, tell the user and try redispatching
+ pom.handleError(err)
+ om.releaseCoordinator(broker)
+ }
+ }
+ }
+}
+
+func (om *offsetManager) handleError(err error) {
+ om.pomsLock.RLock()
+ defer om.pomsLock.RUnlock()
+
+ for _, topicManagers := range om.poms {
+ for _, pom := range topicManagers {
+ pom.handleError(err)
+ }
+ }
+}
+
+func (om *offsetManager) asyncClosePOMs() {
+ om.pomsLock.RLock()
+ defer om.pomsLock.RUnlock()
+
+ for _, topicManagers := range om.poms {
+ for _, pom := range topicManagers {
+ pom.AsyncClose()
+ }
+ }
+}
+
+// Releases/removes closed POMs once they are clean (or when forced)
+func (om *offsetManager) releasePOMs(force bool) (remaining int) {
+ om.pomsLock.Lock()
+ defer om.pomsLock.Unlock()
+
+ for topic, topicManagers := range om.poms {
+ for partition, pom := range topicManagers {
+ pom.lock.Lock()
+ releaseDue := pom.done && (force || !pom.dirty)
+ pom.lock.Unlock()
+
+ if releaseDue {
+ pom.release()
+
+ delete(om.poms[topic], partition)
+ if len(om.poms[topic]) == 0 {
+ delete(om.poms, topic)
+ }
+ }
+ }
+ remaining += len(om.poms[topic])
+ }
+ return
+}
+
+func (om *offsetManager) findPOM(topic string, partition int32) *partitionOffsetManager {
+ om.pomsLock.RLock()
+ defer om.pomsLock.RUnlock()
+
+ if partitions, ok := om.poms[topic]; ok {
+ if pom, ok := partitions[partition]; ok {
+ return pom
+ }
+ }
+ return nil
}
// Partition Offset Manager
@@ -187,138 +463,26 @@ type partitionOffsetManager struct {
offset int64
metadata string
dirty bool
- clean sync.Cond
- broker *brokerOffsetManager
+ done bool
- errors chan *ConsumerError
- rebalance chan none
- dying chan none
+ releaseOnce sync.Once
+ errors chan *ConsumerError
}
func (om *offsetManager) newPartitionOffsetManager(topic string, partition int32) (*partitionOffsetManager, error) {
- pom := &partitionOffsetManager{
+ offset, metadata, err := om.fetchInitialOffset(topic, partition, om.conf.Metadata.Retry.Max)
+ if err != nil {
+ return nil, err
+ }
+
+ return &partitionOffsetManager{
parent: om,
topic: topic,
partition: partition,
errors: make(chan *ConsumerError, om.conf.ChannelBufferSize),
- rebalance: make(chan none, 1),
- dying: make(chan none),
- }
- pom.clean.L = &pom.lock
-
- if err := pom.selectBroker(); err != nil {
- return nil, err
- }
-
- if err := pom.fetchInitialOffset(om.conf.Metadata.Retry.Max); err != nil {
- return nil, err
- }
-
- pom.broker.updateSubscriptions <- pom
-
- go withRecover(pom.mainLoop)
-
- return pom, nil
-}
-
-func (pom *partitionOffsetManager) mainLoop() {
- for {
- select {
- case <-pom.rebalance:
- if err := pom.selectBroker(); err != nil {
- pom.handleError(err)
- pom.rebalance <- none{}
- } else {
- pom.broker.updateSubscriptions <- pom
- }
- case <-pom.dying:
- if pom.broker != nil {
- select {
- case <-pom.rebalance:
- case pom.broker.updateSubscriptions <- pom:
- }
- pom.parent.unrefBrokerOffsetManager(pom.broker)
- }
- pom.parent.abandonPartitionOffsetManager(pom)
- close(pom.errors)
- return
- }
- }
-}
-
-func (pom *partitionOffsetManager) selectBroker() error {
- if pom.broker != nil {
- pom.parent.unrefBrokerOffsetManager(pom.broker)
- pom.broker = nil
- }
-
- var broker *Broker
- var err error
-
- if err = pom.parent.client.RefreshCoordinator(pom.parent.group); err != nil {
- return err
- }
-
- if broker, err = pom.parent.client.Coordinator(pom.parent.group); err != nil {
- return err
- }
-
- pom.broker = pom.parent.refBrokerOffsetManager(broker)
- return nil
-}
-
-func (pom *partitionOffsetManager) fetchInitialOffset(retries int) error {
- request := new(OffsetFetchRequest)
- request.Version = 1
- request.ConsumerGroup = pom.parent.group
- request.AddPartition(pom.topic, pom.partition)
-
- response, err := pom.broker.broker.FetchOffset(request)
- if err != nil {
- return err
- }
-
- block := response.GetBlock(pom.topic, pom.partition)
- if block == nil {
- return ErrIncompleteResponse
- }
-
- switch block.Err {
- case ErrNoError:
- pom.offset = block.Offset
- pom.metadata = block.Metadata
- return nil
- case ErrNotCoordinatorForConsumer:
- if retries <= 0 {
- return block.Err
- }
- if err := pom.selectBroker(); err != nil {
- return err
- }
- return pom.fetchInitialOffset(retries - 1)
- case ErrOffsetsLoadInProgress:
- if retries <= 0 {
- return block.Err
- }
- time.Sleep(pom.parent.conf.Metadata.Retry.Backoff)
- return pom.fetchInitialOffset(retries - 1)
- default:
- return block.Err
- }
-}
-
-func (pom *partitionOffsetManager) handleError(err error) {
- cErr := &ConsumerError{
- Topic: pom.topic,
- Partition: pom.partition,
- Err: err,
- }
-
- if pom.parent.conf.Consumer.Return.Errors {
- pom.errors <- cErr
- } else {
- Logger.Println(cErr)
- }
+ offset: offset,
+ metadata: metadata,
+ }, nil
}
func (pom *partitionOffsetManager) Errors() <-chan *ConsumerError {
@@ -353,7 +517,6 @@ func (pom *partitionOffsetManager) updateCommitted(offset int64, metadata string
if pom.offset == offset && pom.metadata == metadata {
pom.dirty = false
- pom.clean.Signal()
}
}
@@ -369,16 +532,9 @@ func (pom *partitionOffsetManager) NextOffset() (int64, string) {
}
func (pom *partitionOffsetManager) AsyncClose() {
- go func() {
- pom.lock.Lock()
- defer pom.lock.Unlock()
-
- for pom.dirty {
- pom.clean.Wait()
- }
-
- close(pom.dying)
- }()
+ pom.lock.Lock()
+ pom.done = true
+ pom.lock.Unlock()
}
func (pom *partitionOffsetManager) Close() error {
@@ -395,166 +551,22 @@ func (pom *partitionOffsetManager) Close() error {
return nil
}
-// Broker Offset Manager
-
-type brokerOffsetManager struct {
- parent *offsetManager
- broker *Broker
- timer *time.Ticker
- updateSubscriptions chan *partitionOffsetManager
- subscriptions map[*partitionOffsetManager]none
- refs int
-}
-
-func (om *offsetManager) newBrokerOffsetManager(broker *Broker) *brokerOffsetManager {
- bom := &brokerOffsetManager{
- parent: om,
- broker: broker,
- timer: time.NewTicker(om.conf.Consumer.Offsets.CommitInterval),
- updateSubscriptions: make(chan *partitionOffsetManager),
- subscriptions: make(map[*partitionOffsetManager]none),
+func (pom *partitionOffsetManager) handleError(err error) {
+ cErr := &ConsumerError{
+ Topic: pom.topic,
+ Partition: pom.partition,
+ Err: err,
}
- go withRecover(bom.mainLoop)
-
- return bom
-}
-
-func (bom *brokerOffsetManager) mainLoop() {
- for {
- select {
- case <-bom.timer.C:
- if len(bom.subscriptions) > 0 {
- bom.flushToBroker()
- }
- case s, ok := <-bom.updateSubscriptions:
- if !ok {
- bom.timer.Stop()
- return
- }
- if _, ok := bom.subscriptions[s]; ok {
- delete(bom.subscriptions, s)
- } else {
- bom.subscriptions[s] = none{}
- }
- }
- }
-}
-
-func (bom *brokerOffsetManager) flushToBroker() {
- request := bom.constructRequest()
- if request == nil {
- return
- }
-
- response, err := bom.broker.CommitOffset(request)
-
- if err != nil {
- bom.abort(err)
- return
- }
-
- for s := range bom.subscriptions {
- if request.blocks[s.topic] == nil || request.blocks[s.topic][s.partition] == nil {
- continue
- }
-
- var err KError
- var ok bool
-
- if response.Errors[s.topic] == nil {
- s.handleError(ErrIncompleteResponse)
- delete(bom.subscriptions, s)
- s.rebalance <- none{}
- continue
- }
- if err, ok = response.Errors[s.topic][s.partition]; !ok {
- s.handleError(ErrIncompleteResponse)
- delete(bom.subscriptions, s)
- s.rebalance <- none{}
- continue
- }
-
- switch err {
- case ErrNoError:
- block := request.blocks[s.topic][s.partition]
- s.updateCommitted(block.offset, block.metadata)
- case ErrNotLeaderForPartition, ErrLeaderNotAvailable,
- ErrConsumerCoordinatorNotAvailable, ErrNotCoordinatorForConsumer:
- // not a critical error, we just need to redispatch
- delete(bom.subscriptions, s)
- s.rebalance <- none{}
- case ErrOffsetMetadataTooLarge, ErrInvalidCommitOffsetSize:
- // nothing we can do about this, just tell the user and carry on
- s.handleError(err)
- case ErrOffsetsLoadInProgress:
- // nothing wrong but we didn't commit, we'll get it next time round
- break
- case ErrUnknownTopicOrPartition:
- // let the user know *and* try redispatching - if topic-auto-create is
- // enabled, redispatching should trigger a metadata request and create the
- // topic; if not then re-dispatching won't help, but we've let the user
- // know and it shouldn't hurt either (see https://github.com/Shopify/sarama/issues/706)
- fallthrough
- default:
- // dunno, tell the user and try redispatching
- s.handleError(err)
- delete(bom.subscriptions, s)
- s.rebalance <- none{}
- }
- }
-}
-
-func (bom *brokerOffsetManager) constructRequest() *OffsetCommitRequest {
- var r *OffsetCommitRequest
- var perPartitionTimestamp int64
- if bom.parent.conf.Consumer.Offsets.Retention == 0 {
- perPartitionTimestamp = ReceiveTime
- r = &OffsetCommitRequest{
- Version: 1,
- ConsumerGroup: bom.parent.group,
- ConsumerGroupGeneration: GroupGenerationUndefined,
- }
+ if pom.parent.conf.Consumer.Return.Errors {
+ pom.errors <- cErr
} else {
- r = &OffsetCommitRequest{
- Version: 2,
- RetentionTime: int64(bom.parent.conf.Consumer.Offsets.Retention / time.Millisecond),
- ConsumerGroup: bom.parent.group,
- ConsumerGroupGeneration: GroupGenerationUndefined,
- }
-
+ Logger.Println(cErr)
}
-
- for s := range bom.subscriptions {
- s.lock.Lock()
- if s.dirty {
- r.AddBlock(s.topic, s.partition, s.offset, perPartitionTimestamp, s.metadata)
- }
- s.lock.Unlock()
- }
-
- if len(r.blocks) > 0 {
- return r
- }
-
- return nil
}
-func (bom *brokerOffsetManager) abort(err error) {
- _ = bom.broker.Close() // we don't care about the error this might return, we already have one
- bom.parent.abandonBroker(bom)
-
- for pom := range bom.subscriptions {
- pom.handleError(err)
- pom.rebalance <- none{}
- }
-
- for s := range bom.updateSubscriptions {
- if _, ok := bom.subscriptions[s]; !ok {
- s.handleError(err)
- s.rebalance <- none{}
- }
- }
-
- bom.subscriptions = make(map[*partitionOffsetManager]none)
+func (pom *partitionOffsetManager) release() {
+ pom.releaseOnce.Do(func() {
+ go close(pom.errors)
+ })
}
diff --git a/vendor/github.com/Shopify/sarama/partitioner.go b/vendor/github.com/Shopify/sarama/partitioner.go
index 972932728a..6a708e729e 100644
--- a/vendor/github.com/Shopify/sarama/partitioner.go
+++ b/vendor/github.com/Shopify/sarama/partitioner.go
@@ -22,11 +22,51 @@ type Partitioner interface {
RequiresConsistency() bool
}
+// DynamicConsistencyPartitioner can optionally be implemented by Partitioners
+// in order to allow more flexibility than is originally allowed by the
+// RequiresConsistency method in the Partitioner interface. This allows
+// partitioners to require consistency sometimes, but not all times. It's useful
+// for, e.g., the HashPartitioner, which does not require consistency if the
+// message key is nil.
+type DynamicConsistencyPartitioner interface {
+ Partitioner
+
+ // MessageRequiresConsistency is similar to Partitioner.RequiresConsistency,
+ // but takes in the message being partitioned so that the partitioner can
+ // make a per-message determination.
+ MessageRequiresConsistency(message *ProducerMessage) bool
+}
+
// PartitionerConstructor is the type for a function capable of constructing new Partitioners.
type PartitionerConstructor func(topic string) Partitioner
type manualPartitioner struct{}
+// HashPartitionOption lets you modify default values of the partitioner
+type HashPartitionerOption func(*hashPartitioner)
+
+// WithAbsFirst means that the partitioner handles absolute values
+// in the same way as the reference Java implementation
+func WithAbsFirst() HashPartitionerOption {
+ return func(hp *hashPartitioner) {
+ hp.referenceAbs = true
+ }
+}
+
+// WithCustomHashFunction lets you specify what hash function to use for the partitioning
+func WithCustomHashFunction(hasher func() hash.Hash32) HashPartitionerOption {
+ return func(hp *hashPartitioner) {
+ hp.hasher = hasher()
+ }
+}
+
+// WithCustomFallbackPartitioner lets you specify what HashPartitioner should be used in case a Distribution Key is empty
+func WithCustomFallbackPartitioner(randomHP *hashPartitioner) HashPartitionerOption {
+ return func(hp *hashPartitioner) {
+ hp.random = hp
+ }
+}
+
// NewManualPartitioner returns a Partitioner which uses the partition manually set in the provided
// ProducerMessage's Partition field as the partition to produce to.
func NewManualPartitioner(topic string) Partitioner {
@@ -83,8 +123,9 @@ func (p *roundRobinPartitioner) RequiresConsistency() bool {
}
type hashPartitioner struct {
- random Partitioner
- hasher hash.Hash32
+ random Partitioner
+ hasher hash.Hash32
+ referenceAbs bool
}
// NewCustomHashPartitioner is a wrapper around NewHashPartitioner, allowing the use of custom hasher.
@@ -95,6 +136,21 @@ func NewCustomHashPartitioner(hasher func() hash.Hash32) PartitionerConstructor
p := new(hashPartitioner)
p.random = NewRandomPartitioner(topic)
p.hasher = hasher()
+ p.referenceAbs = false
+ return p
+ }
+}
+
+// NewCustomPartitioner creates a default Partitioner but lets you specify the behavior of each component via options
+func NewCustomPartitioner(options ...HashPartitionerOption) PartitionerConstructor {
+ return func(topic string) Partitioner {
+ p := new(hashPartitioner)
+ p.random = NewRandomPartitioner(topic)
+ p.hasher = fnv.New32a()
+ p.referenceAbs = false
+ for _, option := range options {
+ option(p)
+ }
return p
}
}
@@ -107,6 +163,19 @@ func NewHashPartitioner(topic string) Partitioner {
p := new(hashPartitioner)
p.random = NewRandomPartitioner(topic)
p.hasher = fnv.New32a()
+ p.referenceAbs = false
+ return p
+}
+
+// NewReferenceHashPartitioner is like NewHashPartitioner except that it handles absolute values
+// in the same way as the reference Java implementation. NewHashPartitioner was supposed to do
+// that but it had a mistake and now there are people depending on both behaviours. This will
+// all go away on the next major version bump.
+func NewReferenceHashPartitioner(topic string) Partitioner {
+ p := new(hashPartitioner)
+ p.random = NewRandomPartitioner(topic)
+ p.hasher = fnv.New32a()
+ p.referenceAbs = true
return p
}
@@ -123,9 +192,18 @@ func (p *hashPartitioner) Partition(message *ProducerMessage, numPartitions int3
if err != nil {
return -1, err
}
- partition := int32(p.hasher.Sum32()) % numPartitions
- if partition < 0 {
- partition = -partition
+ var partition int32
+ // Turns out we were doing our absolute value in a subtly different way from the upstream
+ // implementation, but now we need to maintain backwards compat for people who started using
+ // the old version; if referenceAbs is set we are compatible with the reference java client
+ // but not past Sarama versions
+ if p.referenceAbs {
+ partition = (int32(p.hasher.Sum32()) & 0x7fffffff) % numPartitions
+ } else {
+ partition = int32(p.hasher.Sum32()) % numPartitions
+ if partition < 0 {
+ partition = -partition
+ }
}
return partition, nil
}
@@ -133,3 +211,7 @@ func (p *hashPartitioner) Partition(message *ProducerMessage, numPartitions int3
func (p *hashPartitioner) RequiresConsistency() bool {
return true
}
+
+func (p *hashPartitioner) MessageRequiresConsistency(message *ProducerMessage) bool {
+ return message.Key != nil
+}
diff --git a/vendor/github.com/Shopify/sarama/records.go b/vendor/github.com/Shopify/sarama/records.go
index 301055bb07..192f5927b2 100644
--- a/vendor/github.com/Shopify/sarama/records.go
+++ b/vendor/github.com/Shopify/sarama/records.go
@@ -163,6 +163,27 @@ func (r *Records) isControl() (bool, error) {
return false, fmt.Errorf("unknown records type: %v", r.recordsType)
}
+func (r *Records) isOverflow() (bool, error) {
+ if r.recordsType == unknownRecords {
+ if empty, err := r.setTypeFromFields(); err != nil || empty {
+ return false, err
+ }
+ }
+
+ switch r.recordsType {
+ case unknownRecords:
+ return false, nil
+ case legacyRecords:
+ if r.MsgSet == nil {
+ return false, nil
+ }
+ return r.MsgSet.OverflowMessage, nil
+ case defaultRecords:
+ return false, nil
+ }
+ return false, fmt.Errorf("unknown records type: %v", r.recordsType)
+}
+
func magicValue(pd packetDecoder) (int8, error) {
dec, err := pd.peek(magicOffset, magicLength)
if err != nil {
diff --git a/vendor/github.com/Shopify/sarama/sync_producer.go b/vendor/github.com/Shopify/sarama/sync_producer.go
index dd096b6db6..021c5a0103 100644
--- a/vendor/github.com/Shopify/sarama/sync_producer.go
+++ b/vendor/github.com/Shopify/sarama/sync_producer.go
@@ -90,13 +90,8 @@ func verifyProducerConfig(config *Config) error {
}
func (sp *syncProducer) SendMessage(msg *ProducerMessage) (partition int32, offset int64, err error) {
- oldMetadata := msg.Metadata
- defer func() {
- msg.Metadata = oldMetadata
- }()
-
expectation := make(chan *ProducerError, 1)
- msg.Metadata = expectation
+ msg.expectation = expectation
sp.producer.Input() <- msg
if err := <-expectation; err != nil {
@@ -107,21 +102,11 @@ func (sp *syncProducer) SendMessage(msg *ProducerMessage) (partition int32, offs
}
func (sp *syncProducer) SendMessages(msgs []*ProducerMessage) error {
- savedMetadata := make([]interface{}, len(msgs))
- for i := range msgs {
- savedMetadata[i] = msgs[i].Metadata
- }
- defer func() {
- for i := range msgs {
- msgs[i].Metadata = savedMetadata[i]
- }
- }()
-
expectations := make(chan chan *ProducerError, len(msgs))
go func() {
for _, msg := range msgs {
expectation := make(chan *ProducerError, 1)
- msg.Metadata = expectation
+ msg.expectation = expectation
sp.producer.Input() <- msg
expectations <- expectation
}
@@ -144,7 +129,7 @@ func (sp *syncProducer) SendMessages(msgs []*ProducerMessage) error {
func (sp *syncProducer) handleSuccesses() {
defer sp.wg.Done()
for msg := range sp.producer.Successes() {
- expectation := msg.Metadata.(chan *ProducerError)
+ expectation := msg.expectation
expectation <- nil
}
}
@@ -152,7 +137,7 @@ func (sp *syncProducer) handleSuccesses() {
func (sp *syncProducer) handleErrors() {
defer sp.wg.Done()
for err := range sp.producer.Errors() {
- expectation := err.Msg.Metadata.(chan *ProducerError)
+ expectation := err.Msg.expectation
expectation <- err
}
}
diff --git a/vendor/github.com/Shopify/sarama/utils.go b/vendor/github.com/Shopify/sarama/utils.go
index 702e226270..1bb00d761a 100644
--- a/vendor/github.com/Shopify/sarama/utils.go
+++ b/vendor/github.com/Shopify/sarama/utils.go
@@ -155,6 +155,7 @@ var (
V0_11_0_2 = newKafkaVersion(0, 11, 0, 2)
V1_0_0_0 = newKafkaVersion(1, 0, 0, 0)
V1_1_0_0 = newKafkaVersion(1, 1, 0, 0)
+ V2_0_0_0 = newKafkaVersion(2, 0, 0, 0)
SupportedVersions = []KafkaVersion{
V0_8_2_0,
@@ -173,9 +174,10 @@ var (
V0_11_0_2,
V1_0_0_0,
V1_1_0_0,
+ V2_0_0_0,
}
MinVersion = V0_8_2_0
- MaxVersion = V1_1_0_0
+ MaxVersion = V2_0_0_0
)
func ParseKafkaVersion(s string) (KafkaVersion, error) {
diff --git a/vendor/github.com/aliyun/aliyun-oss-go-sdk/oss/bucket.go b/vendor/github.com/aliyun/aliyun-oss-go-sdk/oss/bucket.go
index 086f0127e1..45a1c7e90c 100644
--- a/vendor/github.com/aliyun/aliyun-oss-go-sdk/oss/bucket.go
+++ b/vendor/github.com/aliyun/aliyun-oss-go-sdk/oss/bucket.go
@@ -9,11 +9,11 @@ import (
"hash"
"hash/crc64"
"io"
- "io/ioutil"
"net/http"
"net/url"
"os"
"strconv"
+ "strings"
"time"
)
@@ -128,7 +128,8 @@ func (bucket Bucket) GetObject(objectKey string, options ...Option) (io.ReadClos
if err != nil {
return nil, err
}
- return result.Response.Body, nil
+
+ return result.Response, nil
}
// GetObjectToFile downloads the data to a local file.
@@ -147,7 +148,7 @@ func (bucket Bucket) GetObjectToFile(objectKey, filePath string, options ...Opti
if err != nil {
return err
}
- defer result.Response.Body.Close()
+ defer result.Response.Close()
// If the local file does not exist, create a new one. If it exists, overwrite it.
fd, err := os.OpenFile(tempFilePath, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, FilePermMode)
@@ -164,7 +165,12 @@ func (bucket Bucket) GetObjectToFile(objectKey, filePath string, options ...Opti
// Compares the CRC value
hasRange, _, _ := isOptionSet(options, HTTPHeaderRange)
- if bucket.getConfig().IsEnableCRC && !hasRange {
+ encodeOpt, _ := findOption(options, HTTPHeaderAcceptEncoding, nil)
+ acceptEncoding := ""
+ if encodeOpt != nil {
+ acceptEncoding = encodeOpt.(string)
+ }
+ if bucket.getConfig().IsEnableCRC && !hasRange && acceptEncoding != "gzip" {
result.Response.ClientCRC = result.ClientCRC.Sum64()
err = checkCRC(result.Response, "GetObjectToFile")
if err != nil {
@@ -185,7 +191,7 @@ func (bucket Bucket) GetObjectToFile(objectKey, filePath string, options ...Opti
// error it's nil if no error, otherwise it's an error object.
//
func (bucket Bucket) DoGetObject(request *GetObjectRequest, options []Option) (*GetObjectResult, error) {
- params := map[string]interface{}{}
+ params, _ := getRawParams(options)
resp, err := bucket.do("GET", request.ObjectKey, params, options, nil, nil)
if err != nil {
return nil, err
@@ -208,7 +214,7 @@ func (bucket Bucket) DoGetObject(request *GetObjectRequest, options []Option) (*
listener := getProgressListener(options)
contentLen, _ := strconv.ParseInt(resp.Headers.Get(HTTPHeaderContentLength), 10, 64)
- resp.Body = ioutil.NopCloser(TeeReader(resp.Body, crcCalc, contentLen, listener, nil))
+ resp.Body = TeeReader(resp.Body, crcCalc, contentLen, listener, nil)
return result, nil
}
@@ -219,7 +225,7 @@ func (bucket Bucket) DoGetObject(request *GetObjectRequest, options []Option) (*
// destObjectKey the target object to copy.
// options options for copying an object. You can specify the conditions of copy. The valid conditions are CopySourceIfMatch,
// CopySourceIfNoneMatch, CopySourceIfModifiedSince, CopySourceIfUnmodifiedSince, MetadataDirective.
-// Also you can specify the target object's attributes, such as CacheControl, ContentDisposition, ContentEncoding, Expires,
+// Also you can specify the target object's attributes, such as CacheControl, ContentDisposition, ContentEncoding, Expires,
// ServerSideEncryption, ObjectACL, Meta. Refer to the link below for more details :
// https://help.aliyun.com/document_detail/oss/api-reference/object/CopyObject.html
//
@@ -303,7 +309,7 @@ func (bucket Bucket) copy(srcObjectKey, destBucketName, destObjectKey string, op
// reader io.Reader. The read instance for reading the data to append.
// appendPosition the start position to append.
// destObjectProperties the options for the first appending, such as CacheControl, ContentDisposition, ContentEncoding,
-// Expires, ServerSideEncryption, ObjectACL.
+// Expires, ServerSideEncryption, ObjectACL.
//
// int64 the next append position, it's valid when error is nil.
// error it's nil if no error, otherwise it's an error object.
@@ -464,7 +470,7 @@ func (bucket Bucket) IsObjectExist(objectKey string) (bool, error) {
// options it contains all the filters for listing objects.
// It could specify a prefix filter on object keys, the max keys count to return and the object key marker and the delimiter for grouping object names.
// The key marker means the returned objects' key must be greater than it in lexicographic order.
-//
+//
// For example, if the bucket has 8 objects, my-object-1, my-object-11, my-object-2, my-object-21,
// my-object-22, my-object-3, my-object-31, my-object-32. If the prefix is my-object-2 (no other filters), then it returns
// my-object-2, my-object-21, my-object-22 three objects. If the marker is my-object-22 (no other filters), then it returns
@@ -474,9 +480,9 @@ func (bucket Bucket) IsObjectExist(objectKey string) (bool, error) {
// But if the delimiter is specified with '/', then it only returns that folder's files (no subfolder's files). The direct subfolders are in the commonPrefixes properties.
// For example, if the bucket has three objects fun/test.jpg, fun/movie/001.avi, fun/movie/007.avi. And if the prefix is "fun/", then it returns all three objects.
// But if the delimiter is '/', then only "fun/test.jpg" is returned as files and fun/movie/ is returned as common prefix.
-//
+//
// For common usage scenario, check out sample/list_object.go.
-//
+//
// ListObjectsResponse the return value after operation succeeds (only valid when error is nil).
//
func (bucket Bucket) ListObjects(options ...Option) (ListObjectsResult, error) {
@@ -802,7 +808,7 @@ func (bucket Bucket) GetObjectWithURL(signedURL string, options ...Option) (io.R
if err != nil {
return nil, err
}
- return result.Response.Body, nil
+ return result.Response, nil
}
// GetObjectToFileWithURL downloads the object into a local file with the signed URL.
@@ -821,7 +827,7 @@ func (bucket Bucket) GetObjectToFileWithURL(signedURL, filePath string, options
if err != nil {
return err
}
- defer result.Response.Body.Close()
+ defer result.Response.Close()
// If the file does not exist, create one. If exists, then overwrite it.
fd, err := os.OpenFile(tempFilePath, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, FilePermMode)
@@ -838,7 +844,13 @@ func (bucket Bucket) GetObjectToFileWithURL(signedURL, filePath string, options
// Compare the CRC value. If CRC values do not match, return error.
hasRange, _, _ := isOptionSet(options, HTTPHeaderRange)
- if bucket.getConfig().IsEnableCRC && !hasRange {
+ encodeOpt, _ := findOption(options, HTTPHeaderAcceptEncoding, nil)
+ acceptEncoding := ""
+ if encodeOpt != nil {
+ acceptEncoding = encodeOpt.(string)
+ }
+
+ if bucket.getConfig().IsEnableCRC && !hasRange && acceptEncoding != "gzip" {
result.Response.ClientCRC = result.ClientCRC.Sum64()
err = checkCRC(result.Response, "GetObjectToFileWithURL")
if err != nil {
@@ -859,7 +871,7 @@ func (bucket Bucket) GetObjectToFileWithURL(signedURL, filePath string, options
// error it's nil if no error, otherwise it's an error object.
//
func (bucket Bucket) DoGetObjectWithURL(signedURL string, options []Option) (*GetObjectResult, error) {
- params := map[string]interface{}{}
+ params, _ := getRawParams(options)
resp, err := bucket.doURL("GET", signedURL, params, options, nil, nil)
if err != nil {
return nil, err
@@ -882,11 +894,39 @@ func (bucket Bucket) DoGetObjectWithURL(signedURL string, options []Option) (*Ge
listener := getProgressListener(options)
contentLen, _ := strconv.ParseInt(resp.Headers.Get(HTTPHeaderContentLength), 10, 64)
- resp.Body = ioutil.NopCloser(TeeReader(resp.Body, crcCalc, contentLen, listener, nil))
+ resp.Body = TeeReader(resp.Body, crcCalc, contentLen, listener, nil)
return result, nil
}
+//
+// ProcessObject apply process on the specified image file.
+//
+// The supported process includes resize, rotate, crop, watermark, format,
+// udf, customized style, etc.
+//
+//
+// objectKey object key to process.
+// process process string, such as "image/resize,w_100|sys/saveas,o_dGVzdC5qcGc,b_dGVzdA"
+//
+// error it's nil if no error, otherwise it's an error object.
+//
+func (bucket Bucket) ProcessObject(objectKey string, process string) (ProcessObjectResult, error) {
+ var out ProcessObjectResult
+ params := map[string]interface{}{}
+ params["x-oss-process"] = nil
+ processData := fmt.Sprintf("%v=%v", "x-oss-process", process)
+ data := strings.NewReader(processData)
+ resp, err := bucket.do("POST", objectKey, params, nil, data, nil)
+ if err != nil {
+ return out, err
+ }
+ defer resp.Body.Close()
+
+ err = jsonUnmarshal(resp.Body, &out)
+ return out, err
+}
+
// Private
func (bucket Bucket) do(method, objectName string, params map[string]interface{}, options []Option,
data io.Reader, listener ProgressListener) (*Response, error) {
diff --git a/vendor/github.com/aliyun/aliyun-oss-go-sdk/oss/conn.go b/vendor/github.com/aliyun/aliyun-oss-go-sdk/oss/conn.go
index 05b53359d2..ae2c4903ce 100644
--- a/vendor/github.com/aliyun/aliyun-oss-go-sdk/oss/conn.go
+++ b/vendor/github.com/aliyun/aliyun-oss-go-sdk/oss/conn.go
@@ -4,6 +4,7 @@ import (
"bytes"
"crypto/md5"
"encoding/base64"
+ "encoding/json"
"encoding/xml"
"fmt"
"hash"
@@ -26,7 +27,7 @@ type Conn struct {
client *http.Client
}
-var signKeyList = []string{"acl", "uploads", "location", "cors", "logging", "website", "referer", "lifecycle", "delete", "append", "tagging", "objectMeta", "uploadId", "partNumber", "security-token", "position", "img", "style", "styleName", "replication", "replicationProgress", "replicationLocation", "cname", "bucketInfo", "comp", "qos", "live", "status", "vod", "startTime", "endTime", "symlink", "x-oss-process", "response-content-type", "response-content-language", "response-expires", "response-cache-control", "response-content-disposition", "response-content-encoding", "udf", "udfName", "udfImage", "udfId", "udfImageDesc", "udfApplication", "comp", "udfApplicationLog", "restore"}
+var signKeyList = []string{"acl", "uploads", "location", "cors", "logging", "website", "referer", "lifecycle", "delete", "append", "tagging", "objectMeta", "uploadId", "partNumber", "security-token", "position", "img", "style", "styleName", "replication", "replicationProgress", "replicationLocation", "cname", "bucketInfo", "comp", "qos", "live", "status", "vod", "startTime", "endTime", "symlink", "x-oss-process", "response-content-type", "response-content-language", "response-expires", "response-cache-control", "response-content-disposition", "response-content-encoding", "udf", "udfName", "udfImage", "udfId", "udfImageDesc", "udfApplication", "comp", "udfApplicationLog", "restore", "callback", "callback-var"}
// init initializes Conn
func (conn *Conn) init(config *Config, urlMaker *urlMaker) error {
@@ -440,6 +441,14 @@ func xmlUnmarshal(body io.Reader, v interface{}) error {
return xml.Unmarshal(data, v)
}
+func jsonUnmarshal(body io.Reader, v interface{}) error {
+ data, err := ioutil.ReadAll(body)
+ if err != nil {
+ return err
+ }
+ return json.Unmarshal(data, v)
+}
+
// timeoutConn handles HTTP timeout
type timeoutConn struct {
conn net.Conn
@@ -524,7 +533,11 @@ func (um *urlMaker) Init(endpoint string, isCname bool, isProxy bool) {
host, _, err := net.SplitHostPort(um.NetLoc)
if err != nil {
host = um.NetLoc
+ if host[0] == '[' && host[len(host)-1] == ']' {
+ host = host[1 : len(host)-1]
+ }
}
+
ip := net.ParseIP(host)
if ip != nil {
um.Type = urlTypeIP
@@ -587,7 +600,7 @@ func (um urlMaker) buildURL(bucket, object string) (string, string) {
return host, path
}
-// getResource gets canonicalized resource
+// getResource gets canonicalized resource
func (um urlMaker) getResource(bucketName, objectName, subResource string) string {
if subResource != "" {
subResource = "?" + subResource
diff --git a/vendor/github.com/aliyun/aliyun-oss-go-sdk/oss/const.go b/vendor/github.com/aliyun/aliyun-oss-go-sdk/oss/const.go
index 92aea712e6..c83c90ca7f 100644
--- a/vendor/github.com/aliyun/aliyun-oss-go-sdk/oss/const.go
+++ b/vendor/github.com/aliyun/aliyun-oss-go-sdk/oss/const.go
@@ -106,6 +106,9 @@ const (
HTTPHeaderOssRequestID = "X-Oss-Request-Id"
HTTPHeaderOssCRC64 = "X-Oss-Hash-Crc64ecma"
HTTPHeaderOssSymlinkTarget = "X-Oss-Symlink-Target"
+ HTTPHeaderOssStorageClass = "X-Oss-Storage-Class"
+ HTTPHeaderOssCallback = "X-Oss-Callback"
+ HTTPHeaderOssCallbackVar = "X-Oss-Callback-Var"
)
// HTTP Param
@@ -123,10 +126,10 @@ const (
FilePermMode = os.FileMode(0664) // Default file permission
- TempFilePrefix = "oss-go-temp-" // Temp file prefix
- TempFileSuffix = ".temp" // Temp file suffix
+ TempFilePrefix = "oss-go-temp-" // Temp file prefix
+ TempFileSuffix = ".temp" // Temp file suffix
- CheckpointFileSuffix = ".cp" // Checkpoint file suffix
+ CheckpointFileSuffix = ".cp" // Checkpoint file suffix
- Version = "1.9.0" // Go SDK version
+ Version = "1.9.1" // Go SDK version
)
diff --git a/vendor/github.com/aliyun/aliyun-oss-go-sdk/oss/model.go b/vendor/github.com/aliyun/aliyun-oss-go-sdk/oss/model.go
index ee96f54334..51f1c31e3d 100644
--- a/vendor/github.com/aliyun/aliyun-oss-go-sdk/oss/model.go
+++ b/vendor/github.com/aliyun/aliyun-oss-go-sdk/oss/model.go
@@ -15,6 +15,14 @@ type Response struct {
ServerCRC uint64
}
+func (r *Response) Read(p []byte) (n int, err error) {
+ return r.Body.Read(p)
+}
+
+func (r *Response) Close() error {
+ return r.Body.Close()
+}
+
// PutObjectRequest is the request of DoPutObject
type PutObjectRequest struct {
ObjectKey string
diff --git a/vendor/github.com/aliyun/aliyun-oss-go-sdk/oss/multipart.go b/vendor/github.com/aliyun/aliyun-oss-go-sdk/oss/multipart.go
index 04d8754c13..27a42712f2 100644
--- a/vendor/github.com/aliyun/aliyun-oss-go-sdk/oss/multipart.go
+++ b/vendor/github.com/aliyun/aliyun-oss-go-sdk/oss/multipart.go
@@ -5,6 +5,7 @@ import (
"encoding/xml"
"io"
"net/http"
+ "net/url"
"os"
"sort"
"strconv"
@@ -13,7 +14,7 @@ import (
// InitiateMultipartUpload initializes multipart upload
//
// objectKey object name
-// options the object constricts for upload. The valid options are CacheControl, ContentDisposition, ContentEncoding, Expires,
+// options the object constricts for upload. The valid options are CacheControl, ContentDisposition, ContentEncoding, Expires,
// ServerSideEncryption, Meta, check out the following link:
// https://help.aliyun.com/document_detail/oss/api-reference/multipart-upload/InitiateMultipartUpload.html
//
@@ -151,7 +152,7 @@ func (bucket Bucket) UploadPartCopy(imur InitiateMultipartUploadResult, srcBucke
var out UploadPartCopyResult
var part UploadPart
- opts := []Option{CopySource(srcBucketName, srcObjectKey),
+ opts := []Option{CopySource(srcBucketName, url.QueryEscape(srcObjectKey)),
CopySourceRange(startPosition, partSize)}
opts = append(opts, options...)
params := map[string]interface{}{}
@@ -231,9 +232,16 @@ func (bucket Bucket) AbortMultipartUpload(imur InitiateMultipartUploadResult) er
// ListUploadedPartsResponse the return value if it succeeds, only valid when error is nil.
// error it's nil if the operation succeeds, otherwise it's an error object.
//
-func (bucket Bucket) ListUploadedParts(imur InitiateMultipartUploadResult) (ListUploadedPartsResult, error) {
+func (bucket Bucket) ListUploadedParts(imur InitiateMultipartUploadResult, options ...Option) (ListUploadedPartsResult, error) {
var out ListUploadedPartsResult
+ options = append(options, EncodingType("url"))
+
params := map[string]interface{}{}
+ params, err := getRawParams(options)
+ if err != nil {
+ return out, err
+ }
+
params["uploadId"] = imur.UploadID
resp, err := bucket.do("GET", imur.Key, params, nil, nil, nil)
if err != nil {
@@ -242,6 +250,10 @@ func (bucket Bucket) ListUploadedParts(imur InitiateMultipartUploadResult) (List
defer resp.Body.Close()
err = xmlUnmarshal(resp.Body, &out)
+ if err != nil {
+ return out, err
+ }
+ err = decodeListUploadedPartsResult(&out)
return out, err
}
diff --git a/vendor/github.com/aliyun/aliyun-oss-go-sdk/oss/option.go b/vendor/github.com/aliyun/aliyun-oss-go-sdk/oss/option.go
index 77952947fd..5df6f94625 100644
--- a/vendor/github.com/aliyun/aliyun-oss-go-sdk/oss/option.go
+++ b/vendor/github.com/aliyun/aliyun-oss-go-sdk/oss/option.go
@@ -172,6 +172,21 @@ func Origin(value string) Option {
return setHeader(HTTPHeaderOrigin, value)
}
+// ObjectStorageClass is an option to set the storage class of object
+func ObjectStorageClass(storageClass StorageClassType) Option {
+ return setHeader(HTTPHeaderOssStorageClass, string(storageClass))
+}
+
+// Callback is an option to set callback values
+func Callback(callback string) Option {
+ return setHeader(HTTPHeaderOssCallback, callback)
+}
+
+// CallbackVar is an option to set callback user defined values
+func CallbackVar(callbackVar string) Option {
+ return setHeader(HTTPHeaderOssCallbackVar, callbackVar)
+}
+
// Delimiter is an option to set delimiler parameter
func Delimiter(value string) Option {
return addParam("delimiter", value)
@@ -212,6 +227,16 @@ func UploadIDMarker(value string) Option {
return addParam("upload-id-marker", value)
}
+// MaxParts is an option to set max-parts parameter
+func MaxParts(value int) Option {
+ return addParam("max-parts", strconv.Itoa(value))
+}
+
+// PartNumberMarker is an option to set part-number-marker parameter
+func PartNumberMarker(value int) Option {
+ return addParam("part-number-marker", strconv.Itoa(value))
+}
+
// DeleteObjectsQuiet false:DeleteObjects in verbose mode; true:DeleteObjects in quite mode. Default is false.
func DeleteObjectsQuiet(isQuiet bool) Option {
return addArg(deleteObjectsQuiet, isQuiet)
@@ -278,10 +303,11 @@ func ResponseContentEncoding(value string) Option {
return addParam("response-content-encoding", value)
}
-// Process is an option to set X-Oss-Process param
+// Process is an option to set x-oss-process param
func Process(value string) Option {
- return addParam("X-Oss-Process", value)
+ return addParam("x-oss-process", value)
}
+
func setHeader(key string, value interface{}) Option {
return func(params map[string]optionValue) error {
if value == nil {
diff --git a/vendor/github.com/aliyun/aliyun-oss-go-sdk/oss/progress.go b/vendor/github.com/aliyun/aliyun-oss-go-sdk/oss/progress.go
index 0d9ed089e0..b38d803fe1 100644
--- a/vendor/github.com/aliyun/aliyun-oss-go-sdk/oss/progress.go
+++ b/vendor/github.com/aliyun/aliyun-oss-go-sdk/oss/progress.go
@@ -62,7 +62,7 @@ type teeReader struct {
// corresponding writes to w. There is no internal buffering -
// the write must complete before the read completes.
// Any error encountered while writing is reported as a read error.
-func TeeReader(reader io.Reader, writer io.Writer, totalBytes int64, listener ProgressListener, tracker *readerTracker) io.Reader {
+func TeeReader(reader io.Reader, writer io.Writer, totalBytes int64, listener ProgressListener, tracker *readerTracker) io.ReadCloser {
return &teeReader{
reader: reader,
writer: writer,
@@ -103,3 +103,10 @@ func (t *teeReader) Read(p []byte) (n int, err error) {
return
}
+
+func (t *teeReader) Close() error {
+ if rc, ok := t.reader.(io.ReadCloser); ok {
+ return rc.Close()
+ }
+ return nil
+}
diff --git a/vendor/github.com/aliyun/aliyun-oss-go-sdk/oss/type.go b/vendor/github.com/aliyun/aliyun-oss-go-sdk/oss/type.go
index 1a450b007a..794f282316 100644
--- a/vendor/github.com/aliyun/aliyun-oss-go-sdk/oss/type.go
+++ b/vendor/github.com/aliyun/aliyun-oss-go-sdk/oss/type.go
@@ -363,6 +363,14 @@ type UncompletedUpload struct {
Initiated time.Time `xml:"Initiated"` // Initialization time in the format such as 2012-02-23T04:18:23.000Z
}
+// ProcessObjectResult defines result object of ProcessObject
+type ProcessObjectResult struct {
+ Bucket string `json:"bucket"`
+ FileSize int `json:"fileSize"`
+ Object string `json:"object"`
+ Status string `json:"status"`
+}
+
// decodeDeleteObjectsResult decodes deleting objects result in URL encoding
func decodeDeleteObjectsResult(result *DeleteObjectsResult) error {
var err error
@@ -409,6 +417,16 @@ func decodeListObjectsResult(result *ListObjectsResult) error {
return nil
}
+// decodeListUploadedPartsResult decodes
+func decodeListUploadedPartsResult(result *ListUploadedPartsResult) error {
+ var err error
+ result.Key, err = url.QueryUnescape(result.Key)
+ if err != nil {
+ return err
+ }
+ return nil
+}
+
// decodeListMultipartUploadResult decodes list multipart upload result in URL encoding
func decodeListMultipartUploadResult(result *ListMultipartUploadResult) error {
var err error
diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/binary_protocol.go b/vendor/github.com/apache/thrift/lib/go/thrift/binary_protocol.go
index de0f6a7a5c..690d341111 100644
--- a/vendor/github.com/apache/thrift/lib/go/thrift/binary_protocol.go
+++ b/vendor/github.com/apache/thrift/lib/go/thrift/binary_protocol.go
@@ -21,7 +21,6 @@ package thrift
import (
"bytes"
- "context"
"encoding/binary"
"errors"
"fmt"
@@ -458,8 +457,8 @@ func (p *TBinaryProtocol) ReadBinary() ([]byte, error) {
return buf, NewTProtocolException(err)
}
-func (p *TBinaryProtocol) Flush(ctx context.Context) (err error) {
- return NewTProtocolException(p.trans.Flush(ctx))
+func (p *TBinaryProtocol) Flush() (err error) {
+ return NewTProtocolException(p.trans.Flush())
}
func (p *TBinaryProtocol) Skip(fieldType TType) (err error) {
diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/buffered_transport.go b/vendor/github.com/apache/thrift/lib/go/thrift/buffered_transport.go
index 96702061b2..b754f925d0 100644
--- a/vendor/github.com/apache/thrift/lib/go/thrift/buffered_transport.go
+++ b/vendor/github.com/apache/thrift/lib/go/thrift/buffered_transport.go
@@ -21,7 +21,6 @@ package thrift
import (
"bufio"
- "context"
)
type TBufferedTransportFactory struct {
@@ -79,12 +78,12 @@ func (p *TBufferedTransport) Write(b []byte) (int, error) {
return n, err
}
-func (p *TBufferedTransport) Flush(ctx context.Context) error {
+func (p *TBufferedTransport) Flush() error {
if err := p.ReadWriter.Flush(); err != nil {
p.ReadWriter.Writer.Reset(p.tp)
return err
}
- return p.tp.Flush(ctx)
+ return p.tp.Flush()
}
func (p *TBufferedTransport) RemainingBytes() (num_bytes uint64) {
diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/client.go b/vendor/github.com/apache/thrift/lib/go/thrift/client.go
index 28791ccd0c..8bdb53d8d9 100644
--- a/vendor/github.com/apache/thrift/lib/go/thrift/client.go
+++ b/vendor/github.com/apache/thrift/lib/go/thrift/client.go
@@ -1,13 +1,6 @@
package thrift
-import (
- "context"
- "fmt"
-)
-
-type TClient interface {
- Call(ctx context.Context, method string, args, result TStruct) error
-}
+import "fmt"
type TStandardClient struct {
seqId int32
@@ -23,7 +16,7 @@ func NewTStandardClient(inputProtocol, outputProtocol TProtocol) *TStandardClien
}
}
-func (p *TStandardClient) Send(ctx context.Context, oprot TProtocol, seqId int32, method string, args TStruct) error {
+func (p *TStandardClient) Send(oprot TProtocol, seqId int32, method string, args TStruct) error {
if err := oprot.WriteMessageBegin(method, CALL, seqId); err != nil {
return err
}
@@ -33,7 +26,7 @@ func (p *TStandardClient) Send(ctx context.Context, oprot TProtocol, seqId int32
if err := oprot.WriteMessageEnd(); err != nil {
return err
}
- return oprot.Flush(ctx)
+ return oprot.Flush()
}
func (p *TStandardClient) Recv(iprot TProtocol, seqId int32, method string, result TStruct) error {
@@ -68,11 +61,11 @@ func (p *TStandardClient) Recv(iprot TProtocol, seqId int32, method string, resu
return iprot.ReadMessageEnd()
}
-func (p *TStandardClient) Call(ctx context.Context, method string, args, result TStruct) error {
+func (p *TStandardClient) call(method string, args, result TStruct) error {
p.seqId++
seqId := p.seqId
- if err := p.Send(ctx, p.oprot, seqId, method, args); err != nil {
+ if err := p.Send(p.oprot, seqId, method, args); err != nil {
return err
}
diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/client_go17.go b/vendor/github.com/apache/thrift/lib/go/thrift/client_go17.go
new file mode 100644
index 0000000000..15c1c52ca6
--- /dev/null
+++ b/vendor/github.com/apache/thrift/lib/go/thrift/client_go17.go
@@ -0,0 +1,13 @@
+// +build go1.7
+
+package thrift
+
+import "context"
+
+type TClient interface {
+ Call(ctx context.Context, method string, args, result TStruct) error
+}
+
+func (p *TStandardClient) Call(ctx context.Context, method string, args, result TStruct) error {
+ return p.call(method, args, result)
+}
diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/client_pre_go17.go b/vendor/github.com/apache/thrift/lib/go/thrift/client_pre_go17.go
new file mode 100644
index 0000000000..d2e99ef2af
--- /dev/null
+++ b/vendor/github.com/apache/thrift/lib/go/thrift/client_pre_go17.go
@@ -0,0 +1,13 @@
+// +build !go1.7
+
+package thrift
+
+import "golang.org/x/net/context"
+
+type TClient interface {
+ Call(ctx context.Context, method string, args, result TStruct) error
+}
+
+func (p *TStandardClient) Call(ctx context.Context, method string, args, result TStruct) error {
+ return p.call(method, args, result)
+}
diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/common_test_go17.go b/vendor/github.com/apache/thrift/lib/go/thrift/common_test_go17.go
new file mode 100644
index 0000000000..2c729a2269
--- /dev/null
+++ b/vendor/github.com/apache/thrift/lib/go/thrift/common_test_go17.go
@@ -0,0 +1,32 @@
+// +build go1.7
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package thrift
+
+import "context"
+
+type mockProcessor struct {
+ ProcessFunc func(in, out TProtocol) (bool, TException)
+}
+
+func (m *mockProcessor) Process(ctx context.Context, in, out TProtocol) (bool, TException) {
+ return m.ProcessFunc(in, out)
+}
diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/common_test_pre_go17.go b/vendor/github.com/apache/thrift/lib/go/thrift/common_test_pre_go17.go
new file mode 100644
index 0000000000..e6d0c4d9af
--- /dev/null
+++ b/vendor/github.com/apache/thrift/lib/go/thrift/common_test_pre_go17.go
@@ -0,0 +1,32 @@
+// +build !go1.7
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package thrift
+
+import "golang.org/x/net/context"
+
+type mockProcessor struct {
+ ProcessFunc func(in, out TProtocol) (bool, TException)
+}
+
+func (m *mockProcessor) Process(ctx context.Context, in, out TProtocol) (bool, TException) {
+ return m.ProcessFunc(in, out)
+}
diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/compact_protocol.go b/vendor/github.com/apache/thrift/lib/go/thrift/compact_protocol.go
index 66fbf5c335..0bc5fddeb3 100644
--- a/vendor/github.com/apache/thrift/lib/go/thrift/compact_protocol.go
+++ b/vendor/github.com/apache/thrift/lib/go/thrift/compact_protocol.go
@@ -20,7 +20,6 @@
package thrift
import (
- "context"
"encoding/binary"
"fmt"
"io"
@@ -600,8 +599,8 @@ func (p *TCompactProtocol) ReadBinary() (value []byte, err error) {
return buf, NewTProtocolException(e)
}
-func (p *TCompactProtocol) Flush(ctx context.Context) (err error) {
- return NewTProtocolException(p.trans.Flush(ctx))
+func (p *TCompactProtocol) Flush() (err error) {
+ return NewTProtocolException(p.trans.Flush())
}
func (p *TCompactProtocol) Skip(fieldType TType) (err error) {
@@ -807,7 +806,7 @@ func (p *TCompactProtocol) getTType(t tCompactType) (TType, error) {
case COMPACT_STRUCT:
return STRUCT, nil
}
- return STOP, TException(fmt.Errorf("don't know what type: %v", t&0x0f))
+ return STOP, TException(fmt.Errorf("don't know what type: %s", t&0x0f))
}
// Given a TType value, find the appropriate TCompactProtocol.Types constant.
diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/debug_protocol.go b/vendor/github.com/apache/thrift/lib/go/thrift/debug_protocol.go
index 57943e0f35..d37252cc61 100644
--- a/vendor/github.com/apache/thrift/lib/go/thrift/debug_protocol.go
+++ b/vendor/github.com/apache/thrift/lib/go/thrift/debug_protocol.go
@@ -20,7 +20,6 @@
package thrift
import (
- "context"
"log"
)
@@ -259,8 +258,8 @@ func (tdp *TDebugProtocol) Skip(fieldType TType) (err error) {
log.Printf("%sSkip(fieldType=%#v) (err=%#v)", tdp.LogPrefix, fieldType, err)
return
}
-func (tdp *TDebugProtocol) Flush(ctx context.Context) (err error) {
- err = tdp.Delegate.Flush(ctx)
+func (tdp *TDebugProtocol) Flush() (err error) {
+ err = tdp.Delegate.Flush()
log.Printf("%sFlush() (err=%#v)", tdp.LogPrefix, err)
return
}
diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/framed_transport.go b/vendor/github.com/apache/thrift/lib/go/thrift/framed_transport.go
index 81fa65aaae..60b1249915 100644
--- a/vendor/github.com/apache/thrift/lib/go/thrift/framed_transport.go
+++ b/vendor/github.com/apache/thrift/lib/go/thrift/framed_transport.go
@@ -22,7 +22,6 @@ package thrift
import (
"bufio"
"bytes"
- "context"
"encoding/binary"
"fmt"
"io"
@@ -136,7 +135,7 @@ func (p *TFramedTransport) WriteString(s string) (n int, err error) {
return p.buf.WriteString(s)
}
-func (p *TFramedTransport) Flush(ctx context.Context) error {
+func (p *TFramedTransport) Flush() error {
size := p.buf.Len()
buf := p.buffer[:4]
binary.BigEndian.PutUint32(buf, uint32(size))
@@ -152,7 +151,7 @@ func (p *TFramedTransport) Flush(ctx context.Context) error {
return NewTTransportExceptionFromError(err)
}
}
- err = p.transport.Flush(ctx)
+ err = p.transport.Flush()
return NewTTransportExceptionFromError(err)
}
diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/context.go b/vendor/github.com/apache/thrift/lib/go/thrift/go17.go
similarity index 98%
rename from vendor/github.com/apache/thrift/lib/go/thrift/context.go
rename to vendor/github.com/apache/thrift/lib/go/thrift/go17.go
index d15c1bcf89..e3b21c4b73 100644
--- a/vendor/github.com/apache/thrift/lib/go/thrift/context.go
+++ b/vendor/github.com/apache/thrift/lib/go/thrift/go17.go
@@ -1,3 +1,5 @@
+// +build go1.7
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/http_client.go b/vendor/github.com/apache/thrift/lib/go/thrift/http_client.go
index 5c82bf5387..33f2aa4b59 100644
--- a/vendor/github.com/apache/thrift/lib/go/thrift/http_client.go
+++ b/vendor/github.com/apache/thrift/lib/go/thrift/http_client.go
@@ -21,7 +21,6 @@ package thrift
import (
"bytes"
- "context"
"io"
"io/ioutil"
"net/http"
@@ -182,7 +181,7 @@ func (p *THttpClient) WriteString(s string) (n int, err error) {
return p.requestBuffer.WriteString(s)
}
-func (p *THttpClient) Flush(ctx context.Context) error {
+func (p *THttpClient) Flush() error {
// Close any previous response body to avoid leaking connections.
p.closeResponse()
@@ -191,9 +190,6 @@ func (p *THttpClient) Flush(ctx context.Context) error {
return NewTTransportExceptionFromError(err)
}
req.Header = p.header
- if ctx != nil {
- req = req.WithContext(ctx)
- }
response, err := p.client.Do(req)
if err != nil {
return NewTTransportExceptionFromError(err)
diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/http_transport.go b/vendor/github.com/apache/thrift/lib/go/thrift/http_transport.go
index 66f0f388a0..601855b926 100644
--- a/vendor/github.com/apache/thrift/lib/go/thrift/http_transport.go
+++ b/vendor/github.com/apache/thrift/lib/go/thrift/http_transport.go
@@ -26,18 +26,6 @@ import (
"strings"
)
-// NewThriftHandlerFunc is a function that create a ready to use Apache Thrift Handler function
-func NewThriftHandlerFunc(processor TProcessor,
- inPfactory, outPfactory TProtocolFactory) func(w http.ResponseWriter, r *http.Request) {
-
- return gz(func(w http.ResponseWriter, r *http.Request) {
- w.Header().Add("Content-Type", "application/x-thrift")
-
- transport := NewStreamTransport(r.Body, w)
- processor.Process(r.Context(), inPfactory.GetProtocol(transport), outPfactory.GetProtocol(transport))
- })
-}
-
// gz transparently compresses the HTTP response if the client supports it.
func gz(handler http.HandlerFunc) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/http_transport_go17.go b/vendor/github.com/apache/thrift/lib/go/thrift/http_transport_go17.go
new file mode 100644
index 0000000000..1313ac225b
--- /dev/null
+++ b/vendor/github.com/apache/thrift/lib/go/thrift/http_transport_go17.go
@@ -0,0 +1,38 @@
+// +build go1.7
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package thrift
+
+import (
+ "net/http"
+)
+
+// NewThriftHandlerFunc is a function that create a ready to use Apache Thrift Handler function
+func NewThriftHandlerFunc(processor TProcessor,
+ inPfactory, outPfactory TProtocolFactory) func(w http.ResponseWriter, r *http.Request) {
+
+ return gz(func(w http.ResponseWriter, r *http.Request) {
+ w.Header().Add("Content-Type", "application/x-thrift")
+
+ transport := NewStreamTransport(r.Body, w)
+ processor.Process(r.Context(), inPfactory.GetProtocol(transport), outPfactory.GetProtocol(transport))
+ })
+}
diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/http_transport_pre_go17.go b/vendor/github.com/apache/thrift/lib/go/thrift/http_transport_pre_go17.go
new file mode 100644
index 0000000000..13aa1c11d1
--- /dev/null
+++ b/vendor/github.com/apache/thrift/lib/go/thrift/http_transport_pre_go17.go
@@ -0,0 +1,40 @@
+// +build !go1.7
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package thrift
+
+import (
+ "net/http"
+
+ "golang.org/x/net/context"
+)
+
+// NewThriftHandlerFunc is a function that create a ready to use Apache Thrift Handler function
+func NewThriftHandlerFunc(processor TProcessor,
+ inPfactory, outPfactory TProtocolFactory) func(w http.ResponseWriter, r *http.Request) {
+
+ return gz(func(w http.ResponseWriter, r *http.Request) {
+ w.Header().Add("Content-Type", "application/x-thrift")
+
+ transport := NewStreamTransport(r.Body, w)
+ processor.Process(context.Background(), inPfactory.GetProtocol(transport), outPfactory.GetProtocol(transport))
+ })
+}
diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/iostream_transport.go b/vendor/github.com/apache/thrift/lib/go/thrift/iostream_transport.go
index fea93bceff..b18be81c46 100644
--- a/vendor/github.com/apache/thrift/lib/go/thrift/iostream_transport.go
+++ b/vendor/github.com/apache/thrift/lib/go/thrift/iostream_transport.go
@@ -21,7 +21,6 @@ package thrift
import (
"bufio"
- "context"
"io"
)
@@ -139,7 +138,7 @@ func (p *StreamTransport) Close() error {
}
// Flushes the underlying output stream if not null.
-func (p *StreamTransport) Flush(ctx context.Context) error {
+func (p *StreamTransport) Flush() error {
if p.Writer == nil {
return NewTTransportException(NOT_OPEN, "Cannot flush null outputStream")
}
diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/json_protocol.go b/vendor/github.com/apache/thrift/lib/go/thrift/json_protocol.go
index 7be685d43f..442fa9144d 100644
--- a/vendor/github.com/apache/thrift/lib/go/thrift/json_protocol.go
+++ b/vendor/github.com/apache/thrift/lib/go/thrift/json_protocol.go
@@ -20,7 +20,6 @@
package thrift
import (
- "context"
"encoding/base64"
"fmt"
)
@@ -439,10 +438,10 @@ func (p *TJSONProtocol) ReadBinary() ([]byte, error) {
return v, p.ParsePostValue()
}
-func (p *TJSONProtocol) Flush(ctx context.Context) (err error) {
+func (p *TJSONProtocol) Flush() (err error) {
err = p.writer.Flush()
if err == nil {
- err = p.trans.Flush(ctx)
+ err = p.trans.Flush()
}
return NewTProtocolException(err)
}
diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/memory_buffer.go b/vendor/github.com/apache/thrift/lib/go/thrift/memory_buffer.go
index 5936d27303..97a4edfa5d 100644
--- a/vendor/github.com/apache/thrift/lib/go/thrift/memory_buffer.go
+++ b/vendor/github.com/apache/thrift/lib/go/thrift/memory_buffer.go
@@ -21,7 +21,6 @@ package thrift
import (
"bytes"
- "context"
)
// Memory buffer-based implementation of the TTransport interface.
@@ -71,7 +70,7 @@ func (p *TMemoryBuffer) Close() error {
}
// Flushing a memory buffer is a no-op
-func (p *TMemoryBuffer) Flush(ctx context.Context) error {
+func (p *TMemoryBuffer) Flush() error {
return nil
}
diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/multiplexed_protocol.go b/vendor/github.com/apache/thrift/lib/go/thrift/multiplexed_protocol.go
index d028a30b33..b7f4f8a1cc 100644
--- a/vendor/github.com/apache/thrift/lib/go/thrift/multiplexed_protocol.go
+++ b/vendor/github.com/apache/thrift/lib/go/thrift/multiplexed_protocol.go
@@ -19,12 +19,6 @@
package thrift
-import (
- "context"
- "fmt"
- "strings"
-)
-
/*
TMultiplexedProtocol is a protocol-independent concrete decorator
that allows a Thrift client to communicate with a multiplexing Thrift server,
@@ -128,31 +122,6 @@ func (t *TMultiplexedProcessor) RegisterProcessor(name string, processor TProces
t.serviceProcessorMap[name] = processor
}
-func (t *TMultiplexedProcessor) Process(ctx context.Context, in, out TProtocol) (bool, TException) {
- name, typeId, seqid, err := in.ReadMessageBegin()
- if err != nil {
- return false, err
- }
- if typeId != CALL && typeId != ONEWAY {
- return false, fmt.Errorf("Unexpected message type %v", typeId)
- }
- //extract the service name
- v := strings.SplitN(name, MULTIPLEXED_SEPARATOR, 2)
- if len(v) != 2 {
- if t.DefaultProcessor != nil {
- smb := NewStoredMessageProtocol(in, name, typeId, seqid)
- return t.DefaultProcessor.Process(ctx, smb, out)
- }
- return false, fmt.Errorf("Service name not found in message name: %s. Did you forget to use a TMultiplexProtocol in your client?", name)
- }
- actualProcessor, ok := t.serviceProcessorMap[v[0]]
- if !ok {
- return false, fmt.Errorf("Service name not found: %s. Did you forget to call registerProcessor()?", v[0])
- }
- smb := NewStoredMessageProtocol(in, v[1], typeId, seqid)
- return actualProcessor.Process(ctx, smb, out)
-}
-
//Protocol that use stored message for ReadMessageBegin
type storedMessageProtocol struct {
TProtocol
diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/multiplexed_protocol_go17.go b/vendor/github.com/apache/thrift/lib/go/thrift/multiplexed_protocol_go17.go
new file mode 100644
index 0000000000..c71035e680
--- /dev/null
+++ b/vendor/github.com/apache/thrift/lib/go/thrift/multiplexed_protocol_go17.go
@@ -0,0 +1,53 @@
+// +build go1.7
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package thrift
+
+import (
+ "context"
+ "fmt"
+ "strings"
+)
+
+func (t *TMultiplexedProcessor) Process(ctx context.Context, in, out TProtocol) (bool, TException) {
+ name, typeId, seqid, err := in.ReadMessageBegin()
+ if err != nil {
+ return false, err
+ }
+ if typeId != CALL && typeId != ONEWAY {
+ return false, fmt.Errorf("Unexpected message type %v", typeId)
+ }
+ //extract the service name
+ v := strings.SplitN(name, MULTIPLEXED_SEPARATOR, 2)
+ if len(v) != 2 {
+ if t.DefaultProcessor != nil {
+ smb := NewStoredMessageProtocol(in, name, typeId, seqid)
+ return t.DefaultProcessor.Process(ctx, smb, out)
+ }
+ return false, fmt.Errorf("Service name not found in message name: %s. Did you forget to use a TMultiplexProtocol in your client?", name)
+ }
+ actualProcessor, ok := t.serviceProcessorMap[v[0]]
+ if !ok {
+ return false, fmt.Errorf("Service name not found: %s. Did you forget to call registerProcessor()?", v[0])
+ }
+ smb := NewStoredMessageProtocol(in, v[1], typeId, seqid)
+ return actualProcessor.Process(ctx, smb, out)
+}
diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/multiplexed_protocol_pre_go17.go b/vendor/github.com/apache/thrift/lib/go/thrift/multiplexed_protocol_pre_go17.go
new file mode 100644
index 0000000000..5c27b38755
--- /dev/null
+++ b/vendor/github.com/apache/thrift/lib/go/thrift/multiplexed_protocol_pre_go17.go
@@ -0,0 +1,54 @@
+// +build !go1.7
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package thrift
+
+import (
+ "fmt"
+ "strings"
+
+ "golang.org/x/net/context"
+)
+
+func (t *TMultiplexedProcessor) Process(ctx context.Context, in, out TProtocol) (bool, TException) {
+ name, typeId, seqid, err := in.ReadMessageBegin()
+ if err != nil {
+ return false, err
+ }
+ if typeId != CALL && typeId != ONEWAY {
+ return false, fmt.Errorf("Unexpected message type %v", typeId)
+ }
+ //extract the service name
+ v := strings.SplitN(name, MULTIPLEXED_SEPARATOR, 2)
+ if len(v) != 2 {
+ if t.DefaultProcessor != nil {
+ smb := NewStoredMessageProtocol(in, name, typeId, seqid)
+ return t.DefaultProcessor.Process(ctx, smb, out)
+ }
+ return false, fmt.Errorf("Service name not found in message name: %s. Did you forget to use a TMultiplexProtocol in your client?", name)
+ }
+ actualProcessor, ok := t.serviceProcessorMap[v[0]]
+ if !ok {
+ return false, fmt.Errorf("Service name not found: %s. Did you forget to call registerProcessor()?", v[0])
+ }
+ smb := NewStoredMessageProtocol(in, v[1], typeId, seqid)
+ return actualProcessor.Process(ctx, smb, out)
+}
diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/pre_go17.go b/vendor/github.com/apache/thrift/lib/go/thrift/pre_go17.go
new file mode 100644
index 0000000000..cb564b8dbd
--- /dev/null
+++ b/vendor/github.com/apache/thrift/lib/go/thrift/pre_go17.go
@@ -0,0 +1,26 @@
+// +build !go1.7
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package thrift
+
+import "golang.org/x/net/context"
+
+var defaultCtx = context.Background()
diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/processor.go b/vendor/github.com/apache/thrift/lib/go/thrift/processor.go
new file mode 100644
index 0000000000..566aaaf718
--- /dev/null
+++ b/vendor/github.com/apache/thrift/lib/go/thrift/processor.go
@@ -0,0 +1,34 @@
+// +build !go1.7
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package thrift
+
+import "golang.org/x/net/context"
+
+// A processor is a generic object which operates upon an input stream and
+// writes to some output stream.
+type TProcessor interface {
+ Process(ctx context.Context, in, out TProtocol) (bool, TException)
+}
+
+type TProcessorFunction interface {
+ Process(ctx context.Context, seqId int32, in, out TProtocol) (bool, TException)
+}
diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/processor_factory.go b/vendor/github.com/apache/thrift/lib/go/thrift/processor_factory.go
index e4b132b307..9d645df244 100644
--- a/vendor/github.com/apache/thrift/lib/go/thrift/processor_factory.go
+++ b/vendor/github.com/apache/thrift/lib/go/thrift/processor_factory.go
@@ -19,18 +19,6 @@
package thrift
-import "context"
-
-// A processor is a generic object which operates upon an input stream and
-// writes to some output stream.
-type TProcessor interface {
- Process(ctx context.Context, in, out TProtocol) (bool, TException)
-}
-
-type TProcessorFunction interface {
- Process(ctx context.Context, seqId int32, in, out TProtocol) (bool, TException)
-}
-
// The default processor factory just returns a singleton
// instance.
type TProcessorFactory interface {
diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/processor_go17.go b/vendor/github.com/apache/thrift/lib/go/thrift/processor_go17.go
new file mode 100644
index 0000000000..fb0b165dcc
--- /dev/null
+++ b/vendor/github.com/apache/thrift/lib/go/thrift/processor_go17.go
@@ -0,0 +1,34 @@
+// +build go1.7
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package thrift
+
+import "context"
+
+// A processor is a generic object which operates upon an input stream and
+// writes to some output stream.
+type TProcessor interface {
+ Process(ctx context.Context, in, out TProtocol) (bool, TException)
+}
+
+type TProcessorFunction interface {
+ Process(ctx context.Context, seqId int32, in, out TProtocol) (bool, TException)
+}
diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/protocol.go b/vendor/github.com/apache/thrift/lib/go/thrift/protocol.go
index 615b7a4a8f..25e6d24b90 100644
--- a/vendor/github.com/apache/thrift/lib/go/thrift/protocol.go
+++ b/vendor/github.com/apache/thrift/lib/go/thrift/protocol.go
@@ -20,7 +20,6 @@
package thrift
import (
- "context"
"errors"
"fmt"
)
@@ -75,7 +74,7 @@ type TProtocol interface {
ReadBinary() (value []byte, err error)
Skip(fieldType TType) (err error)
- Flush(ctx context.Context) (err error)
+ Flush() (err error)
Transport() TTransport
}
diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/serializer.go b/vendor/github.com/apache/thrift/lib/go/thrift/serializer.go
index 1ff4d37545..7712229990 100644
--- a/vendor/github.com/apache/thrift/lib/go/thrift/serializer.go
+++ b/vendor/github.com/apache/thrift/lib/go/thrift/serializer.go
@@ -19,10 +19,6 @@
package thrift
-import (
- "context"
-)
-
type TSerializer struct {
Transport *TMemoryBuffer
Protocol TProtocol
@@ -42,35 +38,35 @@ func NewTSerializer() *TSerializer {
protocol}
}
-func (t *TSerializer) WriteString(ctx context.Context, msg TStruct) (s string, err error) {
+func (t *TSerializer) WriteString(msg TStruct) (s string, err error) {
t.Transport.Reset()
if err = msg.Write(t.Protocol); err != nil {
return
}
- if err = t.Protocol.Flush(ctx); err != nil {
+ if err = t.Protocol.Flush(); err != nil {
return
}
- if err = t.Transport.Flush(ctx); err != nil {
+ if err = t.Transport.Flush(); err != nil {
return
}
return t.Transport.String(), nil
}
-func (t *TSerializer) Write(ctx context.Context, msg TStruct) (b []byte, err error) {
+func (t *TSerializer) Write(msg TStruct) (b []byte, err error) {
t.Transport.Reset()
if err = msg.Write(t.Protocol); err != nil {
return
}
- if err = t.Protocol.Flush(ctx); err != nil {
+ if err = t.Protocol.Flush(); err != nil {
return
}
- if err = t.Transport.Flush(ctx); err != nil {
+ if err = t.Transport.Flush(); err != nil {
return
}
diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/simple_json_protocol.go b/vendor/github.com/apache/thrift/lib/go/thrift/simple_json_protocol.go
index 2e8a71112a..7353322318 100644
--- a/vendor/github.com/apache/thrift/lib/go/thrift/simple_json_protocol.go
+++ b/vendor/github.com/apache/thrift/lib/go/thrift/simple_json_protocol.go
@@ -22,7 +22,6 @@ package thrift
import (
"bufio"
"bytes"
- "context"
"encoding/base64"
"encoding/json"
"fmt"
@@ -553,7 +552,7 @@ func (p *TSimpleJSONProtocol) ReadBinary() ([]byte, error) {
return v, p.ParsePostValue()
}
-func (p *TSimpleJSONProtocol) Flush(ctx context.Context) (err error) {
+func (p *TSimpleJSONProtocol) Flush() (err error) {
return NewTProtocolException(p.writer.Flush())
}
@@ -1065,7 +1064,7 @@ func (p *TSimpleJSONProtocol) ParseListEnd() error {
for _, char := range line {
switch char {
default:
- e := fmt.Errorf("Expecting end of list \"]\", but found: \"%v\"", line)
+ e := fmt.Errorf("Expecting end of list \"]\", but found: \"", line, "\"")
return NewTProtocolExceptionWithType(INVALID_DATA, e)
case ' ', '\n', '\r', '\t', rune(JSON_RBRACKET[0]):
break
diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/simple_server.go b/vendor/github.com/apache/thrift/lib/go/thrift/simple_server.go
index 6035802516..37081bd835 100644
--- a/vendor/github.com/apache/thrift/lib/go/thrift/simple_server.go
+++ b/vendor/github.com/apache/thrift/lib/go/thrift/simple_server.go
@@ -125,38 +125,26 @@ func (p *TSimpleServer) Listen() error {
return p.serverTransport.Listen()
}
-func (p *TSimpleServer) innerAccept() (int32, error) {
- client, err := p.serverTransport.Accept()
- p.mu.Lock()
- defer p.mu.Unlock()
- closed := atomic.LoadInt32(&p.closed)
- if closed != 0 {
- return closed, nil
- }
- if err != nil {
- return 0, err
- }
- if client != nil {
- p.wg.Add(1)
- go func() {
- defer p.wg.Done()
- if err := p.processRequests(client); err != nil {
- log.Println("error processing request:", err)
- }
- }()
- }
- return 0, nil
-}
-
func (p *TSimpleServer) AcceptLoop() error {
for {
- closed, err := p.innerAccept()
+ client, err := p.serverTransport.Accept()
+ p.mu.Lock()
+ if atomic.LoadInt32(&p.closed) != 0 {
+ return nil
+ }
if err != nil {
return err
}
- if closed != 0 {
- return nil
+ if client != nil {
+ p.wg.Add(1)
+ go func() {
+ defer p.wg.Done()
+ if err := p.processRequests(client); err != nil {
+ log.Println("error processing request:", err)
+ }
+ }()
}
+ p.mu.Unlock()
}
}
diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/socket.go b/vendor/github.com/apache/thrift/lib/go/thrift/socket.go
index 8854279651..383b1fe3e9 100644
--- a/vendor/github.com/apache/thrift/lib/go/thrift/socket.go
+++ b/vendor/github.com/apache/thrift/lib/go/thrift/socket.go
@@ -20,7 +20,6 @@
package thrift
import (
- "context"
"net"
"time"
)
@@ -149,7 +148,7 @@ func (p *TSocket) Write(buf []byte) (int, error) {
return p.conn.Write(buf)
}
-func (p *TSocket) Flush(ctx context.Context) error {
+func (p *TSocket) Flush() error {
return nil
}
diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/ssl_socket.go b/vendor/github.com/apache/thrift/lib/go/thrift/ssl_socket.go
index ba63377263..c3bd72cc46 100644
--- a/vendor/github.com/apache/thrift/lib/go/thrift/ssl_socket.go
+++ b/vendor/github.com/apache/thrift/lib/go/thrift/ssl_socket.go
@@ -20,7 +20,6 @@
package thrift
import (
- "context"
"crypto/tls"
"net"
"time"
@@ -159,7 +158,7 @@ func (p *TSSLSocket) Write(buf []byte) (int, error) {
return p.conn.Write(buf)
}
-func (p *TSSLSocket) Flush(ctx context.Context) error {
+func (p *TSSLSocket) Flush() error {
return nil
}
diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/transport.go b/vendor/github.com/apache/thrift/lib/go/thrift/transport.go
index ba2738a8df..70a85a8489 100644
--- a/vendor/github.com/apache/thrift/lib/go/thrift/transport.go
+++ b/vendor/github.com/apache/thrift/lib/go/thrift/transport.go
@@ -20,7 +20,6 @@
package thrift
import (
- "context"
"errors"
"io"
)
@@ -31,10 +30,6 @@ type Flusher interface {
Flush() (err error)
}
-type ContextFlusher interface {
- Flush(ctx context.Context) (err error)
-}
-
type ReadSizeProvider interface {
RemainingBytes() (num_bytes uint64)
}
@@ -42,7 +37,7 @@ type ReadSizeProvider interface {
// Encapsulates the I/O layer
type TTransport interface {
io.ReadWriteCloser
- ContextFlusher
+ Flusher
ReadSizeProvider
// Opens the transport for communication
@@ -65,6 +60,6 @@ type TRichTransport interface {
io.ByteReader
io.ByteWriter
stringWriter
- ContextFlusher
+ Flusher
ReadSizeProvider
}
diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/zlib_transport.go b/vendor/github.com/apache/thrift/lib/go/thrift/zlib_transport.go
index f3d42673af..f2f0732221 100644
--- a/vendor/github.com/apache/thrift/lib/go/thrift/zlib_transport.go
+++ b/vendor/github.com/apache/thrift/lib/go/thrift/zlib_transport.go
@@ -21,7 +21,6 @@ package thrift
import (
"compress/zlib"
- "context"
"io"
"log"
)
@@ -92,11 +91,11 @@ func (z *TZlibTransport) Close() error {
}
// Flush flushes the writer and its underlying transport.
-func (z *TZlibTransport) Flush(ctx context.Context) error {
+func (z *TZlibTransport) Flush() error {
if err := z.writer.Flush(); err != nil {
return err
}
- return z.transport.Flush(ctx)
+ return z.transport.Flush()
}
// IsOpen returns true if the transport is open
diff --git a/vendor/github.com/aws/aws-sdk-go/aws/config.go b/vendor/github.com/aws/aws-sdk-go/aws/config.go
index 5421b5d4e9..58c89fa0d1 100644
--- a/vendor/github.com/aws/aws-sdk-go/aws/config.go
+++ b/vendor/github.com/aws/aws-sdk-go/aws/config.go
@@ -18,7 +18,7 @@ const UseServiceDefaultRetries = -1
type RequestRetryer interface{}
// A Config provides service configuration for service clients. By default,
-// all clients will use the defaults.DefaultConfig tructure.
+// all clients will use the defaults.DefaultConfig structure.
//
// // Create Session with MaxRetry configuration to be shared by multiple
// // service clients.
diff --git a/vendor/github.com/aws/aws-sdk-go/aws/csm/metric.go b/vendor/github.com/aws/aws-sdk-go/aws/csm/metric.go
index 4b0d630e4c..6f57024d74 100644
--- a/vendor/github.com/aws/aws-sdk-go/aws/csm/metric.go
+++ b/vendor/github.com/aws/aws-sdk-go/aws/csm/metric.go
@@ -48,4 +48,6 @@ type metric struct {
DNSLatency *int `json:"DnsLatency,omitempty"`
TCPLatency *int `json:"TcpLatency,omitempty"`
SSLLatency *int `json:"SslLatency,omitempty"`
+
+ MaxRetriesExceeded *int `json:"MaxRetriesExceeded,omitempty"`
}
diff --git a/vendor/github.com/aws/aws-sdk-go/aws/csm/reporter.go b/vendor/github.com/aws/aws-sdk-go/aws/csm/reporter.go
index 11082e5ed6..1186184424 100644
--- a/vendor/github.com/aws/aws-sdk-go/aws/csm/reporter.go
+++ b/vendor/github.com/aws/aws-sdk-go/aws/csm/reporter.go
@@ -112,14 +112,16 @@ func (rep *Reporter) sendAPICallMetric(r *request.Request) {
now := time.Now()
m := metric{
- ClientID: aws.String(rep.clientID),
- API: aws.String(r.Operation.Name),
- Service: aws.String(r.ClientInfo.ServiceID),
- Timestamp: (*metricTime)(&now),
- Type: aws.String("ApiCall"),
- AttemptCount: aws.Int(r.RetryCount + 1),
- Latency: aws.Int(int(time.Now().Sub(r.Time) / time.Millisecond)),
- XAmzRequestID: aws.String(r.RequestID),
+ ClientID: aws.String(rep.clientID),
+ API: aws.String(r.Operation.Name),
+ Service: aws.String(r.ClientInfo.ServiceID),
+ Timestamp: (*metricTime)(&now),
+ Type: aws.String("ApiCall"),
+ AttemptCount: aws.Int(r.RetryCount + 1),
+ Region: r.Config.Region,
+ Latency: aws.Int(int(time.Now().Sub(r.Time) / time.Millisecond)),
+ XAmzRequestID: aws.String(r.RequestID),
+ MaxRetriesExceeded: aws.Int(boolIntValue(r.RetryCount >= r.MaxRetries())),
}
// TODO: Probably want to figure something out for logging dropped
@@ -229,3 +231,12 @@ func (rep *Reporter) InjectHandlers(handlers *request.Handlers) {
handlers.AfterRetry.PushFrontNamed(apiCallAttemptHandler)
}
+
+// boolIntValue return 1 for true and 0 for false.
+func boolIntValue(b bool) int {
+ if b {
+ return 1
+ }
+
+ return 0
+}
diff --git a/vendor/github.com/aws/aws-sdk-go/aws/request/validation.go b/vendor/github.com/aws/aws-sdk-go/aws/request/validation.go
index 4012462282..bcfd947a3d 100644
--- a/vendor/github.com/aws/aws-sdk-go/aws/request/validation.go
+++ b/vendor/github.com/aws/aws-sdk-go/aws/request/validation.go
@@ -17,6 +17,10 @@ const (
ParamMinValueErrCode = "ParamMinValueError"
// ParamMinLenErrCode is the error code for fields without enough elements.
ParamMinLenErrCode = "ParamMinLenError"
+
+ // ParamFormatErrCode is the error code for a field with invalid
+ // format or characters.
+ ParamFormatErrCode = "ParamFormatInvalidError"
)
// Validator provides a way for types to perform validation logic on their
@@ -232,3 +236,26 @@ func NewErrParamMinLen(field string, min int) *ErrParamMinLen {
func (e *ErrParamMinLen) MinLen() int {
return e.min
}
+
+// An ErrParamFormat represents a invalid format parameter error.
+type ErrParamFormat struct {
+ errInvalidParam
+ format string
+}
+
+// NewErrParamFormat creates a new invalid format parameter error.
+func NewErrParamFormat(field string, format, value string) *ErrParamFormat {
+ return &ErrParamFormat{
+ errInvalidParam: errInvalidParam{
+ code: ParamFormatErrCode,
+ field: field,
+ msg: fmt.Sprintf("format %v, %v", format, value),
+ },
+ format: format,
+ }
+}
+
+// Format returns the field's required format.
+func (e *ErrParamFormat) Format() string {
+ return e.format
+}
diff --git a/vendor/github.com/aws/aws-sdk-go/aws/version.go b/vendor/github.com/aws/aws-sdk-go/aws/version.go
index be84dd516e..29112cbbd9 100644
--- a/vendor/github.com/aws/aws-sdk-go/aws/version.go
+++ b/vendor/github.com/aws/aws-sdk-go/aws/version.go
@@ -5,4 +5,4 @@ package aws
const SDKName = "aws-sdk-go"
// SDKVersion is the version of this SDK
-const SDKVersion = "1.15.43"
+const SDKVersion = "1.15.52"
diff --git a/vendor/github.com/aws/aws-sdk-go/private/protocol/host.go b/vendor/github.com/aws/aws-sdk-go/private/protocol/host.go
new file mode 100644
index 0000000000..f06f44ee1c
--- /dev/null
+++ b/vendor/github.com/aws/aws-sdk-go/private/protocol/host.go
@@ -0,0 +1,21 @@
+package protocol
+
+// ValidHostLabel returns if the label is a valid RFC 1123 Section 2.1 domain
+// host label name.
+func ValidHostLabel(label string) bool {
+ if l := len(label); l == 0 || l > 63 {
+ return false
+ }
+ for _, r := range label {
+ switch {
+ case r >= '0' && r <= '9':
+ case r >= 'A' && r <= 'Z':
+ case r >= 'a' && r <= 'z':
+ case r == '-':
+ default:
+ return false
+ }
+ }
+
+ return true
+}
diff --git a/vendor/github.com/aws/aws-sdk-go/service/ec2/api.go b/vendor/github.com/aws/aws-sdk-go/service/ec2/api.go
index 5d4ffc3d48..6d21aada3b 100644
--- a/vendor/github.com/aws/aws-sdk-go/service/ec2/api.go
+++ b/vendor/github.com/aws/aws-sdk-go/service/ec2/api.go
@@ -18,7 +18,7 @@ const opAcceptReservedInstancesExchangeQuote = "AcceptReservedInstancesExchangeQ
// AcceptReservedInstancesExchangeQuoteRequest generates a "aws/request.Request" representing the
// client's request for the AcceptReservedInstancesExchangeQuote operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -93,7 +93,7 @@ const opAcceptVpcEndpointConnections = "AcceptVpcEndpointConnections"
// AcceptVpcEndpointConnectionsRequest generates a "aws/request.Request" representing the
// client's request for the AcceptVpcEndpointConnections operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -168,7 +168,7 @@ const opAcceptVpcPeeringConnection = "AcceptVpcPeeringConnection"
// AcceptVpcPeeringConnectionRequest generates a "aws/request.Request" representing the
// client's request for the AcceptVpcPeeringConnection operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -248,7 +248,7 @@ const opAllocateAddress = "AllocateAddress"
// AllocateAddressRequest generates a "aws/request.Request" representing the
// client's request for the AllocateAddress operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -338,7 +338,7 @@ const opAllocateHosts = "AllocateHosts"
// AllocateHostsRequest generates a "aws/request.Request" representing the
// client's request for the AllocateHosts operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -413,7 +413,7 @@ const opAssignIpv6Addresses = "AssignIpv6Addresses"
// AssignIpv6AddressesRequest generates a "aws/request.Request" representing the
// client's request for the AssignIpv6Addresses operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -494,7 +494,7 @@ const opAssignPrivateIpAddresses = "AssignPrivateIpAddresses"
// AssignPrivateIpAddressesRequest generates a "aws/request.Request" representing the
// client's request for the AssignPrivateIpAddresses operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -580,7 +580,7 @@ const opAssociateAddress = "AssociateAddress"
// AssociateAddressRequest generates a "aws/request.Request" representing the
// client's request for the AssociateAddress operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -678,7 +678,7 @@ const opAssociateDhcpOptions = "AssociateDhcpOptions"
// AssociateDhcpOptionsRequest generates a "aws/request.Request" representing the
// client's request for the AssociateDhcpOptions operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -765,7 +765,7 @@ const opAssociateIamInstanceProfile = "AssociateIamInstanceProfile"
// AssociateIamInstanceProfileRequest generates a "aws/request.Request" representing the
// client's request for the AssociateIamInstanceProfile operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -840,7 +840,7 @@ const opAssociateRouteTable = "AssociateRouteTable"
// AssociateRouteTableRequest generates a "aws/request.Request" representing the
// client's request for the AssociateRouteTable operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -921,7 +921,7 @@ const opAssociateSubnetCidrBlock = "AssociateSubnetCidrBlock"
// AssociateSubnetCidrBlockRequest generates a "aws/request.Request" representing the
// client's request for the AssociateSubnetCidrBlock operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -997,7 +997,7 @@ const opAssociateVpcCidrBlock = "AssociateVpcCidrBlock"
// AssociateVpcCidrBlockRequest generates a "aws/request.Request" representing the
// client's request for the AssociateVpcCidrBlock operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -1077,7 +1077,7 @@ const opAttachClassicLinkVpc = "AttachClassicLinkVpc"
// AttachClassicLinkVpcRequest generates a "aws/request.Request" representing the
// client's request for the AttachClassicLinkVpc operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -1162,7 +1162,7 @@ const opAttachInternetGateway = "AttachInternetGateway"
// AttachInternetGatewayRequest generates a "aws/request.Request" representing the
// client's request for the AttachInternetGateway operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -1240,7 +1240,7 @@ const opAttachNetworkInterface = "AttachNetworkInterface"
// AttachNetworkInterfaceRequest generates a "aws/request.Request" representing the
// client's request for the AttachNetworkInterface operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -1314,7 +1314,7 @@ const opAttachVolume = "AttachVolume"
// AttachVolumeRequest generates a "aws/request.Request" representing the
// client's request for the AttachVolume operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -1415,7 +1415,7 @@ const opAttachVpnGateway = "AttachVpnGateway"
// AttachVpnGatewayRequest generates a "aws/request.Request" representing the
// client's request for the AttachVpnGateway operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -1493,7 +1493,7 @@ const opAuthorizeSecurityGroupEgress = "AuthorizeSecurityGroupEgress"
// AuthorizeSecurityGroupEgressRequest generates a "aws/request.Request" representing the
// client's request for the AuthorizeSecurityGroupEgress operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -1586,7 +1586,7 @@ const opAuthorizeSecurityGroupIngress = "AuthorizeSecurityGroupIngress"
// AuthorizeSecurityGroupIngressRequest generates a "aws/request.Request" representing the
// client's request for the AuthorizeSecurityGroupIngress operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -1680,7 +1680,7 @@ const opBundleInstance = "BundleInstance"
// BundleInstanceRequest generates a "aws/request.Request" representing the
// client's request for the BundleInstance operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -1760,7 +1760,7 @@ const opCancelBundleTask = "CancelBundleTask"
// CancelBundleTaskRequest generates a "aws/request.Request" representing the
// client's request for the CancelBundleTask operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -1834,7 +1834,7 @@ const opCancelConversionTask = "CancelConversionTask"
// CancelConversionTaskRequest generates a "aws/request.Request" representing the
// client's request for the CancelConversionTask operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -1917,7 +1917,7 @@ const opCancelExportTask = "CancelExportTask"
// CancelExportTaskRequest generates a "aws/request.Request" representing the
// client's request for the CancelExportTask operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -1996,7 +1996,7 @@ const opCancelImportTask = "CancelImportTask"
// CancelImportTaskRequest generates a "aws/request.Request" representing the
// client's request for the CancelImportTask operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -2070,7 +2070,7 @@ const opCancelReservedInstancesListing = "CancelReservedInstancesListing"
// CancelReservedInstancesListingRequest generates a "aws/request.Request" representing the
// client's request for the CancelReservedInstancesListing operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -2148,7 +2148,7 @@ const opCancelSpotFleetRequests = "CancelSpotFleetRequests"
// CancelSpotFleetRequestsRequest generates a "aws/request.Request" representing the
// client's request for the CancelSpotFleetRequests operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -2229,7 +2229,7 @@ const opCancelSpotInstanceRequests = "CancelSpotInstanceRequests"
// CancelSpotInstanceRequestsRequest generates a "aws/request.Request" representing the
// client's request for the CancelSpotInstanceRequests operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -2306,7 +2306,7 @@ const opConfirmProductInstance = "ConfirmProductInstance"
// ConfirmProductInstanceRequest generates a "aws/request.Request" representing the
// client's request for the ConfirmProductInstance operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -2382,7 +2382,7 @@ const opCopyFpgaImage = "CopyFpgaImage"
// CopyFpgaImageRequest generates a "aws/request.Request" representing the
// client's request for the CopyFpgaImage operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -2456,7 +2456,7 @@ const opCopyImage = "CopyImage"
// CopyImageRequest generates a "aws/request.Request" representing the
// client's request for the CopyImage operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -2541,7 +2541,7 @@ const opCopySnapshot = "CopySnapshot"
// CopySnapshotRequest generates a "aws/request.Request" representing the
// client's request for the CopySnapshot operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -2634,7 +2634,7 @@ const opCreateCustomerGateway = "CreateCustomerGateway"
// CreateCustomerGatewayRequest generates a "aws/request.Request" representing the
// client's request for the CreateCustomerGateway operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -2732,7 +2732,7 @@ const opCreateDefaultSubnet = "CreateDefaultSubnet"
// CreateDefaultSubnetRequest generates a "aws/request.Request" representing the
// client's request for the CreateDefaultSubnet operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -2810,7 +2810,7 @@ const opCreateDefaultVpc = "CreateDefaultVpc"
// CreateDefaultVpcRequest generates a "aws/request.Request" representing the
// client's request for the CreateDefaultVpc operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -2896,7 +2896,7 @@ const opCreateDhcpOptions = "CreateDhcpOptions"
// CreateDhcpOptionsRequest generates a "aws/request.Request" representing the
// client's request for the CreateDhcpOptions operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -3008,7 +3008,7 @@ const opCreateEgressOnlyInternetGateway = "CreateEgressOnlyInternetGateway"
// CreateEgressOnlyInternetGatewayRequest generates a "aws/request.Request" representing the
// client's request for the CreateEgressOnlyInternetGateway operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -3085,7 +3085,7 @@ const opCreateFleet = "CreateFleet"
// CreateFleetRequest generates a "aws/request.Request" representing the
// client's request for the CreateFleet operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -3165,7 +3165,7 @@ const opCreateFlowLogs = "CreateFlowLogs"
// CreateFlowLogsRequest generates a "aws/request.Request" representing the
// client's request for the CreateFlowLogs operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -3254,7 +3254,7 @@ const opCreateFpgaImage = "CreateFpgaImage"
// CreateFpgaImageRequest generates a "aws/request.Request" representing the
// client's request for the CreateFpgaImage operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -3335,7 +3335,7 @@ const opCreateImage = "CreateImage"
// CreateImageRequest generates a "aws/request.Request" representing the
// client's request for the CreateImage operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -3418,7 +3418,7 @@ const opCreateInstanceExportTask = "CreateInstanceExportTask"
// CreateInstanceExportTaskRequest generates a "aws/request.Request" representing the
// client's request for the CreateInstanceExportTask operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -3497,7 +3497,7 @@ const opCreateInternetGateway = "CreateInternetGateway"
// CreateInternetGatewayRequest generates a "aws/request.Request" representing the
// client's request for the CreateInternetGateway operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -3575,7 +3575,7 @@ const opCreateKeyPair = "CreateKeyPair"
// CreateKeyPairRequest generates a "aws/request.Request" representing the
// client's request for the CreateKeyPair operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -3661,7 +3661,7 @@ const opCreateLaunchTemplate = "CreateLaunchTemplate"
// CreateLaunchTemplateRequest generates a "aws/request.Request" representing the
// client's request for the CreateLaunchTemplate operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -3737,7 +3737,7 @@ const opCreateLaunchTemplateVersion = "CreateLaunchTemplateVersion"
// CreateLaunchTemplateVersionRequest generates a "aws/request.Request" representing the
// client's request for the CreateLaunchTemplateVersion operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -3815,7 +3815,7 @@ const opCreateNatGateway = "CreateNatGateway"
// CreateNatGatewayRequest generates a "aws/request.Request" representing the
// client's request for the CreateNatGateway operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -3895,7 +3895,7 @@ const opCreateNetworkAcl = "CreateNetworkAcl"
// CreateNetworkAclRequest generates a "aws/request.Request" representing the
// client's request for the CreateNetworkAcl operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -3973,7 +3973,7 @@ const opCreateNetworkAclEntry = "CreateNetworkAclEntry"
// CreateNetworkAclEntryRequest generates a "aws/request.Request" representing the
// client's request for the CreateNetworkAclEntry operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -4065,7 +4065,7 @@ const opCreateNetworkInterface = "CreateNetworkInterface"
// CreateNetworkInterfaceRequest generates a "aws/request.Request" representing the
// client's request for the CreateNetworkInterface operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -4143,7 +4143,7 @@ const opCreateNetworkInterfacePermission = "CreateNetworkInterfacePermission"
// CreateNetworkInterfacePermissionRequest generates a "aws/request.Request" representing the
// client's request for the CreateNetworkInterfacePermission operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -4221,7 +4221,7 @@ const opCreatePlacementGroup = "CreatePlacementGroup"
// CreatePlacementGroupRequest generates a "aws/request.Request" representing the
// client's request for the CreatePlacementGroup operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -4305,7 +4305,7 @@ const opCreateReservedInstancesListing = "CreateReservedInstancesListing"
// CreateReservedInstancesListingRequest generates a "aws/request.Request" representing the
// client's request for the CreateReservedInstancesListing operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -4402,7 +4402,7 @@ const opCreateRoute = "CreateRoute"
// CreateRouteRequest generates a "aws/request.Request" representing the
// client's request for the CreateRoute operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -4495,7 +4495,7 @@ const opCreateRouteTable = "CreateRouteTable"
// CreateRouteTableRequest generates a "aws/request.Request" representing the
// client's request for the CreateRouteTable operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -4573,7 +4573,7 @@ const opCreateSecurityGroup = "CreateSecurityGroup"
// CreateSecurityGroupRequest generates a "aws/request.Request" representing the
// client's request for the CreateSecurityGroup operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -4673,7 +4673,7 @@ const opCreateSnapshot = "CreateSnapshot"
// CreateSnapshotRequest generates a "aws/request.Request" representing the
// client's request for the CreateSnapshot operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -4778,7 +4778,7 @@ const opCreateSpotDatafeedSubscription = "CreateSpotDatafeedSubscription"
// CreateSpotDatafeedSubscriptionRequest generates a "aws/request.Request" representing the
// client's request for the CreateSpotDatafeedSubscription operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -4855,7 +4855,7 @@ const opCreateSubnet = "CreateSubnet"
// CreateSubnetRequest generates a "aws/request.Request" representing the
// client's request for the CreateSubnet operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -4955,7 +4955,7 @@ const opCreateTags = "CreateTags"
// CreateTagsRequest generates a "aws/request.Request" representing the
// client's request for the CreateTags operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -5039,7 +5039,7 @@ const opCreateVolume = "CreateVolume"
// CreateVolumeRequest generates a "aws/request.Request" representing the
// client's request for the CreateVolume operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -5132,7 +5132,7 @@ const opCreateVpc = "CreateVpc"
// CreateVpcRequest generates a "aws/request.Request" representing the
// client's request for the CreateVpc operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -5224,7 +5224,7 @@ const opCreateVpcEndpoint = "CreateVpcEndpoint"
// CreateVpcEndpointRequest generates a "aws/request.Request" representing the
// client's request for the CreateVpcEndpoint operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -5314,7 +5314,7 @@ const opCreateVpcEndpointConnectionNotification = "CreateVpcEndpointConnectionNo
// CreateVpcEndpointConnectionNotificationRequest generates a "aws/request.Request" representing the
// client's request for the CreateVpcEndpointConnectionNotification operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -5394,7 +5394,7 @@ const opCreateVpcEndpointServiceConfiguration = "CreateVpcEndpointServiceConfigu
// CreateVpcEndpointServiceConfigurationRequest generates a "aws/request.Request" representing the
// client's request for the CreateVpcEndpointServiceConfiguration operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -5475,7 +5475,7 @@ const opCreateVpcPeeringConnection = "CreateVpcPeeringConnection"
// CreateVpcPeeringConnectionRequest generates a "aws/request.Request" representing the
// client's request for the CreateVpcPeeringConnection operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -5564,7 +5564,7 @@ const opCreateVpnConnection = "CreateVpnConnection"
// CreateVpnConnectionRequest generates a "aws/request.Request" representing the
// client's request for the CreateVpnConnection operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -5656,7 +5656,7 @@ const opCreateVpnConnectionRoute = "CreateVpnConnectionRoute"
// CreateVpnConnectionRouteRequest generates a "aws/request.Request" representing the
// client's request for the CreateVpnConnectionRoute operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -5739,7 +5739,7 @@ const opCreateVpnGateway = "CreateVpnGateway"
// CreateVpnGatewayRequest generates a "aws/request.Request" representing the
// client's request for the CreateVpnGateway operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -5819,7 +5819,7 @@ const opDeleteCustomerGateway = "DeleteCustomerGateway"
// DeleteCustomerGatewayRequest generates a "aws/request.Request" representing the
// client's request for the DeleteCustomerGateway operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -5896,7 +5896,7 @@ const opDeleteDhcpOptions = "DeleteDhcpOptions"
// DeleteDhcpOptionsRequest generates a "aws/request.Request" representing the
// client's request for the DeleteDhcpOptions operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -5975,7 +5975,7 @@ const opDeleteEgressOnlyInternetGateway = "DeleteEgressOnlyInternetGateway"
// DeleteEgressOnlyInternetGatewayRequest generates a "aws/request.Request" representing the
// client's request for the DeleteEgressOnlyInternetGateway operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -6049,7 +6049,7 @@ const opDeleteFleets = "DeleteFleets"
// DeleteFleetsRequest generates a "aws/request.Request" representing the
// client's request for the DeleteFleets operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -6129,7 +6129,7 @@ const opDeleteFlowLogs = "DeleteFlowLogs"
// DeleteFlowLogsRequest generates a "aws/request.Request" representing the
// client's request for the DeleteFlowLogs operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -6203,7 +6203,7 @@ const opDeleteFpgaImage = "DeleteFpgaImage"
// DeleteFpgaImageRequest generates a "aws/request.Request" representing the
// client's request for the DeleteFpgaImage operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -6277,7 +6277,7 @@ const opDeleteInternetGateway = "DeleteInternetGateway"
// DeleteInternetGatewayRequest generates a "aws/request.Request" representing the
// client's request for the DeleteInternetGateway operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -6354,7 +6354,7 @@ const opDeleteKeyPair = "DeleteKeyPair"
// DeleteKeyPairRequest generates a "aws/request.Request" representing the
// client's request for the DeleteKeyPair operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -6430,7 +6430,7 @@ const opDeleteLaunchTemplate = "DeleteLaunchTemplate"
// DeleteLaunchTemplateRequest generates a "aws/request.Request" representing the
// client's request for the DeleteLaunchTemplate operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -6505,7 +6505,7 @@ const opDeleteLaunchTemplateVersions = "DeleteLaunchTemplateVersions"
// DeleteLaunchTemplateVersionsRequest generates a "aws/request.Request" representing the
// client's request for the DeleteLaunchTemplateVersions operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -6582,7 +6582,7 @@ const opDeleteNatGateway = "DeleteNatGateway"
// DeleteNatGatewayRequest generates a "aws/request.Request" representing the
// client's request for the DeleteNatGateway operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -6658,7 +6658,7 @@ const opDeleteNetworkAcl = "DeleteNetworkAcl"
// DeleteNetworkAclRequest generates a "aws/request.Request" representing the
// client's request for the DeleteNetworkAcl operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -6735,7 +6735,7 @@ const opDeleteNetworkAclEntry = "DeleteNetworkAclEntry"
// DeleteNetworkAclEntryRequest generates a "aws/request.Request" representing the
// client's request for the DeleteNetworkAclEntry operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -6812,7 +6812,7 @@ const opDeleteNetworkInterface = "DeleteNetworkInterface"
// DeleteNetworkInterfaceRequest generates a "aws/request.Request" representing the
// client's request for the DeleteNetworkInterface operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -6889,7 +6889,7 @@ const opDeleteNetworkInterfacePermission = "DeleteNetworkInterfacePermission"
// DeleteNetworkInterfacePermissionRequest generates a "aws/request.Request" representing the
// client's request for the DeleteNetworkInterfacePermission operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -6966,7 +6966,7 @@ const opDeletePlacementGroup = "DeletePlacementGroup"
// DeletePlacementGroupRequest generates a "aws/request.Request" representing the
// client's request for the DeletePlacementGroup operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -7045,7 +7045,7 @@ const opDeleteRoute = "DeleteRoute"
// DeleteRouteRequest generates a "aws/request.Request" representing the
// client's request for the DeleteRoute operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -7121,7 +7121,7 @@ const opDeleteRouteTable = "DeleteRouteTable"
// DeleteRouteTableRequest generates a "aws/request.Request" representing the
// client's request for the DeleteRouteTable operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -7199,7 +7199,7 @@ const opDeleteSecurityGroup = "DeleteSecurityGroup"
// DeleteSecurityGroupRequest generates a "aws/request.Request" representing the
// client's request for the DeleteSecurityGroup operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -7279,7 +7279,7 @@ const opDeleteSnapshot = "DeleteSnapshot"
// DeleteSnapshotRequest generates a "aws/request.Request" representing the
// client's request for the DeleteSnapshot operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -7369,7 +7369,7 @@ const opDeleteSpotDatafeedSubscription = "DeleteSpotDatafeedSubscription"
// DeleteSpotDatafeedSubscriptionRequest generates a "aws/request.Request" representing the
// client's request for the DeleteSpotDatafeedSubscription operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -7445,7 +7445,7 @@ const opDeleteSubnet = "DeleteSubnet"
// DeleteSubnetRequest generates a "aws/request.Request" representing the
// client's request for the DeleteSubnet operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -7522,7 +7522,7 @@ const opDeleteTags = "DeleteTags"
// DeleteTagsRequest generates a "aws/request.Request" representing the
// client's request for the DeleteTags operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -7602,7 +7602,7 @@ const opDeleteVolume = "DeleteVolume"
// DeleteVolumeRequest generates a "aws/request.Request" representing the
// client's request for the DeleteVolume operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -7684,7 +7684,7 @@ const opDeleteVpc = "DeleteVpc"
// DeleteVpcRequest generates a "aws/request.Request" representing the
// client's request for the DeleteVpc operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -7764,7 +7764,7 @@ const opDeleteVpcEndpointConnectionNotifications = "DeleteVpcEndpointConnectionN
// DeleteVpcEndpointConnectionNotificationsRequest generates a "aws/request.Request" representing the
// client's request for the DeleteVpcEndpointConnectionNotifications operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -7838,7 +7838,7 @@ const opDeleteVpcEndpointServiceConfigurations = "DeleteVpcEndpointServiceConfig
// DeleteVpcEndpointServiceConfigurationsRequest generates a "aws/request.Request" representing the
// client's request for the DeleteVpcEndpointServiceConfigurations operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -7915,7 +7915,7 @@ const opDeleteVpcEndpoints = "DeleteVpcEndpoints"
// DeleteVpcEndpointsRequest generates a "aws/request.Request" representing the
// client's request for the DeleteVpcEndpoints operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -7992,7 +7992,7 @@ const opDeleteVpcPeeringConnection = "DeleteVpcPeeringConnection"
// DeleteVpcPeeringConnectionRequest generates a "aws/request.Request" representing the
// client's request for the DeleteVpcPeeringConnection operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -8070,7 +8070,7 @@ const opDeleteVpnConnection = "DeleteVpnConnection"
// DeleteVpnConnectionRequest generates a "aws/request.Request" representing the
// client's request for the DeleteVpnConnection operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -8155,7 +8155,7 @@ const opDeleteVpnConnectionRoute = "DeleteVpnConnectionRoute"
// DeleteVpnConnectionRouteRequest generates a "aws/request.Request" representing the
// client's request for the DeleteVpnConnectionRoute operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -8234,7 +8234,7 @@ const opDeleteVpnGateway = "DeleteVpnGateway"
// DeleteVpnGatewayRequest generates a "aws/request.Request" representing the
// client's request for the DeleteVpnGateway operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -8314,7 +8314,7 @@ const opDeregisterImage = "DeregisterImage"
// DeregisterImageRequest generates a "aws/request.Request" representing the
// client's request for the DeregisterImage operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -8398,7 +8398,7 @@ const opDescribeAccountAttributes = "DescribeAccountAttributes"
// DescribeAccountAttributesRequest generates a "aws/request.Request" representing the
// client's request for the DescribeAccountAttributes operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -8490,7 +8490,7 @@ const opDescribeAddresses = "DescribeAddresses"
// DescribeAddressesRequest generates a "aws/request.Request" representing the
// client's request for the DescribeAddresses operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -8568,7 +8568,7 @@ const opDescribeAggregateIdFormat = "DescribeAggregateIdFormat"
// DescribeAggregateIdFormatRequest generates a "aws/request.Request" representing the
// client's request for the DescribeAggregateIdFormat operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -8656,7 +8656,7 @@ const opDescribeAvailabilityZones = "DescribeAvailabilityZones"
// DescribeAvailabilityZonesRequest generates a "aws/request.Request" representing the
// client's request for the DescribeAvailabilityZones operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -8736,7 +8736,7 @@ const opDescribeBundleTasks = "DescribeBundleTasks"
// DescribeBundleTasksRequest generates a "aws/request.Request" representing the
// client's request for the DescribeBundleTasks operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -8815,7 +8815,7 @@ const opDescribeClassicLinkInstances = "DescribeClassicLinkInstances"
// DescribeClassicLinkInstancesRequest generates a "aws/request.Request" representing the
// client's request for the DescribeClassicLinkInstances operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -8892,7 +8892,7 @@ const opDescribeConversionTasks = "DescribeConversionTasks"
// DescribeConversionTasksRequest generates a "aws/request.Request" representing the
// client's request for the DescribeConversionTasks operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -8970,7 +8970,7 @@ const opDescribeCustomerGateways = "DescribeCustomerGateways"
// DescribeCustomerGatewaysRequest generates a "aws/request.Request" representing the
// client's request for the DescribeCustomerGateways operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -9048,7 +9048,7 @@ const opDescribeDhcpOptions = "DescribeDhcpOptions"
// DescribeDhcpOptionsRequest generates a "aws/request.Request" representing the
// client's request for the DescribeDhcpOptions operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -9125,7 +9125,7 @@ const opDescribeEgressOnlyInternetGateways = "DescribeEgressOnlyInternetGateways
// DescribeEgressOnlyInternetGatewaysRequest generates a "aws/request.Request" representing the
// client's request for the DescribeEgressOnlyInternetGateways operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -9199,7 +9199,7 @@ const opDescribeElasticGpus = "DescribeElasticGpus"
// DescribeElasticGpusRequest generates a "aws/request.Request" representing the
// client's request for the DescribeElasticGpus operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -9274,7 +9274,7 @@ const opDescribeExportTasks = "DescribeExportTasks"
// DescribeExportTasksRequest generates a "aws/request.Request" representing the
// client's request for the DescribeExportTasks operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -9348,7 +9348,7 @@ const opDescribeFleetHistory = "DescribeFleetHistory"
// DescribeFleetHistoryRequest generates a "aws/request.Request" representing the
// client's request for the DescribeFleetHistory operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -9422,7 +9422,7 @@ const opDescribeFleetInstances = "DescribeFleetInstances"
// DescribeFleetInstancesRequest generates a "aws/request.Request" representing the
// client's request for the DescribeFleetInstances operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -9496,7 +9496,7 @@ const opDescribeFleets = "DescribeFleets"
// DescribeFleetsRequest generates a "aws/request.Request" representing the
// client's request for the DescribeFleets operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -9570,7 +9570,7 @@ const opDescribeFlowLogs = "DescribeFlowLogs"
// DescribeFlowLogsRequest generates a "aws/request.Request" representing the
// client's request for the DescribeFlowLogs operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -9646,7 +9646,7 @@ const opDescribeFpgaImageAttribute = "DescribeFpgaImageAttribute"
// DescribeFpgaImageAttributeRequest generates a "aws/request.Request" representing the
// client's request for the DescribeFpgaImageAttribute operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -9720,7 +9720,7 @@ const opDescribeFpgaImages = "DescribeFpgaImages"
// DescribeFpgaImagesRequest generates a "aws/request.Request" representing the
// client's request for the DescribeFpgaImages operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -9796,7 +9796,7 @@ const opDescribeHostReservationOfferings = "DescribeHostReservationOfferings"
// DescribeHostReservationOfferingsRequest generates a "aws/request.Request" representing the
// client's request for the DescribeHostReservationOfferings operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -9878,7 +9878,7 @@ const opDescribeHostReservations = "DescribeHostReservations"
// DescribeHostReservationsRequest generates a "aws/request.Request" representing the
// client's request for the DescribeHostReservations operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -9952,7 +9952,7 @@ const opDescribeHosts = "DescribeHosts"
// DescribeHostsRequest generates a "aws/request.Request" representing the
// client's request for the DescribeHosts operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -10030,7 +10030,7 @@ const opDescribeIamInstanceProfileAssociations = "DescribeIamInstanceProfileAsso
// DescribeIamInstanceProfileAssociationsRequest generates a "aws/request.Request" representing the
// client's request for the DescribeIamInstanceProfileAssociations operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -10104,7 +10104,7 @@ const opDescribeIdFormat = "DescribeIdFormat"
// DescribeIdFormatRequest generates a "aws/request.Request" representing the
// client's request for the DescribeIdFormat operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -10196,7 +10196,7 @@ const opDescribeIdentityIdFormat = "DescribeIdentityIdFormat"
// DescribeIdentityIdFormatRequest generates a "aws/request.Request" representing the
// client's request for the DescribeIdentityIdFormat operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -10286,7 +10286,7 @@ const opDescribeImageAttribute = "DescribeImageAttribute"
// DescribeImageAttributeRequest generates a "aws/request.Request" representing the
// client's request for the DescribeImageAttribute operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -10361,7 +10361,7 @@ const opDescribeImages = "DescribeImages"
// DescribeImagesRequest generates a "aws/request.Request" representing the
// client's request for the DescribeImages operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -10441,7 +10441,7 @@ const opDescribeImportImageTasks = "DescribeImportImageTasks"
// DescribeImportImageTasksRequest generates a "aws/request.Request" representing the
// client's request for the DescribeImportImageTasks operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -10516,7 +10516,7 @@ const opDescribeImportSnapshotTasks = "DescribeImportSnapshotTasks"
// DescribeImportSnapshotTasksRequest generates a "aws/request.Request" representing the
// client's request for the DescribeImportSnapshotTasks operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -10590,7 +10590,7 @@ const opDescribeInstanceAttribute = "DescribeInstanceAttribute"
// DescribeInstanceAttributeRequest generates a "aws/request.Request" representing the
// client's request for the DescribeInstanceAttribute operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -10668,7 +10668,7 @@ const opDescribeInstanceCreditSpecifications = "DescribeInstanceCreditSpecificat
// DescribeInstanceCreditSpecificationsRequest generates a "aws/request.Request" representing the
// client's request for the DescribeInstanceCreditSpecifications operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -10765,7 +10765,7 @@ const opDescribeInstanceStatus = "DescribeInstanceStatus"
// DescribeInstanceStatusRequest generates a "aws/request.Request" representing the
// client's request for the DescribeInstanceStatus operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -10916,7 +10916,7 @@ const opDescribeInstances = "DescribeInstances"
// DescribeInstancesRequest generates a "aws/request.Request" representing the
// client's request for the DescribeInstances operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -11061,7 +11061,7 @@ const opDescribeInternetGateways = "DescribeInternetGateways"
// DescribeInternetGatewaysRequest generates a "aws/request.Request" representing the
// client's request for the DescribeInternetGateways operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -11135,7 +11135,7 @@ const opDescribeKeyPairs = "DescribeKeyPairs"
// DescribeKeyPairsRequest generates a "aws/request.Request" representing the
// client's request for the DescribeKeyPairs operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -11212,7 +11212,7 @@ const opDescribeLaunchTemplateVersions = "DescribeLaunchTemplateVersions"
// DescribeLaunchTemplateVersionsRequest generates a "aws/request.Request" representing the
// client's request for the DescribeLaunchTemplateVersions operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -11287,7 +11287,7 @@ const opDescribeLaunchTemplates = "DescribeLaunchTemplates"
// DescribeLaunchTemplatesRequest generates a "aws/request.Request" representing the
// client's request for the DescribeLaunchTemplates operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -11361,7 +11361,7 @@ const opDescribeMovingAddresses = "DescribeMovingAddresses"
// DescribeMovingAddressesRequest generates a "aws/request.Request" representing the
// client's request for the DescribeMovingAddresses operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -11437,7 +11437,7 @@ const opDescribeNatGateways = "DescribeNatGateways"
// DescribeNatGatewaysRequest generates a "aws/request.Request" representing the
// client's request for the DescribeNatGateways operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -11567,7 +11567,7 @@ const opDescribeNetworkAcls = "DescribeNetworkAcls"
// DescribeNetworkAclsRequest generates a "aws/request.Request" representing the
// client's request for the DescribeNetworkAcls operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -11644,7 +11644,7 @@ const opDescribeNetworkInterfaceAttribute = "DescribeNetworkInterfaceAttribute"
// DescribeNetworkInterfaceAttributeRequest generates a "aws/request.Request" representing the
// client's request for the DescribeNetworkInterfaceAttribute operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -11719,7 +11719,7 @@ const opDescribeNetworkInterfacePermissions = "DescribeNetworkInterfacePermissio
// DescribeNetworkInterfacePermissionsRequest generates a "aws/request.Request" representing the
// client's request for the DescribeNetworkInterfacePermissions operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -11793,7 +11793,7 @@ const opDescribeNetworkInterfaces = "DescribeNetworkInterfaces"
// DescribeNetworkInterfacesRequest generates a "aws/request.Request" representing the
// client's request for the DescribeNetworkInterfaces operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -11923,7 +11923,7 @@ const opDescribePlacementGroups = "DescribePlacementGroups"
// DescribePlacementGroupsRequest generates a "aws/request.Request" representing the
// client's request for the DescribePlacementGroups operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -11999,7 +11999,7 @@ const opDescribePrefixLists = "DescribePrefixLists"
// DescribePrefixListsRequest generates a "aws/request.Request" representing the
// client's request for the DescribePrefixLists operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -12078,7 +12078,7 @@ const opDescribePrincipalIdFormat = "DescribePrincipalIdFormat"
// DescribePrincipalIdFormatRequest generates a "aws/request.Request" representing the
// client's request for the DescribePrincipalIdFormat operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -12166,7 +12166,7 @@ const opDescribeRegions = "DescribeRegions"
// DescribeRegionsRequest generates a "aws/request.Request" representing the
// client's request for the DescribeRegions operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -12243,7 +12243,7 @@ const opDescribeReservedInstances = "DescribeReservedInstances"
// DescribeReservedInstancesRequest generates a "aws/request.Request" representing the
// client's request for the DescribeReservedInstances operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -12320,7 +12320,7 @@ const opDescribeReservedInstancesListings = "DescribeReservedInstancesListings"
// DescribeReservedInstancesListingsRequest generates a "aws/request.Request" representing the
// client's request for the DescribeReservedInstancesListings operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -12415,7 +12415,7 @@ const opDescribeReservedInstancesModifications = "DescribeReservedInstancesModif
// DescribeReservedInstancesModificationsRequest generates a "aws/request.Request" representing the
// client's request for the DescribeReservedInstancesModifications operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -12551,7 +12551,7 @@ const opDescribeReservedInstancesOfferings = "DescribeReservedInstancesOfferings
// DescribeReservedInstancesOfferingsRequest generates a "aws/request.Request" representing the
// client's request for the DescribeReservedInstancesOfferings operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -12692,7 +12692,7 @@ const opDescribeRouteTables = "DescribeRouteTables"
// DescribeRouteTablesRequest generates a "aws/request.Request" representing the
// client's request for the DescribeRouteTables operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -12774,7 +12774,7 @@ const opDescribeScheduledInstanceAvailability = "DescribeScheduledInstanceAvaila
// DescribeScheduledInstanceAvailabilityRequest generates a "aws/request.Request" representing the
// client's request for the DescribeScheduledInstanceAvailability operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -12856,7 +12856,7 @@ const opDescribeScheduledInstances = "DescribeScheduledInstances"
// DescribeScheduledInstancesRequest generates a "aws/request.Request" representing the
// client's request for the DescribeScheduledInstances operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -12930,7 +12930,7 @@ const opDescribeSecurityGroupReferences = "DescribeSecurityGroupReferences"
// DescribeSecurityGroupReferencesRequest generates a "aws/request.Request" representing the
// client's request for the DescribeSecurityGroupReferences operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -13005,7 +13005,7 @@ const opDescribeSecurityGroups = "DescribeSecurityGroups"
// DescribeSecurityGroupsRequest generates a "aws/request.Request" representing the
// client's request for the DescribeSecurityGroups operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -13086,7 +13086,7 @@ const opDescribeSnapshotAttribute = "DescribeSnapshotAttribute"
// DescribeSnapshotAttributeRequest generates a "aws/request.Request" representing the
// client's request for the DescribeSnapshotAttribute operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -13164,7 +13164,7 @@ const opDescribeSnapshots = "DescribeSnapshots"
// DescribeSnapshotsRequest generates a "aws/request.Request" representing the
// client's request for the DescribeSnapshots operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -13339,7 +13339,7 @@ const opDescribeSpotDatafeedSubscription = "DescribeSpotDatafeedSubscription"
// DescribeSpotDatafeedSubscriptionRequest generates a "aws/request.Request" representing the
// client's request for the DescribeSpotDatafeedSubscription operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -13415,7 +13415,7 @@ const opDescribeSpotFleetInstances = "DescribeSpotFleetInstances"
// DescribeSpotFleetInstancesRequest generates a "aws/request.Request" representing the
// client's request for the DescribeSpotFleetInstances operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -13489,7 +13489,7 @@ const opDescribeSpotFleetRequestHistory = "DescribeSpotFleetRequestHistory"
// DescribeSpotFleetRequestHistoryRequest generates a "aws/request.Request" representing the
// client's request for the DescribeSpotFleetRequestHistory operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -13568,7 +13568,7 @@ const opDescribeSpotFleetRequests = "DescribeSpotFleetRequests"
// DescribeSpotFleetRequestsRequest generates a "aws/request.Request" representing the
// client's request for the DescribeSpotFleetRequests operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -13701,7 +13701,7 @@ const opDescribeSpotInstanceRequests = "DescribeSpotInstanceRequests"
// DescribeSpotInstanceRequestsRequest generates a "aws/request.Request" representing the
// client's request for the DescribeSpotInstanceRequests operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -13784,7 +13784,7 @@ const opDescribeSpotPriceHistory = "DescribeSpotPriceHistory"
// DescribeSpotPriceHistoryRequest generates a "aws/request.Request" representing the
// client's request for the DescribeSpotPriceHistory operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -13921,7 +13921,7 @@ const opDescribeStaleSecurityGroups = "DescribeStaleSecurityGroups"
// DescribeStaleSecurityGroupsRequest generates a "aws/request.Request" representing the
// client's request for the DescribeStaleSecurityGroups operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -13998,7 +13998,7 @@ const opDescribeSubnets = "DescribeSubnets"
// DescribeSubnetsRequest generates a "aws/request.Request" representing the
// client's request for the DescribeSubnets operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -14075,7 +14075,7 @@ const opDescribeTags = "DescribeTags"
// DescribeTagsRequest generates a "aws/request.Request" representing the
// client's request for the DescribeTags operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -14208,7 +14208,7 @@ const opDescribeVolumeAttribute = "DescribeVolumeAttribute"
// DescribeVolumeAttributeRequest generates a "aws/request.Request" representing the
// client's request for the DescribeVolumeAttribute operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -14286,7 +14286,7 @@ const opDescribeVolumeStatus = "DescribeVolumeStatus"
// DescribeVolumeStatusRequest generates a "aws/request.Request" representing the
// client's request for the DescribeVolumeStatus operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -14451,7 +14451,7 @@ const opDescribeVolumes = "DescribeVolumes"
// DescribeVolumesRequest generates a "aws/request.Request" representing the
// client's request for the DescribeVolumes operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -14591,7 +14591,7 @@ const opDescribeVolumesModifications = "DescribeVolumesModifications"
// DescribeVolumesModificationsRequest generates a "aws/request.Request" representing the
// client's request for the DescribeVolumesModifications operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -14678,7 +14678,7 @@ const opDescribeVpcAttribute = "DescribeVpcAttribute"
// DescribeVpcAttributeRequest generates a "aws/request.Request" representing the
// client's request for the DescribeVpcAttribute operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -14753,7 +14753,7 @@ const opDescribeVpcClassicLink = "DescribeVpcClassicLink"
// DescribeVpcClassicLinkRequest generates a "aws/request.Request" representing the
// client's request for the DescribeVpcClassicLink operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -14827,7 +14827,7 @@ const opDescribeVpcClassicLinkDnsSupport = "DescribeVpcClassicLinkDnsSupport"
// DescribeVpcClassicLinkDnsSupportRequest generates a "aws/request.Request" representing the
// client's request for the DescribeVpcClassicLinkDnsSupport operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -14907,7 +14907,7 @@ const opDescribeVpcEndpointConnectionNotifications = "DescribeVpcEndpointConnect
// DescribeVpcEndpointConnectionNotificationsRequest generates a "aws/request.Request" representing the
// client's request for the DescribeVpcEndpointConnectionNotifications operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -14982,7 +14982,7 @@ const opDescribeVpcEndpointConnections = "DescribeVpcEndpointConnections"
// DescribeVpcEndpointConnectionsRequest generates a "aws/request.Request" representing the
// client's request for the DescribeVpcEndpointConnections operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -15057,7 +15057,7 @@ const opDescribeVpcEndpointServiceConfigurations = "DescribeVpcEndpointServiceCo
// DescribeVpcEndpointServiceConfigurationsRequest generates a "aws/request.Request" representing the
// client's request for the DescribeVpcEndpointServiceConfigurations operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -15131,7 +15131,7 @@ const opDescribeVpcEndpointServicePermissions = "DescribeVpcEndpointServicePermi
// DescribeVpcEndpointServicePermissionsRequest generates a "aws/request.Request" representing the
// client's request for the DescribeVpcEndpointServicePermissions operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -15206,7 +15206,7 @@ const opDescribeVpcEndpointServices = "DescribeVpcEndpointServices"
// DescribeVpcEndpointServicesRequest generates a "aws/request.Request" representing the
// client's request for the DescribeVpcEndpointServices operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -15280,7 +15280,7 @@ const opDescribeVpcEndpoints = "DescribeVpcEndpoints"
// DescribeVpcEndpointsRequest generates a "aws/request.Request" representing the
// client's request for the DescribeVpcEndpoints operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -15354,7 +15354,7 @@ const opDescribeVpcPeeringConnections = "DescribeVpcPeeringConnections"
// DescribeVpcPeeringConnectionsRequest generates a "aws/request.Request" representing the
// client's request for the DescribeVpcPeeringConnections operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -15428,7 +15428,7 @@ const opDescribeVpcs = "DescribeVpcs"
// DescribeVpcsRequest generates a "aws/request.Request" representing the
// client's request for the DescribeVpcs operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -15502,7 +15502,7 @@ const opDescribeVpnConnections = "DescribeVpnConnections"
// DescribeVpnConnectionsRequest generates a "aws/request.Request" representing the
// client's request for the DescribeVpnConnections operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -15580,7 +15580,7 @@ const opDescribeVpnGateways = "DescribeVpnGateways"
// DescribeVpnGatewaysRequest generates a "aws/request.Request" representing the
// client's request for the DescribeVpnGateways operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -15658,7 +15658,7 @@ const opDetachClassicLinkVpc = "DetachClassicLinkVpc"
// DetachClassicLinkVpcRequest generates a "aws/request.Request" representing the
// client's request for the DetachClassicLinkVpc operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -15734,7 +15734,7 @@ const opDetachInternetGateway = "DetachInternetGateway"
// DetachInternetGatewayRequest generates a "aws/request.Request" representing the
// client's request for the DetachInternetGateway operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -15812,7 +15812,7 @@ const opDetachNetworkInterface = "DetachNetworkInterface"
// DetachNetworkInterfaceRequest generates a "aws/request.Request" representing the
// client's request for the DetachNetworkInterface operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -15888,7 +15888,7 @@ const opDetachVolume = "DetachVolume"
// DetachVolumeRequest generates a "aws/request.Request" representing the
// client's request for the DetachVolume operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -15975,7 +15975,7 @@ const opDetachVpnGateway = "DetachVpnGateway"
// DetachVpnGatewayRequest generates a "aws/request.Request" representing the
// client's request for the DetachVpnGateway operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -16058,7 +16058,7 @@ const opDisableVgwRoutePropagation = "DisableVgwRoutePropagation"
// DisableVgwRoutePropagationRequest generates a "aws/request.Request" representing the
// client's request for the DisableVgwRoutePropagation operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -16135,7 +16135,7 @@ const opDisableVpcClassicLink = "DisableVpcClassicLink"
// DisableVpcClassicLinkRequest generates a "aws/request.Request" representing the
// client's request for the DisableVpcClassicLink operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -16210,7 +16210,7 @@ const opDisableVpcClassicLinkDnsSupport = "DisableVpcClassicLinkDnsSupport"
// DisableVpcClassicLinkDnsSupportRequest generates a "aws/request.Request" representing the
// client's request for the DisableVpcClassicLinkDnsSupport operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -16288,7 +16288,7 @@ const opDisassociateAddress = "DisassociateAddress"
// DisassociateAddressRequest generates a "aws/request.Request" representing the
// client's request for the DisassociateAddress operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -16372,7 +16372,7 @@ const opDisassociateIamInstanceProfile = "DisassociateIamInstanceProfile"
// DisassociateIamInstanceProfileRequest generates a "aws/request.Request" representing the
// client's request for the DisassociateIamInstanceProfile operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -16448,7 +16448,7 @@ const opDisassociateRouteTable = "DisassociateRouteTable"
// DisassociateRouteTableRequest generates a "aws/request.Request" representing the
// client's request for the DisassociateRouteTable operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -16529,7 +16529,7 @@ const opDisassociateSubnetCidrBlock = "DisassociateSubnetCidrBlock"
// DisassociateSubnetCidrBlockRequest generates a "aws/request.Request" representing the
// client's request for the DisassociateSubnetCidrBlock operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -16605,7 +16605,7 @@ const opDisassociateVpcCidrBlock = "DisassociateVpcCidrBlock"
// DisassociateVpcCidrBlockRequest generates a "aws/request.Request" representing the
// client's request for the DisassociateVpcCidrBlock operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -16685,7 +16685,7 @@ const opEnableVgwRoutePropagation = "EnableVgwRoutePropagation"
// EnableVgwRoutePropagationRequest generates a "aws/request.Request" representing the
// client's request for the EnableVgwRoutePropagation operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -16762,7 +16762,7 @@ const opEnableVolumeIO = "EnableVolumeIO"
// EnableVolumeIORequest generates a "aws/request.Request" representing the
// client's request for the EnableVolumeIO operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -16839,7 +16839,7 @@ const opEnableVpcClassicLink = "EnableVpcClassicLink"
// EnableVpcClassicLinkRequest generates a "aws/request.Request" representing the
// client's request for the EnableVpcClassicLink operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -16919,7 +16919,7 @@ const opEnableVpcClassicLinkDnsSupport = "EnableVpcClassicLinkDnsSupport"
// EnableVpcClassicLinkDnsSupportRequest generates a "aws/request.Request" representing the
// client's request for the EnableVpcClassicLinkDnsSupport operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -16999,7 +16999,7 @@ const opGetConsoleOutput = "GetConsoleOutput"
// GetConsoleOutputRequest generates a "aws/request.Request" representing the
// client's request for the GetConsoleOutput operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -17089,7 +17089,7 @@ const opGetConsoleScreenshot = "GetConsoleScreenshot"
// GetConsoleScreenshotRequest generates a "aws/request.Request" representing the
// client's request for the GetConsoleScreenshot operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -17165,7 +17165,7 @@ const opGetHostReservationPurchasePreview = "GetHostReservationPurchasePreview"
// GetHostReservationPurchasePreviewRequest generates a "aws/request.Request" representing the
// client's request for the GetHostReservationPurchasePreview operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -17244,7 +17244,7 @@ const opGetLaunchTemplateData = "GetLaunchTemplateData"
// GetLaunchTemplateDataRequest generates a "aws/request.Request" representing the
// client's request for the GetLaunchTemplateData operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -17319,7 +17319,7 @@ const opGetPasswordData = "GetPasswordData"
// GetPasswordDataRequest generates a "aws/request.Request" representing the
// client's request for the GetPasswordData operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -17410,7 +17410,7 @@ const opGetReservedInstancesExchangeQuote = "GetReservedInstancesExchangeQuote"
// GetReservedInstancesExchangeQuoteRequest generates a "aws/request.Request" representing the
// client's request for the GetReservedInstancesExchangeQuote operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -17487,7 +17487,7 @@ const opImportImage = "ImportImage"
// ImportImageRequest generates a "aws/request.Request" representing the
// client's request for the ImportImage operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -17564,7 +17564,7 @@ const opImportInstance = "ImportInstance"
// ImportInstanceRequest generates a "aws/request.Request" representing the
// client's request for the ImportInstance operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -17644,7 +17644,7 @@ const opImportKeyPair = "ImportKeyPair"
// ImportKeyPairRequest generates a "aws/request.Request" representing the
// client's request for the ImportKeyPair operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -17725,7 +17725,7 @@ const opImportSnapshot = "ImportSnapshot"
// ImportSnapshotRequest generates a "aws/request.Request" representing the
// client's request for the ImportSnapshot operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -17799,7 +17799,7 @@ const opImportVolume = "ImportVolume"
// ImportVolumeRequest generates a "aws/request.Request" representing the
// client's request for the ImportVolume operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -17877,7 +17877,7 @@ const opModifyFleet = "ModifyFleet"
// ModifyFleetRequest generates a "aws/request.Request" representing the
// client's request for the ModifyFleet operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -17953,7 +17953,7 @@ const opModifyFpgaImageAttribute = "ModifyFpgaImageAttribute"
// ModifyFpgaImageAttributeRequest generates a "aws/request.Request" representing the
// client's request for the ModifyFpgaImageAttribute operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -18027,7 +18027,7 @@ const opModifyHosts = "ModifyHosts"
// ModifyHostsRequest generates a "aws/request.Request" representing the
// client's request for the ModifyHosts operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -18107,7 +18107,7 @@ const opModifyIdFormat = "ModifyIdFormat"
// ModifyIdFormatRequest generates a "aws/request.Request" representing the
// client's request for the ModifyIdFormat operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -18205,7 +18205,7 @@ const opModifyIdentityIdFormat = "ModifyIdentityIdFormat"
// ModifyIdentityIdFormatRequest generates a "aws/request.Request" representing the
// client's request for the ModifyIdentityIdFormat operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -18303,7 +18303,7 @@ const opModifyImageAttribute = "ModifyImageAttribute"
// ModifyImageAttributeRequest generates a "aws/request.Request" representing the
// client's request for the ModifyImageAttribute operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -18388,7 +18388,7 @@ const opModifyInstanceAttribute = "ModifyInstanceAttribute"
// ModifyInstanceAttributeRequest generates a "aws/request.Request" representing the
// client's request for the ModifyInstanceAttribute operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -18475,7 +18475,7 @@ const opModifyInstanceCreditSpecification = "ModifyInstanceCreditSpecification"
// ModifyInstanceCreditSpecificationRequest generates a "aws/request.Request" representing the
// client's request for the ModifyInstanceCreditSpecification operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -18553,7 +18553,7 @@ const opModifyInstancePlacement = "ModifyInstancePlacement"
// ModifyInstancePlacementRequest generates a "aws/request.Request" representing the
// client's request for the ModifyInstancePlacement operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -18648,7 +18648,7 @@ const opModifyLaunchTemplate = "ModifyLaunchTemplate"
// ModifyLaunchTemplateRequest generates a "aws/request.Request" representing the
// client's request for the ModifyLaunchTemplate operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -18724,7 +18724,7 @@ const opModifyNetworkInterfaceAttribute = "ModifyNetworkInterfaceAttribute"
// ModifyNetworkInterfaceAttributeRequest generates a "aws/request.Request" representing the
// client's request for the ModifyNetworkInterfaceAttribute operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -18801,7 +18801,7 @@ const opModifyReservedInstances = "ModifyReservedInstances"
// ModifyReservedInstancesRequest generates a "aws/request.Request" representing the
// client's request for the ModifyReservedInstances operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -18881,7 +18881,7 @@ const opModifySnapshotAttribute = "ModifySnapshotAttribute"
// ModifySnapshotAttributeRequest generates a "aws/request.Request" representing the
// client's request for the ModifySnapshotAttribute operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -18969,7 +18969,7 @@ const opModifySpotFleetRequest = "ModifySpotFleetRequest"
// ModifySpotFleetRequestRequest generates a "aws/request.Request" representing the
// client's request for the ModifySpotFleetRequest operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -19065,7 +19065,7 @@ const opModifySubnetAttribute = "ModifySubnetAttribute"
// ModifySubnetAttributeRequest generates a "aws/request.Request" representing the
// client's request for the ModifySubnetAttribute operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -19141,7 +19141,7 @@ const opModifyVolume = "ModifyVolume"
// ModifyVolumeRequest generates a "aws/request.Request" representing the
// client's request for the ModifyVolume operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -19246,7 +19246,7 @@ const opModifyVolumeAttribute = "ModifyVolumeAttribute"
// ModifyVolumeAttributeRequest generates a "aws/request.Request" representing the
// client's request for the ModifyVolumeAttribute operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -19331,7 +19331,7 @@ const opModifyVpcAttribute = "ModifyVpcAttribute"
// ModifyVpcAttributeRequest generates a "aws/request.Request" representing the
// client's request for the ModifyVpcAttribute operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -19407,7 +19407,7 @@ const opModifyVpcEndpoint = "ModifyVpcEndpoint"
// ModifyVpcEndpointRequest generates a "aws/request.Request" representing the
// client's request for the ModifyVpcEndpoint operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -19484,7 +19484,7 @@ const opModifyVpcEndpointConnectionNotification = "ModifyVpcEndpointConnectionNo
// ModifyVpcEndpointConnectionNotificationRequest generates a "aws/request.Request" representing the
// client's request for the ModifyVpcEndpointConnectionNotification operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -19560,7 +19560,7 @@ const opModifyVpcEndpointServiceConfiguration = "ModifyVpcEndpointServiceConfigu
// ModifyVpcEndpointServiceConfigurationRequest generates a "aws/request.Request" representing the
// client's request for the ModifyVpcEndpointServiceConfiguration operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -19637,7 +19637,7 @@ const opModifyVpcEndpointServicePermissions = "ModifyVpcEndpointServicePermissio
// ModifyVpcEndpointServicePermissionsRequest generates a "aws/request.Request" representing the
// client's request for the ModifyVpcEndpointServicePermissions operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -19718,7 +19718,7 @@ const opModifyVpcPeeringConnectionOptions = "ModifyVpcPeeringConnectionOptions"
// ModifyVpcPeeringConnectionOptionsRequest generates a "aws/request.Request" representing the
// client's request for the ModifyVpcPeeringConnectionOptions operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -19811,7 +19811,7 @@ const opModifyVpcTenancy = "ModifyVpcTenancy"
// ModifyVpcTenancyRequest generates a "aws/request.Request" representing the
// client's request for the ModifyVpcTenancy operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -19894,7 +19894,7 @@ const opMonitorInstances = "MonitorInstances"
// MonitorInstancesRequest generates a "aws/request.Request" representing the
// client's request for the MonitorInstances operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -19973,7 +19973,7 @@ const opMoveAddressToVpc = "MoveAddressToVpc"
// MoveAddressToVpcRequest generates a "aws/request.Request" representing the
// client's request for the MoveAddressToVpc operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -20053,7 +20053,7 @@ const opPurchaseHostReservation = "PurchaseHostReservation"
// PurchaseHostReservationRequest generates a "aws/request.Request" representing the
// client's request for the PurchaseHostReservation operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -20130,7 +20130,7 @@ const opPurchaseReservedInstancesOffering = "PurchaseReservedInstancesOffering"
// PurchaseReservedInstancesOfferingRequest generates a "aws/request.Request" representing the
// client's request for the PurchaseReservedInstancesOffering operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -20213,7 +20213,7 @@ const opPurchaseScheduledInstances = "PurchaseScheduledInstances"
// PurchaseScheduledInstancesRequest generates a "aws/request.Request" representing the
// client's request for the PurchaseScheduledInstances operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -20296,7 +20296,7 @@ const opRebootInstances = "RebootInstances"
// RebootInstancesRequest generates a "aws/request.Request" representing the
// client's request for the RebootInstances operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -20382,7 +20382,7 @@ const opRegisterImage = "RegisterImage"
// RegisterImageRequest generates a "aws/request.Request" representing the
// client's request for the RegisterImage operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -20487,7 +20487,7 @@ const opRejectVpcEndpointConnections = "RejectVpcEndpointConnections"
// RejectVpcEndpointConnectionsRequest generates a "aws/request.Request" representing the
// client's request for the RejectVpcEndpointConnections operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -20562,7 +20562,7 @@ const opRejectVpcPeeringConnection = "RejectVpcPeeringConnection"
// RejectVpcPeeringConnectionRequest generates a "aws/request.Request" representing the
// client's request for the RejectVpcPeeringConnection operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -20640,7 +20640,7 @@ const opReleaseAddress = "ReleaseAddress"
// ReleaseAddressRequest generates a "aws/request.Request" representing the
// client's request for the ReleaseAddress operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -20733,7 +20733,7 @@ const opReleaseHosts = "ReleaseHosts"
// ReleaseHostsRequest generates a "aws/request.Request" representing the
// client's request for the ReleaseHosts operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -20817,7 +20817,7 @@ const opReplaceIamInstanceProfileAssociation = "ReplaceIamInstanceProfileAssocia
// ReplaceIamInstanceProfileAssociationRequest generates a "aws/request.Request" representing the
// client's request for the ReplaceIamInstanceProfileAssociation operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -20896,7 +20896,7 @@ const opReplaceNetworkAclAssociation = "ReplaceNetworkAclAssociation"
// ReplaceNetworkAclAssociationRequest generates a "aws/request.Request" representing the
// client's request for the ReplaceNetworkAclAssociation operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -20975,7 +20975,7 @@ const opReplaceNetworkAclEntry = "ReplaceNetworkAclEntry"
// ReplaceNetworkAclEntryRequest generates a "aws/request.Request" representing the
// client's request for the ReplaceNetworkAclEntry operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -21053,7 +21053,7 @@ const opReplaceRoute = "ReplaceRoute"
// ReplaceRouteRequest generates a "aws/request.Request" representing the
// client's request for the ReplaceRoute operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -21135,7 +21135,7 @@ const opReplaceRouteTableAssociation = "ReplaceRouteTableAssociation"
// ReplaceRouteTableAssociationRequest generates a "aws/request.Request" representing the
// client's request for the ReplaceRouteTableAssociation operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -21217,7 +21217,7 @@ const opReportInstanceStatus = "ReportInstanceStatus"
// ReportInstanceStatusRequest generates a "aws/request.Request" representing the
// client's request for the ReportInstanceStatus operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -21299,7 +21299,7 @@ const opRequestSpotFleet = "RequestSpotFleet"
// RequestSpotFleetRequest generates a "aws/request.Request" representing the
// client's request for the RequestSpotFleet operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -21397,7 +21397,7 @@ const opRequestSpotInstances = "RequestSpotInstances"
// RequestSpotInstancesRequest generates a "aws/request.Request" representing the
// client's request for the RequestSpotInstances operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -21474,7 +21474,7 @@ const opResetFpgaImageAttribute = "ResetFpgaImageAttribute"
// ResetFpgaImageAttributeRequest generates a "aws/request.Request" representing the
// client's request for the ResetFpgaImageAttribute operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -21549,7 +21549,7 @@ const opResetImageAttribute = "ResetImageAttribute"
// ResetImageAttributeRequest generates a "aws/request.Request" representing the
// client's request for the ResetImageAttribute operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -21627,7 +21627,7 @@ const opResetInstanceAttribute = "ResetInstanceAttribute"
// ResetInstanceAttributeRequest generates a "aws/request.Request" representing the
// client's request for the ResetInstanceAttribute operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -21711,7 +21711,7 @@ const opResetNetworkInterfaceAttribute = "ResetNetworkInterfaceAttribute"
// ResetNetworkInterfaceAttributeRequest generates a "aws/request.Request" representing the
// client's request for the ResetNetworkInterfaceAttribute operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -21788,7 +21788,7 @@ const opResetSnapshotAttribute = "ResetSnapshotAttribute"
// ResetSnapshotAttributeRequest generates a "aws/request.Request" representing the
// client's request for the ResetSnapshotAttribute operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -21868,7 +21868,7 @@ const opRestoreAddressToClassic = "RestoreAddressToClassic"
// RestoreAddressToClassicRequest generates a "aws/request.Request" representing the
// client's request for the RestoreAddressToClassic operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -21945,7 +21945,7 @@ const opRevokeSecurityGroupEgress = "RevokeSecurityGroupEgress"
// RevokeSecurityGroupEgressRequest generates a "aws/request.Request" representing the
// client's request for the RevokeSecurityGroupEgress operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -22033,7 +22033,7 @@ const opRevokeSecurityGroupIngress = "RevokeSecurityGroupIngress"
// RevokeSecurityGroupIngressRequest generates a "aws/request.Request" representing the
// client's request for the RevokeSecurityGroupIngress operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -22124,7 +22124,7 @@ const opRunInstances = "RunInstances"
// RunInstancesRequest generates a "aws/request.Request" representing the
// client's request for the RunInstances operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -22251,7 +22251,7 @@ const opRunScheduledInstances = "RunScheduledInstances"
// RunScheduledInstancesRequest generates a "aws/request.Request" representing the
// client's request for the RunScheduledInstances operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -22335,7 +22335,7 @@ const opStartInstances = "StartInstances"
// StartInstancesRequest generates a "aws/request.Request" representing the
// client's request for the StartInstances operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -22431,7 +22431,7 @@ const opStopInstances = "StopInstances"
// StopInstancesRequest generates a "aws/request.Request" representing the
// client's request for the StopInstances operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -22537,7 +22537,7 @@ const opTerminateInstances = "TerminateInstances"
// TerminateInstancesRequest generates a "aws/request.Request" representing the
// client's request for the TerminateInstances operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -22635,7 +22635,7 @@ const opUnassignIpv6Addresses = "UnassignIpv6Addresses"
// UnassignIpv6AddressesRequest generates a "aws/request.Request" representing the
// client's request for the UnassignIpv6Addresses operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -22709,7 +22709,7 @@ const opUnassignPrivateIpAddresses = "UnassignPrivateIpAddresses"
// UnassignPrivateIpAddressesRequest generates a "aws/request.Request" representing the
// client's request for the UnassignPrivateIpAddresses operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -22785,7 +22785,7 @@ const opUnmonitorInstances = "UnmonitorInstances"
// UnmonitorInstancesRequest generates a "aws/request.Request" representing the
// client's request for the UnmonitorInstances operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -22861,7 +22861,7 @@ const opUpdateSecurityGroupRuleDescriptionsEgress = "UpdateSecurityGroupRuleDesc
// UpdateSecurityGroupRuleDescriptionsEgressRequest generates a "aws/request.Request" representing the
// client's request for the UpdateSecurityGroupRuleDescriptionsEgress operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -22941,7 +22941,7 @@ const opUpdateSecurityGroupRuleDescriptionsIngress = "UpdateSecurityGroupRuleDes
// UpdateSecurityGroupRuleDescriptionsIngressRequest generates a "aws/request.Request" representing the
// client's request for the UpdateSecurityGroupRuleDescriptionsIngress operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -71161,6 +71161,15 @@ const (
// InstanceTypeZ1d12xlarge is a InstanceType enum value
InstanceTypeZ1d12xlarge = "z1d.12xlarge"
+
+ // InstanceTypeU6tb1Metal is a InstanceType enum value
+ InstanceTypeU6tb1Metal = "u-6tb1.metal"
+
+ // InstanceTypeU9tb1Metal is a InstanceType enum value
+ InstanceTypeU9tb1Metal = "u-9tb1.metal"
+
+ // InstanceTypeU12tb1Metal is a InstanceType enum value
+ InstanceTypeU12tb1Metal = "u-12tb1.metal"
)
const (
diff --git a/vendor/github.com/aws/aws-sdk-go/service/sts/api.go b/vendor/github.com/aws/aws-sdk-go/service/sts/api.go
index 6f89a796e5..ee908f9167 100644
--- a/vendor/github.com/aws/aws-sdk-go/service/sts/api.go
+++ b/vendor/github.com/aws/aws-sdk-go/service/sts/api.go
@@ -15,7 +15,7 @@ const opAssumeRole = "AssumeRole"
// AssumeRoleRequest generates a "aws/request.Request" representing the
// client's request for the AssumeRole operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -209,7 +209,7 @@ const opAssumeRoleWithSAML = "AssumeRoleWithSAML"
// AssumeRoleWithSAMLRequest generates a "aws/request.Request" representing the
// client's request for the AssumeRoleWithSAML operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -391,7 +391,7 @@ const opAssumeRoleWithWebIdentity = "AssumeRoleWithWebIdentity"
// AssumeRoleWithWebIdentityRequest generates a "aws/request.Request" representing the
// client's request for the AssumeRoleWithWebIdentity operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -602,7 +602,7 @@ const opDecodeAuthorizationMessage = "DecodeAuthorizationMessage"
// DecodeAuthorizationMessageRequest generates a "aws/request.Request" representing the
// client's request for the DecodeAuthorizationMessage operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -714,7 +714,7 @@ const opGetCallerIdentity = "GetCallerIdentity"
// GetCallerIdentityRequest generates a "aws/request.Request" representing the
// client's request for the GetCallerIdentity operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -789,7 +789,7 @@ const opGetFederationToken = "GetFederationToken"
// GetFederationTokenRequest generates a "aws/request.Request" representing the
// client's request for the GetFederationToken operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
@@ -958,7 +958,7 @@ const opGetSessionToken = "GetSessionToken"
// GetSessionTokenRequest generates a "aws/request.Request" representing the
// client's request for the GetSessionToken operation. The "output" return
// value will be populated with the request's response once the request completes
-// successfuly.
+// successfully.
//
// Use "Send" method on the returned Request to send the API call to the service.
// the "output" return value is not valid until after Send returns without error.
diff --git a/vendor/github.com/c-bata/go-prompt/CHANGELOG.md b/vendor/github.com/c-bata/go-prompt/CHANGELOG.md
index a1fcb273be..ac4b02dc1f 100644
--- a/vendor/github.com/c-bata/go-prompt/CHANGELOG.md
+++ b/vendor/github.com/c-bata/go-prompt/CHANGELOG.md
@@ -1,31 +1,10 @@
# Change Log
-## v0.3.0 (2018/??/??)
-
-next release.
-
-## v0.2.2 (2018/06/28)
-
-### What's new?
-
-* Support CJK(Chinese, Japanese and Korean) and Cyrillic characters.
-* Add OptionCompletionWordSeparator(x string) to customize insertion points for completions.
- * To support this, text query functions by arbitrary word separator are added in Document (please see [here](https://github.com/c-bata/go-prompt/pull/79) for more details).
-* Add FilePathCompleter to complete file path on your system.
-* Add option to customize ascii code key bindings.
-* Add GetWordAfterCursor method in Document.
-
-### Removed or Deprecated
-
-* SetColor method in ConsoleWriter is deprecated. Please use SetDisplayAttributes instead.
-* prompt.Choose shortcut function is deprecated.
-
## v0.2.1 (2018/02/14)
### What's New?
-* ~~It seems that windows support is almost perfect.~~
- * A critical bug is found :( When you change a terminal window size, the layout will be broken because current implementation cannot catch signal for updating window size on Windows.
+* It seems that windows support is almost perfect.
### Fixed
diff --git a/vendor/github.com/c-bata/go-prompt/DEVELOPER_GUIDE.md b/vendor/github.com/c-bata/go-prompt/DEVELOPER_GUIDE.md
new file mode 100644
index 0000000000..44f2c55bd2
--- /dev/null
+++ b/vendor/github.com/c-bata/go-prompt/DEVELOPER_GUIDE.md
@@ -0,0 +1,155 @@
+# Developer Guide
+
+## Getting Started
+
+The most simple example is below.
+
+```go
+package main
+
+import (
+ "fmt"
+
+ "github.com/c-bata/go-prompt"
+)
+
+// executor executes command and print the output.
+func executor(in string) {
+ fmt.Println("Your input: " + in)
+}
+
+// completer returns the completion items from user input.
+func completer(d prompt.Document) []prompt.Suggest {
+ s := []prompt.Suggest{
+ {Text: "users", Description: "user table"},
+ {Text: "sites", Description: "sites table"},
+ {Text: "articles", Description: "articles table"},
+ {Text: "comments", Description: "comments table"},
+ }
+ return prompt.FilterHasPrefix(s, d.GetWordBeforeCursor(), true)
+}
+
+func main() {
+ p := prompt.New(
+ executor,
+ completer,
+ prompt.OptionPrefix(">>> "),
+ prompt.OptionTitle("sql-prompt"),
+ )
+ p.Run()
+}
+```
+
+If you want to create CLI using go-prompt, I recommend you to look at the [source code of kube-prompt](https://github.com/c-bata/kube-prompt).
+It is the most practical example.
+
+
+## Options
+
+go-prompt has many color options.
+It is difficult to describe by text. So please see below figure:
+
+
+
+* **OptionPrefixTextColor(prompt.Color)** : default `prompt.Blue`
+* **OptionPrefixBackgroundColor(prompt.Color)** : default `prompt.DefaultColor`
+* **OptionInputTextColor(prompt.Color)** : default `prompt.DefaultColor`
+* **OptionInputBGColor(prompt.Color)** : default `prompt.DefaultColor`
+* **OptionPreviewSuggestionTextColor(prompt.Color)** : default `prompt.Green`
+* **OptionPreviewSuggestionBGColor(prompt.Color)** : default `prompt.DefaultColor`
+* **OptionSuggestionTextColor(prompt.Color)** : default `prompt.White`
+* **OptionSuggestionBGColor(prompt.Color)** : default `prompt.Cyan`
+* **OptionSelectedSuggestionTextColor(prompt.Color)** : `default prompt.Black`
+* **OptionSelectedSuggestionBGColor(prompt.Color)** : `default prompt.DefaultColor`
+* **OptionDescriptionTextColor(prompt.Color)** : default `prompt.Black`
+* **OptionDescriptionBGColor(prompt.Color)** : default `prompt.Turquoise`
+* **OptionSelectedDescriptionTextColor(prompt.Color)** : default `prompt.White`
+* **OptionSelectedDescriptionBGColor(prompt.Color)** : default `prompt.Cyan`
+* **OptionScrollbarThumbColor** : `prompt.DarkGray`
+* **OptionScrollbarBGColor** : `prompt.Cyan`
+
+**Other Options**
+
+#### `OptionTitle(string)` : default `""`
+Option to set a title that wll be displayed on the header bar of terminal.
+
+#### `OptionHistory([]string)` : default `[]string{}`
+Option to set history.
+
+#### `OptionPrefix(string)` : default `"> "`
+Option to set prefix string.
+
+#### `OptionLivePrefix(func() (prefix string, useLivePrefix bool))` : default `nil`
+Option to set a callback function for updating prefix string dynamically.
+
+#### `OptionMaxSuggestions(x uint16)` : default `6`
+The max number of displayed suggestions.
+
+#### `OptionParser(prompt.ConsoleParser)` : default `VT100Parser`
+To set a custom ConsoleParser object.
+The argument should implement ConsoleParser interface.
+
+#### `OptionWriter(prompt.ConsoleWriter)` : default `VT100Writer`
+To set a custom ConsoleWriter object.
+The argument should implement ConsoleWriter interface.
+
+#### `SwitchKeyBindMode(prompt.KeyBindMode)` : default `prompt.EmacsKeyBindMode`
+To set a key bind mode.
+
+#### `OptionAddKeyBind(...KeyBind)` : default `[]KeyBind{}`
+To set a custom key bind.
+
+## Architecture of go-prompt
+
+*Caution: This section is WIP.*
+
+This is a short description of go-prompt implementation.
+go-prompt consists of three parts.
+
+1. Input parser
+2. Emulate user input with Buffer object.
+3. Render buffer object.
+
+### Input Parser
+
+
+
+Input Parser only supports vt100-compatible console now.
+
+* Set as the raw mode.
+* Read a standard input.
+* Parse to byte array
+
+### Emulate user input
+
+go-prompt contains Buffer class.
+It represents input state by handling a key input by user.
+
+`Buffer` object has text and cursor position.
+
+**TODO prepare the sample of buffer**
+
+```go
+package main
+
+import "github.com/c-bata/go-prompt"
+
+func main() {
+ b := prompt.NewBuffer()
+ ... wip
+}
+```
+
+### Renderer
+
+`Renderer` object renders a buffer object.
+
+**TODO prepare the sample of brender**
+
+```go
+package main
+```
+
+the output is below:
+
+**TODO prepare a screen shot**
diff --git a/vendor/github.com/c-bata/go-prompt/Gopkg.lock b/vendor/github.com/c-bata/go-prompt/Gopkg.lock
index 1b6866bfcb..0228094527 100644
--- a/vendor/github.com/c-bata/go-prompt/Gopkg.lock
+++ b/vendor/github.com/c-bata/go-prompt/Gopkg.lock
@@ -13,33 +13,27 @@
revision = "0360b2af4f38e8d38c7fce2a9f4e702702d73a39"
version = "v0.0.3"
-[[projects]]
- branch = "master"
- name = "github.com/mattn/go-runewidth"
- packages = ["."]
- revision = "ce7b0b5c7b45a81508558cd1dba6bb1e4ddb51bb"
-
[[projects]]
branch = "master"
name = "github.com/mattn/go-tty"
packages = ["."]
- revision = "931426f7535ac39720c8909d70ece5a41a2502a6"
+ revision = "c1750293025292316a611ae8f632d9791515e51c"
[[projects]]
branch = "master"
name = "github.com/pkg/term"
packages = ["termios"]
- revision = "cda20d4ac917ad418d86e151eff439648b06185b"
+ revision = "b1f72af2d63057363398bec5873d16a98b453312"
[[projects]]
branch = "master"
name = "golang.org/x/sys"
packages = ["unix"]
- revision = "ad87a3a340fa7f3bed189293fbfa7a9b7e021ae1"
+ revision = "37707fdb30a5b38865cfb95e5aab41707daec7fd"
[solve-meta]
analyzer-name = "dep"
analyzer-version = 1
- inputs-digest = "d6a0ea9e49092cfd8cb3d6077c97a938de7c39195b83828dae2a0befdd207ffd"
+ inputs-digest = "6c442f55617e93df75aa1ee2fd2b36cfab23003fded4723be56c6b6fd0545c56"
solver-name = "gps-cdcl"
solver-version = 1
diff --git a/vendor/github.com/c-bata/go-prompt/Gopkg.toml b/vendor/github.com/c-bata/go-prompt/Gopkg.toml
index 903f53b251..fe31c575ad 100644
--- a/vendor/github.com/c-bata/go-prompt/Gopkg.toml
+++ b/vendor/github.com/c-bata/go-prompt/Gopkg.toml
@@ -32,7 +32,3 @@
[[constraint]]
branch = "master"
name = "github.com/pkg/term"
-
-[[constraint]]
- branch = "master"
- name = "github.com/mattn/go-runewidth"
diff --git a/vendor/github.com/c-bata/go-prompt/Makefile b/vendor/github.com/c-bata/go-prompt/Makefile
index 3cb6edfe63..caf263cabc 100644
--- a/vendor/github.com/c-bata/go-prompt/Makefile
+++ b/vendor/github.com/c-bata/go-prompt/Makefile
@@ -21,11 +21,6 @@ lint: ## Run golint and go vet.
test: ## Run the tests.
@go test .
-.PHONY: coverage
-cover: ## Run the tests.
- @go test -coverprofile=coverage.o
- @go tool cover -func=coverage.o
-
.PHONY: race-test
race-test: ## Checking the race condition.
@go test -race .
diff --git a/vendor/github.com/c-bata/go-prompt/README.md b/vendor/github.com/c-bata/go-prompt/README.md
index a949b8b9d8..e66ae425e0 100644
--- a/vendor/github.com/c-bata/go-prompt/README.md
+++ b/vendor/github.com/c-bata/go-prompt/README.md
@@ -1,10 +1,7 @@
# go-prompt
-[](https://goreportcard.com/report/github.com/c-bata/go-prompt)
-
-
-A library for building powerful interactive prompts inspired by [python-prompt-toolkit](https://github.com/jonathanslenders/python-prompt-toolkit),
-making it easier to build cross-platform command line tools using Go.
+Library for building a powerful interactive prompt, inspired by [python-prompt-toolkit](https://github.com/jonathanslenders/python-prompt-toolkit).
+Easy building a multi-platform binary of the command line tools because written in Golang.
```go
package main
@@ -30,15 +27,15 @@ func main() {
}
```
+
#### Projects using go-prompt
* [c-bata/kube-prompt : An interactive kubernetes client featuring auto-complete written in Go.](https://github.com/c-bata/kube-prompt)
* [rancher/cli : The Rancher Command Line Interface (CLI)is a unified tool to manage your Rancher server](https://github.com/rancher/cli)
-* [kubicorn/kubicorn : Simple, cloud native infrastructure for Kubernetes.](https://github.com/kubicorn/kubicorn)
+* [kris-nova/kubicorn : Simple. Cloud Native. Kubernetes. Infrastructure.](https://github.com/kris-nova/kubicorn)
* [cch123/asm-cli : Interactive shell of assembly language(X86/X64) based on unicorn and rasm2](https://github.com/cch123/asm-cli)
* [ktr0731/evans : more expressive universal gRPC client](https://github.com/ktr0731/evans)
-* [CrushedPixel/moshpit: A Command-line tool for datamoshing.](https://github.com/CrushedPixel/moshpit)
-* (If you create a CLI utility using go-prompt and want your own project to be listed here, please submit a GitHub issue.)
+* (If you create a CLI using go-prompt and want your own project to be listed here, Please submit a Github Issue.)
## Features
@@ -50,52 +47,54 @@ func main() {
### Flexible options
-go-prompt provides many options. Please check [option section of GoDoc](https://godoc.org/github.com/c-bata/go-prompt#Option) for more details.
+go-prompt provides many options. All options are listed in [Developer Guide](./DEVELOPER_GUIDE.md).
[](#flexible-options)
### Keyboard Shortcuts
-Emacs-like keyboard shortcuts are available by default (these also are the default shortcuts in Bash shell).
+Emacs-like keyboard shortcut is available by default (it's also default shortcuts in Bash shell).
You can customize and expand these shortcuts.
[](#keyboard-shortcuts)
-Key Binding | Description
----------------------|---------------------------------------------------------
-Ctrl + A | Go to the beginning of the line (Home)
-Ctrl + E | Go to the end of the line (End)
-Ctrl + P | Previous command (Up arrow)
-Ctrl + N | Next command (Down arrow)
-Ctrl + F | Forward one character
-Ctrl + B | Backward one character
-Ctrl + D | Delete character under the cursor
-Ctrl + H | Delete character before the cursor (Backspace)
-Ctrl + W | Cut the word before the cursor to the clipboard
-Ctrl + K | Cut the line after the cursor to the clipboard
-Ctrl + U | Cut the line before the cursor to the clipboard
-Ctrl + L | Clear the screen
+KeyBinding | Description
+--------------------|---------------------------------------------------------
+Ctrl + A | Go to the beginning of the line (Home)
+Ctrl + E | Go to the End of the line (End)
+Ctrl + P | Previous command (Up arrow)
+Ctrl + N | Next command (Down arrow)
+Ctrl + F | Forward one character
+Ctrl + B | Backward one character
+Ctrl + D | Delete character under the cursor
+Ctrl + H | Delete character before the cursor (Backspace)
+Ctrl + W | Cut the Word before the cursor to the clipboard.
+Ctrl + K | Cut the Line after the cursor to the clipboard.
+Ctrl + U | Cut/delete the Line before the cursor to the clipboard.
+Ctrl + L | Clear the screen
### History
-You can use Up arrow and Down arrow to walk through the history of commands executed.
+You can use up-arrow and down-arrow to walk through the history of commands executed.
[](#history)
+
### Multiple platform support
-We have confirmed go-prompt works fine in the following terminals:
+We confirmed following terminals
* iTerm2 (macOS)
* Terminal.app (macOS)
* Command Prompt (Windows)
-* gnome-terminal (Ubuntu)
+* GNU Terminal (Ubuntu)
+
## Links
+* [Developer Guide](./DEVELOPER_GUIDE.md).
* [Change Log](./CHANGELOG.md)
-* [GoDoc](http://godoc.org/github.com/c-bata/go-prompt)
-* [gocover.io](https://gocover.io/github.com/c-bata/go-prompt)
+* [GoDoc](http://godoc.org/github.com/c-bata/go-prompt).
## Author
@@ -105,6 +104,7 @@ Masashi Shibata
* Github: [@c-bata](https://github.com/c-bata/)
* Facebook: [Masashi Shibata](https://www.facebook.com/masashi.cbata)
-## License
+## LICENSE
+
+This software is licensed under the MIT License (See [LICENSE](./LICENSE) ).
-This software is licensed under the MIT license, see [LICENSE](./LICENSE) for more information.
diff --git a/vendor/github.com/c-bata/go-prompt/bisect.go b/vendor/github.com/c-bata/go-prompt/bisect.go
new file mode 100644
index 0000000000..2bcef3a5be
--- /dev/null
+++ b/vendor/github.com/c-bata/go-prompt/bisect.go
@@ -0,0 +1,27 @@
+package prompt
+
+import "sort"
+
+// BisectLeft to Locate the insertion point for v in a to maintain sorted order.
+func BisectLeft(a []int, v int) int {
+ return bisectLeftRange(a, v, 0, len(a))
+}
+
+func bisectLeftRange(a []int, v int, lo, hi int) int {
+ s := a[lo:hi]
+ return sort.Search(len(s), func(i int) bool {
+ return s[i] >= v
+ })
+}
+
+// BisectRight to Locate the insertion point for v in a to maintain sorted order.
+func BisectRight(a []int, v int) int {
+ return bisectRightRange(a, v, 0, len(a))
+}
+
+func bisectRightRange(a []int, v int, lo, hi int) int {
+ s := a[lo:hi]
+ return sort.Search(len(s), func(i int) bool {
+ return s[i] > v
+ })
+}
diff --git a/vendor/github.com/c-bata/go-prompt/buffer.go b/vendor/github.com/c-bata/go-prompt/buffer.go
index 6c29b461e3..929d2fcecb 100644
--- a/vendor/github.com/c-bata/go-prompt/buffer.go
+++ b/vendor/github.com/c-bata/go-prompt/buffer.go
@@ -9,7 +9,7 @@ import (
type Buffer struct {
workingLines []string // The working lines. Similar to history
workingIndex int
- cursorPosition int
+ CursorPosition int
cacheDocument *Document
preferredColumn int // Remember the original column for the next up/down movement.
}
@@ -23,25 +23,19 @@ func (b *Buffer) Text() string {
func (b *Buffer) Document() (d *Document) {
if b.cacheDocument == nil ||
b.cacheDocument.Text != b.Text() ||
- b.cacheDocument.cursorPosition != b.cursorPosition {
+ b.cacheDocument.CursorPosition != b.CursorPosition {
b.cacheDocument = &Document{
Text: b.Text(),
- cursorPosition: b.cursorPosition,
+ CursorPosition: b.CursorPosition,
}
}
return b.cacheDocument
}
-// DisplayCursorPosition returns the cursor position on rendered text on terminal emulators.
-// So if Document is "日本(cursor)語", DisplayedCursorPosition returns 4 because '日' and '本' are double width characters.
-func (b *Buffer) DisplayCursorPosition() int {
- return b.Document().DisplayCursorPosition()
-}
-
// InsertText insert string from current line.
func (b *Buffer) InsertText(v string, overwrite bool, moveCursor bool) {
or := []rune(b.Text())
- oc := b.cursorPosition
+ oc := b.CursorPosition
if overwrite {
overwritten := string(or[oc : oc+len(v)])
@@ -55,15 +49,15 @@ func (b *Buffer) InsertText(v string, overwrite bool, moveCursor bool) {
}
if moveCursor {
- b.cursorPosition += len([]rune(v))
+ b.CursorPosition += len([]rune(v))
}
}
-// SetText method to set text and update cursorPosition.
+// SetText method to set text and update CursorPosition.
// (When doing this, make sure that the cursor_position is valid for this text.
// text/cursor_position should be consistent at any time, otherwise set a Document instead.)
func (b *Buffer) setText(v string) {
- if b.cursorPosition > len([]rune(v)) {
+ if b.CursorPosition > len([]rune(v)) {
log.Print("[ERROR] The length of input value should be shorter than the position of cursor.")
}
o := b.workingLines[b.workingIndex]
@@ -78,11 +72,11 @@ func (b *Buffer) setText(v string) {
// Set cursor position. Return whether it changed.
func (b *Buffer) setCursorPosition(p int) {
- o := b.cursorPosition
+ o := b.CursorPosition
if p > 0 {
- b.cursorPosition = p
+ b.CursorPosition = p
} else {
- b.cursorPosition = 0
+ b.CursorPosition = 0
}
if p != o {
// Cursor position is changed.
@@ -92,21 +86,21 @@ func (b *Buffer) setCursorPosition(p int) {
func (b *Buffer) setDocument(d *Document) {
b.cacheDocument = d
- b.setCursorPosition(d.cursorPosition) // Call before setText because setText check the relation between cursorPosition and line length.
+ b.setCursorPosition(d.CursorPosition) // Call before setText because setText check the relation between cursorPosition and line length.
b.setText(d.Text)
}
// CursorLeft move to left on the current line.
func (b *Buffer) CursorLeft(count int) {
l := b.Document().GetCursorLeftPosition(count)
- b.cursorPosition += l
+ b.CursorPosition += l
return
}
// CursorRight move to right on the current line.
func (b *Buffer) CursorRight(count int) {
l := b.Document().GetCursorRightPosition(count)
- b.cursorPosition += l
+ b.CursorPosition += l
return
}
@@ -117,7 +111,7 @@ func (b *Buffer) CursorUp(count int) {
if b.preferredColumn == -1 { // -1 means nil
orig = b.Document().CursorPositionCol()
}
- b.cursorPosition += b.Document().GetCursorUpPosition(count, orig)
+ b.CursorPosition += b.Document().GetCursorUpPosition(count, orig)
// Remember the original column for the next up/down movement.
b.preferredColumn = orig
@@ -130,7 +124,7 @@ func (b *Buffer) CursorDown(count int) {
if b.preferredColumn == -1 { // -1 means nil
orig = b.Document().CursorPositionCol()
}
- b.cursorPosition += b.Document().GetCursorDownPosition(count, orig)
+ b.CursorPosition += b.Document().GetCursorDownPosition(count, orig)
// Remember the original column for the next up/down movement.
b.preferredColumn = orig
@@ -143,15 +137,15 @@ func (b *Buffer) DeleteBeforeCursor(count int) (deleted string) {
}
r := []rune(b.Text())
- if b.cursorPosition > 0 {
- start := b.cursorPosition - count
+ if b.CursorPosition > 0 {
+ start := b.CursorPosition - count
if start < 0 {
start = 0
}
- deleted = string(r[start:b.cursorPosition])
+ deleted = string(r[start:b.CursorPosition])
b.setDocument(&Document{
- Text: string(r[:start]) + string(r[b.cursorPosition:]),
- cursorPosition: b.cursorPosition - len([]rune(deleted)),
+ Text: string(r[:start]) + string(r[b.CursorPosition:]),
+ CursorPosition: b.CursorPosition - len([]rune(deleted)),
})
}
return
@@ -169,9 +163,9 @@ func (b *Buffer) NewLine(copyMargin bool) {
// Delete specified number of characters and Return the deleted text.
func (b *Buffer) Delete(count int) (deleted string) {
r := []rune(b.Text())
- if b.cursorPosition < len(r) {
+ if b.CursorPosition < len(r) {
deleted = b.Document().TextAfterCursor()[:count]
- b.setText(string(r[:b.cursorPosition]) + string(r[b.cursorPosition+len(deleted):]))
+ b.setText(string(r[:b.CursorPosition]) + string(r[b.CursorPosition+len(deleted):]))
}
return
}
@@ -179,7 +173,7 @@ func (b *Buffer) Delete(count int) (deleted string) {
// JoinNextLine joins the next line to the current one by deleting the line ending after the current line.
func (b *Buffer) JoinNextLine(separator string) {
if !b.Document().OnLastLine() {
- b.cursorPosition += b.Document().GetEndOfLinePosition()
+ b.CursorPosition += b.Document().GetEndOfLinePosition()
b.Delete(1)
// Remove spaces
b.setText(b.Document().TextBeforeCursor() + separator + strings.TrimLeft(b.Document().TextAfterCursor(), " "))
@@ -188,10 +182,10 @@ func (b *Buffer) JoinNextLine(separator string) {
// SwapCharactersBeforeCursor swaps the last two characters before the cursor.
func (b *Buffer) SwapCharactersBeforeCursor() {
- if b.cursorPosition >= 2 {
- x := b.Text()[b.cursorPosition-2 : b.cursorPosition-1]
- y := b.Text()[b.cursorPosition-1 : b.cursorPosition]
- b.setText(b.Text()[:b.cursorPosition-2] + y + x + b.Text()[b.cursorPosition:])
+ if b.CursorPosition >= 2 {
+ x := b.Text()[b.CursorPosition-2 : b.CursorPosition-1]
+ y := b.Text()[b.CursorPosition-1 : b.CursorPosition]
+ b.setText(b.Text()[:b.CursorPosition-2] + y + x + b.Text()[b.CursorPosition:])
}
}
diff --git a/vendor/github.com/c-bata/go-prompt/completion.go b/vendor/github.com/c-bata/go-prompt/completion.go
index 5f698034bf..0c0f54bf81 100644
--- a/vendor/github.com/c-bata/go-prompt/completion.go
+++ b/vendor/github.com/c-bata/go-prompt/completion.go
@@ -3,21 +3,16 @@ package prompt
import (
"log"
"strings"
-
- "github.com/mattn/go-runewidth"
)
const (
- shortenSuffix = "..."
- leftPrefix = " "
- leftSuffix = " "
- rightPrefix = " "
- rightSuffix = " "
-)
-
-var (
- leftMargin = runewidth.StringWidth(leftPrefix + leftSuffix)
- rightMargin = runewidth.StringWidth(rightPrefix + rightSuffix)
+ shortenSuffix = "..."
+ leftPrefix = " "
+ leftSuffix = " "
+ rightPrefix = " "
+ rightSuffix = " "
+ leftMargin = len(leftPrefix + leftSuffix)
+ rightMargin = len(rightPrefix + rightSuffix)
completionMargin = leftMargin + rightMargin
)
@@ -35,7 +30,6 @@ type CompletionManager struct {
completer Completer
verticalScroll int
- wordSeparator string
}
// GetSelectedSuggestion returns the selected item.
@@ -108,26 +102,17 @@ func (c *CompletionManager) update() {
}
}
-func deleteBreakLineCharacters(s string) string {
- s = strings.Replace(s, "\n", "", -1)
- s = strings.Replace(s, "\r", "", -1)
- return s
-}
-
func formatTexts(o []string, max int, prefix, suffix string) (new []string, width int) {
l := len(o)
n := make([]string, l)
- lenPrefix := runewidth.StringWidth(prefix)
- lenSuffix := runewidth.StringWidth(suffix)
- lenShorten := runewidth.StringWidth(shortenSuffix)
+ lenPrefix := len([]rune(prefix))
+ lenSuffix := len([]rune(suffix))
+ lenShorten := len(shortenSuffix)
min := lenPrefix + lenSuffix + lenShorten
for i := 0; i < l; i++ {
- o[i] = deleteBreakLineCharacters(o[i])
-
- w := runewidth.StringWidth(o[i])
- if width < w {
- width = w
+ if width < len([]rune(o[i])) {
+ width = len([]rune(o[i]))
}
}
@@ -143,15 +128,13 @@ func formatTexts(o []string, max int, prefix, suffix string) (new []string, widt
}
for i := 0; i < l; i++ {
- x := runewidth.StringWidth(o[i])
+ r := []rune(o[i])
+ x := len(r)
if x <= width {
spaces := strings.Repeat(" ", width-x)
n[i] = prefix + o[i] + spaces + suffix
} else if x > width {
- x := runewidth.Truncate(o[i], width, shortenSuffix)
- // When calling runewidth.Truncate("您好xxx您好xxx", 11, "...") returns "您好xxx..."
- // But the length of this result is 10. So we need fill right using runewidth.FillRight.
- n[i] = prefix + runewidth.FillRight(x, width) + suffix
+ n[i] = prefix + string(r[:width-lenShorten]) + shortenSuffix + suffix
}
}
return n, lenPrefix + width + lenSuffix
diff --git a/vendor/github.com/c-bata/go-prompt/output.go b/vendor/github.com/c-bata/go-prompt/console_interface.go
similarity index 58%
rename from vendor/github.com/c-bata/go-prompt/output.go
rename to vendor/github.com/c-bata/go-prompt/console_interface.go
index 5afb81c090..1215359a77 100644
--- a/vendor/github.com/c-bata/go-prompt/output.go
+++ b/vendor/github.com/c-bata/go-prompt/console_interface.go
@@ -1,90 +1,63 @@
package prompt
-// DisplayAttribute represents display attributes like Blinking, Bold, Italic and so on.
-type DisplayAttribute int
-
-const (
- // DisplayReset reset all display attributes.
- DisplayReset DisplayAttribute = iota
- // DisplayBold set bold or increases intensity.
- DisplayBold
- // DisplayLowIntensity decreases intensity. Not widely supported.
- DisplayLowIntensity
- // DisplayItalic set italic. Not widely supported.
- DisplayItalic
- // DisplayUnderline set underline
- DisplayUnderline
- // DisplayBlink set blink (less than 150 per minute).
- DisplayBlink
- // DisplayRapidBlink set blink (more than 150 per minute). Not widely supported.
- DisplayRapidBlink
- // DisplayReverse swap foreground and background colors.
- DisplayReverse
- // DisplayInvisible set invisible. Not widely supported.
- DisplayInvisible
- // DisplayCrossedOut set characters legible, but marked for deletion. Not widely supported.
- DisplayCrossedOut
- // DisplayDefaultFont set primary(default) font
- DisplayDefaultFont
-)
+// WinSize represents the width and height of terminal.
+type WinSize struct {
+ Row uint16
+ Col uint16
+}
// Color represents color on terminal.
type Color int
const (
- // DefaultColor represents a default color.
DefaultColor Color = iota
// Low intensity
-
- // Black represents a black.
Black
- // DarkRed represents a dark red.
DarkRed
- // DarkGreen represents a dark green.
DarkGreen
- // Brown represents a brown.
Brown
- // DarkBlue represents a dark blue.
DarkBlue
- // Purple represents a purple.
Purple
- // Cyan represents a cyan.
Cyan
- // LightGray represents a light gray.
LightGray
// High intensity
-
- // DarkGray represents a dark gray.
DarkGray
- // Red represents a red.
Red
- // Green represents a green.
Green
- // Yellow represents a yellow.
Yellow
- // Blue represents a blue.
Blue
- // Fuchsia represents a fuchsia.
Fuchsia
- // Turquoise represents a turquoise.
Turquoise
- // White represents a white.
White
)
+// ConsoleParser is an interface to abstract input layer.
+type ConsoleParser interface {
+ // Setup should be called before starting input
+ Setup() error
+ // TearDown should be called after stopping input
+ TearDown() error
+ // GetKey returns Key correspond to input byte codes.
+ GetKey(b []byte) Key
+ // GetWinSize returns WinSize object to represent width and height of terminal.
+ GetWinSize() *WinSize
+ // Read returns byte array.
+ Read() ([]byte, error)
+}
+
// ConsoleWriter is an interface to abstract output layer.
type ConsoleWriter interface {
/* Write */
// WriteRaw to write raw byte array.
WriteRaw(data []byte)
- // Write to write safety byte array by removing control sequences.
+ // Write to write byte array without control sequences.
Write(data []byte)
// WriteStr to write raw string.
WriteRawStr(data string)
- // WriteStr to write safety string by removing control sequences.
+ // WriteStr to write string without control sequences.
WriteStr(data string)
// Flush to flush buffer.
Flush() error
diff --git a/vendor/github.com/c-bata/go-prompt/document.go b/vendor/github.com/c-bata/go-prompt/document.go
index 06b436a21d..94a410e229 100644
--- a/vendor/github.com/c-bata/go-prompt/document.go
+++ b/vendor/github.com/c-bata/go-prompt/document.go
@@ -1,41 +1,24 @@
package prompt
import (
- "sort"
"strings"
"unicode/utf8"
-
- "github.com/mattn/go-runewidth"
)
// Document has text displayed in terminal and cursor position.
type Document struct {
- Text string
- // This represents a index in a rune array of Document.Text.
- // So if Document is "日本(cursor)語", cursorPosition is 2.
- // But DisplayedCursorPosition returns 4 because '日' and '本' are double width characters.
- cursorPosition int
+ Text string
+ CursorPosition int
}
// NewDocument return the new empty document.
func NewDocument() *Document {
return &Document{
Text: "",
- cursorPosition: 0,
+ CursorPosition: 0,
}
}
-// DisplayCursorPosition returns the cursor position on rendered text on terminal emulators.
-// So if Document is "日本(cursor)語", DisplayedCursorPosition returns 4 because '日' and '本' are double width characters.
-func (d *Document) DisplayCursorPosition() int {
- var position int
- runes := []rune(d.Text)[:d.cursorPosition]
- for i := range runes {
- position += runewidth.RuneWidth(runes[i])
- }
- return position
-}
-
// GetCharRelativeToCursor return character relative to cursor position, or empty string
func (d *Document) GetCharRelativeToCursor(offset int) (r rune) {
s := d.Text
@@ -44,7 +27,7 @@ func (d *Document) GetCharRelativeToCursor(offset int) (r rune) {
for len(s) > 0 {
cnt++
r, size := utf8.DecodeRuneInString(s)
- if cnt == d.cursorPosition+offset {
+ if cnt == d.CursorPosition+offset {
return r
}
s = s[size:]
@@ -55,13 +38,13 @@ func (d *Document) GetCharRelativeToCursor(offset int) (r rune) {
// TextBeforeCursor returns the text before the cursor.
func (d *Document) TextBeforeCursor() string {
r := []rune(d.Text)
- return string(r[:d.cursorPosition])
+ return string(r[:d.CursorPosition])
}
// TextAfterCursor returns the text after the cursor.
func (d *Document) TextAfterCursor() string {
r := []rune(d.Text)
- return string(r[d.cursorPosition:])
+ return string(r[d.CursorPosition:])
}
// GetWordBeforeCursor returns the word before the cursor.
@@ -71,13 +54,6 @@ func (d *Document) GetWordBeforeCursor() string {
return x[d.FindStartOfPreviousWord():]
}
-// GetWordAfterCursor returns the word after the cursor.
-// If we have whitespace after the cursor this returns an empty string.
-func (d *Document) GetWordAfterCursor() string {
- x := d.TextAfterCursor()
- return x[:d.FindEndOfCurrentWord()]
-}
-
// GetWordBeforeCursorWithSpace returns the word before the cursor.
// Unlike GetWordBeforeCursor, it returns string containing space
func (d *Document) GetWordBeforeCursorWithSpace() string {
@@ -85,46 +61,16 @@ func (d *Document) GetWordBeforeCursorWithSpace() string {
return x[d.FindStartOfPreviousWordWithSpace():]
}
-// GetWordAfterCursorWithSpace returns the word after the cursor.
-// Unlike GetWordAfterCursor, it returns string containing space
-func (d *Document) GetWordAfterCursorWithSpace() string {
- x := d.TextAfterCursor()
- return x[:d.FindEndOfCurrentWordWithSpace()]
-}
-
-// GetWordBeforeCursorUntilSeparator returns the text before the cursor until next separator.
-func (d *Document) GetWordBeforeCursorUntilSeparator(sep string) string {
- x := d.TextBeforeCursor()
- return x[d.FindStartOfPreviousWordUntilSeparator(sep):]
-}
-
-// GetWordAfterCursorUntilSeparator returns the text after the cursor until next separator.
-func (d *Document) GetWordAfterCursorUntilSeparator(sep string) string {
- x := d.TextAfterCursor()
- return x[:d.FindEndOfCurrentWordUntilSeparator(sep)]
-}
-
-// GetWordBeforeCursorUntilSeparatorIgnoreNextToCursor returns the word before the cursor.
-// Unlike GetWordBeforeCursor, it returns string containing space
-func (d *Document) GetWordBeforeCursorUntilSeparatorIgnoreNextToCursor(sep string) string {
- x := d.TextBeforeCursor()
- return x[d.FindStartOfPreviousWordUntilSeparatorIgnoreNextToCursor(sep):]
-}
-
-// GetWordAfterCursorUntilSeparatorIgnoreNextToCursor returns the word after the cursor.
-// Unlike GetWordAfterCursor, it returns string containing space
-func (d *Document) GetWordAfterCursorUntilSeparatorIgnoreNextToCursor(sep string) string {
- x := d.TextAfterCursor()
- return x[:d.FindEndOfCurrentWordUntilSeparatorIgnoreNextToCursor(sep)]
-}
-
// FindStartOfPreviousWord returns an index relative to the cursor position
-// pointing to the start of the previous word. Return 0 if nothing was found.
+// pointing to the start of the previous word. Return `None` if nothing was found.
func (d *Document) FindStartOfPreviousWord() int {
+ // Reverse the text before the cursor, in order to do an efficient backwards search.
x := d.TextBeforeCursor()
- i := strings.LastIndexByte(x, ' ')
- if i != -1 {
- return i + 1
+ l := len(x)
+ for i := l; i > 0; i-- {
+ if x[i-1:i] == " " {
+ return i
+ }
}
return 0
}
@@ -132,119 +78,21 @@ func (d *Document) FindStartOfPreviousWord() int {
// FindStartOfPreviousWordWithSpace is almost the same as FindStartOfPreviousWord.
// The only difference is to ignore contiguous spaces.
func (d *Document) FindStartOfPreviousWordWithSpace() int {
+ // Reverse the text before the cursor, in order to do an efficient backwards search.
x := d.TextBeforeCursor()
- end := lastIndexByteNot(x, ' ')
- if end == -1 {
- return 0
- }
-
- start := strings.LastIndexByte(x[:end], ' ')
- if start == -1 {
- return 0
- }
- return start + 1
-}
-
-// FindStartOfPreviousWordUntilSeparator is almost the same as FindStartOfPreviousWord.
-// But this can specify Separator. Return 0 if nothing was found.
-func (d *Document) FindStartOfPreviousWordUntilSeparator(sep string) int {
- if sep == "" {
- return d.FindStartOfPreviousWord()
- }
-
- x := d.TextBeforeCursor()
- i := strings.LastIndexAny(x, sep)
- if i != -1 {
- return i + 1
+ l := len(x)
+ appear := false
+ for i := l; i > 0; i-- {
+ if x[i-1:i] != " " {
+ appear = true
+ }
+ if x[i-1:i] == " " && appear {
+ return i
+ }
}
return 0
}
-// FindStartOfPreviousWordUntilSeparatorIgnoreNextToCursor is almost the same as FindStartOfPreviousWordWithSpace.
-// But this can specify Separator. Return 0 if nothing was found.
-func (d *Document) FindStartOfPreviousWordUntilSeparatorIgnoreNextToCursor(sep string) int {
- if sep == "" {
- return d.FindStartOfPreviousWordWithSpace()
- }
-
- x := d.TextBeforeCursor()
- end := lastIndexAnyNot(x, sep)
- if end == -1 {
- return 0
- }
- start := strings.LastIndexAny(x[:end], sep)
- if start == -1 {
- return 0
- }
- return start + 1
-}
-
-// FindEndOfCurrentWord returns an index relative to the cursor position.
-// pointing to the end of the current word. Return 0 if nothing was found.
-func (d *Document) FindEndOfCurrentWord() int {
- x := d.TextAfterCursor()
- i := strings.IndexByte(x, ' ')
- if i != -1 {
- return i
- }
- return len(x)
-}
-
-// FindEndOfCurrentWordWithSpace is almost the same as FindEndOfCurrentWord.
-// The only difference is to ignore contiguous spaces.
-func (d *Document) FindEndOfCurrentWordWithSpace() int {
- x := d.TextAfterCursor()
-
- start := indexByteNot(x, ' ')
- if start == -1 {
- return len(x)
- }
-
- end := strings.IndexByte(x[start:], ' ')
- if end == -1 {
- return len(x)
- }
-
- return start + end
-}
-
-// FindEndOfCurrentWordUntilSeparator is almost the same as FindEndOfCurrentWord.
-// But this can specify Separator. Return 0 if nothing was found.
-func (d *Document) FindEndOfCurrentWordUntilSeparator(sep string) int {
- if sep == "" {
- return d.FindEndOfCurrentWord()
- }
-
- x := d.TextAfterCursor()
- i := strings.IndexAny(x, sep)
- if i != -1 {
- return i
- }
- return len(x)
-}
-
-// FindEndOfCurrentWordUntilSeparatorIgnoreNextToCursor is almost the same as FindEndOfCurrentWordWithSpace.
-// But this can specify Separator. Return 0 if nothing was found.
-func (d *Document) FindEndOfCurrentWordUntilSeparatorIgnoreNextToCursor(sep string) int {
- if sep == "" {
- return d.FindEndOfCurrentWordWithSpace()
- }
-
- x := d.TextAfterCursor()
-
- start := indexAnyNot(x, sep)
- if start == -1 {
- return len(x)
- }
-
- end := strings.IndexAny(x[start:], sep)
- if end == -1 {
- return len(x)
- }
-
- return start + end
-}
-
// CurrentLineBeforeCursor returns the text from the start of the line until the cursor.
func (d *Document) CurrentLineBeforeCursor() string {
s := strings.Split(d.TextBeforeCursor(), "\n")
@@ -292,14 +140,14 @@ func (d *Document) lineStartIndexes() []int {
// the first character on that line.
func (d *Document) findLineStartIndex(index int) (pos int, lineStartIndex int) {
indexes := d.lineStartIndexes()
- pos = bisectRight(indexes, index) - 1
+ pos = BisectRight(indexes, index) - 1
lineStartIndex = indexes[pos]
return
}
// CursorPositionRow returns the current row. (0-based.)
func (d *Document) CursorPositionRow() (row int) {
- row, _ = d.findLineStartIndex(d.cursorPosition)
+ row, _ = d.findLineStartIndex(d.CursorPosition)
return
}
@@ -307,8 +155,8 @@ func (d *Document) CursorPositionRow() (row int) {
func (d *Document) CursorPositionCol() (col int) {
// Don't use self.text_before_cursor to calculate this. Creating substrings
// and splitting is too expensive for getting the cursor position.
- _, index := d.findLineStartIndex(d.cursorPosition)
- col = d.cursorPosition - index
+ _, index := d.findLineStartIndex(d.CursorPosition)
+ col = d.CursorPosition - index
return
}
@@ -348,7 +196,7 @@ func (d *Document) GetCursorUpPosition(count int, preferredColumn int) int {
if row < 0 {
row = 0
}
- return d.TranslateRowColToIndex(row, col) - d.cursorPosition
+ return d.TranslateRowColToIndex(row, col) - d.CursorPosition
}
// GetCursorDownPosition return the relative cursor position (character index) where we would be if the
@@ -361,7 +209,7 @@ func (d *Document) GetCursorDownPosition(count int, preferredColumn int) int {
col = preferredColumn
}
row := d.CursorPositionRow() + count
- return d.TranslateRowColToIndex(row, col) - d.cursorPosition
+ return d.TranslateRowColToIndex(row, col) - d.CursorPosition
}
// Lines returns the array of all the lines.
@@ -432,102 +280,3 @@ func (d *Document) leadingWhitespaceInCurrentLine() (margin string) {
margin = d.CurrentLine()[:len(d.CurrentLine())-len(trimmed)]
return
}
-
-// bisectRight to Locate the insertion point for v in a to maintain sorted order.
-func bisectRight(a []int, v int) int {
- return bisectRightRange(a, v, 0, len(a))
-}
-
-func bisectRightRange(a []int, v int, lo, hi int) int {
- s := a[lo:hi]
- return sort.Search(len(s), func(i int) bool {
- return s[i] > v
- })
-}
-
-func indexByteNot(s string, c byte) int {
- n := len(s)
- for i := 0; i < n; i++ {
- if s[i] != c {
- return i
- }
- }
- return -1
-}
-
-func lastIndexByteNot(s string, c byte) int {
- for i := len(s) - 1; i >= 0; i-- {
- if s[i] != c {
- return i
- }
- }
- return -1
-}
-
-type asciiSet [8]uint32
-
-func (as *asciiSet) notContains(c byte) bool {
- return (as[c>>5] & (1 << uint(c&31))) == 0
-}
-
-func makeASCIISet(chars string) (as asciiSet, ok bool) {
- for i := 0; i < len(chars); i++ {
- c := chars[i]
- if c >= utf8.RuneSelf {
- return as, false
- }
- as[c>>5] |= 1 << uint(c&31)
- }
- return as, true
-}
-
-func indexAnyNot(s, chars string) int {
- if len(chars) > 0 {
- if len(s) > 8 {
- if as, isASCII := makeASCIISet(chars); isASCII {
- for i := 0; i < len(s); i++ {
- if as.notContains(s[i]) {
- return i
- }
- }
- return -1
- }
- }
- for i := 0; i < len(s); {
- // I don't know why strings.IndexAny doesn't add rune count here.
- r, size := utf8.DecodeRuneInString(s[i:])
- i += size
- for _, c := range chars {
- if r != c {
- return i
- }
- }
- }
- }
- return -1
-}
-
-func lastIndexAnyNot(s, chars string) int {
- if len(chars) > 0 {
- if len(s) > 8 {
- if as, isASCII := makeASCIISet(chars); isASCII {
- for i := len(s) - 1; i >= 0; i-- {
- if as.notContains(s[i]) {
- return i
- }
- }
- return -1
- }
- }
- for i := len(s); i > 0; {
- r, size := utf8.DecodeLastRuneInString(s[:i])
- i -= size
- for _, c := range chars {
- if r != c {
- return i
- }
- }
- }
- }
- return -1
-}
diff --git a/vendor/github.com/c-bata/go-prompt/emacs.go b/vendor/github.com/c-bata/go-prompt/emacs.go
index 9dc71edcab..f38d3f7302 100644
--- a/vendor/github.com/c-bata/go-prompt/emacs.go
+++ b/vendor/github.com/c-bata/go-prompt/emacs.go
@@ -113,7 +113,6 @@ var emacsKeyBindings = []KeyBind{
out := NewStandardOutputWriter()
out.EraseScreen()
out.CursorGoTo(0, 0)
- out.Flush()
},
},
}
diff --git a/vendor/github.com/c-bata/go-prompt/input.go b/vendor/github.com/c-bata/go-prompt/input.go
index 4c90b0f309..70837103cc 100644
--- a/vendor/github.com/c-bata/go-prompt/input.go
+++ b/vendor/github.com/c-bata/go-prompt/input.go
@@ -1,158 +1,42 @@
package prompt
-// WinSize represents the width and height of terminal.
-type WinSize struct {
- Row uint16
- Col uint16
+func dummyExecutor(in string) { return }
+
+// Input get the input data from the user and return it.
+func Input(prefix string, completer Completer, opts ...Option) string {
+ pt := New(dummyExecutor, completer)
+ pt.renderer.prefixTextColor = DefaultColor
+ pt.renderer.prefix = prefix
+
+ for _, opt := range opts {
+ if err := opt(pt); err != nil {
+ panic(err)
+ }
+ }
+ return pt.Input()
}
-// ConsoleParser is an interface to abstract input layer.
-type ConsoleParser interface {
- // Setup should be called before starting input
- Setup() error
- // TearDown should be called after stopping input
- TearDown() error
- // GetKey returns Key correspond to input byte codes.
- GetKey(b []byte) Key
- // GetWinSize returns WinSize object to represent width and height of terminal.
- GetWinSize() *WinSize
- // Read returns byte array.
- Read() ([]byte, error)
+// Choose to the shortcut of input function to select from string array.
+func Choose(prefix string, choices []string, opts ...Option) string {
+ completer := newChoiceCompleter(choices, FilterHasPrefix)
+ pt := New(dummyExecutor, completer)
+ pt.renderer.prefixTextColor = DefaultColor
+ pt.renderer.prefix = prefix
+
+ for _, opt := range opts {
+ if err := opt(pt); err != nil {
+ panic(err)
+ }
+ }
+ return pt.Input()
}
-var asciiSequences = []*ASCIICode{
- {Key: Escape, ASCIICode: []byte{0x1b}},
-
- {Key: ControlSpace, ASCIICode: []byte{0x00}},
- {Key: ControlA, ASCIICode: []byte{0x1}},
- {Key: ControlB, ASCIICode: []byte{0x2}},
- {Key: ControlC, ASCIICode: []byte{0x3}},
- {Key: ControlD, ASCIICode: []byte{0x4}},
- {Key: ControlE, ASCIICode: []byte{0x5}},
- {Key: ControlF, ASCIICode: []byte{0x6}},
- {Key: ControlG, ASCIICode: []byte{0x7}},
- {Key: ControlH, ASCIICode: []byte{0x8}},
- //{Key: ControlI, ASCIICode: []byte{0x9}},
- //{Key: ControlJ, ASCIICode: []byte{0xa}},
- {Key: ControlK, ASCIICode: []byte{0xb}},
- {Key: ControlL, ASCIICode: []byte{0xc}},
- {Key: ControlM, ASCIICode: []byte{0xd}},
- {Key: ControlN, ASCIICode: []byte{0xe}},
- {Key: ControlO, ASCIICode: []byte{0xf}},
- {Key: ControlP, ASCIICode: []byte{0x10}},
- {Key: ControlQ, ASCIICode: []byte{0x11}},
- {Key: ControlR, ASCIICode: []byte{0x12}},
- {Key: ControlS, ASCIICode: []byte{0x13}},
- {Key: ControlT, ASCIICode: []byte{0x14}},
- {Key: ControlU, ASCIICode: []byte{0x15}},
- {Key: ControlV, ASCIICode: []byte{0x16}},
- {Key: ControlW, ASCIICode: []byte{0x17}},
- {Key: ControlX, ASCIICode: []byte{0x18}},
- {Key: ControlY, ASCIICode: []byte{0x19}},
- {Key: ControlZ, ASCIICode: []byte{0x1a}},
-
- {Key: ControlBackslash, ASCIICode: []byte{0x1c}},
- {Key: ControlSquareClose, ASCIICode: []byte{0x1d}},
- {Key: ControlCircumflex, ASCIICode: []byte{0x1e}},
- {Key: ControlUnderscore, ASCIICode: []byte{0x1f}},
- {Key: Backspace, ASCIICode: []byte{0x7f}},
-
- {Key: Up, ASCIICode: []byte{0x1b, 0x5b, 0x41}},
- {Key: Down, ASCIICode: []byte{0x1b, 0x5b, 0x42}},
- {Key: Right, ASCIICode: []byte{0x1b, 0x5b, 0x43}},
- {Key: Left, ASCIICode: []byte{0x1b, 0x5b, 0x44}},
- {Key: Home, ASCIICode: []byte{0x1b, 0x5b, 0x48}},
- {Key: Home, ASCIICode: []byte{0x1b, 0x30, 0x48}},
- {Key: End, ASCIICode: []byte{0x1b, 0x5b, 0x46}},
- {Key: End, ASCIICode: []byte{0x1b, 0x30, 0x46}},
-
- {Key: Enter, ASCIICode: []byte{0xa}},
- {Key: Delete, ASCIICode: []byte{0x1b, 0x5b, 0x33, 0x7e}},
- {Key: ShiftDelete, ASCIICode: []byte{0x1b, 0x5b, 0x33, 0x3b, 0x32, 0x7e}},
- {Key: ControlDelete, ASCIICode: []byte{0x1b, 0x5b, 0x33, 0x3b, 0x35, 0x7e}},
- {Key: Home, ASCIICode: []byte{0x1b, 0x5b, 0x31, 0x7e}},
- {Key: End, ASCIICode: []byte{0x1b, 0x5b, 0x34, 0x7e}},
- {Key: PageUp, ASCIICode: []byte{0x1b, 0x5b, 0x35, 0x7e}},
- {Key: PageDown, ASCIICode: []byte{0x1b, 0x5b, 0x36, 0x7e}},
- {Key: Home, ASCIICode: []byte{0x1b, 0x5b, 0x37, 0x7e}},
- {Key: End, ASCIICode: []byte{0x1b, 0x5b, 0x38, 0x7e}},
- {Key: Tab, ASCIICode: []byte{0x9}},
- {Key: BackTab, ASCIICode: []byte{0x1b, 0x5b, 0x5a}},
- {Key: Insert, ASCIICode: []byte{0x1b, 0x5b, 0x32, 0x7e}},
-
- {Key: F1, ASCIICode: []byte{0x1b, 0x4f, 0x50}},
- {Key: F2, ASCIICode: []byte{0x1b, 0x4f, 0x51}},
- {Key: F3, ASCIICode: []byte{0x1b, 0x4f, 0x52}},
- {Key: F4, ASCIICode: []byte{0x1b, 0x4f, 0x53}},
-
- {Key: F1, ASCIICode: []byte{0x1b, 0x4f, 0x50, 0x41}}, // Linux console
- {Key: F2, ASCIICode: []byte{0x1b, 0x5b, 0x5b, 0x42}}, // Linux console
- {Key: F3, ASCIICode: []byte{0x1b, 0x5b, 0x5b, 0x43}}, // Linux console
- {Key: F4, ASCIICode: []byte{0x1b, 0x5b, 0x5b, 0x44}}, // Linux console
- {Key: F5, ASCIICode: []byte{0x1b, 0x5b, 0x5b, 0x45}}, // Linux console
-
- {Key: F1, ASCIICode: []byte{0x1b, 0x5b, 0x11, 0x7e}}, // rxvt-unicode
- {Key: F2, ASCIICode: []byte{0x1b, 0x5b, 0x12, 0x7e}}, // rxvt-unicode
- {Key: F3, ASCIICode: []byte{0x1b, 0x5b, 0x13, 0x7e}}, // rxvt-unicode
- {Key: F4, ASCIICode: []byte{0x1b, 0x5b, 0x14, 0x7e}}, // rxvt-unicode
-
- {Key: F5, ASCIICode: []byte{0x1b, 0x5b, 0x31, 0x35, 0x7e}},
- {Key: F6, ASCIICode: []byte{0x1b, 0x5b, 0x31, 0x37, 0x7e}},
- {Key: F7, ASCIICode: []byte{0x1b, 0x5b, 0x31, 0x38, 0x7e}},
- {Key: F8, ASCIICode: []byte{0x1b, 0x5b, 0x31, 0x39, 0x7e}},
- {Key: F9, ASCIICode: []byte{0x1b, 0x5b, 0x32, 0x30, 0x7e}},
- {Key: F10, ASCIICode: []byte{0x1b, 0x5b, 0x32, 0x31, 0x7e}},
- {Key: F11, ASCIICode: []byte{0x1b, 0x5b, 0x32, 0x32, 0x7e}},
- {Key: F12, ASCIICode: []byte{0x1b, 0x5b, 0x32, 0x34, 0x7e, 0x8}},
- {Key: F13, ASCIICode: []byte{0x1b, 0x5b, 0x25, 0x7e}},
- {Key: F14, ASCIICode: []byte{0x1b, 0x5b, 0x26, 0x7e}},
- {Key: F15, ASCIICode: []byte{0x1b, 0x5b, 0x28, 0x7e}},
- {Key: F16, ASCIICode: []byte{0x1b, 0x5b, 0x29, 0x7e}},
- {Key: F17, ASCIICode: []byte{0x1b, 0x5b, 0x31, 0x7e}},
- {Key: F18, ASCIICode: []byte{0x1b, 0x5b, 0x32, 0x7e}},
- {Key: F19, ASCIICode: []byte{0x1b, 0x5b, 0x33, 0x7e}},
- {Key: F20, ASCIICode: []byte{0x1b, 0x5b, 0x34, 0x7e}},
-
- // Xterm
- {Key: F13, ASCIICode: []byte{0x1b, 0x5b, 0x31, 0x3b, 0x32, 0x50}},
- {Key: F14, ASCIICode: []byte{0x1b, 0x5b, 0x31, 0x3b, 0x32, 0x51}},
- // &ASCIICode{Key: F15, ASCIICode: []byte{0x1b, 0x5b, 0x31, 0x3b, 0x32, 0x52}}, // Conflicts with CPR response
- {Key: F16, ASCIICode: []byte{0x1b, 0x5b, 0x31, 0x3b, 0x32, 0x52}},
- {Key: F17, ASCIICode: []byte{0x1b, 0x5b, 0x15, 0x3b, 0x32, 0x7e}},
- {Key: F18, ASCIICode: []byte{0x1b, 0x5b, 0x17, 0x3b, 0x32, 0x7e}},
- {Key: F19, ASCIICode: []byte{0x1b, 0x5b, 0x18, 0x3b, 0x32, 0x7e}},
- {Key: F20, ASCIICode: []byte{0x1b, 0x5b, 0x19, 0x3b, 0x32, 0x7e}},
- {Key: F21, ASCIICode: []byte{0x1b, 0x5b, 0x20, 0x3b, 0x32, 0x7e}},
- {Key: F22, ASCIICode: []byte{0x1b, 0x5b, 0x21, 0x3b, 0x32, 0x7e}},
- {Key: F23, ASCIICode: []byte{0x1b, 0x5b, 0x23, 0x3b, 0x32, 0x7e}},
- {Key: F24, ASCIICode: []byte{0x1b, 0x5b, 0x24, 0x3b, 0x32, 0x7e}},
-
- {Key: ControlUp, ASCIICode: []byte{0x1b, 0x5b, 0x31, 0x3b, 0x35, 0x41}},
- {Key: ControlDown, ASCIICode: []byte{0x1b, 0x5b, 0x31, 0x3b, 0x35, 0x42}},
- {Key: ControlRight, ASCIICode: []byte{0x1b, 0x5b, 0x31, 0x3b, 0x35, 0x43}},
- {Key: ControlLeft, ASCIICode: []byte{0x1b, 0x5b, 0x31, 0x3b, 0x35, 0x44}},
-
- {Key: ShiftUp, ASCIICode: []byte{0x1b, 0x5b, 0x31, 0x3b, 0x32, 0x41}},
- {Key: ShiftDown, ASCIICode: []byte{0x1b, 0x5b, 0x31, 0x3b, 0x32, 0x42}},
- {Key: ShiftRight, ASCIICode: []byte{0x1b, 0x5b, 0x31, 0x3b, 0x32, 0x43}},
- {Key: ShiftLeft, ASCIICode: []byte{0x1b, 0x5b, 0x31, 0x3b, 0x32, 0x44}},
-
- // Tmux sends following keystrokes when control+arrow is pressed, but for
- // Emacs ansi-term sends the same sequences for normal arrow keys. Consider
- // it a normal arrow press, because that's more important.
- {Key: Up, ASCIICode: []byte{0x1b, 0x4f, 0x41}},
- {Key: Down, ASCIICode: []byte{0x1b, 0x4f, 0x42}},
- {Key: Right, ASCIICode: []byte{0x1b, 0x4f, 0x43}},
- {Key: Left, ASCIICode: []byte{0x1b, 0x4f, 0x44}},
-
- {Key: ControlUp, ASCIICode: []byte{0x1b, 0x5b, 0x35, 0x41}},
- {Key: ControlDown, ASCIICode: []byte{0x1b, 0x5b, 0x35, 0x42}},
- {Key: ControlRight, ASCIICode: []byte{0x1b, 0x5b, 0x35, 0x43}},
- {Key: ControlLeft, ASCIICode: []byte{0x1b, 0x5b, 0x35, 0x44}},
-
- {Key: ControlRight, ASCIICode: []byte{0x1b, 0x5b, 0x4f, 0x63}}, // rxvt
- {Key: ControlLeft, ASCIICode: []byte{0x1b, 0x5b, 0x4f, 0x64}}, // rxvt
-
- {Key: Ignore, ASCIICode: []byte{0x1b, 0x5b, 0x45}}, // Xterm
- {Key: Ignore, ASCIICode: []byte{0x1b, 0x5b, 0x46}}, // Linux console
+func newChoiceCompleter(choices []string, filter Filter) Completer {
+ s := make([]Suggest, len(choices))
+ for i := range choices {
+ s[i] = Suggest{Text: choices[i]}
+ }
+ return func(x Document) []Suggest {
+ return filter(s, x.GetWordBeforeCursor(), true)
+ }
}
diff --git a/vendor/github.com/c-bata/go-prompt/input_posix.go b/vendor/github.com/c-bata/go-prompt/input_posix.go
deleted file mode 100644
index 46ecb511a1..0000000000
--- a/vendor/github.com/c-bata/go-prompt/input_posix.go
+++ /dev/null
@@ -1,128 +0,0 @@
-// +build !windows
-
-package prompt
-
-import (
- "bytes"
- "log"
- "syscall"
- "unsafe"
-
- "github.com/pkg/term/termios"
-)
-
-const maxReadBytes = 1024
-
-// PosixParser is a ConsoleParser implementation for POSIX environment.
-type PosixParser struct {
- fd int
- origTermios syscall.Termios
-}
-
-// Setup should be called before starting input
-func (t *PosixParser) Setup() error {
- // Set NonBlocking mode because if syscall.Read block this goroutine, it cannot receive data from stopCh.
- if err := syscall.SetNonblock(t.fd, true); err != nil {
- log.Println("[ERROR] Cannot set non blocking mode.")
- return err
- }
- if err := t.setRawMode(); err != nil {
- log.Println("[ERROR] Cannot set raw mode.")
- return err
- }
- return nil
-}
-
-// TearDown should be called after stopping input
-func (t *PosixParser) TearDown() error {
- if err := syscall.SetNonblock(t.fd, false); err != nil {
- log.Println("[ERROR] Cannot set blocking mode.")
- return err
- }
- if err := t.resetRawMode(); err != nil {
- log.Println("[ERROR] Cannot reset from raw mode.")
- return err
- }
- return nil
-}
-
-// Read returns byte array.
-func (t *PosixParser) Read() ([]byte, error) {
- buf := make([]byte, maxReadBytes)
- n, err := syscall.Read(syscall.Stdin, buf)
- if err != nil {
- return []byte{}, err
- }
- return buf[:n], nil
-}
-
-func (t *PosixParser) setRawMode() error {
- x := t.origTermios.Lflag
- if x &^= syscall.ICANON; x != 0 && x == t.origTermios.Lflag {
- // fd is already raw mode
- return nil
- }
- var n syscall.Termios
- if err := termios.Tcgetattr(uintptr(t.fd), &t.origTermios); err != nil {
- return err
- }
- n = t.origTermios
- // "&^=" used like: https://play.golang.org/p/8eJw3JxS4O
- n.Lflag &^= syscall.ECHO | syscall.ICANON | syscall.IEXTEN | syscall.ISIG
- n.Cc[syscall.VMIN] = 1
- n.Cc[syscall.VTIME] = 0
- termios.Tcsetattr(uintptr(t.fd), termios.TCSANOW, &n)
- return nil
-}
-
-func (t *PosixParser) resetRawMode() error {
- if t.origTermios.Lflag == 0 {
- return nil
- }
- return termios.Tcsetattr(uintptr(t.fd), termios.TCSANOW, &t.origTermios)
-}
-
-// GetKey returns Key correspond to input byte codes.
-func (t *PosixParser) GetKey(b []byte) Key {
- for _, k := range asciiSequences {
- if bytes.Equal(k.ASCIICode, b) {
- return k.Key
- }
- }
- return NotDefined
-}
-
-// winsize is winsize struct got from the ioctl(2) system call.
-type ioctlWinsize struct {
- Row uint16
- Col uint16
- X uint16 // pixel value
- Y uint16 // pixel value
-}
-
-// GetWinSize returns WinSize object to represent width and height of terminal.
-func (t *PosixParser) GetWinSize() *WinSize {
- ws := &ioctlWinsize{}
- retCode, _, errno := syscall.Syscall(
- syscall.SYS_IOCTL,
- uintptr(t.fd),
- uintptr(syscall.TIOCGWINSZ),
- uintptr(unsafe.Pointer(ws)))
-
- if int(retCode) == -1 {
- panic(errno)
- }
- return &WinSize{
- Row: ws.Row,
- Col: ws.Col,
- }
-}
-
-var _ ConsoleParser = &PosixParser{}
-
-// NewStandardInputParser returns ConsoleParser object to read from stdin.
-func NewStandardInputParser() *PosixParser {
- return &PosixParser{
- fd: syscall.Stdin,
- }
-}
diff --git a/vendor/github.com/c-bata/go-prompt/input_windows.go b/vendor/github.com/c-bata/go-prompt/input_windows.go
deleted file mode 100644
index f52b538977..0000000000
--- a/vendor/github.com/c-bata/go-prompt/input_windows.go
+++ /dev/null
@@ -1,94 +0,0 @@
-// +build windows
-
-package prompt
-
-import (
- "bytes"
- "errors"
- "syscall"
- "unicode/utf8"
- "unsafe"
-
- "github.com/mattn/go-tty"
-)
-
-const maxReadBytes = 1024
-
-var kernel32 = syscall.NewLazyDLL("kernel32.dll")
-
-var procGetNumberOfConsoleInputEvents = kernel32.NewProc("GetNumberOfConsoleInputEvents")
-
-// WindowsParser is a ConsoleParser implementation for Win32 console.
-type WindowsParser struct {
- tty *tty.TTY
-}
-
-// Setup should be called before starting input
-func (p *WindowsParser) Setup() error {
- t, err := tty.Open()
- if err != nil {
- return err
- }
- p.tty = t
- return nil
-}
-
-// TearDown should be called after stopping input
-func (p *WindowsParser) TearDown() error {
- return p.tty.Close()
-}
-
-// GetKey returns Key correspond to input byte codes.
-func (p *WindowsParser) GetKey(b []byte) Key {
- for _, k := range asciiSequences {
- if bytes.Compare(k.ASCIICode, b) == 0 {
- return k.Key
- }
- }
- return NotDefined
-}
-
-// Read returns byte array.
-func (p *WindowsParser) Read() ([]byte, error) {
- var ev uint32
- r0, _, err := procGetNumberOfConsoleInputEvents.Call(p.tty.Input().Fd(), uintptr(unsafe.Pointer(&ev)))
- if r0 == 0 {
- return nil, err
- }
- if ev == 0 {
- return nil, errors.New("EAGAIN")
- }
-
- r, err := p.tty.ReadRune()
- if err != nil {
- return nil, err
- }
-
- buf := make([]byte, maxReadBytes)
- n := utf8.EncodeRune(buf[:], r)
- for p.tty.Buffered() && n < maxReadBytes {
- r, err := p.tty.ReadRune()
- if err != nil {
- break
- }
- n += utf8.EncodeRune(buf[n:], r)
- }
- return buf[:n], nil
-}
-
-// GetWinSize returns WinSize object to represent width and height of terminal.
-func (p *WindowsParser) GetWinSize() *WinSize {
- w, h, err := p.tty.Size()
- if err != nil {
- panic(err)
- }
- return &WinSize{
- Row: uint16(h),
- Col: uint16(w),
- }
-}
-
-// NewStandardInputParser returns ConsoleParser object to read from stdin.
-func NewStandardInputParser() *WindowsParser {
- return &WindowsParser{}
-}
diff --git a/vendor/github.com/c-bata/go-prompt/key.go b/vendor/github.com/c-bata/go-prompt/key.go
index 068b70e9f7..9f79185f50 100644
--- a/vendor/github.com/c-bata/go-prompt/key.go
+++ b/vendor/github.com/c-bata/go-prompt/key.go
@@ -1,6 +1,3 @@
-// Code generated "This is a fake comment to avoid golint errors"; DO NOT EDIT.
-// FIXME: This is a little bit stupid, but there are many public constants which is no value for writing godoc comment.
-
package prompt
// Key is the type express the key inserted from user.
diff --git a/vendor/github.com/c-bata/go-prompt/key_bind.go b/vendor/github.com/c-bata/go-prompt/key_bind.go
index 42669e7f94..0cfcab44aa 100644
--- a/vendor/github.com/c-bata/go-prompt/key_bind.go
+++ b/vendor/github.com/c-bata/go-prompt/key_bind.go
@@ -1,59 +1,62 @@
package prompt
-// KeyBindFunc receives buffer and processed it.
type KeyBindFunc func(*Buffer)
-// KeyBind represents which key should do what operation.
type KeyBind struct {
Key Key
Fn KeyBindFunc
}
-// ASCIICodeBind represents which []byte should do what operation
-type ASCIICodeBind struct {
- ASCIICode []byte
- Fn KeyBindFunc
-}
-
-// KeyBindMode to switch a key binding flexibly.
type KeyBindMode string
const (
- // CommonKeyBind is a mode without any keyboard shortcut
CommonKeyBind KeyBindMode = "common"
- // EmacsKeyBind is a mode to use emacs-like keyboard shortcut
- EmacsKeyBind KeyBindMode = "emacs"
+ EmacsKeyBind KeyBindMode = "emacs"
)
var commonKeyBindings = []KeyBind{
// Go to the End of the line
{
Key: End,
- Fn: GoLineEnd,
+ Fn: func(buf *Buffer) {
+ x := []rune(buf.Document().TextAfterCursor())
+ buf.CursorRight(len(x))
+ },
},
// Go to the beginning of the line
{
Key: Home,
- Fn: GoLineBeginning,
+ Fn: func(buf *Buffer) {
+ x := []rune(buf.Document().TextBeforeCursor())
+ buf.CursorLeft(len(x))
+ },
},
// Delete character under the cursor
{
Key: Delete,
- Fn: DeleteChar,
+ Fn: func(buf *Buffer) {
+ buf.Delete(1)
+ },
},
// Backspace
{
Key: Backspace,
- Fn: DeleteBeforeChar,
+ Fn: func(buf *Buffer) {
+ buf.DeleteBeforeCursor(1)
+ },
},
// Right allow: Forward one character
{
Key: Right,
- Fn: GoRightChar,
+ Fn: func(buf *Buffer) {
+ buf.CursorRight(1)
+ },
},
// Left allow: Backward one character
{
Key: Left,
- Fn: GoLeftChar,
+ Fn: func(buf *Buffer) {
+ buf.CursorLeft(1)
+ },
},
}
diff --git a/vendor/github.com/c-bata/go-prompt/key_bind_func.go b/vendor/github.com/c-bata/go-prompt/key_bind_func.go
deleted file mode 100644
index 7b2ecdf631..0000000000
--- a/vendor/github.com/c-bata/go-prompt/key_bind_func.go
+++ /dev/null
@@ -1,48 +0,0 @@
-package prompt
-
-// GoLineEnd Go to the End of the line
-func GoLineEnd(buf *Buffer) {
- x := []rune(buf.Document().TextAfterCursor())
- buf.CursorRight(len(x))
-}
-
-// GoLineBeginning Go to the beginning of the line
-func GoLineBeginning(buf *Buffer) {
- x := []rune(buf.Document().TextBeforeCursor())
- buf.CursorLeft(len(x))
-}
-
-// DeleteChar Delete character under the cursor
-func DeleteChar(buf *Buffer) {
- buf.Delete(1)
-}
-
-// DeleteWord Delete word before the cursor
-func DeleteWord(buf *Buffer) {
- buf.DeleteBeforeCursor(len([]rune(buf.Document().TextBeforeCursor())) - buf.Document().FindStartOfPreviousWordWithSpace())
-}
-
-// DeleteBeforeChar Go to Backspace
-func DeleteBeforeChar(buf *Buffer) {
- buf.DeleteBeforeCursor(1)
-}
-
-// GoRightChar Forward one character
-func GoRightChar(buf *Buffer) {
- buf.CursorRight(1)
-}
-
-// GoLeftChar Backward one character
-func GoLeftChar(buf *Buffer) {
- buf.CursorLeft(1)
-}
-
-// GoRightWord Forward one word
-func GoRightWord(buf *Buffer) {
- buf.CursorRight(buf.Document().FindEndOfCurrentWordWithSpace())
-}
-
-// GoLeftWord Backward one word
-func GoLeftWord(buf *Buffer) {
- buf.CursorLeft(len([]rune(buf.Document().TextBeforeCursor())) - buf.Document().FindStartOfPreviousWordWithSpace())
-}
diff --git a/vendor/github.com/c-bata/go-prompt/option.go b/vendor/github.com/c-bata/go-prompt/option.go
index 9a7f386da3..72c6de3103 100644
--- a/vendor/github.com/c-bata/go-prompt/option.go
+++ b/vendor/github.com/c-bata/go-prompt/option.go
@@ -12,7 +12,7 @@ func OptionParser(x ConsoleParser) Option {
}
}
-// OptionWriter to set a custom ConsoleWriter object. An argument should implement ConsoleWriter interface.
+// OptionWriter to set a custom ConsoleWriter object. An argument should implement ConsoleWriter interace.
func OptionWriter(x ConsoleWriter) Option {
return func(p *Prompt) error {
p.renderer.out = x
@@ -36,14 +36,6 @@ func OptionPrefix(x string) Option {
}
}
-// OptionCompletionWordSeparator to set word separators. Enable only ' ' if empty.
-func OptionCompletionWordSeparator(x string) Option {
- return func(p *Prompt) error {
- p.completion.wordSeparator = x
- return nil
- }
-}
-
// OptionLivePrefix to change the prefix dynamically by callback function
func OptionLivePrefix(f func() (prefix string, useLivePrefix bool)) Option {
return func(p *Prompt) error {
@@ -52,7 +44,6 @@ func OptionLivePrefix(f func() (prefix string, useLivePrefix bool)) Option {
}
}
-// OptionPrefixTextColor change a text color of prefix string
func OptionPrefixTextColor(x Color) Option {
return func(p *Prompt) error {
p.renderer.prefixTextColor = x
@@ -60,7 +51,6 @@ func OptionPrefixTextColor(x Color) Option {
}
}
-// OptionPrefixBackgroundColor to change a background color of prefix string
func OptionPrefixBackgroundColor(x Color) Option {
return func(p *Prompt) error {
p.renderer.prefixBGColor = x
@@ -68,7 +58,6 @@ func OptionPrefixBackgroundColor(x Color) Option {
}
}
-// OptionInputTextColor to change a color of text which is input by user
func OptionInputTextColor(x Color) Option {
return func(p *Prompt) error {
p.renderer.inputTextColor = x
@@ -76,7 +65,6 @@ func OptionInputTextColor(x Color) Option {
}
}
-// OptionInputBGColor to change a color of background which is input by user
func OptionInputBGColor(x Color) Option {
return func(p *Prompt) error {
p.renderer.inputBGColor = x
@@ -84,7 +72,6 @@ func OptionInputBGColor(x Color) Option {
}
}
-// OptionPreviewSuggestionTextColor to change a text color which is completed
func OptionPreviewSuggestionTextColor(x Color) Option {
return func(p *Prompt) error {
p.renderer.previewSuggestionTextColor = x
@@ -92,7 +79,6 @@ func OptionPreviewSuggestionTextColor(x Color) Option {
}
}
-// OptionPreviewSuggestionBGColor to change a background color which is completed
func OptionPreviewSuggestionBGColor(x Color) Option {
return func(p *Prompt) error {
p.renderer.previewSuggestionBGColor = x
@@ -100,7 +86,6 @@ func OptionPreviewSuggestionBGColor(x Color) Option {
}
}
-// OptionSuggestionTextColor to change a text color in drop down suggestions.
func OptionSuggestionTextColor(x Color) Option {
return func(p *Prompt) error {
p.renderer.suggestionTextColor = x
@@ -108,7 +93,6 @@ func OptionSuggestionTextColor(x Color) Option {
}
}
-// OptionSuggestionBGColor change a background color in drop down suggestions.
func OptionSuggestionBGColor(x Color) Option {
return func(p *Prompt) error {
p.renderer.suggestionBGColor = x
@@ -116,7 +100,6 @@ func OptionSuggestionBGColor(x Color) Option {
}
}
-// OptionSelectedSuggestionTextColor to change a text color for completed text which is selected inside suggestions drop down box.
func OptionSelectedSuggestionTextColor(x Color) Option {
return func(p *Prompt) error {
p.renderer.selectedSuggestionTextColor = x
@@ -124,7 +107,6 @@ func OptionSelectedSuggestionTextColor(x Color) Option {
}
}
-// OptionSelectedSuggestionBGColor to change a background color for completed text which is selected inside suggestions drop down box.
func OptionSelectedSuggestionBGColor(x Color) Option {
return func(p *Prompt) error {
p.renderer.selectedSuggestionBGColor = x
@@ -132,7 +114,6 @@ func OptionSelectedSuggestionBGColor(x Color) Option {
}
}
-// OptionDescriptionTextColor to change a background color of description text in drop down suggestions.
func OptionDescriptionTextColor(x Color) Option {
return func(p *Prompt) error {
p.renderer.descriptionTextColor = x
@@ -140,7 +121,6 @@ func OptionDescriptionTextColor(x Color) Option {
}
}
-// OptionDescriptionBGColor to change a background color of description text in drop down suggestions.
func OptionDescriptionBGColor(x Color) Option {
return func(p *Prompt) error {
p.renderer.descriptionBGColor = x
@@ -148,7 +128,6 @@ func OptionDescriptionBGColor(x Color) Option {
}
}
-// OptionSelectedDescriptionTextColor to change a text color of description which is selected inside suggestions drop down box.
func OptionSelectedDescriptionTextColor(x Color) Option {
return func(p *Prompt) error {
p.renderer.selectedDescriptionTextColor = x
@@ -156,7 +135,6 @@ func OptionSelectedDescriptionTextColor(x Color) Option {
}
}
-// OptionSelectedDescriptionBGColor to change a background color of description which is selected inside suggestions drop down box.
func OptionSelectedDescriptionBGColor(x Color) Option {
return func(p *Prompt) error {
p.renderer.selectedDescriptionBGColor = x
@@ -164,7 +142,6 @@ func OptionSelectedDescriptionBGColor(x Color) Option {
}
}
-// OptionScrollbarThumbColor to change a thumb color on scrollbar.
func OptionScrollbarThumbColor(x Color) Option {
return func(p *Prompt) error {
p.renderer.scrollbarThumbColor = x
@@ -172,7 +149,6 @@ func OptionScrollbarThumbColor(x Color) Option {
}
}
-// OptionScrollbarBGColor to change a background color of scrollbar.
func OptionScrollbarBGColor(x Color) Option {
return func(p *Prompt) error {
p.renderer.scrollbarBGColor = x
@@ -217,14 +193,6 @@ func OptionAddKeyBind(b ...KeyBind) Option {
}
}
-// OptionAddASCIICodeBind to set a custom key bind.
-func OptionAddASCIICodeBind(b ...ASCIICodeBind) Option {
- return func(p *Prompt) error {
- p.ASCIICodeBindings = append(p.ASCIICodeBindings, b...)
- return nil
- }
-}
-
// New returns a Prompt with powerful auto-completion.
func New(executor Executor, completer Completer, opts ...Option) *Prompt {
pt := &Prompt{
diff --git a/vendor/github.com/c-bata/go-prompt/output_posix.go b/vendor/github.com/c-bata/go-prompt/output_posix.go
deleted file mode 100644
index 4c2ccf63b1..0000000000
--- a/vendor/github.com/c-bata/go-prompt/output_posix.go
+++ /dev/null
@@ -1,35 +0,0 @@
-// +build !windows
-
-package prompt
-
-import (
- "syscall"
-)
-
-// PosixWriter is a ConsoleWriter implementation for POSIX environment.
-// To control terminal emulator, this outputs VT100 escape sequences.
-type PosixWriter struct {
- VT100Writer
- fd int
-}
-
-// Flush to flush buffer
-func (w *PosixWriter) Flush() error {
- _, err := syscall.Write(w.fd, w.buffer)
- if err != nil {
- return err
- }
- w.buffer = []byte{}
- return nil
-}
-
-var _ ConsoleWriter = &PosixWriter{}
-
-// NewStandardOutputWriter returns ConsoleWriter object to write to stdout.
-// This generates VT100 escape sequences because almost terminal emulators
-// in POSIX OS built on top of a VT100 specification.
-func NewStandardOutputWriter() *PosixWriter {
- return &PosixWriter{
- fd: syscall.Stdout,
- }
-}
diff --git a/vendor/github.com/c-bata/go-prompt/output_vt100.go b/vendor/github.com/c-bata/go-prompt/output_vt100.go
deleted file mode 100644
index 3b3031d70b..0000000000
--- a/vendor/github.com/c-bata/go-prompt/output_vt100.go
+++ /dev/null
@@ -1,333 +0,0 @@
-package prompt
-
-import (
- "bytes"
- "strconv"
-)
-
-// VT100Writer generates VT100 escape sequences.
-type VT100Writer struct {
- buffer []byte
-}
-
-// WriteRaw to write raw byte array
-func (w *VT100Writer) WriteRaw(data []byte) {
- w.buffer = append(w.buffer, data...)
- return
-}
-
-// Write to write safety byte array by removing control sequences.
-func (w *VT100Writer) Write(data []byte) {
- w.WriteRaw(bytes.Replace(data, []byte{0x1b}, []byte{'?'}, -1))
- return
-}
-
-// WriteRawStr to write raw string
-func (w *VT100Writer) WriteRawStr(data string) {
- w.WriteRaw([]byte(data))
- return
-}
-
-// WriteStr to write safety string by removing control sequences.
-func (w *VT100Writer) WriteStr(data string) {
- w.Write([]byte(data))
- return
-}
-
-/* Erase */
-
-// EraseScreen erases the screen with the background colour and moves the cursor to home.
-func (w *VT100Writer) EraseScreen() {
- w.WriteRaw([]byte{0x1b, '[', '2', 'J'})
- return
-}
-
-// EraseUp erases the screen from the current line up to the top of the screen.
-func (w *VT100Writer) EraseUp() {
- w.WriteRaw([]byte{0x1b, '[', '1', 'J'})
- return
-}
-
-// EraseDown erases the screen from the current line down to the bottom of the screen.
-func (w *VT100Writer) EraseDown() {
- w.WriteRaw([]byte{0x1b, '[', 'J'})
- return
-}
-
-// EraseStartOfLine erases from the current cursor position to the start of the current line.
-func (w *VT100Writer) EraseStartOfLine() {
- w.WriteRaw([]byte{0x1b, '[', '1', 'K'})
- return
-}
-
-// EraseEndOfLine erases from the current cursor position to the end of the current line.
-func (w *VT100Writer) EraseEndOfLine() {
- w.WriteRaw([]byte{0x1b, '[', 'K'})
- return
-}
-
-// EraseLine erases the entire current line.
-func (w *VT100Writer) EraseLine() {
- w.WriteRaw([]byte{0x1b, '[', '2', 'K'})
- return
-}
-
-/* Cursor */
-
-// ShowCursor stops blinking cursor and show.
-func (w *VT100Writer) ShowCursor() {
- w.WriteRaw([]byte{0x1b, '[', '?', '1', '2', 'l', 0x1b, '[', '?', '2', '5', 'h'})
-}
-
-// HideCursor hides cursor.
-func (w *VT100Writer) HideCursor() {
- w.WriteRaw([]byte{0x1b, '[', '?', '2', '5', 'l'})
- return
-}
-
-// CursorGoTo sets the cursor position where subsequent text will begin.
-func (w *VT100Writer) CursorGoTo(row, col int) {
- if row == 0 && col == 0 {
- // If no row/column parameters are provided (ie. [H), the cursor will move to the home position.
- w.WriteRaw([]byte{0x1b, '[', 'H'})
- return
- }
- r := strconv.Itoa(row)
- c := strconv.Itoa(col)
- w.WriteRaw([]byte{0x1b, '['})
- w.WriteRaw([]byte(r))
- w.WriteRaw([]byte{';'})
- w.WriteRaw([]byte(c))
- w.WriteRaw([]byte{'H'})
- return
-}
-
-// CursorUp moves the cursor up by 'n' rows; the default count is 1.
-func (w *VT100Writer) CursorUp(n int) {
- if n == 0 {
- return
- } else if n < 0 {
- w.CursorDown(-n)
- return
- }
- s := strconv.Itoa(n)
- w.WriteRaw([]byte{0x1b, '['})
- w.WriteRaw([]byte(s))
- w.WriteRaw([]byte{'A'})
- return
-}
-
-// CursorDown moves the cursor down by 'n' rows; the default count is 1.
-func (w *VT100Writer) CursorDown(n int) {
- if n == 0 {
- return
- } else if n < 0 {
- w.CursorUp(-n)
- return
- }
- s := strconv.Itoa(n)
- w.WriteRaw([]byte{0x1b, '['})
- w.WriteRaw([]byte(s))
- w.WriteRaw([]byte{'B'})
- return
-}
-
-// CursorForward moves the cursor forward by 'n' columns; the default count is 1.
-func (w *VT100Writer) CursorForward(n int) {
- if n == 0 {
- return
- } else if n < 0 {
- w.CursorBackward(-n)
- return
- }
- s := strconv.Itoa(n)
- w.WriteRaw([]byte{0x1b, '['})
- w.WriteRaw([]byte(s))
- w.WriteRaw([]byte{'C'})
- return
-}
-
-// CursorBackward moves the cursor backward by 'n' columns; the default count is 1.
-func (w *VT100Writer) CursorBackward(n int) {
- if n == 0 {
- return
- } else if n < 0 {
- w.CursorForward(-n)
- return
- }
- s := strconv.Itoa(n)
- w.WriteRaw([]byte{0x1b, '['})
- w.WriteRaw([]byte(s))
- w.WriteRaw([]byte{'D'})
- return
-}
-
-// AskForCPR asks for a cursor position report (CPR).
-func (w *VT100Writer) AskForCPR() {
- // CPR: Cursor Position Request.
- w.WriteRaw([]byte{0x1b, '[', '6', 'n'})
- return
-}
-
-// SaveCursor saves current cursor position.
-func (w *VT100Writer) SaveCursor() {
- w.WriteRaw([]byte{0x1b, '[', 's'})
- return
-}
-
-// UnSaveCursor restores cursor position after a Save Cursor.
-func (w *VT100Writer) UnSaveCursor() {
- w.WriteRaw([]byte{0x1b, '[', 'u'})
- return
-}
-
-/* Scrolling */
-
-// ScrollDown scrolls display down one line.
-func (w *VT100Writer) ScrollDown() {
- w.WriteRaw([]byte{0x1b, 'D'})
- return
-}
-
-// ScrollUp scroll display up one line.
-func (w *VT100Writer) ScrollUp() {
- w.WriteRaw([]byte{0x1b, 'M'})
- return
-}
-
-/* Title */
-
-// SetTitle sets a title of terminal window.
-func (w *VT100Writer) SetTitle(title string) {
- titleBytes := []byte(title)
- patterns := []struct {
- from []byte
- to []byte
- }{
- {
- from: []byte{0x13},
- to: []byte{},
- },
- {
- from: []byte{0x07},
- to: []byte{},
- },
- }
- for i := range patterns {
- titleBytes = bytes.Replace(titleBytes, patterns[i].from, patterns[i].to, -1)
- }
-
- w.WriteRaw([]byte{0x1b, ']', '2', ';'})
- w.WriteRaw(titleBytes)
- w.WriteRaw([]byte{0x07})
- return
-}
-
-// ClearTitle clears a title of terminal window.
-func (w *VT100Writer) ClearTitle() {
- w.WriteRaw([]byte{0x1b, ']', '2', ';', 0x07})
- return
-}
-
-/* Font */
-
-// SetColor sets text and background colors. and specify whether text is bold.
-func (w *VT100Writer) SetColor(fg, bg Color, bold bool) {
- if bold {
- w.SetDisplayAttributes(fg, bg, DisplayBold)
- } else {
- w.SetDisplayAttributes(fg, bg, DisplayDefaultFont)
- }
- return
-}
-
-// SetDisplayAttributes to set VT100 display attributes.
-func (w *VT100Writer) SetDisplayAttributes(fg, bg Color, attrs ...DisplayAttribute) {
- w.WriteRaw([]byte{0x1b, '['}) // control sequence introducer
- defer w.WriteRaw([]byte{'m'}) // final character
-
- var separator byte = ';'
- for i := range attrs {
- p, ok := displayAttributeParameters[attrs[i]]
- if !ok {
- continue
- }
- w.WriteRaw(p)
- w.WriteRaw([]byte{separator})
- }
-
- f, ok := foregroundANSIColors[fg]
- if !ok {
- f = foregroundANSIColors[DefaultColor]
- }
- w.WriteRaw(f)
- w.WriteRaw([]byte{separator})
- b, ok := backgroundANSIColors[bg]
- if !ok {
- b = backgroundANSIColors[DefaultColor]
- }
- w.WriteRaw(b)
- return
-}
-
-var displayAttributeParameters = map[DisplayAttribute][]byte{
- DisplayReset: {'0'},
- DisplayBold: {'1'},
- DisplayLowIntensity: {'2'},
- DisplayItalic: {'3'},
- DisplayUnderline: {'4'},
- DisplayBlink: {'5'},
- DisplayRapidBlink: {'6'},
- DisplayReverse: {'7'},
- DisplayInvisible: {'8'},
- DisplayCrossedOut: {'9'},
- DisplayDefaultFont: {'1', '0'},
-}
-
-var foregroundANSIColors = map[Color][]byte{
- DefaultColor: {'3', '9'},
-
- // Low intensity.
- Black: {'3', '0'},
- DarkRed: {'3', '1'},
- DarkGreen: {'3', '2'},
- Brown: {'3', '3'},
- DarkBlue: {'3', '4'},
- Purple: {'3', '5'},
- Cyan: {'3', '6'},
- LightGray: {'3', '7'},
-
- // High intensity.
- DarkGray: {'9', '0'},
- Red: {'9', '1'},
- Green: {'9', '2'},
- Yellow: {'9', '3'},
- Blue: {'9', '4'},
- Fuchsia: {'9', '5'},
- Turquoise: {'9', '6'},
- White: {'9', '7'},
-}
-
-var backgroundANSIColors = map[Color][]byte{
- DefaultColor: {'4', '9'},
-
- // Low intensity.
- Black: {'4', '0'},
- DarkRed: {'4', '1'},
- DarkGreen: {'4', '2'},
- Brown: {'4', '3'},
- DarkBlue: {'4', '4'},
- Purple: {'4', '5'},
- Cyan: {'4', '6'},
- LightGray: {'4', '7'},
-
- // High intensity
- DarkGray: {'1', '0', '0'},
- Red: {'1', '0', '1'},
- Green: {'1', '0', '2'},
- Yellow: {'1', '0', '3'},
- Blue: {'1', '0', '4'},
- Fuchsia: {'1', '0', '5'},
- Turquoise: {'1', '0', '6'},
- White: {'1', '0', '7'},
-}
diff --git a/vendor/github.com/c-bata/go-prompt/output_windows.go b/vendor/github.com/c-bata/go-prompt/output_windows.go
deleted file mode 100644
index 7418af3491..0000000000
--- a/vendor/github.com/c-bata/go-prompt/output_windows.go
+++ /dev/null
@@ -1,36 +0,0 @@
-// +build windows
-
-package prompt
-
-import (
- "io"
-
- "github.com/mattn/go-colorable"
-)
-
-// WindowsWriter is a ConsoleWriter implementation for Win32 console.
-// Output is converted from VT100 escape sequences by mattn/go-colorable.
-type WindowsWriter struct {
- VT100Writer
- out io.Writer
-}
-
-// Flush to flush buffer
-func (w *WindowsWriter) Flush() error {
- _, err := w.out.Write(w.buffer)
- if err != nil {
- return err
- }
- w.buffer = []byte{}
- return nil
-}
-
-var _ ConsoleWriter = &WindowsWriter{}
-
-// NewStandardOutputWriter returns ConsoleWriter object to write to stdout.
-// This generates win32 control sequences.
-func NewStandardOutputWriter() *WindowsWriter {
- return &WindowsWriter{
- out: colorable.NewColorableStdout(),
- }
-}
diff --git a/vendor/github.com/c-bata/go-prompt/posix_input.go b/vendor/github.com/c-bata/go-prompt/posix_input.go
new file mode 100644
index 0000000000..ead496d97e
--- /dev/null
+++ b/vendor/github.com/c-bata/go-prompt/posix_input.go
@@ -0,0 +1,265 @@
+// +build !windows
+
+package prompt
+
+import (
+ "bytes"
+ "log"
+ "syscall"
+ "unsafe"
+
+ "github.com/pkg/term/termios"
+)
+
+const maxReadBytes = 1024
+
+// PosixParser is a ConsoleParser implementation for POSIX environment.
+type PosixParser struct {
+ fd int
+ origTermios syscall.Termios
+}
+
+// Setup should be called before starting input
+func (t *PosixParser) Setup() error {
+ // Set NonBlocking mode because if syscall.Read block this goroutine, it cannot receive data from stopCh.
+ if err := syscall.SetNonblock(t.fd, true); err != nil {
+ log.Println("[ERROR] Cannot set non blocking mode.")
+ return err
+ }
+ if err := t.setRawMode(); err != nil {
+ log.Println("[ERROR] Cannot set raw mode.")
+ return err
+ }
+ return nil
+}
+
+// TearDown should be called after stopping input
+func (t *PosixParser) TearDown() error {
+ if err := syscall.SetNonblock(t.fd, false); err != nil {
+ log.Println("[ERROR] Cannot set blocking mode.")
+ return err
+ }
+ if err := t.resetRawMode(); err != nil {
+ log.Println("[ERROR] Cannot reset from raw mode.")
+ return err
+ }
+ return nil
+}
+
+// Read returns byte array.
+func (t *PosixParser) Read() ([]byte, error) {
+ buf := make([]byte, maxReadBytes)
+ n, err := syscall.Read(syscall.Stdin, buf)
+ if err != nil {
+ return []byte{}, err
+ }
+ return buf[:n], nil
+}
+
+func (t *PosixParser) setRawMode() error {
+ x := t.origTermios.Lflag
+ if x &^= syscall.ICANON; x != 0 && x == t.origTermios.Lflag {
+ // fd is already raw mode
+ return nil
+ }
+ var n syscall.Termios
+ if err := termios.Tcgetattr(uintptr(t.fd), &t.origTermios); err != nil {
+ return err
+ }
+ n = t.origTermios
+ // "&^=" used like: https://play.golang.org/p/8eJw3JxS4O
+ n.Lflag &^= syscall.ECHO | syscall.ICANON | syscall.IEXTEN | syscall.ISIG
+ n.Cc[syscall.VMIN] = 1
+ n.Cc[syscall.VTIME] = 0
+ termios.Tcsetattr(uintptr(t.fd), termios.TCSANOW, &n)
+ return nil
+}
+
+func (t *PosixParser) resetRawMode() error {
+ if t.origTermios.Lflag == 0 {
+ return nil
+ }
+ return termios.Tcsetattr(uintptr(t.fd), termios.TCSANOW, &t.origTermios)
+}
+
+// GetKey returns Key correspond to input byte codes.
+func (t *PosixParser) GetKey(b []byte) Key {
+ for _, k := range asciiSequences {
+ if bytes.Equal(k.ASCIICode, b) {
+ return k.Key
+ }
+ }
+ return NotDefined
+}
+
+// winsize is winsize struct got from the ioctl(2) system call.
+type ioctlWinsize struct {
+ Row uint16
+ Col uint16
+ X uint16 // pixel value
+ Y uint16 // pixel value
+}
+
+// GetWinSize returns WinSize object to represent width and height of terminal.
+func (t *PosixParser) GetWinSize() *WinSize {
+ ws := &ioctlWinsize{}
+ retCode, _, errno := syscall.Syscall(
+ syscall.SYS_IOCTL,
+ uintptr(t.fd),
+ uintptr(syscall.TIOCGWINSZ),
+ uintptr(unsafe.Pointer(ws)))
+
+ if int(retCode) == -1 {
+ panic(errno)
+ }
+ return &WinSize{
+ Row: ws.Row,
+ Col: ws.Col,
+ }
+}
+
+var asciiSequences = []*ASCIICode{
+ {Key: Escape, ASCIICode: []byte{0x1b}},
+
+ {Key: ControlSpace, ASCIICode: []byte{0x00}},
+ {Key: ControlA, ASCIICode: []byte{0x1}},
+ {Key: ControlB, ASCIICode: []byte{0x2}},
+ {Key: ControlC, ASCIICode: []byte{0x3}},
+ {Key: ControlD, ASCIICode: []byte{0x4}},
+ {Key: ControlE, ASCIICode: []byte{0x5}},
+ {Key: ControlF, ASCIICode: []byte{0x6}},
+ {Key: ControlG, ASCIICode: []byte{0x7}},
+ {Key: ControlH, ASCIICode: []byte{0x8}},
+ //{Key: ControlI, ASCIICode: []byte{0x9}},
+ //{Key: ControlJ, ASCIICode: []byte{0xa}},
+ {Key: ControlK, ASCIICode: []byte{0xb}},
+ {Key: ControlL, ASCIICode: []byte{0xc}},
+ {Key: ControlM, ASCIICode: []byte{0xd}},
+ {Key: ControlN, ASCIICode: []byte{0xe}},
+ {Key: ControlO, ASCIICode: []byte{0xf}},
+ {Key: ControlP, ASCIICode: []byte{0x10}},
+ {Key: ControlQ, ASCIICode: []byte{0x11}},
+ {Key: ControlR, ASCIICode: []byte{0x12}},
+ {Key: ControlS, ASCIICode: []byte{0x13}},
+ {Key: ControlT, ASCIICode: []byte{0x14}},
+ {Key: ControlU, ASCIICode: []byte{0x15}},
+ {Key: ControlV, ASCIICode: []byte{0x16}},
+ {Key: ControlW, ASCIICode: []byte{0x17}},
+ {Key: ControlX, ASCIICode: []byte{0x18}},
+ {Key: ControlY, ASCIICode: []byte{0x19}},
+ {Key: ControlZ, ASCIICode: []byte{0x1a}},
+
+ {Key: ControlBackslash, ASCIICode: []byte{0x1c}},
+ {Key: ControlSquareClose, ASCIICode: []byte{0x1d}},
+ {Key: ControlCircumflex, ASCIICode: []byte{0x1e}},
+ {Key: ControlUnderscore, ASCIICode: []byte{0x1f}},
+ {Key: Backspace, ASCIICode: []byte{0x7f}},
+
+ {Key: Up, ASCIICode: []byte{0x1b, 0x5b, 0x41}},
+ {Key: Down, ASCIICode: []byte{0x1b, 0x5b, 0x42}},
+ {Key: Right, ASCIICode: []byte{0x1b, 0x5b, 0x43}},
+ {Key: Left, ASCIICode: []byte{0x1b, 0x5b, 0x44}},
+ {Key: Home, ASCIICode: []byte{0x1b, 0x5b, 0x48}},
+ {Key: Home, ASCIICode: []byte{0x1b, 0x30, 0x48}},
+ {Key: End, ASCIICode: []byte{0x1b, 0x5b, 0x46}},
+ {Key: End, ASCIICode: []byte{0x1b, 0x30, 0x46}},
+
+ {Key: Enter, ASCIICode: []byte{0xa}},
+ {Key: Delete, ASCIICode: []byte{0x1b, 0x5b, 0x33, 0x7e}},
+ {Key: ShiftDelete, ASCIICode: []byte{0x1b, 0x5b, 0x33, 0x3b, 0x32, 0x7e}},
+ {Key: ControlDelete, ASCIICode: []byte{0x1b, 0x5b, 0x33, 0x3b, 0x35, 0x7e}},
+ {Key: Home, ASCIICode: []byte{0x1b, 0x5b, 0x31, 0x7e}},
+ {Key: End, ASCIICode: []byte{0x1b, 0x5b, 0x34, 0x7e}},
+ {Key: PageUp, ASCIICode: []byte{0x1b, 0x5b, 0x35, 0x7e}},
+ {Key: PageDown, ASCIICode: []byte{0x1b, 0x5b, 0x36, 0x7e}},
+ {Key: Home, ASCIICode: []byte{0x1b, 0x5b, 0x37, 0x7e}},
+ {Key: End, ASCIICode: []byte{0x1b, 0x5b, 0x38, 0x7e}},
+ {Key: Tab, ASCIICode: []byte{0x9}},
+ {Key: BackTab, ASCIICode: []byte{0x1b, 0x5b, 0x5a}},
+ {Key: Insert, ASCIICode: []byte{0x1b, 0x5b, 0x32, 0x7e}},
+
+ {Key: F1, ASCIICode: []byte{0x1b, 0x4f, 0x50}},
+ {Key: F2, ASCIICode: []byte{0x1b, 0x4f, 0x51}},
+ {Key: F3, ASCIICode: []byte{0x1b, 0x4f, 0x52}},
+ {Key: F4, ASCIICode: []byte{0x1b, 0x4f, 0x53}},
+
+ {Key: F1, ASCIICode: []byte{0x1b, 0x4f, 0x50, 0x41}}, // Linux console
+ {Key: F2, ASCIICode: []byte{0x1b, 0x5b, 0x5b, 0x42}}, // Linux console
+ {Key: F3, ASCIICode: []byte{0x1b, 0x5b, 0x5b, 0x43}}, // Linux console
+ {Key: F4, ASCIICode: []byte{0x1b, 0x5b, 0x5b, 0x44}}, // Linux console
+ {Key: F5, ASCIICode: []byte{0x1b, 0x5b, 0x5b, 0x45}}, // Linux console
+
+ {Key: F1, ASCIICode: []byte{0x1b, 0x5b, 0x11, 0x7e}}, // rxvt-unicode
+ {Key: F2, ASCIICode: []byte{0x1b, 0x5b, 0x12, 0x7e}}, // rxvt-unicode
+ {Key: F3, ASCIICode: []byte{0x1b, 0x5b, 0x13, 0x7e}}, // rxvt-unicode
+ {Key: F4, ASCIICode: []byte{0x1b, 0x5b, 0x14, 0x7e}}, // rxvt-unicode
+
+ {Key: F5, ASCIICode: []byte{0x1b, 0x5b, 0x31, 0x35, 0x7e}},
+ {Key: F6, ASCIICode: []byte{0x1b, 0x5b, 0x31, 0x37, 0x7e}},
+ {Key: F7, ASCIICode: []byte{0x1b, 0x5b, 0x31, 0x38, 0x7e}},
+ {Key: F8, ASCIICode: []byte{0x1b, 0x5b, 0x31, 0x39, 0x7e}},
+ {Key: F9, ASCIICode: []byte{0x1b, 0x5b, 0x32, 0x30, 0x7e}},
+ {Key: F10, ASCIICode: []byte{0x1b, 0x5b, 0x32, 0x31, 0x7e}},
+ {Key: F11, ASCIICode: []byte{0x1b, 0x5b, 0x32, 0x32, 0x7e}},
+ {Key: F12, ASCIICode: []byte{0x1b, 0x5b, 0x32, 0x34, 0x7e, 0x8}},
+ {Key: F13, ASCIICode: []byte{0x1b, 0x5b, 0x25, 0x7e}},
+ {Key: F14, ASCIICode: []byte{0x1b, 0x5b, 0x26, 0x7e}},
+ {Key: F15, ASCIICode: []byte{0x1b, 0x5b, 0x28, 0x7e}},
+ {Key: F16, ASCIICode: []byte{0x1b, 0x5b, 0x29, 0x7e}},
+ {Key: F17, ASCIICode: []byte{0x1b, 0x5b, 0x31, 0x7e}},
+ {Key: F18, ASCIICode: []byte{0x1b, 0x5b, 0x32, 0x7e}},
+ {Key: F19, ASCIICode: []byte{0x1b, 0x5b, 0x33, 0x7e}},
+ {Key: F20, ASCIICode: []byte{0x1b, 0x5b, 0x34, 0x7e}},
+
+ // Xterm
+ {Key: F13, ASCIICode: []byte{0x1b, 0x5b, 0x31, 0x3b, 0x32, 0x50}},
+ {Key: F14, ASCIICode: []byte{0x1b, 0x5b, 0x31, 0x3b, 0x32, 0x51}},
+ // &ASCIICode{Key: F15, ASCIICode: []byte{0x1b, 0x5b, 0x31, 0x3b, 0x32, 0x52}}, // Conflicts with CPR response
+ {Key: F16, ASCIICode: []byte{0x1b, 0x5b, 0x31, 0x3b, 0x32, 0x52}},
+ {Key: F17, ASCIICode: []byte{0x1b, 0x5b, 0x15, 0x3b, 0x32, 0x7e}},
+ {Key: F18, ASCIICode: []byte{0x1b, 0x5b, 0x17, 0x3b, 0x32, 0x7e}},
+ {Key: F19, ASCIICode: []byte{0x1b, 0x5b, 0x18, 0x3b, 0x32, 0x7e}},
+ {Key: F20, ASCIICode: []byte{0x1b, 0x5b, 0x19, 0x3b, 0x32, 0x7e}},
+ {Key: F21, ASCIICode: []byte{0x1b, 0x5b, 0x20, 0x3b, 0x32, 0x7e}},
+ {Key: F22, ASCIICode: []byte{0x1b, 0x5b, 0x21, 0x3b, 0x32, 0x7e}},
+ {Key: F23, ASCIICode: []byte{0x1b, 0x5b, 0x23, 0x3b, 0x32, 0x7e}},
+ {Key: F24, ASCIICode: []byte{0x1b, 0x5b, 0x24, 0x3b, 0x32, 0x7e}},
+
+ {Key: ControlUp, ASCIICode: []byte{0x1b, 0x5b, 0x31, 0x3b, 0x35, 0x41}},
+ {Key: ControlDown, ASCIICode: []byte{0x1b, 0x5b, 0x31, 0x3b, 0x35, 0x42}},
+ {Key: ControlRight, ASCIICode: []byte{0x1b, 0x5b, 0x31, 0x3b, 0x35, 0x43}},
+ {Key: ControlLeft, ASCIICode: []byte{0x1b, 0x5b, 0x31, 0x3b, 0x35, 0x44}},
+
+ {Key: ShiftUp, ASCIICode: []byte{0x1b, 0x5b, 0x31, 0x3b, 0x32, 0x41}},
+ {Key: ShiftDown, ASCIICode: []byte{0x1b, 0x5b, 0x31, 0x3b, 0x32, 0x42}},
+ {Key: ShiftRight, ASCIICode: []byte{0x1b, 0x5b, 0x31, 0x3b, 0x32, 0x43}},
+ {Key: ShiftLeft, ASCIICode: []byte{0x1b, 0x5b, 0x31, 0x3b, 0x32, 0x44}},
+
+ // Tmux sends following keystrokes when control+arrow is pressed, but for
+ // Emacs ansi-term sends the same sequences for normal arrow keys. Consider
+ // it a normal arrow press, because that's more important.
+ {Key: Up, ASCIICode: []byte{0x1b, 0x4f, 0x41}},
+ {Key: Down, ASCIICode: []byte{0x1b, 0x4f, 0x42}},
+ {Key: Right, ASCIICode: []byte{0x1b, 0x4f, 0x43}},
+ {Key: Left, ASCIICode: []byte{0x1b, 0x4f, 0x44}},
+
+ {Key: ControlUp, ASCIICode: []byte{0x1b, 0x5b, 0x35, 0x41}},
+ {Key: ControlDown, ASCIICode: []byte{0x1b, 0x5b, 0x35, 0x42}},
+ {Key: ControlRight, ASCIICode: []byte{0x1b, 0x5b, 0x35, 0x43}},
+ {Key: ControlLeft, ASCIICode: []byte{0x1b, 0x5b, 0x35, 0x44}},
+
+ {Key: ControlRight, ASCIICode: []byte{0x1b, 0x5b, 0x4f, 0x63}}, // rxvt
+ {Key: ControlLeft, ASCIICode: []byte{0x1b, 0x5b, 0x4f, 0x64}}, // rxvt
+
+ {Key: Ignore, ASCIICode: []byte{0x1b, 0x5b, 0x45}}, // Xterm
+ {Key: Ignore, ASCIICode: []byte{0x1b, 0x5b, 0x46}}, // Linux console
+}
+
+var _ ConsoleParser = &PosixParser{}
+
+// NewStandardInputParser returns ConsoleParser object to read from stdin.
+func NewStandardInputParser() *PosixParser {
+ return &PosixParser{
+ fd: syscall.Stdin,
+ }
+}
diff --git a/vendor/github.com/c-bata/go-prompt/posix_output.go b/vendor/github.com/c-bata/go-prompt/posix_output.go
new file mode 100644
index 0000000000..52c69d9465
--- /dev/null
+++ b/vendor/github.com/c-bata/go-prompt/posix_output.go
@@ -0,0 +1,335 @@
+// +build !windows
+
+package prompt
+
+import (
+ "strconv"
+ "syscall"
+)
+
+// PosixWriter is a ConsoleWriter implementation for POSIX environment.
+// To control terminal emulator, this outputs VT100 escape sequences.
+type PosixWriter struct {
+ fd int
+ buffer []byte
+}
+
+// WriteRaw to write raw byte array
+func (w *PosixWriter) WriteRaw(data []byte) {
+ w.buffer = append(w.buffer, data...)
+ // Flush because sometimes the render is broken when a large amount data in buffer.
+ w.Flush()
+ return
+}
+
+// Write to write byte array without control sequences
+func (w *PosixWriter) Write(data []byte) {
+ w.WriteRaw(byteFilter(data, writeFilter))
+ return
+}
+
+// WriteRawStr to write raw string
+func (w *PosixWriter) WriteRawStr(data string) {
+ w.WriteRaw([]byte(data))
+ return
+}
+
+// WriteStr to write string without control sequences
+func (w *PosixWriter) WriteStr(data string) {
+ w.Write([]byte(data))
+ return
+}
+
+// Flush to flush buffer
+func (w *PosixWriter) Flush() error {
+ _, err := syscall.Write(w.fd, w.buffer)
+ if err != nil {
+ return err
+ }
+ w.buffer = []byte{}
+ return nil
+}
+
+/* Erase */
+
+// EraseScreen erases the screen with the background colour and moves the cursor to home.
+func (w *PosixWriter) EraseScreen() {
+ w.WriteRaw([]byte{0x1b, 0x5b, 0x32, 0x4a})
+ return
+}
+
+// EraseUp erases the screen from the current line up to the top of the screen.
+func (w *PosixWriter) EraseUp() {
+ w.WriteRaw([]byte{0x1b, 0x5b, 0x31, 0x4a})
+ return
+}
+
+// EraseDown erases the screen from the current line down to the bottom of the screen.
+func (w *PosixWriter) EraseDown() {
+ w.WriteRaw([]byte{0x1b, 0x5b, 0x4a})
+ return
+}
+
+// EraseStartOfLine erases from the current cursor position to the start of the current line.
+func (w *PosixWriter) EraseStartOfLine() {
+ w.WriteRaw([]byte{0x1b, 0x5b, 0x31, 0x4b})
+ return
+}
+
+// EraseEndOfLine erases from the current cursor position to the end of the current line.
+func (w *PosixWriter) EraseEndOfLine() {
+ w.WriteRaw([]byte{0x1b, 0x5b, 0x4b})
+ return
+}
+
+// EraseLine erases the entire current line.
+func (w *PosixWriter) EraseLine() {
+ w.WriteRaw([]byte{0x1b, 0x5b, 0x32, 0x4b})
+ return
+}
+
+/* Cursor */
+
+// ShowCursor stops blinking cursor and show.
+func (w *PosixWriter) ShowCursor() {
+ w.WriteRaw([]byte{0x1b, 0x5b, 0x3f, 0x31, 0x32, 0x6c, 0x1b, 0x5b, 0x3f, 0x32, 0x35, 0x68})
+}
+
+// HideCursor hides cursor.
+func (w *PosixWriter) HideCursor() {
+ w.WriteRaw([]byte{0x1b, 0x5b, 0x3f, 0x32, 0x35, 0x6c})
+ return
+}
+
+// CursorGoTo sets the cursor position where subsequent text will begin.
+func (w *PosixWriter) CursorGoTo(row, col int) {
+ if row == 0 && col == 0 {
+ // If no row/column parameters are provided (ie. [H), the cursor will move to the home position.
+ w.WriteRaw([]byte{0x1b, 0x5b, 0x3b, 0x48})
+ return
+ }
+ r := strconv.Itoa(row)
+ c := strconv.Itoa(col)
+ w.WriteRaw([]byte{0x1b, 0x5b})
+ w.WriteRaw([]byte(r))
+ w.WriteRaw([]byte{0x3b})
+ w.WriteRaw([]byte(c))
+ w.WriteRaw([]byte{0x48})
+ return
+}
+
+// CursorUp moves the cursor up by 'n' rows; the default count is 1.
+func (w *PosixWriter) CursorUp(n int) {
+ if n == 0 {
+ return
+ } else if n < 0 {
+ w.CursorDown(-n)
+ return
+ }
+ s := strconv.Itoa(n)
+ w.WriteRaw([]byte{0x1b, 0x5b})
+ w.WriteRaw([]byte(s))
+ w.WriteRaw([]byte{0x41})
+ return
+}
+
+// CursorDown moves the cursor down by 'n' rows; the default count is 1.
+func (w *PosixWriter) CursorDown(n int) {
+ if n == 0 {
+ return
+ } else if n < 0 {
+ w.CursorUp(-n)
+ return
+ }
+ s := strconv.Itoa(n)
+ w.WriteRaw([]byte{0x1b, 0x5b})
+ w.WriteRaw([]byte(s))
+ w.WriteRaw([]byte{0x42})
+ return
+}
+
+// CursorForward moves the cursor forward by 'n' columns; the default count is 1.
+func (w *PosixWriter) CursorForward(n int) {
+ if n == 0 {
+ return
+ } else if n < 0 {
+ w.CursorBackward(-n)
+ return
+ }
+ s := strconv.Itoa(n)
+ w.WriteRaw([]byte{0x1b, 0x5b})
+ w.WriteRaw([]byte(s))
+ w.WriteRaw([]byte{0x43})
+ return
+}
+
+// CursorBackward moves the cursor backward by 'n' columns; the default count is 1.
+func (w *PosixWriter) CursorBackward(n int) {
+ if n == 0 {
+ return
+ } else if n < 0 {
+ w.CursorForward(-n)
+ return
+ }
+ s := strconv.Itoa(n)
+ w.WriteRaw([]byte{0x1b, 0x5b})
+ w.WriteRaw([]byte(s))
+ w.WriteRaw([]byte{0x44})
+ return
+}
+
+// AskForCPR asks for a cursor position report (CPR).
+func (w *PosixWriter) AskForCPR() {
+ // CPR: Cursor Position Request.
+ w.WriteRaw([]byte{0x1b, 0x5b, 0x36, 0x6e})
+ w.Flush()
+ return
+}
+
+// SaveCursor saves current cursor position.
+func (w *PosixWriter) SaveCursor() {
+ w.WriteRaw([]byte{0x1b, 0x5b, 0x73})
+ return
+}
+
+// UnSaveCursor restores cursor position after a Save Cursor.
+func (w *PosixWriter) UnSaveCursor() {
+ w.WriteRaw([]byte{0x1b, 0x5b, 0x75})
+ return
+}
+
+/* Scrolling */
+
+// ScrollDown scrolls display down one line.
+func (w *PosixWriter) ScrollDown() {
+ w.WriteRaw([]byte{0x1b, 0x44})
+ return
+}
+
+// ScrollUp scroll display up one line.
+func (w *PosixWriter) ScrollUp() {
+ w.WriteRaw([]byte{0x1b, 0x4d})
+ return
+}
+
+/* Title */
+
+// SetTitle sets a title of terminal window.
+func (w *PosixWriter) SetTitle(title string) {
+ w.WriteRaw([]byte{0x1b, 0x5d, 0x32, 0x3b})
+ w.WriteRaw(byteFilter([]byte(title), setTextFilter))
+ w.WriteRaw([]byte{0x07})
+ return
+}
+
+// ClearTitle clears a title of terminal window.
+func (w *PosixWriter) ClearTitle() {
+ w.WriteRaw([]byte{0x1b, 0x5d, 0x32, 0x3b, 0x07})
+ return
+}
+
+/* Font */
+
+// SetColor sets text and background colors. and specify whether text is bold.
+func (w *PosixWriter) SetColor(fg, bg Color, bold bool) {
+ f, ok := foregroundANSIColors[fg]
+ if !ok {
+ f = foregroundANSIColors[DefaultColor]
+ }
+ b, ok := backgroundANSIColors[bg]
+ if !ok {
+ b = backgroundANSIColors[DefaultColor]
+ }
+ syscall.Write(syscall.Stdout, []byte{0x1b, 0x5b, 0x33, 0x39, 0x3b, 0x34, 0x39, 0x6d})
+ w.WriteRaw([]byte{0x1b, 0x5b})
+ if !bold {
+ w.WriteRaw([]byte{0x30, 0x3b})
+ }
+ w.WriteRaw(f)
+ w.WriteRaw([]byte{0x3b})
+ w.WriteRaw(b)
+ if bold {
+ w.WriteRaw([]byte{0x3b, 0x31})
+ }
+ w.WriteRaw([]byte{0x6d})
+ return
+}
+
+var foregroundANSIColors = map[Color][]byte{
+ DefaultColor: {0x33, 0x39}, // 39
+
+ // Low intensity.
+ Black: {0x33, 0x30}, // 30
+ DarkRed: {0x33, 0x31}, // 31
+ DarkGreen: {0x33, 0x32}, // 32
+ Brown: {0x33, 0x33}, // 33
+ DarkBlue: {0x33, 0x34}, // 34
+ Purple: {0x33, 0x35}, // 35
+ Cyan: {0x33, 0x36}, //36
+ LightGray: {0x33, 0x37}, //37
+
+ // High intensity.
+ DarkGray: {0x39, 0x30}, // 90
+ Red: {0x39, 0x31}, // 91
+ Green: {0x39, 0x32}, // 92
+ Yellow: {0x39, 0x33}, // 93
+ Blue: {0x39, 0x34}, // 94
+ Fuchsia: {0x39, 0x35}, // 95
+ Turquoise: {0x39, 0x36}, // 96
+ White: {0x39, 0x37}, // 97
+}
+
+var backgroundANSIColors = map[Color][]byte{
+ DefaultColor: {0x34, 0x39}, // 49
+
+ // Low intensity.
+ Black: {0x34, 0x30}, // 40
+ DarkRed: {0x34, 0x31}, // 41
+ DarkGreen: {0x34, 0x32}, // 42
+ Brown: {0x34, 0x33}, // 43
+ DarkBlue: {0x34, 0x34}, // 44
+ Purple: {0x34, 0x35}, // 45
+ Cyan: {0x34, 0x36}, // 46
+ LightGray: {0x34, 0x37}, // 47
+
+ // High intensity
+ DarkGray: {0x31, 0x30, 0x30}, // 100
+ Red: {0x31, 0x30, 0x31}, // 101
+ Green: {0x31, 0x30, 0x32}, // 102
+ Yellow: {0x31, 0x30, 0x33}, // 103
+ Blue: {0x31, 0x30, 0x34}, // 104
+ Fuchsia: {0x31, 0x30, 0x35}, // 105
+ Turquoise: {0x31, 0x30, 0x36}, // 106
+ White: {0x31, 0x30, 0x37}, // 107
+}
+
+func writeFilter(buf byte) bool {
+ return buf != 0x1b && buf != 0x3f
+}
+
+func setTextFilter(buf byte) bool {
+ return buf != 0x1b && buf != 0x07
+}
+
+func byteFilter(buf []byte, fn ...func(b byte) bool) []byte {
+ if len(fn) == 0 {
+ return buf
+ }
+ ret := make([]byte, 0, len(buf))
+ f := fn[0]
+ for i, n := range buf {
+ if f(n) {
+ ret = append(ret, buf[i])
+ }
+ }
+ return byteFilter(ret, fn[1:]...)
+}
+
+var _ ConsoleWriter = &PosixWriter{}
+
+// NewStandardOutputWriter returns ConsoleWriter object to write to stdout.
+func NewStandardOutputWriter() *PosixWriter {
+ return &PosixWriter{
+ fd: syscall.Stdout,
+ }
+}
diff --git a/vendor/github.com/c-bata/go-prompt/prompt.go b/vendor/github.com/c-bata/go-prompt/prompt.go
index 6f72944c34..74ce03b616 100644
--- a/vendor/github.com/c-bata/go-prompt/prompt.go
+++ b/vendor/github.com/c-bata/go-prompt/prompt.go
@@ -1,7 +1,6 @@
package prompt
import (
- "bytes"
"io/ioutil"
"log"
"os"
@@ -20,15 +19,14 @@ type Completer func(Document) []Suggest
// Prompt is core struct of go-prompt.
type Prompt struct {
- in ConsoleParser
- buf *Buffer
- renderer *Render
- executor Executor
- history *History
- completion *CompletionManager
- keyBindings []KeyBind
- ASCIICodeBindings []ASCIICodeBind
- keyBindMode KeyBindMode
+ in ConsoleParser
+ buf *Buffer
+ renderer *Render
+ executor Executor
+ history *History
+ completion *CompletionManager
+ keyBindings []KeyBind
+ keyBindMode KeyBindMode
}
// Exec is the struct contains user input context.
@@ -67,8 +65,6 @@ func (p *Prompt) Run() {
case b := <-bufCh:
if shouldExit, e := p.feed(b); shouldExit {
p.renderer.BreakLine(p.buf)
- stopReadBufCh <- struct{}{}
- stopHandleSignalCh <- struct{}{}
return
} else if e != nil {
// Stop goroutine to run readBuffer function
@@ -109,7 +105,31 @@ func (p *Prompt) feed(b []byte) (shouldExit bool, exec *Exec) {
// completion
completing := p.completion.Completing()
- p.handleCompletionKeyBinding(key, completing)
+ switch key {
+ case Down:
+ if completing {
+ p.completion.Next()
+ }
+ case Tab, ControlI:
+ p.completion.Next()
+ case Up:
+ if completing {
+ p.completion.Previous()
+ }
+ case BackTab:
+ p.completion.Previous()
+ case ControlSpace:
+ return
+ default:
+ if s, ok := p.completion.GetSelectedSuggestion(); ok {
+ w := p.buf.Document().GetWordBeforeCursor()
+ if w != "" {
+ p.buf.DeleteBeforeCursor(len([]rune(w)))
+ }
+ p.buf.InsertText(s.Text, false, true)
+ }
+ p.completion.Reset()
+ }
switch key {
case Enter, ControlJ, ControlM:
@@ -144,43 +164,10 @@ func (p *Prompt) feed(b []byte) (shouldExit bool, exec *Exec) {
return
}
case NotDefined:
- if p.handleASCIICodeBinding(b) {
- return
- }
p.buf.InsertText(string(b), false, true)
}
- p.handleKeyBinding(key)
- return
-}
-
-func (p *Prompt) handleCompletionKeyBinding(key Key, completing bool) {
- switch key {
- case Down:
- if completing {
- p.completion.Next()
- }
- case Tab, ControlI:
- p.completion.Next()
- case Up:
- if completing {
- p.completion.Previous()
- }
- case BackTab:
- p.completion.Previous()
- default:
- if s, ok := p.completion.GetSelectedSuggestion(); ok {
- w := p.buf.Document().GetWordBeforeCursorUntilSeparator(p.completion.wordSeparator)
- if w != "" {
- p.buf.DeleteBeforeCursor(len([]rune(w)))
- }
- p.buf.InsertText(s.Text, false, true)
- }
- p.completion.Reset()
- }
-}
-
-func (p *Prompt) handleKeyBinding(key Key) {
+ // Key bindings
for i := range commonKeyBindings {
kb := commonKeyBindings[i]
if kb.Key == key {
@@ -204,17 +191,7 @@ func (p *Prompt) handleKeyBinding(key Key) {
kb.Fn(p.buf)
}
}
-}
-
-func (p *Prompt) handleASCIICodeBinding(b []byte) bool {
- checked := false
- for _, kb := range p.ASCIICodeBindings {
- if bytes.Compare(kb.ASCIICode, b) == 0 {
- kb.Fn(p.buf)
- checked = true
- }
- }
- return checked
+ return
}
// Input just returns user input text.
@@ -242,7 +219,6 @@ func (p *Prompt) Input() string {
case b := <-bufCh:
if shouldExit, e := p.feed(b); shouldExit {
p.renderer.BreakLine(p.buf)
- stopReadBufCh <- struct{}{}
return ""
} else if e != nil {
// Stop goroutine to run readBuffer function
@@ -261,16 +237,16 @@ func (p *Prompt) Input() string {
func (p *Prompt) readBuffer(bufCh chan []byte, stopCh chan struct{}) {
log.Printf("[INFO] readBuffer start")
for {
+ time.Sleep(10 * time.Millisecond)
select {
case <-stopCh:
log.Print("[INFO] stop readBuffer")
return
default:
- if b, err := p.in.Read(); err == nil && !(len(b) == 1 && b[0] == 0) {
+ if b, err := p.in.Read(); err == nil {
bufCh <- b
}
}
- time.Sleep(10 * time.Millisecond)
}
}
diff --git a/vendor/github.com/c-bata/go-prompt/render.go b/vendor/github.com/c-bata/go-prompt/render.go
index 2d774aafca..e37867876e 100644
--- a/vendor/github.com/c-bata/go-prompt/render.go
+++ b/vendor/github.com/c-bata/go-prompt/render.go
@@ -1,11 +1,5 @@
package prompt
-import (
- "runtime"
-
- "github.com/mattn/go-runewidth"
-)
-
// Render to render prompt information from state of Buffer.
type Render struct {
out ConsoleWriter
@@ -88,6 +82,7 @@ func (r *Render) renderWindowTooSmall() {
r.out.EraseScreen()
r.out.SetColor(DarkRed, White, false)
r.out.WriteStr("Your console window is too small...")
+ r.out.Flush()
return
}
@@ -99,7 +94,7 @@ func (r *Render) renderCompletion(buf *Buffer, completions *CompletionManager) {
prefix := r.getCurrentPrefix()
formatted, width := formatSuggestions(
suggestions,
- int(r.col)-runewidth.StringWidth(prefix)-1, // -1 means a width of scrollbar
+ int(r.col)-len(prefix)-1, // -1 means a width of scrollbar
)
// +1 means a width of scrollbar.
width++
@@ -111,10 +106,10 @@ func (r *Render) renderCompletion(buf *Buffer, completions *CompletionManager) {
formatted = formatted[completions.verticalScroll : completions.verticalScroll+windowHeight]
r.prepareArea(windowHeight)
- cursor := runewidth.StringWidth(prefix) + runewidth.StringWidth(buf.Document().TextBeforeCursor())
+ cursor := len(prefix) + len(buf.Document().TextBeforeCursor())
x, _ := r.toPos(cursor)
if x+width >= int(r.col) {
- cursor = r.backward(cursor, x+width-int(r.col))
+ r.out.CursorBackward(x + width - int(r.col))
}
contentHeight := len(completions.tmp)
@@ -153,10 +148,7 @@ func (r *Render) renderCompletion(buf *Buffer, completions *CompletionManager) {
r.out.SetColor(DefaultColor, r.scrollbarBGColor, false)
}
r.out.WriteStr(" ")
- r.out.SetColor(DefaultColor, DefaultColor, false)
-
- r.lineWrap(cursor + width)
- r.backward(cursor+width, width)
+ r.out.CursorBackward(width)
}
if x+width >= int(r.col) {
@@ -170,64 +162,53 @@ func (r *Render) renderCompletion(buf *Buffer, completions *CompletionManager) {
// Render renders to the console.
func (r *Render) Render(buffer *Buffer, completion *CompletionManager) {
- // In situations where a pseudo tty is allocated (e.g. within a docker container),
- // window size via TIOCGWINSZ is not immediately available and will result in 0,0 dimensions.
- if r.col == 0 {
- return
- }
- defer r.out.Flush()
- r.move(r.previousCursor, 0)
-
line := buffer.Text()
prefix := r.getCurrentPrefix()
- cursor := runewidth.StringWidth(prefix) + runewidth.StringWidth(line)
+ cursor := len(prefix) + len(line)
- // prepare area
- _, y := r.toPos(cursor)
+ // In situations where a psuedo tty is allocated (e.g. within a docker container),
+ // window size via TIOCGWINSZ is not immediately available and will result in 0,0 dimensions.
+ if r.col > 0 {
+ // Erasing
+ r.clear(r.previousCursor)
- h := y + 1 + int(completion.max)
- if h > int(r.row) || completionMargin > int(r.col) {
- r.renderWindowTooSmall()
- return
+ // prepare area
+ _, y := r.toPos(cursor)
+
+ h := y + 1 + int(completion.max)
+ if h > int(r.row) || completionMargin > int(r.col) {
+ r.renderWindowTooSmall()
+ return
+ }
}
// Rendering
- r.out.HideCursor()
- defer r.out.ShowCursor()
-
r.renderPrefix()
r.out.SetColor(r.inputTextColor, r.inputBGColor, false)
r.out.WriteStr(line)
r.out.SetColor(DefaultColor, DefaultColor, false)
- r.lineWrap(cursor)
- r.out.EraseDown()
-
- cursor = r.backward(cursor, runewidth.StringWidth(line)-buffer.DisplayCursorPosition())
+ cursor = r.backward(cursor, len(line)-buffer.CursorPosition)
r.renderCompletion(buffer, completion)
if suggest, ok := completion.GetSelectedSuggestion(); ok {
- cursor = r.backward(cursor, runewidth.StringWidth(buffer.Document().GetWordBeforeCursorUntilSeparator(completion.wordSeparator)))
+ cursor = r.backward(cursor, len(buffer.Document().GetWordBeforeCursor()))
r.out.SetColor(r.previewSuggestionTextColor, r.previewSuggestionBGColor, false)
r.out.WriteStr(suggest.Text)
r.out.SetColor(DefaultColor, DefaultColor, false)
- cursor += runewidth.StringWidth(suggest.Text)
- rest := buffer.Document().TextAfterCursor()
- r.out.WriteStr(rest)
- cursor += runewidth.StringWidth(rest)
- r.lineWrap(cursor)
-
- cursor = r.backward(cursor, runewidth.StringWidth(rest))
+ cursor += len(suggest.Text)
}
+ r.out.Flush()
+
r.previousCursor = cursor
}
// BreakLine to break line.
func (r *Render) BreakLine(buffer *Buffer) {
// Erasing and Render
- cursor := runewidth.StringWidth(buffer.Document().TextBeforeCursor()) + runewidth.StringWidth(r.getCurrentPrefix())
+ cursor := len(buffer.Document().TextBeforeCursor()) + len(r.getCurrentPrefix())
r.clear(cursor)
r.renderPrefix()
r.out.SetColor(r.inputTextColor, r.inputBGColor, false)
@@ -238,40 +219,37 @@ func (r *Render) BreakLine(buffer *Buffer) {
r.previousCursor = 0
}
-// clear erases the screen from a beginning of input
-// even if there is line break which means input length exceeds a window's width.
func (r *Render) clear(cursor int) {
- r.move(cursor, 0)
+ r.backward(cursor, cursor)
r.out.EraseDown()
}
-// backward moves cursor to backward from a current cursor position
-// regardless there is a line break.
func (r *Render) backward(from, n int) int {
return r.move(from, from-n)
}
-// move moves cursor to specified position from the beginning of input
-// even if there is a line break.
func (r *Render) move(from, to int) int {
- fromX, fromY := r.toPos(from)
+ _, fromY := r.toPos(from)
toX, toY := r.toPos(to)
r.out.CursorUp(fromY - toY)
- r.out.CursorBackward(fromX - toX)
+ r.out.WriteRaw([]byte{'\r'})
+ r.out.CursorForward(toX)
return to
}
// toPos returns the relative position from the beginning of the string.
+// the coordinate system with the beginning of the string as (0,0) and the width as r.col.
+// the cursor points to the next character, but it points to that character only at the right end (x == r.col - 1).
+// x will not return 0 except for the first row.
func (r *Render) toPos(cursor int) (x, y int) {
col := int(r.col)
- return cursor % col, cursor / col
-}
-func (r *Render) lineWrap(cursor int) {
- if runtime.GOOS != "windows" && cursor > 0 && cursor%int(r.col) == 0 {
- r.out.WriteRaw([]byte{'\n'})
+ if cursor > 0 && cursor%col == 0 {
+ return col - 1, cursor/col - 1
}
+
+ return cursor % col, cursor / col
}
func clamp(high, low, x float64) float64 {
diff --git a/vendor/github.com/c-bata/go-prompt/shortcut.go b/vendor/github.com/c-bata/go-prompt/shortcut.go
deleted file mode 100644
index 20fe71d085..0000000000
--- a/vendor/github.com/c-bata/go-prompt/shortcut.go
+++ /dev/null
@@ -1,43 +0,0 @@
-package prompt
-
-func dummyExecutor(in string) { return }
-
-// Input get the input data from the user and return it.
-func Input(prefix string, completer Completer, opts ...Option) string {
- pt := New(dummyExecutor, completer)
- pt.renderer.prefixTextColor = DefaultColor
- pt.renderer.prefix = prefix
-
- for _, opt := range opts {
- if err := opt(pt); err != nil {
- panic(err)
- }
- }
- return pt.Input()
-}
-
-// Choose to the shortcut of input function to select from string array.
-// Deprecated: Maybe anyone want to use this.
-func Choose(prefix string, choices []string, opts ...Option) string {
- completer := newChoiceCompleter(choices, FilterHasPrefix)
- pt := New(dummyExecutor, completer)
- pt.renderer.prefixTextColor = DefaultColor
- pt.renderer.prefix = prefix
-
- for _, opt := range opts {
- if err := opt(pt); err != nil {
- panic(err)
- }
- }
- return pt.Input()
-}
-
-func newChoiceCompleter(choices []string, filter Filter) Completer {
- s := make([]Suggest, len(choices))
- for i := range choices {
- s[i] = Suggest{Text: choices[i]}
- }
- return func(x Document) []Suggest {
- return filter(s, x.GetWordBeforeCursor(), true)
- }
-}
diff --git a/vendor/github.com/c-bata/go-prompt/windows_input.go b/vendor/github.com/c-bata/go-prompt/windows_input.go
new file mode 100644
index 0000000000..13b332a775
--- /dev/null
+++ b/vendor/github.com/c-bata/go-prompt/windows_input.go
@@ -0,0 +1,214 @@
+// +build windows
+
+package prompt
+
+import (
+ "bytes"
+ "unicode/utf8"
+
+ "github.com/mattn/go-tty"
+)
+
+const maxReadBytes = 1024
+
+// WindowsParser is a ConsoleParser implementation for Win32 console.
+type WindowsParser struct {
+ tty *tty.TTY
+}
+
+// Setup should be called before starting input
+func (p *WindowsParser) Setup() error {
+ t, err := tty.Open()
+ if err != nil {
+ return err
+ }
+ p.tty = t
+ return nil
+}
+
+// TearDown should be called after stopping input
+func (p *WindowsParser) TearDown() error {
+ return p.tty.Close()
+}
+
+// GetKey returns Key correspond to input byte codes.
+func (p *WindowsParser) GetKey(b []byte) Key {
+ for _, k := range asciiSequences {
+ if bytes.Compare(k.ASCIICode, b) == 0 {
+ return k.Key
+ }
+ }
+ return NotDefined
+}
+
+// Read returns byte array.
+func (p *WindowsParser) Read() ([]byte, error) {
+ buf := make([]byte, maxReadBytes)
+ r, err := p.tty.ReadRune()
+ if err != nil {
+ return []byte{}, err
+ }
+ n := utf8.EncodeRune(buf[:], r)
+ for p.tty.Buffered() && n < maxReadBytes {
+ r, err := p.tty.ReadRune()
+ if err != nil {
+ break
+ }
+ n += utf8.EncodeRune(buf[n:], r)
+ }
+ return buf[:n], nil
+}
+
+// GetWinSize returns WinSize object to represent width and height of terminal.
+func (p *WindowsParser) GetWinSize() *WinSize {
+ w, h, err := p.tty.Size()
+ if err != nil {
+ panic(err)
+ }
+ return &WinSize{
+ Row: uint16(h),
+ Col: uint16(w),
+ }
+}
+
+var asciiSequences []*ASCIICode = []*ASCIICode{
+ {Key: Escape, ASCIICode: []byte{0x1b}},
+
+ {Key: ControlSpace, ASCIICode: []byte{0x00}},
+ {Key: ControlA, ASCIICode: []byte{0x1}},
+ {Key: ControlB, ASCIICode: []byte{0x2}},
+ {Key: ControlC, ASCIICode: []byte{0x3}},
+ {Key: ControlD, ASCIICode: []byte{0x4}},
+ {Key: ControlE, ASCIICode: []byte{0x5}},
+ {Key: ControlF, ASCIICode: []byte{0x6}},
+ {Key: ControlG, ASCIICode: []byte{0x7}},
+ {Key: ControlH, ASCIICode: []byte{0x8}},
+ //{Key: ControlI, ASCIICode: []byte{0x9}},
+ //{Key: ControlJ, ASCIICode: []byte{0xa}},
+ {Key: ControlK, ASCIICode: []byte{0xb}},
+ {Key: ControlL, ASCIICode: []byte{0xc}},
+ {Key: ControlM, ASCIICode: []byte{0xd}},
+ {Key: ControlN, ASCIICode: []byte{0xe}},
+ {Key: ControlO, ASCIICode: []byte{0xf}},
+ {Key: ControlP, ASCIICode: []byte{0x10}},
+ {Key: ControlQ, ASCIICode: []byte{0x11}},
+ {Key: ControlR, ASCIICode: []byte{0x12}},
+ {Key: ControlS, ASCIICode: []byte{0x13}},
+ {Key: ControlT, ASCIICode: []byte{0x14}},
+ {Key: ControlU, ASCIICode: []byte{0x15}},
+ {Key: ControlV, ASCIICode: []byte{0x16}},
+ {Key: ControlW, ASCIICode: []byte{0x17}},
+ {Key: ControlX, ASCIICode: []byte{0x18}},
+ {Key: ControlY, ASCIICode: []byte{0x19}},
+ {Key: ControlZ, ASCIICode: []byte{0x1a}},
+
+ {Key: ControlBackslash, ASCIICode: []byte{0x1c}},
+ {Key: ControlSquareClose, ASCIICode: []byte{0x1d}},
+ {Key: ControlCircumflex, ASCIICode: []byte{0x1e}},
+ {Key: ControlUnderscore, ASCIICode: []byte{0x1f}},
+ {Key: Backspace, ASCIICode: []byte{0x7f}},
+
+ {Key: Up, ASCIICode: []byte{0x1b, 0x5b, 0x41}},
+ {Key: Down, ASCIICode: []byte{0x1b, 0x5b, 0x42}},
+ {Key: Right, ASCIICode: []byte{0x1b, 0x5b, 0x43}},
+ {Key: Left, ASCIICode: []byte{0x1b, 0x5b, 0x44}},
+ {Key: Home, ASCIICode: []byte{0x1b, 0x5b, 0x48}},
+ {Key: Home, ASCIICode: []byte{0x1b, 0x4f, 0x48}},
+ {Key: End, ASCIICode: []byte{0x1b, 0x5b, 0x70}},
+ {Key: End, ASCIICode: []byte{0x1b, 0x4f, 0x70}},
+
+ {Key: Enter, ASCIICode: []byte{0xa}},
+ {Key: Delete, ASCIICode: []byte{0x1b, 0x5b, 0x33, 0x7e}},
+ {Key: ShiftDelete, ASCIICode: []byte{0x1b, 0x5b, 0x33, 0x3b, 0x02, 0x7e}},
+ {Key: ControlDelete, ASCIICode: []byte{0x1b, 0x5b, 0x33, 0x3b, 0x05, 0x7e}},
+ {Key: Home, ASCIICode: []byte{0x1b, 0x5b, 0x01, 0x7e}},
+ {Key: End, ASCIICode: []byte{0x1b, 0x5b, 0x04, 0x7e}},
+ {Key: PageUp, ASCIICode: []byte{0x1b, 0x5b, 0x05, 0x7e}},
+ {Key: PageDown, ASCIICode: []byte{0x1b, 0x5b, 0x06, 0x7e}},
+ {Key: Home, ASCIICode: []byte{0x1b, 0x5b, 0x07, 0x7e}},
+ {Key: End, ASCIICode: []byte{0x1b, 0x5b, 0x09, 0x7e}},
+ {Key: Tab, ASCIICode: []byte{0x9}},
+ {Key: BackTab, ASCIICode: []byte{0x1b, 0x5b, 0x5a}},
+ {Key: Insert, ASCIICode: []byte{0x1b, 0x5b, 0x02, 0x7e}},
+
+ {Key: F1, ASCIICode: []byte{0x1b, 0x4f, 0x50}},
+ {Key: F2, ASCIICode: []byte{0x1b, 0x4f, 0x51}},
+ {Key: F3, ASCIICode: []byte{0x1b, 0x4f, 0x52}},
+ {Key: F4, ASCIICode: []byte{0x1b, 0x4f, 0x53}},
+
+ {Key: F1, ASCIICode: []byte{0x1b, 0x4f, 0x50, 0x41}}, // Linux console
+ {Key: F2, ASCIICode: []byte{0x1b, 0x5b, 0x5b, 0x42}}, // Linux console
+ {Key: F3, ASCIICode: []byte{0x1b, 0x5b, 0x5b, 0x43}}, // Linux console
+ {Key: F4, ASCIICode: []byte{0x1b, 0x5b, 0x5b, 0x44}}, // Linux console
+ {Key: F5, ASCIICode: []byte{0x1b, 0x5b, 0x5b, 0x45}}, // Linux console
+
+ {Key: F1, ASCIICode: []byte{0x1b, 0x5b, 0x11, 0x7e}}, // rxvt-unicode
+ {Key: F2, ASCIICode: []byte{0x1b, 0x5b, 0x12, 0x7e}}, // rxvt-unicode
+ {Key: F3, ASCIICode: []byte{0x1b, 0x5b, 0x13, 0x7e}}, // rxvt-unicode
+ {Key: F4, ASCIICode: []byte{0x1b, 0x5b, 0x14, 0x7e}}, // rxvt-unicode
+
+ {Key: F5, ASCIICode: []byte{0x1b, 0x5b, 0x31, 0x35, 0x7e}},
+ {Key: F6, ASCIICode: []byte{0x1b, 0x5b, 0x31, 0x37, 0x7e}},
+ {Key: F7, ASCIICode: []byte{0x1b, 0x5b, 0x31, 0x38, 0x7e}},
+ {Key: F8, ASCIICode: []byte{0x1b, 0x5b, 0x31, 0x39, 0x7e}},
+ {Key: F9, ASCIICode: []byte{0x1b, 0x5b, 0x32, 0x30, 0x7e}},
+ {Key: F10, ASCIICode: []byte{0x1b, 0x5b, 0x32, 0x31, 0x7e}},
+ {Key: F11, ASCIICode: []byte{0x1b, 0x5b, 0x32, 0x32, 0x7e}},
+ {Key: F12, ASCIICode: []byte{0x1b, 0x5b, 0x32, 0x34, 0x7e, 0x8}},
+ {Key: F13, ASCIICode: []byte{0x1b, 0x5b, 0x25, 0x7e}},
+ {Key: F14, ASCIICode: []byte{0x1b, 0x5b, 0x26, 0x7e}},
+ {Key: F15, ASCIICode: []byte{0x1b, 0x5b, 0x28, 0x7e}},
+ {Key: F16, ASCIICode: []byte{0x1b, 0x5b, 0x29, 0x7e}},
+ {Key: F17, ASCIICode: []byte{0x1b, 0x5b, 0x31, 0x7e}},
+ {Key: F18, ASCIICode: []byte{0x1b, 0x5b, 0x32, 0x7e}},
+ {Key: F19, ASCIICode: []byte{0x1b, 0x5b, 0x33, 0x7e}},
+ {Key: F20, ASCIICode: []byte{0x1b, 0x5b, 0x34, 0x7e}},
+
+ // Xterm
+ {Key: F13, ASCIICode: []byte{0x1b, 0x5b, 0x01, 0x3b, 0x02, 0x50}},
+ {Key: F14, ASCIICode: []byte{0x1b, 0x5b, 0x01, 0x3b, 0x02, 0x51}},
+ // &ASCIICode{Key: F15, ASCIICode: []byte{0x1b, 0x5b, 0x01, 0x3b, 0x02, 0x52}}, // Conflicts with CPR response
+ {Key: F16, ASCIICode: []byte{0x1b, 0x5b, 0x01, 0x3b, 0x02, 0x52}},
+ {Key: F17, ASCIICode: []byte{0x1b, 0x5b, 0x15, 0x3b, 0x02, 0x7e}},
+ {Key: F18, ASCIICode: []byte{0x1b, 0x5b, 0x17, 0x3b, 0x02, 0x7e}},
+ {Key: F19, ASCIICode: []byte{0x1b, 0x5b, 0x18, 0x3b, 0x02, 0x7e}},
+ {Key: F20, ASCIICode: []byte{0x1b, 0x5b, 0x19, 0x3b, 0x02, 0x7e}},
+ {Key: F21, ASCIICode: []byte{0x1b, 0x5b, 0x20, 0x3b, 0x02, 0x7e}},
+ {Key: F22, ASCIICode: []byte{0x1b, 0x5b, 0x21, 0x3b, 0x02, 0x7e}},
+ {Key: F23, ASCIICode: []byte{0x1b, 0x5b, 0x23, 0x3b, 0x02, 0x7e}},
+ {Key: F24, ASCIICode: []byte{0x1b, 0x5b, 0x24, 0x3b, 0x02, 0x7e}},
+
+ {Key: ControlUp, ASCIICode: []byte{0x1b, 0x5b, 0x01, 0x3b, 0x5a}},
+ {Key: ControlDown, ASCIICode: []byte{0x1b, 0x5b, 0x01, 0x3b, 0x5b}},
+ {Key: ControlRight, ASCIICode: []byte{0x1b, 0x5b, 0x01, 0x3b, 0x5c}},
+ {Key: ControlLeft, ASCIICode: []byte{0x1b, 0x5b, 0x01, 0x3b, 0x5d}},
+
+ {Key: ShiftUp, ASCIICode: []byte{0x1b, 0x5b, 0x01, 0x2a}},
+ {Key: ShiftDown, ASCIICode: []byte{0x1b, 0x5b, 0x01, 0x2b}},
+ {Key: ShiftRight, ASCIICode: []byte{0x1b, 0x5b, 0x01, 0x2c}},
+ {Key: ShiftLeft, ASCIICode: []byte{0x1b, 0x5b, 0x01, 0x2d}},
+
+ // Tmux sends following keystrokes when control+arrow is pressed, but for
+ // Emacs ansi-term sends the same sequences for normal arrow keys. Consider
+ // it a normal arrow press, because that's more important.
+ {Key: Up, ASCIICode: []byte{0x1b, 0x4f, 0x41}},
+ {Key: Down, ASCIICode: []byte{0x1b, 0x4f, 0x42}},
+ {Key: Right, ASCIICode: []byte{0x1b, 0x4f, 0x43}},
+ {Key: Left, ASCIICode: []byte{0x1b, 0x4f, 0x44}},
+
+ {Key: ControlUp, ASCIICode: []byte{0x1b, 0x5b, 0x05, 0x41}},
+ {Key: ControlDown, ASCIICode: []byte{0x1b, 0x5b, 0x05, 0x42}},
+ {Key: ControlRight, ASCIICode: []byte{0x1b, 0x5b, 0x05, 0x43}},
+ {Key: ControlLeft, ASCIICode: []byte{0x1b, 0x5b, 0x05, 0x44}},
+
+ {Key: ControlRight, ASCIICode: []byte{0x1b, 0x5b, 0x4f, 0x63}}, // rxvt
+ {Key: ControlLeft, ASCIICode: []byte{0x1b, 0x5b, 0x4f, 0x64}}, // rxvt
+
+ {Key: Ignore, ASCIICode: []byte{0x1b, 0x5b, 0x45}}, // Xterm
+ {Key: Ignore, ASCIICode: []byte{0x1b, 0x5b, 0x46}}, // Linux console
+}
+
+// NewStandardInputParser returns ConsoleParser object to read from stdin.
+func NewStandardInputParser() *WindowsParser {
+ return &WindowsParser{}
+}
diff --git a/vendor/github.com/c-bata/go-prompt/windows_output.go b/vendor/github.com/c-bata/go-prompt/windows_output.go
new file mode 100644
index 0000000000..2281ab1563
--- /dev/null
+++ b/vendor/github.com/c-bata/go-prompt/windows_output.go
@@ -0,0 +1,333 @@
+// +build windows
+
+package prompt
+
+import (
+ "io"
+ "strconv"
+
+ "github.com/mattn/go-colorable"
+)
+
+// WindowsWriter is a ConsoleWriter implementation for Win32 console.
+// Output is converted from VT100 escape sequences by mattn/go-colorable.
+type WindowsWriter struct {
+ out io.Writer
+ buffer []byte
+}
+
+// WriteRaw to write raw byte array
+func (w *WindowsWriter) WriteRaw(data []byte) {
+ w.buffer = append(w.buffer, data...)
+ // Flush because sometimes the render is broken when a large amount data in buffer.
+ w.Flush()
+ return
+}
+
+// Write to write byte array without control sequences
+func (w *WindowsWriter) Write(data []byte) {
+ w.WriteRaw(byteFilter(data, writeFilter))
+ return
+}
+
+// WriteRawStr to write raw string
+func (w *WindowsWriter) WriteRawStr(data string) {
+ w.WriteRaw([]byte(data))
+ return
+}
+
+// WriteStr to write string without control sequences
+func (w *WindowsWriter) WriteStr(data string) {
+ w.Write([]byte(data))
+ return
+}
+
+// Flush to flush buffer
+func (w *WindowsWriter) Flush() error {
+ _, err := w.out.Write(w.buffer)
+ if err != nil {
+ return err
+ }
+ w.buffer = []byte{}
+ return nil
+}
+
+/* Erase */
+
+// EraseScreen erases the screen with the background colour and moves the cursor to home.
+func (w *WindowsWriter) EraseScreen() {
+ w.WriteRaw([]byte{0x1b, 0x5b, 0x32, 0x4a})
+ return
+}
+
+// EraseUp erases the screen from the current line up to the top of the screen.
+func (w *WindowsWriter) EraseUp() {
+ w.WriteRaw([]byte{0x1b, 0x5b, 0x31, 0x4a})
+ return
+}
+
+// EraseDown erases the screen from the current line down to the bottom of the screen.
+func (w *WindowsWriter) EraseDown() {
+ w.WriteRaw([]byte{0x1b, 0x5b, 0x4a})
+ return
+}
+
+// EraseStartOfLine erases from the current cursor position to the start of the current line.
+func (w *WindowsWriter) EraseStartOfLine() {
+ w.WriteRaw([]byte{0x1b, 0x5b, 0x31, 0x4b})
+ return
+}
+
+// EraseEndOfLine erases from the current cursor position to the end of the current line.
+func (w *WindowsWriter) EraseEndOfLine() {
+ w.WriteRaw([]byte{0x1b, 0x5b, 0x4b})
+ return
+}
+
+// EraseLine erases the entire current line.
+func (w *WindowsWriter) EraseLine() {
+ w.WriteRaw([]byte{0x1b, 0x5b, 0x32, 0x4b})
+ return
+}
+
+/* Cursor */
+
+// ShowCursor stops blinking cursor and show.
+func (w *WindowsWriter) ShowCursor() {
+ w.WriteRaw([]byte{0x1b, 0x5b, 0x3f, 0x31, 0x32, 0x6c, 0x1b, 0x5b, 0x3f, 0x32, 0x35, 0x68})
+}
+
+// HideCursor hides cursor.
+func (w *WindowsWriter) HideCursor() {
+ w.WriteRaw([]byte{0x1b, 0x5b, 0x3f, 0x32, 0x35, 0x6c})
+ return
+}
+
+// CursorGoTo sets the cursor position where subsequent text will begin.
+func (w *WindowsWriter) CursorGoTo(row, col int) {
+ if row == 0 && col == 0 {
+ // If no row/column parameters are provided (ie. [H), the cursor will move to the home position.
+ w.WriteRaw([]byte{0x1b, 0x5b, 0x3b, 0x48})
+ return
+ }
+ r := strconv.Itoa(row)
+ c := strconv.Itoa(col)
+ w.WriteRaw([]byte{0x1b, 0x5b})
+ w.WriteRaw([]byte(r))
+ w.WriteRaw([]byte{0x3b})
+ w.WriteRaw([]byte(c))
+ w.WriteRaw([]byte{0x48})
+ return
+}
+
+// CursorUp moves the cursor up by 'n' rows; the default count is 1.
+func (w *WindowsWriter) CursorUp(n int) {
+ if n < 0 {
+ w.CursorDown(n)
+ return
+ }
+ s := strconv.Itoa(n)
+ w.WriteRaw([]byte{0x1b, 0x5b})
+ w.WriteRaw([]byte(s))
+ w.WriteRaw([]byte{0x41})
+ return
+}
+
+// CursorDown moves the cursor down by 'n' rows; the default count is 1.
+func (w *WindowsWriter) CursorDown(n int) {
+ if n < 0 {
+ w.CursorUp(n)
+ return
+ }
+ s := strconv.Itoa(n)
+ w.WriteRaw([]byte{0x1b, 0x5b})
+ w.WriteRaw([]byte(s))
+ w.WriteRaw([]byte{0x42})
+ return
+}
+
+// CursorForward moves the cursor forward by 'n' columns; the default count is 1.
+func (w *WindowsWriter) CursorForward(n int) {
+ if n == 0 {
+ return
+ } else if n < 0 {
+ w.CursorBackward(-n)
+ return
+ }
+ s := strconv.Itoa(n)
+ w.WriteRaw([]byte{0x1b, 0x5b})
+ w.WriteRaw([]byte(s))
+ w.WriteRaw([]byte{0x43})
+ return
+}
+
+// CursorBackward moves the cursor backward by 'n' columns; the default count is 1.
+func (w *WindowsWriter) CursorBackward(n int) {
+ if n == 0 {
+ return
+ } else if n < 0 {
+ w.CursorForward(-n)
+ return
+ }
+ s := strconv.Itoa(n)
+ w.WriteRaw([]byte{0x1b, 0x5b})
+ w.WriteRaw([]byte(s))
+ w.WriteRaw([]byte{0x44})
+ return
+}
+
+// AskForCPR asks for a cursor position report (CPR).
+func (w *WindowsWriter) AskForCPR() {
+ // CPR: Cursor Position Request.
+ w.WriteRaw([]byte{0x1b, 0x5b, 0x36, 0x6e})
+ w.Flush()
+ return
+}
+
+// SaveCursor saves current cursor position.
+func (w *WindowsWriter) SaveCursor() {
+ w.WriteRaw([]byte{0x1b, 0x5b, 0x73})
+ return
+}
+
+// UnSaveCursor restores cursor position after a Save Cursor.
+func (w *WindowsWriter) UnSaveCursor() {
+ w.WriteRaw([]byte{0x1b, 0x5b, 0x75})
+ return
+}
+
+/* Scrolling */
+
+// ScrollDown scrolls display down one line.
+func (w *WindowsWriter) ScrollDown() {
+ w.WriteRaw([]byte{0x1b, 0x44})
+ return
+}
+
+// ScrollUp scroll display up one line.
+func (w *WindowsWriter) ScrollUp() {
+ w.WriteRaw([]byte{0x1b, 0x4d})
+ return
+}
+
+/* Title */
+
+// SetTitle sets a title of terminal window.
+func (w *WindowsWriter) SetTitle(title string) {
+ w.WriteRaw([]byte{0x1b, 0x5d, 0x32, 0x3b})
+ w.WriteRaw(byteFilter([]byte(title), setTextFilter))
+ w.WriteRaw([]byte{0x07})
+ return
+}
+
+// ClearTitle clears a title of terminal window.
+func (w *WindowsWriter) ClearTitle() {
+ w.WriteRaw([]byte{0x1b, 0x5d, 0x32, 0x3b, 0x07})
+ return
+}
+
+/* Font */
+
+// SetColor sets text and background colors. and specify whether text is bold.
+func (w *WindowsWriter) SetColor(fg, bg Color, bold bool) {
+ f, ok := foregroundANSIColors[fg]
+ if !ok {
+ f, _ = foregroundANSIColors[DefaultColor]
+ }
+ b, ok := backgroundANSIColors[bg]
+ if !ok {
+ b, _ = backgroundANSIColors[DefaultColor]
+ }
+ w.out.Write([]byte{0x1b, 0x5b, 0x33, 0x39, 0x3b, 0x34, 0x39, 0x6d})
+ w.WriteRaw([]byte{0x1b, 0x5b})
+ if !bold {
+ w.WriteRaw([]byte{0x30, 0x3b})
+ }
+ w.WriteRaw(f)
+ w.WriteRaw([]byte{0x3b})
+ w.WriteRaw(b)
+ if bold {
+ w.WriteRaw([]byte{0x3b, 0x31})
+ }
+ w.WriteRaw([]byte{0x6d})
+ return
+}
+
+var foregroundANSIColors = map[Color][]byte{
+ DefaultColor: {0x33, 0x39}, // 39
+
+ // Low intensity.
+ Black: {0x33, 0x30}, // 30
+ DarkRed: {0x33, 0x31}, // 31
+ DarkGreen: {0x33, 0x32}, // 32
+ Brown: {0x33, 0x33}, // 33
+ DarkBlue: {0x33, 0x34}, // 34
+ Purple: {0x33, 0x35}, // 35
+ Cyan: {0x33, 0x36}, //36
+ LightGray: {0x33, 0x37}, //37
+
+ // High intensity.
+ DarkGray: {0x39, 0x30}, // 90
+ Red: {0x39, 0x31}, // 91
+ Green: {0x39, 0x32}, // 92
+ Yellow: {0x39, 0x33}, // 93
+ Blue: {0x39, 0x34}, // 94
+ Fuchsia: {0x39, 0x35}, // 95
+ Turquoise: {0x39, 0x36}, // 96
+ White: {0x39, 0x37}, // 97
+}
+
+var backgroundANSIColors = map[Color][]byte{
+ DefaultColor: {0x34, 0x39}, // 49
+
+ // Low intensity.
+ Black: {0x34, 0x30}, // 40
+ DarkRed: {0x34, 0x31}, // 41
+ DarkGreen: {0x34, 0x32}, // 42
+ Brown: {0x34, 0x33}, // 43
+ DarkBlue: {0x34, 0x34}, // 44
+ Purple: {0x34, 0x35}, // 45
+ Cyan: {0x34, 0x36}, // 46
+ LightGray: {0x34, 0x37}, // 47
+
+ // High intensity
+ DarkGray: {0x31, 0x30, 0x30}, // 100
+ Red: {0x31, 0x30, 0x31}, // 101
+ Green: {0x31, 0x30, 0x32}, // 102
+ Yellow: {0x31, 0x30, 0x33}, // 103
+ Blue: {0x31, 0x30, 0x34}, // 104
+ Fuchsia: {0x31, 0x30, 0x35}, // 105
+ Turquoise: {0x31, 0x30, 0x36}, // 106
+ White: {0x31, 0x30, 0x37}, // 107
+}
+
+func writeFilter(buf byte) bool {
+ return buf != 0x1b && buf != 0x3f
+}
+
+func setTextFilter(buf byte) bool {
+ return buf != 0x1b && buf != 0x07
+}
+
+func byteFilter(buf []byte, fn ...func(b byte) bool) []byte {
+ if len(fn) == 0 {
+ return buf
+ }
+ ret := make([]byte, 0, len(buf))
+ f := fn[0]
+ for i, n := range buf {
+ if f(n) {
+ ret = append(ret, buf[i])
+ }
+ }
+ return byteFilter(ret, fn[1:]...)
+}
+
+var _ ConsoleWriter = &WindowsWriter{}
+
+// NewStandardOutputWriter returns ConsoleWriter object to write to stdout.
+func NewStandardOutputWriter() *WindowsWriter {
+ return &WindowsWriter{
+ out: colorable.NewColorableStdout(),
+ }
+}
diff --git a/vendor/github.com/coredns/coredns/core/dnsserver/zdirectives.go b/vendor/github.com/coredns/coredns/core/dnsserver/zdirectives.go
index e2eed21171..280c031444 100644
--- a/vendor/github.com/coredns/coredns/core/dnsserver/zdirectives.go
+++ b/vendor/github.com/coredns/coredns/core/dnsserver/zdirectives.go
@@ -39,6 +39,7 @@ var Directives = []string{
"auto",
"secondary",
"etcd",
+ "loop",
"forward",
"proxy",
"erratic",
diff --git a/vendor/github.com/coredns/coredns/coremain/run.go b/vendor/github.com/coredns/coredns/coremain/run.go
index 98eaa5ba86..033f600773 100644
--- a/vendor/github.com/coredns/coredns/coremain/run.go
+++ b/vendor/github.com/coredns/coredns/coremain/run.go
@@ -42,7 +42,7 @@ func Run() {
caddy.TrapSignals()
// Reset flag.CommandLine to get rid of unwanted flags for instance from glog (used in kubernetes).
- // And readd the once we want to keep.
+ // And read the ones we want to keep.
flag.VisitAll(func(f *flag.Flag) {
if _, ok := flagsBlacklist[f.Name]; ok {
return
diff --git a/vendor/github.com/coredns/coredns/coremain/version.go b/vendor/github.com/coredns/coredns/coremain/version.go
index 7e73e5adb7..edddf9608e 100644
--- a/vendor/github.com/coredns/coredns/coremain/version.go
+++ b/vendor/github.com/coredns/coredns/coremain/version.go
@@ -2,7 +2,7 @@ package coremain
// Various CoreDNS constants.
const (
- CoreVersion = "1.2.0"
+ CoreVersion = "1.2.2"
coreName = "CoreDNS"
serverType = "dns"
)
diff --git a/vendor/github.com/coredns/coredns/plugin/backend_lookup.go b/vendor/github.com/coredns/coredns/plugin/backend_lookup.go
index 3946c9fee5..65cdcbaf57 100644
--- a/vendor/github.com/coredns/coredns/plugin/backend_lookup.go
+++ b/vendor/github.com/coredns/coredns/plugin/backend_lookup.go
@@ -40,24 +40,22 @@ func A(b ServiceBackend, zone string, state request.Request, previousRecords []d
if dnsutil.DuplicateCNAME(newRecord, previousRecords) {
continue
}
+ if dns.IsSubDomain(zone, dns.Fqdn(serv.Host)) {
+ state1 := state.NewWithQuestion(serv.Host, state.QType())
+ state1.Zone = zone
+ nextRecords, err := A(b, zone, state1, append(previousRecords, newRecord), opt)
- state1 := state.NewWithQuestion(serv.Host, state.QType())
- nextRecords, err := A(b, zone, state1, append(previousRecords, newRecord), opt)
-
- if err == nil {
- // Not only have we found something we should add the CNAME and the IP addresses.
- if len(nextRecords) > 0 {
- records = append(records, newRecord)
- records = append(records, nextRecords...)
+ if err == nil {
+ // Not only have we found something we should add the CNAME and the IP addresses.
+ if len(nextRecords) > 0 {
+ records = append(records, newRecord)
+ records = append(records, nextRecords...)
+ }
}
continue
}
// This means we can not complete the CNAME, try to look else where.
target := newRecord.Target
- if dns.IsSubDomain(zone, target) {
- // We should already have found it
- continue
- }
// Lookup
m1, e1 := b.Lookup(state, target, state.QType())
if e1 != nil {
@@ -110,19 +108,20 @@ func AAAA(b ServiceBackend, zone string, state request.Request, previousRecords
if dnsutil.DuplicateCNAME(newRecord, previousRecords) {
continue
}
+ if dns.IsSubDomain(zone, dns.Fqdn(serv.Host)) {
+ state1 := state.NewWithQuestion(serv.Host, state.QType())
+ state1.Zone = zone
+ nextRecords, err := AAAA(b, zone, state1, append(previousRecords, newRecord), opt)
- state1 := state.NewWithQuestion(serv.Host, state.QType())
- nextRecords, err := AAAA(b, zone, state1, append(previousRecords, newRecord), opt)
-
- if err == nil {
- // Not only have we found something we should add the CNAME and the IP addresses.
- if len(nextRecords) > 0 {
- records = append(records, newRecord)
- records = append(records, nextRecords...)
+ if err == nil {
+ // Not only have we found something we should add the CNAME and the IP addresses.
+ if len(nextRecords) > 0 {
+ records = append(records, newRecord)
+ records = append(records, nextRecords...)
+ }
}
continue
}
-
// This means we can not complete the CNAME, try to look else where.
target := newRecord.Target
m1, e1 := b.Lookup(state, target, state.QType())
@@ -173,6 +172,11 @@ func SRV(b ServiceBackend, zone string, state request.Request, opt Options) (rec
w[serv.Priority] += weight
}
for _, serv := range services {
+ // Don't add the entry if the port is -1 (invalid). The kubernetes plugin uses port -1 when a service/endpoint
+ // does not have any declared ports.
+ if serv.Port == -1 {
+ continue
+ }
w1 := 100.0 / float64(w[serv.Priority])
if serv.Weight == 0 {
w1 *= 100
diff --git a/vendor/github.com/coredns/coredns/plugin/cache/README.md b/vendor/github.com/coredns/coredns/plugin/cache/README.md
index e48152682b..fa790185e4 100644
--- a/vendor/github.com/coredns/coredns/plugin/cache/README.md
+++ b/vendor/github.com/coredns/coredns/plugin/cache/README.md
@@ -52,11 +52,12 @@ cache [TTL] [ZONES...] {
## Capacity and Eviction
-When specifying **CAPACITY**, the minimum cache capacity is 131,072. Specifying a lower value will be
-ignored. Specifying a **CAPACITY** of zero does not disable the cache.
-
-Eviction is done per shard - i.e. when a shard reaches capacity, items are evicted from that shard. Since shards don't fill up perfectly evenly, evictions will occur before the entire cache reaches full capacity. Each shard capacity is equal to the total cache size / number of shards (256).
+If **CAPACITY** is not specified, the default cache size is 10,000 per cache. The minimum allowed cache size is 1024.
+Eviction is done per shard. In effect, when a shard reaches capacity, items are evicted from that shard.
+Since shards don't fill up perfectly evenly, evictions will occur before the entire cache reaches full capacity.
+Each shard capacity is equal to the total cache size / number of shards (256). Eviction is random, not TTL based.
+Entries with 0 TTL will remain in the cache until randomly evicted when the shard reaches capacity.
## Metrics
@@ -89,3 +90,13 @@ Proxy to Google Public DNS and only cache responses for example.org (or below).
cache example.org
}
~~~
+
+Enable caching for all zones, keep a positive cache size of 5000 and a negative cache size of 2500:
+ ~~~ corefile
+ . {
+ cache {
+ success 5000
+ denial 2500
+ }
+ }
+ ~~~
\ No newline at end of file
diff --git a/vendor/github.com/coredns/coredns/plugin/dnstap/handler.go b/vendor/github.com/coredns/coredns/plugin/dnstap/handler.go
index 1c411e2aaa..b09c704066 100644
--- a/vendor/github.com/coredns/coredns/plugin/dnstap/handler.go
+++ b/vendor/github.com/coredns/coredns/plugin/dnstap/handler.go
@@ -51,7 +51,7 @@ func TapperFromContext(ctx context.Context) (t Tapper) {
}
// TapMessage implements Tapper.
-func (h *Dnstap) TapMessage(m *tap.Message) {
+func (h Dnstap) TapMessage(m *tap.Message) {
t := tap.Dnstap_MESSAGE
h.IO.Dnstap(tap.Dnstap{
Type: &t,
diff --git a/vendor/github.com/coredns/coredns/plugin/etcd/msg/service.go b/vendor/github.com/coredns/coredns/plugin/etcd/msg/service.go
index 68ffc544bd..987fb14c7d 100644
--- a/vendor/github.com/coredns/coredns/plugin/etcd/msg/service.go
+++ b/vendor/github.com/coredns/coredns/plugin/etcd/msg/service.go
@@ -164,7 +164,7 @@ func targetStrip(name string, targetStrip int) string {
offset, end = dns.NextLabel(name, offset)
}
if end {
- // We overshot the name, use the orignal one.
+ // We overshot the name, use the original one.
offset = 0
}
name = name[offset:]
diff --git a/vendor/github.com/coredns/coredns/plugin/file/secondary.go b/vendor/github.com/coredns/coredns/plugin/file/secondary.go
index 39f79f2b13..049fe0cda2 100644
--- a/vendor/github.com/coredns/coredns/plugin/file/secondary.go
+++ b/vendor/github.com/coredns/coredns/plugin/file/secondary.go
@@ -103,7 +103,7 @@ func less(a, b uint32) bool {
// Update updates the secondary zone according to its SOA. It will run for the life time of the server
// and uses the SOA parameters. Every refresh it will check for a new SOA number. If that fails (for all
-// server) it wil retry every retry interval. If the zone failed to transfer before the expire, the zone
+// server) it will retry every retry interval. If the zone failed to transfer before the expire, the zone
// will be marked expired.
func (z *Zone) Update() error {
// If we don't have a SOA, we don't have a zone, wait for it to appear.
diff --git a/vendor/github.com/coredns/coredns/plugin/file/setup.go b/vendor/github.com/coredns/coredns/plugin/file/setup.go
index 3f8d1969b8..457ea53485 100644
--- a/vendor/github.com/coredns/coredns/plugin/file/setup.go
+++ b/vendor/github.com/coredns/coredns/plugin/file/setup.go
@@ -53,7 +53,6 @@ func setup(c *caddy.Controller) error {
func fileParse(c *caddy.Controller) (Zones, error) {
z := make(map[string]*Zone)
names := []string{}
- origins := []string{}
config := dnsserver.GetConfig(c)
@@ -64,7 +63,7 @@ func fileParse(c *caddy.Controller) (Zones, error) {
}
fileName := c.Val()
- origins = make([]string, len(c.ServerBlockKeys))
+ origins := make([]string, len(c.ServerBlockKeys))
copy(origins, c.ServerBlockKeys)
args := c.RemainingArgs()
if len(args) > 0 {
diff --git a/vendor/github.com/coredns/coredns/plugin/file/xfr.go b/vendor/github.com/coredns/coredns/plugin/file/xfr.go
index 3ad380902a..18b6bb1176 100644
--- a/vendor/github.com/coredns/coredns/plugin/file/xfr.go
+++ b/vendor/github.com/coredns/coredns/plugin/file/xfr.go
@@ -55,7 +55,7 @@ func (x Xfr) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (in
return dns.RcodeSuccess, nil
}
-// Name implements the plugin.Hander interface.
+// Name implements the plugin.Handler interface.
func (x Xfr) Name() string { return "xfr" }
const transferLength = 1000 // Start a new envelop after message reaches this size in bytes. Intentionally small to test multi envelope parsing.
diff --git a/vendor/github.com/coredns/coredns/plugin/file/zone.go b/vendor/github.com/coredns/coredns/plugin/file/zone.go
index 6e1ec6d698..5aa72175f4 100644
--- a/vendor/github.com/coredns/coredns/plugin/file/zone.go
+++ b/vendor/github.com/coredns/coredns/plugin/file/zone.go
@@ -203,7 +203,7 @@ func (z *Zone) nameFromRight(qname string, i int) (string, bool) {
}
k := 0
- shot := false
+ var shot bool
for j := 1; j <= i; j++ {
k, shot = dns.PrevLabel(qname, j+z.origLen)
if shot {
diff --git a/vendor/github.com/coredns/coredns/plugin/forward/connect.go b/vendor/github.com/coredns/coredns/plugin/forward/connect.go
index 439caf9328..6102bbe158 100644
--- a/vendor/github.com/coredns/coredns/plugin/forward/connect.go
+++ b/vendor/github.com/coredns/coredns/plugin/forward/connect.go
@@ -1,6 +1,6 @@
// Package forward implements a forwarding proxy. It caches an upstream net.Conn for some time, so if the same
// client returns the upstream's Conn will be precached. Depending on how you benchmark this looks to be
-// 50% faster than just openening a new connection for every client. It works with UDP and TCP and uses
+// 50% faster than just opening a new connection for every client. It works with UDP and TCP and uses
// inband healthchecking.
package forward
diff --git a/vendor/github.com/coredns/coredns/plugin/forward/forward.go b/vendor/github.com/coredns/coredns/plugin/forward/forward.go
index 6eb2e0084e..8e64831f4d 100644
--- a/vendor/github.com/coredns/coredns/plugin/forward/forward.go
+++ b/vendor/github.com/coredns/coredns/plugin/forward/forward.go
@@ -1,6 +1,6 @@
// Package forward implements a forwarding proxy. It caches an upstream net.Conn for some time, so if the same
// client returns the upstream's Conn will be precached. Depending on how you benchmark this looks to be
-// 50% faster than just openening a new connection for every client. It works with UDP and TCP and uses
+// 50% faster than just opening a new connection for every client. It works with UDP and TCP and uses
// inband healthchecking.
package forward
diff --git a/vendor/github.com/coredns/coredns/plugin/forward/lookup.go b/vendor/github.com/coredns/coredns/plugin/forward/lookup.go
index 94114647c3..cba24f85f0 100644
--- a/vendor/github.com/coredns/coredns/plugin/forward/lookup.go
+++ b/vendor/github.com/coredns/coredns/plugin/forward/lookup.go
@@ -1,6 +1,6 @@
// Package forward implements a forwarding proxy. It caches an upstream net.Conn for some time, so if the same
// client returns the upstream's Conn will be precached. Depending on how you benchmark this looks to be
-// 50% faster than just openening a new connection for every client. It works with UDP and TCP and uses
+// 50% faster than just opening a new connection for every client. It works with UDP and TCP and uses
// inband healthchecking.
package forward
diff --git a/vendor/github.com/coredns/coredns/plugin/forward/setup.go b/vendor/github.com/coredns/coredns/plugin/forward/setup.go
index ee48fdaf6c..9fe8a6c388 100644
--- a/vendor/github.com/coredns/coredns/plugin/forward/setup.go
+++ b/vendor/github.com/coredns/coredns/plugin/forward/setup.go
@@ -13,6 +13,7 @@ import (
pkgtls "github.com/coredns/coredns/plugin/pkg/tls"
"github.com/mholt/caddy"
+ "github.com/mholt/caddy/caddyfile"
)
func init() {
@@ -70,69 +71,81 @@ func (f *Forward) OnShutdown() error {
func (f *Forward) Close() { f.OnShutdown() }
func parseForward(c *caddy.Controller) (*Forward, error) {
- f := New()
-
- protocols := map[int]int{}
-
- i := 0
+ var (
+ f *Forward
+ err error
+ i int
+ )
for c.Next() {
if i > 0 {
return nil, plugin.ErrOnce
}
i++
-
- if !c.Args(&f.from) {
- return f, c.ArgErr()
- }
- f.from = plugin.Host(f.from).Normalize()
-
- to := c.RemainingArgs()
- if len(to) == 0 {
- return f, c.ArgErr()
- }
-
- // A bit fiddly, but first check if we've got protocols and if so add them back in when we create the proxies.
- protocols = make(map[int]int)
- for i := range to {
- protocols[i], to[i] = protocol(to[i])
- }
-
- // If parseHostPortOrFile expands a file with a lot of nameserver our accounting in protocols doesn't make
- // any sense anymore... For now: lets don't care.
- toHosts, err := dnsutil.ParseHostPortOrFile(to...)
+ f, err = ParseForwardStanza(&c.Dispenser)
if err != nil {
+ return nil, err
+ }
+ }
+ return f, nil
+}
+
+// ParseForwardStanza parses one forward stanza
+func ParseForwardStanza(c *caddyfile.Dispenser) (*Forward, error) {
+ f := New()
+
+ protocols := map[int]int{}
+
+ if !c.Args(&f.from) {
+ return f, c.ArgErr()
+ }
+ f.from = plugin.Host(f.from).Normalize()
+
+ to := c.RemainingArgs()
+ if len(to) == 0 {
+ return f, c.ArgErr()
+ }
+
+ // A bit fiddly, but first check if we've got protocols and if so add them back in when we create the proxies.
+ protocols = make(map[int]int)
+ for i := range to {
+ protocols[i], to[i] = protocol(to[i])
+ }
+
+ // If parseHostPortOrFile expands a file with a lot of nameserver our accounting in protocols doesn't make
+ // any sense anymore... For now: lets don't care.
+ toHosts, err := dnsutil.ParseHostPortOrFile(to...)
+ if err != nil {
+ return f, err
+ }
+
+ for i, h := range toHosts {
+ // Double check the port, if e.g. is 53 and the transport is TLS make it 853.
+ // This can be somewhat annoying because you *can't* have TLS on port 53 then.
+ switch protocols[i] {
+ case TLS:
+ h1, p, err := net.SplitHostPort(h)
+ if err != nil {
+ break
+ }
+
+ // This is more of a bug in dnsutil.ParseHostPortOrFile that defaults to
+ // 53 because it doesn't know about the tls:// // and friends (that should be fixed). Hence
+ // Fix the port number here, back to what the user intended.
+ if p == "53" {
+ h = net.JoinHostPort(h1, "853")
+ }
+ }
+
+ // We can't set tlsConfig here, because we haven't parsed it yet.
+ // We set it below at the end of parseBlock, use nil now.
+ p := NewProxy(h, protocols[i])
+ f.proxies = append(f.proxies, p)
+ }
+
+ for c.NextBlock() {
+ if err := parseBlock(c, f); err != nil {
return f, err
}
-
- for i, h := range toHosts {
- // Double check the port, if e.g. is 53 and the transport is TLS make it 853.
- // This can be somewhat annoying because you *can't* have TLS on port 53 then.
- switch protocols[i] {
- case TLS:
- h1, p, err := net.SplitHostPort(h)
- if err != nil {
- break
- }
-
- // This is more of a bug in dnsutil.ParseHostPortOrFile that defaults to
- // 53 because it doesn't know about the tls:// // and friends (that should be fixed). Hence
- // Fix the port number here, back to what the user intended.
- if p == "53" {
- h = net.JoinHostPort(h1, "853")
- }
- }
-
- // We can't set tlsConfig here, because we haven't parsed it yet.
- // We set it below at the end of parseBlock, use nil now.
- p := NewProxy(h, protocols[i])
- f.proxies = append(f.proxies, p)
- }
-
- for c.NextBlock() {
- if err := parseBlock(c, f); err != nil {
- return f, err
- }
- }
}
if f.tlsServerName != "" {
@@ -148,7 +161,7 @@ func parseForward(c *caddy.Controller) (*Forward, error) {
return f, nil
}
-func parseBlock(c *caddy.Controller, f *Forward) error {
+func parseBlock(c *caddyfile.Dispenser, f *Forward) error {
switch c.Val() {
case "except":
ignore := c.RemainingArgs()
diff --git a/vendor/github.com/coredns/coredns/plugin/forward/truncated.go b/vendor/github.com/coredns/coredns/plugin/forward/truncated.go
index f9bd464d1d..fb821d3351 100644
--- a/vendor/github.com/coredns/coredns/plugin/forward/truncated.go
+++ b/vendor/github.com/coredns/coredns/plugin/forward/truncated.go
@@ -6,7 +6,7 @@ import (
"github.com/miekg/dns"
)
-// truncated looks at the error and if truncated return a nil errror
+// truncated looks at the error and if truncated return a nil error
// and a possible reconstructed dns message if that was nil.
func truncated(state request.Request, ret *dns.Msg, err error) (*dns.Msg, error) {
// If you query for instance ANY isc.org; you get a truncated query back which miekg/dns fails to unpack
diff --git a/vendor/github.com/coredns/coredns/plugin/hosts/hostsfile.go b/vendor/github.com/coredns/coredns/plugin/hosts/hostsfile.go
index 4b912b17c0..af5e054fdc 100644
--- a/vendor/github.com/coredns/coredns/plugin/hosts/hostsfile.go
+++ b/vendor/github.com/coredns/coredns/plugin/hosts/hostsfile.go
@@ -54,11 +54,27 @@ func newHostsMap() *hostsMap {
}
}
+// Len returns the total number of addresses in the hostmap, this includes
+// V4/V6 and any reverse addresses.
+func (h *hostsMap) Len() int {
+ l := 0
+ for _, v4 := range h.byNameV4 {
+ l += len(v4)
+ }
+ for _, v6 := range h.byNameV6 {
+ l += len(v6)
+ }
+ for _, a := range h.byAddr {
+ l += len(a)
+ }
+ return l
+}
+
// Hostsfile contains known host entries.
type Hostsfile struct {
sync.RWMutex
- // list of zones we are authoritive for
+ // list of zones we are authoritative for
Origins []string
// hosts maps for lookups
@@ -111,6 +127,8 @@ func (h *Hostsfile) initInline(inline []string) {
func (h *Hostsfile) parseReader(r io.Reader) {
h.hmap = h.parse(r, h.inline)
+
+ log.Debugf("Parsed hosts file into %d entries", h.hmap.Len())
}
// Parse reads the hostsfile and populates the byName and byAddr maps.
diff --git a/vendor/github.com/coredns/coredns/plugin/metrics/README.md b/vendor/github.com/coredns/coredns/plugin/metrics/README.md
index c8c2983998..b3fbc111f3 100644
--- a/vendor/github.com/coredns/coredns/plugin/metrics/README.md
+++ b/vendor/github.com/coredns/coredns/plugin/metrics/README.md
@@ -60,7 +60,7 @@ Use an alternative address:
}
~~~
-Or via an enviroment variable (this is supported throughout the Corefile): `export PORT=9253`, and
+Or via an environment variable (this is supported throughout the Corefile): `export PORT=9253`, and
then:
~~~ corefile
diff --git a/vendor/github.com/coredns/coredns/plugin/metrics/metrics.go b/vendor/github.com/coredns/coredns/plugin/metrics/metrics.go
index af4afc6ac7..8efeff1e76 100644
--- a/vendor/github.com/coredns/coredns/plugin/metrics/metrics.go
+++ b/vendor/github.com/coredns/coredns/plugin/metrics/metrics.go
@@ -2,10 +2,12 @@
package metrics
import (
+ "context"
"net"
"net/http"
"os"
"sync"
+ "time"
"github.com/coredns/coredns/plugin"
"github.com/coredns/coredns/plugin/metrics/vars"
@@ -22,6 +24,7 @@ type Metrics struct {
ln net.Listener
lnSetup bool
mux *http.ServeMux
+ srv *http.Server
zoneNames []string
zoneMap map[string]bool
@@ -94,9 +97,9 @@ func (m *Metrics) OnStartup() error {
m.mux = http.NewServeMux()
m.mux.Handle("/metrics", promhttp.HandlerFor(m.Reg, promhttp.HandlerOpts{}))
-
+ m.srv = &http.Server{Handler: m.mux}
go func() {
- http.Serve(m.ln, m.mux)
+ m.srv.Serve(m.ln)
}()
return nil
}
@@ -106,24 +109,28 @@ func (m *Metrics) OnRestart() error {
if !m.lnSetup {
return nil
}
+ uniqAddr.Unset(m.Addr)
+ return m.stopServer()
+}
- uniqAddr.SetTodo(m.Addr)
-
- m.ln.Close()
+func (m *Metrics) stopServer() error {
+ if !m.lnSetup {
+ return nil
+ }
+ ctx, cancel := context.WithTimeout(context.Background(), shutdownTimeout)
+ defer cancel()
+ if err := m.srv.Shutdown(ctx); err != nil {
+ log.Infof("Failed to stop prometheus http server: %s", err)
+ return err
+ }
m.lnSetup = false
+ m.ln.Close()
return nil
}
// OnFinalShutdown tears down the metrics listener on shutdown and restart.
func (m *Metrics) OnFinalShutdown() error {
- // We allow prometheus statements in multiple Server Blocks, but only the first
- // will open the listener, for the rest they are all nil; guard against that.
- if !m.lnSetup {
- return nil
- }
-
- m.lnSetup = false
- return m.ln.Close()
+ return m.stopServer()
}
func keys(m map[string]bool) []string {
@@ -138,6 +145,10 @@ func keys(m map[string]bool) []string {
// we listen on "localhost:0" and need to retrieve the actual address.
var ListenAddr string
+// shutdownTimeout is the maximum amount of time the metrics plugin will wait
+// before erroring when it tries to close the metrics server
+const shutdownTimeout time.Duration = time.Second * 5
+
var buildInfo = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: plugin.Namespace,
Name: "build_info",
diff --git a/vendor/github.com/coredns/coredns/plugin/metrics/vars/report.go b/vendor/github.com/coredns/coredns/plugin/metrics/vars/report.go
index 8b619a5f94..d0c64b8647 100644
--- a/vendor/github.com/coredns/coredns/plugin/metrics/vars/report.go
+++ b/vendor/github.com/coredns/coredns/plugin/metrics/vars/report.go
@@ -10,7 +10,7 @@ import (
"github.com/miekg/dns"
)
-// Report reports the metrics data associcated with request.
+// Report reports the metrics data associated with request.
func Report(ctx context.Context, req request.Request, zone, rcode string, size int, start time.Time) {
// Proto and Family.
net := req.Proto()
diff --git a/vendor/github.com/coredns/coredns/plugin/normalize.go b/vendor/github.com/coredns/coredns/plugin/normalize.go
index fbbe5c8263..e44e55385a 100644
--- a/vendor/github.com/coredns/coredns/plugin/normalize.go
+++ b/vendor/github.com/coredns/coredns/plugin/normalize.go
@@ -125,7 +125,8 @@ func SplitHostPort(s string) (host, port string, ipnet *net.IPNet, err error) {
// Get the first lower octet boundary to see what encompassing zone we should be authoritative for.
mod := (bits - ones) % sizeDigit
nearest := (bits - ones) + mod
- offset, end := 0, false
+ offset := 0
+ var end bool
for i := 0; i < nearest/sizeDigit; i++ {
offset, end = dns.NextLabel(rev, offset)
if end {
diff --git a/vendor/github.com/coredns/coredns/plugin/pkg/cache/cache.go b/vendor/github.com/coredns/coredns/plugin/pkg/cache/cache.go
index 25faf93ea6..954befa767 100644
--- a/vendor/github.com/coredns/coredns/plugin/pkg/cache/cache.go
+++ b/vendor/github.com/coredns/coredns/plugin/pkg/cache/cache.go
@@ -31,8 +31,8 @@ type shard struct {
// New returns a new cache.
func New(size int) *Cache {
ssize := size / shardSize
- if ssize < 512 {
- ssize = 512
+ if ssize < 4 {
+ ssize = 4
}
c := &Cache{}
diff --git a/vendor/github.com/coredns/coredns/plugin/pkg/doh/doh.go b/vendor/github.com/coredns/coredns/plugin/pkg/doh/doh.go
index e0a398e9c7..812b89b1e2 100644
--- a/vendor/github.com/coredns/coredns/plugin/pkg/doh/doh.go
+++ b/vendor/github.com/coredns/coredns/plugin/pkg/doh/doh.go
@@ -53,7 +53,7 @@ func NewRequest(method, url string, m *dns.Msg) (*http.Request, error) {
}
-// ResponseToMsg converts a http.Repsonse to a dns message.
+// ResponseToMsg converts a http.Response to a dns message.
func ResponseToMsg(resp *http.Response) (*dns.Msg, error) {
defer resp.Body.Close()
diff --git a/vendor/github.com/coredns/coredns/plugin/pkg/log/log.go b/vendor/github.com/coredns/coredns/plugin/pkg/log/log.go
index 161fbc8869..f05dce03ae 100644
--- a/vendor/github.com/coredns/coredns/plugin/pkg/log/log.go
+++ b/vendor/github.com/coredns/coredns/plugin/pkg/log/log.go
@@ -10,7 +10,9 @@ package log
import (
"fmt"
+ "io/ioutil"
golog "log"
+ "os"
)
// D controls whether we should output debug logs. If true, we do.
@@ -61,9 +63,21 @@ func Error(v ...interface{}) { log(err, v...) }
// Errorf is equivalent to log.Printf, but prefixed with "[ERROR] ".
func Errorf(format string, v ...interface{}) { logf(err, format, v...) }
+// Fatal is equivalent to log.Print, but prefixed with "[FATAL] ", and calling
+// os.Exit(1).
+func Fatal(v ...interface{}) { log(fatal, v...); os.Exit(1) }
+
+// Fatalf is equivalent to log.Printf, but prefixed with "[FATAL] ", and calling
+// os.Exit(1)
+func Fatalf(format string, v ...interface{}) { logf(fatal, format, v...); os.Exit(1) }
+
+// Discard sets the log output to /dev/null.
+func Discard() { golog.SetOutput(ioutil.Discard) }
+
const (
debug = "[DEBUG] "
err = "[ERROR] "
- warning = "[WARNING] "
+ fatal = "[FATAL] "
info = "[INFO] "
+ warning = "[WARNING] "
)
diff --git a/vendor/github.com/coredns/coredns/plugin/pkg/log/plugin.go b/vendor/github.com/coredns/coredns/plugin/pkg/log/plugin.go
index 354c19d3fb..1df3026095 100644
--- a/vendor/github.com/coredns/coredns/plugin/pkg/log/plugin.go
+++ b/vendor/github.com/coredns/coredns/plugin/pkg/log/plugin.go
@@ -3,6 +3,7 @@ package log
import (
"fmt"
golog "log"
+ "os"
)
// P is a logger that includes the plugin doing the logging.
@@ -58,4 +59,10 @@ func (p P) Error(v ...interface{}) { p.log(err, v...) }
// Errorf logs as log.Errorf.
func (p P) Errorf(format string, v ...interface{}) { p.logf(err, format, v...) }
+// Fatal logs as log.Fatal and calls os.Exit(1).
+func (p P) Fatal(v ...interface{}) { p.log(fatal, v...); os.Exit(1) }
+
+// Fatalf logs as log.Fatalf and calls os.Exit(1).
+func (p P) Fatalf(format string, v ...interface{}) { p.logf(fatal, format, v...); os.Exit(1) }
+
func pFormat(s string) string { return "plugin/" + s + ": " }
diff --git a/vendor/github.com/coredns/coredns/plugin/pkg/uniq/uniq.go b/vendor/github.com/coredns/coredns/plugin/pkg/uniq/uniq.go
index 3e50d64b5f..6dd74883d1 100644
--- a/vendor/github.com/coredns/coredns/plugin/pkg/uniq/uniq.go
+++ b/vendor/github.com/coredns/coredns/plugin/pkg/uniq/uniq.go
@@ -24,6 +24,13 @@ func (u U) Set(key string, f func() error) {
u.u[key] = item{todo, f}
}
+// Unset removes the 'todo' associated with a key
+func (u U) Unset(key string) {
+ if _, ok := u.u[key]; ok {
+ delete(u.u, key)
+ }
+}
+
// SetTodo sets key to 'todo' again.
func (u U) SetTodo(key string) {
v, ok := u.u[key]
diff --git a/vendor/github.com/coredns/coredns/plugin/pkg/up/up.go b/vendor/github.com/coredns/coredns/plugin/pkg/up/up.go
index e4752ce4d4..e2c9fe2cd8 100644
--- a/vendor/github.com/coredns/coredns/plugin/pkg/up/up.go
+++ b/vendor/github.com/coredns/coredns/plugin/pkg/up/up.go
@@ -18,7 +18,7 @@ type Probe struct {
// Func is used to determine if a target is alive. If so this function must return nil.
type Func func() error
-// New returns a pointer to an intialized Probe.
+// New returns a pointer to an initialized Probe.
func New() *Probe { return &Probe{} }
// Do will probe target, if a probe is already in progress this is a noop.
diff --git a/vendor/github.com/coredns/coredns/plugin/pkg/watch/watcher.go b/vendor/github.com/coredns/coredns/plugin/pkg/watch/watcher.go
index 59474a7bc1..86a952db21 100644
--- a/vendor/github.com/coredns/coredns/plugin/pkg/watch/watcher.go
+++ b/vendor/github.com/coredns/coredns/plugin/pkg/watch/watcher.go
@@ -169,7 +169,7 @@ func (w *Manager) Stop() {
wr := pb.WatchResponse{WatchId: id, Canceled: true}
err := stream.Send(&wr)
if err != nil {
- log.Warningf("Error notifiying client of cancellation: %s\n", err)
+ log.Warningf("Error notifying client of cancellation: %s\n", err)
}
}
delete(w.watches, wn)
diff --git a/vendor/github.com/coredns/coredns/plugin/proxy/README.md b/vendor/github.com/coredns/coredns/plugin/proxy/README.md
index f9dc3493b5..b108b52a9b 100644
--- a/vendor/github.com/coredns/coredns/plugin/proxy/README.md
+++ b/vendor/github.com/coredns/coredns/plugin/proxy/README.md
@@ -99,7 +99,7 @@ If monitoring is enabled (via the *prometheus* directive) then the following met
Where `proxy_proto` is the protocol used (`dns` or `grpc`) and `to` is **TO**
specified in the config, `proto` is the protocol used by the incoming query ("tcp" or "udp"), family
the transport family ("1" for IPv4, and "2" for IPv6). `Server` is the server responsible for the
-request (and metric). See the documention in the metrics plugin.
+request (and metric). See the documentation in the metrics plugin.
## Examples
diff --git a/vendor/github.com/coredns/coredns/plugin/proxy/lookup.go b/vendor/github.com/coredns/coredns/plugin/proxy/lookup.go
index 44bee4b0eb..0437e8eb73 100644
--- a/vendor/github.com/coredns/coredns/plugin/proxy/lookup.go
+++ b/vendor/github.com/coredns/coredns/plugin/proxy/lookup.go
@@ -71,7 +71,7 @@ func (p Proxy) lookup(state request.Request) (*dns.Msg, error) {
}
for {
start := time.Now()
- reply := new(dns.Msg)
+ var reply *dns.Msg
var backendErr error
// Since Select() should give us "up" hosts, keep retrying
diff --git a/vendor/github.com/coredns/coredns/plugin/proxy/proxy.go b/vendor/github.com/coredns/coredns/plugin/proxy/proxy.go
index 2a8e350963..002007c98b 100644
--- a/vendor/github.com/coredns/coredns/plugin/proxy/proxy.go
+++ b/vendor/github.com/coredns/coredns/plugin/proxy/proxy.go
@@ -70,7 +70,7 @@ func (p Proxy) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (
for {
start := time.Now()
- reply := new(dns.Msg)
+ var reply *dns.Msg
var backendErr error
// Since Select() should give us "up" hosts, keep retrying
@@ -123,7 +123,7 @@ func (p Proxy) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (
// Note this keeps looping and trying until tryDuration is hit, at which point our client
// might be long gone...
if oe.Timeout() {
- // Our upstream's upstream is problably messing up, continue with next selected
+ // Our upstream's upstream is probably messing up, continue with next selected
// host - which my be the *same* one as we don't set any uh.Fails.
continue
}
diff --git a/vendor/github.com/coredns/coredns/plugin/reload/README.md b/vendor/github.com/coredns/coredns/plugin/reload/README.md
index eb06bb71ca..625e4b0255 100644
--- a/vendor/github.com/coredns/coredns/plugin/reload/README.md
+++ b/vendor/github.com/coredns/coredns/plugin/reload/README.md
@@ -84,7 +84,7 @@ is already listening on that port. The process reloads and performs the followin
3. fail to start a new listener on 443
4. fail loading the new Corefile, abort and keep using the old process
-After the aborted attempt to reload we are left with the old proceses running, but the listener is
+After the aborted attempt to reload we are left with the old processes running, but the listener is
closed in step 1; so the health endpoint is broken. The same can hopen in the prometheus metrics plugin.
In general be careful with assigning new port and expecting reload to work fully.
diff --git a/vendor/github.com/coredns/coredns/request/request.go b/vendor/github.com/coredns/coredns/request/request.go
index 06f840f89e..bcf6570bee 100644
--- a/vendor/github.com/coredns/coredns/request/request.go
+++ b/vendor/github.com/coredns/coredns/request/request.go
@@ -263,12 +263,16 @@ func (r *Request) Scrub(reply *dns.Msg) (*dns.Msg, Result) {
// Account for the OPT record that gets added in SizeAndDo(), subtract that length.
sub := 0
- if r.Do() {
+ if r.Req.IsEdns0() != nil {
sub = optLen
}
- origExtra := reply.Extra
+
+ // subtract to make spaces for re-added EDNS0 OPT RR.
re := len(reply.Extra) - sub
+ size -= sub
+
l, m := 0, 0
+ origExtra := reply.Extra
for l < re {
m = (l + re) / 2
reply.Extra = origExtra[:m]
@@ -297,9 +301,9 @@ func (r *Request) Scrub(reply *dns.Msg) (*dns.Msg, Result) {
return reply, ScrubExtra
}
- origAnswer := reply.Answer
ra := len(reply.Answer)
l, m = 0, 0
+ origAnswer := reply.Answer
for l < ra {
m = (l + ra) / 2
reply.Answer = origAnswer[:m]
@@ -324,14 +328,12 @@ func (r *Request) Scrub(reply *dns.Msg) (*dns.Msg, Result) {
// this extra m-1 step does make it fit in the client's buffer however.
}
- // It now fits, but Truncated. We can't call sizeAndDo() because that adds a new record (OPT)
- // in the additional section.
+ r.SizeAndDo(reply)
reply.Truncated = true
return reply, ScrubAnswer
}
-// Type returns the type of the question as a string. If the request is malformed
-// the empty string is returned.
+// Type returns the type of the question as a string. If the request is malformed the empty string is returned.
func (r *Request) Type() string {
if r.Req == nil {
return ""
diff --git a/vendor/github.com/davecgh/go-spew/LICENSE b/vendor/github.com/davecgh/go-spew/LICENSE
index c836416192..bc52e96f2b 100644
--- a/vendor/github.com/davecgh/go-spew/LICENSE
+++ b/vendor/github.com/davecgh/go-spew/LICENSE
@@ -2,7 +2,7 @@ ISC License
Copyright (c) 2012-2016 Dave Collins
-Permission to use, copy, modify, and distribute this software for any
+Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
diff --git a/vendor/github.com/davecgh/go-spew/spew/bypass.go b/vendor/github.com/davecgh/go-spew/spew/bypass.go
index 8a4a6589a2..792994785e 100644
--- a/vendor/github.com/davecgh/go-spew/spew/bypass.go
+++ b/vendor/github.com/davecgh/go-spew/spew/bypass.go
@@ -16,7 +16,9 @@
// when the code is not running on Google App Engine, compiled by GopherJS, and
// "-tags safe" is not added to the go build command line. The "disableunsafe"
// tag is deprecated and thus should not be used.
-// +build !js,!appengine,!safe,!disableunsafe
+// Go versions prior to 1.4 are disabled because they use a different layout
+// for interfaces which make the implementation of unsafeReflectValue more complex.
+// +build !js,!appengine,!safe,!disableunsafe,go1.4
package spew
@@ -34,80 +36,49 @@ const (
ptrSize = unsafe.Sizeof((*byte)(nil))
)
-var (
- // offsetPtr, offsetScalar, and offsetFlag are the offsets for the
- // internal reflect.Value fields. These values are valid before golang
- // commit ecccf07e7f9d which changed the format. The are also valid
- // after commit 82f48826c6c7 which changed the format again to mirror
- // the original format. Code in the init function updates these offsets
- // as necessary.
- offsetPtr = uintptr(ptrSize)
- offsetScalar = uintptr(0)
- offsetFlag = uintptr(ptrSize * 2)
+type flag uintptr
- // flagKindWidth and flagKindShift indicate various bits that the
- // reflect package uses internally to track kind information.
- //
- // flagRO indicates whether or not the value field of a reflect.Value is
- // read-only.
- //
- // flagIndir indicates whether the value field of a reflect.Value is
- // the actual data or a pointer to the data.
- //
- // These values are valid before golang commit 90a7c3c86944 which
- // changed their positions. Code in the init function updates these
- // flags as necessary.
- flagKindWidth = uintptr(5)
- flagKindShift = uintptr(flagKindWidth - 1)
- flagRO = uintptr(1 << 0)
- flagIndir = uintptr(1 << 1)
+var (
+ // flagRO indicates whether the value field of a reflect.Value
+ // is read-only.
+ flagRO flag
+
+ // flagAddr indicates whether the address of the reflect.Value's
+ // value may be taken.
+ flagAddr flag
)
-func init() {
- // Older versions of reflect.Value stored small integers directly in the
- // ptr field (which is named val in the older versions). Versions
- // between commits ecccf07e7f9d and 82f48826c6c7 added a new field named
- // scalar for this purpose which unfortunately came before the flag
- // field, so the offset of the flag field is different for those
- // versions.
- //
- // This code constructs a new reflect.Value from a known small integer
- // and checks if the size of the reflect.Value struct indicates it has
- // the scalar field. When it does, the offsets are updated accordingly.
- vv := reflect.ValueOf(0xf00)
- if unsafe.Sizeof(vv) == (ptrSize * 4) {
- offsetScalar = ptrSize * 2
- offsetFlag = ptrSize * 3
- }
+// flagKindMask holds the bits that make up the kind
+// part of the flags field. In all the supported versions,
+// it is in the lower 5 bits.
+const flagKindMask = flag(0x1f)
- // Commit 90a7c3c86944 changed the flag positions such that the low
- // order bits are the kind. This code extracts the kind from the flags
- // field and ensures it's the correct type. When it's not, the flag
- // order has been changed to the newer format, so the flags are updated
- // accordingly.
- upf := unsafe.Pointer(uintptr(unsafe.Pointer(&vv)) + offsetFlag)
- upfv := *(*uintptr)(upf)
- flagKindMask := uintptr((1<>flagKindShift != uintptr(reflect.Int) {
- flagKindShift = 0
- flagRO = 1 << 5
- flagIndir = 1 << 6
+// Different versions of Go have used different
+// bit layouts for the flags type. This table
+// records the known combinations.
+var okFlags = []struct {
+ ro, addr flag
+}{{
+ // From Go 1.4 to 1.5
+ ro: 1 << 5,
+ addr: 1 << 7,
+}, {
+ // Up to Go tip.
+ ro: 1<<5 | 1<<6,
+ addr: 1 << 8,
+}}
- // Commit adf9b30e5594 modified the flags to separate the
- // flagRO flag into two bits which specifies whether or not the
- // field is embedded. This causes flagIndir to move over a bit
- // and means that flagRO is the combination of either of the
- // original flagRO bit and the new bit.
- //
- // This code detects the change by extracting what used to be
- // the indirect bit to ensure it's set. When it's not, the flag
- // order has been changed to the newer format, so the flags are
- // updated accordingly.
- if upfv&flagIndir == 0 {
- flagRO = 3 << 5
- flagIndir = 1 << 7
- }
+var flagValOffset = func() uintptr {
+ field, ok := reflect.TypeOf(reflect.Value{}).FieldByName("flag")
+ if !ok {
+ panic("reflect.Value has no flag field")
}
+ return field.Offset
+}()
+
+// flagField returns a pointer to the flag field of a reflect.Value.
+func flagField(v *reflect.Value) *flag {
+ return (*flag)(unsafe.Pointer(uintptr(unsafe.Pointer(v)) + flagValOffset))
}
// unsafeReflectValue converts the passed reflect.Value into a one that bypasses
@@ -119,34 +90,56 @@ func init() {
// This allows us to check for implementations of the Stringer and error
// interfaces to be used for pretty printing ordinarily unaddressable and
// inaccessible values such as unexported struct fields.
-func unsafeReflectValue(v reflect.Value) (rv reflect.Value) {
- indirects := 1
- vt := v.Type()
- upv := unsafe.Pointer(uintptr(unsafe.Pointer(&v)) + offsetPtr)
- rvf := *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&v)) + offsetFlag))
- if rvf&flagIndir != 0 {
- vt = reflect.PtrTo(v.Type())
- indirects++
- } else if offsetScalar != 0 {
- // The value is in the scalar field when it's not one of the
- // reference types.
- switch vt.Kind() {
- case reflect.Uintptr:
- case reflect.Chan:
- case reflect.Func:
- case reflect.Map:
- case reflect.Ptr:
- case reflect.UnsafePointer:
- default:
- upv = unsafe.Pointer(uintptr(unsafe.Pointer(&v)) +
- offsetScalar)
+func unsafeReflectValue(v reflect.Value) reflect.Value {
+ if !v.IsValid() || (v.CanInterface() && v.CanAddr()) {
+ return v
+ }
+ flagFieldPtr := flagField(&v)
+ *flagFieldPtr &^= flagRO
+ *flagFieldPtr |= flagAddr
+ return v
+}
+
+// Sanity checks against future reflect package changes
+// to the type or semantics of the Value.flag field.
+func init() {
+ field, ok := reflect.TypeOf(reflect.Value{}).FieldByName("flag")
+ if !ok {
+ panic("reflect.Value has no flag field")
+ }
+ if field.Type.Kind() != reflect.TypeOf(flag(0)).Kind() {
+ panic("reflect.Value flag field has changed kind")
+ }
+ type t0 int
+ var t struct {
+ A t0
+ // t0 will have flagEmbedRO set.
+ t0
+ // a will have flagStickyRO set
+ a t0
+ }
+ vA := reflect.ValueOf(t).FieldByName("A")
+ va := reflect.ValueOf(t).FieldByName("a")
+ vt0 := reflect.ValueOf(t).FieldByName("t0")
+
+ // Infer flagRO from the difference between the flags
+ // for the (otherwise identical) fields in t.
+ flagPublic := *flagField(&vA)
+ flagWithRO := *flagField(&va) | *flagField(&vt0)
+ flagRO = flagPublic ^ flagWithRO
+
+ // Infer flagAddr from the difference between a value
+ // taken from a pointer and not.
+ vPtrA := reflect.ValueOf(&t).Elem().FieldByName("A")
+ flagNoPtr := *flagField(&vA)
+ flagPtr := *flagField(&vPtrA)
+ flagAddr = flagNoPtr ^ flagPtr
+
+ // Check that the inferred flags tally with one of the known versions.
+ for _, f := range okFlags {
+ if flagRO == f.ro && flagAddr == f.addr {
+ return
}
}
-
- pv := reflect.NewAt(vt, upv)
- rv = pv
- for i := 0; i < indirects; i++ {
- rv = rv.Elem()
- }
- return rv
+ panic("reflect.Value read-only flag has changed semantics")
}
diff --git a/vendor/github.com/davecgh/go-spew/spew/bypasssafe.go b/vendor/github.com/davecgh/go-spew/spew/bypasssafe.go
index 1fe3cf3d5d..205c28d68c 100644
--- a/vendor/github.com/davecgh/go-spew/spew/bypasssafe.go
+++ b/vendor/github.com/davecgh/go-spew/spew/bypasssafe.go
@@ -16,7 +16,7 @@
// when the code is running on Google App Engine, compiled by GopherJS, or
// "-tags safe" is added to the go build command line. The "disableunsafe"
// tag is deprecated and thus should not be used.
-// +build js appengine safe disableunsafe
+// +build js appengine safe disableunsafe !go1.4
package spew
diff --git a/vendor/github.com/davecgh/go-spew/spew/common.go b/vendor/github.com/davecgh/go-spew/spew/common.go
index 7c519ff47a..1be8ce9457 100644
--- a/vendor/github.com/davecgh/go-spew/spew/common.go
+++ b/vendor/github.com/davecgh/go-spew/spew/common.go
@@ -180,7 +180,7 @@ func printComplex(w io.Writer, c complex128, floatPrecision int) {
w.Write(closeParenBytes)
}
-// printHexPtr outputs a uintptr formatted as hexidecimal with a leading '0x'
+// printHexPtr outputs a uintptr formatted as hexadecimal with a leading '0x'
// prefix to Writer w.
func printHexPtr(w io.Writer, p uintptr) {
// Null pointer.
diff --git a/vendor/github.com/davecgh/go-spew/spew/dump.go b/vendor/github.com/davecgh/go-spew/spew/dump.go
index df1d582a72..f78d89fc1f 100644
--- a/vendor/github.com/davecgh/go-spew/spew/dump.go
+++ b/vendor/github.com/davecgh/go-spew/spew/dump.go
@@ -35,16 +35,16 @@ var (
// cCharRE is a regular expression that matches a cgo char.
// It is used to detect character arrays to hexdump them.
- cCharRE = regexp.MustCompile("^.*\\._Ctype_char$")
+ cCharRE = regexp.MustCompile(`^.*\._Ctype_char$`)
// cUnsignedCharRE is a regular expression that matches a cgo unsigned
// char. It is used to detect unsigned character arrays to hexdump
// them.
- cUnsignedCharRE = regexp.MustCompile("^.*\\._Ctype_unsignedchar$")
+ cUnsignedCharRE = regexp.MustCompile(`^.*\._Ctype_unsignedchar$`)
// cUint8tCharRE is a regular expression that matches a cgo uint8_t.
// It is used to detect uint8_t arrays to hexdump them.
- cUint8tCharRE = regexp.MustCompile("^.*\\._Ctype_uint8_t$")
+ cUint8tCharRE = regexp.MustCompile(`^.*\._Ctype_uint8_t$`)
)
// dumpState contains information about the state of a dump operation.
@@ -143,10 +143,10 @@ func (d *dumpState) dumpPtr(v reflect.Value) {
// Display dereferenced value.
d.w.Write(openParenBytes)
switch {
- case nilFound == true:
+ case nilFound:
d.w.Write(nilAngleBytes)
- case cycleFound == true:
+ case cycleFound:
d.w.Write(circularBytes)
default:
diff --git a/vendor/github.com/davecgh/go-spew/spew/format.go b/vendor/github.com/davecgh/go-spew/spew/format.go
index c49875bacb..b04edb7d7a 100644
--- a/vendor/github.com/davecgh/go-spew/spew/format.go
+++ b/vendor/github.com/davecgh/go-spew/spew/format.go
@@ -182,10 +182,10 @@ func (f *formatState) formatPtr(v reflect.Value) {
// Display dereferenced value.
switch {
- case nilFound == true:
+ case nilFound:
f.fs.Write(nilAngleBytes)
- case cycleFound == true:
+ case cycleFound:
f.fs.Write(circularShortBytes)
default:
diff --git a/vendor/github.com/eapache/go-xerial-snappy/snappy.go b/vendor/github.com/eapache/go-xerial-snappy/snappy.go
index de69eacbb3..ea8f7afeb3 100644
--- a/vendor/github.com/eapache/go-xerial-snappy/snappy.go
+++ b/vendor/github.com/eapache/go-xerial-snappy/snappy.go
@@ -15,37 +15,96 @@ const (
var (
xerialHeader = []byte{130, 83, 78, 65, 80, 80, 89, 0}
+
+ // This is xerial version 1 and minimally compatible with version 1
+ xerialVersionInfo = []byte{0, 0, 0, 1, 0, 0, 0, 1}
+
// ErrMalformed is returned by the decoder when the xerial framing
// is malformed
ErrMalformed = errors.New("malformed xerial framing")
)
+func min(x, y int) int {
+ if x < y {
+ return x
+ }
+ return y
+}
+
// Encode encodes data as snappy with no framing header.
func Encode(src []byte) []byte {
return master.Encode(nil, src)
}
+// EncodeStream *appends* to the specified 'dst' the compressed
+// 'src' in xerial framing format. If 'dst' does not have enough
+// capacity, then a new slice will be allocated. If 'dst' has
+// non-zero length, then if *must* have been built using this function.
+func EncodeStream(dst, src []byte) []byte {
+ if len(dst) == 0 {
+ dst = append(dst, xerialHeader...)
+ dst = append(dst, xerialVersionInfo...)
+ }
+
+ // Snappy encode in blocks of maximum 32KB
+ var (
+ max = len(src)
+ blockSize = 32 * 1024
+ pos = 0
+ chunk []byte
+ )
+
+ for pos < max {
+ newPos := min(pos + blockSize, max)
+ chunk = master.Encode(chunk[:cap(chunk)], src[pos:newPos])
+
+ // First encode the compressed size (big-endian)
+ // Put* panics if the buffer is too small, so pad 4 bytes first
+ origLen := len(dst)
+ dst = append(dst, dst[0:4]...)
+ binary.BigEndian.PutUint32(dst[origLen:], uint32(len(chunk)))
+
+ // And now the compressed data
+ dst = append(dst, chunk...)
+ pos = newPos
+ }
+ return dst
+}
+
// Decode decodes snappy data whether it is traditional unframed
// or includes the xerial framing format.
func Decode(src []byte) ([]byte, error) {
+ return DecodeInto(nil, src)
+}
+
+// DecodeInto decodes snappy data whether it is traditional unframed
+// or includes the xerial framing format into the specified `dst`.
+// It is assumed that the entirety of `dst` including all capacity is available
+// for use by this function. If `dst` is nil *or* insufficiently large to hold
+// the decoded `src`, new space will be allocated.
+func DecodeInto(dst, src []byte) ([]byte, error) {
var max = len(src)
if max < len(xerialHeader) {
return nil, ErrMalformed
}
if !bytes.Equal(src[:8], xerialHeader) {
- return master.Decode(nil, src)
+ return master.Decode(dst[:cap(dst)], src)
}
if max < sizeOffset+sizeBytes {
return nil, ErrMalformed
}
+ if dst == nil {
+ dst = make([]byte, 0, len(src))
+ }
+
+ dst = dst[:0]
var (
pos = sizeOffset
- dst = make([]byte, 0, len(src))
chunk []byte
- err error
+ err error
)
for pos+sizeBytes <= max {
@@ -60,7 +119,8 @@ func Decode(src []byte) ([]byte, error) {
return nil, ErrMalformed
}
- chunk, err = master.Decode(chunk, src[pos:nextPos])
+ chunk, err = master.Decode(chunk[:cap(chunk)], src[pos:nextPos])
+
if err != nil {
return nil, err
}
diff --git a/vendor/github.com/ghodss/yaml/README.md b/vendor/github.com/ghodss/yaml/README.md
index 0200f75b4d..f8f7e36954 100644
--- a/vendor/github.com/ghodss/yaml/README.md
+++ b/vendor/github.com/ghodss/yaml/README.md
@@ -4,13 +4,13 @@
## Introduction
-A wrapper around [go-yaml](https://github.com/go-yaml/yaml) designed to enable a better way of handling YAML when marshaling to and from structs.
+A wrapper around [go-yaml](https://github.com/go-yaml/yaml) designed to enable a better way of handling YAML when marshaling to and from structs.
In short, this library first converts YAML to JSON using go-yaml and then uses `json.Marshal` and `json.Unmarshal` to convert to or from the struct. This means that it effectively reuses the JSON struct tags as well as the custom JSON methods `MarshalJSON` and `UnmarshalJSON` unlike go-yaml. For a detailed overview of the rationale behind this method, [see this blog post](http://ghodss.com/2014/the-right-way-to-handle-yaml-in-golang/).
## Compatibility
-This package uses [go-yaml](https://github.com/go-yaml/yaml) and therefore supports [everything go-yaml supports](https://github.com/go-yaml/yaml#compatibility).
+This package uses [go-yaml v2](https://github.com/go-yaml/yaml) and therefore supports [everything go-yaml supports](https://github.com/go-yaml/yaml#compatibility).
## Caveats
@@ -44,8 +44,6 @@ import "github.com/ghodss/yaml"
Usage is very similar to the JSON library:
```go
-package main
-
import (
"fmt"
@@ -53,8 +51,8 @@ import (
)
type Person struct {
- Name string `json:"name"` // Affects YAML field names too.
- Age int `json:"age"`
+ Name string `json:"name"` // Affects YAML field names too.
+ Age int `json:"name"`
}
func main() {
@@ -67,13 +65,13 @@ func main() {
}
fmt.Println(string(y))
/* Output:
- age: 30
name: John
+ age: 30
*/
// Unmarshal the YAML back into a Person struct.
var p2 Person
- err = yaml.Unmarshal(y, &p2)
+ err := yaml.Unmarshal(y, &p2)
if err != nil {
fmt.Printf("err: %v\n", err)
return
@@ -88,14 +86,11 @@ func main() {
`yaml.YAMLToJSON` and `yaml.JSONToYAML` methods are also available:
```go
-package main
-
import (
"fmt"
"github.com/ghodss/yaml"
)
-
func main() {
j := []byte(`{"name": "John", "age": 30}`)
y, err := yaml.JSONToYAML(j)
diff --git a/vendor/github.com/ghodss/yaml/fields.go b/vendor/github.com/ghodss/yaml/fields.go
index 5860074026..0bd3c2b462 100644
--- a/vendor/github.com/ghodss/yaml/fields.go
+++ b/vendor/github.com/ghodss/yaml/fields.go
@@ -45,11 +45,7 @@ func indirect(v reflect.Value, decodingNull bool) (json.Unmarshaler, encoding.Te
break
}
if v.IsNil() {
- if v.CanSet() {
- v.Set(reflect.New(v.Type().Elem()))
- } else {
- v = reflect.New(v.Type().Elem())
- }
+ v.Set(reflect.New(v.Type().Elem()))
}
if v.Type().NumMethod() > 0 {
if u, ok := v.Interface().(json.Unmarshaler); ok {
diff --git a/vendor/github.com/ghodss/yaml/yaml.go b/vendor/github.com/ghodss/yaml/yaml.go
index 4fb4054a8b..c02beacb9a 100644
--- a/vendor/github.com/ghodss/yaml/yaml.go
+++ b/vendor/github.com/ghodss/yaml/yaml.go
@@ -15,12 +15,12 @@ import (
func Marshal(o interface{}) ([]byte, error) {
j, err := json.Marshal(o)
if err != nil {
- return nil, fmt.Errorf("error marshaling into JSON: %v", err)
+ return nil, fmt.Errorf("error marshaling into JSON: ", err)
}
y, err := JSONToYAML(j)
if err != nil {
- return nil, fmt.Errorf("error converting JSON to YAML: %v", err)
+ return nil, fmt.Errorf("error converting JSON to YAML: ", err)
}
return y, nil
@@ -48,7 +48,7 @@ func JSONToYAML(j []byte) ([]byte, error) {
var jsonObj interface{}
// We are using yaml.Unmarshal here (instead of json.Unmarshal) because the
// Go JSON library doesn't try to pick the right number type (int, float,
- // etc.) when unmarshalling to interface{}, it just picks float64
+ // etc.) when unmarshling to interface{}, it just picks float64
// universally. go-yaml does go through the effort of picking the right
// number type, so we can preserve number type throughout this process.
err := yaml.Unmarshal(j, &jsonObj)
diff --git a/vendor/github.com/gin-gonic/gin/AUTHORS.md b/vendor/github.com/gin-gonic/gin/AUTHORS.md
index 7ab7213d98..dda19bcf3e 100644
--- a/vendor/github.com/gin-gonic/gin/AUTHORS.md
+++ b/vendor/github.com/gin-gonic/gin/AUTHORS.md
@@ -1,8 +1,12 @@
List of all the awesome people working to make Gin the best Web Framework in Go.
+## gin 1.x series authors
+
+**Gin Core Team:** Bo-Yi Wu (@appleboy), 田欧 (@thinkerou), Javier Provecho (@javierprovecho)
+
## gin 0.x series authors
-**Maintainer:** Manu Martinez-Almeida (@manucorporat), Javier Provecho (@javierprovecho)
+**Maintainers:** Manu Martinez-Almeida (@manucorporat), Javier Provecho (@javierprovecho)
People and companies, who have contributed, in alphabetical order.
diff --git a/vendor/github.com/gin-gonic/gin/binding/binding.go b/vendor/github.com/gin-gonic/gin/binding/binding.go
index 1dbf2460a5..3a2aad9cce 100644
--- a/vendor/github.com/gin-gonic/gin/binding/binding.go
+++ b/vendor/github.com/gin-gonic/gin/binding/binding.go
@@ -6,6 +6,7 @@ package binding
import "net/http"
+// Content-Type MIME of the most common data formats.
const (
MIMEJSON = "application/json"
MIMEHTML = "text/html"
@@ -19,11 +20,25 @@ const (
MIMEMSGPACK2 = "application/msgpack"
)
+// 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
+}
+
+// StructValidator is the minimal interface which needs to be implemented in
+// order for it to be used as the validator engine for ensuring the correctness
+// of the reqest. Gin provides a default implementation for this using
+// 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.
@@ -31,20 +46,32 @@ type StructValidator interface {
// 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{}
MsgPack = msgpackBinding{}
)
+// 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
diff --git a/vendor/github.com/gin-gonic/gin/binding/default_validator.go b/vendor/github.com/gin-gonic/gin/binding/default_validator.go
index 19885f164a..e7a302de67 100644
--- a/vendor/github.com/gin-gonic/gin/binding/default_validator.go
+++ b/vendor/github.com/gin-gonic/gin/binding/default_validator.go
@@ -18,28 +18,34 @@ type defaultValidator struct {
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 {
- if kindOfData(obj) == reflect.Struct {
+ value := reflect.ValueOf(obj)
+ valueType := value.Kind()
+ if valueType == reflect.Ptr {
+ valueType = value.Elem().Kind()
+ }
+ if valueType == reflect.Struct {
v.lazyinit()
if err := v.validate.Struct(obj); err != nil {
- return error(err)
+ return err
}
}
return nil
}
+// Engine returns the underlying validator engine which powers the default
+// Validator instance. This is useful if you want to register custom validations
+// or struct level validations. See validator GoDoc for more info -
+// https://godoc.org/gopkg.in/go-playground/validator.v8
+func (v *defaultValidator) Engine() interface{} {
+ v.lazyinit()
+ return v.validate
+}
+
func (v *defaultValidator) lazyinit() {
v.once.Do(func() {
config := &validator.Config{TagName: "binding"}
v.validate = validator.New(config)
})
}
-
-func kindOfData(data interface{}) reflect.Kind {
- value := reflect.ValueOf(data)
- valueType := value.Kind()
- if valueType == reflect.Ptr {
- valueType = value.Elem().Kind()
- }
- return valueType
-}
diff --git a/vendor/github.com/gin-gonic/gin/binding/form.go b/vendor/github.com/gin-gonic/gin/binding/form.go
index 557333e6fa..0be59660b3 100644
--- a/vendor/github.com/gin-gonic/gin/binding/form.go
+++ b/vendor/github.com/gin-gonic/gin/binding/form.go
@@ -6,6 +6,8 @@ package binding
import "net/http"
+const defaultMemory = 32 * 1024 * 1024
+
type formBinding struct{}
type formPostBinding struct{}
type formMultipartBinding struct{}
@@ -18,7 +20,7 @@ func (formBinding) Bind(req *http.Request, obj interface{}) error {
if err := req.ParseForm(); err != nil {
return err
}
- req.ParseMultipartForm(32 << 10) // 32 MB
+ req.ParseMultipartForm(defaultMemory)
if err := mapForm(obj, req.Form); err != nil {
return err
}
@@ -44,7 +46,7 @@ func (formMultipartBinding) Name() string {
}
func (formMultipartBinding) Bind(req *http.Request, obj interface{}) error {
- if err := req.ParseMultipartForm(32 << 10); err != nil {
+ if err := req.ParseMultipartForm(defaultMemory); err != nil {
return err
}
if err := mapForm(obj, req.MultipartForm.Value); err != nil {
diff --git a/vendor/github.com/gin-gonic/gin/binding/form_mapping.go b/vendor/github.com/gin-gonic/gin/binding/form_mapping.go
index 34f126781e..3f6b9bfa1a 100644
--- a/vendor/github.com/gin-gonic/gin/binding/form_mapping.go
+++ b/vendor/github.com/gin-gonic/gin/binding/form_mapping.go
@@ -8,6 +8,7 @@ import (
"errors"
"reflect"
"strconv"
+ "strings"
"time"
)
@@ -23,12 +24,28 @@ func mapForm(ptr interface{}, form map[string][]string) error {
structFieldKind := structField.Kind()
inputFieldName := typeField.Tag.Get("form")
+ inputFieldNameList := strings.Split(inputFieldName, ",")
+ inputFieldName = inputFieldNameList[0]
+ var defaultValue string
+ if len(inputFieldNameList) > 1 {
+ defaultList := strings.SplitN(inputFieldNameList[1], "=", 2)
+ if defaultList[0] == "default" {
+ defaultValue = defaultList[1]
+ }
+ }
if inputFieldName == "" {
inputFieldName = typeField.Name
- // if "form" tag is nil, we inspect if the field is a struct.
+ // if "form" tag is nil, we inspect if the field is a struct or struct pointer.
// this would not make sense for JSON parsing but it does for a form
// since data is flatten
+ if structFieldKind == reflect.Ptr {
+ if !structField.Elem().IsValid() {
+ structField.Set(reflect.New(structField.Type().Elem()))
+ }
+ structField = structField.Elem()
+ structFieldKind = structField.Kind()
+ }
if structFieldKind == reflect.Struct {
err := mapForm(structField.Addr().Interface(), form)
if err != nil {
@@ -38,8 +55,13 @@ func mapForm(ptr interface{}, form map[string][]string) error {
}
}
inputValue, exists := form[inputFieldName]
+
if !exists {
- continue
+ if defaultValue == "" {
+ continue
+ }
+ inputValue = make([]string, 1)
+ inputValue[0] = defaultValue
}
numElems := len(inputValue)
@@ -97,6 +119,12 @@ func setWithProperType(valueKind reflect.Kind, val string, structField reflect.V
return setFloatField(val, 64, structField)
case reflect.String:
structField.SetString(val)
+ case reflect.Ptr:
+ if !structField.Elem().IsValid() {
+ structField.Set(reflect.New(structField.Type().Elem()))
+ }
+ structFieldElem := structField.Elem()
+ return setWithProperType(structFieldElem.Kind(), val, structFieldElem)
default:
return errors.New("Unknown type")
}
@@ -133,7 +161,7 @@ func setBoolField(val string, field reflect.Value) error {
if err == nil {
field.SetBool(boolVal)
}
- return nil
+ return err
}
func setFloatField(val string, bitSize int, field reflect.Value) error {
@@ -163,6 +191,14 @@ func setTimeField(val string, structField reflect.StructField, value reflect.Val
l = time.UTC
}
+ if locTag := structField.Tag.Get("time_location"); locTag != "" {
+ loc, err := time.LoadLocation(locTag)
+ if err != nil {
+ return err
+ }
+ l = loc
+ }
+
t, err := time.ParseInLocation(timeFormat, val, l)
if err != nil {
return err
@@ -171,12 +207,3 @@ func setTimeField(val string, structField reflect.StructField, value reflect.Val
value.Set(reflect.ValueOf(t))
return nil
}
-
-// Don't pass in pointers to bind to. Can lead to bugs. See:
-// https://github.com/codegangsta/martini-contrib/issues/40
-// https://github.com/codegangsta/martini-contrib/pull/34#issuecomment-29683659
-func ensureNotPointer(obj interface{}) {
- if reflect.TypeOf(obj).Kind() == reflect.Ptr {
- panic("Pointers are not accepted as binding models")
- }
-}
diff --git a/vendor/github.com/gin-gonic/gin/binding/json.go b/vendor/github.com/gin-gonic/gin/binding/json.go
index 486b9733b5..fea17bb2fd 100644
--- a/vendor/github.com/gin-gonic/gin/binding/json.go
+++ b/vendor/github.com/gin-gonic/gin/binding/json.go
@@ -5,10 +5,18 @@
package binding
import (
- "encoding/json"
+ "bytes"
+ "io"
"net/http"
+
+ "github.com/gin-gonic/gin/json"
)
+// EnableDecoderUseNumber is used to call the UseNumber method on the JSON
+// Decoder instance. UseNumber causes the Decoder to unmarshal a number into an
+// interface{} as a Number instead of as a float64.
+var EnableDecoderUseNumber = false
+
type jsonBinding struct{}
func (jsonBinding) Name() string {
@@ -16,7 +24,18 @@ func (jsonBinding) Name() string {
}
func (jsonBinding) Bind(req *http.Request, obj interface{}) error {
- decoder := json.NewDecoder(req.Body)
+ return decodeJSON(req.Body, obj)
+}
+
+func (jsonBinding) BindBody(body []byte, obj interface{}) error {
+ return decodeJSON(bytes.NewReader(body), obj)
+}
+
+func decodeJSON(r io.Reader, obj interface{}) error {
+ decoder := json.NewDecoder(r)
+ if EnableDecoderUseNumber {
+ decoder.UseNumber()
+ }
if err := decoder.Decode(obj); err != nil {
return err
}
diff --git a/vendor/github.com/gin-gonic/gin/binding/msgpack.go b/vendor/github.com/gin-gonic/gin/binding/msgpack.go
index 69367175b6..b7f7319771 100644
--- a/vendor/github.com/gin-gonic/gin/binding/msgpack.go
+++ b/vendor/github.com/gin-gonic/gin/binding/msgpack.go
@@ -5,6 +5,8 @@
package binding
import (
+ "bytes"
+ "io"
"net/http"
"github.com/ugorji/go/codec"
@@ -17,12 +19,17 @@ func (msgpackBinding) Name() string {
}
func (msgpackBinding) Bind(req *http.Request, obj interface{}) error {
+ return decodeMsgPack(req.Body, obj)
+}
- if err := codec.NewDecoder(req.Body, new(codec.MsgpackHandle)).Decode(&obj); err != nil {
- //var decoder *codec.Decoder = codec.NewDecoder(req.Body, &codec.MsgpackHandle)
- //if err := decoder.Decode(&obj); err != nil {
+func (msgpackBinding) BindBody(body []byte, obj interface{}) error {
+ return decodeMsgPack(bytes.NewReader(body), obj)
+}
+
+func decodeMsgPack(r io.Reader, obj interface{}) error {
+ cdc := new(codec.MsgpackHandle)
+ if err := codec.NewDecoder(r, cdc).Decode(&obj); err != nil {
return err
}
return validate(obj)
-
}
diff --git a/vendor/github.com/gin-gonic/gin/binding/protobuf.go b/vendor/github.com/gin-gonic/gin/binding/protobuf.go
index c7eb84e9b8..540e9c1f78 100644
--- a/vendor/github.com/gin-gonic/gin/binding/protobuf.go
+++ b/vendor/github.com/gin-gonic/gin/binding/protobuf.go
@@ -17,19 +17,20 @@ func (protobufBinding) Name() string {
return "protobuf"
}
-func (protobufBinding) Bind(req *http.Request, obj interface{}) error {
-
+func (b protobufBinding) Bind(req *http.Request, obj interface{}) error {
buf, err := ioutil.ReadAll(req.Body)
if err != nil {
return err
}
+ return b.BindBody(buf, obj)
+}
- if err = proto.Unmarshal(buf, obj.(proto.Message)); err != nil {
+func (protobufBinding) BindBody(body []byte, obj interface{}) error {
+ if err := proto.Unmarshal(body, obj.(proto.Message)); err != nil {
return err
}
-
- //Here it's same to return validate(obj), but util now we cann't add `binding:""` to the struct
- //which automatically generate by gen-proto
+ // Here it's same to return validate(obj), but util now we cann't add
+ // `binding:""` to the struct which automatically generate by gen-proto
return nil
- //return validate(obj)
+ // return validate(obj)
}
diff --git a/vendor/github.com/gin-gonic/gin/binding/query.go b/vendor/github.com/gin-gonic/gin/binding/query.go
new file mode 100644
index 0000000000..219743f2a9
--- /dev/null
+++ b/vendor/github.com/gin-gonic/gin/binding/query.go
@@ -0,0 +1,21 @@
+// 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.
+
+package binding
+
+import "net/http"
+
+type queryBinding struct{}
+
+func (queryBinding) Name() string {
+ return "query"
+}
+
+func (queryBinding) Bind(req *http.Request, obj interface{}) error {
+ values := req.URL.Query()
+ if err := mapForm(obj, values); err != nil {
+ return err
+ }
+ return validate(obj)
+}
diff --git a/vendor/github.com/gin-gonic/gin/binding/xml.go b/vendor/github.com/gin-gonic/gin/binding/xml.go
index f84a6b7f1c..4e90114962 100644
--- a/vendor/github.com/gin-gonic/gin/binding/xml.go
+++ b/vendor/github.com/gin-gonic/gin/binding/xml.go
@@ -5,7 +5,9 @@
package binding
import (
+ "bytes"
"encoding/xml"
+ "io"
"net/http"
)
@@ -16,7 +18,14 @@ func (xmlBinding) Name() string {
}
func (xmlBinding) Bind(req *http.Request, obj interface{}) error {
- decoder := xml.NewDecoder(req.Body)
+ return decodeXML(req.Body, obj)
+}
+
+func (xmlBinding) BindBody(body []byte, obj interface{}) error {
+ return decodeXML(bytes.NewReader(body), obj)
+}
+func decodeXML(r io.Reader, obj interface{}) error {
+ decoder := xml.NewDecoder(r)
if err := decoder.Decode(obj); err != nil {
return err
}
diff --git a/vendor/github.com/gin-gonic/gin/json/json.go b/vendor/github.com/gin-gonic/gin/json/json.go
new file mode 100644
index 0000000000..aa76aa3098
--- /dev/null
+++ b/vendor/github.com/gin-gonic/gin/json/json.go
@@ -0,0 +1,15 @@
+// Copyright 2017 Bo-Yi Wu. All rights reserved.
+// Use of this source code is governed by a MIT style
+// license that can be found in the LICENSE file.
+
+// +build !jsoniter
+
+package json
+
+import "encoding/json"
+
+var (
+ Marshal = json.Marshal
+ MarshalIndent = json.MarshalIndent
+ NewDecoder = json.NewDecoder
+)
diff --git a/vendor/github.com/gin-gonic/gin/json/jsoniter.go b/vendor/github.com/gin-gonic/gin/json/jsoniter.go
new file mode 100644
index 0000000000..ffe1424acd
--- /dev/null
+++ b/vendor/github.com/gin-gonic/gin/json/jsoniter.go
@@ -0,0 +1,16 @@
+// Copyright 2017 Bo-Yi Wu. All rights reserved.
+// Use of this source code is governed by a MIT style
+// license that can be found in the LICENSE file.
+
+// +build jsoniter
+
+package json
+
+import "github.com/json-iterator/go"
+
+var (
+ json = jsoniter.ConfigCompatibleWithStandardLibrary
+ Marshal = json.Marshal
+ MarshalIndent = json.MarshalIndent
+ NewDecoder = json.NewDecoder
+)
diff --git a/vendor/github.com/gin-gonic/gin/render/data.go b/vendor/github.com/gin-gonic/gin/render/data.go
index c296042c92..3319491397 100644
--- a/vendor/github.com/gin-gonic/gin/render/data.go
+++ b/vendor/github.com/gin-gonic/gin/render/data.go
@@ -11,7 +11,7 @@ type Data struct {
Data []byte
}
-// Render (Data) writes data with custom ContentType
+// Render (Data) writes data with custom ContentType.
func (r Data) Render(w http.ResponseWriter) (err error) {
r.WriteContentType(w)
_, err = w.Write(r.Data)
diff --git a/vendor/github.com/gin-gonic/gin/render/html.go b/vendor/github.com/gin-gonic/gin/render/html.go
index cf91219cc5..1e3be65b9d 100644
--- a/vendor/github.com/gin-gonic/gin/render/html.go
+++ b/vendor/github.com/gin-gonic/gin/render/html.go
@@ -9,34 +9,32 @@ import (
"net/http"
)
-type (
- Delims struct {
- Left string
- Right string
- }
+type Delims struct {
+ Left string
+ Right string
+}
- HTMLRender interface {
- Instance(string, interface{}) Render
- }
+type HTMLRender interface {
+ Instance(string, interface{}) Render
+}
- HTMLProduction struct {
- Template *template.Template
- Delims Delims
- }
+type HTMLProduction struct {
+ Template *template.Template
+ Delims Delims
+}
- HTMLDebug struct {
- Files []string
- Glob string
- Delims Delims
- FuncMap template.FuncMap
- }
+type HTMLDebug struct {
+ Files []string
+ Glob string
+ Delims Delims
+ FuncMap template.FuncMap
+}
- HTML struct {
- Template *template.Template
- Name string
- Data interface{}
- }
-)
+type HTML struct {
+ Template *template.Template
+ Name string
+ Data interface{}
+}
var htmlContentType = []string{"text/html; charset=utf-8"}
@@ -62,7 +60,7 @@ func (r HTMLDebug) loadTemplate() *template.Template {
if len(r.Files) > 0 {
return template.Must(template.New("").Delims(r.Delims.Left, r.Delims.Right).Funcs(r.FuncMap).ParseFiles(r.Files...))
}
- if len(r.Glob) > 0 {
+ if r.Glob != "" {
return template.Must(template.New("").Delims(r.Delims.Left, r.Delims.Right).Funcs(r.FuncMap).ParseGlob(r.Glob))
}
panic("the HTML debug render was created without files or glob pattern")
@@ -71,7 +69,7 @@ func (r HTMLDebug) loadTemplate() *template.Template {
func (r HTML) Render(w http.ResponseWriter) error {
r.WriteContentType(w)
- if len(r.Name) == 0 {
+ if r.Name == "" {
return r.Template.Execute(w, r.Data)
}
return r.Template.ExecuteTemplate(w, r.Name, r.Data)
diff --git a/vendor/github.com/gin-gonic/gin/render/json.go b/vendor/github.com/gin-gonic/gin/render/json.go
old mode 100644
new mode 100755
index 3ee8b13268..6e5089a0c3
--- a/vendor/github.com/gin-gonic/gin/render/json.go
+++ b/vendor/github.com/gin-gonic/gin/render/json.go
@@ -5,21 +5,41 @@
package render
import (
- "encoding/json"
+ "bytes"
+ "fmt"
+ "html/template"
"net/http"
+
+ "github.com/gin-gonic/gin/json"
)
-type (
- JSON struct {
- Data interface{}
- }
+type JSON struct {
+ Data interface{}
+}
- IndentedJSON struct {
- Data interface{}
- }
-)
+type IndentedJSON struct {
+ Data interface{}
+}
+
+type SecureJSON struct {
+ Prefix string
+ Data interface{}
+}
+
+type JsonpJSON struct {
+ Callback string
+ Data interface{}
+}
+
+type AsciiJSON struct {
+ Data interface{}
+}
+
+type SecureJSONPrefix string
var jsonContentType = []string{"application/json; charset=utf-8"}
+var jsonpContentType = []string{"application/javascript; charset=utf-8"}
+var jsonAsciiContentType = []string{"application/json"}
func (r JSON) Render(w http.ResponseWriter) (err error) {
if err = WriteJSON(w, r.Data); err != nil {
@@ -55,3 +75,72 @@ func (r IndentedJSON) Render(w http.ResponseWriter) error {
func (r IndentedJSON) WriteContentType(w http.ResponseWriter) {
writeContentType(w, jsonContentType)
}
+
+func (r SecureJSON) Render(w http.ResponseWriter) error {
+ r.WriteContentType(w)
+ jsonBytes, err := json.Marshal(r.Data)
+ if err != nil {
+ return err
+ }
+ // if the jsonBytes is array values
+ if bytes.HasPrefix(jsonBytes, []byte("[")) && bytes.HasSuffix(jsonBytes, []byte("]")) {
+ w.Write([]byte(r.Prefix))
+ }
+ w.Write(jsonBytes)
+ return nil
+}
+
+func (r SecureJSON) WriteContentType(w http.ResponseWriter) {
+ writeContentType(w, jsonContentType)
+}
+
+func (r JsonpJSON) Render(w http.ResponseWriter) (err error) {
+ r.WriteContentType(w)
+ ret, err := json.Marshal(r.Data)
+ if err != nil {
+ return err
+ }
+
+ if r.Callback == "" {
+ w.Write(ret)
+ return nil
+ }
+
+ callback := template.JSEscapeString(r.Callback)
+ w.Write([]byte(callback))
+ w.Write([]byte("("))
+ w.Write(ret)
+ w.Write([]byte(")"))
+
+ return nil
+}
+
+func (r JsonpJSON) WriteContentType(w http.ResponseWriter) {
+ writeContentType(w, jsonpContentType)
+}
+
+func (r AsciiJSON) Render(w http.ResponseWriter) (err error) {
+ r.WriteContentType(w)
+ ret, err := json.Marshal(r.Data)
+ if err != nil {
+ return err
+ }
+
+ var buffer bytes.Buffer
+ for _, r := range string(ret) {
+ cvt := ""
+ if r < 128 {
+ cvt = string(r)
+ } else {
+ cvt = fmt.Sprintf("\\u%04x", int64(r))
+ }
+ buffer.WriteString(cvt)
+ }
+
+ w.Write(buffer.Bytes())
+ return nil
+}
+
+func (r AsciiJSON) WriteContentType(w http.ResponseWriter) {
+ writeContentType(w, jsonAsciiContentType)
+}
diff --git a/vendor/github.com/gin-gonic/gin/render/reader.go b/vendor/github.com/gin-gonic/gin/render/reader.go
new file mode 100644
index 0000000000..be2132c8fa
--- /dev/null
+++ b/vendor/github.com/gin-gonic/gin/render/reader.go
@@ -0,0 +1,36 @@
+package render
+
+import (
+ "io"
+ "net/http"
+ "strconv"
+)
+
+type Reader struct {
+ ContentType string
+ ContentLength int64
+ Reader io.Reader
+ Headers map[string]string
+}
+
+// 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)
+ r.writeHeaders(w, r.Headers)
+ _, err = io.Copy(w, r.Reader)
+ return
+}
+
+func (r Reader) WriteContentType(w http.ResponseWriter) {
+ writeContentType(w, []string{r.ContentType})
+}
+
+func (r Reader) writeHeaders(w http.ResponseWriter, headers map[string]string) {
+ header := w.Header()
+ for k, v := range headers {
+ if val := header[k]; len(val) == 0 {
+ header[k] = []string{v}
+ }
+ }
+}
diff --git a/vendor/github.com/gin-gonic/gin/render/redirect.go b/vendor/github.com/gin-gonic/gin/render/redirect.go
index f874a3515d..a0634f5a70 100644
--- a/vendor/github.com/gin-gonic/gin/render/redirect.go
+++ b/vendor/github.com/gin-gonic/gin/render/redirect.go
@@ -16,6 +16,8 @@ type Redirect struct {
}
func (r Redirect) Render(w http.ResponseWriter) error {
+ // todo(thinkerou): go1.6 not support StatusPermanentRedirect(308)
+ // when we upgrade go version we can use http.StatusPermanentRedirect
if (r.Code < 300 || r.Code > 308) && r.Code != 201 {
panic(fmt.Sprintf("Cannot redirect with status code %d", r.Code))
}
diff --git a/vendor/github.com/gin-gonic/gin/render/render.go b/vendor/github.com/gin-gonic/gin/render/render.go
old mode 100644
new mode 100755
index 462914214e..4ff1c7b637
--- a/vendor/github.com/gin-gonic/gin/render/render.go
+++ b/vendor/github.com/gin-gonic/gin/render/render.go
@@ -14,6 +14,8 @@ type Render interface {
var (
_ Render = JSON{}
_ Render = IndentedJSON{}
+ _ Render = SecureJSON{}
+ _ Render = JsonpJSON{}
_ Render = XML{}
_ Render = String{}
_ Render = Redirect{}
@@ -23,7 +25,8 @@ var (
_ HTMLRender = HTMLProduction{}
_ Render = YAML{}
_ Render = MsgPack{}
- _ Render = MsgPack{}
+ _ Render = Reader{}
+ _ Render = AsciiJSON{}
)
func writeContentType(w http.ResponseWriter, value []string) {
diff --git a/vendor/github.com/go-ini/ini/README.md b/vendor/github.com/go-ini/ini/README.md
index 988dceabac..ae4dfc3a5a 100644
--- a/vendor/github.com/go-ini/ini/README.md
+++ b/vendor/github.com/go-ini/ini/README.md
@@ -20,6 +20,8 @@ Package ini provides INI file read and write functionality in Go.
## Installation
+The minimum requirement of Go is **1.6**.
+
To use a tagged revision:
```sh
diff --git a/vendor/github.com/go-ini/ini/file.go b/vendor/github.com/go-ini/ini/file.go
index 1a3186b9f2..762e525518 100644
--- a/vendor/github.com/go-ini/ini/file.go
+++ b/vendor/github.com/go-ini/ini/file.go
@@ -227,7 +227,8 @@ func (f *File) Append(source interface{}, others ...interface{}) error {
}
func (f *File) writeToBuffer(indent string) (*bytes.Buffer, error) {
- equalSign := "="
+ equalSign := DefaultFormatLeft + "=" + DefaultFormatRight
+
if PrettyFormat || PrettyEqual {
equalSign = " = "
}
diff --git a/vendor/github.com/go-ini/ini/ini.go b/vendor/github.com/go-ini/ini/ini.go
index cb55997a3d..2920e01181 100644
--- a/vendor/github.com/go-ini/ini/ini.go
+++ b/vendor/github.com/go-ini/ini/ini.go
@@ -34,7 +34,7 @@ const (
// Maximum allowed depth when recursively substituing variable names.
_DEPTH_VALUES = 99
- _VERSION = "1.38.2"
+ _VERSION = "1.38.3"
)
// Version returns current package version literal.
@@ -48,6 +48,10 @@ var (
// at package init time.
LineBreak = "\n"
+ // Place custom spaces when PrettyFormat and PrettyEqual are both disabled
+ DefaultFormatLeft = ""
+ DefaultFormatRight = ""
+
// Variable regexp pattern: %(variable)s
varPattern = regexp.MustCompile(`%\(([^\)]+)\)s`)
diff --git a/vendor/github.com/gogo/protobuf/CONTRIBUTORS b/vendor/github.com/gogo/protobuf/CONTRIBUTORS
index 1b4f6c208a..b1abc4d305 100644
--- a/vendor/github.com/gogo/protobuf/CONTRIBUTORS
+++ b/vendor/github.com/gogo/protobuf/CONTRIBUTORS
@@ -11,7 +11,6 @@ John Shahid
John Tuley
Laurent
Patrick Lee
-Peter Edge
Roger Johansson
Sam Nguyen
Sergio Arbeo
diff --git a/vendor/github.com/gogo/protobuf/proto/Makefile b/vendor/github.com/gogo/protobuf/proto/Makefile
index 00d65f3277..41c717573e 100644
--- a/vendor/github.com/gogo/protobuf/proto/Makefile
+++ b/vendor/github.com/gogo/protobuf/proto/Makefile
@@ -38,6 +38,6 @@ test: install generate-test-pbs
generate-test-pbs:
make install
- make -C test_proto
- make -C proto3_proto
+ make -C testdata
+ protoc-min-version --version="3.0.0" --proto_path=.:../../../../:../protobuf --gogo_out=Mtestdata/test.proto=github.com/gogo/protobuf/proto/testdata,Mgoogle/protobuf/any.proto=github.com/gogo/protobuf/types:. proto3_proto/proto3.proto
make
diff --git a/vendor/github.com/gogo/protobuf/proto/clone.go b/vendor/github.com/gogo/protobuf/proto/clone.go
index a26b046d94..5d4cba4b51 100644
--- a/vendor/github.com/gogo/protobuf/proto/clone.go
+++ b/vendor/github.com/gogo/protobuf/proto/clone.go
@@ -35,39 +35,22 @@
package proto
import (
- "fmt"
"log"
"reflect"
"strings"
)
// Clone returns a deep copy of a protocol buffer.
-func Clone(src Message) Message {
- in := reflect.ValueOf(src)
+func Clone(pb Message) Message {
+ in := reflect.ValueOf(pb)
if in.IsNil() {
- return src
+ return pb
}
+
out := reflect.New(in.Type().Elem())
- dst := out.Interface().(Message)
- Merge(dst, src)
- return dst
-}
-
-// Merger is the interface representing objects that can merge messages of the same type.
-type Merger interface {
- // Merge merges src into this message.
- // Required and optional fields that are set in src will be set to that value in dst.
- // Elements of repeated fields will be appended.
- //
- // Merge may panic if called with a different argument type than the receiver.
- Merge(src Message)
-}
-
-// generatedMerger is the custom merge method that generated protos will have.
-// We must add this method since a generate Merge method will conflict with
-// many existing protos that have a Merge data field already defined.
-type generatedMerger interface {
- XXX_Merge(src Message)
+ // out is empty so a merge is a deep copy.
+ mergeStruct(out.Elem(), in.Elem())
+ return out.Interface().(Message)
}
// Merge merges src into dst.
@@ -75,24 +58,17 @@ type generatedMerger interface {
// Elements of repeated fields will be appended.
// Merge panics if src and dst are not the same type, or if dst is nil.
func Merge(dst, src Message) {
- if m, ok := dst.(Merger); ok {
- m.Merge(src)
- return
- }
-
in := reflect.ValueOf(src)
out := reflect.ValueOf(dst)
if out.IsNil() {
panic("proto: nil destination")
}
if in.Type() != out.Type() {
- panic(fmt.Sprintf("proto.Merge(%T, %T) type mismatch", dst, src))
+ // Explicit test prior to mergeStruct so that mistyped nils will fail
+ panic("proto: type mismatch")
}
if in.IsNil() {
- return // Merge from nil src is a noop
- }
- if m, ok := dst.(generatedMerger); ok {
- m.XXX_Merge(src)
+ // Merging nil into non-nil is a quiet no-op
return
}
mergeStruct(out.Elem(), in.Elem())
@@ -113,7 +89,7 @@ func mergeStruct(out, in reflect.Value) {
bIn := emIn.GetExtensions()
bOut := emOut.GetExtensions()
*bOut = append(*bOut, *bIn...)
- } else if emIn, err := extendable(in.Addr().Interface()); err == nil {
+ } else if emIn, ok := extendable(in.Addr().Interface()); ok {
emOut, _ := extendable(out.Addr().Interface())
mIn, muIn := emIn.extensionsRead()
if mIn != nil {
diff --git a/vendor/github.com/gogo/protobuf/proto/custom_gogo.go b/vendor/github.com/gogo/protobuf/proto/custom_gogo.go
deleted file mode 100644
index 24552483c6..0000000000
--- a/vendor/github.com/gogo/protobuf/proto/custom_gogo.go
+++ /dev/null
@@ -1,39 +0,0 @@
-// Protocol Buffers for Go with Gadgets
-//
-// Copyright (c) 2018, The GoGo Authors. All rights reserved.
-// http://github.com/gogo/protobuf
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-package proto
-
-import "reflect"
-
-type custom interface {
- Marshal() ([]byte, error)
- Unmarshal(data []byte) error
- Size() int
-}
-
-var customType = reflect.TypeOf((*custom)(nil)).Elem()
diff --git a/vendor/github.com/gogo/protobuf/proto/decode.go b/vendor/github.com/gogo/protobuf/proto/decode.go
index d9aa3c42d6..737f2731d4 100644
--- a/vendor/github.com/gogo/protobuf/proto/decode.go
+++ b/vendor/github.com/gogo/protobuf/proto/decode.go
@@ -39,6 +39,8 @@ import (
"errors"
"fmt"
"io"
+ "os"
+ "reflect"
)
// errOverflow is returned when an integer is too large to be represented.
@@ -48,6 +50,10 @@ var errOverflow = errors.New("proto: integer overflow")
// wire type is encountered. It does not get returned to user code.
var ErrInternalBadWireType = errors.New("proto: internal error: bad wiretype for oneof")
+// The fundamental decoders that interpret bytes on the wire.
+// Those that take integer types all return uint64 and are
+// therefore of type valueDecoder.
+
// DecodeVarint reads a varint-encoded integer from the slice.
// It returns the integer and the number of bytes consumed, or
// zero if there is not enough.
@@ -261,6 +267,9 @@ func (p *Buffer) DecodeZigzag32() (x uint64, err error) {
return
}
+// These are not ValueDecoders: they produce an array of bytes or a string.
+// bytes, embedded messages
+
// DecodeRawBytes reads a count-delimited byte buffer from the Buffer.
// This is the format used for the bytes protocol buffer
// type and for embedded messages.
@@ -302,27 +311,79 @@ func (p *Buffer) DecodeStringBytes() (s string, err error) {
return string(buf), nil
}
-// Unmarshaler is the interface representing objects that can
-// unmarshal themselves. The argument points to data that may be
-// overwritten, so implementations should not keep references to the
-// buffer.
-// Unmarshal implementations should not clear the receiver.
-// Any unmarshaled data should be merged into the receiver.
-// Callers of Unmarshal that do not want to retain existing data
-// should Reset the receiver before calling Unmarshal.
-type Unmarshaler interface {
- Unmarshal([]byte) error
+// Skip the next item in the buffer. Its wire type is decoded and presented as an argument.
+// If the protocol buffer has extensions, and the field matches, add it as an extension.
+// Otherwise, if the XXX_unrecognized field exists, append the skipped data there.
+func (o *Buffer) skipAndSave(t reflect.Type, tag, wire int, base structPointer, unrecField field) error {
+ oi := o.index
+
+ err := o.skip(t, tag, wire)
+ if err != nil {
+ return err
+ }
+
+ if !unrecField.IsValid() {
+ return nil
+ }
+
+ ptr := structPointer_Bytes(base, unrecField)
+
+ // Add the skipped field to struct field
+ obuf := o.buf
+
+ o.buf = *ptr
+ o.EncodeVarint(uint64(tag<<3 | wire))
+ *ptr = append(o.buf, obuf[oi:o.index]...)
+
+ o.buf = obuf
+
+ return nil
}
-// newUnmarshaler is the interface representing objects that can
-// unmarshal themselves. The semantics are identical to Unmarshaler.
-//
-// This exists to support protoc-gen-go generated messages.
-// The proto package will stop type-asserting to this interface in the future.
-//
-// DO NOT DEPEND ON THIS.
-type newUnmarshaler interface {
- XXX_Unmarshal([]byte) error
+// Skip the next item in the buffer. Its wire type is decoded and presented as an argument.
+func (o *Buffer) skip(t reflect.Type, tag, wire int) error {
+
+ var u uint64
+ var err error
+
+ switch wire {
+ case WireVarint:
+ _, err = o.DecodeVarint()
+ case WireFixed64:
+ _, err = o.DecodeFixed64()
+ case WireBytes:
+ _, err = o.DecodeRawBytes(false)
+ case WireFixed32:
+ _, err = o.DecodeFixed32()
+ case WireStartGroup:
+ for {
+ u, err = o.DecodeVarint()
+ if err != nil {
+ break
+ }
+ fwire := int(u & 0x7)
+ if fwire == WireEndGroup {
+ break
+ }
+ ftag := int(u >> 3)
+ err = o.skip(t, ftag, fwire)
+ if err != nil {
+ break
+ }
+ }
+ default:
+ err = fmt.Errorf("proto: can't skip unknown wire type %d for %s", wire, t)
+ }
+ return err
+}
+
+// Unmarshaler is the interface representing objects that can
+// unmarshal themselves. The method should reset the receiver before
+// decoding starts. The argument points to data that may be
+// overwritten, so implementations should not keep references to the
+// buffer.
+type Unmarshaler interface {
+ Unmarshal([]byte) error
}
// Unmarshal parses the protocol buffer representation in buf and places the
@@ -334,13 +395,7 @@ type newUnmarshaler interface {
// to preserve and append to existing data.
func Unmarshal(buf []byte, pb Message) error {
pb.Reset()
- if u, ok := pb.(newUnmarshaler); ok {
- return u.XXX_Unmarshal(buf)
- }
- if u, ok := pb.(Unmarshaler); ok {
- return u.Unmarshal(buf)
- }
- return NewBuffer(buf).Unmarshal(pb)
+ return UnmarshalMerge(buf, pb)
}
// UnmarshalMerge parses the protocol buffer representation in buf and
@@ -350,16 +405,8 @@ func Unmarshal(buf []byte, pb Message) error {
// UnmarshalMerge merges into existing data in pb.
// Most code should use Unmarshal instead.
func UnmarshalMerge(buf []byte, pb Message) error {
- if u, ok := pb.(newUnmarshaler); ok {
- return u.XXX_Unmarshal(buf)
- }
+ // If the object can unmarshal itself, let it.
if u, ok := pb.(Unmarshaler); ok {
- // NOTE: The history of proto have unfortunately been inconsistent
- // whether Unmarshaler should or should not implicitly clear itself.
- // Some implementations do, most do not.
- // Thus, calling this here may or may not do what people want.
- //
- // See https://github.com/golang/protobuf/issues/424
return u.Unmarshal(buf)
}
return NewBuffer(buf).Unmarshal(pb)
@@ -375,17 +422,12 @@ func (p *Buffer) DecodeMessage(pb Message) error {
}
// DecodeGroup reads a tag-delimited group from the Buffer.
-// StartGroup tag is already consumed. This function consumes
-// EndGroup tag.
func (p *Buffer) DecodeGroup(pb Message) error {
- b := p.buf[p.index:]
- x, y := findEndGroup(b)
- if x < 0 {
- return io.ErrUnexpectedEOF
+ typ, base, err := getbase(pb)
+ if err != nil {
+ return err
}
- err := Unmarshal(b[:x], pb)
- p.index += y
- return err
+ return p.unmarshalType(typ.Elem(), GetProperties(typ.Elem()), true, base)
}
// Unmarshal parses the protocol buffer representation in the
@@ -396,33 +438,541 @@ func (p *Buffer) DecodeGroup(pb Message) error {
// Unlike proto.Unmarshal, this does not reset pb before starting to unmarshal.
func (p *Buffer) Unmarshal(pb Message) error {
// If the object can unmarshal itself, let it.
- if u, ok := pb.(newUnmarshaler); ok {
- err := u.XXX_Unmarshal(p.buf[p.index:])
- p.index = len(p.buf)
- return err
- }
if u, ok := pb.(Unmarshaler); ok {
- // NOTE: The history of proto have unfortunately been inconsistent
- // whether Unmarshaler should or should not implicitly clear itself.
- // Some implementations do, most do not.
- // Thus, calling this here may or may not do what people want.
- //
- // See https://github.com/golang/protobuf/issues/424
err := u.Unmarshal(p.buf[p.index:])
p.index = len(p.buf)
return err
}
- // Slow workaround for messages that aren't Unmarshalers.
- // This includes some hand-coded .pb.go files and
- // bootstrap protos.
- // TODO: fix all of those and then add Unmarshal to
- // the Message interface. Then:
- // The cast above and code below can be deleted.
- // The old unmarshaler can be deleted.
- // Clients can call Unmarshal directly (can already do that, actually).
- var info InternalMessageInfo
- err := info.Unmarshal(pb, p.buf[p.index:])
- p.index = len(p.buf)
+ typ, base, err := getbase(pb)
+ if err != nil {
+ return err
+ }
+
+ err = p.unmarshalType(typ.Elem(), GetProperties(typ.Elem()), false, base)
+
+ if collectStats {
+ stats.Decode++
+ }
+
+ return err
+}
+
+// unmarshalType does the work of unmarshaling a structure.
+func (o *Buffer) unmarshalType(st reflect.Type, prop *StructProperties, is_group bool, base structPointer) error {
+ var state errorState
+ required, reqFields := prop.reqCount, uint64(0)
+
+ var err error
+ for err == nil && o.index < len(o.buf) {
+ oi := o.index
+ var u uint64
+ u, err = o.DecodeVarint()
+ if err != nil {
+ break
+ }
+ wire := int(u & 0x7)
+ if wire == WireEndGroup {
+ if is_group {
+ if required > 0 {
+ // Not enough information to determine the exact field.
+ // (See below.)
+ return &RequiredNotSetError{"{Unknown}"}
+ }
+ return nil // input is satisfied
+ }
+ return fmt.Errorf("proto: %s: wiretype end group for non-group", st)
+ }
+ tag := int(u >> 3)
+ if tag <= 0 {
+ return fmt.Errorf("proto: %s: illegal tag %d (wire type %d)", st, tag, wire)
+ }
+ fieldnum, ok := prop.decoderTags.get(tag)
+ if !ok {
+ // Maybe it's an extension?
+ if prop.extendable {
+ if e, eok := structPointer_Interface(base, st).(extensionsBytes); eok {
+ if isExtensionField(e, int32(tag)) {
+ if err = o.skip(st, tag, wire); err == nil {
+ ext := e.GetExtensions()
+ *ext = append(*ext, o.buf[oi:o.index]...)
+ }
+ continue
+ }
+ } else if e, _ := extendable(structPointer_Interface(base, st)); isExtensionField(e, int32(tag)) {
+ if err = o.skip(st, tag, wire); err == nil {
+ extmap := e.extensionsWrite()
+ ext := extmap[int32(tag)] // may be missing
+ ext.enc = append(ext.enc, o.buf[oi:o.index]...)
+ extmap[int32(tag)] = ext
+ }
+ continue
+ }
+ }
+ // Maybe it's a oneof?
+ if prop.oneofUnmarshaler != nil {
+ m := structPointer_Interface(base, st).(Message)
+ // First return value indicates whether tag is a oneof field.
+ ok, err = prop.oneofUnmarshaler(m, tag, wire, o)
+ if err == ErrInternalBadWireType {
+ // Map the error to something more descriptive.
+ // Do the formatting here to save generated code space.
+ err = fmt.Errorf("bad wiretype for oneof field in %T", m)
+ }
+ if ok {
+ continue
+ }
+ }
+ err = o.skipAndSave(st, tag, wire, base, prop.unrecField)
+ continue
+ }
+ p := prop.Prop[fieldnum]
+
+ if p.dec == nil {
+ fmt.Fprintf(os.Stderr, "proto: no protobuf decoder for %s.%s\n", st, st.Field(fieldnum).Name)
+ continue
+ }
+ dec := p.dec
+ if wire != WireStartGroup && wire != p.WireType {
+ if wire == WireBytes && p.packedDec != nil {
+ // a packable field
+ dec = p.packedDec
+ } else {
+ err = fmt.Errorf("proto: bad wiretype for field %s.%s: got wiretype %d, want %d", st, st.Field(fieldnum).Name, wire, p.WireType)
+ continue
+ }
+ }
+ decErr := dec(o, p, base)
+ if decErr != nil && !state.shouldContinue(decErr, p) {
+ err = decErr
+ }
+ if err == nil && p.Required {
+ // Successfully decoded a required field.
+ if tag <= 64 {
+ // use bitmap for fields 1-64 to catch field reuse.
+ var mask uint64 = 1 << uint64(tag-1)
+ if reqFields&mask == 0 {
+ // new required field
+ reqFields |= mask
+ required--
+ }
+ } else {
+ // This is imprecise. It can be fooled by a required field
+ // with a tag > 64 that is encoded twice; that's very rare.
+ // A fully correct implementation would require allocating
+ // a data structure, which we would like to avoid.
+ required--
+ }
+ }
+ }
+ if err == nil {
+ if is_group {
+ return io.ErrUnexpectedEOF
+ }
+ if state.err != nil {
+ return state.err
+ }
+ if required > 0 {
+ // Not enough information to determine the exact field. If we use extra
+ // CPU, we could determine the field only if the missing required field
+ // has a tag <= 64 and we check reqFields.
+ return &RequiredNotSetError{"{Unknown}"}
+ }
+ }
+ return err
+}
+
+// Individual type decoders
+// For each,
+// u is the decoded value,
+// v is a pointer to the field (pointer) in the struct
+
+// Sizes of the pools to allocate inside the Buffer.
+// The goal is modest amortization and allocation
+// on at least 16-byte boundaries.
+const (
+ boolPoolSize = 16
+ uint32PoolSize = 8
+ uint64PoolSize = 4
+)
+
+// Decode a bool.
+func (o *Buffer) dec_bool(p *Properties, base structPointer) error {
+ u, err := p.valDec(o)
+ if err != nil {
+ return err
+ }
+ if len(o.bools) == 0 {
+ o.bools = make([]bool, boolPoolSize)
+ }
+ o.bools[0] = u != 0
+ *structPointer_Bool(base, p.field) = &o.bools[0]
+ o.bools = o.bools[1:]
+ return nil
+}
+
+func (o *Buffer) dec_proto3_bool(p *Properties, base structPointer) error {
+ u, err := p.valDec(o)
+ if err != nil {
+ return err
+ }
+ *structPointer_BoolVal(base, p.field) = u != 0
+ return nil
+}
+
+// Decode an int32.
+func (o *Buffer) dec_int32(p *Properties, base structPointer) error {
+ u, err := p.valDec(o)
+ if err != nil {
+ return err
+ }
+ word32_Set(structPointer_Word32(base, p.field), o, uint32(u))
+ return nil
+}
+
+func (o *Buffer) dec_proto3_int32(p *Properties, base structPointer) error {
+ u, err := p.valDec(o)
+ if err != nil {
+ return err
+ }
+ word32Val_Set(structPointer_Word32Val(base, p.field), uint32(u))
+ return nil
+}
+
+// Decode an int64.
+func (o *Buffer) dec_int64(p *Properties, base structPointer) error {
+ u, err := p.valDec(o)
+ if err != nil {
+ return err
+ }
+ word64_Set(structPointer_Word64(base, p.field), o, u)
+ return nil
+}
+
+func (o *Buffer) dec_proto3_int64(p *Properties, base structPointer) error {
+ u, err := p.valDec(o)
+ if err != nil {
+ return err
+ }
+ word64Val_Set(structPointer_Word64Val(base, p.field), o, u)
+ return nil
+}
+
+// Decode a string.
+func (o *Buffer) dec_string(p *Properties, base structPointer) error {
+ s, err := o.DecodeStringBytes()
+ if err != nil {
+ return err
+ }
+ *structPointer_String(base, p.field) = &s
+ return nil
+}
+
+func (o *Buffer) dec_proto3_string(p *Properties, base structPointer) error {
+ s, err := o.DecodeStringBytes()
+ if err != nil {
+ return err
+ }
+ *structPointer_StringVal(base, p.field) = s
+ return nil
+}
+
+// Decode a slice of bytes ([]byte).
+func (o *Buffer) dec_slice_byte(p *Properties, base structPointer) error {
+ b, err := o.DecodeRawBytes(true)
+ if err != nil {
+ return err
+ }
+ *structPointer_Bytes(base, p.field) = b
+ return nil
+}
+
+// Decode a slice of bools ([]bool).
+func (o *Buffer) dec_slice_bool(p *Properties, base structPointer) error {
+ u, err := p.valDec(o)
+ if err != nil {
+ return err
+ }
+ v := structPointer_BoolSlice(base, p.field)
+ *v = append(*v, u != 0)
+ return nil
+}
+
+// Decode a slice of bools ([]bool) in packed format.
+func (o *Buffer) dec_slice_packed_bool(p *Properties, base structPointer) error {
+ v := structPointer_BoolSlice(base, p.field)
+
+ nn, err := o.DecodeVarint()
+ if err != nil {
+ return err
+ }
+ nb := int(nn) // number of bytes of encoded bools
+ fin := o.index + nb
+ if fin < o.index {
+ return errOverflow
+ }
+
+ y := *v
+ for o.index < fin {
+ u, err := p.valDec(o)
+ if err != nil {
+ return err
+ }
+ y = append(y, u != 0)
+ }
+
+ *v = y
+ return nil
+}
+
+// Decode a slice of int32s ([]int32).
+func (o *Buffer) dec_slice_int32(p *Properties, base structPointer) error {
+ u, err := p.valDec(o)
+ if err != nil {
+ return err
+ }
+ structPointer_Word32Slice(base, p.field).Append(uint32(u))
+ return nil
+}
+
+// Decode a slice of int32s ([]int32) in packed format.
+func (o *Buffer) dec_slice_packed_int32(p *Properties, base structPointer) error {
+ v := structPointer_Word32Slice(base, p.field)
+
+ nn, err := o.DecodeVarint()
+ if err != nil {
+ return err
+ }
+ nb := int(nn) // number of bytes of encoded int32s
+
+ fin := o.index + nb
+ if fin < o.index {
+ return errOverflow
+ }
+ for o.index < fin {
+ u, err := p.valDec(o)
+ if err != nil {
+ return err
+ }
+ v.Append(uint32(u))
+ }
+ return nil
+}
+
+// Decode a slice of int64s ([]int64).
+func (o *Buffer) dec_slice_int64(p *Properties, base structPointer) error {
+ u, err := p.valDec(o)
+ if err != nil {
+ return err
+ }
+
+ structPointer_Word64Slice(base, p.field).Append(u)
+ return nil
+}
+
+// Decode a slice of int64s ([]int64) in packed format.
+func (o *Buffer) dec_slice_packed_int64(p *Properties, base structPointer) error {
+ v := structPointer_Word64Slice(base, p.field)
+
+ nn, err := o.DecodeVarint()
+ if err != nil {
+ return err
+ }
+ nb := int(nn) // number of bytes of encoded int64s
+
+ fin := o.index + nb
+ if fin < o.index {
+ return errOverflow
+ }
+ for o.index < fin {
+ u, err := p.valDec(o)
+ if err != nil {
+ return err
+ }
+ v.Append(u)
+ }
+ return nil
+}
+
+// Decode a slice of strings ([]string).
+func (o *Buffer) dec_slice_string(p *Properties, base structPointer) error {
+ s, err := o.DecodeStringBytes()
+ if err != nil {
+ return err
+ }
+ v := structPointer_StringSlice(base, p.field)
+ *v = append(*v, s)
+ return nil
+}
+
+// Decode a slice of slice of bytes ([][]byte).
+func (o *Buffer) dec_slice_slice_byte(p *Properties, base structPointer) error {
+ b, err := o.DecodeRawBytes(true)
+ if err != nil {
+ return err
+ }
+ v := structPointer_BytesSlice(base, p.field)
+ *v = append(*v, b)
+ return nil
+}
+
+// Decode a map field.
+func (o *Buffer) dec_new_map(p *Properties, base structPointer) error {
+ raw, err := o.DecodeRawBytes(false)
+ if err != nil {
+ return err
+ }
+ oi := o.index // index at the end of this map entry
+ o.index -= len(raw) // move buffer back to start of map entry
+
+ mptr := structPointer_NewAt(base, p.field, p.mtype) // *map[K]V
+ if mptr.Elem().IsNil() {
+ mptr.Elem().Set(reflect.MakeMap(mptr.Type().Elem()))
+ }
+ v := mptr.Elem() // map[K]V
+
+ // Prepare addressable doubly-indirect placeholders for the key and value types.
+ // See enc_new_map for why.
+ keyptr := reflect.New(reflect.PtrTo(p.mtype.Key())).Elem() // addressable *K
+ keybase := toStructPointer(keyptr.Addr()) // **K
+
+ var valbase structPointer
+ var valptr reflect.Value
+ switch p.mtype.Elem().Kind() {
+ case reflect.Slice:
+ // []byte
+ var dummy []byte
+ valptr = reflect.ValueOf(&dummy) // *[]byte
+ valbase = toStructPointer(valptr) // *[]byte
+ case reflect.Ptr:
+ // message; valptr is **Msg; need to allocate the intermediate pointer
+ valptr = reflect.New(reflect.PtrTo(p.mtype.Elem())).Elem() // addressable *V
+ valptr.Set(reflect.New(valptr.Type().Elem()))
+ valbase = toStructPointer(valptr)
+ default:
+ // everything else
+ valptr = reflect.New(reflect.PtrTo(p.mtype.Elem())).Elem() // addressable *V
+ valbase = toStructPointer(valptr.Addr()) // **V
+ }
+
+ // Decode.
+ // This parses a restricted wire format, namely the encoding of a message
+ // with two fields. See enc_new_map for the format.
+ for o.index < oi {
+ // tagcode for key and value properties are always a single byte
+ // because they have tags 1 and 2.
+ tagcode := o.buf[o.index]
+ o.index++
+ switch tagcode {
+ case p.mkeyprop.tagcode[0]:
+ if err := p.mkeyprop.dec(o, p.mkeyprop, keybase); err != nil {
+ return err
+ }
+ case p.mvalprop.tagcode[0]:
+ if err := p.mvalprop.dec(o, p.mvalprop, valbase); err != nil {
+ return err
+ }
+ default:
+ // TODO: Should we silently skip this instead?
+ return fmt.Errorf("proto: bad map data tag %d", raw[0])
+ }
+ }
+ keyelem, valelem := keyptr.Elem(), valptr.Elem()
+ if !keyelem.IsValid() {
+ keyelem = reflect.Zero(p.mtype.Key())
+ }
+ if !valelem.IsValid() {
+ valelem = reflect.Zero(p.mtype.Elem())
+ }
+
+ v.SetMapIndex(keyelem, valelem)
+ return nil
+}
+
+// Decode a group.
+func (o *Buffer) dec_struct_group(p *Properties, base structPointer) error {
+ bas := structPointer_GetStructPointer(base, p.field)
+ if structPointer_IsNil(bas) {
+ // allocate new nested message
+ bas = toStructPointer(reflect.New(p.stype))
+ structPointer_SetStructPointer(base, p.field, bas)
+ }
+ return o.unmarshalType(p.stype, p.sprop, true, bas)
+}
+
+// Decode an embedded message.
+func (o *Buffer) dec_struct_message(p *Properties, base structPointer) (err error) {
+ raw, e := o.DecodeRawBytes(false)
+ if e != nil {
+ return e
+ }
+
+ bas := structPointer_GetStructPointer(base, p.field)
+ if structPointer_IsNil(bas) {
+ // allocate new nested message
+ bas = toStructPointer(reflect.New(p.stype))
+ structPointer_SetStructPointer(base, p.field, bas)
+ }
+
+ // If the object can unmarshal itself, let it.
+ if p.isUnmarshaler {
+ iv := structPointer_Interface(bas, p.stype)
+ return iv.(Unmarshaler).Unmarshal(raw)
+ }
+
+ obuf := o.buf
+ oi := o.index
+ o.buf = raw
+ o.index = 0
+
+ err = o.unmarshalType(p.stype, p.sprop, false, bas)
+ o.buf = obuf
+ o.index = oi
+
+ return err
+}
+
+// Decode a slice of embedded messages.
+func (o *Buffer) dec_slice_struct_message(p *Properties, base structPointer) error {
+ return o.dec_slice_struct(p, false, base)
+}
+
+// Decode a slice of embedded groups.
+func (o *Buffer) dec_slice_struct_group(p *Properties, base structPointer) error {
+ return o.dec_slice_struct(p, true, base)
+}
+
+// Decode a slice of structs ([]*struct).
+func (o *Buffer) dec_slice_struct(p *Properties, is_group bool, base structPointer) error {
+ v := reflect.New(p.stype)
+ bas := toStructPointer(v)
+ structPointer_StructPointerSlice(base, p.field).Append(bas)
+
+ if is_group {
+ err := o.unmarshalType(p.stype, p.sprop, is_group, bas)
+ return err
+ }
+
+ raw, err := o.DecodeRawBytes(false)
+ if err != nil {
+ return err
+ }
+
+ // If the object can unmarshal itself, let it.
+ if p.isUnmarshaler {
+ iv := v.Interface()
+ return iv.(Unmarshaler).Unmarshal(raw)
+ }
+
+ obuf := o.buf
+ oi := o.index
+ o.buf = raw
+ o.index = 0
+
+ err = o.unmarshalType(p.stype, p.sprop, is_group, bas)
+
+ o.buf = obuf
+ o.index = oi
+
return err
}
diff --git a/vendor/github.com/gogo/protobuf/proto/decode_gogo.go b/vendor/github.com/gogo/protobuf/proto/decode_gogo.go
new file mode 100644
index 0000000000..6fb74de4cc
--- /dev/null
+++ b/vendor/github.com/gogo/protobuf/proto/decode_gogo.go
@@ -0,0 +1,172 @@
+// Protocol Buffers for Go with Gadgets
+//
+// Copyright (c) 2013, The GoGo Authors. All rights reserved.
+// http://github.com/gogo/protobuf
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+package proto
+
+import (
+ "reflect"
+)
+
+// Decode a reference to a struct pointer.
+func (o *Buffer) dec_ref_struct_message(p *Properties, base structPointer) (err error) {
+ raw, e := o.DecodeRawBytes(false)
+ if e != nil {
+ return e
+ }
+
+ // If the object can unmarshal itself, let it.
+ if p.isUnmarshaler {
+ panic("not supported, since this is a pointer receiver")
+ }
+
+ obuf := o.buf
+ oi := o.index
+ o.buf = raw
+ o.index = 0
+
+ bas := structPointer_FieldPointer(base, p.field)
+
+ err = o.unmarshalType(p.stype, p.sprop, false, bas)
+ o.buf = obuf
+ o.index = oi
+
+ return err
+}
+
+// Decode a slice of references to struct pointers ([]struct).
+func (o *Buffer) dec_slice_ref_struct(p *Properties, is_group bool, base structPointer) error {
+ newBas := appendStructPointer(base, p.field, p.sstype)
+
+ if is_group {
+ panic("not supported, maybe in future, if requested.")
+ }
+
+ raw, err := o.DecodeRawBytes(false)
+ if err != nil {
+ return err
+ }
+
+ // If the object can unmarshal itself, let it.
+ if p.isUnmarshaler {
+ panic("not supported, since this is not a pointer receiver.")
+ }
+
+ obuf := o.buf
+ oi := o.index
+ o.buf = raw
+ o.index = 0
+
+ err = o.unmarshalType(p.stype, p.sprop, is_group, newBas)
+
+ o.buf = obuf
+ o.index = oi
+
+ return err
+}
+
+// Decode a slice of references to struct pointers.
+func (o *Buffer) dec_slice_ref_struct_message(p *Properties, base structPointer) error {
+ return o.dec_slice_ref_struct(p, false, base)
+}
+
+func setPtrCustomType(base structPointer, f field, v interface{}) {
+ if v == nil {
+ return
+ }
+ structPointer_SetStructPointer(base, f, toStructPointer(reflect.ValueOf(v)))
+}
+
+func setCustomType(base structPointer, f field, value interface{}) {
+ if value == nil {
+ return
+ }
+ v := reflect.ValueOf(value).Elem()
+ t := reflect.TypeOf(value).Elem()
+ kind := t.Kind()
+ switch kind {
+ case reflect.Slice:
+ slice := reflect.MakeSlice(t, v.Len(), v.Cap())
+ reflect.Copy(slice, v)
+ oldHeader := structPointer_GetSliceHeader(base, f)
+ oldHeader.Data = slice.Pointer()
+ oldHeader.Len = v.Len()
+ oldHeader.Cap = v.Cap()
+ default:
+ size := reflect.TypeOf(value).Elem().Size()
+ structPointer_Copy(toStructPointer(reflect.ValueOf(value)), structPointer_Add(base, f), int(size))
+ }
+}
+
+func (o *Buffer) dec_custom_bytes(p *Properties, base structPointer) error {
+ b, err := o.DecodeRawBytes(true)
+ if err != nil {
+ return err
+ }
+ i := reflect.New(p.ctype.Elem()).Interface()
+ custom := (i).(Unmarshaler)
+ if err := custom.Unmarshal(b); err != nil {
+ return err
+ }
+ setPtrCustomType(base, p.field, custom)
+ return nil
+}
+
+func (o *Buffer) dec_custom_ref_bytes(p *Properties, base structPointer) error {
+ b, err := o.DecodeRawBytes(true)
+ if err != nil {
+ return err
+ }
+ i := reflect.New(p.ctype).Interface()
+ custom := (i).(Unmarshaler)
+ if err := custom.Unmarshal(b); err != nil {
+ return err
+ }
+ if custom != nil {
+ setCustomType(base, p.field, custom)
+ }
+ return nil
+}
+
+// Decode a slice of bytes ([]byte) into a slice of custom types.
+func (o *Buffer) dec_custom_slice_bytes(p *Properties, base structPointer) error {
+ b, err := o.DecodeRawBytes(true)
+ if err != nil {
+ return err
+ }
+ i := reflect.New(p.ctype.Elem()).Interface()
+ custom := (i).(Unmarshaler)
+ if err := custom.Unmarshal(b); err != nil {
+ return err
+ }
+ newBas := appendStructPointer(base, p.field, p.ctype)
+
+ var zero field
+ setCustomType(newBas, zero, custom)
+
+ return nil
+}
diff --git a/vendor/github.com/gogo/protobuf/proto/discard.go b/vendor/github.com/gogo/protobuf/proto/discard.go
deleted file mode 100644
index fe1bd7d904..0000000000
--- a/vendor/github.com/gogo/protobuf/proto/discard.go
+++ /dev/null
@@ -1,350 +0,0 @@
-// Go support for Protocol Buffers - Google's data interchange format
-//
-// Copyright 2017 The Go Authors. All rights reserved.
-// https://github.com/golang/protobuf
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-package proto
-
-import (
- "fmt"
- "reflect"
- "strings"
- "sync"
- "sync/atomic"
-)
-
-type generatedDiscarder interface {
- XXX_DiscardUnknown()
-}
-
-// DiscardUnknown recursively discards all unknown fields from this message
-// and all embedded messages.
-//
-// When unmarshaling a message with unrecognized fields, the tags and values
-// of such fields are preserved in the Message. This allows a later call to
-// marshal to be able to produce a message that continues to have those
-// unrecognized fields. To avoid this, DiscardUnknown is used to
-// explicitly clear the unknown fields after unmarshaling.
-//
-// For proto2 messages, the unknown fields of message extensions are only
-// discarded from messages that have been accessed via GetExtension.
-func DiscardUnknown(m Message) {
- if m, ok := m.(generatedDiscarder); ok {
- m.XXX_DiscardUnknown()
- return
- }
- // TODO: Dynamically populate a InternalMessageInfo for legacy messages,
- // but the master branch has no implementation for InternalMessageInfo,
- // so it would be more work to replicate that approach.
- discardLegacy(m)
-}
-
-// DiscardUnknown recursively discards all unknown fields.
-func (a *InternalMessageInfo) DiscardUnknown(m Message) {
- di := atomicLoadDiscardInfo(&a.discard)
- if di == nil {
- di = getDiscardInfo(reflect.TypeOf(m).Elem())
- atomicStoreDiscardInfo(&a.discard, di)
- }
- di.discard(toPointer(&m))
-}
-
-type discardInfo struct {
- typ reflect.Type
-
- initialized int32 // 0: only typ is valid, 1: everything is valid
- lock sync.Mutex
-
- fields []discardFieldInfo
- unrecognized field
-}
-
-type discardFieldInfo struct {
- field field // Offset of field, guaranteed to be valid
- discard func(src pointer)
-}
-
-var (
- discardInfoMap = map[reflect.Type]*discardInfo{}
- discardInfoLock sync.Mutex
-)
-
-func getDiscardInfo(t reflect.Type) *discardInfo {
- discardInfoLock.Lock()
- defer discardInfoLock.Unlock()
- di := discardInfoMap[t]
- if di == nil {
- di = &discardInfo{typ: t}
- discardInfoMap[t] = di
- }
- return di
-}
-
-func (di *discardInfo) discard(src pointer) {
- if src.isNil() {
- return // Nothing to do.
- }
-
- if atomic.LoadInt32(&di.initialized) == 0 {
- di.computeDiscardInfo()
- }
-
- for _, fi := range di.fields {
- sfp := src.offset(fi.field)
- fi.discard(sfp)
- }
-
- // For proto2 messages, only discard unknown fields in message extensions
- // that have been accessed via GetExtension.
- if em, err := extendable(src.asPointerTo(di.typ).Interface()); err == nil {
- // Ignore lock since DiscardUnknown is not concurrency safe.
- emm, _ := em.extensionsRead()
- for _, mx := range emm {
- if m, ok := mx.value.(Message); ok {
- DiscardUnknown(m)
- }
- }
- }
-
- if di.unrecognized.IsValid() {
- *src.offset(di.unrecognized).toBytes() = nil
- }
-}
-
-func (di *discardInfo) computeDiscardInfo() {
- di.lock.Lock()
- defer di.lock.Unlock()
- if di.initialized != 0 {
- return
- }
- t := di.typ
- n := t.NumField()
-
- for i := 0; i < n; i++ {
- f := t.Field(i)
- if strings.HasPrefix(f.Name, "XXX_") {
- continue
- }
-
- dfi := discardFieldInfo{field: toField(&f)}
- tf := f.Type
-
- // Unwrap tf to get its most basic type.
- var isPointer, isSlice bool
- if tf.Kind() == reflect.Slice && tf.Elem().Kind() != reflect.Uint8 {
- isSlice = true
- tf = tf.Elem()
- }
- if tf.Kind() == reflect.Ptr {
- isPointer = true
- tf = tf.Elem()
- }
- if isPointer && isSlice && tf.Kind() != reflect.Struct {
- panic(fmt.Sprintf("%v.%s cannot be a slice of pointers to primitive types", t, f.Name))
- }
-
- switch tf.Kind() {
- case reflect.Struct:
- switch {
- case !isPointer:
- panic(fmt.Sprintf("%v.%s cannot be a direct struct value", t, f.Name))
- case isSlice: // E.g., []*pb.T
- discardInfo := getDiscardInfo(tf)
- dfi.discard = func(src pointer) {
- sps := src.getPointerSlice()
- for _, sp := range sps {
- if !sp.isNil() {
- discardInfo.discard(sp)
- }
- }
- }
- default: // E.g., *pb.T
- discardInfo := getDiscardInfo(tf)
- dfi.discard = func(src pointer) {
- sp := src.getPointer()
- if !sp.isNil() {
- discardInfo.discard(sp)
- }
- }
- }
- case reflect.Map:
- switch {
- case isPointer || isSlice:
- panic(fmt.Sprintf("%v.%s cannot be a pointer to a map or a slice of map values", t, f.Name))
- default: // E.g., map[K]V
- if tf.Elem().Kind() == reflect.Ptr { // Proto struct (e.g., *T)
- dfi.discard = func(src pointer) {
- sm := src.asPointerTo(tf).Elem()
- if sm.Len() == 0 {
- return
- }
- for _, key := range sm.MapKeys() {
- val := sm.MapIndex(key)
- DiscardUnknown(val.Interface().(Message))
- }
- }
- } else {
- dfi.discard = func(pointer) {} // Noop
- }
- }
- case reflect.Interface:
- // Must be oneof field.
- switch {
- case isPointer || isSlice:
- panic(fmt.Sprintf("%v.%s cannot be a pointer to a interface or a slice of interface values", t, f.Name))
- default: // E.g., interface{}
- // TODO: Make this faster?
- dfi.discard = func(src pointer) {
- su := src.asPointerTo(tf).Elem()
- if !su.IsNil() {
- sv := su.Elem().Elem().Field(0)
- if sv.Kind() == reflect.Ptr && sv.IsNil() {
- return
- }
- switch sv.Type().Kind() {
- case reflect.Ptr: // Proto struct (e.g., *T)
- DiscardUnknown(sv.Interface().(Message))
- }
- }
- }
- }
- default:
- continue
- }
- di.fields = append(di.fields, dfi)
- }
-
- di.unrecognized = invalidField
- if f, ok := t.FieldByName("XXX_unrecognized"); ok {
- if f.Type != reflect.TypeOf([]byte{}) {
- panic("expected XXX_unrecognized to be of type []byte")
- }
- di.unrecognized = toField(&f)
- }
-
- atomic.StoreInt32(&di.initialized, 1)
-}
-
-func discardLegacy(m Message) {
- v := reflect.ValueOf(m)
- if v.Kind() != reflect.Ptr || v.IsNil() {
- return
- }
- v = v.Elem()
- if v.Kind() != reflect.Struct {
- return
- }
- t := v.Type()
-
- for i := 0; i < v.NumField(); i++ {
- f := t.Field(i)
- if strings.HasPrefix(f.Name, "XXX_") {
- continue
- }
- vf := v.Field(i)
- tf := f.Type
-
- // Unwrap tf to get its most basic type.
- var isPointer, isSlice bool
- if tf.Kind() == reflect.Slice && tf.Elem().Kind() != reflect.Uint8 {
- isSlice = true
- tf = tf.Elem()
- }
- if tf.Kind() == reflect.Ptr {
- isPointer = true
- tf = tf.Elem()
- }
- if isPointer && isSlice && tf.Kind() != reflect.Struct {
- panic(fmt.Sprintf("%T.%s cannot be a slice of pointers to primitive types", m, f.Name))
- }
-
- switch tf.Kind() {
- case reflect.Struct:
- switch {
- case !isPointer:
- panic(fmt.Sprintf("%T.%s cannot be a direct struct value", m, f.Name))
- case isSlice: // E.g., []*pb.T
- for j := 0; j < vf.Len(); j++ {
- discardLegacy(vf.Index(j).Interface().(Message))
- }
- default: // E.g., *pb.T
- discardLegacy(vf.Interface().(Message))
- }
- case reflect.Map:
- switch {
- case isPointer || isSlice:
- panic(fmt.Sprintf("%T.%s cannot be a pointer to a map or a slice of map values", m, f.Name))
- default: // E.g., map[K]V
- tv := vf.Type().Elem()
- if tv.Kind() == reflect.Ptr && tv.Implements(protoMessageType) { // Proto struct (e.g., *T)
- for _, key := range vf.MapKeys() {
- val := vf.MapIndex(key)
- discardLegacy(val.Interface().(Message))
- }
- }
- }
- case reflect.Interface:
- // Must be oneof field.
- switch {
- case isPointer || isSlice:
- panic(fmt.Sprintf("%T.%s cannot be a pointer to a interface or a slice of interface values", m, f.Name))
- default: // E.g., test_proto.isCommunique_Union interface
- if !vf.IsNil() && f.Tag.Get("protobuf_oneof") != "" {
- vf = vf.Elem() // E.g., *test_proto.Communique_Msg
- if !vf.IsNil() {
- vf = vf.Elem() // E.g., test_proto.Communique_Msg
- vf = vf.Field(0) // E.g., Proto struct (e.g., *T) or primitive value
- if vf.Kind() == reflect.Ptr {
- discardLegacy(vf.Interface().(Message))
- }
- }
- }
- }
- }
- }
-
- if vf := v.FieldByName("XXX_unrecognized"); vf.IsValid() {
- if vf.Type() != reflect.TypeOf([]byte{}) {
- panic("expected XXX_unrecognized to be of type []byte")
- }
- vf.Set(reflect.ValueOf([]byte(nil)))
- }
-
- // For proto2 messages, only discard unknown fields in message extensions
- // that have been accessed via GetExtension.
- if em, err := extendable(m); err == nil {
- // Ignore lock since discardLegacy is not concurrency safe.
- emm, _ := em.extensionsRead()
- for _, mx := range emm {
- if m, ok := mx.value.(Message); ok {
- discardLegacy(m)
- }
- }
- }
-}
diff --git a/vendor/github.com/gogo/protobuf/proto/duration_gogo.go b/vendor/github.com/gogo/protobuf/proto/duration_gogo.go
index e748e1730e..18e2a5f776 100644
--- a/vendor/github.com/gogo/protobuf/proto/duration_gogo.go
+++ b/vendor/github.com/gogo/protobuf/proto/duration_gogo.go
@@ -47,3 +47,157 @@ func (*duration) String() string { return "duration" }
func init() {
RegisterType((*duration)(nil), "gogo.protobuf.proto.duration")
}
+
+func (o *Buffer) decDuration() (time.Duration, error) {
+ b, err := o.DecodeRawBytes(true)
+ if err != nil {
+ return 0, err
+ }
+ dproto := &duration{}
+ if err := Unmarshal(b, dproto); err != nil {
+ return 0, err
+ }
+ return durationFromProto(dproto)
+}
+
+func (o *Buffer) dec_duration(p *Properties, base structPointer) error {
+ d, err := o.decDuration()
+ if err != nil {
+ return err
+ }
+ word64_Set(structPointer_Word64(base, p.field), o, uint64(d))
+ return nil
+}
+
+func (o *Buffer) dec_ref_duration(p *Properties, base structPointer) error {
+ d, err := o.decDuration()
+ if err != nil {
+ return err
+ }
+ word64Val_Set(structPointer_Word64Val(base, p.field), o, uint64(d))
+ return nil
+}
+
+func (o *Buffer) dec_slice_duration(p *Properties, base structPointer) error {
+ d, err := o.decDuration()
+ if err != nil {
+ return err
+ }
+ newBas := appendStructPointer(base, p.field, reflect.SliceOf(reflect.PtrTo(durationType)))
+ var zero field
+ setPtrCustomType(newBas, zero, &d)
+ return nil
+}
+
+func (o *Buffer) dec_slice_ref_duration(p *Properties, base structPointer) error {
+ d, err := o.decDuration()
+ if err != nil {
+ return err
+ }
+ structPointer_Word64Slice(base, p.field).Append(uint64(d))
+ return nil
+}
+
+func size_duration(p *Properties, base structPointer) (n int) {
+ structp := structPointer_GetStructPointer(base, p.field)
+ if structPointer_IsNil(structp) {
+ return 0
+ }
+ dur := structPointer_Interface(structp, durationType).(*time.Duration)
+ d := durationProto(*dur)
+ size := Size(d)
+ return size + sizeVarint(uint64(size)) + len(p.tagcode)
+}
+
+func (o *Buffer) enc_duration(p *Properties, base structPointer) error {
+ structp := structPointer_GetStructPointer(base, p.field)
+ if structPointer_IsNil(structp) {
+ return ErrNil
+ }
+ dur := structPointer_Interface(structp, durationType).(*time.Duration)
+ d := durationProto(*dur)
+ data, err := Marshal(d)
+ if err != nil {
+ return err
+ }
+ o.buf = append(o.buf, p.tagcode...)
+ o.EncodeRawBytes(data)
+ return nil
+}
+
+func size_ref_duration(p *Properties, base structPointer) (n int) {
+ dur := structPointer_InterfaceAt(base, p.field, durationType).(*time.Duration)
+ d := durationProto(*dur)
+ size := Size(d)
+ return size + sizeVarint(uint64(size)) + len(p.tagcode)
+}
+
+func (o *Buffer) enc_ref_duration(p *Properties, base structPointer) error {
+ dur := structPointer_InterfaceAt(base, p.field, durationType).(*time.Duration)
+ d := durationProto(*dur)
+ data, err := Marshal(d)
+ if err != nil {
+ return err
+ }
+ o.buf = append(o.buf, p.tagcode...)
+ o.EncodeRawBytes(data)
+ return nil
+}
+
+func size_slice_duration(p *Properties, base structPointer) (n int) {
+ pdurs := structPointer_InterfaceAt(base, p.field, reflect.SliceOf(reflect.PtrTo(durationType))).(*[]*time.Duration)
+ durs := *pdurs
+ for i := 0; i < len(durs); i++ {
+ if durs[i] == nil {
+ return 0
+ }
+ dproto := durationProto(*durs[i])
+ size := Size(dproto)
+ n += len(p.tagcode) + size + sizeVarint(uint64(size))
+ }
+ return n
+}
+
+func (o *Buffer) enc_slice_duration(p *Properties, base structPointer) error {
+ pdurs := structPointer_InterfaceAt(base, p.field, reflect.SliceOf(reflect.PtrTo(durationType))).(*[]*time.Duration)
+ durs := *pdurs
+ for i := 0; i < len(durs); i++ {
+ if durs[i] == nil {
+ return errRepeatedHasNil
+ }
+ dproto := durationProto(*durs[i])
+ data, err := Marshal(dproto)
+ if err != nil {
+ return err
+ }
+ o.buf = append(o.buf, p.tagcode...)
+ o.EncodeRawBytes(data)
+ }
+ return nil
+}
+
+func size_slice_ref_duration(p *Properties, base structPointer) (n int) {
+ pdurs := structPointer_InterfaceAt(base, p.field, reflect.SliceOf(durationType)).(*[]time.Duration)
+ durs := *pdurs
+ for i := 0; i < len(durs); i++ {
+ dproto := durationProto(durs[i])
+ size := Size(dproto)
+ n += len(p.tagcode) + size + sizeVarint(uint64(size))
+ }
+ return n
+}
+
+func (o *Buffer) enc_slice_ref_duration(p *Properties, base structPointer) error {
+ pdurs := structPointer_InterfaceAt(base, p.field, reflect.SliceOf(durationType)).(*[]time.Duration)
+ durs := *pdurs
+ for i := 0; i < len(durs); i++ {
+ dproto := durationProto(durs[i])
+ data, err := Marshal(dproto)
+ if err != nil {
+ return err
+ }
+ o.buf = append(o.buf, p.tagcode...)
+ o.EncodeRawBytes(data)
+ }
+ return nil
+}
diff --git a/vendor/github.com/gogo/protobuf/proto/encode.go b/vendor/github.com/gogo/protobuf/proto/encode.go
index c27d35f866..8b84d1b22d 100644
--- a/vendor/github.com/gogo/protobuf/proto/encode.go
+++ b/vendor/github.com/gogo/protobuf/proto/encode.go
@@ -39,6 +39,7 @@ import (
"errors"
"fmt"
"reflect"
+ "sort"
)
// RequiredNotSetError is the error returned if Marshal is called with
@@ -81,6 +82,10 @@ var (
const maxVarintBytes = 10 // maximum length of a varint
+// maxMarshalSize is the largest allowed size of an encoded protobuf,
+// since C++ and Java use signed int32s for the size.
+const maxMarshalSize = 1<<31 - 1
+
// EncodeVarint returns the varint encoding of x.
// This is the format for the
// int32, int64, uint32, uint64, bool, and enum
@@ -114,27 +119,18 @@ func (p *Buffer) EncodeVarint(x uint64) error {
// SizeVarint returns the varint encoding size of an integer.
func SizeVarint(x uint64) int {
- switch {
- case x < 1<<7:
- return 1
- case x < 1<<14:
- return 2
- case x < 1<<21:
- return 3
- case x < 1<<28:
- return 4
- case x < 1<<35:
- return 5
- case x < 1<<42:
- return 6
- case x < 1<<49:
- return 7
- case x < 1<<56:
- return 8
- case x < 1<<63:
- return 9
+ return sizeVarint(x)
+}
+
+func sizeVarint(x uint64) (n int) {
+ for {
+ n++
+ x >>= 7
+ if x == 0 {
+ break
+ }
}
- return 10
+ return n
}
// EncodeFixed64 writes a 64-bit integer to the Buffer.
@@ -153,6 +149,10 @@ func (p *Buffer) EncodeFixed64(x uint64) error {
return nil
}
+func sizeFixed64(x uint64) int {
+ return 8
+}
+
// EncodeFixed32 writes a 32-bit integer to the Buffer.
// This is the format for the
// fixed32, sfixed32, and float protocol buffer types.
@@ -165,12 +165,20 @@ func (p *Buffer) EncodeFixed32(x uint64) error {
return nil
}
+func sizeFixed32(x uint64) int {
+ return 4
+}
+
// EncodeZigzag64 writes a zigzag-encoded 64-bit integer
// to the Buffer.
// This is the format used for the sint64 protocol buffer type.
func (p *Buffer) EncodeZigzag64(x uint64) error {
// use signed number to get arithmetic right shift.
- return p.EncodeVarint(uint64((x << 1) ^ uint64((int64(x) >> 63))))
+ return p.EncodeVarint((x << 1) ^ uint64((int64(x) >> 63)))
+}
+
+func sizeZigzag64(x uint64) int {
+ return sizeVarint((x << 1) ^ uint64((int64(x) >> 63)))
}
// EncodeZigzag32 writes a zigzag-encoded 32-bit integer
@@ -181,6 +189,10 @@ func (p *Buffer) EncodeZigzag32(x uint64) error {
return p.EncodeVarint(uint64((uint32(x) << 1) ^ uint32((int32(x) >> 31))))
}
+func sizeZigzag32(x uint64) int {
+ return sizeVarint(uint64((uint32(x) << 1) ^ uint32((int32(x) >> 31))))
+}
+
// EncodeRawBytes writes a count-delimited byte buffer to the Buffer.
// This is the format used for the bytes protocol buffer
// type and for embedded messages.
@@ -190,6 +202,11 @@ func (p *Buffer) EncodeRawBytes(b []byte) error {
return nil
}
+func sizeRawBytes(b []byte) int {
+ return sizeVarint(uint64(len(b))) +
+ len(b)
+}
+
// EncodeStringBytes writes an encoded string to the Buffer.
// This is the format used for the proto2 string type.
func (p *Buffer) EncodeStringBytes(s string) error {
@@ -198,17 +215,319 @@ func (p *Buffer) EncodeStringBytes(s string) error {
return nil
}
+func sizeStringBytes(s string) int {
+ return sizeVarint(uint64(len(s))) +
+ len(s)
+}
+
// Marshaler is the interface representing objects that can marshal themselves.
type Marshaler interface {
Marshal() ([]byte, error)
}
+// Marshal takes the protocol buffer
+// and encodes it into the wire format, returning the data.
+func Marshal(pb Message) ([]byte, error) {
+ // Can the object marshal itself?
+ if m, ok := pb.(Marshaler); ok {
+ return m.Marshal()
+ }
+ p := NewBuffer(nil)
+ err := p.Marshal(pb)
+ if p.buf == nil && err == nil {
+ // Return a non-nil slice on success.
+ return []byte{}, nil
+ }
+ return p.buf, err
+}
+
// EncodeMessage writes the protocol buffer to the Buffer,
// prefixed by a varint-encoded length.
func (p *Buffer) EncodeMessage(pb Message) error {
- siz := Size(pb)
- p.EncodeVarint(uint64(siz))
- return p.Marshal(pb)
+ t, base, err := getbase(pb)
+ if structPointer_IsNil(base) {
+ return ErrNil
+ }
+ if err == nil {
+ var state errorState
+ err = p.enc_len_struct(GetProperties(t.Elem()), base, &state)
+ }
+ return err
+}
+
+// Marshal takes the protocol buffer
+// and encodes it into the wire format, writing the result to the
+// Buffer.
+func (p *Buffer) Marshal(pb Message) error {
+ // Can the object marshal itself?
+ if m, ok := pb.(Marshaler); ok {
+ data, err := m.Marshal()
+ p.buf = append(p.buf, data...)
+ return err
+ }
+
+ t, base, err := getbase(pb)
+ if structPointer_IsNil(base) {
+ return ErrNil
+ }
+ if err == nil {
+ err = p.enc_struct(GetProperties(t.Elem()), base)
+ }
+
+ if collectStats {
+ (stats).Encode++ // Parens are to work around a goimports bug.
+ }
+
+ if len(p.buf) > maxMarshalSize {
+ return ErrTooLarge
+ }
+ return err
+}
+
+// Size returns the encoded size of a protocol buffer.
+func Size(pb Message) (n int) {
+ // Can the object marshal itself? If so, Size is slow.
+ // TODO: add Size to Marshaler, or add a Sizer interface.
+ if m, ok := pb.(Marshaler); ok {
+ b, _ := m.Marshal()
+ return len(b)
+ }
+
+ t, base, err := getbase(pb)
+ if structPointer_IsNil(base) {
+ return 0
+ }
+ if err == nil {
+ n = size_struct(GetProperties(t.Elem()), base)
+ }
+
+ if collectStats {
+ (stats).Size++ // Parens are to work around a goimports bug.
+ }
+
+ return
+}
+
+// Individual type encoders.
+
+// Encode a bool.
+func (o *Buffer) enc_bool(p *Properties, base structPointer) error {
+ v := *structPointer_Bool(base, p.field)
+ if v == nil {
+ return ErrNil
+ }
+ x := 0
+ if *v {
+ x = 1
+ }
+ o.buf = append(o.buf, p.tagcode...)
+ p.valEnc(o, uint64(x))
+ return nil
+}
+
+func (o *Buffer) enc_proto3_bool(p *Properties, base structPointer) error {
+ v := *structPointer_BoolVal(base, p.field)
+ if !v {
+ return ErrNil
+ }
+ o.buf = append(o.buf, p.tagcode...)
+ p.valEnc(o, 1)
+ return nil
+}
+
+func size_bool(p *Properties, base structPointer) int {
+ v := *structPointer_Bool(base, p.field)
+ if v == nil {
+ return 0
+ }
+ return len(p.tagcode) + 1 // each bool takes exactly one byte
+}
+
+func size_proto3_bool(p *Properties, base structPointer) int {
+ v := *structPointer_BoolVal(base, p.field)
+ if !v && !p.oneof {
+ return 0
+ }
+ return len(p.tagcode) + 1 // each bool takes exactly one byte
+}
+
+// Encode an int32.
+func (o *Buffer) enc_int32(p *Properties, base structPointer) error {
+ v := structPointer_Word32(base, p.field)
+ if word32_IsNil(v) {
+ return ErrNil
+ }
+ x := int32(word32_Get(v)) // permit sign extension to use full 64-bit range
+ o.buf = append(o.buf, p.tagcode...)
+ p.valEnc(o, uint64(x))
+ return nil
+}
+
+func (o *Buffer) enc_proto3_int32(p *Properties, base structPointer) error {
+ v := structPointer_Word32Val(base, p.field)
+ x := int32(word32Val_Get(v)) // permit sign extension to use full 64-bit range
+ if x == 0 {
+ return ErrNil
+ }
+ o.buf = append(o.buf, p.tagcode...)
+ p.valEnc(o, uint64(x))
+ return nil
+}
+
+func size_int32(p *Properties, base structPointer) (n int) {
+ v := structPointer_Word32(base, p.field)
+ if word32_IsNil(v) {
+ return 0
+ }
+ x := int32(word32_Get(v)) // permit sign extension to use full 64-bit range
+ n += len(p.tagcode)
+ n += p.valSize(uint64(x))
+ return
+}
+
+func size_proto3_int32(p *Properties, base structPointer) (n int) {
+ v := structPointer_Word32Val(base, p.field)
+ x := int32(word32Val_Get(v)) // permit sign extension to use full 64-bit range
+ if x == 0 && !p.oneof {
+ return 0
+ }
+ n += len(p.tagcode)
+ n += p.valSize(uint64(x))
+ return
+}
+
+// Encode a uint32.
+// Exactly the same as int32, except for no sign extension.
+func (o *Buffer) enc_uint32(p *Properties, base structPointer) error {
+ v := structPointer_Word32(base, p.field)
+ if word32_IsNil(v) {
+ return ErrNil
+ }
+ x := word32_Get(v)
+ o.buf = append(o.buf, p.tagcode...)
+ p.valEnc(o, uint64(x))
+ return nil
+}
+
+func (o *Buffer) enc_proto3_uint32(p *Properties, base structPointer) error {
+ v := structPointer_Word32Val(base, p.field)
+ x := word32Val_Get(v)
+ if x == 0 {
+ return ErrNil
+ }
+ o.buf = append(o.buf, p.tagcode...)
+ p.valEnc(o, uint64(x))
+ return nil
+}
+
+func size_uint32(p *Properties, base structPointer) (n int) {
+ v := structPointer_Word32(base, p.field)
+ if word32_IsNil(v) {
+ return 0
+ }
+ x := word32_Get(v)
+ n += len(p.tagcode)
+ n += p.valSize(uint64(x))
+ return
+}
+
+func size_proto3_uint32(p *Properties, base structPointer) (n int) {
+ v := structPointer_Word32Val(base, p.field)
+ x := word32Val_Get(v)
+ if x == 0 && !p.oneof {
+ return 0
+ }
+ n += len(p.tagcode)
+ n += p.valSize(uint64(x))
+ return
+}
+
+// Encode an int64.
+func (o *Buffer) enc_int64(p *Properties, base structPointer) error {
+ v := structPointer_Word64(base, p.field)
+ if word64_IsNil(v) {
+ return ErrNil
+ }
+ x := word64_Get(v)
+ o.buf = append(o.buf, p.tagcode...)
+ p.valEnc(o, x)
+ return nil
+}
+
+func (o *Buffer) enc_proto3_int64(p *Properties, base structPointer) error {
+ v := structPointer_Word64Val(base, p.field)
+ x := word64Val_Get(v)
+ if x == 0 {
+ return ErrNil
+ }
+ o.buf = append(o.buf, p.tagcode...)
+ p.valEnc(o, x)
+ return nil
+}
+
+func size_int64(p *Properties, base structPointer) (n int) {
+ v := structPointer_Word64(base, p.field)
+ if word64_IsNil(v) {
+ return 0
+ }
+ x := word64_Get(v)
+ n += len(p.tagcode)
+ n += p.valSize(x)
+ return
+}
+
+func size_proto3_int64(p *Properties, base structPointer) (n int) {
+ v := structPointer_Word64Val(base, p.field)
+ x := word64Val_Get(v)
+ if x == 0 && !p.oneof {
+ return 0
+ }
+ n += len(p.tagcode)
+ n += p.valSize(x)
+ return
+}
+
+// Encode a string.
+func (o *Buffer) enc_string(p *Properties, base structPointer) error {
+ v := *structPointer_String(base, p.field)
+ if v == nil {
+ return ErrNil
+ }
+ x := *v
+ o.buf = append(o.buf, p.tagcode...)
+ o.EncodeStringBytes(x)
+ return nil
+}
+
+func (o *Buffer) enc_proto3_string(p *Properties, base structPointer) error {
+ v := *structPointer_StringVal(base, p.field)
+ if v == "" {
+ return ErrNil
+ }
+ o.buf = append(o.buf, p.tagcode...)
+ o.EncodeStringBytes(v)
+ return nil
+}
+
+func size_string(p *Properties, base structPointer) (n int) {
+ v := *structPointer_String(base, p.field)
+ if v == nil {
+ return 0
+ }
+ x := *v
+ n += len(p.tagcode)
+ n += sizeStringBytes(x)
+ return
+}
+
+func size_proto3_string(p *Properties, base structPointer) (n int) {
+ v := *structPointer_StringVal(base, p.field)
+ if v == "" && !p.oneof {
+ return 0
+ }
+ n += len(p.tagcode)
+ n += sizeStringBytes(v)
+ return
}
// All protocol buffer fields are nillable, but be careful.
@@ -219,3 +538,825 @@ func isNil(v reflect.Value) bool {
}
return false
}
+
+// Encode a message struct.
+func (o *Buffer) enc_struct_message(p *Properties, base structPointer) error {
+ var state errorState
+ structp := structPointer_GetStructPointer(base, p.field)
+ if structPointer_IsNil(structp) {
+ return ErrNil
+ }
+
+ // Can the object marshal itself?
+ if p.isMarshaler {
+ m := structPointer_Interface(structp, p.stype).(Marshaler)
+ data, err := m.Marshal()
+ if err != nil && !state.shouldContinue(err, nil) {
+ return err
+ }
+ o.buf = append(o.buf, p.tagcode...)
+ o.EncodeRawBytes(data)
+ return state.err
+ }
+
+ o.buf = append(o.buf, p.tagcode...)
+ return o.enc_len_struct(p.sprop, structp, &state)
+}
+
+func size_struct_message(p *Properties, base structPointer) int {
+ structp := structPointer_GetStructPointer(base, p.field)
+ if structPointer_IsNil(structp) {
+ return 0
+ }
+
+ // Can the object marshal itself?
+ if p.isMarshaler {
+ m := structPointer_Interface(structp, p.stype).(Marshaler)
+ data, _ := m.Marshal()
+ n0 := len(p.tagcode)
+ n1 := sizeRawBytes(data)
+ return n0 + n1
+ }
+
+ n0 := len(p.tagcode)
+ n1 := size_struct(p.sprop, structp)
+ n2 := sizeVarint(uint64(n1)) // size of encoded length
+ return n0 + n1 + n2
+}
+
+// Encode a group struct.
+func (o *Buffer) enc_struct_group(p *Properties, base structPointer) error {
+ var state errorState
+ b := structPointer_GetStructPointer(base, p.field)
+ if structPointer_IsNil(b) {
+ return ErrNil
+ }
+
+ o.EncodeVarint(uint64((p.Tag << 3) | WireStartGroup))
+ err := o.enc_struct(p.sprop, b)
+ if err != nil && !state.shouldContinue(err, nil) {
+ return err
+ }
+ o.EncodeVarint(uint64((p.Tag << 3) | WireEndGroup))
+ return state.err
+}
+
+func size_struct_group(p *Properties, base structPointer) (n int) {
+ b := structPointer_GetStructPointer(base, p.field)
+ if structPointer_IsNil(b) {
+ return 0
+ }
+
+ n += sizeVarint(uint64((p.Tag << 3) | WireStartGroup))
+ n += size_struct(p.sprop, b)
+ n += sizeVarint(uint64((p.Tag << 3) | WireEndGroup))
+ return
+}
+
+// Encode a slice of bools ([]bool).
+func (o *Buffer) enc_slice_bool(p *Properties, base structPointer) error {
+ s := *structPointer_BoolSlice(base, p.field)
+ l := len(s)
+ if l == 0 {
+ return ErrNil
+ }
+ for _, x := range s {
+ o.buf = append(o.buf, p.tagcode...)
+ v := uint64(0)
+ if x {
+ v = 1
+ }
+ p.valEnc(o, v)
+ }
+ return nil
+}
+
+func size_slice_bool(p *Properties, base structPointer) int {
+ s := *structPointer_BoolSlice(base, p.field)
+ l := len(s)
+ if l == 0 {
+ return 0
+ }
+ return l * (len(p.tagcode) + 1) // each bool takes exactly one byte
+}
+
+// Encode a slice of bools ([]bool) in packed format.
+func (o *Buffer) enc_slice_packed_bool(p *Properties, base structPointer) error {
+ s := *structPointer_BoolSlice(base, p.field)
+ l := len(s)
+ if l == 0 {
+ return ErrNil
+ }
+ o.buf = append(o.buf, p.tagcode...)
+ o.EncodeVarint(uint64(l)) // each bool takes exactly one byte
+ for _, x := range s {
+ v := uint64(0)
+ if x {
+ v = 1
+ }
+ p.valEnc(o, v)
+ }
+ return nil
+}
+
+func size_slice_packed_bool(p *Properties, base structPointer) (n int) {
+ s := *structPointer_BoolSlice(base, p.field)
+ l := len(s)
+ if l == 0 {
+ return 0
+ }
+ n += len(p.tagcode)
+ n += sizeVarint(uint64(l))
+ n += l // each bool takes exactly one byte
+ return
+}
+
+// Encode a slice of bytes ([]byte).
+func (o *Buffer) enc_slice_byte(p *Properties, base structPointer) error {
+ s := *structPointer_Bytes(base, p.field)
+ if s == nil {
+ return ErrNil
+ }
+ o.buf = append(o.buf, p.tagcode...)
+ o.EncodeRawBytes(s)
+ return nil
+}
+
+func (o *Buffer) enc_proto3_slice_byte(p *Properties, base structPointer) error {
+ s := *structPointer_Bytes(base, p.field)
+ if len(s) == 0 {
+ return ErrNil
+ }
+ o.buf = append(o.buf, p.tagcode...)
+ o.EncodeRawBytes(s)
+ return nil
+}
+
+func size_slice_byte(p *Properties, base structPointer) (n int) {
+ s := *structPointer_Bytes(base, p.field)
+ if s == nil && !p.oneof {
+ return 0
+ }
+ n += len(p.tagcode)
+ n += sizeRawBytes(s)
+ return
+}
+
+func size_proto3_slice_byte(p *Properties, base structPointer) (n int) {
+ s := *structPointer_Bytes(base, p.field)
+ if len(s) == 0 && !p.oneof {
+ return 0
+ }
+ n += len(p.tagcode)
+ n += sizeRawBytes(s)
+ return
+}
+
+// Encode a slice of int32s ([]int32).
+func (o *Buffer) enc_slice_int32(p *Properties, base structPointer) error {
+ s := structPointer_Word32Slice(base, p.field)
+ l := s.Len()
+ if l == 0 {
+ return ErrNil
+ }
+ for i := 0; i < l; i++ {
+ o.buf = append(o.buf, p.tagcode...)
+ x := int32(s.Index(i)) // permit sign extension to use full 64-bit range
+ p.valEnc(o, uint64(x))
+ }
+ return nil
+}
+
+func size_slice_int32(p *Properties, base structPointer) (n int) {
+ s := structPointer_Word32Slice(base, p.field)
+ l := s.Len()
+ if l == 0 {
+ return 0
+ }
+ for i := 0; i < l; i++ {
+ n += len(p.tagcode)
+ x := int32(s.Index(i)) // permit sign extension to use full 64-bit range
+ n += p.valSize(uint64(x))
+ }
+ return
+}
+
+// Encode a slice of int32s ([]int32) in packed format.
+func (o *Buffer) enc_slice_packed_int32(p *Properties, base structPointer) error {
+ s := structPointer_Word32Slice(base, p.field)
+ l := s.Len()
+ if l == 0 {
+ return ErrNil
+ }
+ // TODO: Reuse a Buffer.
+ buf := NewBuffer(nil)
+ for i := 0; i < l; i++ {
+ x := int32(s.Index(i)) // permit sign extension to use full 64-bit range
+ p.valEnc(buf, uint64(x))
+ }
+
+ o.buf = append(o.buf, p.tagcode...)
+ o.EncodeVarint(uint64(len(buf.buf)))
+ o.buf = append(o.buf, buf.buf...)
+ return nil
+}
+
+func size_slice_packed_int32(p *Properties, base structPointer) (n int) {
+ s := structPointer_Word32Slice(base, p.field)
+ l := s.Len()
+ if l == 0 {
+ return 0
+ }
+ var bufSize int
+ for i := 0; i < l; i++ {
+ x := int32(s.Index(i)) // permit sign extension to use full 64-bit range
+ bufSize += p.valSize(uint64(x))
+ }
+
+ n += len(p.tagcode)
+ n += sizeVarint(uint64(bufSize))
+ n += bufSize
+ return
+}
+
+// Encode a slice of uint32s ([]uint32).
+// Exactly the same as int32, except for no sign extension.
+func (o *Buffer) enc_slice_uint32(p *Properties, base structPointer) error {
+ s := structPointer_Word32Slice(base, p.field)
+ l := s.Len()
+ if l == 0 {
+ return ErrNil
+ }
+ for i := 0; i < l; i++ {
+ o.buf = append(o.buf, p.tagcode...)
+ x := s.Index(i)
+ p.valEnc(o, uint64(x))
+ }
+ return nil
+}
+
+func size_slice_uint32(p *Properties, base structPointer) (n int) {
+ s := structPointer_Word32Slice(base, p.field)
+ l := s.Len()
+ if l == 0 {
+ return 0
+ }
+ for i := 0; i < l; i++ {
+ n += len(p.tagcode)
+ x := s.Index(i)
+ n += p.valSize(uint64(x))
+ }
+ return
+}
+
+// Encode a slice of uint32s ([]uint32) in packed format.
+// Exactly the same as int32, except for no sign extension.
+func (o *Buffer) enc_slice_packed_uint32(p *Properties, base structPointer) error {
+ s := structPointer_Word32Slice(base, p.field)
+ l := s.Len()
+ if l == 0 {
+ return ErrNil
+ }
+ // TODO: Reuse a Buffer.
+ buf := NewBuffer(nil)
+ for i := 0; i < l; i++ {
+ p.valEnc(buf, uint64(s.Index(i)))
+ }
+
+ o.buf = append(o.buf, p.tagcode...)
+ o.EncodeVarint(uint64(len(buf.buf)))
+ o.buf = append(o.buf, buf.buf...)
+ return nil
+}
+
+func size_slice_packed_uint32(p *Properties, base structPointer) (n int) {
+ s := structPointer_Word32Slice(base, p.field)
+ l := s.Len()
+ if l == 0 {
+ return 0
+ }
+ var bufSize int
+ for i := 0; i < l; i++ {
+ bufSize += p.valSize(uint64(s.Index(i)))
+ }
+
+ n += len(p.tagcode)
+ n += sizeVarint(uint64(bufSize))
+ n += bufSize
+ return
+}
+
+// Encode a slice of int64s ([]int64).
+func (o *Buffer) enc_slice_int64(p *Properties, base structPointer) error {
+ s := structPointer_Word64Slice(base, p.field)
+ l := s.Len()
+ if l == 0 {
+ return ErrNil
+ }
+ for i := 0; i < l; i++ {
+ o.buf = append(o.buf, p.tagcode...)
+ p.valEnc(o, s.Index(i))
+ }
+ return nil
+}
+
+func size_slice_int64(p *Properties, base structPointer) (n int) {
+ s := structPointer_Word64Slice(base, p.field)
+ l := s.Len()
+ if l == 0 {
+ return 0
+ }
+ for i := 0; i < l; i++ {
+ n += len(p.tagcode)
+ n += p.valSize(s.Index(i))
+ }
+ return
+}
+
+// Encode a slice of int64s ([]int64) in packed format.
+func (o *Buffer) enc_slice_packed_int64(p *Properties, base structPointer) error {
+ s := structPointer_Word64Slice(base, p.field)
+ l := s.Len()
+ if l == 0 {
+ return ErrNil
+ }
+ // TODO: Reuse a Buffer.
+ buf := NewBuffer(nil)
+ for i := 0; i < l; i++ {
+ p.valEnc(buf, s.Index(i))
+ }
+
+ o.buf = append(o.buf, p.tagcode...)
+ o.EncodeVarint(uint64(len(buf.buf)))
+ o.buf = append(o.buf, buf.buf...)
+ return nil
+}
+
+func size_slice_packed_int64(p *Properties, base structPointer) (n int) {
+ s := structPointer_Word64Slice(base, p.field)
+ l := s.Len()
+ if l == 0 {
+ return 0
+ }
+ var bufSize int
+ for i := 0; i < l; i++ {
+ bufSize += p.valSize(s.Index(i))
+ }
+
+ n += len(p.tagcode)
+ n += sizeVarint(uint64(bufSize))
+ n += bufSize
+ return
+}
+
+// Encode a slice of slice of bytes ([][]byte).
+func (o *Buffer) enc_slice_slice_byte(p *Properties, base structPointer) error {
+ ss := *structPointer_BytesSlice(base, p.field)
+ l := len(ss)
+ if l == 0 {
+ return ErrNil
+ }
+ for i := 0; i < l; i++ {
+ o.buf = append(o.buf, p.tagcode...)
+ o.EncodeRawBytes(ss[i])
+ }
+ return nil
+}
+
+func size_slice_slice_byte(p *Properties, base structPointer) (n int) {
+ ss := *structPointer_BytesSlice(base, p.field)
+ l := len(ss)
+ if l == 0 {
+ return 0
+ }
+ n += l * len(p.tagcode)
+ for i := 0; i < l; i++ {
+ n += sizeRawBytes(ss[i])
+ }
+ return
+}
+
+// Encode a slice of strings ([]string).
+func (o *Buffer) enc_slice_string(p *Properties, base structPointer) error {
+ ss := *structPointer_StringSlice(base, p.field)
+ l := len(ss)
+ for i := 0; i < l; i++ {
+ o.buf = append(o.buf, p.tagcode...)
+ o.EncodeStringBytes(ss[i])
+ }
+ return nil
+}
+
+func size_slice_string(p *Properties, base structPointer) (n int) {
+ ss := *structPointer_StringSlice(base, p.field)
+ l := len(ss)
+ n += l * len(p.tagcode)
+ for i := 0; i < l; i++ {
+ n += sizeStringBytes(ss[i])
+ }
+ return
+}
+
+// Encode a slice of message structs ([]*struct).
+func (o *Buffer) enc_slice_struct_message(p *Properties, base structPointer) error {
+ var state errorState
+ s := structPointer_StructPointerSlice(base, p.field)
+ l := s.Len()
+
+ for i := 0; i < l; i++ {
+ structp := s.Index(i)
+ if structPointer_IsNil(structp) {
+ return errRepeatedHasNil
+ }
+
+ // Can the object marshal itself?
+ if p.isMarshaler {
+ m := structPointer_Interface(structp, p.stype).(Marshaler)
+ data, err := m.Marshal()
+ if err != nil && !state.shouldContinue(err, nil) {
+ return err
+ }
+ o.buf = append(o.buf, p.tagcode...)
+ o.EncodeRawBytes(data)
+ continue
+ }
+
+ o.buf = append(o.buf, p.tagcode...)
+ err := o.enc_len_struct(p.sprop, structp, &state)
+ if err != nil && !state.shouldContinue(err, nil) {
+ if err == ErrNil {
+ return errRepeatedHasNil
+ }
+ return err
+ }
+ }
+ return state.err
+}
+
+func size_slice_struct_message(p *Properties, base structPointer) (n int) {
+ s := structPointer_StructPointerSlice(base, p.field)
+ l := s.Len()
+ n += l * len(p.tagcode)
+ for i := 0; i < l; i++ {
+ structp := s.Index(i)
+ if structPointer_IsNil(structp) {
+ return // return the size up to this point
+ }
+
+ // Can the object marshal itself?
+ if p.isMarshaler {
+ m := structPointer_Interface(structp, p.stype).(Marshaler)
+ data, _ := m.Marshal()
+ n += sizeRawBytes(data)
+ continue
+ }
+
+ n0 := size_struct(p.sprop, structp)
+ n1 := sizeVarint(uint64(n0)) // size of encoded length
+ n += n0 + n1
+ }
+ return
+}
+
+// Encode a slice of group structs ([]*struct).
+func (o *Buffer) enc_slice_struct_group(p *Properties, base structPointer) error {
+ var state errorState
+ s := structPointer_StructPointerSlice(base, p.field)
+ l := s.Len()
+
+ for i := 0; i < l; i++ {
+ b := s.Index(i)
+ if structPointer_IsNil(b) {
+ return errRepeatedHasNil
+ }
+
+ o.EncodeVarint(uint64((p.Tag << 3) | WireStartGroup))
+
+ err := o.enc_struct(p.sprop, b)
+
+ if err != nil && !state.shouldContinue(err, nil) {
+ if err == ErrNil {
+ return errRepeatedHasNil
+ }
+ return err
+ }
+
+ o.EncodeVarint(uint64((p.Tag << 3) | WireEndGroup))
+ }
+ return state.err
+}
+
+func size_slice_struct_group(p *Properties, base structPointer) (n int) {
+ s := structPointer_StructPointerSlice(base, p.field)
+ l := s.Len()
+
+ n += l * sizeVarint(uint64((p.Tag<<3)|WireStartGroup))
+ n += l * sizeVarint(uint64((p.Tag<<3)|WireEndGroup))
+ for i := 0; i < l; i++ {
+ b := s.Index(i)
+ if structPointer_IsNil(b) {
+ return // return size up to this point
+ }
+
+ n += size_struct(p.sprop, b)
+ }
+ return
+}
+
+// Encode an extension map.
+func (o *Buffer) enc_map(p *Properties, base structPointer) error {
+ exts := structPointer_ExtMap(base, p.field)
+ if err := encodeExtensionsMap(*exts); err != nil {
+ return err
+ }
+
+ return o.enc_map_body(*exts)
+}
+
+func (o *Buffer) enc_exts(p *Properties, base structPointer) error {
+ exts := structPointer_Extensions(base, p.field)
+
+ v, mu := exts.extensionsRead()
+ if v == nil {
+ return nil
+ }
+
+ mu.Lock()
+ defer mu.Unlock()
+ if err := encodeExtensionsMap(v); err != nil {
+ return err
+ }
+
+ return o.enc_map_body(v)
+}
+
+func (o *Buffer) enc_map_body(v map[int32]Extension) error {
+ // Fast-path for common cases: zero or one extensions.
+ if len(v) <= 1 {
+ for _, e := range v {
+ o.buf = append(o.buf, e.enc...)
+ }
+ return nil
+ }
+
+ // Sort keys to provide a deterministic encoding.
+ keys := make([]int, 0, len(v))
+ for k := range v {
+ keys = append(keys, int(k))
+ }
+ sort.Ints(keys)
+
+ for _, k := range keys {
+ o.buf = append(o.buf, v[int32(k)].enc...)
+ }
+ return nil
+}
+
+func size_map(p *Properties, base structPointer) int {
+ v := structPointer_ExtMap(base, p.field)
+ return extensionsMapSize(*v)
+}
+
+func size_exts(p *Properties, base structPointer) int {
+ v := structPointer_Extensions(base, p.field)
+ return extensionsSize(v)
+}
+
+// Encode a map field.
+func (o *Buffer) enc_new_map(p *Properties, base structPointer) error {
+ var state errorState // XXX: or do we need to plumb this through?
+
+ /*
+ A map defined as
+ map map_field = N;
+ is encoded in the same way as
+ message MapFieldEntry {
+ key_type key = 1;
+ value_type value = 2;
+ }
+ repeated MapFieldEntry map_field = N;
+ */
+
+ v := structPointer_NewAt(base, p.field, p.mtype).Elem() // map[K]V
+ if v.Len() == 0 {
+ return nil
+ }
+
+ keycopy, valcopy, keybase, valbase := mapEncodeScratch(p.mtype)
+
+ enc := func() error {
+ if err := p.mkeyprop.enc(o, p.mkeyprop, keybase); err != nil {
+ return err
+ }
+ if err := p.mvalprop.enc(o, p.mvalprop, valbase); err != nil && err != ErrNil {
+ return err
+ }
+ return nil
+ }
+
+ // Don't sort map keys. It is not required by the spec, and C++ doesn't do it.
+ for _, key := range v.MapKeys() {
+ val := v.MapIndex(key)
+
+ keycopy.Set(key)
+ valcopy.Set(val)
+
+ o.buf = append(o.buf, p.tagcode...)
+ if err := o.enc_len_thing(enc, &state); err != nil {
+ return err
+ }
+ }
+ return nil
+}
+
+func size_new_map(p *Properties, base structPointer) int {
+ v := structPointer_NewAt(base, p.field, p.mtype).Elem() // map[K]V
+
+ keycopy, valcopy, keybase, valbase := mapEncodeScratch(p.mtype)
+
+ n := 0
+ for _, key := range v.MapKeys() {
+ val := v.MapIndex(key)
+ keycopy.Set(key)
+ valcopy.Set(val)
+
+ // Tag codes for key and val are the responsibility of the sub-sizer.
+ keysize := p.mkeyprop.size(p.mkeyprop, keybase)
+ valsize := p.mvalprop.size(p.mvalprop, valbase)
+ entry := keysize + valsize
+ // Add on tag code and length of map entry itself.
+ n += len(p.tagcode) + sizeVarint(uint64(entry)) + entry
+ }
+ return n
+}
+
+// mapEncodeScratch returns a new reflect.Value matching the map's value type,
+// and a structPointer suitable for passing to an encoder or sizer.
+func mapEncodeScratch(mapType reflect.Type) (keycopy, valcopy reflect.Value, keybase, valbase structPointer) {
+ // Prepare addressable doubly-indirect placeholders for the key and value types.
+ // This is needed because the element-type encoders expect **T, but the map iteration produces T.
+
+ keycopy = reflect.New(mapType.Key()).Elem() // addressable K
+ keyptr := reflect.New(reflect.PtrTo(keycopy.Type())).Elem() // addressable *K
+ keyptr.Set(keycopy.Addr()) //
+ keybase = toStructPointer(keyptr.Addr()) // **K
+
+ // Value types are more varied and require special handling.
+ switch mapType.Elem().Kind() {
+ case reflect.Slice:
+ // []byte
+ var dummy []byte
+ valcopy = reflect.ValueOf(&dummy).Elem() // addressable []byte
+ valbase = toStructPointer(valcopy.Addr())
+ case reflect.Ptr:
+ // message; the generated field type is map[K]*Msg (so V is *Msg),
+ // so we only need one level of indirection.
+ valcopy = reflect.New(mapType.Elem()).Elem() // addressable V
+ valbase = toStructPointer(valcopy.Addr())
+ default:
+ // everything else
+ valcopy = reflect.New(mapType.Elem()).Elem() // addressable V
+ valptr := reflect.New(reflect.PtrTo(valcopy.Type())).Elem() // addressable *V
+ valptr.Set(valcopy.Addr()) //
+ valbase = toStructPointer(valptr.Addr()) // **V
+ }
+ return
+}
+
+// Encode a struct.
+func (o *Buffer) enc_struct(prop *StructProperties, base structPointer) error {
+ var state errorState
+ // Encode fields in tag order so that decoders may use optimizations
+ // that depend on the ordering.
+ // https://developers.google.com/protocol-buffers/docs/encoding#order
+ for _, i := range prop.order {
+ p := prop.Prop[i]
+ if p.enc != nil {
+ err := p.enc(o, p, base)
+ if err != nil {
+ if err == ErrNil {
+ if p.Required && state.err == nil {
+ state.err = &RequiredNotSetError{p.Name}
+ }
+ } else if err == errRepeatedHasNil {
+ // Give more context to nil values in repeated fields.
+ return errors.New("repeated field " + p.OrigName + " has nil element")
+ } else if !state.shouldContinue(err, p) {
+ return err
+ }
+ }
+ if len(o.buf) > maxMarshalSize {
+ return ErrTooLarge
+ }
+ }
+ }
+
+ // Do oneof fields.
+ if prop.oneofMarshaler != nil {
+ m := structPointer_Interface(base, prop.stype).(Message)
+ if err := prop.oneofMarshaler(m, o); err == ErrNil {
+ return errOneofHasNil
+ } else if err != nil {
+ return err
+ }
+ }
+
+ // Add unrecognized fields at the end.
+ if prop.unrecField.IsValid() {
+ v := *structPointer_Bytes(base, prop.unrecField)
+ if len(o.buf)+len(v) > maxMarshalSize {
+ return ErrTooLarge
+ }
+ if len(v) > 0 {
+ o.buf = append(o.buf, v...)
+ }
+ }
+
+ return state.err
+}
+
+func size_struct(prop *StructProperties, base structPointer) (n int) {
+ for _, i := range prop.order {
+ p := prop.Prop[i]
+ if p.size != nil {
+ n += p.size(p, base)
+ }
+ }
+
+ // Add unrecognized fields at the end.
+ if prop.unrecField.IsValid() {
+ v := *structPointer_Bytes(base, prop.unrecField)
+ n += len(v)
+ }
+
+ // Factor in any oneof fields.
+ if prop.oneofSizer != nil {
+ m := structPointer_Interface(base, prop.stype).(Message)
+ n += prop.oneofSizer(m)
+ }
+
+ return
+}
+
+var zeroes [20]byte // longer than any conceivable sizeVarint
+
+// Encode a struct, preceded by its encoded length (as a varint).
+func (o *Buffer) enc_len_struct(prop *StructProperties, base structPointer, state *errorState) error {
+ return o.enc_len_thing(func() error { return o.enc_struct(prop, base) }, state)
+}
+
+// Encode something, preceded by its encoded length (as a varint).
+func (o *Buffer) enc_len_thing(enc func() error, state *errorState) error {
+ iLen := len(o.buf)
+ o.buf = append(o.buf, 0, 0, 0, 0) // reserve four bytes for length
+ iMsg := len(o.buf)
+ err := enc()
+ if err != nil && !state.shouldContinue(err, nil) {
+ return err
+ }
+ lMsg := len(o.buf) - iMsg
+ lLen := sizeVarint(uint64(lMsg))
+ switch x := lLen - (iMsg - iLen); {
+ case x > 0: // actual length is x bytes larger than the space we reserved
+ // Move msg x bytes right.
+ o.buf = append(o.buf, zeroes[:x]...)
+ copy(o.buf[iMsg+x:], o.buf[iMsg:iMsg+lMsg])
+ case x < 0: // actual length is x bytes smaller than the space we reserved
+ // Move msg x bytes left.
+ copy(o.buf[iMsg+x:], o.buf[iMsg:iMsg+lMsg])
+ o.buf = o.buf[:len(o.buf)+x] // x is negative
+ }
+ // Encode the length in the reserved space.
+ o.buf = o.buf[:iLen]
+ o.EncodeVarint(uint64(lMsg))
+ o.buf = o.buf[:len(o.buf)+lMsg]
+ return state.err
+}
+
+// errorState maintains the first error that occurs and updates that error
+// with additional context.
+type errorState struct {
+ err error
+}
+
+// shouldContinue reports whether encoding should continue upon encountering the
+// given error. If the error is RequiredNotSetError, shouldContinue returns true
+// and, if this is the first appearance of that error, remembers it for future
+// reporting.
+//
+// If prop is not nil, it may update any error with additional context about the
+// field with the error.
+func (s *errorState) shouldContinue(err error, prop *Properties) bool {
+ // Ignore unset required fields.
+ reqNotSet, ok := err.(*RequiredNotSetError)
+ if !ok {
+ return false
+ }
+ if s.err == nil {
+ if prop != nil {
+ err = &RequiredNotSetError{prop.Name + "." + reqNotSet.field}
+ }
+ s.err = err
+ }
+ return true
+}
diff --git a/vendor/github.com/gogo/protobuf/proto/encode_gogo.go b/vendor/github.com/gogo/protobuf/proto/encode_gogo.go
index 0f5fb173e9..32111b7f41 100644
--- a/vendor/github.com/gogo/protobuf/proto/encode_gogo.go
+++ b/vendor/github.com/gogo/protobuf/proto/encode_gogo.go
@@ -3,6 +3,11 @@
// Copyright (c) 2013, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
+// Go support for Protocol Buffers - Google's data interchange format
+//
+// Copyright 2010 The Go Authors. All rights reserved.
+// http://github.com/golang/protobuf/
+//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
@@ -13,6 +18,9 @@
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
@@ -28,6 +36,315 @@
package proto
+import (
+ "reflect"
+)
+
func NewRequiredNotSetError(field string) *RequiredNotSetError {
return &RequiredNotSetError{field}
}
+
+type Sizer interface {
+ Size() int
+}
+
+func (o *Buffer) enc_ext_slice_byte(p *Properties, base structPointer) error {
+ s := *structPointer_Bytes(base, p.field)
+ if s == nil {
+ return ErrNil
+ }
+ o.buf = append(o.buf, s...)
+ return nil
+}
+
+func size_ext_slice_byte(p *Properties, base structPointer) (n int) {
+ s := *structPointer_Bytes(base, p.field)
+ if s == nil {
+ return 0
+ }
+ n += len(s)
+ return
+}
+
+// Encode a reference to bool pointer.
+func (o *Buffer) enc_ref_bool(p *Properties, base structPointer) error {
+ v := *structPointer_BoolVal(base, p.field)
+ x := 0
+ if v {
+ x = 1
+ }
+ o.buf = append(o.buf, p.tagcode...)
+ p.valEnc(o, uint64(x))
+ return nil
+}
+
+func size_ref_bool(p *Properties, base structPointer) int {
+ return len(p.tagcode) + 1 // each bool takes exactly one byte
+}
+
+// Encode a reference to int32 pointer.
+func (o *Buffer) enc_ref_int32(p *Properties, base structPointer) error {
+ v := structPointer_Word32Val(base, p.field)
+ x := int32(word32Val_Get(v))
+ o.buf = append(o.buf, p.tagcode...)
+ p.valEnc(o, uint64(x))
+ return nil
+}
+
+func size_ref_int32(p *Properties, base structPointer) (n int) {
+ v := structPointer_Word32Val(base, p.field)
+ x := int32(word32Val_Get(v))
+ n += len(p.tagcode)
+ n += p.valSize(uint64(x))
+ return
+}
+
+func (o *Buffer) enc_ref_uint32(p *Properties, base structPointer) error {
+ v := structPointer_Word32Val(base, p.field)
+ x := word32Val_Get(v)
+ o.buf = append(o.buf, p.tagcode...)
+ p.valEnc(o, uint64(x))
+ return nil
+}
+
+func size_ref_uint32(p *Properties, base structPointer) (n int) {
+ v := structPointer_Word32Val(base, p.field)
+ x := word32Val_Get(v)
+ n += len(p.tagcode)
+ n += p.valSize(uint64(x))
+ return
+}
+
+// Encode a reference to an int64 pointer.
+func (o *Buffer) enc_ref_int64(p *Properties, base structPointer) error {
+ v := structPointer_Word64Val(base, p.field)
+ x := word64Val_Get(v)
+ o.buf = append(o.buf, p.tagcode...)
+ p.valEnc(o, x)
+ return nil
+}
+
+func size_ref_int64(p *Properties, base structPointer) (n int) {
+ v := structPointer_Word64Val(base, p.field)
+ x := word64Val_Get(v)
+ n += len(p.tagcode)
+ n += p.valSize(x)
+ return
+}
+
+// Encode a reference to a string pointer.
+func (o *Buffer) enc_ref_string(p *Properties, base structPointer) error {
+ v := *structPointer_StringVal(base, p.field)
+ o.buf = append(o.buf, p.tagcode...)
+ o.EncodeStringBytes(v)
+ return nil
+}
+
+func size_ref_string(p *Properties, base structPointer) (n int) {
+ v := *structPointer_StringVal(base, p.field)
+ n += len(p.tagcode)
+ n += sizeStringBytes(v)
+ return
+}
+
+// Encode a reference to a message struct.
+func (o *Buffer) enc_ref_struct_message(p *Properties, base structPointer) error {
+ var state errorState
+ structp := structPointer_GetRefStructPointer(base, p.field)
+ if structPointer_IsNil(structp) {
+ return ErrNil
+ }
+
+ // Can the object marshal itself?
+ if p.isMarshaler {
+ m := structPointer_Interface(structp, p.stype).(Marshaler)
+ data, err := m.Marshal()
+ if err != nil && !state.shouldContinue(err, nil) {
+ return err
+ }
+ o.buf = append(o.buf, p.tagcode...)
+ o.EncodeRawBytes(data)
+ return nil
+ }
+
+ o.buf = append(o.buf, p.tagcode...)
+ return o.enc_len_struct(p.sprop, structp, &state)
+}
+
+//TODO this is only copied, please fix this
+func size_ref_struct_message(p *Properties, base structPointer) int {
+ structp := structPointer_GetRefStructPointer(base, p.field)
+ if structPointer_IsNil(structp) {
+ return 0
+ }
+
+ // Can the object marshal itself?
+ if p.isMarshaler {
+ m := structPointer_Interface(structp, p.stype).(Marshaler)
+ data, _ := m.Marshal()
+ n0 := len(p.tagcode)
+ n1 := sizeRawBytes(data)
+ return n0 + n1
+ }
+
+ n0 := len(p.tagcode)
+ n1 := size_struct(p.sprop, structp)
+ n2 := sizeVarint(uint64(n1)) // size of encoded length
+ return n0 + n1 + n2
+}
+
+// Encode a slice of references to message struct pointers ([]struct).
+func (o *Buffer) enc_slice_ref_struct_message(p *Properties, base structPointer) error {
+ var state errorState
+ ss := structPointer_StructRefSlice(base, p.field, p.stype.Size())
+ l := ss.Len()
+ for i := 0; i < l; i++ {
+ structp := ss.Index(i)
+ if structPointer_IsNil(structp) {
+ return errRepeatedHasNil
+ }
+
+ // Can the object marshal itself?
+ if p.isMarshaler {
+ m := structPointer_Interface(structp, p.stype).(Marshaler)
+ data, err := m.Marshal()
+ if err != nil && !state.shouldContinue(err, nil) {
+ return err
+ }
+ o.buf = append(o.buf, p.tagcode...)
+ o.EncodeRawBytes(data)
+ continue
+ }
+
+ o.buf = append(o.buf, p.tagcode...)
+ err := o.enc_len_struct(p.sprop, structp, &state)
+ if err != nil && !state.shouldContinue(err, nil) {
+ if err == ErrNil {
+ return errRepeatedHasNil
+ }
+ return err
+ }
+
+ }
+ return state.err
+}
+
+//TODO this is only copied, please fix this
+func size_slice_ref_struct_message(p *Properties, base structPointer) (n int) {
+ ss := structPointer_StructRefSlice(base, p.field, p.stype.Size())
+ l := ss.Len()
+ n += l * len(p.tagcode)
+ for i := 0; i < l; i++ {
+ structp := ss.Index(i)
+ if structPointer_IsNil(structp) {
+ return // return the size up to this point
+ }
+
+ // Can the object marshal itself?
+ if p.isMarshaler {
+ m := structPointer_Interface(structp, p.stype).(Marshaler)
+ data, _ := m.Marshal()
+ n += len(p.tagcode)
+ n += sizeRawBytes(data)
+ continue
+ }
+
+ n0 := size_struct(p.sprop, structp)
+ n1 := sizeVarint(uint64(n0)) // size of encoded length
+ n += n0 + n1
+ }
+ return
+}
+
+func (o *Buffer) enc_custom_bytes(p *Properties, base structPointer) error {
+ i := structPointer_InterfaceRef(base, p.field, p.ctype)
+ if i == nil {
+ return ErrNil
+ }
+ custom := i.(Marshaler)
+ data, err := custom.Marshal()
+ if err != nil {
+ return err
+ }
+ if data == nil {
+ return ErrNil
+ }
+ o.buf = append(o.buf, p.tagcode...)
+ o.EncodeRawBytes(data)
+ return nil
+}
+
+func size_custom_bytes(p *Properties, base structPointer) (n int) {
+ n += len(p.tagcode)
+ i := structPointer_InterfaceRef(base, p.field, p.ctype)
+ if i == nil {
+ return 0
+ }
+ custom := i.(Marshaler)
+ data, _ := custom.Marshal()
+ n += sizeRawBytes(data)
+ return
+}
+
+func (o *Buffer) enc_custom_ref_bytes(p *Properties, base structPointer) error {
+ custom := structPointer_InterfaceAt(base, p.field, p.ctype).(Marshaler)
+ data, err := custom.Marshal()
+ if err != nil {
+ return err
+ }
+ if data == nil {
+ return ErrNil
+ }
+ o.buf = append(o.buf, p.tagcode...)
+ o.EncodeRawBytes(data)
+ return nil
+}
+
+func size_custom_ref_bytes(p *Properties, base structPointer) (n int) {
+ n += len(p.tagcode)
+ i := structPointer_InterfaceAt(base, p.field, p.ctype)
+ if i == nil {
+ return 0
+ }
+ custom := i.(Marshaler)
+ data, _ := custom.Marshal()
+ n += sizeRawBytes(data)
+ return
+}
+
+func (o *Buffer) enc_custom_slice_bytes(p *Properties, base structPointer) error {
+ inter := structPointer_InterfaceRef(base, p.field, p.ctype)
+ if inter == nil {
+ return ErrNil
+ }
+ slice := reflect.ValueOf(inter)
+ l := slice.Len()
+ for i := 0; i < l; i++ {
+ v := slice.Index(i)
+ custom := v.Interface().(Marshaler)
+ data, err := custom.Marshal()
+ if err != nil {
+ return err
+ }
+ o.buf = append(o.buf, p.tagcode...)
+ o.EncodeRawBytes(data)
+ }
+ return nil
+}
+
+func size_custom_slice_bytes(p *Properties, base structPointer) (n int) {
+ inter := structPointer_InterfaceRef(base, p.field, p.ctype)
+ if inter == nil {
+ return 0
+ }
+ slice := reflect.ValueOf(inter)
+ l := slice.Len()
+ n += l * len(p.tagcode)
+ for i := 0; i < l; i++ {
+ v := slice.Index(i)
+ custom := v.Interface().(Marshaler)
+ data, _ := custom.Marshal()
+ n += sizeRawBytes(data)
+ }
+ return
+}
diff --git a/vendor/github.com/gogo/protobuf/proto/equal.go b/vendor/github.com/gogo/protobuf/proto/equal.go
index d4db5a1c14..2ed1cf5966 100644
--- a/vendor/github.com/gogo/protobuf/proto/equal.go
+++ b/vendor/github.com/gogo/protobuf/proto/equal.go
@@ -109,6 +109,15 @@ func equalStruct(v1, v2 reflect.Value) bool {
// set/unset mismatch
return false
}
+ b1, ok := f1.Interface().(raw)
+ if ok {
+ b2 := f2.Interface().(raw)
+ // RawMessage
+ if !bytes.Equal(b1.Bytes(), b2.Bytes()) {
+ return false
+ }
+ continue
+ }
f1, f2 = f1.Elem(), f2.Elem()
}
if !equalAny(f1, f2, sprop.Prop[i]) {
@@ -137,7 +146,11 @@ func equalStruct(v1, v2 reflect.Value) bool {
u1 := uf.Bytes()
u2 := v2.FieldByName("XXX_unrecognized").Bytes()
- return bytes.Equal(u1, u2)
+ if !bytes.Equal(u1, u2) {
+ return false
+ }
+
+ return true
}
// v1 and v2 are known to have the same type.
@@ -248,15 +261,6 @@ func equalExtMap(base reflect.Type, em1, em2 map[int32]Extension) bool {
m1, m2 := e1.value, e2.value
- if m1 == nil && m2 == nil {
- // Both have only encoded form.
- if bytes.Equal(e1.enc, e2.enc) {
- continue
- }
- // The bytes are different, but the extensions might still be
- // equal. We need to decode them to compare.
- }
-
if m1 != nil && m2 != nil {
// Both are unencoded.
if !equalAny(reflect.ValueOf(m1), reflect.ValueOf(m2), nil) {
@@ -272,12 +276,8 @@ func equalExtMap(base reflect.Type, em1, em2 map[int32]Extension) bool {
desc = m[extNum]
}
if desc == nil {
- // If both have only encoded form and the bytes are the same,
- // it is handled above. We get here when the bytes are different.
- // We don't know how to decode it, so just compare them as byte
- // slices.
log.Printf("proto: don't know how to compare extension %d of %v", extNum, base)
- return false
+ continue
}
var err error
if m1 == nil {
diff --git a/vendor/github.com/gogo/protobuf/proto/extensions.go b/vendor/github.com/gogo/protobuf/proto/extensions.go
index 44ebd457cf..0dfcb538e8 100644
--- a/vendor/github.com/gogo/protobuf/proto/extensions.go
+++ b/vendor/github.com/gogo/protobuf/proto/extensions.go
@@ -38,7 +38,6 @@ package proto
import (
"errors"
"fmt"
- "io"
"reflect"
"strconv"
"sync"
@@ -70,6 +69,12 @@ type extendableProtoV1 interface {
ExtensionMap() map[int32]Extension
}
+type extensionsBytes interface {
+ Message
+ ExtensionRangeArray() []ExtensionRange
+ GetExtensions() *[]byte
+}
+
// extensionAdapter is a wrapper around extendableProtoV1 that implements extendableProto.
type extensionAdapter struct {
extendableProtoV1
@@ -92,31 +97,14 @@ func (n notLocker) Unlock() {}
// extendable returns the extendableProto interface for the given generated proto message.
// If the proto message has the old extension format, it returns a wrapper that implements
// the extendableProto interface.
-func extendable(p interface{}) (extendableProto, error) {
- switch p := p.(type) {
- case extendableProto:
- if isNilPtr(p) {
- return nil, fmt.Errorf("proto: nil %T is not extendable", p)
- }
- return p, nil
- case extendableProtoV1:
- if isNilPtr(p) {
- return nil, fmt.Errorf("proto: nil %T is not extendable", p)
- }
- return extensionAdapter{p}, nil
- case extensionsBytes:
- return slowExtensionAdapter{p}, nil
+func extendable(p interface{}) (extendableProto, bool) {
+ if ep, ok := p.(extendableProto); ok {
+ return ep, ok
}
- // Don't allocate a specific error containing %T:
- // this is the hot path for Clone and MarshalText.
- return nil, errNotExtendable
-}
-
-var errNotExtendable = errors.New("proto: not an extendable proto.Message")
-
-func isNilPtr(x interface{}) bool {
- v := reflect.ValueOf(x)
- return v.Kind() == reflect.Ptr && v.IsNil()
+ if ep, ok := p.(extendableProtoV1); ok {
+ return extensionAdapter{ep}, ok
+ }
+ return nil, false
}
// XXX_InternalExtensions is an internal representation of proto extensions.
@@ -161,6 +149,16 @@ func (e *XXX_InternalExtensions) extensionsRead() (map[int32]Extension, sync.Loc
return e.p.extensionMap, &e.p.mu
}
+type extensionRange interface {
+ Message
+ ExtensionRangeArray() []ExtensionRange
+}
+
+var extendableProtoType = reflect.TypeOf((*extendableProto)(nil)).Elem()
+var extendableProtoV1Type = reflect.TypeOf((*extendableProtoV1)(nil)).Elem()
+var extendableBytesType = reflect.TypeOf((*extensionsBytes)(nil)).Elem()
+var extensionRangeType = reflect.TypeOf((*extensionRange)(nil)).Elem()
+
// ExtensionDesc represents an extension specification.
// Used in generated code from the protocol compiler.
type ExtensionDesc struct {
@@ -200,8 +198,8 @@ func SetRawExtension(base Message, id int32, b []byte) {
*ext = append(*ext, b...)
return
}
- epb, err := extendable(base)
- if err != nil {
+ epb, ok := extendable(base)
+ if !ok {
return
}
extmap := epb.extensionsWrite()
@@ -209,7 +207,7 @@ func SetRawExtension(base Message, id int32, b []byte) {
}
// isExtensionField returns true iff the given field number is in an extension range.
-func isExtensionField(pb extendableProto, field int32) bool {
+func isExtensionField(pb extensionRange, field int32) bool {
for _, er := range pb.ExtensionRangeArray() {
if er.Start <= field && field <= er.End {
return true
@@ -225,11 +223,8 @@ func checkExtensionTypes(pb extendableProto, extension *ExtensionDesc) error {
if ea, ok := pbi.(extensionAdapter); ok {
pbi = ea.extendableProtoV1
}
- if ea, ok := pbi.(slowExtensionAdapter); ok {
- pbi = ea.extensionsBytes
- }
if a, b := reflect.TypeOf(pbi), reflect.TypeOf(extension.ExtendedType); a != b {
- return fmt.Errorf("proto: bad extended type; %v does not extend %v", b, a)
+ return errors.New("proto: bad extended type; " + b.String() + " does not extend " + a.String())
}
// Check the range.
if !isExtensionField(pb, extension.Field) {
@@ -274,6 +269,80 @@ func extensionProperties(ed *ExtensionDesc) *Properties {
return prop
}
+// encode encodes any unmarshaled (unencoded) extensions in e.
+func encodeExtensions(e *XXX_InternalExtensions) error {
+ m, mu := e.extensionsRead()
+ if m == nil {
+ return nil // fast path
+ }
+ mu.Lock()
+ defer mu.Unlock()
+ return encodeExtensionsMap(m)
+}
+
+// encode encodes any unmarshaled (unencoded) extensions in e.
+func encodeExtensionsMap(m map[int32]Extension) error {
+ for k, e := range m {
+ if e.value == nil || e.desc == nil {
+ // Extension is only in its encoded form.
+ continue
+ }
+
+ // We don't skip extensions that have an encoded form set,
+ // because the extension value may have been mutated after
+ // the last time this function was called.
+
+ et := reflect.TypeOf(e.desc.ExtensionType)
+ props := extensionProperties(e.desc)
+
+ p := NewBuffer(nil)
+ // If e.value has type T, the encoder expects a *struct{ X T }.
+ // Pass a *T with a zero field and hope it all works out.
+ x := reflect.New(et)
+ x.Elem().Set(reflect.ValueOf(e.value))
+ if err := props.enc(p, props, toStructPointer(x)); err != nil {
+ return err
+ }
+ e.enc = p.buf
+ m[k] = e
+ }
+ return nil
+}
+
+func extensionsSize(e *XXX_InternalExtensions) (n int) {
+ m, mu := e.extensionsRead()
+ if m == nil {
+ return 0
+ }
+ mu.Lock()
+ defer mu.Unlock()
+ return extensionsMapSize(m)
+}
+
+func extensionsMapSize(m map[int32]Extension) (n int) {
+ for _, e := range m {
+ if e.value == nil || e.desc == nil {
+ // Extension is only in its encoded form.
+ n += len(e.enc)
+ continue
+ }
+
+ // We don't skip extensions that have an encoded form set,
+ // because the extension value may have been mutated after
+ // the last time this function was called.
+
+ et := reflect.TypeOf(e.desc.ExtensionType)
+ props := extensionProperties(e.desc)
+
+ // If e.value has type T, the encoder expects a *struct{ X T }.
+ // Pass a *T with a zero field and hope it all works out.
+ x := reflect.New(et)
+ x.Elem().Set(reflect.ValueOf(e.value))
+ n += props.size(props, toStructPointer(x))
+ }
+ return
+}
+
// HasExtension returns whether the given extension is present in pb.
func HasExtension(pb Message, extension *ExtensionDesc) bool {
if epb, doki := pb.(extensionsBytes); doki {
@@ -297,8 +366,8 @@ func HasExtension(pb Message, extension *ExtensionDesc) bool {
return false
}
// TODO: Check types, field numbers, etc.?
- epb, err := extendable(pb)
- if err != nil {
+ epb, ok := extendable(pb)
+ if !ok {
return false
}
extmap, mu := epb.extensionsRead()
@@ -306,26 +375,46 @@ func HasExtension(pb Message, extension *ExtensionDesc) bool {
return false
}
mu.Lock()
- _, ok := extmap[extension.Field]
+ _, ok = extmap[extension.Field]
mu.Unlock()
return ok
}
+func deleteExtension(pb extensionsBytes, theFieldNum int32, offset int) int {
+ ext := pb.GetExtensions()
+ for offset < len(*ext) {
+ tag, n1 := DecodeVarint((*ext)[offset:])
+ fieldNum := int32(tag >> 3)
+ wireType := int(tag & 0x7)
+ n2, err := size((*ext)[offset+n1:], wireType)
+ if err != nil {
+ panic(err)
+ }
+ newOffset := offset + n1 + n2
+ if fieldNum == theFieldNum {
+ *ext = append((*ext)[:offset], (*ext)[newOffset:]...)
+ return offset
+ }
+ offset = newOffset
+ }
+ return -1
+}
+
// ClearExtension removes the given extension from pb.
func ClearExtension(pb Message, extension *ExtensionDesc) {
clearExtension(pb, extension.Field)
}
func clearExtension(pb Message, fieldNum int32) {
- if epb, ok := pb.(extensionsBytes); ok {
+ if epb, doki := pb.(extensionsBytes); doki {
offset := 0
for offset != -1 {
offset = deleteExtension(epb, fieldNum, offset)
}
return
}
- epb, err := extendable(pb)
- if err != nil {
+ epb, ok := extendable(pb)
+ if !ok {
return
}
// TODO: Check types, field numbers, etc.?
@@ -333,31 +422,37 @@ func clearExtension(pb Message, fieldNum int32) {
delete(extmap, fieldNum)
}
-// GetExtension retrieves a proto2 extended field from pb.
-//
-// If the descriptor is type complete (i.e., ExtensionDesc.ExtensionType is non-nil),
-// then GetExtension parses the encoded field and returns a Go value of the specified type.
-// If the field is not present, then the default value is returned (if one is specified),
-// otherwise ErrMissingExtension is reported.
-//
-// If the descriptor is not type complete (i.e., ExtensionDesc.ExtensionType is nil),
-// then GetExtension returns the raw encoded bytes of the field extension.
+// GetExtension parses and returns the given extension of pb.
+// If the extension is not present and has no default value it returns ErrMissingExtension.
func GetExtension(pb Message, extension *ExtensionDesc) (interface{}, error) {
if epb, doki := pb.(extensionsBytes); doki {
ext := epb.GetExtensions()
- return decodeExtensionFromBytes(extension, *ext)
- }
-
- epb, err := extendable(pb)
- if err != nil {
- return nil, err
- }
-
- if extension.ExtendedType != nil {
- // can only check type if this is a complete descriptor
- if cerr := checkExtensionTypes(epb, extension); cerr != nil {
- return nil, cerr
+ o := 0
+ for o < len(*ext) {
+ tag, n := DecodeVarint((*ext)[o:])
+ fieldNum := int32(tag >> 3)
+ wireType := int(tag & 0x7)
+ l, err := size((*ext)[o+n:], wireType)
+ if err != nil {
+ return nil, err
+ }
+ if int32(fieldNum) == extension.Field {
+ v, err := decodeExtension((*ext)[o:o+n+l], extension)
+ if err != nil {
+ return nil, err
+ }
+ return v, nil
+ }
+ o += n + l
}
+ return defaultExtensionValue(extension)
+ }
+ epb, ok := extendable(pb)
+ if !ok {
+ return nil, errors.New("proto: not an extendable proto")
+ }
+ if err := checkExtensionTypes(epb, extension); err != nil {
+ return nil, err
}
emap, mu := epb.extensionsRead()
@@ -384,11 +479,6 @@ func GetExtension(pb Message, extension *ExtensionDesc) (interface{}, error) {
return e.value, nil
}
- if extension.ExtensionType == nil {
- // incomplete descriptor
- return e.enc, nil
- }
-
v, err := decodeExtension(e.enc, extension)
if err != nil {
return nil, err
@@ -406,11 +496,6 @@ func GetExtension(pb Message, extension *ExtensionDesc) (interface{}, error) {
// defaultExtensionValue returns the default value for extension.
// If no default for an extension is defined ErrMissingExtension is returned.
func defaultExtensionValue(extension *ExtensionDesc) (interface{}, error) {
- if extension.ExtensionType == nil {
- // incomplete descriptor, so no default
- return nil, ErrMissingExtension
- }
-
t := reflect.TypeOf(extension.ExtensionType)
props := extensionProperties(extension)
@@ -445,28 +530,31 @@ func defaultExtensionValue(extension *ExtensionDesc) (interface{}, error) {
// decodeExtension decodes an extension encoded in b.
func decodeExtension(b []byte, extension *ExtensionDesc) (interface{}, error) {
+ o := NewBuffer(b)
+
t := reflect.TypeOf(extension.ExtensionType)
- unmarshal := typeUnmarshaler(t, extension.Tag)
+
+ props := extensionProperties(extension)
// t is a pointer to a struct, pointer to basic type or a slice.
- // Allocate space to store the pointer/slice.
+ // Allocate a "field" to store the pointer/slice itself; the
+ // pointer/slice will be stored here. We pass
+ // the address of this field to props.dec.
+ // This passes a zero field and a *t and lets props.dec
+ // interpret it as a *struct{ x t }.
value := reflect.New(t).Elem()
- var err error
for {
- x, n := decodeVarint(b)
- if n == 0 {
- return nil, io.ErrUnexpectedEOF
- }
- b = b[n:]
- wire := int(x) & 7
-
- b, err = unmarshal(b, valToPointer(value.Addr()), wire)
- if err != nil {
+ // Discard wire type and field number varint. It isn't needed.
+ if _, err := o.DecodeVarint(); err != nil {
return nil, err
}
- if len(b) == 0 {
+ if err := props.dec(o, props, toStructPointer(value.Addr())); err != nil {
+ return nil, err
+ }
+
+ if o.index >= len(o.buf) {
break
}
}
@@ -476,13 +564,9 @@ func decodeExtension(b []byte, extension *ExtensionDesc) (interface{}, error) {
// GetExtensions returns a slice of the extensions present in pb that are also listed in es.
// The returned slice has the same length as es; missing extensions will appear as nil elements.
func GetExtensions(pb Message, es []*ExtensionDesc) (extensions []interface{}, err error) {
- epb, err := extendable(pb)
- if err != nil {
- return nil, err
- }
extensions = make([]interface{}, len(es))
for i, e := range es {
- extensions[i], err = GetExtension(epb, e)
+ extensions[i], err = GetExtension(pb, e)
if err == ErrMissingExtension {
err = nil
}
@@ -497,9 +581,9 @@ func GetExtensions(pb Message, es []*ExtensionDesc) (extensions []interface{}, e
// For non-registered extensions, ExtensionDescs returns an incomplete descriptor containing
// just the Field field, which defines the extension's field number.
func ExtensionDescs(pb Message) ([]*ExtensionDesc, error) {
- epb, err := extendable(pb)
- if err != nil {
- return nil, err
+ epb, ok := extendable(pb)
+ if !ok {
+ return nil, fmt.Errorf("proto: %T is not an extendable proto.Message", pb)
}
registeredExtensions := RegisteredExtensions(pb)
@@ -526,18 +610,23 @@ func ExtensionDescs(pb Message) ([]*ExtensionDesc, error) {
// SetExtension sets the specified extension of pb to the specified value.
func SetExtension(pb Message, extension *ExtensionDesc, value interface{}) error {
- if epb, ok := pb.(extensionsBytes); ok {
- newb, err := encodeExtension(extension, value)
- if err != nil {
+ if epb, doki := pb.(extensionsBytes); doki {
+ ClearExtension(pb, extension)
+ ext := epb.GetExtensions()
+ et := reflect.TypeOf(extension.ExtensionType)
+ props := extensionProperties(extension)
+ p := NewBuffer(nil)
+ x := reflect.New(et)
+ x.Elem().Set(reflect.ValueOf(value))
+ if err := props.enc(p, props, toStructPointer(x)); err != nil {
return err
}
- bb := epb.GetExtensions()
- *bb = append(*bb, newb...)
+ *ext = append(*ext, p.buf...)
return nil
}
- epb, err := extendable(pb)
- if err != nil {
- return err
+ epb, ok := extendable(pb)
+ if !ok {
+ return errors.New("proto: not an extendable proto")
}
if err := checkExtensionTypes(epb, extension); err != nil {
return err
@@ -567,8 +656,8 @@ func ClearAllExtensions(pb Message) {
*ext = []byte{}
return
}
- epb, err := extendable(pb)
- if err != nil {
+ epb, ok := extendable(pb)
+ if !ok {
return
}
m := epb.extensionsWrite()
diff --git a/vendor/github.com/gogo/protobuf/proto/extensions_gogo.go b/vendor/github.com/gogo/protobuf/proto/extensions_gogo.go
index 53ebd8cca0..ea6478f009 100644
--- a/vendor/github.com/gogo/protobuf/proto/extensions_gogo.go
+++ b/vendor/github.com/gogo/protobuf/proto/extensions_gogo.go
@@ -32,36 +32,12 @@ import (
"bytes"
"errors"
"fmt"
- "io"
"reflect"
"sort"
"strings"
"sync"
)
-type extensionsBytes interface {
- Message
- ExtensionRangeArray() []ExtensionRange
- GetExtensions() *[]byte
-}
-
-type slowExtensionAdapter struct {
- extensionsBytes
-}
-
-func (s slowExtensionAdapter) extensionsWrite() map[int32]Extension {
- panic("Please report a bug to github.com/gogo/protobuf if you see this message: Writing extensions is not supported for extensions stored in a byte slice field.")
-}
-
-func (s slowExtensionAdapter) extensionsRead() (map[int32]Extension, sync.Locker) {
- b := s.GetExtensions()
- m, err := BytesToExtensionsMap(*b)
- if err != nil {
- panic(err)
- }
- return m, notLocker{}
-}
-
func GetBoolExtension(pb Message, extension *ExtensionDesc, ifnotset bool) bool {
if reflect.ValueOf(pb).IsNil() {
return ifnotset
@@ -80,28 +56,19 @@ func GetBoolExtension(pb Message, extension *ExtensionDesc, ifnotset bool) bool
}
func (this *Extension) Equal(that *Extension) bool {
- if err := this.Encode(); err != nil {
- return false
- }
- if err := that.Encode(); err != nil {
- return false
- }
return bytes.Equal(this.enc, that.enc)
}
func (this *Extension) Compare(that *Extension) int {
- if err := this.Encode(); err != nil {
- return 1
- }
- if err := that.Encode(); err != nil {
- return -1
- }
return bytes.Compare(this.enc, that.enc)
}
func SizeOfInternalExtension(m extendableProto) (n int) {
- info := getMarshalInfo(reflect.TypeOf(m))
- return info.sizeV1Extensions(m.extensionsWrite())
+ return SizeOfExtensionMap(m.extensionsWrite())
+}
+
+func SizeOfExtensionMap(m map[int32]Extension) (n int) {
+ return extensionsMapSize(m)
}
type sortableMapElem struct {
@@ -155,26 +122,28 @@ func EncodeInternalExtension(m extendableProto, data []byte) (n int, err error)
}
func EncodeExtensionMap(m map[int32]Extension, data []byte) (n int, err error) {
- o := 0
- for _, e := range m {
- if err := e.Encode(); err != nil {
- return 0, err
- }
- n := copy(data[o:], e.enc)
- if n != len(e.enc) {
- return 0, io.ErrShortBuffer
- }
- o += n
+ if err := encodeExtensionsMap(m); err != nil {
+ return 0, err
}
- return o, nil
+ keys := make([]int, 0, len(m))
+ for k := range m {
+ keys = append(keys, int(k))
+ }
+ sort.Ints(keys)
+ for _, k := range keys {
+ n += copy(data[n:], m[int32(k)].enc)
+ }
+ return n, nil
}
func GetRawExtension(m map[int32]Extension, id int32) ([]byte, error) {
- e := m[id]
- if err := e.Encode(); err != nil {
+ if m[id].value == nil || m[id].desc == nil {
+ return m[id].enc, nil
+ }
+ if err := encodeExtensionsMap(m); err != nil {
return nil, err
}
- return e.enc, nil
+ return m[id].enc, nil
}
func size(buf []byte, wire int) (int, error) {
@@ -249,58 +218,35 @@ func AppendExtension(e Message, tag int32, buf []byte) {
}
}
-func encodeExtension(extension *ExtensionDesc, value interface{}) ([]byte, error) {
- u := getMarshalInfo(reflect.TypeOf(extension.ExtendedType))
- ei := u.getExtElemInfo(extension)
- v := value
- p := toAddrPointer(&v, ei.isptr)
- siz := ei.sizer(p, SizeVarint(ei.wiretag))
- buf := make([]byte, 0, siz)
- return ei.marshaler(buf, p, ei.wiretag, false)
-}
-
-func decodeExtensionFromBytes(extension *ExtensionDesc, buf []byte) (interface{}, error) {
- o := 0
- for o < len(buf) {
- tag, n := DecodeVarint((buf)[o:])
- fieldNum := int32(tag >> 3)
- wireType := int(tag & 0x7)
- if o+n > len(buf) {
- return nil, fmt.Errorf("unable to decode extension")
- }
- l, err := size((buf)[o+n:], wireType)
- if err != nil {
- return nil, err
- }
- if int32(fieldNum) == extension.Field {
- if o+n+l > len(buf) {
- return nil, fmt.Errorf("unable to decode extension")
- }
- v, err := decodeExtension((buf)[o:o+n+l], extension)
- if err != nil {
- return nil, err
- }
- return v, nil
- }
- o += n + l
+func encodeExtension(e *Extension) error {
+ if e.value == nil || e.desc == nil {
+ // Extension is only in its encoded form.
+ return nil
}
- return defaultExtensionValue(extension)
-}
+ // We don't skip extensions that have an encoded form set,
+ // because the extension value may have been mutated after
+ // the last time this function was called.
-func (this *Extension) Encode() error {
- if this.enc == nil {
- var err error
- this.enc, err = encodeExtension(this.desc, this.value)
- if err != nil {
- return err
- }
+ et := reflect.TypeOf(e.desc.ExtensionType)
+ props := extensionProperties(e.desc)
+
+ p := NewBuffer(nil)
+ // If e.value has type T, the encoder expects a *struct{ X T }.
+ // Pass a *T with a zero field and hope it all works out.
+ x := reflect.New(et)
+ x.Elem().Set(reflect.ValueOf(e.value))
+ if err := props.enc(p, props, toStructPointer(x)); err != nil {
+ return err
}
+ e.enc = p.buf
return nil
}
func (this Extension) GoString() string {
- if err := this.Encode(); err != nil {
- return fmt.Sprintf("error encoding extension: %v", err)
+ if this.enc == nil {
+ if err := encodeExtension(&this); err != nil {
+ panic(err)
+ }
}
return fmt.Sprintf("proto.NewExtension(%#v)", this.enc)
}
@@ -346,23 +292,3 @@ func GetUnsafeExtensionsMap(extendable Message) map[int32]Extension {
pb := extendable.(extendableProto)
return pb.extensionsWrite()
}
-
-func deleteExtension(pb extensionsBytes, theFieldNum int32, offset int) int {
- ext := pb.GetExtensions()
- for offset < len(*ext) {
- tag, n1 := DecodeVarint((*ext)[offset:])
- fieldNum := int32(tag >> 3)
- wireType := int(tag & 0x7)
- n2, err := size((*ext)[offset+n1:], wireType)
- if err != nil {
- panic(err)
- }
- newOffset := offset + n1 + n2
- if fieldNum == theFieldNum {
- *ext = append((*ext)[:offset], (*ext)[newOffset:]...)
- return offset
- }
- offset = newOffset
- }
- return -1
-}
diff --git a/vendor/github.com/gogo/protobuf/proto/lib.go b/vendor/github.com/gogo/protobuf/proto/lib.go
index 0f1950c67e..c98d73da49 100644
--- a/vendor/github.com/gogo/protobuf/proto/lib.go
+++ b/vendor/github.com/gogo/protobuf/proto/lib.go
@@ -265,7 +265,6 @@ package proto
import (
"encoding/json"
- "errors"
"fmt"
"log"
"reflect"
@@ -274,8 +273,6 @@ import (
"sync"
)
-var errInvalidUTF8 = errors.New("proto: invalid UTF-8 string")
-
// Message is implemented by generated protocol buffer messages.
type Message interface {
Reset()
@@ -312,7 +309,16 @@ type Buffer struct {
buf []byte // encode/decode byte stream
index int // read point
- deterministic bool
+ // pools of basic types to amortize allocation.
+ bools []bool
+ uint32s []uint32
+ uint64s []uint64
+
+ // extra pools, only used with pointer_reflect.go
+ int32s []int32
+ int64s []int64
+ float32s []float32
+ float64s []float64
}
// NewBuffer allocates a new Buffer and initializes its internal data to
@@ -337,30 +343,6 @@ func (p *Buffer) SetBuf(s []byte) {
// Bytes returns the contents of the Buffer.
func (p *Buffer) Bytes() []byte { return p.buf }
-// SetDeterministic sets whether to use deterministic serialization.
-//
-// Deterministic serialization guarantees that for a given binary, equal
-// messages will always be serialized to the same bytes. This implies:
-//
-// - Repeated serialization of a message will return the same bytes.
-// - Different processes of the same binary (which may be executing on
-// different machines) will serialize equal messages to the same bytes.
-//
-// Note that the deterministic serialization is NOT canonical across
-// languages. It is not guaranteed to remain stable over time. It is unstable
-// across different builds with schema changes due to unknown fields.
-// Users who need canonical serialization (e.g., persistent storage in a
-// canonical form, fingerprinting, etc.) should define their own
-// canonicalization specification and implement their own serializer rather
-// 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
-// subject to change.
-func (p *Buffer) SetDeterministic(deterministic bool) {
- p.deterministic = deterministic
-}
-
/*
* Helper routines for simplifying the creation of optional fields of basic type.
*/
@@ -849,12 +831,22 @@ func fieldDefault(ft reflect.Type, prop *Properties) (sf *scalarField, nestedMes
return sf, false, nil
}
-// mapKeys returns a sort.Interface to be used for sorting the map keys.
// Map fields may have key types of non-float scalars, strings and enums.
-func mapKeys(vs []reflect.Value) sort.Interface {
- s := mapKeySorter{vs: vs}
+// The easiest way to sort them in some deterministic order is to use fmt.
+// If this turns out to be inefficient we can always consider other options,
+// such as doing a Schwartzian transform.
- // Type specialization per https://developers.google.com/protocol-buffers/docs/proto#maps.
+func mapKeys(vs []reflect.Value) sort.Interface {
+ s := mapKeySorter{
+ vs: vs,
+ // default Less function: textual comparison
+ less: func(a, b reflect.Value) bool {
+ return fmt.Sprint(a.Interface()) < fmt.Sprint(b.Interface())
+ },
+ }
+
+ // Type specialization per https://developers.google.com/protocol-buffers/docs/proto#maps;
+ // numeric keys are sorted numerically.
if len(vs) == 0 {
return s
}
@@ -863,12 +855,6 @@ func mapKeys(vs []reflect.Value) sort.Interface {
s.less = func(a, b reflect.Value) bool { return a.Int() < b.Int() }
case reflect.Uint32, reflect.Uint64:
s.less = func(a, b reflect.Value) bool { return a.Uint() < b.Uint() }
- case reflect.Bool:
- s.less = func(a, b reflect.Value) bool { return !a.Bool() && b.Bool() } // false < true
- case reflect.String:
- s.less = func(a, b reflect.Value) bool { return a.String() < b.String() }
- default:
- panic(fmt.Sprintf("unsupported map key type: %v", vs[0].Kind()))
}
return s
@@ -909,13 +895,3 @@ const GoGoProtoPackageIsVersion2 = true
// ProtoPackageIsVersion1 is referenced from generated protocol buffer files
// to assert that that code is compatible with this version of the proto package.
const GoGoProtoPackageIsVersion1 = true
-
-// InternalMessageInfo is a type used internally by generated .pb.go files.
-// This type is not intended to be used by non-generated code.
-// This type is not subject to any compatibility guarantee.
-type InternalMessageInfo struct {
- marshal *marshalInfo
- unmarshal *unmarshalInfo
- merge *mergeInfo
- discard *discardInfo
-}
diff --git a/vendor/github.com/gogo/protobuf/proto/lib_gogo.go b/vendor/github.com/gogo/protobuf/proto/lib_gogo.go
index b3aa39190a..4b4f7c909e 100644
--- a/vendor/github.com/gogo/protobuf/proto/lib_gogo.go
+++ b/vendor/github.com/gogo/protobuf/proto/lib_gogo.go
@@ -33,14 +33,6 @@ import (
"strconv"
)
-type Sizer interface {
- Size() int
-}
-
-type ProtoSizer interface {
- ProtoSize() int
-}
-
func MarshalJSONEnum(m map[int32]string, value int32) ([]byte, error) {
s, ok := m[value]
if !ok {
diff --git a/vendor/github.com/gogo/protobuf/proto/message_set.go b/vendor/github.com/gogo/protobuf/proto/message_set.go
index 3b6ca41d5e..fd982decd6 100644
--- a/vendor/github.com/gogo/protobuf/proto/message_set.go
+++ b/vendor/github.com/gogo/protobuf/proto/message_set.go
@@ -42,7 +42,6 @@ import (
"fmt"
"reflect"
"sort"
- "sync"
)
// errNoMessageTypeID occurs when a protocol buffer does not have a message type ID.
@@ -95,7 +94,10 @@ func (ms *messageSet) find(pb Message) *_MessageSet_Item {
}
func (ms *messageSet) Has(pb Message) bool {
- return ms.find(pb) != nil
+ if ms.find(pb) != nil {
+ return true
+ }
+ return false
}
func (ms *messageSet) Unmarshal(pb Message) error {
@@ -148,42 +150,46 @@ func skipVarint(buf []byte) []byte {
// MarshalMessageSet encodes the extension map represented by m in the message set wire format.
// It is called by generated Marshal methods on protocol buffer messages with the message_set_wire_format option.
func MarshalMessageSet(exts interface{}) ([]byte, error) {
- return marshalMessageSet(exts, false)
-}
-
-// marshaMessageSet implements above function, with the opt to turn on / off deterministic during Marshal.
-func marshalMessageSet(exts interface{}, deterministic bool) ([]byte, error) {
+ var m map[int32]Extension
switch exts := exts.(type) {
case *XXX_InternalExtensions:
- var u marshalInfo
- siz := u.sizeMessageSet(exts)
- b := make([]byte, 0, siz)
- return u.appendMessageSet(b, exts, deterministic)
-
- case map[int32]Extension:
- // This is an old-style extension map.
- // Wrap it in a new-style XXX_InternalExtensions.
- ie := XXX_InternalExtensions{
- p: &struct {
- mu sync.Mutex
- extensionMap map[int32]Extension
- }{
- extensionMap: exts,
- },
+ if err := encodeExtensions(exts); err != nil {
+ return nil, err
}
-
- var u marshalInfo
- siz := u.sizeMessageSet(&ie)
- b := make([]byte, 0, siz)
- return u.appendMessageSet(b, &ie, deterministic)
-
+ m, _ = exts.extensionsRead()
+ case map[int32]Extension:
+ if err := encodeExtensionsMap(exts); err != nil {
+ return nil, err
+ }
+ m = exts
default:
return nil, errors.New("proto: not an extension map")
}
+
+ // Sort extension IDs to provide a deterministic encoding.
+ // See also enc_map in encode.go.
+ ids := make([]int, 0, len(m))
+ for id := range m {
+ ids = append(ids, int(id))
+ }
+ sort.Ints(ids)
+
+ ms := &messageSet{Item: make([]*_MessageSet_Item, 0, len(m))}
+ for _, id := range ids {
+ e := m[int32(id)]
+ // Remove the wire type and field number varint, as well as the length varint.
+ msg := skipVarint(skipVarint(e.enc))
+
+ ms.Item = append(ms.Item, &_MessageSet_Item{
+ TypeId: Int32(int32(id)),
+ Message: msg,
+ })
+ }
+ return Marshal(ms)
}
// UnmarshalMessageSet decodes the extension map encoded in buf in the message set wire format.
-// It is called by Unmarshal methods on protocol buffer messages with the message_set_wire_format option.
+// It is called by generated Unmarshal methods on protocol buffer messages with the message_set_wire_format option.
func UnmarshalMessageSet(buf []byte, exts interface{}) error {
var m map[int32]Extension
switch exts := exts.(type) {
@@ -229,15 +235,7 @@ func MarshalMessageSetJSON(exts interface{}) ([]byte, error) {
var m map[int32]Extension
switch exts := exts.(type) {
case *XXX_InternalExtensions:
- var mu sync.Locker
- m, mu = exts.extensionsRead()
- if m != nil {
- // Keep the extensions map locked until we're done marshaling to prevent
- // races between marshaling and unmarshaling the lazily-{en,de}coded
- // values.
- mu.Lock()
- defer mu.Unlock()
- }
+ m, _ = exts.extensionsRead()
case map[int32]Extension:
m = exts
default:
@@ -255,16 +253,15 @@ func MarshalMessageSetJSON(exts interface{}) ([]byte, error) {
for i, id := range ids {
ext := m[id]
+ if i > 0 {
+ b.WriteByte(',')
+ }
+
msd, ok := messageSetMap[id]
if !ok {
// Unknown type; we can't render it, so skip it.
continue
}
-
- if i > 0 && b.Len() > 1 {
- b.WriteByte(',')
- }
-
fmt.Fprintf(&b, `"[%s]":`, msd.name)
x := ext.value
diff --git a/vendor/github.com/gogo/protobuf/proto/pointer_reflect.go b/vendor/github.com/gogo/protobuf/proto/pointer_reflect.go
index b6cad90834..fb512e2e16 100644
--- a/vendor/github.com/gogo/protobuf/proto/pointer_reflect.go
+++ b/vendor/github.com/gogo/protobuf/proto/pointer_reflect.go
@@ -29,7 +29,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-// +build purego appengine js
+// +build appengine js
// This file contains an implementation of proto field accesses using package reflect.
// It is slower than the code in pointer_unsafe.go but it avoids package unsafe and can
@@ -38,13 +38,32 @@
package proto
import (
+ "math"
"reflect"
- "sync"
)
-const unsafeAllowed = false
+// A structPointer is a pointer to a struct.
+type structPointer struct {
+ v reflect.Value
+}
-// A field identifies a field in a struct, accessible from a pointer.
+// toStructPointer returns a structPointer equivalent to the given reflect value.
+// The reflect value must itself be a pointer to a struct.
+func toStructPointer(v reflect.Value) structPointer {
+ return structPointer{v}
+}
+
+// IsNil reports whether p is nil.
+func structPointer_IsNil(p structPointer) bool {
+ return p.v.IsNil()
+}
+
+// Interface returns the struct pointer as an interface value.
+func structPointer_Interface(p structPointer, _ reflect.Type) interface{} {
+ return p.v.Interface()
+}
+
+// A field identifies a field in a struct, accessible from a structPointer.
// In this implementation, a field is identified by the sequence of field indices
// passed to reflect's FieldByIndex.
type field []int
@@ -57,301 +76,409 @@ func toField(f *reflect.StructField) field {
// invalidField is an invalid field identifier.
var invalidField = field(nil)
-// zeroField is a noop when calling pointer.offset.
-var zeroField = field([]int{})
-
// IsValid reports whether the field identifier is valid.
func (f field) IsValid() bool { return f != nil }
-// The pointer type is for the table-driven decoder.
-// The implementation here uses a reflect.Value of pointer type to
-// create a generic pointer. In pointer_unsafe.go we use unsafe
-// instead of reflect to implement the same (but faster) interface.
-type pointer struct {
+// field returns the given field in the struct as a reflect value.
+func structPointer_field(p structPointer, f field) reflect.Value {
+ // Special case: an extension map entry with a value of type T
+ // passes a *T to the struct-handling code with a zero field,
+ // expecting that it will be treated as equivalent to *struct{ X T },
+ // which has the same memory layout. We have to handle that case
+ // specially, because reflect will panic if we call FieldByIndex on a
+ // non-struct.
+ if f == nil {
+ return p.v.Elem()
+ }
+
+ return p.v.Elem().FieldByIndex(f)
+}
+
+// ifield returns the given field in the struct as an interface value.
+func structPointer_ifield(p structPointer, f field) interface{} {
+ return structPointer_field(p, f).Addr().Interface()
+}
+
+// Bytes returns the address of a []byte field in the struct.
+func structPointer_Bytes(p structPointer, f field) *[]byte {
+ return structPointer_ifield(p, f).(*[]byte)
+}
+
+// BytesSlice returns the address of a [][]byte field in the struct.
+func structPointer_BytesSlice(p structPointer, f field) *[][]byte {
+ return structPointer_ifield(p, f).(*[][]byte)
+}
+
+// Bool returns the address of a *bool field in the struct.
+func structPointer_Bool(p structPointer, f field) **bool {
+ return structPointer_ifield(p, f).(**bool)
+}
+
+// BoolVal returns the address of a bool field in the struct.
+func structPointer_BoolVal(p structPointer, f field) *bool {
+ return structPointer_ifield(p, f).(*bool)
+}
+
+// BoolSlice returns the address of a []bool field in the struct.
+func structPointer_BoolSlice(p structPointer, f field) *[]bool {
+ return structPointer_ifield(p, f).(*[]bool)
+}
+
+// String returns the address of a *string field in the struct.
+func structPointer_String(p structPointer, f field) **string {
+ return structPointer_ifield(p, f).(**string)
+}
+
+// StringVal returns the address of a string field in the struct.
+func structPointer_StringVal(p structPointer, f field) *string {
+ return structPointer_ifield(p, f).(*string)
+}
+
+// StringSlice returns the address of a []string field in the struct.
+func structPointer_StringSlice(p structPointer, f field) *[]string {
+ return structPointer_ifield(p, f).(*[]string)
+}
+
+// Extensions returns the address of an extension map field in the struct.
+func structPointer_Extensions(p structPointer, f field) *XXX_InternalExtensions {
+ return structPointer_ifield(p, f).(*XXX_InternalExtensions)
+}
+
+// ExtMap returns the address of an extension map field in the struct.
+func structPointer_ExtMap(p structPointer, f field) *map[int32]Extension {
+ return structPointer_ifield(p, f).(*map[int32]Extension)
+}
+
+// NewAt returns the reflect.Value for a pointer to a field in the struct.
+func structPointer_NewAt(p structPointer, f field, typ reflect.Type) reflect.Value {
+ return structPointer_field(p, f).Addr()
+}
+
+// SetStructPointer writes a *struct field in the struct.
+func structPointer_SetStructPointer(p structPointer, f field, q structPointer) {
+ structPointer_field(p, f).Set(q.v)
+}
+
+// GetStructPointer reads a *struct field in the struct.
+func structPointer_GetStructPointer(p structPointer, f field) structPointer {
+ return structPointer{structPointer_field(p, f)}
+}
+
+// StructPointerSlice the address of a []*struct field in the struct.
+func structPointer_StructPointerSlice(p structPointer, f field) structPointerSlice {
+ return structPointerSlice{structPointer_field(p, f)}
+}
+
+// A structPointerSlice represents the address of a slice of pointers to structs
+// (themselves messages or groups). That is, v.Type() is *[]*struct{...}.
+type structPointerSlice struct {
v reflect.Value
}
-// toPointer converts an interface of pointer type to a pointer
-// that points to the same target.
-func toPointer(i *Message) pointer {
- return pointer{v: reflect.ValueOf(*i)}
+func (p structPointerSlice) Len() int { return p.v.Len() }
+func (p structPointerSlice) Index(i int) structPointer { return structPointer{p.v.Index(i)} }
+func (p structPointerSlice) Append(q structPointer) {
+ p.v.Set(reflect.Append(p.v, q.v))
}
-// toAddrPointer converts an interface to a pointer that points to
-// the interface data.
-func toAddrPointer(i *interface{}, isptr bool) pointer {
- v := reflect.ValueOf(*i)
- u := reflect.New(v.Type())
- u.Elem().Set(v)
- return pointer{v: u}
+var (
+ int32Type = reflect.TypeOf(int32(0))
+ uint32Type = reflect.TypeOf(uint32(0))
+ float32Type = reflect.TypeOf(float32(0))
+ int64Type = reflect.TypeOf(int64(0))
+ uint64Type = reflect.TypeOf(uint64(0))
+ float64Type = reflect.TypeOf(float64(0))
+)
+
+// A word32 represents a field of type *int32, *uint32, *float32, or *enum.
+// That is, v.Type() is *int32, *uint32, *float32, or *enum and v is assignable.
+type word32 struct {
+ v reflect.Value
}
-// valToPointer converts v to a pointer. v must be of pointer type.
-func valToPointer(v reflect.Value) pointer {
- return pointer{v: v}
-}
-
-// offset converts from a pointer to a structure to a pointer to
-// one of its fields.
-func (p pointer) offset(f field) pointer {
- return pointer{v: p.v.Elem().FieldByIndex(f).Addr()}
-}
-
-func (p pointer) isNil() bool {
+// IsNil reports whether p is nil.
+func word32_IsNil(p word32) bool {
return p.v.IsNil()
}
-// grow updates the slice s in place to make it one element longer.
-// s must be addressable.
-// Returns the (addressable) new element.
-func grow(s reflect.Value) reflect.Value {
- n, m := s.Len(), s.Cap()
+// Set sets p to point at a newly allocated word with bits set to x.
+func word32_Set(p word32, o *Buffer, x uint32) {
+ t := p.v.Type().Elem()
+ switch t {
+ case int32Type:
+ if len(o.int32s) == 0 {
+ o.int32s = make([]int32, uint32PoolSize)
+ }
+ o.int32s[0] = int32(x)
+ p.v.Set(reflect.ValueOf(&o.int32s[0]))
+ o.int32s = o.int32s[1:]
+ return
+ case uint32Type:
+ if len(o.uint32s) == 0 {
+ o.uint32s = make([]uint32, uint32PoolSize)
+ }
+ o.uint32s[0] = x
+ p.v.Set(reflect.ValueOf(&o.uint32s[0]))
+ o.uint32s = o.uint32s[1:]
+ return
+ case float32Type:
+ if len(o.float32s) == 0 {
+ o.float32s = make([]float32, uint32PoolSize)
+ }
+ o.float32s[0] = math.Float32frombits(x)
+ p.v.Set(reflect.ValueOf(&o.float32s[0]))
+ o.float32s = o.float32s[1:]
+ return
+ }
+
+ // must be enum
+ p.v.Set(reflect.New(t))
+ p.v.Elem().SetInt(int64(int32(x)))
+}
+
+// Get gets the bits pointed at by p, as a uint32.
+func word32_Get(p word32) uint32 {
+ elem := p.v.Elem()
+ switch elem.Kind() {
+ case reflect.Int32:
+ return uint32(elem.Int())
+ case reflect.Uint32:
+ return uint32(elem.Uint())
+ case reflect.Float32:
+ return math.Float32bits(float32(elem.Float()))
+ }
+ panic("unreachable")
+}
+
+// Word32 returns a reference to a *int32, *uint32, *float32, or *enum field in the struct.
+func structPointer_Word32(p structPointer, f field) word32 {
+ return word32{structPointer_field(p, f)}
+}
+
+// A word32Val represents a field of type int32, uint32, float32, or enum.
+// That is, v.Type() is int32, uint32, float32, or enum and v is assignable.
+type word32Val struct {
+ v reflect.Value
+}
+
+// Set sets *p to x.
+func word32Val_Set(p word32Val, x uint32) {
+ switch p.v.Type() {
+ case int32Type:
+ p.v.SetInt(int64(x))
+ return
+ case uint32Type:
+ p.v.SetUint(uint64(x))
+ return
+ case float32Type:
+ p.v.SetFloat(float64(math.Float32frombits(x)))
+ return
+ }
+
+ // must be enum
+ p.v.SetInt(int64(int32(x)))
+}
+
+// Get gets the bits pointed at by p, as a uint32.
+func word32Val_Get(p word32Val) uint32 {
+ elem := p.v
+ switch elem.Kind() {
+ case reflect.Int32:
+ return uint32(elem.Int())
+ case reflect.Uint32:
+ return uint32(elem.Uint())
+ case reflect.Float32:
+ return math.Float32bits(float32(elem.Float()))
+ }
+ panic("unreachable")
+}
+
+// Word32Val returns a reference to a int32, uint32, float32, or enum field in the struct.
+func structPointer_Word32Val(p structPointer, f field) word32Val {
+ return word32Val{structPointer_field(p, f)}
+}
+
+// A word32Slice is a slice of 32-bit values.
+// That is, v.Type() is []int32, []uint32, []float32, or []enum.
+type word32Slice struct {
+ v reflect.Value
+}
+
+func (p word32Slice) Append(x uint32) {
+ n, m := p.v.Len(), p.v.Cap()
if n < m {
- s.SetLen(n + 1)
+ p.v.SetLen(n + 1)
} else {
- s.Set(reflect.Append(s, reflect.Zero(s.Type().Elem())))
+ t := p.v.Type().Elem()
+ p.v.Set(reflect.Append(p.v, reflect.Zero(t)))
}
- return s.Index(n)
-}
-
-func (p pointer) toInt64() *int64 {
- return p.v.Interface().(*int64)
-}
-func (p pointer) toInt64Ptr() **int64 {
- return p.v.Interface().(**int64)
-}
-func (p pointer) toInt64Slice() *[]int64 {
- return p.v.Interface().(*[]int64)
-}
-
-var int32ptr = reflect.TypeOf((*int32)(nil))
-
-func (p pointer) toInt32() *int32 {
- return p.v.Convert(int32ptr).Interface().(*int32)
-}
-
-// The toInt32Ptr/Slice methods don't work because of enums.
-// Instead, we must use set/get methods for the int32ptr/slice case.
-/*
- func (p pointer) toInt32Ptr() **int32 {
- return p.v.Interface().(**int32)
-}
- func (p pointer) toInt32Slice() *[]int32 {
- return p.v.Interface().(*[]int32)
-}
-*/
-func (p pointer) getInt32Ptr() *int32 {
- if p.v.Type().Elem().Elem() == reflect.TypeOf(int32(0)) {
- // raw int32 type
- return p.v.Elem().Interface().(*int32)
+ elem := p.v.Index(n)
+ switch elem.Kind() {
+ case reflect.Int32:
+ elem.SetInt(int64(int32(x)))
+ case reflect.Uint32:
+ elem.SetUint(uint64(x))
+ case reflect.Float32:
+ elem.SetFloat(float64(math.Float32frombits(x)))
}
- // an enum
- return p.v.Elem().Convert(int32PtrType).Interface().(*int32)
-}
-func (p pointer) setInt32Ptr(v int32) {
- // Allocate value in a *int32. Possibly convert that to a *enum.
- // Then assign it to a **int32 or **enum.
- // Note: we can convert *int32 to *enum, but we can't convert
- // **int32 to **enum!
- p.v.Elem().Set(reflect.ValueOf(&v).Convert(p.v.Type().Elem()))
}
-// getInt32Slice copies []int32 from p as a new slice.
-// This behavior differs from the implementation in pointer_unsafe.go.
-func (p pointer) getInt32Slice() []int32 {
- if p.v.Type().Elem().Elem() == reflect.TypeOf(int32(0)) {
- // raw int32 type
- return p.v.Elem().Interface().([]int32)
- }
- // an enum
- // Allocate a []int32, then assign []enum's values into it.
- // Note: we can't convert []enum to []int32.
- slice := p.v.Elem()
- s := make([]int32, slice.Len())
- for i := 0; i < slice.Len(); i++ {
- s[i] = int32(slice.Index(i).Int())
- }
- return s
+func (p word32Slice) Len() int {
+ return p.v.Len()
}
-// setInt32Slice copies []int32 into p as a new slice.
-// This behavior differs from the implementation in pointer_unsafe.go.
-func (p pointer) setInt32Slice(v []int32) {
- if p.v.Type().Elem().Elem() == reflect.TypeOf(int32(0)) {
- // raw int32 type
- p.v.Elem().Set(reflect.ValueOf(v))
+func (p word32Slice) Index(i int) uint32 {
+ elem := p.v.Index(i)
+ switch elem.Kind() {
+ case reflect.Int32:
+ return uint32(elem.Int())
+ case reflect.Uint32:
+ return uint32(elem.Uint())
+ case reflect.Float32:
+ return math.Float32bits(float32(elem.Float()))
+ }
+ panic("unreachable")
+}
+
+// Word32Slice returns a reference to a []int32, []uint32, []float32, or []enum field in the struct.
+func structPointer_Word32Slice(p structPointer, f field) word32Slice {
+ return word32Slice{structPointer_field(p, f)}
+}
+
+// word64 is like word32 but for 64-bit values.
+type word64 struct {
+ v reflect.Value
+}
+
+func word64_Set(p word64, o *Buffer, x uint64) {
+ t := p.v.Type().Elem()
+ switch t {
+ case int64Type:
+ if len(o.int64s) == 0 {
+ o.int64s = make([]int64, uint64PoolSize)
+ }
+ o.int64s[0] = int64(x)
+ p.v.Set(reflect.ValueOf(&o.int64s[0]))
+ o.int64s = o.int64s[1:]
+ return
+ case uint64Type:
+ if len(o.uint64s) == 0 {
+ o.uint64s = make([]uint64, uint64PoolSize)
+ }
+ o.uint64s[0] = x
+ p.v.Set(reflect.ValueOf(&o.uint64s[0]))
+ o.uint64s = o.uint64s[1:]
+ return
+ case float64Type:
+ if len(o.float64s) == 0 {
+ o.float64s = make([]float64, uint64PoolSize)
+ }
+ o.float64s[0] = math.Float64frombits(x)
+ p.v.Set(reflect.ValueOf(&o.float64s[0]))
+ o.float64s = o.float64s[1:]
return
}
- // an enum
- // Allocate a []enum, then assign []int32's values into it.
- // Note: we can't convert []enum to []int32.
- slice := reflect.MakeSlice(p.v.Type().Elem(), len(v), cap(v))
- for i, x := range v {
- slice.Index(i).SetInt(int64(x))
- }
- p.v.Elem().Set(slice)
-}
-func (p pointer) appendInt32Slice(v int32) {
- grow(p.v.Elem()).SetInt(int64(v))
+ panic("unreachable")
}
-func (p pointer) toUint64() *uint64 {
- return p.v.Interface().(*uint64)
-}
-func (p pointer) toUint64Ptr() **uint64 {
- return p.v.Interface().(**uint64)
-}
-func (p pointer) toUint64Slice() *[]uint64 {
- return p.v.Interface().(*[]uint64)
-}
-func (p pointer) toUint32() *uint32 {
- return p.v.Interface().(*uint32)
-}
-func (p pointer) toUint32Ptr() **uint32 {
- return p.v.Interface().(**uint32)
-}
-func (p pointer) toUint32Slice() *[]uint32 {
- return p.v.Interface().(*[]uint32)
-}
-func (p pointer) toBool() *bool {
- return p.v.Interface().(*bool)
-}
-func (p pointer) toBoolPtr() **bool {
- return p.v.Interface().(**bool)
-}
-func (p pointer) toBoolSlice() *[]bool {
- return p.v.Interface().(*[]bool)
-}
-func (p pointer) toFloat64() *float64 {
- return p.v.Interface().(*float64)
-}
-func (p pointer) toFloat64Ptr() **float64 {
- return p.v.Interface().(**float64)
-}
-func (p pointer) toFloat64Slice() *[]float64 {
- return p.v.Interface().(*[]float64)
-}
-func (p pointer) toFloat32() *float32 {
- return p.v.Interface().(*float32)
-}
-func (p pointer) toFloat32Ptr() **float32 {
- return p.v.Interface().(**float32)
-}
-func (p pointer) toFloat32Slice() *[]float32 {
- return p.v.Interface().(*[]float32)
-}
-func (p pointer) toString() *string {
- return p.v.Interface().(*string)
-}
-func (p pointer) toStringPtr() **string {
- return p.v.Interface().(**string)
-}
-func (p pointer) toStringSlice() *[]string {
- return p.v.Interface().(*[]string)
-}
-func (p pointer) toBytes() *[]byte {
- return p.v.Interface().(*[]byte)
-}
-func (p pointer) toBytesSlice() *[][]byte {
- return p.v.Interface().(*[][]byte)
-}
-func (p pointer) toExtensions() *XXX_InternalExtensions {
- return p.v.Interface().(*XXX_InternalExtensions)
-}
-func (p pointer) toOldExtensions() *map[int32]Extension {
- return p.v.Interface().(*map[int32]Extension)
-}
-func (p pointer) getPointer() pointer {
- return pointer{v: p.v.Elem()}
-}
-func (p pointer) setPointer(q pointer) {
- p.v.Elem().Set(q.v)
-}
-func (p pointer) appendPointer(q pointer) {
- grow(p.v.Elem()).Set(q.v)
+func word64_IsNil(p word64) bool {
+ return p.v.IsNil()
}
-// getPointerSlice copies []*T from p as a new []pointer.
-// This behavior differs from the implementation in pointer_unsafe.go.
-func (p pointer) getPointerSlice() []pointer {
- if p.v.IsNil() {
- return nil
+func word64_Get(p word64) uint64 {
+ elem := p.v.Elem()
+ switch elem.Kind() {
+ case reflect.Int64:
+ return uint64(elem.Int())
+ case reflect.Uint64:
+ return elem.Uint()
+ case reflect.Float64:
+ return math.Float64bits(elem.Float())
}
- n := p.v.Elem().Len()
- s := make([]pointer, n)
- for i := 0; i < n; i++ {
- s[i] = pointer{v: p.v.Elem().Index(i)}
- }
- return s
+ panic("unreachable")
}
-// setPointerSlice copies []pointer into p as a new []*T.
-// This behavior differs from the implementation in pointer_unsafe.go.
-func (p pointer) setPointerSlice(v []pointer) {
- if v == nil {
- p.v.Elem().Set(reflect.New(p.v.Elem().Type()).Elem())
+func structPointer_Word64(p structPointer, f field) word64 {
+ return word64{structPointer_field(p, f)}
+}
+
+// word64Val is like word32Val but for 64-bit values.
+type word64Val struct {
+ v reflect.Value
+}
+
+func word64Val_Set(p word64Val, o *Buffer, x uint64) {
+ switch p.v.Type() {
+ case int64Type:
+ p.v.SetInt(int64(x))
+ return
+ case uint64Type:
+ p.v.SetUint(x)
+ return
+ case float64Type:
+ p.v.SetFloat(math.Float64frombits(x))
return
}
- s := reflect.MakeSlice(p.v.Elem().Type(), 0, len(v))
- for _, p := range v {
- s = reflect.Append(s, p.v)
+ panic("unreachable")
+}
+
+func word64Val_Get(p word64Val) uint64 {
+ elem := p.v
+ switch elem.Kind() {
+ case reflect.Int64:
+ return uint64(elem.Int())
+ case reflect.Uint64:
+ return elem.Uint()
+ case reflect.Float64:
+ return math.Float64bits(elem.Float())
}
- p.v.Elem().Set(s)
+ panic("unreachable")
}
-// getInterfacePointer returns a pointer that points to the
-// interface data of the interface pointed by p.
-func (p pointer) getInterfacePointer() pointer {
- if p.v.Elem().IsNil() {
- return pointer{v: p.v.Elem()}
+func structPointer_Word64Val(p structPointer, f field) word64Val {
+ return word64Val{structPointer_field(p, f)}
+}
+
+type word64Slice struct {
+ v reflect.Value
+}
+
+func (p word64Slice) Append(x uint64) {
+ n, m := p.v.Len(), p.v.Cap()
+ if n < m {
+ p.v.SetLen(n + 1)
+ } else {
+ t := p.v.Type().Elem()
+ p.v.Set(reflect.Append(p.v, reflect.Zero(t)))
+ }
+ elem := p.v.Index(n)
+ switch elem.Kind() {
+ case reflect.Int64:
+ elem.SetInt(int64(int64(x)))
+ case reflect.Uint64:
+ elem.SetUint(uint64(x))
+ case reflect.Float64:
+ elem.SetFloat(float64(math.Float64frombits(x)))
}
- return pointer{v: p.v.Elem().Elem().Elem().Field(0).Addr()} // *interface -> interface -> *struct -> struct
}
-func (p pointer) asPointerTo(t reflect.Type) reflect.Value {
- // TODO: check that p.v.Type().Elem() == t?
- return p.v
+func (p word64Slice) Len() int {
+ return p.v.Len()
}
-func atomicLoadUnmarshalInfo(p **unmarshalInfo) *unmarshalInfo {
- atomicLock.Lock()
- defer atomicLock.Unlock()
- return *p
-}
-func atomicStoreUnmarshalInfo(p **unmarshalInfo, v *unmarshalInfo) {
- atomicLock.Lock()
- defer atomicLock.Unlock()
- *p = v
-}
-func atomicLoadMarshalInfo(p **marshalInfo) *marshalInfo {
- atomicLock.Lock()
- defer atomicLock.Unlock()
- return *p
-}
-func atomicStoreMarshalInfo(p **marshalInfo, v *marshalInfo) {
- atomicLock.Lock()
- defer atomicLock.Unlock()
- *p = v
-}
-func atomicLoadMergeInfo(p **mergeInfo) *mergeInfo {
- atomicLock.Lock()
- defer atomicLock.Unlock()
- return *p
-}
-func atomicStoreMergeInfo(p **mergeInfo, v *mergeInfo) {
- atomicLock.Lock()
- defer atomicLock.Unlock()
- *p = v
-}
-func atomicLoadDiscardInfo(p **discardInfo) *discardInfo {
- atomicLock.Lock()
- defer atomicLock.Unlock()
- return *p
-}
-func atomicStoreDiscardInfo(p **discardInfo, v *discardInfo) {
- atomicLock.Lock()
- defer atomicLock.Unlock()
- *p = v
+func (p word64Slice) Index(i int) uint64 {
+ elem := p.v.Index(i)
+ switch elem.Kind() {
+ case reflect.Int64:
+ return uint64(elem.Int())
+ case reflect.Uint64:
+ return uint64(elem.Uint())
+ case reflect.Float64:
+ return math.Float64bits(float64(elem.Float()))
+ }
+ panic("unreachable")
}
-var atomicLock sync.Mutex
+func structPointer_Word64Slice(p structPointer, f field) word64Slice {
+ return word64Slice{structPointer_field(p, f)}
+}
diff --git a/vendor/github.com/gogo/protobuf/proto/pointer_reflect_gogo.go b/vendor/github.com/gogo/protobuf/proto/pointer_reflect_gogo.go
index 7ffd3c29d9..1763a5f227 100644
--- a/vendor/github.com/gogo/protobuf/proto/pointer_reflect_gogo.go
+++ b/vendor/github.com/gogo/protobuf/proto/pointer_reflect_gogo.go
@@ -1,6 +1,6 @@
// Protocol Buffers for Go with Gadgets
//
-// Copyright (c) 2018, The GoGo Authors. All rights reserved.
+// Copyright (c) 2016, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
@@ -26,11 +26,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-// +build purego appengine js
-
-// This file contains an implementation of proto field accesses using package reflect.
-// It is slower than the code in pointer_unsafe.go but it avoids package unsafe and can
-// be used on App Engine.
+// +build appengine js
package proto
@@ -38,22 +34,52 @@ import (
"reflect"
)
-// TODO: untested, so probably incorrect.
-
-func (p pointer) getRef() pointer {
- return pointer{v: p.v.Addr()}
+func structPointer_FieldPointer(p structPointer, f field) structPointer {
+ panic("not implemented")
}
-func (p pointer) appendRef(v pointer, typ reflect.Type) {
- slice := p.getSlice(typ)
- elem := v.asPointerTo(typ).Elem()
- newSlice := reflect.Append(slice, elem)
- slice.Set(newSlice)
+func appendStructPointer(base structPointer, f field, typ reflect.Type) structPointer {
+ panic("not implemented")
}
-func (p pointer) getSlice(typ reflect.Type) reflect.Value {
- sliceTyp := reflect.SliceOf(typ)
- slice := p.asPointerTo(sliceTyp)
- slice = slice.Elem()
- return slice
+func structPointer_InterfaceAt(p structPointer, f field, t reflect.Type) interface{} {
+ panic("not implemented")
+}
+
+func structPointer_InterfaceRef(p structPointer, f field, t reflect.Type) interface{} {
+ panic("not implemented")
+}
+
+func structPointer_GetRefStructPointer(p structPointer, f field) structPointer {
+ panic("not implemented")
+}
+
+func structPointer_Add(p structPointer, size field) structPointer {
+ panic("not implemented")
+}
+
+func structPointer_Len(p structPointer, f field) int {
+ panic("not implemented")
+}
+
+func structPointer_GetSliceHeader(p structPointer, f field) *reflect.SliceHeader {
+ panic("not implemented")
+}
+
+func structPointer_Copy(oldptr structPointer, newptr structPointer, size int) {
+ panic("not implemented")
+}
+
+func structPointer_StructRefSlice(p structPointer, f field, size uintptr) *structRefSlice {
+ panic("not implemented")
+}
+
+type structRefSlice struct{}
+
+func (v *structRefSlice) Len() int {
+ panic("not implemented")
+}
+
+func (v *structRefSlice) Index(i int) structPointer {
+ panic("not implemented")
}
diff --git a/vendor/github.com/gogo/protobuf/proto/pointer_unsafe.go b/vendor/github.com/gogo/protobuf/proto/pointer_unsafe.go
index d55a335d94..6b5567d47c 100644
--- a/vendor/github.com/gogo/protobuf/proto/pointer_unsafe.go
+++ b/vendor/github.com/gogo/protobuf/proto/pointer_unsafe.go
@@ -29,7 +29,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-// +build !purego,!appengine,!js
+// +build !appengine,!js
// This file contains the implementation of the proto field accesses using package unsafe.
@@ -37,13 +37,38 @@ package proto
import (
"reflect"
- "sync/atomic"
"unsafe"
)
-const unsafeAllowed = true
+// NOTE: These type_Foo functions would more idiomatically be methods,
+// but Go does not allow methods on pointer types, and we must preserve
+// some pointer type for the garbage collector. We use these
+// funcs with clunky names as our poor approximation to methods.
+//
+// An alternative would be
+// type structPointer struct { p unsafe.Pointer }
+// but that does not registerize as well.
-// A field identifies a field in a struct, accessible from a pointer.
+// A structPointer is a pointer to a struct.
+type structPointer unsafe.Pointer
+
+// toStructPointer returns a structPointer equivalent to the given reflect value.
+func toStructPointer(v reflect.Value) structPointer {
+ return structPointer(unsafe.Pointer(v.Pointer()))
+}
+
+// IsNil reports whether p is nil.
+func structPointer_IsNil(p structPointer) bool {
+ return p == nil
+}
+
+// Interface returns the struct pointer, assumed to have element type t,
+// as an interface value.
+func structPointer_Interface(p structPointer, t reflect.Type) interface{} {
+ return reflect.NewAt(t, unsafe.Pointer(p)).Interface()
+}
+
+// A field identifies a field in a struct, accessible from a structPointer.
// In this implementation, a field is identified by its byte offset from the start of the struct.
type field uintptr
@@ -55,254 +80,191 @@ func toField(f *reflect.StructField) field {
// invalidField is an invalid field identifier.
const invalidField = ^field(0)
-// zeroField is a noop when calling pointer.offset.
-const zeroField = field(0)
-
// IsValid reports whether the field identifier is valid.
func (f field) IsValid() bool {
- return f != invalidField
+ return f != ^field(0)
}
-// The pointer type below is for the new table-driven encoder/decoder.
-// The implementation here uses unsafe.Pointer to create a generic pointer.
-// In pointer_reflect.go we use reflect instead of unsafe to implement
-// the same (but slower) interface.
-type pointer struct {
- p unsafe.Pointer
+// Bytes returns the address of a []byte field in the struct.
+func structPointer_Bytes(p structPointer, f field) *[]byte {
+ return (*[]byte)(unsafe.Pointer(uintptr(p) + uintptr(f)))
}
-// size of pointer
-var ptrSize = unsafe.Sizeof(uintptr(0))
-
-// toPointer converts an interface of pointer type to a pointer
-// that points to the same target.
-func toPointer(i *Message) pointer {
- // Super-tricky - read pointer out of data word of interface value.
- // Saves ~25ns over the equivalent:
- // return valToPointer(reflect.ValueOf(*i))
- return pointer{p: (*[2]unsafe.Pointer)(unsafe.Pointer(i))[1]}
+// BytesSlice returns the address of a [][]byte field in the struct.
+func structPointer_BytesSlice(p structPointer, f field) *[][]byte {
+ return (*[][]byte)(unsafe.Pointer(uintptr(p) + uintptr(f)))
}
-// toAddrPointer converts an interface to a pointer that points to
-// the interface data.
-func toAddrPointer(i *interface{}, isptr bool) pointer {
- // Super-tricky - read or get the address of data word of interface value.
- if isptr {
- // The interface is of pointer type, thus it is a direct interface.
- // The data word is the pointer data itself. We take its address.
- return pointer{p: unsafe.Pointer(uintptr(unsafe.Pointer(i)) + ptrSize)}
+// Bool returns the address of a *bool field in the struct.
+func structPointer_Bool(p structPointer, f field) **bool {
+ return (**bool)(unsafe.Pointer(uintptr(p) + uintptr(f)))
+}
+
+// BoolVal returns the address of a bool field in the struct.
+func structPointer_BoolVal(p structPointer, f field) *bool {
+ return (*bool)(unsafe.Pointer(uintptr(p) + uintptr(f)))
+}
+
+// BoolSlice returns the address of a []bool field in the struct.
+func structPointer_BoolSlice(p structPointer, f field) *[]bool {
+ return (*[]bool)(unsafe.Pointer(uintptr(p) + uintptr(f)))
+}
+
+// String returns the address of a *string field in the struct.
+func structPointer_String(p structPointer, f field) **string {
+ return (**string)(unsafe.Pointer(uintptr(p) + uintptr(f)))
+}
+
+// StringVal returns the address of a string field in the struct.
+func structPointer_StringVal(p structPointer, f field) *string {
+ return (*string)(unsafe.Pointer(uintptr(p) + uintptr(f)))
+}
+
+// StringSlice returns the address of a []string field in the struct.
+func structPointer_StringSlice(p structPointer, f field) *[]string {
+ return (*[]string)(unsafe.Pointer(uintptr(p) + uintptr(f)))
+}
+
+// ExtMap returns the address of an extension map field in the struct.
+func structPointer_Extensions(p structPointer, f field) *XXX_InternalExtensions {
+ return (*XXX_InternalExtensions)(unsafe.Pointer(uintptr(p) + uintptr(f)))
+}
+
+func structPointer_ExtMap(p structPointer, f field) *map[int32]Extension {
+ return (*map[int32]Extension)(unsafe.Pointer(uintptr(p) + uintptr(f)))
+}
+
+// NewAt returns the reflect.Value for a pointer to a field in the struct.
+func structPointer_NewAt(p structPointer, f field, typ reflect.Type) reflect.Value {
+ return reflect.NewAt(typ, unsafe.Pointer(uintptr(p)+uintptr(f)))
+}
+
+// SetStructPointer writes a *struct field in the struct.
+func structPointer_SetStructPointer(p structPointer, f field, q structPointer) {
+ *(*structPointer)(unsafe.Pointer(uintptr(p) + uintptr(f))) = q
+}
+
+// GetStructPointer reads a *struct field in the struct.
+func structPointer_GetStructPointer(p structPointer, f field) structPointer {
+ return *(*structPointer)(unsafe.Pointer(uintptr(p) + uintptr(f)))
+}
+
+// StructPointerSlice the address of a []*struct field in the struct.
+func structPointer_StructPointerSlice(p structPointer, f field) *structPointerSlice {
+ return (*structPointerSlice)(unsafe.Pointer(uintptr(p) + uintptr(f)))
+}
+
+// A structPointerSlice represents a slice of pointers to structs (themselves submessages or groups).
+type structPointerSlice []structPointer
+
+func (v *structPointerSlice) Len() int { return len(*v) }
+func (v *structPointerSlice) Index(i int) structPointer { return (*v)[i] }
+func (v *structPointerSlice) Append(p structPointer) { *v = append(*v, p) }
+
+// A word32 is the address of a "pointer to 32-bit value" field.
+type word32 **uint32
+
+// IsNil reports whether *v is nil.
+func word32_IsNil(p word32) bool {
+ return *p == nil
+}
+
+// Set sets *v to point at a newly allocated word set to x.
+func word32_Set(p word32, o *Buffer, x uint32) {
+ if len(o.uint32s) == 0 {
+ o.uint32s = make([]uint32, uint32PoolSize)
}
- // The interface is not of pointer type. The data word is the pointer
- // to the data.
- return pointer{p: (*[2]unsafe.Pointer)(unsafe.Pointer(i))[1]}
+ o.uint32s[0] = x
+ *p = &o.uint32s[0]
+ o.uint32s = o.uint32s[1:]
}
-// valToPointer converts v to a pointer. v must be of pointer type.
-func valToPointer(v reflect.Value) pointer {
- return pointer{p: unsafe.Pointer(v.Pointer())}
+// Get gets the value pointed at by *v.
+func word32_Get(p word32) uint32 {
+ return **p
}
-// offset converts from a pointer to a structure to a pointer to
-// one of its fields.
-func (p pointer) offset(f field) pointer {
- // For safety, we should panic if !f.IsValid, however calling panic causes
- // this to no longer be inlineable, which is a serious performance cost.
- /*
- if !f.IsValid() {
- panic("invalid field")
- }
- */
- return pointer{p: unsafe.Pointer(uintptr(p.p) + uintptr(f))}
+// Word32 returns the address of a *int32, *uint32, *float32, or *enum field in the struct.
+func structPointer_Word32(p structPointer, f field) word32 {
+ return word32((**uint32)(unsafe.Pointer(uintptr(p) + uintptr(f))))
}
-func (p pointer) isNil() bool {
- return p.p == nil
+// A word32Val is the address of a 32-bit value field.
+type word32Val *uint32
+
+// Set sets *p to x.
+func word32Val_Set(p word32Val, x uint32) {
+ *p = x
}
-func (p pointer) toInt64() *int64 {
- return (*int64)(p.p)
-}
-func (p pointer) toInt64Ptr() **int64 {
- return (**int64)(p.p)
-}
-func (p pointer) toInt64Slice() *[]int64 {
- return (*[]int64)(p.p)
-}
-func (p pointer) toInt32() *int32 {
- return (*int32)(p.p)
+// Get gets the value pointed at by p.
+func word32Val_Get(p word32Val) uint32 {
+ return *p
}
-// See pointer_reflect.go for why toInt32Ptr/Slice doesn't exist.
-/*
- func (p pointer) toInt32Ptr() **int32 {
- return (**int32)(p.p)
+// Word32Val returns the address of a *int32, *uint32, *float32, or *enum field in the struct.
+func structPointer_Word32Val(p structPointer, f field) word32Val {
+ return word32Val((*uint32)(unsafe.Pointer(uintptr(p) + uintptr(f))))
+}
+
+// A word32Slice is a slice of 32-bit values.
+type word32Slice []uint32
+
+func (v *word32Slice) Append(x uint32) { *v = append(*v, x) }
+func (v *word32Slice) Len() int { return len(*v) }
+func (v *word32Slice) Index(i int) uint32 { return (*v)[i] }
+
+// Word32Slice returns the address of a []int32, []uint32, []float32, or []enum field in the struct.
+func structPointer_Word32Slice(p structPointer, f field) *word32Slice {
+ return (*word32Slice)(unsafe.Pointer(uintptr(p) + uintptr(f)))
+}
+
+// word64 is like word32 but for 64-bit values.
+type word64 **uint64
+
+func word64_Set(p word64, o *Buffer, x uint64) {
+ if len(o.uint64s) == 0 {
+ o.uint64s = make([]uint64, uint64PoolSize)
}
- func (p pointer) toInt32Slice() *[]int32 {
- return (*[]int32)(p.p)
- }
-*/
-func (p pointer) getInt32Ptr() *int32 {
- return *(**int32)(p.p)
-}
-func (p pointer) setInt32Ptr(v int32) {
- *(**int32)(p.p) = &v
+ o.uint64s[0] = x
+ *p = &o.uint64s[0]
+ o.uint64s = o.uint64s[1:]
}
-// getInt32Slice loads a []int32 from p.
-// The value returned is aliased with the original slice.
-// This behavior differs from the implementation in pointer_reflect.go.
-func (p pointer) getInt32Slice() []int32 {
- return *(*[]int32)(p.p)
+func word64_IsNil(p word64) bool {
+ return *p == nil
}
-// setInt32Slice stores a []int32 to p.
-// The value set is aliased with the input slice.
-// This behavior differs from the implementation in pointer_reflect.go.
-func (p pointer) setInt32Slice(v []int32) {
- *(*[]int32)(p.p) = v
+func word64_Get(p word64) uint64 {
+ return **p
}
-// TODO: Can we get rid of appendInt32Slice and use setInt32Slice instead?
-func (p pointer) appendInt32Slice(v int32) {
- s := (*[]int32)(p.p)
- *s = append(*s, v)
+func structPointer_Word64(p structPointer, f field) word64 {
+ return word64((**uint64)(unsafe.Pointer(uintptr(p) + uintptr(f))))
}
-func (p pointer) toUint64() *uint64 {
- return (*uint64)(p.p)
-}
-func (p pointer) toUint64Ptr() **uint64 {
- return (**uint64)(p.p)
-}
-func (p pointer) toUint64Slice() *[]uint64 {
- return (*[]uint64)(p.p)
-}
-func (p pointer) toUint32() *uint32 {
- return (*uint32)(p.p)
-}
-func (p pointer) toUint32Ptr() **uint32 {
- return (**uint32)(p.p)
-}
-func (p pointer) toUint32Slice() *[]uint32 {
- return (*[]uint32)(p.p)
-}
-func (p pointer) toBool() *bool {
- return (*bool)(p.p)
-}
-func (p pointer) toBoolPtr() **bool {
- return (**bool)(p.p)
-}
-func (p pointer) toBoolSlice() *[]bool {
- return (*[]bool)(p.p)
-}
-func (p pointer) toFloat64() *float64 {
- return (*float64)(p.p)
-}
-func (p pointer) toFloat64Ptr() **float64 {
- return (**float64)(p.p)
-}
-func (p pointer) toFloat64Slice() *[]float64 {
- return (*[]float64)(p.p)
-}
-func (p pointer) toFloat32() *float32 {
- return (*float32)(p.p)
-}
-func (p pointer) toFloat32Ptr() **float32 {
- return (**float32)(p.p)
-}
-func (p pointer) toFloat32Slice() *[]float32 {
- return (*[]float32)(p.p)
-}
-func (p pointer) toString() *string {
- return (*string)(p.p)
-}
-func (p pointer) toStringPtr() **string {
- return (**string)(p.p)
-}
-func (p pointer) toStringSlice() *[]string {
- return (*[]string)(p.p)
-}
-func (p pointer) toBytes() *[]byte {
- return (*[]byte)(p.p)
-}
-func (p pointer) toBytesSlice() *[][]byte {
- return (*[][]byte)(p.p)
-}
-func (p pointer) toExtensions() *XXX_InternalExtensions {
- return (*XXX_InternalExtensions)(p.p)
-}
-func (p pointer) toOldExtensions() *map[int32]Extension {
- return (*map[int32]Extension)(p.p)
+// word64Val is like word32Val but for 64-bit values.
+type word64Val *uint64
+
+func word64Val_Set(p word64Val, o *Buffer, x uint64) {
+ *p = x
}
-// getPointerSlice loads []*T from p as a []pointer.
-// The value returned is aliased with the original slice.
-// This behavior differs from the implementation in pointer_reflect.go.
-func (p pointer) getPointerSlice() []pointer {
- // Super-tricky - p should point to a []*T where T is a
- // message type. We load it as []pointer.
- return *(*[]pointer)(p.p)
+func word64Val_Get(p word64Val) uint64 {
+ return *p
}
-// setPointerSlice stores []pointer into p as a []*T.
-// The value set is aliased with the input slice.
-// This behavior differs from the implementation in pointer_reflect.go.
-func (p pointer) setPointerSlice(v []pointer) {
- // Super-tricky - p should point to a []*T where T is a
- // message type. We store it as []pointer.
- *(*[]pointer)(p.p) = v
+func structPointer_Word64Val(p structPointer, f field) word64Val {
+ return word64Val((*uint64)(unsafe.Pointer(uintptr(p) + uintptr(f))))
}
-// getPointer loads the pointer at p and returns it.
-func (p pointer) getPointer() pointer {
- return pointer{p: *(*unsafe.Pointer)(p.p)}
-}
+// word64Slice is like word32Slice but for 64-bit values.
+type word64Slice []uint64
-// setPointer stores the pointer q at p.
-func (p pointer) setPointer(q pointer) {
- *(*unsafe.Pointer)(p.p) = q.p
-}
+func (v *word64Slice) Append(x uint64) { *v = append(*v, x) }
+func (v *word64Slice) Len() int { return len(*v) }
+func (v *word64Slice) Index(i int) uint64 { return (*v)[i] }
-// append q to the slice pointed to by p.
-func (p pointer) appendPointer(q pointer) {
- s := (*[]unsafe.Pointer)(p.p)
- *s = append(*s, q.p)
-}
-
-// getInterfacePointer returns a pointer that points to the
-// interface data of the interface pointed by p.
-func (p pointer) getInterfacePointer() pointer {
- // Super-tricky - read pointer out of data word of interface value.
- return pointer{p: (*(*[2]unsafe.Pointer)(p.p))[1]}
-}
-
-// asPointerTo returns a reflect.Value that is a pointer to an
-// object of type t stored at p.
-func (p pointer) asPointerTo(t reflect.Type) reflect.Value {
- return reflect.NewAt(t, p.p)
-}
-
-func atomicLoadUnmarshalInfo(p **unmarshalInfo) *unmarshalInfo {
- return (*unmarshalInfo)(atomic.LoadPointer((*unsafe.Pointer)(unsafe.Pointer(p))))
-}
-func atomicStoreUnmarshalInfo(p **unmarshalInfo, v *unmarshalInfo) {
- atomic.StorePointer((*unsafe.Pointer)(unsafe.Pointer(p)), unsafe.Pointer(v))
-}
-func atomicLoadMarshalInfo(p **marshalInfo) *marshalInfo {
- return (*marshalInfo)(atomic.LoadPointer((*unsafe.Pointer)(unsafe.Pointer(p))))
-}
-func atomicStoreMarshalInfo(p **marshalInfo, v *marshalInfo) {
- atomic.StorePointer((*unsafe.Pointer)(unsafe.Pointer(p)), unsafe.Pointer(v))
-}
-func atomicLoadMergeInfo(p **mergeInfo) *mergeInfo {
- return (*mergeInfo)(atomic.LoadPointer((*unsafe.Pointer)(unsafe.Pointer(p))))
-}
-func atomicStoreMergeInfo(p **mergeInfo, v *mergeInfo) {
- atomic.StorePointer((*unsafe.Pointer)(unsafe.Pointer(p)), unsafe.Pointer(v))
-}
-func atomicLoadDiscardInfo(p **discardInfo) *discardInfo {
- return (*discardInfo)(atomic.LoadPointer((*unsafe.Pointer)(unsafe.Pointer(p))))
-}
-func atomicStoreDiscardInfo(p **discardInfo, v *discardInfo) {
- atomic.StorePointer((*unsafe.Pointer)(unsafe.Pointer(p)), unsafe.Pointer(v))
+func structPointer_Word64Slice(p structPointer, f field) *word64Slice {
+ return (*word64Slice)(unsafe.Pointer(uintptr(p) + uintptr(f)))
}
diff --git a/vendor/github.com/gogo/protobuf/proto/pointer_unsafe_gogo.go b/vendor/github.com/gogo/protobuf/proto/pointer_unsafe_gogo.go
index b354101b9c..f156a29f0e 100644
--- a/vendor/github.com/gogo/protobuf/proto/pointer_unsafe_gogo.go
+++ b/vendor/github.com/gogo/protobuf/proto/pointer_unsafe_gogo.go
@@ -1,6 +1,6 @@
// Protocol Buffers for Go with Gadgets
//
-// Copyright (c) 2018, The GoGo Authors. All rights reserved.
+// Copyright (c) 2013, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
@@ -26,7 +26,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-// +build !purego !appengine,!js
+// +build !appengine,!js
// This file contains the implementation of the proto field accesses using package unsafe.
@@ -37,20 +37,92 @@ import (
"unsafe"
)
-func (p pointer) getRef() pointer {
- return pointer{p: (unsafe.Pointer)(&p.p)}
+func structPointer_InterfaceAt(p structPointer, f field, t reflect.Type) interface{} {
+ point := unsafe.Pointer(uintptr(p) + uintptr(f))
+ r := reflect.NewAt(t, point)
+ return r.Interface()
}
-func (p pointer) appendRef(v pointer, typ reflect.Type) {
- slice := p.getSlice(typ)
- elem := v.asPointerTo(typ).Elem()
- newSlice := reflect.Append(slice, elem)
- slice.Set(newSlice)
+func structPointer_InterfaceRef(p structPointer, f field, t reflect.Type) interface{} {
+ point := unsafe.Pointer(uintptr(p) + uintptr(f))
+ r := reflect.NewAt(t, point)
+ if r.Elem().IsNil() {
+ return nil
+ }
+ return r.Elem().Interface()
}
-func (p pointer) getSlice(typ reflect.Type) reflect.Value {
- sliceTyp := reflect.SliceOf(typ)
- slice := p.asPointerTo(sliceTyp)
- slice = slice.Elem()
- return slice
+func copyUintPtr(oldptr, newptr uintptr, size int) {
+ oldbytes := make([]byte, 0)
+ oldslice := (*reflect.SliceHeader)(unsafe.Pointer(&oldbytes))
+ oldslice.Data = oldptr
+ oldslice.Len = size
+ oldslice.Cap = size
+ newbytes := make([]byte, 0)
+ newslice := (*reflect.SliceHeader)(unsafe.Pointer(&newbytes))
+ newslice.Data = newptr
+ newslice.Len = size
+ newslice.Cap = size
+ copy(newbytes, oldbytes)
+}
+
+func structPointer_Copy(oldptr structPointer, newptr structPointer, size int) {
+ copyUintPtr(uintptr(oldptr), uintptr(newptr), size)
+}
+
+func appendStructPointer(base structPointer, f field, typ reflect.Type) structPointer {
+ size := typ.Elem().Size()
+
+ oldHeader := structPointer_GetSliceHeader(base, f)
+ oldSlice := reflect.NewAt(typ, unsafe.Pointer(oldHeader)).Elem()
+ newLen := oldHeader.Len + 1
+ newSlice := reflect.MakeSlice(typ, newLen, newLen)
+ reflect.Copy(newSlice, oldSlice)
+ bas := toStructPointer(newSlice)
+ oldHeader.Data = uintptr(bas)
+ oldHeader.Len = newLen
+ oldHeader.Cap = newLen
+
+ return structPointer(unsafe.Pointer(uintptr(unsafe.Pointer(bas)) + uintptr(uintptr(newLen-1)*size)))
+}
+
+func structPointer_FieldPointer(p structPointer, f field) structPointer {
+ return structPointer(unsafe.Pointer(uintptr(p) + uintptr(f)))
+}
+
+func structPointer_GetRefStructPointer(p structPointer, f field) structPointer {
+ return structPointer((*structPointer)(unsafe.Pointer(uintptr(p) + uintptr(f))))
+}
+
+func structPointer_GetSliceHeader(p structPointer, f field) *reflect.SliceHeader {
+ return (*reflect.SliceHeader)(unsafe.Pointer(uintptr(p) + uintptr(f)))
+}
+
+func structPointer_Add(p structPointer, size field) structPointer {
+ return structPointer(unsafe.Pointer(uintptr(p) + uintptr(size)))
+}
+
+func structPointer_Len(p structPointer, f field) int {
+ return len(*(*[]interface{})(unsafe.Pointer(structPointer_GetRefStructPointer(p, f))))
+}
+
+func structPointer_StructRefSlice(p structPointer, f field, size uintptr) *structRefSlice {
+ return &structRefSlice{p: p, f: f, size: size}
+}
+
+// A structRefSlice represents a slice of structs (themselves submessages or groups).
+type structRefSlice struct {
+ p structPointer
+ f field
+ size uintptr
+}
+
+func (v *structRefSlice) Len() int {
+ return structPointer_Len(v.p, v.f)
+}
+
+func (v *structRefSlice) Index(i int) structPointer {
+ ss := structPointer_GetStructPointer(v.p, v.f)
+ ss1 := structPointer_GetRefStructPointer(ss, 0)
+ return structPointer_Add(ss1, field(uintptr(i)*v.size))
}
diff --git a/vendor/github.com/gogo/protobuf/proto/properties.go b/vendor/github.com/gogo/protobuf/proto/properties.go
index 7a5e28efe5..2a69e8862d 100644
--- a/vendor/github.com/gogo/protobuf/proto/properties.go
+++ b/vendor/github.com/gogo/protobuf/proto/properties.go
@@ -63,6 +63,42 @@ const (
WireFixed32 = 5
)
+const startSize = 10 // initial slice/string sizes
+
+// Encoders are defined in encode.go
+// An encoder outputs the full representation of a field, including its
+// tag and encoder type.
+type encoder func(p *Buffer, prop *Properties, base structPointer) error
+
+// A valueEncoder encodes a single integer in a particular encoding.
+type valueEncoder func(o *Buffer, x uint64) error
+
+// Sizers are defined in encode.go
+// A sizer returns the encoded size of a field, including its tag and encoder
+// type.
+type sizer func(prop *Properties, base structPointer) int
+
+// A valueSizer returns the encoded size of a single integer in a particular
+// encoding.
+type valueSizer func(x uint64) int
+
+// Decoders are defined in decode.go
+// A decoder creates a value from its wire representation.
+// Unrecognized subelements are saved in unrec.
+type decoder func(p *Buffer, prop *Properties, base structPointer) error
+
+// A valueDecoder decodes a single integer in a particular encoding.
+type valueDecoder func(o *Buffer) (x uint64, err error)
+
+// A oneofMarshaler does the marshaling for all oneof fields in a message.
+type oneofMarshaler func(Message, *Buffer) error
+
+// A oneofUnmarshaler does the unmarshaling for a oneof field in a message.
+type oneofUnmarshaler func(Message, int, int, *Buffer) (bool, error)
+
+// A oneofSizer does the sizing for all oneof fields in a message.
+type oneofSizer func(Message) int
+
// tagMap is an optimization over map[int]int for typical protocol buffer
// use-cases. Encoded protocol buffers are often in tag order with small tag
// numbers.
@@ -109,6 +145,13 @@ type StructProperties struct {
decoderTags tagMap // map from proto tag to struct field number
decoderOrigNames map[string]int // map from original name to struct field number
order []int // list of struct field numbers in tag order
+ unrecField field // field id of the XXX_unrecognized []byte field
+ extendable bool // is this an extendable proto
+
+ oneofMarshaler oneofMarshaler
+ oneofUnmarshaler oneofUnmarshaler
+ oneofSizer oneofSizer
+ stype reflect.Type
// OneofTypes contains information about the oneof fields in this message.
// It is keyed by the original name of a field.
@@ -154,19 +197,36 @@ type Properties struct {
StdTime bool
StdDuration bool
- stype reflect.Type // set for struct types only
- ctype reflect.Type // set for custom types only
- sprop *StructProperties // set for struct types only
+ enc encoder
+ valEnc valueEncoder // set for bool and numeric types only
+ field field
+ tagcode []byte // encoding of EncodeVarint((Tag<<3)|WireType)
+ tagbuf [8]byte
+ stype reflect.Type // set for struct types only
+ sstype reflect.Type // set for slices of structs types only
+ ctype reflect.Type // set for custom types only
+ sprop *StructProperties // set for struct types only
+ isMarshaler bool
+ isUnmarshaler bool
mtype reflect.Type // set for map types only
mkeyprop *Properties // set for map types only
mvalprop *Properties // set for map types only
+
+ size sizer
+ valSize valueSizer // set for bool and numeric types only
+
+ dec decoder
+ valDec valueDecoder // set for bool and numeric types only
+
+ // If this is a packable field, this will be the decoder for the packed version of the field.
+ packedDec decoder
}
// String formats the properties in the protobuf struct field tag style.
func (p *Properties) String() string {
s := p.Wire
- s += ","
+ s = ","
s += strconv.Itoa(p.Tag)
if p.Required {
s += ",req"
@@ -212,14 +272,29 @@ func (p *Properties) Parse(s string) {
switch p.Wire {
case "varint":
p.WireType = WireVarint
+ p.valEnc = (*Buffer).EncodeVarint
+ p.valDec = (*Buffer).DecodeVarint
+ p.valSize = sizeVarint
case "fixed32":
p.WireType = WireFixed32
+ p.valEnc = (*Buffer).EncodeFixed32
+ p.valDec = (*Buffer).DecodeFixed32
+ p.valSize = sizeFixed32
case "fixed64":
p.WireType = WireFixed64
+ p.valEnc = (*Buffer).EncodeFixed64
+ p.valDec = (*Buffer).DecodeFixed64
+ p.valSize = sizeFixed64
case "zigzag32":
p.WireType = WireVarint
+ p.valEnc = (*Buffer).EncodeZigzag32
+ p.valDec = (*Buffer).DecodeZigzag32
+ p.valSize = sizeZigzag32
case "zigzag64":
p.WireType = WireVarint
+ p.valEnc = (*Buffer).EncodeZigzag64
+ p.valDec = (*Buffer).DecodeZigzag64
+ p.valSize = sizeZigzag64
case "bytes", "group":
p.WireType = WireBytes
// no numeric converter for non-numeric types
@@ -234,7 +309,6 @@ func (p *Properties) Parse(s string) {
return
}
-outer:
for i := 2; i < len(fields); i++ {
f := fields[i]
switch {
@@ -262,7 +336,7 @@ outer:
if i+1 < len(fields) {
// Commas aren't escaped, and def is always last.
p.Default += "," + strings.Join(fields[i+1:], ",")
- break outer
+ break
}
case strings.HasPrefix(f, "embedded="):
p.OrigName = strings.Split(f, "=")[1]
@@ -278,43 +352,292 @@ outer:
}
}
+func logNoSliceEnc(t1, t2 reflect.Type) {
+ fmt.Fprintf(os.Stderr, "proto: no slice oenc for %T = []%T\n", t1, t2)
+}
+
var protoMessageType = reflect.TypeOf((*Message)(nil)).Elem()
-// setFieldProps initializes the field properties for submessages and maps.
-func (p *Properties) setFieldProps(typ reflect.Type, f *reflect.StructField, lockGetProp bool) {
+// Initialize the fields for encoding and decoding.
+func (p *Properties) setEncAndDec(typ reflect.Type, f *reflect.StructField, lockGetProp bool) {
+ p.enc = nil
+ p.dec = nil
+ p.size = nil
isMap := typ.Kind() == reflect.Map
if len(p.CustomType) > 0 && !isMap {
- p.ctype = typ
+ p.setCustomEncAndDec(typ)
p.setTag(lockGetProp)
return
}
if p.StdTime && !isMap {
+ p.setTimeEncAndDec(typ)
p.setTag(lockGetProp)
return
}
if p.StdDuration && !isMap {
+ p.setDurationEncAndDec(typ)
p.setTag(lockGetProp)
return
}
switch t1 := typ; t1.Kind() {
+ default:
+ fmt.Fprintf(os.Stderr, "proto: no coders for %v\n", t1)
+
+ // proto3 scalar types
+
+ case reflect.Bool:
+ if p.proto3 {
+ p.enc = (*Buffer).enc_proto3_bool
+ p.dec = (*Buffer).dec_proto3_bool
+ p.size = size_proto3_bool
+ } else {
+ p.enc = (*Buffer).enc_ref_bool
+ p.dec = (*Buffer).dec_proto3_bool
+ p.size = size_ref_bool
+ }
+ case reflect.Int32:
+ if p.proto3 {
+ p.enc = (*Buffer).enc_proto3_int32
+ p.dec = (*Buffer).dec_proto3_int32
+ p.size = size_proto3_int32
+ } else {
+ p.enc = (*Buffer).enc_ref_int32
+ p.dec = (*Buffer).dec_proto3_int32
+ p.size = size_ref_int32
+ }
+ case reflect.Uint32:
+ if p.proto3 {
+ p.enc = (*Buffer).enc_proto3_uint32
+ p.dec = (*Buffer).dec_proto3_int32 // can reuse
+ p.size = size_proto3_uint32
+ } else {
+ p.enc = (*Buffer).enc_ref_uint32
+ p.dec = (*Buffer).dec_proto3_int32 // can reuse
+ p.size = size_ref_uint32
+ }
+ case reflect.Int64, reflect.Uint64:
+ if p.proto3 {
+ p.enc = (*Buffer).enc_proto3_int64
+ p.dec = (*Buffer).dec_proto3_int64
+ p.size = size_proto3_int64
+ } else {
+ p.enc = (*Buffer).enc_ref_int64
+ p.dec = (*Buffer).dec_proto3_int64
+ p.size = size_ref_int64
+ }
+ case reflect.Float32:
+ if p.proto3 {
+ p.enc = (*Buffer).enc_proto3_uint32 // can just treat them as bits
+ p.dec = (*Buffer).dec_proto3_int32
+ p.size = size_proto3_uint32
+ } else {
+ p.enc = (*Buffer).enc_ref_uint32 // can just treat them as bits
+ p.dec = (*Buffer).dec_proto3_int32
+ p.size = size_ref_uint32
+ }
+ case reflect.Float64:
+ if p.proto3 {
+ p.enc = (*Buffer).enc_proto3_int64 // can just treat them as bits
+ p.dec = (*Buffer).dec_proto3_int64
+ p.size = size_proto3_int64
+ } else {
+ p.enc = (*Buffer).enc_ref_int64 // can just treat them as bits
+ p.dec = (*Buffer).dec_proto3_int64
+ p.size = size_ref_int64
+ }
+ case reflect.String:
+ if p.proto3 {
+ p.enc = (*Buffer).enc_proto3_string
+ p.dec = (*Buffer).dec_proto3_string
+ p.size = size_proto3_string
+ } else {
+ p.enc = (*Buffer).enc_ref_string
+ p.dec = (*Buffer).dec_proto3_string
+ p.size = size_ref_string
+ }
case reflect.Struct:
p.stype = typ
- case reflect.Ptr:
- if t1.Elem().Kind() == reflect.Struct {
- p.stype = t1.Elem()
+ p.isMarshaler = isMarshaler(typ)
+ p.isUnmarshaler = isUnmarshaler(typ)
+ if p.Wire == "bytes" {
+ p.enc = (*Buffer).enc_ref_struct_message
+ p.dec = (*Buffer).dec_ref_struct_message
+ p.size = size_ref_struct_message
+ } else {
+ fmt.Fprintf(os.Stderr, "proto: no coders for struct %T\n", typ)
}
+
+ case reflect.Ptr:
+ switch t2 := t1.Elem(); t2.Kind() {
+ default:
+ fmt.Fprintf(os.Stderr, "proto: no encoder function for %v -> %v\n", t1, t2)
+ break
+ case reflect.Bool:
+ p.enc = (*Buffer).enc_bool
+ p.dec = (*Buffer).dec_bool
+ p.size = size_bool
+ case reflect.Int32:
+ p.enc = (*Buffer).enc_int32
+ p.dec = (*Buffer).dec_int32
+ p.size = size_int32
+ case reflect.Uint32:
+ p.enc = (*Buffer).enc_uint32
+ p.dec = (*Buffer).dec_int32 // can reuse
+ p.size = size_uint32
+ case reflect.Int64, reflect.Uint64:
+ p.enc = (*Buffer).enc_int64
+ p.dec = (*Buffer).dec_int64
+ p.size = size_int64
+ case reflect.Float32:
+ p.enc = (*Buffer).enc_uint32 // can just treat them as bits
+ p.dec = (*Buffer).dec_int32
+ p.size = size_uint32
+ case reflect.Float64:
+ p.enc = (*Buffer).enc_int64 // can just treat them as bits
+ p.dec = (*Buffer).dec_int64
+ p.size = size_int64
+ case reflect.String:
+ p.enc = (*Buffer).enc_string
+ p.dec = (*Buffer).dec_string
+ p.size = size_string
+ case reflect.Struct:
+ p.stype = t1.Elem()
+ p.isMarshaler = isMarshaler(t1)
+ p.isUnmarshaler = isUnmarshaler(t1)
+ if p.Wire == "bytes" {
+ p.enc = (*Buffer).enc_struct_message
+ p.dec = (*Buffer).dec_struct_message
+ p.size = size_struct_message
+ } else {
+ p.enc = (*Buffer).enc_struct_group
+ p.dec = (*Buffer).dec_struct_group
+ p.size = size_struct_group
+ }
+ }
+
case reflect.Slice:
switch t2 := t1.Elem(); t2.Kind() {
+ default:
+ logNoSliceEnc(t1, t2)
+ break
+ case reflect.Bool:
+ if p.Packed {
+ p.enc = (*Buffer).enc_slice_packed_bool
+ p.size = size_slice_packed_bool
+ } else {
+ p.enc = (*Buffer).enc_slice_bool
+ p.size = size_slice_bool
+ }
+ p.dec = (*Buffer).dec_slice_bool
+ p.packedDec = (*Buffer).dec_slice_packed_bool
+ case reflect.Int32:
+ if p.Packed {
+ p.enc = (*Buffer).enc_slice_packed_int32
+ p.size = size_slice_packed_int32
+ } else {
+ p.enc = (*Buffer).enc_slice_int32
+ p.size = size_slice_int32
+ }
+ p.dec = (*Buffer).dec_slice_int32
+ p.packedDec = (*Buffer).dec_slice_packed_int32
+ case reflect.Uint32:
+ if p.Packed {
+ p.enc = (*Buffer).enc_slice_packed_uint32
+ p.size = size_slice_packed_uint32
+ } else {
+ p.enc = (*Buffer).enc_slice_uint32
+ p.size = size_slice_uint32
+ }
+ p.dec = (*Buffer).dec_slice_int32
+ p.packedDec = (*Buffer).dec_slice_packed_int32
+ case reflect.Int64, reflect.Uint64:
+ if p.Packed {
+ p.enc = (*Buffer).enc_slice_packed_int64
+ p.size = size_slice_packed_int64
+ } else {
+ p.enc = (*Buffer).enc_slice_int64
+ p.size = size_slice_int64
+ }
+ p.dec = (*Buffer).dec_slice_int64
+ p.packedDec = (*Buffer).dec_slice_packed_int64
+ case reflect.Uint8:
+ p.dec = (*Buffer).dec_slice_byte
+ if p.proto3 {
+ p.enc = (*Buffer).enc_proto3_slice_byte
+ p.size = size_proto3_slice_byte
+ } else {
+ p.enc = (*Buffer).enc_slice_byte
+ p.size = size_slice_byte
+ }
+ case reflect.Float32, reflect.Float64:
+ switch t2.Bits() {
+ case 32:
+ // can just treat them as bits
+ if p.Packed {
+ p.enc = (*Buffer).enc_slice_packed_uint32
+ p.size = size_slice_packed_uint32
+ } else {
+ p.enc = (*Buffer).enc_slice_uint32
+ p.size = size_slice_uint32
+ }
+ p.dec = (*Buffer).dec_slice_int32
+ p.packedDec = (*Buffer).dec_slice_packed_int32
+ case 64:
+ // can just treat them as bits
+ if p.Packed {
+ p.enc = (*Buffer).enc_slice_packed_int64
+ p.size = size_slice_packed_int64
+ } else {
+ p.enc = (*Buffer).enc_slice_int64
+ p.size = size_slice_int64
+ }
+ p.dec = (*Buffer).dec_slice_int64
+ p.packedDec = (*Buffer).dec_slice_packed_int64
+ default:
+ logNoSliceEnc(t1, t2)
+ break
+ }
+ case reflect.String:
+ p.enc = (*Buffer).enc_slice_string
+ p.dec = (*Buffer).dec_slice_string
+ p.size = size_slice_string
case reflect.Ptr:
switch t3 := t2.Elem(); t3.Kind() {
+ default:
+ fmt.Fprintf(os.Stderr, "proto: no ptr oenc for %T -> %T -> %T\n", t1, t2, t3)
+ break
case reflect.Struct:
- p.stype = t3
+ p.stype = t2.Elem()
+ p.isMarshaler = isMarshaler(t2)
+ p.isUnmarshaler = isUnmarshaler(t2)
+ if p.Wire == "bytes" {
+ p.enc = (*Buffer).enc_slice_struct_message
+ p.dec = (*Buffer).dec_slice_struct_message
+ p.size = size_slice_struct_message
+ } else {
+ p.enc = (*Buffer).enc_slice_struct_group
+ p.dec = (*Buffer).dec_slice_struct_group
+ p.size = size_slice_struct_group
+ }
+ }
+ case reflect.Slice:
+ switch t2.Elem().Kind() {
+ default:
+ fmt.Fprintf(os.Stderr, "proto: no slice elem oenc for %T -> %T -> %T\n", t1, t2, t2.Elem())
+ break
+ case reflect.Uint8:
+ p.enc = (*Buffer).enc_slice_slice_byte
+ p.dec = (*Buffer).dec_slice_slice_byte
+ p.size = size_slice_slice_byte
}
case reflect.Struct:
- p.stype = t2
+ p.setSliceOfNonPointerStructs(t1)
}
case reflect.Map:
+ p.enc = (*Buffer).enc_new_map
+ p.dec = (*Buffer).dec_new_map
+ p.size = size_new_map
p.mtype = t1
p.mkeyprop = &Properties{}
@@ -336,6 +659,20 @@ func (p *Properties) setFieldProps(typ reflect.Type, f *reflect.StructField, loc
}
func (p *Properties) setTag(lockGetProp bool) {
+ // precalculate tag code
+ wire := p.WireType
+ if p.Packed {
+ wire = WireBytes
+ }
+ x := uint32(p.Tag)<<3 | uint32(wire)
+ i := 0
+ for i = 0; x > 127; i++ {
+ p.tagbuf[i] = 0x80 | uint8(x&0x7F)
+ x >>= 7
+ }
+ p.tagbuf[i] = uint8(x)
+ p.tagcode = p.tagbuf[0 : i+1]
+
if p.stype != nil {
if lockGetProp {
p.sprop = GetProperties(p.stype)
@@ -346,9 +683,20 @@ func (p *Properties) setTag(lockGetProp bool) {
}
var (
- marshalerType = reflect.TypeOf((*Marshaler)(nil)).Elem()
+ marshalerType = reflect.TypeOf((*Marshaler)(nil)).Elem()
+ unmarshalerType = reflect.TypeOf((*Unmarshaler)(nil)).Elem()
)
+// isMarshaler reports whether type t implements Marshaler.
+func isMarshaler(t reflect.Type) bool {
+ return t.Implements(marshalerType)
+}
+
+// isUnmarshaler reports whether type t implements Unmarshaler.
+func isUnmarshaler(t reflect.Type) bool {
+ return t.Implements(unmarshalerType)
+}
+
// Init populates the properties from a protocol buffer struct tag.
func (p *Properties) Init(typ reflect.Type, name, tag string, f *reflect.StructField) {
p.init(typ, name, tag, f, true)
@@ -358,11 +706,14 @@ func (p *Properties) init(typ reflect.Type, name, tag string, f *reflect.StructF
// "bytes,49,opt,def=hello!"
p.Name = name
p.OrigName = name
+ if f != nil {
+ p.field = toField(f)
+ }
if tag == "" {
return
}
p.Parse(tag)
- p.setFieldProps(typ, f, lockGetProp)
+ p.setEncAndDec(typ, f, lockGetProp)
}
var (
@@ -412,6 +763,10 @@ func getPropertiesLocked(t reflect.Type) *StructProperties {
propertiesMap[t] = prop
// build properties
+ prop.extendable = reflect.PtrTo(t).Implements(extendableProtoType) ||
+ reflect.PtrTo(t).Implements(extendableProtoV1Type) ||
+ reflect.PtrTo(t).Implements(extendableBytesType)
+ prop.unrecField = invalidField
prop.Prop = make([]*Properties, t.NumField())
prop.order = make([]int, t.NumField())
@@ -422,6 +777,23 @@ func getPropertiesLocked(t reflect.Type) *StructProperties {
name := f.Name
p.init(f.Type, name, f.Tag.Get("protobuf"), &f, false)
+ if f.Name == "XXX_InternalExtensions" { // special case
+ p.enc = (*Buffer).enc_exts
+ p.dec = nil // not needed
+ p.size = size_exts
+ } else if f.Name == "XXX_extensions" { // special case
+ if len(f.Tag.Get("protobuf")) > 0 {
+ p.enc = (*Buffer).enc_ext_slice_byte
+ p.dec = nil // not needed
+ p.size = size_ext_slice_byte
+ } else {
+ p.enc = (*Buffer).enc_map
+ p.dec = nil // not needed
+ p.size = size_map
+ }
+ } else if f.Name == "XXX_unrecognized" { // special case
+ prop.unrecField = toField(&f)
+ }
oneof := f.Tag.Get("protobuf_oneof") // special case
if oneof != "" {
isOneofMessage = true
@@ -437,6 +809,9 @@ func getPropertiesLocked(t reflect.Type) *StructProperties {
}
print("\n")
}
+ if p.enc == nil && !strings.HasPrefix(f.Name, "XXX_") && oneof == "" {
+ fmt.Fprintln(os.Stderr, "proto: no encoder for", f.Name, f.Type.String(), "[GetProperties]")
+ }
}
// Re-order prop.order.
@@ -447,7 +822,8 @@ func getPropertiesLocked(t reflect.Type) *StructProperties {
}
if om, ok := reflect.Zero(reflect.PtrTo(t)).Interface().(oneofMessage); isOneofMessage && ok {
var oots []interface{}
- _, _, _, oots = om.XXX_OneofFuncs()
+ prop.oneofMarshaler, prop.oneofUnmarshaler, prop.oneofSizer, oots = om.XXX_OneofFuncs()
+ prop.stype = t
// Interpret oneof metadata.
prop.OneofTypes = make(map[string]*OneofProperties)
@@ -497,6 +873,30 @@ func getPropertiesLocked(t reflect.Type) *StructProperties {
return prop
}
+// Return the Properties object for the x[0]'th field of the structure.
+func propByIndex(t reflect.Type, x []int) *Properties {
+ if len(x) != 1 {
+ fmt.Fprintf(os.Stderr, "proto: field index dimension %d (not 1) for type %s\n", len(x), t)
+ return nil
+ }
+ prop := GetProperties(t)
+ return prop.Prop[x[0]]
+}
+
+// Get the address and type of a pointer to a struct from an interface.
+func getbase(pb Message) (t reflect.Type, b structPointer, err error) {
+ if pb == nil {
+ err = ErrNil
+ return
+ }
+ // get the reflect type of the pointer to the struct.
+ t = reflect.TypeOf(pb)
+ // get the address of the struct.
+ value := reflect.ValueOf(pb)
+ b = toStructPointer(value)
+ return
+}
+
// A global registry of enum types.
// The generated code will register the generated maps by calling RegisterEnum.
@@ -525,42 +925,20 @@ func EnumValueMap(enumType string) map[string]int32 {
// A registry of all linked message types.
// The string is a fully-qualified proto name ("pkg.Message").
var (
- protoTypedNils = make(map[string]Message) // a map from proto names to typed nil pointers
- protoMapTypes = make(map[string]reflect.Type) // a map from proto names to map types
- revProtoTypes = make(map[reflect.Type]string)
+ protoTypes = make(map[string]reflect.Type)
+ revProtoTypes = make(map[reflect.Type]string)
)
// RegisterType is called from generated code and maps from the fully qualified
// proto name to the type (pointer to struct) of the protocol buffer.
func RegisterType(x Message, name string) {
- if _, ok := protoTypedNils[name]; ok {
+ if _, ok := protoTypes[name]; ok {
// TODO: Some day, make this a panic.
log.Printf("proto: duplicate proto type registered: %s", name)
return
}
t := reflect.TypeOf(x)
- if v := reflect.ValueOf(x); v.Kind() == reflect.Ptr && v.Pointer() == 0 {
- // Generated code always calls RegisterType with nil x.
- // This check is just for extra safety.
- protoTypedNils[name] = x
- } else {
- protoTypedNils[name] = reflect.Zero(t).Interface().(Message)
- }
- revProtoTypes[t] = name
-}
-
-// RegisterMapType is called from generated code and maps from the fully qualified
-// proto name to the native map type of the proto map definition.
-func RegisterMapType(x interface{}, name string) {
- if reflect.TypeOf(x).Kind() != reflect.Map {
- panic(fmt.Sprintf("RegisterMapType(%T, %q); want map", x, name))
- }
- if _, ok := protoMapTypes[name]; ok {
- log.Printf("proto: duplicate proto type registered: %s", name)
- return
- }
- t := reflect.TypeOf(x)
- protoMapTypes[name] = t
+ protoTypes[name] = t
revProtoTypes[t] = name
}
@@ -576,14 +954,7 @@ func MessageName(x Message) string {
}
// MessageType returns the message type (pointer to struct) for a named message.
-// The type is not guaranteed to implement proto.Message if the name refers to a
-// map entry.
-func MessageType(name string) reflect.Type {
- if t, ok := protoTypedNils[name]; ok {
- return reflect.TypeOf(t)
- }
- return protoMapTypes[name]
-}
+func MessageType(name string) reflect.Type { return protoTypes[name] }
// A registry of all linked proto files.
var (
diff --git a/vendor/github.com/gogo/protobuf/proto/properties_gogo.go b/vendor/github.com/gogo/protobuf/proto/properties_gogo.go
index 40ea3dd935..b6b7176c56 100644
--- a/vendor/github.com/gogo/protobuf/proto/properties_gogo.go
+++ b/vendor/github.com/gogo/protobuf/proto/properties_gogo.go
@@ -1,6 +1,6 @@
// Protocol Buffers for Go with Gadgets
//
-// Copyright (c) 2018, The GoGo Authors. All rights reserved.
+// Copyright (c) 2013, The GoGo Authors. All rights reserved.
// http://github.com/gogo/protobuf
//
// Redistribution and use in source and binary forms, with or without
@@ -29,8 +29,83 @@
package proto
import (
+ "fmt"
+ "os"
"reflect"
)
-var sizerType = reflect.TypeOf((*Sizer)(nil)).Elem()
-var protosizerType = reflect.TypeOf((*ProtoSizer)(nil)).Elem()
+func (p *Properties) setCustomEncAndDec(typ reflect.Type) {
+ p.ctype = typ
+ if p.Repeated {
+ p.enc = (*Buffer).enc_custom_slice_bytes
+ p.dec = (*Buffer).dec_custom_slice_bytes
+ p.size = size_custom_slice_bytes
+ } else if typ.Kind() == reflect.Ptr {
+ p.enc = (*Buffer).enc_custom_bytes
+ p.dec = (*Buffer).dec_custom_bytes
+ p.size = size_custom_bytes
+ } else {
+ p.enc = (*Buffer).enc_custom_ref_bytes
+ p.dec = (*Buffer).dec_custom_ref_bytes
+ p.size = size_custom_ref_bytes
+ }
+}
+
+func (p *Properties) setDurationEncAndDec(typ reflect.Type) {
+ if p.Repeated {
+ if typ.Elem().Kind() == reflect.Ptr {
+ p.enc = (*Buffer).enc_slice_duration
+ p.dec = (*Buffer).dec_slice_duration
+ p.size = size_slice_duration
+ } else {
+ p.enc = (*Buffer).enc_slice_ref_duration
+ p.dec = (*Buffer).dec_slice_ref_duration
+ p.size = size_slice_ref_duration
+ }
+ } else if typ.Kind() == reflect.Ptr {
+ p.enc = (*Buffer).enc_duration
+ p.dec = (*Buffer).dec_duration
+ p.size = size_duration
+ } else {
+ p.enc = (*Buffer).enc_ref_duration
+ p.dec = (*Buffer).dec_ref_duration
+ p.size = size_ref_duration
+ }
+}
+
+func (p *Properties) setTimeEncAndDec(typ reflect.Type) {
+ if p.Repeated {
+ if typ.Elem().Kind() == reflect.Ptr {
+ p.enc = (*Buffer).enc_slice_time
+ p.dec = (*Buffer).dec_slice_time
+ p.size = size_slice_time
+ } else {
+ p.enc = (*Buffer).enc_slice_ref_time
+ p.dec = (*Buffer).dec_slice_ref_time
+ p.size = size_slice_ref_time
+ }
+ } else if typ.Kind() == reflect.Ptr {
+ p.enc = (*Buffer).enc_time
+ p.dec = (*Buffer).dec_time
+ p.size = size_time
+ } else {
+ p.enc = (*Buffer).enc_ref_time
+ p.dec = (*Buffer).dec_ref_time
+ p.size = size_ref_time
+ }
+
+}
+
+func (p *Properties) setSliceOfNonPointerStructs(typ reflect.Type) {
+ t2 := typ.Elem()
+ p.sstype = typ
+ p.stype = t2
+ p.isMarshaler = isMarshaler(t2)
+ p.isUnmarshaler = isUnmarshaler(t2)
+ p.enc = (*Buffer).enc_slice_ref_struct_message
+ p.dec = (*Buffer).dec_slice_ref_struct_message
+ p.size = size_slice_ref_struct_message
+ if p.Wire != "bytes" {
+ fmt.Fprintf(os.Stderr, "proto: no ptr oenc for %T -> %T \n", typ, t2)
+ }
+}
diff --git a/vendor/github.com/gogo/protobuf/proto/table_marshal.go b/vendor/github.com/gogo/protobuf/proto/table_marshal.go
deleted file mode 100644
index 255e7b5088..0000000000
--- a/vendor/github.com/gogo/protobuf/proto/table_marshal.go
+++ /dev/null
@@ -1,2799 +0,0 @@
-// Go support for Protocol Buffers - Google's data interchange format
-//
-// Copyright 2016 The Go Authors. All rights reserved.
-// https://github.com/golang/protobuf
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-package proto
-
-import (
- "errors"
- "fmt"
- "math"
- "reflect"
- "sort"
- "strconv"
- "strings"
- "sync"
- "sync/atomic"
- "unicode/utf8"
-)
-
-// a sizer takes a pointer to a field and the size of its tag, computes the size of
-// the encoded data.
-type sizer func(pointer, int) int
-
-// a marshaler takes a byte slice, a pointer to a field, and its tag (in wire format),
-// marshals the field to the end of the slice, returns the slice and error (if any).
-type marshaler func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error)
-
-// marshalInfo is the information used for marshaling a message.
-type marshalInfo struct {
- typ reflect.Type
- fields []*marshalFieldInfo
- unrecognized field // offset of XXX_unrecognized
- extensions field // offset of XXX_InternalExtensions
- v1extensions field // offset of XXX_extensions
- sizecache field // offset of XXX_sizecache
- initialized int32 // 0 -- only typ is set, 1 -- fully initialized
- messageset bool // uses message set wire format
- hasmarshaler bool // has custom marshaler
- sync.RWMutex // protect extElems map, also for initialization
- extElems map[int32]*marshalElemInfo // info of extension elements
-
- hassizer bool // has custom sizer
- hasprotosizer bool // has custom protosizer
-
- bytesExtensions field // offset of XXX_extensions where the field type is []byte
-}
-
-// marshalFieldInfo is the information used for marshaling a field of a message.
-type marshalFieldInfo struct {
- field field
- wiretag uint64 // tag in wire format
- tagsize int // size of tag in wire format
- sizer sizer
- marshaler marshaler
- isPointer bool
- required bool // field is required
- name string // name of the field, for error reporting
- oneofElems map[reflect.Type]*marshalElemInfo // info of oneof elements
-}
-
-// marshalElemInfo is the information used for marshaling an extension or oneof element.
-type marshalElemInfo struct {
- wiretag uint64 // tag in wire format
- tagsize int // size of tag in wire format
- sizer sizer
- marshaler marshaler
- isptr bool // elem is pointer typed, thus interface of this type is a direct interface (extension only)
-}
-
-var (
- marshalInfoMap = map[reflect.Type]*marshalInfo{}
- marshalInfoLock sync.Mutex
-)
-
-// getMarshalInfo returns the information to marshal a given type of message.
-// The info it returns may not necessarily initialized.
-// t is the type of the message (NOT the pointer to it).
-func getMarshalInfo(t reflect.Type) *marshalInfo {
- marshalInfoLock.Lock()
- u, ok := marshalInfoMap[t]
- if !ok {
- u = &marshalInfo{typ: t}
- marshalInfoMap[t] = u
- }
- marshalInfoLock.Unlock()
- return u
-}
-
-// Size is the entry point from generated code,
-// and should be ONLY called by generated code.
-// It computes the size of encoded data of msg.
-// a is a pointer to a place to store cached marshal info.
-func (a *InternalMessageInfo) Size(msg Message) int {
- u := getMessageMarshalInfo(msg, a)
- ptr := toPointer(&msg)
- if ptr.isNil() {
- // We get here if msg is a typed nil ((*SomeMessage)(nil)),
- // so it satisfies the interface, and msg == nil wouldn't
- // catch it. We don't want crash in this case.
- return 0
- }
- return u.size(ptr)
-}
-
-// Marshal is the entry point from generated code,
-// and should be ONLY called by generated code.
-// It marshals msg to the end of b.
-// a is a pointer to a place to store cached marshal info.
-func (a *InternalMessageInfo) Marshal(b []byte, msg Message, deterministic bool) ([]byte, error) {
- u := getMessageMarshalInfo(msg, a)
- ptr := toPointer(&msg)
- if ptr.isNil() {
- // We get here if msg is a typed nil ((*SomeMessage)(nil)),
- // so it satisfies the interface, and msg == nil wouldn't
- // catch it. We don't want crash in this case.
- return b, ErrNil
- }
- return u.marshal(b, ptr, deterministic)
-}
-
-func getMessageMarshalInfo(msg interface{}, a *InternalMessageInfo) *marshalInfo {
- // u := a.marshal, but atomically.
- // We use an atomic here to ensure memory consistency.
- u := atomicLoadMarshalInfo(&a.marshal)
- if u == nil {
- // Get marshal information from type of message.
- t := reflect.ValueOf(msg).Type()
- if t.Kind() != reflect.Ptr {
- panic(fmt.Sprintf("cannot handle non-pointer message type %v", t))
- }
- u = getMarshalInfo(t.Elem())
- // Store it in the cache for later users.
- // a.marshal = u, but atomically.
- atomicStoreMarshalInfo(&a.marshal, u)
- }
- return u
-}
-
-// size is the main function to compute the size of the encoded data of a message.
-// ptr is the pointer to the message.
-func (u *marshalInfo) size(ptr pointer) int {
- if atomic.LoadInt32(&u.initialized) == 0 {
- u.computeMarshalInfo()
- }
-
- // If the message can marshal itself, let it do it, for compatibility.
- // NOTE: This is not efficient.
- if u.hasmarshaler {
- // Uses the message's Size method if available
- if u.hassizer {
- s := ptr.asPointerTo(u.typ).Interface().(Sizer)
- return s.Size()
- }
- // Uses the message's ProtoSize method if available
- if u.hasprotosizer {
- s := ptr.asPointerTo(u.typ).Interface().(ProtoSizer)
- return s.ProtoSize()
- }
-
- m := ptr.asPointerTo(u.typ).Interface().(Marshaler)
- b, _ := m.Marshal()
- return len(b)
- }
-
- n := 0
- for _, f := range u.fields {
- if f.isPointer && ptr.offset(f.field).getPointer().isNil() {
- // nil pointer always marshals to nothing
- continue
- }
- n += f.sizer(ptr.offset(f.field), f.tagsize)
- }
- if u.extensions.IsValid() {
- e := ptr.offset(u.extensions).toExtensions()
- if u.messageset {
- n += u.sizeMessageSet(e)
- } else {
- n += u.sizeExtensions(e)
- }
- }
- if u.v1extensions.IsValid() {
- m := *ptr.offset(u.v1extensions).toOldExtensions()
- n += u.sizeV1Extensions(m)
- }
- if u.bytesExtensions.IsValid() {
- s := *ptr.offset(u.bytesExtensions).toBytes()
- n += len(s)
- }
- if u.unrecognized.IsValid() {
- s := *ptr.offset(u.unrecognized).toBytes()
- n += len(s)
- }
-
- // cache the result for use in marshal
- if u.sizecache.IsValid() {
- atomic.StoreInt32(ptr.offset(u.sizecache).toInt32(), int32(n))
- }
- return n
-}
-
-// cachedsize gets the size from cache. If there is no cache (i.e. message is not generated),
-// fall back to compute the size.
-func (u *marshalInfo) cachedsize(ptr pointer) int {
- if u.sizecache.IsValid() {
- return int(atomic.LoadInt32(ptr.offset(u.sizecache).toInt32()))
- }
- return u.size(ptr)
-}
-
-// marshal is the main function to marshal a message. It takes a byte slice and appends
-// the encoded data to the end of the slice, returns the slice and error (if any).
-// ptr is the pointer to the message.
-// If deterministic is true, map is marshaled in deterministic order.
-func (u *marshalInfo) marshal(b []byte, ptr pointer, deterministic bool) ([]byte, error) {
- if atomic.LoadInt32(&u.initialized) == 0 {
- u.computeMarshalInfo()
- }
-
- // If the message can marshal itself, let it do it, for compatibility.
- // NOTE: This is not efficient.
- if u.hasmarshaler {
- if deterministic {
- return nil, errors.New("proto: deterministic not supported by the Marshal method of " + u.typ.String())
- }
- m := ptr.asPointerTo(u.typ).Interface().(Marshaler)
- b1, err := m.Marshal()
- b = append(b, b1...)
- return b, err
- }
-
- var err, errreq error
- // The old marshaler encodes extensions at beginning.
- if u.extensions.IsValid() {
- e := ptr.offset(u.extensions).toExtensions()
- if u.messageset {
- b, err = u.appendMessageSet(b, e, deterministic)
- } else {
- b, err = u.appendExtensions(b, e, deterministic)
- }
- if err != nil {
- return b, err
- }
- }
- if u.v1extensions.IsValid() {
- m := *ptr.offset(u.v1extensions).toOldExtensions()
- b, err = u.appendV1Extensions(b, m, deterministic)
- if err != nil {
- return b, err
- }
- }
- if u.bytesExtensions.IsValid() {
- s := *ptr.offset(u.bytesExtensions).toBytes()
- b = append(b, s...)
- }
- for _, f := range u.fields {
- if f.required && errreq == nil {
- if ptr.offset(f.field).getPointer().isNil() {
- // Required field is not set.
- // We record the error but keep going, to give a complete marshaling.
- errreq = &RequiredNotSetError{f.name}
- continue
- }
- }
- if f.isPointer && ptr.offset(f.field).getPointer().isNil() {
- // nil pointer always marshals to nothing
- continue
- }
- b, err = f.marshaler(b, ptr.offset(f.field), f.wiretag, deterministic)
- if err != nil {
- if err1, ok := err.(*RequiredNotSetError); ok {
- // Required field in submessage is not set.
- // We record the error but keep going, to give a complete marshaling.
- if errreq == nil {
- errreq = &RequiredNotSetError{f.name + "." + err1.field}
- }
- continue
- }
- if err == errRepeatedHasNil {
- err = errors.New("proto: repeated field " + f.name + " has nil element")
- }
- return b, err
- }
- }
- if u.unrecognized.IsValid() {
- s := *ptr.offset(u.unrecognized).toBytes()
- b = append(b, s...)
- }
- return b, errreq
-}
-
-// computeMarshalInfo initializes the marshal info.
-func (u *marshalInfo) computeMarshalInfo() {
- u.Lock()
- defer u.Unlock()
- if u.initialized != 0 { // non-atomic read is ok as it is protected by the lock
- return
- }
-
- t := u.typ
- u.unrecognized = invalidField
- u.extensions = invalidField
- u.v1extensions = invalidField
- u.bytesExtensions = invalidField
- u.sizecache = invalidField
- isOneofMessage := false
-
- if reflect.PtrTo(t).Implements(sizerType) {
- u.hassizer = true
- }
- if reflect.PtrTo(t).Implements(protosizerType) {
- u.hasprotosizer = true
- }
- // If the message can marshal itself, let it do it, for compatibility.
- // NOTE: This is not efficient.
- if reflect.PtrTo(t).Implements(marshalerType) {
- u.hasmarshaler = true
- atomic.StoreInt32(&u.initialized, 1)
- return
- }
-
- n := t.NumField()
-
- // deal with XXX fields first
- for i := 0; i < t.NumField(); i++ {
- f := t.Field(i)
- if f.Tag.Get("protobuf_oneof") != "" {
- isOneofMessage = true
- }
- if !strings.HasPrefix(f.Name, "XXX_") {
- continue
- }
- switch f.Name {
- case "XXX_sizecache":
- u.sizecache = toField(&f)
- case "XXX_unrecognized":
- u.unrecognized = toField(&f)
- case "XXX_InternalExtensions":
- u.extensions = toField(&f)
- u.messageset = f.Tag.Get("protobuf_messageset") == "1"
- case "XXX_extensions":
- if f.Type.Kind() == reflect.Map {
- u.v1extensions = toField(&f)
- } else {
- u.bytesExtensions = toField(&f)
- }
- case "XXX_NoUnkeyedLiteral":
- // nothing to do
- default:
- panic("unknown XXX field: " + f.Name)
- }
- n--
- }
-
- // get oneof implementers
- var oneofImplementers []interface{}
- // gogo: isOneofMessage is needed for embedded oneof messages, without a marshaler and unmarshaler
- if m, ok := reflect.Zero(reflect.PtrTo(t)).Interface().(oneofMessage); ok && isOneofMessage {
- _, _, _, oneofImplementers = m.XXX_OneofFuncs()
- }
-
- // normal fields
- fields := make([]marshalFieldInfo, n) // batch allocation
- u.fields = make([]*marshalFieldInfo, 0, n)
- for i, j := 0, 0; i < t.NumField(); i++ {
- f := t.Field(i)
-
- if strings.HasPrefix(f.Name, "XXX_") {
- continue
- }
- field := &fields[j]
- j++
- field.name = f.Name
- u.fields = append(u.fields, field)
- if f.Tag.Get("protobuf_oneof") != "" {
- field.computeOneofFieldInfo(&f, oneofImplementers)
- continue
- }
- if f.Tag.Get("protobuf") == "" {
- // field has no tag (not in generated message), ignore it
- u.fields = u.fields[:len(u.fields)-1]
- j--
- continue
- }
- field.computeMarshalFieldInfo(&f)
- }
-
- // fields are marshaled in tag order on the wire.
- sort.Sort(byTag(u.fields))
-
- atomic.StoreInt32(&u.initialized, 1)
-}
-
-// helper for sorting fields by tag
-type byTag []*marshalFieldInfo
-
-func (a byTag) Len() int { return len(a) }
-func (a byTag) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
-func (a byTag) Less(i, j int) bool { return a[i].wiretag < a[j].wiretag }
-
-// getExtElemInfo returns the information to marshal an extension element.
-// The info it returns is initialized.
-func (u *marshalInfo) getExtElemInfo(desc *ExtensionDesc) *marshalElemInfo {
- // get from cache first
- u.RLock()
- e, ok := u.extElems[desc.Field]
- u.RUnlock()
- if ok {
- return e
- }
-
- t := reflect.TypeOf(desc.ExtensionType) // pointer or slice to basic type or struct
- tags := strings.Split(desc.Tag, ",")
- tag, err := strconv.Atoi(tags[1])
- if err != nil {
- panic("tag is not an integer")
- }
- wt := wiretype(tags[0])
- sizr, marshalr := typeMarshaler(t, tags, false, false)
- e = &marshalElemInfo{
- wiretag: uint64(tag)<<3 | wt,
- tagsize: SizeVarint(uint64(tag) << 3),
- sizer: sizr,
- marshaler: marshalr,
- isptr: t.Kind() == reflect.Ptr,
- }
-
- // update cache
- u.Lock()
- if u.extElems == nil {
- u.extElems = make(map[int32]*marshalElemInfo)
- }
- u.extElems[desc.Field] = e
- u.Unlock()
- return e
-}
-
-// computeMarshalFieldInfo fills up the information to marshal a field.
-func (fi *marshalFieldInfo) computeMarshalFieldInfo(f *reflect.StructField) {
- // parse protobuf tag of the field.
- // tag has format of "bytes,49,opt,name=foo,def=hello!"
- tags := strings.Split(f.Tag.Get("protobuf"), ",")
- if tags[0] == "" {
- return
- }
- tag, err := strconv.Atoi(tags[1])
- if err != nil {
- panic("tag is not an integer")
- }
- wt := wiretype(tags[0])
- if tags[2] == "req" {
- fi.required = true
- }
- fi.setTag(f, tag, wt)
- fi.setMarshaler(f, tags)
-}
-
-func (fi *marshalFieldInfo) computeOneofFieldInfo(f *reflect.StructField, oneofImplementers []interface{}) {
- fi.field = toField(f)
- fi.wiretag = 1<<31 - 1 // Use a large tag number, make oneofs sorted at the end. This tag will not appear on the wire.
- fi.isPointer = true
- fi.sizer, fi.marshaler = makeOneOfMarshaler(fi, f)
- fi.oneofElems = make(map[reflect.Type]*marshalElemInfo)
-
- ityp := f.Type // interface type
- for _, o := range oneofImplementers {
- t := reflect.TypeOf(o)
- if !t.Implements(ityp) {
- continue
- }
- sf := t.Elem().Field(0) // oneof implementer is a struct with a single field
- tags := strings.Split(sf.Tag.Get("protobuf"), ",")
- tag, err := strconv.Atoi(tags[1])
- if err != nil {
- panic("tag is not an integer")
- }
- wt := wiretype(tags[0])
- sizr, marshalr := typeMarshaler(sf.Type, tags, false, true) // oneof should not omit any zero value
- fi.oneofElems[t.Elem()] = &marshalElemInfo{
- wiretag: uint64(tag)<<3 | wt,
- tagsize: SizeVarint(uint64(tag) << 3),
- sizer: sizr,
- marshaler: marshalr,
- }
- }
-}
-
-type oneofMessage interface {
- XXX_OneofFuncs() (func(Message, *Buffer) error, func(Message, int, int, *Buffer) (bool, error), func(Message) int, []interface{})
-}
-
-// wiretype returns the wire encoding of the type.
-func wiretype(encoding string) uint64 {
- switch encoding {
- case "fixed32":
- return WireFixed32
- case "fixed64":
- return WireFixed64
- case "varint", "zigzag32", "zigzag64":
- return WireVarint
- case "bytes":
- return WireBytes
- case "group":
- return WireStartGroup
- }
- panic("unknown wire type " + encoding)
-}
-
-// setTag fills up the tag (in wire format) and its size in the info of a field.
-func (fi *marshalFieldInfo) setTag(f *reflect.StructField, tag int, wt uint64) {
- fi.field = toField(f)
- fi.wiretag = uint64(tag)<<3 | wt
- fi.tagsize = SizeVarint(uint64(tag) << 3)
-}
-
-// setMarshaler fills up the sizer and marshaler in the info of a field.
-func (fi *marshalFieldInfo) setMarshaler(f *reflect.StructField, tags []string) {
- switch f.Type.Kind() {
- case reflect.Map:
- // map field
- fi.isPointer = true
- fi.sizer, fi.marshaler = makeMapMarshaler(f)
- return
- case reflect.Ptr, reflect.Slice:
- fi.isPointer = true
- }
- fi.sizer, fi.marshaler = typeMarshaler(f.Type, tags, true, false)
-}
-
-// typeMarshaler returns the sizer and marshaler of a given field.
-// t is the type of the field.
-// tags is the generated "protobuf" tag of the field.
-// If nozero is true, zero value is not marshaled to the wire.
-// If oneof is true, it is a oneof field.
-func typeMarshaler(t reflect.Type, tags []string, nozero, oneof bool) (sizer, marshaler) {
- encoding := tags[0]
-
- pointer := false
- slice := false
- if t.Kind() == reflect.Slice && t.Elem().Kind() != reflect.Uint8 {
- slice = true
- t = t.Elem()
- }
- if t.Kind() == reflect.Ptr {
- pointer = true
- t = t.Elem()
- }
-
- packed := false
- proto3 := false
- ctype := false
- isTime := false
- isDuration := false
- for i := 2; i < len(tags); i++ {
- if tags[i] == "packed" {
- packed = true
- }
- if tags[i] == "proto3" {
- proto3 = true
- }
- if strings.HasPrefix(tags[i], "customtype=") {
- ctype = true
- }
- if tags[i] == "stdtime" {
- isTime = true
- }
- if tags[i] == "stdduration" {
- isDuration = true
- }
- }
- if !proto3 && !pointer && !slice {
- nozero = false
- }
-
- if ctype {
- if reflect.PtrTo(t).Implements(customType) {
- if slice {
- return makeMessageRefSliceMarshaler(getMarshalInfo(t))
- }
- if pointer {
- return makeCustomPtrMarshaler(getMarshalInfo(t))
- }
- return makeCustomMarshaler(getMarshalInfo(t))
- } else {
- panic(fmt.Sprintf("custom type: type: %v, does not implement the proto.custom interface", t))
- }
- }
-
- if isTime {
- if pointer {
- if slice {
- return makeTimePtrSliceMarshaler(getMarshalInfo(t))
- }
- return makeTimePtrMarshaler(getMarshalInfo(t))
- }
- if slice {
- return makeTimeSliceMarshaler(getMarshalInfo(t))
- }
- return makeTimeMarshaler(getMarshalInfo(t))
- }
-
- if isDuration {
- if pointer {
- if slice {
- return makeDurationPtrSliceMarshaler(getMarshalInfo(t))
- }
- return makeDurationPtrMarshaler(getMarshalInfo(t))
- }
- if slice {
- return makeDurationSliceMarshaler(getMarshalInfo(t))
- }
- return makeDurationMarshaler(getMarshalInfo(t))
- }
-
- switch t.Kind() {
- case reflect.Bool:
- if pointer {
- return sizeBoolPtr, appendBoolPtr
- }
- if slice {
- if packed {
- return sizeBoolPackedSlice, appendBoolPackedSlice
- }
- return sizeBoolSlice, appendBoolSlice
- }
- if nozero {
- return sizeBoolValueNoZero, appendBoolValueNoZero
- }
- return sizeBoolValue, appendBoolValue
- case reflect.Uint32:
- switch encoding {
- case "fixed32":
- if pointer {
- return sizeFixed32Ptr, appendFixed32Ptr
- }
- if slice {
- if packed {
- return sizeFixed32PackedSlice, appendFixed32PackedSlice
- }
- return sizeFixed32Slice, appendFixed32Slice
- }
- if nozero {
- return sizeFixed32ValueNoZero, appendFixed32ValueNoZero
- }
- return sizeFixed32Value, appendFixed32Value
- case "varint":
- if pointer {
- return sizeVarint32Ptr, appendVarint32Ptr
- }
- if slice {
- if packed {
- return sizeVarint32PackedSlice, appendVarint32PackedSlice
- }
- return sizeVarint32Slice, appendVarint32Slice
- }
- if nozero {
- return sizeVarint32ValueNoZero, appendVarint32ValueNoZero
- }
- return sizeVarint32Value, appendVarint32Value
- }
- case reflect.Int32:
- switch encoding {
- case "fixed32":
- if pointer {
- return sizeFixedS32Ptr, appendFixedS32Ptr
- }
- if slice {
- if packed {
- return sizeFixedS32PackedSlice, appendFixedS32PackedSlice
- }
- return sizeFixedS32Slice, appendFixedS32Slice
- }
- if nozero {
- return sizeFixedS32ValueNoZero, appendFixedS32ValueNoZero
- }
- return sizeFixedS32Value, appendFixedS32Value
- case "varint":
- if pointer {
- return sizeVarintS32Ptr, appendVarintS32Ptr
- }
- if slice {
- if packed {
- return sizeVarintS32PackedSlice, appendVarintS32PackedSlice
- }
- return sizeVarintS32Slice, appendVarintS32Slice
- }
- if nozero {
- return sizeVarintS32ValueNoZero, appendVarintS32ValueNoZero
- }
- return sizeVarintS32Value, appendVarintS32Value
- case "zigzag32":
- if pointer {
- return sizeZigzag32Ptr, appendZigzag32Ptr
- }
- if slice {
- if packed {
- return sizeZigzag32PackedSlice, appendZigzag32PackedSlice
- }
- return sizeZigzag32Slice, appendZigzag32Slice
- }
- if nozero {
- return sizeZigzag32ValueNoZero, appendZigzag32ValueNoZero
- }
- return sizeZigzag32Value, appendZigzag32Value
- }
- case reflect.Uint64:
- switch encoding {
- case "fixed64":
- if pointer {
- return sizeFixed64Ptr, appendFixed64Ptr
- }
- if slice {
- if packed {
- return sizeFixed64PackedSlice, appendFixed64PackedSlice
- }
- return sizeFixed64Slice, appendFixed64Slice
- }
- if nozero {
- return sizeFixed64ValueNoZero, appendFixed64ValueNoZero
- }
- return sizeFixed64Value, appendFixed64Value
- case "varint":
- if pointer {
- return sizeVarint64Ptr, appendVarint64Ptr
- }
- if slice {
- if packed {
- return sizeVarint64PackedSlice, appendVarint64PackedSlice
- }
- return sizeVarint64Slice, appendVarint64Slice
- }
- if nozero {
- return sizeVarint64ValueNoZero, appendVarint64ValueNoZero
- }
- return sizeVarint64Value, appendVarint64Value
- }
- case reflect.Int64:
- switch encoding {
- case "fixed64":
- if pointer {
- return sizeFixedS64Ptr, appendFixedS64Ptr
- }
- if slice {
- if packed {
- return sizeFixedS64PackedSlice, appendFixedS64PackedSlice
- }
- return sizeFixedS64Slice, appendFixedS64Slice
- }
- if nozero {
- return sizeFixedS64ValueNoZero, appendFixedS64ValueNoZero
- }
- return sizeFixedS64Value, appendFixedS64Value
- case "varint":
- if pointer {
- return sizeVarintS64Ptr, appendVarintS64Ptr
- }
- if slice {
- if packed {
- return sizeVarintS64PackedSlice, appendVarintS64PackedSlice
- }
- return sizeVarintS64Slice, appendVarintS64Slice
- }
- if nozero {
- return sizeVarintS64ValueNoZero, appendVarintS64ValueNoZero
- }
- return sizeVarintS64Value, appendVarintS64Value
- case "zigzag64":
- if pointer {
- return sizeZigzag64Ptr, appendZigzag64Ptr
- }
- if slice {
- if packed {
- return sizeZigzag64PackedSlice, appendZigzag64PackedSlice
- }
- return sizeZigzag64Slice, appendZigzag64Slice
- }
- if nozero {
- return sizeZigzag64ValueNoZero, appendZigzag64ValueNoZero
- }
- return sizeZigzag64Value, appendZigzag64Value
- }
- case reflect.Float32:
- if pointer {
- return sizeFloat32Ptr, appendFloat32Ptr
- }
- if slice {
- if packed {
- return sizeFloat32PackedSlice, appendFloat32PackedSlice
- }
- return sizeFloat32Slice, appendFloat32Slice
- }
- if nozero {
- return sizeFloat32ValueNoZero, appendFloat32ValueNoZero
- }
- return sizeFloat32Value, appendFloat32Value
- case reflect.Float64:
- if pointer {
- return sizeFloat64Ptr, appendFloat64Ptr
- }
- if slice {
- if packed {
- return sizeFloat64PackedSlice, appendFloat64PackedSlice
- }
- return sizeFloat64Slice, appendFloat64Slice
- }
- if nozero {
- return sizeFloat64ValueNoZero, appendFloat64ValueNoZero
- }
- return sizeFloat64Value, appendFloat64Value
- case reflect.String:
- if pointer {
- return sizeStringPtr, appendStringPtr
- }
- if slice {
- return sizeStringSlice, appendStringSlice
- }
- if nozero {
- return sizeStringValueNoZero, appendStringValueNoZero
- }
- return sizeStringValue, appendStringValue
- case reflect.Slice:
- if slice {
- return sizeBytesSlice, appendBytesSlice
- }
- if oneof {
- // Oneof bytes field may also have "proto3" tag.
- // We want to marshal it as a oneof field. Do this
- // check before the proto3 check.
- return sizeBytesOneof, appendBytesOneof
- }
- if proto3 {
- return sizeBytes3, appendBytes3
- }
- return sizeBytes, appendBytes
- case reflect.Struct:
- switch encoding {
- case "group":
- if slice {
- return makeGroupSliceMarshaler(getMarshalInfo(t))
- }
- return makeGroupMarshaler(getMarshalInfo(t))
- case "bytes":
- if pointer {
- if slice {
- return makeMessageSliceMarshaler(getMarshalInfo(t))
- }
- return makeMessageMarshaler(getMarshalInfo(t))
- } else {
- if slice {
- return makeMessageRefSliceMarshaler(getMarshalInfo(t))
- }
- return makeMessageRefMarshaler(getMarshalInfo(t))
- }
- }
- }
- panic(fmt.Sprintf("unknown or mismatched type: type: %v, wire type: %v", t, encoding))
-}
-
-// Below are functions to size/marshal a specific type of a field.
-// They are stored in the field's info, and called by function pointers.
-// They have type sizer or marshaler.
-
-func sizeFixed32Value(_ pointer, tagsize int) int {
- return 4 + tagsize
-}
-func sizeFixed32ValueNoZero(ptr pointer, tagsize int) int {
- v := *ptr.toUint32()
- if v == 0 {
- return 0
- }
- return 4 + tagsize
-}
-func sizeFixed32Ptr(ptr pointer, tagsize int) int {
- p := *ptr.toUint32Ptr()
- if p == nil {
- return 0
- }
- return 4 + tagsize
-}
-func sizeFixed32Slice(ptr pointer, tagsize int) int {
- s := *ptr.toUint32Slice()
- return (4 + tagsize) * len(s)
-}
-func sizeFixed32PackedSlice(ptr pointer, tagsize int) int {
- s := *ptr.toUint32Slice()
- if len(s) == 0 {
- return 0
- }
- return 4*len(s) + SizeVarint(uint64(4*len(s))) + tagsize
-}
-func sizeFixedS32Value(_ pointer, tagsize int) int {
- return 4 + tagsize
-}
-func sizeFixedS32ValueNoZero(ptr pointer, tagsize int) int {
- v := *ptr.toInt32()
- if v == 0 {
- return 0
- }
- return 4 + tagsize
-}
-func sizeFixedS32Ptr(ptr pointer, tagsize int) int {
- p := ptr.getInt32Ptr()
- if p == nil {
- return 0
- }
- return 4 + tagsize
-}
-func sizeFixedS32Slice(ptr pointer, tagsize int) int {
- s := ptr.getInt32Slice()
- return (4 + tagsize) * len(s)
-}
-func sizeFixedS32PackedSlice(ptr pointer, tagsize int) int {
- s := ptr.getInt32Slice()
- if len(s) == 0 {
- return 0
- }
- return 4*len(s) + SizeVarint(uint64(4*len(s))) + tagsize
-}
-func sizeFloat32Value(_ pointer, tagsize int) int {
- return 4 + tagsize
-}
-func sizeFloat32ValueNoZero(ptr pointer, tagsize int) int {
- v := math.Float32bits(*ptr.toFloat32())
- if v == 0 {
- return 0
- }
- return 4 + tagsize
-}
-func sizeFloat32Ptr(ptr pointer, tagsize int) int {
- p := *ptr.toFloat32Ptr()
- if p == nil {
- return 0
- }
- return 4 + tagsize
-}
-func sizeFloat32Slice(ptr pointer, tagsize int) int {
- s := *ptr.toFloat32Slice()
- return (4 + tagsize) * len(s)
-}
-func sizeFloat32PackedSlice(ptr pointer, tagsize int) int {
- s := *ptr.toFloat32Slice()
- if len(s) == 0 {
- return 0
- }
- return 4*len(s) + SizeVarint(uint64(4*len(s))) + tagsize
-}
-func sizeFixed64Value(_ pointer, tagsize int) int {
- return 8 + tagsize
-}
-func sizeFixed64ValueNoZero(ptr pointer, tagsize int) int {
- v := *ptr.toUint64()
- if v == 0 {
- return 0
- }
- return 8 + tagsize
-}
-func sizeFixed64Ptr(ptr pointer, tagsize int) int {
- p := *ptr.toUint64Ptr()
- if p == nil {
- return 0
- }
- return 8 + tagsize
-}
-func sizeFixed64Slice(ptr pointer, tagsize int) int {
- s := *ptr.toUint64Slice()
- return (8 + tagsize) * len(s)
-}
-func sizeFixed64PackedSlice(ptr pointer, tagsize int) int {
- s := *ptr.toUint64Slice()
- if len(s) == 0 {
- return 0
- }
- return 8*len(s) + SizeVarint(uint64(8*len(s))) + tagsize
-}
-func sizeFixedS64Value(_ pointer, tagsize int) int {
- return 8 + tagsize
-}
-func sizeFixedS64ValueNoZero(ptr pointer, tagsize int) int {
- v := *ptr.toInt64()
- if v == 0 {
- return 0
- }
- return 8 + tagsize
-}
-func sizeFixedS64Ptr(ptr pointer, tagsize int) int {
- p := *ptr.toInt64Ptr()
- if p == nil {
- return 0
- }
- return 8 + tagsize
-}
-func sizeFixedS64Slice(ptr pointer, tagsize int) int {
- s := *ptr.toInt64Slice()
- return (8 + tagsize) * len(s)
-}
-func sizeFixedS64PackedSlice(ptr pointer, tagsize int) int {
- s := *ptr.toInt64Slice()
- if len(s) == 0 {
- return 0
- }
- return 8*len(s) + SizeVarint(uint64(8*len(s))) + tagsize
-}
-func sizeFloat64Value(_ pointer, tagsize int) int {
- return 8 + tagsize
-}
-func sizeFloat64ValueNoZero(ptr pointer, tagsize int) int {
- v := math.Float64bits(*ptr.toFloat64())
- if v == 0 {
- return 0
- }
- return 8 + tagsize
-}
-func sizeFloat64Ptr(ptr pointer, tagsize int) int {
- p := *ptr.toFloat64Ptr()
- if p == nil {
- return 0
- }
- return 8 + tagsize
-}
-func sizeFloat64Slice(ptr pointer, tagsize int) int {
- s := *ptr.toFloat64Slice()
- return (8 + tagsize) * len(s)
-}
-func sizeFloat64PackedSlice(ptr pointer, tagsize int) int {
- s := *ptr.toFloat64Slice()
- if len(s) == 0 {
- return 0
- }
- return 8*len(s) + SizeVarint(uint64(8*len(s))) + tagsize
-}
-func sizeVarint32Value(ptr pointer, tagsize int) int {
- v := *ptr.toUint32()
- return SizeVarint(uint64(v)) + tagsize
-}
-func sizeVarint32ValueNoZero(ptr pointer, tagsize int) int {
- v := *ptr.toUint32()
- if v == 0 {
- return 0
- }
- return SizeVarint(uint64(v)) + tagsize
-}
-func sizeVarint32Ptr(ptr pointer, tagsize int) int {
- p := *ptr.toUint32Ptr()
- if p == nil {
- return 0
- }
- return SizeVarint(uint64(*p)) + tagsize
-}
-func sizeVarint32Slice(ptr pointer, tagsize int) int {
- s := *ptr.toUint32Slice()
- n := 0
- for _, v := range s {
- n += SizeVarint(uint64(v)) + tagsize
- }
- return n
-}
-func sizeVarint32PackedSlice(ptr pointer, tagsize int) int {
- s := *ptr.toUint32Slice()
- if len(s) == 0 {
- return 0
- }
- n := 0
- for _, v := range s {
- n += SizeVarint(uint64(v))
- }
- return n + SizeVarint(uint64(n)) + tagsize
-}
-func sizeVarintS32Value(ptr pointer, tagsize int) int {
- v := *ptr.toInt32()
- return SizeVarint(uint64(v)) + tagsize
-}
-func sizeVarintS32ValueNoZero(ptr pointer, tagsize int) int {
- v := *ptr.toInt32()
- if v == 0 {
- return 0
- }
- return SizeVarint(uint64(v)) + tagsize
-}
-func sizeVarintS32Ptr(ptr pointer, tagsize int) int {
- p := ptr.getInt32Ptr()
- if p == nil {
- return 0
- }
- return SizeVarint(uint64(*p)) + tagsize
-}
-func sizeVarintS32Slice(ptr pointer, tagsize int) int {
- s := ptr.getInt32Slice()
- n := 0
- for _, v := range s {
- n += SizeVarint(uint64(v)) + tagsize
- }
- return n
-}
-func sizeVarintS32PackedSlice(ptr pointer, tagsize int) int {
- s := ptr.getInt32Slice()
- if len(s) == 0 {
- return 0
- }
- n := 0
- for _, v := range s {
- n += SizeVarint(uint64(v))
- }
- return n + SizeVarint(uint64(n)) + tagsize
-}
-func sizeVarint64Value(ptr pointer, tagsize int) int {
- v := *ptr.toUint64()
- return SizeVarint(v) + tagsize
-}
-func sizeVarint64ValueNoZero(ptr pointer, tagsize int) int {
- v := *ptr.toUint64()
- if v == 0 {
- return 0
- }
- return SizeVarint(v) + tagsize
-}
-func sizeVarint64Ptr(ptr pointer, tagsize int) int {
- p := *ptr.toUint64Ptr()
- if p == nil {
- return 0
- }
- return SizeVarint(*p) + tagsize
-}
-func sizeVarint64Slice(ptr pointer, tagsize int) int {
- s := *ptr.toUint64Slice()
- n := 0
- for _, v := range s {
- n += SizeVarint(v) + tagsize
- }
- return n
-}
-func sizeVarint64PackedSlice(ptr pointer, tagsize int) int {
- s := *ptr.toUint64Slice()
- if len(s) == 0 {
- return 0
- }
- n := 0
- for _, v := range s {
- n += SizeVarint(v)
- }
- return n + SizeVarint(uint64(n)) + tagsize
-}
-func sizeVarintS64Value(ptr pointer, tagsize int) int {
- v := *ptr.toInt64()
- return SizeVarint(uint64(v)) + tagsize
-}
-func sizeVarintS64ValueNoZero(ptr pointer, tagsize int) int {
- v := *ptr.toInt64()
- if v == 0 {
- return 0
- }
- return SizeVarint(uint64(v)) + tagsize
-}
-func sizeVarintS64Ptr(ptr pointer, tagsize int) int {
- p := *ptr.toInt64Ptr()
- if p == nil {
- return 0
- }
- return SizeVarint(uint64(*p)) + tagsize
-}
-func sizeVarintS64Slice(ptr pointer, tagsize int) int {
- s := *ptr.toInt64Slice()
- n := 0
- for _, v := range s {
- n += SizeVarint(uint64(v)) + tagsize
- }
- return n
-}
-func sizeVarintS64PackedSlice(ptr pointer, tagsize int) int {
- s := *ptr.toInt64Slice()
- if len(s) == 0 {
- return 0
- }
- n := 0
- for _, v := range s {
- n += SizeVarint(uint64(v))
- }
- return n + SizeVarint(uint64(n)) + tagsize
-}
-func sizeZigzag32Value(ptr pointer, tagsize int) int {
- v := *ptr.toInt32()
- return SizeVarint(uint64((uint32(v)<<1)^uint32((int32(v)>>31)))) + tagsize
-}
-func sizeZigzag32ValueNoZero(ptr pointer, tagsize int) int {
- v := *ptr.toInt32()
- if v == 0 {
- return 0
- }
- return SizeVarint(uint64((uint32(v)<<1)^uint32((int32(v)>>31)))) + tagsize
-}
-func sizeZigzag32Ptr(ptr pointer, tagsize int) int {
- p := ptr.getInt32Ptr()
- if p == nil {
- return 0
- }
- v := *p
- return SizeVarint(uint64((uint32(v)<<1)^uint32((int32(v)>>31)))) + tagsize
-}
-func sizeZigzag32Slice(ptr pointer, tagsize int) int {
- s := ptr.getInt32Slice()
- n := 0
- for _, v := range s {
- n += SizeVarint(uint64((uint32(v)<<1)^uint32((int32(v)>>31)))) + tagsize
- }
- return n
-}
-func sizeZigzag32PackedSlice(ptr pointer, tagsize int) int {
- s := ptr.getInt32Slice()
- if len(s) == 0 {
- return 0
- }
- n := 0
- for _, v := range s {
- n += SizeVarint(uint64((uint32(v) << 1) ^ uint32((int32(v) >> 31))))
- }
- return n + SizeVarint(uint64(n)) + tagsize
-}
-func sizeZigzag64Value(ptr pointer, tagsize int) int {
- v := *ptr.toInt64()
- return SizeVarint(uint64(v<<1)^uint64((int64(v)>>63))) + tagsize
-}
-func sizeZigzag64ValueNoZero(ptr pointer, tagsize int) int {
- v := *ptr.toInt64()
- if v == 0 {
- return 0
- }
- return SizeVarint(uint64(v<<1)^uint64((int64(v)>>63))) + tagsize
-}
-func sizeZigzag64Ptr(ptr pointer, tagsize int) int {
- p := *ptr.toInt64Ptr()
- if p == nil {
- return 0
- }
- v := *p
- return SizeVarint(uint64(v<<1)^uint64((int64(v)>>63))) + tagsize
-}
-func sizeZigzag64Slice(ptr pointer, tagsize int) int {
- s := *ptr.toInt64Slice()
- n := 0
- for _, v := range s {
- n += SizeVarint(uint64(v<<1)^uint64((int64(v)>>63))) + tagsize
- }
- return n
-}
-func sizeZigzag64PackedSlice(ptr pointer, tagsize int) int {
- s := *ptr.toInt64Slice()
- if len(s) == 0 {
- return 0
- }
- n := 0
- for _, v := range s {
- n += SizeVarint(uint64(v<<1) ^ uint64((int64(v) >> 63)))
- }
- return n + SizeVarint(uint64(n)) + tagsize
-}
-func sizeBoolValue(_ pointer, tagsize int) int {
- return 1 + tagsize
-}
-func sizeBoolValueNoZero(ptr pointer, tagsize int) int {
- v := *ptr.toBool()
- if !v {
- return 0
- }
- return 1 + tagsize
-}
-func sizeBoolPtr(ptr pointer, tagsize int) int {
- p := *ptr.toBoolPtr()
- if p == nil {
- return 0
- }
- return 1 + tagsize
-}
-func sizeBoolSlice(ptr pointer, tagsize int) int {
- s := *ptr.toBoolSlice()
- return (1 + tagsize) * len(s)
-}
-func sizeBoolPackedSlice(ptr pointer, tagsize int) int {
- s := *ptr.toBoolSlice()
- if len(s) == 0 {
- return 0
- }
- return len(s) + SizeVarint(uint64(len(s))) + tagsize
-}
-func sizeStringValue(ptr pointer, tagsize int) int {
- v := *ptr.toString()
- return len(v) + SizeVarint(uint64(len(v))) + tagsize
-}
-func sizeStringValueNoZero(ptr pointer, tagsize int) int {
- v := *ptr.toString()
- if v == "" {
- return 0
- }
- return len(v) + SizeVarint(uint64(len(v))) + tagsize
-}
-func sizeStringPtr(ptr pointer, tagsize int) int {
- p := *ptr.toStringPtr()
- if p == nil {
- return 0
- }
- v := *p
- return len(v) + SizeVarint(uint64(len(v))) + tagsize
-}
-func sizeStringSlice(ptr pointer, tagsize int) int {
- s := *ptr.toStringSlice()
- n := 0
- for _, v := range s {
- n += len(v) + SizeVarint(uint64(len(v))) + tagsize
- }
- return n
-}
-func sizeBytes(ptr pointer, tagsize int) int {
- v := *ptr.toBytes()
- if v == nil {
- return 0
- }
- return len(v) + SizeVarint(uint64(len(v))) + tagsize
-}
-func sizeBytes3(ptr pointer, tagsize int) int {
- v := *ptr.toBytes()
- if len(v) == 0 {
- return 0
- }
- return len(v) + SizeVarint(uint64(len(v))) + tagsize
-}
-func sizeBytesOneof(ptr pointer, tagsize int) int {
- v := *ptr.toBytes()
- return len(v) + SizeVarint(uint64(len(v))) + tagsize
-}
-func sizeBytesSlice(ptr pointer, tagsize int) int {
- s := *ptr.toBytesSlice()
- n := 0
- for _, v := range s {
- n += len(v) + SizeVarint(uint64(len(v))) + tagsize
- }
- return n
-}
-
-// appendFixed32 appends an encoded fixed32 to b.
-func appendFixed32(b []byte, v uint32) []byte {
- b = append(b,
- byte(v),
- byte(v>>8),
- byte(v>>16),
- byte(v>>24))
- return b
-}
-
-// appendFixed64 appends an encoded fixed64 to b.
-func appendFixed64(b []byte, v uint64) []byte {
- b = append(b,
- byte(v),
- byte(v>>8),
- byte(v>>16),
- byte(v>>24),
- byte(v>>32),
- byte(v>>40),
- byte(v>>48),
- byte(v>>56))
- return b
-}
-
-// appendVarint appends an encoded varint to b.
-func appendVarint(b []byte, v uint64) []byte {
- // TODO: make 1-byte (maybe 2-byte) case inline-able, once we
- // have non-leaf inliner.
- switch {
- case v < 1<<7:
- b = append(b, byte(v))
- case v < 1<<14:
- b = append(b,
- byte(v&0x7f|0x80),
- byte(v>>7))
- case v < 1<<21:
- b = append(b,
- byte(v&0x7f|0x80),
- byte((v>>7)&0x7f|0x80),
- byte(v>>14))
- case v < 1<<28:
- b = append(b,
- byte(v&0x7f|0x80),
- byte((v>>7)&0x7f|0x80),
- byte((v>>14)&0x7f|0x80),
- byte(v>>21))
- case v < 1<<35:
- b = append(b,
- byte(v&0x7f|0x80),
- byte((v>>7)&0x7f|0x80),
- byte((v>>14)&0x7f|0x80),
- byte((v>>21)&0x7f|0x80),
- byte(v>>28))
- case v < 1<<42:
- b = append(b,
- byte(v&0x7f|0x80),
- byte((v>>7)&0x7f|0x80),
- byte((v>>14)&0x7f|0x80),
- byte((v>>21)&0x7f|0x80),
- byte((v>>28)&0x7f|0x80),
- byte(v>>35))
- case v < 1<<49:
- b = append(b,
- byte(v&0x7f|0x80),
- byte((v>>7)&0x7f|0x80),
- byte((v>>14)&0x7f|0x80),
- byte((v>>21)&0x7f|0x80),
- byte((v>>28)&0x7f|0x80),
- byte((v>>35)&0x7f|0x80),
- byte(v>>42))
- case v < 1<<56:
- b = append(b,
- byte(v&0x7f|0x80),
- byte((v>>7)&0x7f|0x80),
- byte((v>>14)&0x7f|0x80),
- byte((v>>21)&0x7f|0x80),
- byte((v>>28)&0x7f|0x80),
- byte((v>>35)&0x7f|0x80),
- byte((v>>42)&0x7f|0x80),
- byte(v>>49))
- case v < 1<<63:
- b = append(b,
- byte(v&0x7f|0x80),
- byte((v>>7)&0x7f|0x80),
- byte((v>>14)&0x7f|0x80),
- byte((v>>21)&0x7f|0x80),
- byte((v>>28)&0x7f|0x80),
- byte((v>>35)&0x7f|0x80),
- byte((v>>42)&0x7f|0x80),
- byte((v>>49)&0x7f|0x80),
- byte(v>>56))
- default:
- b = append(b,
- byte(v&0x7f|0x80),
- byte((v>>7)&0x7f|0x80),
- byte((v>>14)&0x7f|0x80),
- byte((v>>21)&0x7f|0x80),
- byte((v>>28)&0x7f|0x80),
- byte((v>>35)&0x7f|0x80),
- byte((v>>42)&0x7f|0x80),
- byte((v>>49)&0x7f|0x80),
- byte((v>>56)&0x7f|0x80),
- 1)
- }
- return b
-}
-
-func appendFixed32Value(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- v := *ptr.toUint32()
- b = appendVarint(b, wiretag)
- b = appendFixed32(b, v)
- return b, nil
-}
-func appendFixed32ValueNoZero(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- v := *ptr.toUint32()
- if v == 0 {
- return b, nil
- }
- b = appendVarint(b, wiretag)
- b = appendFixed32(b, v)
- return b, nil
-}
-func appendFixed32Ptr(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- p := *ptr.toUint32Ptr()
- if p == nil {
- return b, nil
- }
- b = appendVarint(b, wiretag)
- b = appendFixed32(b, *p)
- return b, nil
-}
-func appendFixed32Slice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- s := *ptr.toUint32Slice()
- for _, v := range s {
- b = appendVarint(b, wiretag)
- b = appendFixed32(b, v)
- }
- return b, nil
-}
-func appendFixed32PackedSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- s := *ptr.toUint32Slice()
- if len(s) == 0 {
- return b, nil
- }
- b = appendVarint(b, wiretag&^7|WireBytes)
- b = appendVarint(b, uint64(4*len(s)))
- for _, v := range s {
- b = appendFixed32(b, v)
- }
- return b, nil
-}
-func appendFixedS32Value(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- v := *ptr.toInt32()
- b = appendVarint(b, wiretag)
- b = appendFixed32(b, uint32(v))
- return b, nil
-}
-func appendFixedS32ValueNoZero(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- v := *ptr.toInt32()
- if v == 0 {
- return b, nil
- }
- b = appendVarint(b, wiretag)
- b = appendFixed32(b, uint32(v))
- return b, nil
-}
-func appendFixedS32Ptr(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- p := ptr.getInt32Ptr()
- if p == nil {
- return b, nil
- }
- b = appendVarint(b, wiretag)
- b = appendFixed32(b, uint32(*p))
- return b, nil
-}
-func appendFixedS32Slice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- s := ptr.getInt32Slice()
- for _, v := range s {
- b = appendVarint(b, wiretag)
- b = appendFixed32(b, uint32(v))
- }
- return b, nil
-}
-func appendFixedS32PackedSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- s := ptr.getInt32Slice()
- if len(s) == 0 {
- return b, nil
- }
- b = appendVarint(b, wiretag&^7|WireBytes)
- b = appendVarint(b, uint64(4*len(s)))
- for _, v := range s {
- b = appendFixed32(b, uint32(v))
- }
- return b, nil
-}
-func appendFloat32Value(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- v := math.Float32bits(*ptr.toFloat32())
- b = appendVarint(b, wiretag)
- b = appendFixed32(b, v)
- return b, nil
-}
-func appendFloat32ValueNoZero(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- v := math.Float32bits(*ptr.toFloat32())
- if v == 0 {
- return b, nil
- }
- b = appendVarint(b, wiretag)
- b = appendFixed32(b, v)
- return b, nil
-}
-func appendFloat32Ptr(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- p := *ptr.toFloat32Ptr()
- if p == nil {
- return b, nil
- }
- b = appendVarint(b, wiretag)
- b = appendFixed32(b, math.Float32bits(*p))
- return b, nil
-}
-func appendFloat32Slice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- s := *ptr.toFloat32Slice()
- for _, v := range s {
- b = appendVarint(b, wiretag)
- b = appendFixed32(b, math.Float32bits(v))
- }
- return b, nil
-}
-func appendFloat32PackedSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- s := *ptr.toFloat32Slice()
- if len(s) == 0 {
- return b, nil
- }
- b = appendVarint(b, wiretag&^7|WireBytes)
- b = appendVarint(b, uint64(4*len(s)))
- for _, v := range s {
- b = appendFixed32(b, math.Float32bits(v))
- }
- return b, nil
-}
-func appendFixed64Value(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- v := *ptr.toUint64()
- b = appendVarint(b, wiretag)
- b = appendFixed64(b, v)
- return b, nil
-}
-func appendFixed64ValueNoZero(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- v := *ptr.toUint64()
- if v == 0 {
- return b, nil
- }
- b = appendVarint(b, wiretag)
- b = appendFixed64(b, v)
- return b, nil
-}
-func appendFixed64Ptr(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- p := *ptr.toUint64Ptr()
- if p == nil {
- return b, nil
- }
- b = appendVarint(b, wiretag)
- b = appendFixed64(b, *p)
- return b, nil
-}
-func appendFixed64Slice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- s := *ptr.toUint64Slice()
- for _, v := range s {
- b = appendVarint(b, wiretag)
- b = appendFixed64(b, v)
- }
- return b, nil
-}
-func appendFixed64PackedSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- s := *ptr.toUint64Slice()
- if len(s) == 0 {
- return b, nil
- }
- b = appendVarint(b, wiretag&^7|WireBytes)
- b = appendVarint(b, uint64(8*len(s)))
- for _, v := range s {
- b = appendFixed64(b, v)
- }
- return b, nil
-}
-func appendFixedS64Value(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- v := *ptr.toInt64()
- b = appendVarint(b, wiretag)
- b = appendFixed64(b, uint64(v))
- return b, nil
-}
-func appendFixedS64ValueNoZero(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- v := *ptr.toInt64()
- if v == 0 {
- return b, nil
- }
- b = appendVarint(b, wiretag)
- b = appendFixed64(b, uint64(v))
- return b, nil
-}
-func appendFixedS64Ptr(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- p := *ptr.toInt64Ptr()
- if p == nil {
- return b, nil
- }
- b = appendVarint(b, wiretag)
- b = appendFixed64(b, uint64(*p))
- return b, nil
-}
-func appendFixedS64Slice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- s := *ptr.toInt64Slice()
- for _, v := range s {
- b = appendVarint(b, wiretag)
- b = appendFixed64(b, uint64(v))
- }
- return b, nil
-}
-func appendFixedS64PackedSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- s := *ptr.toInt64Slice()
- if len(s) == 0 {
- return b, nil
- }
- b = appendVarint(b, wiretag&^7|WireBytes)
- b = appendVarint(b, uint64(8*len(s)))
- for _, v := range s {
- b = appendFixed64(b, uint64(v))
- }
- return b, nil
-}
-func appendFloat64Value(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- v := math.Float64bits(*ptr.toFloat64())
- b = appendVarint(b, wiretag)
- b = appendFixed64(b, v)
- return b, nil
-}
-func appendFloat64ValueNoZero(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- v := math.Float64bits(*ptr.toFloat64())
- if v == 0 {
- return b, nil
- }
- b = appendVarint(b, wiretag)
- b = appendFixed64(b, v)
- return b, nil
-}
-func appendFloat64Ptr(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- p := *ptr.toFloat64Ptr()
- if p == nil {
- return b, nil
- }
- b = appendVarint(b, wiretag)
- b = appendFixed64(b, math.Float64bits(*p))
- return b, nil
-}
-func appendFloat64Slice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- s := *ptr.toFloat64Slice()
- for _, v := range s {
- b = appendVarint(b, wiretag)
- b = appendFixed64(b, math.Float64bits(v))
- }
- return b, nil
-}
-func appendFloat64PackedSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- s := *ptr.toFloat64Slice()
- if len(s) == 0 {
- return b, nil
- }
- b = appendVarint(b, wiretag&^7|WireBytes)
- b = appendVarint(b, uint64(8*len(s)))
- for _, v := range s {
- b = appendFixed64(b, math.Float64bits(v))
- }
- return b, nil
-}
-func appendVarint32Value(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- v := *ptr.toUint32()
- b = appendVarint(b, wiretag)
- b = appendVarint(b, uint64(v))
- return b, nil
-}
-func appendVarint32ValueNoZero(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- v := *ptr.toUint32()
- if v == 0 {
- return b, nil
- }
- b = appendVarint(b, wiretag)
- b = appendVarint(b, uint64(v))
- return b, nil
-}
-func appendVarint32Ptr(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- p := *ptr.toUint32Ptr()
- if p == nil {
- return b, nil
- }
- b = appendVarint(b, wiretag)
- b = appendVarint(b, uint64(*p))
- return b, nil
-}
-func appendVarint32Slice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- s := *ptr.toUint32Slice()
- for _, v := range s {
- b = appendVarint(b, wiretag)
- b = appendVarint(b, uint64(v))
- }
- return b, nil
-}
-func appendVarint32PackedSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- s := *ptr.toUint32Slice()
- if len(s) == 0 {
- return b, nil
- }
- b = appendVarint(b, wiretag&^7|WireBytes)
- // compute size
- n := 0
- for _, v := range s {
- n += SizeVarint(uint64(v))
- }
- b = appendVarint(b, uint64(n))
- for _, v := range s {
- b = appendVarint(b, uint64(v))
- }
- return b, nil
-}
-func appendVarintS32Value(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- v := *ptr.toInt32()
- b = appendVarint(b, wiretag)
- b = appendVarint(b, uint64(v))
- return b, nil
-}
-func appendVarintS32ValueNoZero(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- v := *ptr.toInt32()
- if v == 0 {
- return b, nil
- }
- b = appendVarint(b, wiretag)
- b = appendVarint(b, uint64(v))
- return b, nil
-}
-func appendVarintS32Ptr(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- p := ptr.getInt32Ptr()
- if p == nil {
- return b, nil
- }
- b = appendVarint(b, wiretag)
- b = appendVarint(b, uint64(*p))
- return b, nil
-}
-func appendVarintS32Slice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- s := ptr.getInt32Slice()
- for _, v := range s {
- b = appendVarint(b, wiretag)
- b = appendVarint(b, uint64(v))
- }
- return b, nil
-}
-func appendVarintS32PackedSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- s := ptr.getInt32Slice()
- if len(s) == 0 {
- return b, nil
- }
- b = appendVarint(b, wiretag&^7|WireBytes)
- // compute size
- n := 0
- for _, v := range s {
- n += SizeVarint(uint64(v))
- }
- b = appendVarint(b, uint64(n))
- for _, v := range s {
- b = appendVarint(b, uint64(v))
- }
- return b, nil
-}
-func appendVarint64Value(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- v := *ptr.toUint64()
- b = appendVarint(b, wiretag)
- b = appendVarint(b, v)
- return b, nil
-}
-func appendVarint64ValueNoZero(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- v := *ptr.toUint64()
- if v == 0 {
- return b, nil
- }
- b = appendVarint(b, wiretag)
- b = appendVarint(b, v)
- return b, nil
-}
-func appendVarint64Ptr(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- p := *ptr.toUint64Ptr()
- if p == nil {
- return b, nil
- }
- b = appendVarint(b, wiretag)
- b = appendVarint(b, *p)
- return b, nil
-}
-func appendVarint64Slice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- s := *ptr.toUint64Slice()
- for _, v := range s {
- b = appendVarint(b, wiretag)
- b = appendVarint(b, v)
- }
- return b, nil
-}
-func appendVarint64PackedSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- s := *ptr.toUint64Slice()
- if len(s) == 0 {
- return b, nil
- }
- b = appendVarint(b, wiretag&^7|WireBytes)
- // compute size
- n := 0
- for _, v := range s {
- n += SizeVarint(v)
- }
- b = appendVarint(b, uint64(n))
- for _, v := range s {
- b = appendVarint(b, v)
- }
- return b, nil
-}
-func appendVarintS64Value(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- v := *ptr.toInt64()
- b = appendVarint(b, wiretag)
- b = appendVarint(b, uint64(v))
- return b, nil
-}
-func appendVarintS64ValueNoZero(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- v := *ptr.toInt64()
- if v == 0 {
- return b, nil
- }
- b = appendVarint(b, wiretag)
- b = appendVarint(b, uint64(v))
- return b, nil
-}
-func appendVarintS64Ptr(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- p := *ptr.toInt64Ptr()
- if p == nil {
- return b, nil
- }
- b = appendVarint(b, wiretag)
- b = appendVarint(b, uint64(*p))
- return b, nil
-}
-func appendVarintS64Slice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- s := *ptr.toInt64Slice()
- for _, v := range s {
- b = appendVarint(b, wiretag)
- b = appendVarint(b, uint64(v))
- }
- return b, nil
-}
-func appendVarintS64PackedSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- s := *ptr.toInt64Slice()
- if len(s) == 0 {
- return b, nil
- }
- b = appendVarint(b, wiretag&^7|WireBytes)
- // compute size
- n := 0
- for _, v := range s {
- n += SizeVarint(uint64(v))
- }
- b = appendVarint(b, uint64(n))
- for _, v := range s {
- b = appendVarint(b, uint64(v))
- }
- return b, nil
-}
-func appendZigzag32Value(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- v := *ptr.toInt32()
- b = appendVarint(b, wiretag)
- b = appendVarint(b, uint64((uint32(v)<<1)^uint32((int32(v)>>31))))
- return b, nil
-}
-func appendZigzag32ValueNoZero(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- v := *ptr.toInt32()
- if v == 0 {
- return b, nil
- }
- b = appendVarint(b, wiretag)
- b = appendVarint(b, uint64((uint32(v)<<1)^uint32((int32(v)>>31))))
- return b, nil
-}
-func appendZigzag32Ptr(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- p := ptr.getInt32Ptr()
- if p == nil {
- return b, nil
- }
- b = appendVarint(b, wiretag)
- v := *p
- b = appendVarint(b, uint64((uint32(v)<<1)^uint32((int32(v)>>31))))
- return b, nil
-}
-func appendZigzag32Slice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- s := ptr.getInt32Slice()
- for _, v := range s {
- b = appendVarint(b, wiretag)
- b = appendVarint(b, uint64((uint32(v)<<1)^uint32((int32(v)>>31))))
- }
- return b, nil
-}
-func appendZigzag32PackedSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- s := ptr.getInt32Slice()
- if len(s) == 0 {
- return b, nil
- }
- b = appendVarint(b, wiretag&^7|WireBytes)
- // compute size
- n := 0
- for _, v := range s {
- n += SizeVarint(uint64((uint32(v) << 1) ^ uint32((int32(v) >> 31))))
- }
- b = appendVarint(b, uint64(n))
- for _, v := range s {
- b = appendVarint(b, uint64((uint32(v)<<1)^uint32((int32(v)>>31))))
- }
- return b, nil
-}
-func appendZigzag64Value(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- v := *ptr.toInt64()
- b = appendVarint(b, wiretag)
- b = appendVarint(b, uint64(v<<1)^uint64((int64(v)>>63)))
- return b, nil
-}
-func appendZigzag64ValueNoZero(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- v := *ptr.toInt64()
- if v == 0 {
- return b, nil
- }
- b = appendVarint(b, wiretag)
- b = appendVarint(b, uint64(v<<1)^uint64((int64(v)>>63)))
- return b, nil
-}
-func appendZigzag64Ptr(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- p := *ptr.toInt64Ptr()
- if p == nil {
- return b, nil
- }
- b = appendVarint(b, wiretag)
- v := *p
- b = appendVarint(b, uint64(v<<1)^uint64((int64(v)>>63)))
- return b, nil
-}
-func appendZigzag64Slice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- s := *ptr.toInt64Slice()
- for _, v := range s {
- b = appendVarint(b, wiretag)
- b = appendVarint(b, uint64(v<<1)^uint64((int64(v)>>63)))
- }
- return b, nil
-}
-func appendZigzag64PackedSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- s := *ptr.toInt64Slice()
- if len(s) == 0 {
- return b, nil
- }
- b = appendVarint(b, wiretag&^7|WireBytes)
- // compute size
- n := 0
- for _, v := range s {
- n += SizeVarint(uint64(v<<1) ^ uint64((int64(v) >> 63)))
- }
- b = appendVarint(b, uint64(n))
- for _, v := range s {
- b = appendVarint(b, uint64(v<<1)^uint64((int64(v)>>63)))
- }
- return b, nil
-}
-func appendBoolValue(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- v := *ptr.toBool()
- b = appendVarint(b, wiretag)
- if v {
- b = append(b, 1)
- } else {
- b = append(b, 0)
- }
- return b, nil
-}
-func appendBoolValueNoZero(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- v := *ptr.toBool()
- if !v {
- return b, nil
- }
- b = appendVarint(b, wiretag)
- b = append(b, 1)
- return b, nil
-}
-
-func appendBoolPtr(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- p := *ptr.toBoolPtr()
- if p == nil {
- return b, nil
- }
- b = appendVarint(b, wiretag)
- if *p {
- b = append(b, 1)
- } else {
- b = append(b, 0)
- }
- return b, nil
-}
-func appendBoolSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- s := *ptr.toBoolSlice()
- for _, v := range s {
- b = appendVarint(b, wiretag)
- if v {
- b = append(b, 1)
- } else {
- b = append(b, 0)
- }
- }
- return b, nil
-}
-func appendBoolPackedSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- s := *ptr.toBoolSlice()
- if len(s) == 0 {
- return b, nil
- }
- b = appendVarint(b, wiretag&^7|WireBytes)
- b = appendVarint(b, uint64(len(s)))
- for _, v := range s {
- if v {
- b = append(b, 1)
- } else {
- b = append(b, 0)
- }
- }
- return b, nil
-}
-func appendStringValue(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- v := *ptr.toString()
- if !utf8.ValidString(v) {
- return nil, errInvalidUTF8
- }
- b = appendVarint(b, wiretag)
- b = appendVarint(b, uint64(len(v)))
- b = append(b, v...)
- return b, nil
-}
-func appendStringValueNoZero(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- v := *ptr.toString()
- if v == "" {
- return b, nil
- }
- if !utf8.ValidString(v) {
- return nil, errInvalidUTF8
- }
- b = appendVarint(b, wiretag)
- b = appendVarint(b, uint64(len(v)))
- b = append(b, v...)
- return b, nil
-}
-func appendStringPtr(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- p := *ptr.toStringPtr()
- if p == nil {
- return b, nil
- }
- v := *p
- if !utf8.ValidString(v) {
- return nil, errInvalidUTF8
- }
- b = appendVarint(b, wiretag)
- b = appendVarint(b, uint64(len(v)))
- b = append(b, v...)
- return b, nil
-}
-func appendStringSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- s := *ptr.toStringSlice()
- for _, v := range s {
- if !utf8.ValidString(v) {
- return nil, errInvalidUTF8
- }
- b = appendVarint(b, wiretag)
- b = appendVarint(b, uint64(len(v)))
- b = append(b, v...)
- }
- return b, nil
-}
-func appendBytes(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- v := *ptr.toBytes()
- if v == nil {
- return b, nil
- }
- b = appendVarint(b, wiretag)
- b = appendVarint(b, uint64(len(v)))
- b = append(b, v...)
- return b, nil
-}
-func appendBytes3(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- v := *ptr.toBytes()
- if len(v) == 0 {
- return b, nil
- }
- b = appendVarint(b, wiretag)
- b = appendVarint(b, uint64(len(v)))
- b = append(b, v...)
- return b, nil
-}
-func appendBytesOneof(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- v := *ptr.toBytes()
- b = appendVarint(b, wiretag)
- b = appendVarint(b, uint64(len(v)))
- b = append(b, v...)
- return b, nil
-}
-func appendBytesSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
- s := *ptr.toBytesSlice()
- for _, v := range s {
- b = appendVarint(b, wiretag)
- b = appendVarint(b, uint64(len(v)))
- b = append(b, v...)
- }
- return b, nil
-}
-
-// makeGroupMarshaler returns the sizer and marshaler for a group.
-// u is the marshal info of the underlying message.
-func makeGroupMarshaler(u *marshalInfo) (sizer, marshaler) {
- return func(ptr pointer, tagsize int) int {
- p := ptr.getPointer()
- if p.isNil() {
- return 0
- }
- return u.size(p) + 2*tagsize
- },
- func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) {
- p := ptr.getPointer()
- if p.isNil() {
- return b, nil
- }
- var err error
- b = appendVarint(b, wiretag) // start group
- b, err = u.marshal(b, p, deterministic)
- b = appendVarint(b, wiretag+(WireEndGroup-WireStartGroup)) // end group
- return b, err
- }
-}
-
-// makeGroupSliceMarshaler returns the sizer and marshaler for a group slice.
-// u is the marshal info of the underlying message.
-func makeGroupSliceMarshaler(u *marshalInfo) (sizer, marshaler) {
- return func(ptr pointer, tagsize int) int {
- s := ptr.getPointerSlice()
- n := 0
- for _, v := range s {
- if v.isNil() {
- continue
- }
- n += u.size(v) + 2*tagsize
- }
- return n
- },
- func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) {
- s := ptr.getPointerSlice()
- var err, errreq error
- for _, v := range s {
- if v.isNil() {
- return b, errRepeatedHasNil
- }
- b = appendVarint(b, wiretag) // start group
- b, err = u.marshal(b, v, deterministic)
- b = appendVarint(b, wiretag+(WireEndGroup-WireStartGroup)) // end group
- if err != nil {
- if _, ok := err.(*RequiredNotSetError); ok {
- // Required field in submessage is not set.
- // We record the error but keep going, to give a complete marshaling.
- if errreq == nil {
- errreq = err
- }
- continue
- }
- if err == ErrNil {
- err = errRepeatedHasNil
- }
- return b, err
- }
- }
- return b, errreq
- }
-}
-
-// makeMessageMarshaler returns the sizer and marshaler for a message field.
-// u is the marshal info of the message.
-func makeMessageMarshaler(u *marshalInfo) (sizer, marshaler) {
- return func(ptr pointer, tagsize int) int {
- p := ptr.getPointer()
- if p.isNil() {
- return 0
- }
- siz := u.size(p)
- return siz + SizeVarint(uint64(siz)) + tagsize
- },
- func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) {
- p := ptr.getPointer()
- if p.isNil() {
- return b, nil
- }
- b = appendVarint(b, wiretag)
- siz := u.cachedsize(p)
- b = appendVarint(b, uint64(siz))
- return u.marshal(b, p, deterministic)
- }
-}
-
-// makeMessageSliceMarshaler returns the sizer and marshaler for a message slice.
-// u is the marshal info of the message.
-func makeMessageSliceMarshaler(u *marshalInfo) (sizer, marshaler) {
- return func(ptr pointer, tagsize int) int {
- s := ptr.getPointerSlice()
- n := 0
- for _, v := range s {
- if v.isNil() {
- continue
- }
- siz := u.size(v)
- n += siz + SizeVarint(uint64(siz)) + tagsize
- }
- return n
- },
- func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) {
- s := ptr.getPointerSlice()
- var err, errreq error
- for _, v := range s {
- if v.isNil() {
- return b, errRepeatedHasNil
- }
- b = appendVarint(b, wiretag)
- siz := u.cachedsize(v)
- b = appendVarint(b, uint64(siz))
- b, err = u.marshal(b, v, deterministic)
- if err != nil {
- if _, ok := err.(*RequiredNotSetError); ok {
- // Required field in submessage is not set.
- // We record the error but keep going, to give a complete marshaling.
- if errreq == nil {
- errreq = err
- }
- continue
- }
- if err == ErrNil {
- err = errRepeatedHasNil
- }
- return b, err
- }
- }
- return b, errreq
- }
-}
-
-// makeMapMarshaler returns the sizer and marshaler for a map field.
-// f is the pointer to the reflect data structure of the field.
-func makeMapMarshaler(f *reflect.StructField) (sizer, marshaler) {
- // figure out key and value type
- t := f.Type
- keyType := t.Key()
- valType := t.Elem()
- tags := strings.Split(f.Tag.Get("protobuf"), ",")
- keyTags := strings.Split(f.Tag.Get("protobuf_key"), ",")
- valTags := strings.Split(f.Tag.Get("protobuf_val"), ",")
- for _, t := range tags {
- if strings.HasPrefix(t, "customtype=") {
- valTags = append(valTags, t)
- }
- if t == "stdtime" {
- valTags = append(valTags, t)
- }
- if t == "stdduration" {
- valTags = append(valTags, t)
- }
- }
- keySizer, keyMarshaler := typeMarshaler(keyType, keyTags, false, false) // don't omit zero value in map
- valSizer, valMarshaler := typeMarshaler(valType, valTags, false, false) // don't omit zero value in map
- keyWireTag := 1<<3 | wiretype(keyTags[0])
- valWireTag := 2<<3 | wiretype(valTags[0])
-
- // We create an interface to get the addresses of the map key and value.
- // If value is pointer-typed, the interface is a direct interface, the
- // idata itself is the value. Otherwise, the idata is the pointer to the
- // value.
- // Key cannot be pointer-typed.
- valIsPtr := valType.Kind() == reflect.Ptr
- return func(ptr pointer, tagsize int) int {
- m := ptr.asPointerTo(t).Elem() // the map
- n := 0
- for _, k := range m.MapKeys() {
- ki := k.Interface()
- vi := m.MapIndex(k).Interface()
- kaddr := toAddrPointer(&ki, false) // pointer to key
- vaddr := toAddrPointer(&vi, valIsPtr) // pointer to value
- siz := keySizer(kaddr, 1) + valSizer(vaddr, 1) // tag of key = 1 (size=1), tag of val = 2 (size=1)
- n += siz + SizeVarint(uint64(siz)) + tagsize
- }
- return n
- },
- func(b []byte, ptr pointer, tag uint64, deterministic bool) ([]byte, error) {
- m := ptr.asPointerTo(t).Elem() // the map
- var err error
- keys := m.MapKeys()
- if len(keys) > 1 && deterministic {
- sort.Sort(mapKeys(keys))
- }
- for _, k := range keys {
- ki := k.Interface()
- vi := m.MapIndex(k).Interface()
- kaddr := toAddrPointer(&ki, false) // pointer to key
- vaddr := toAddrPointer(&vi, valIsPtr) // pointer to value
- b = appendVarint(b, tag)
- siz := keySizer(kaddr, 1) + valSizer(vaddr, 1) // tag of key = 1 (size=1), tag of val = 2 (size=1)
- b = appendVarint(b, uint64(siz))
- b, err = keyMarshaler(b, kaddr, keyWireTag, deterministic)
- if err != nil {
- return b, err
- }
- b, err = valMarshaler(b, vaddr, valWireTag, deterministic)
- if err != nil && err != ErrNil { // allow nil value in map
- return b, err
- }
- }
- return b, nil
- }
-}
-
-// makeOneOfMarshaler returns the sizer and marshaler for a oneof field.
-// fi is the marshal info of the field.
-// f is the pointer to the reflect data structure of the field.
-func makeOneOfMarshaler(fi *marshalFieldInfo, f *reflect.StructField) (sizer, marshaler) {
- // Oneof field is an interface. We need to get the actual data type on the fly.
- t := f.Type
- return func(ptr pointer, _ int) int {
- p := ptr.getInterfacePointer()
- if p.isNil() {
- return 0
- }
- v := ptr.asPointerTo(t).Elem().Elem().Elem() // *interface -> interface -> *struct -> struct
- telem := v.Type()
- e := fi.oneofElems[telem]
- return e.sizer(p, e.tagsize)
- },
- func(b []byte, ptr pointer, _ uint64, deterministic bool) ([]byte, error) {
- p := ptr.getInterfacePointer()
- if p.isNil() {
- return b, nil
- }
- v := ptr.asPointerTo(t).Elem().Elem().Elem() // *interface -> interface -> *struct -> struct
- telem := v.Type()
- if telem.Field(0).Type.Kind() == reflect.Ptr && p.getPointer().isNil() {
- return b, errOneofHasNil
- }
- e := fi.oneofElems[telem]
- return e.marshaler(b, p, e.wiretag, deterministic)
- }
-}
-
-// sizeExtensions computes the size of encoded data for a XXX_InternalExtensions field.
-func (u *marshalInfo) sizeExtensions(ext *XXX_InternalExtensions) int {
- m, mu := ext.extensionsRead()
- if m == nil {
- return 0
- }
- mu.Lock()
-
- n := 0
- for _, e := range m {
- if e.value == nil || e.desc == nil {
- // Extension is only in its encoded form.
- n += len(e.enc)
- continue
- }
-
- // We don't skip extensions that have an encoded form set,
- // because the extension value may have been mutated after
- // the last time this function was called.
- ei := u.getExtElemInfo(e.desc)
- v := e.value
- p := toAddrPointer(&v, ei.isptr)
- n += ei.sizer(p, ei.tagsize)
- }
- mu.Unlock()
- return n
-}
-
-// appendExtensions marshals a XXX_InternalExtensions field to the end of byte slice b.
-func (u *marshalInfo) appendExtensions(b []byte, ext *XXX_InternalExtensions, deterministic bool) ([]byte, error) {
- m, mu := ext.extensionsRead()
- if m == nil {
- return b, nil
- }
- mu.Lock()
- defer mu.Unlock()
-
- var err error
-
- // Fast-path for common cases: zero or one extensions.
- // Don't bother sorting the keys.
- if len(m) <= 1 {
- for _, e := range m {
- if e.value == nil || e.desc == nil {
- // Extension is only in its encoded form.
- b = append(b, e.enc...)
- continue
- }
-
- // We don't skip extensions that have an encoded form set,
- // because the extension value may have been mutated after
- // the last time this function was called.
-
- ei := u.getExtElemInfo(e.desc)
- v := e.value
- p := toAddrPointer(&v, ei.isptr)
- b, err = ei.marshaler(b, p, ei.wiretag, deterministic)
- if err != nil {
- return b, err
- }
- }
- return b, nil
- }
-
- // Sort the keys to provide a deterministic encoding.
- // Not sure this is required, but the old code does it.
- keys := make([]int, 0, len(m))
- for k := range m {
- keys = append(keys, int(k))
- }
- sort.Ints(keys)
-
- for _, k := range keys {
- e := m[int32(k)]
- if e.value == nil || e.desc == nil {
- // Extension is only in its encoded form.
- b = append(b, e.enc...)
- continue
- }
-
- // We don't skip extensions that have an encoded form set,
- // because the extension value may have been mutated after
- // the last time this function was called.
-
- ei := u.getExtElemInfo(e.desc)
- v := e.value
- p := toAddrPointer(&v, ei.isptr)
- b, err = ei.marshaler(b, p, ei.wiretag, deterministic)
- if err != nil {
- return b, err
- }
- }
- return b, nil
-}
-
-// message set format is:
-// message MessageSet {
-// repeated group Item = 1 {
-// required int32 type_id = 2;
-// required string message = 3;
-// };
-// }
-
-// sizeMessageSet computes the size of encoded data for a XXX_InternalExtensions field
-// in message set format (above).
-func (u *marshalInfo) sizeMessageSet(ext *XXX_InternalExtensions) int {
- m, mu := ext.extensionsRead()
- if m == nil {
- return 0
- }
- mu.Lock()
-
- n := 0
- for id, e := range m {
- n += 2 // start group, end group. tag = 1 (size=1)
- n += SizeVarint(uint64(id)) + 1 // type_id, tag = 2 (size=1)
-
- if e.value == nil || e.desc == nil {
- // Extension is only in its encoded form.
- msgWithLen := skipVarint(e.enc) // skip old tag, but leave the length varint
- siz := len(msgWithLen)
- n += siz + 1 // message, tag = 3 (size=1)
- continue
- }
-
- // We don't skip extensions that have an encoded form set,
- // because the extension value may have been mutated after
- // the last time this function was called.
-
- ei := u.getExtElemInfo(e.desc)
- v := e.value
- p := toAddrPointer(&v, ei.isptr)
- n += ei.sizer(p, 1) // message, tag = 3 (size=1)
- }
- mu.Unlock()
- return n
-}
-
-// appendMessageSet marshals a XXX_InternalExtensions field in message set format (above)
-// to the end of byte slice b.
-func (u *marshalInfo) appendMessageSet(b []byte, ext *XXX_InternalExtensions, deterministic bool) ([]byte, error) {
- m, mu := ext.extensionsRead()
- if m == nil {
- return b, nil
- }
- mu.Lock()
- defer mu.Unlock()
-
- var err error
-
- // Fast-path for common cases: zero or one extensions.
- // Don't bother sorting the keys.
- if len(m) <= 1 {
- for id, e := range m {
- b = append(b, 1<<3|WireStartGroup)
- b = append(b, 2<<3|WireVarint)
- b = appendVarint(b, uint64(id))
-
- if e.value == nil || e.desc == nil {
- // Extension is only in its encoded form.
- msgWithLen := skipVarint(e.enc) // skip old tag, but leave the length varint
- b = append(b, 3<<3|WireBytes)
- b = append(b, msgWithLen...)
- b = append(b, 1<<3|WireEndGroup)
- continue
- }
-
- // We don't skip extensions that have an encoded form set,
- // because the extension value may have been mutated after
- // the last time this function was called.
-
- ei := u.getExtElemInfo(e.desc)
- v := e.value
- p := toAddrPointer(&v, ei.isptr)
- b, err = ei.marshaler(b, p, 3<<3|WireBytes, deterministic)
- if err != nil {
- return b, err
- }
- b = append(b, 1<<3|WireEndGroup)
- }
- return b, nil
- }
-
- // Sort the keys to provide a deterministic encoding.
- keys := make([]int, 0, len(m))
- for k := range m {
- keys = append(keys, int(k))
- }
- sort.Ints(keys)
-
- for _, id := range keys {
- e := m[int32(id)]
- b = append(b, 1<<3|WireStartGroup)
- b = append(b, 2<<3|WireVarint)
- b = appendVarint(b, uint64(id))
-
- if e.value == nil || e.desc == nil {
- // Extension is only in its encoded form.
- msgWithLen := skipVarint(e.enc) // skip old tag, but leave the length varint
- b = append(b, 3<<3|WireBytes)
- b = append(b, msgWithLen...)
- b = append(b, 1<<3|WireEndGroup)
- continue
- }
-
- // We don't skip extensions that have an encoded form set,
- // because the extension value may have been mutated after
- // the last time this function was called.
-
- ei := u.getExtElemInfo(e.desc)
- v := e.value
- p := toAddrPointer(&v, ei.isptr)
- b, err = ei.marshaler(b, p, 3<<3|WireBytes, deterministic)
- b = append(b, 1<<3|WireEndGroup)
- if err != nil {
- return b, err
- }
- }
- return b, nil
-}
-
-// sizeV1Extensions computes the size of encoded data for a V1-API extension field.
-func (u *marshalInfo) sizeV1Extensions(m map[int32]Extension) int {
- if m == nil {
- return 0
- }
-
- n := 0
- for _, e := range m {
- if e.value == nil || e.desc == nil {
- // Extension is only in its encoded form.
- n += len(e.enc)
- continue
- }
-
- // We don't skip extensions that have an encoded form set,
- // because the extension value may have been mutated after
- // the last time this function was called.
-
- ei := u.getExtElemInfo(e.desc)
- v := e.value
- p := toAddrPointer(&v, ei.isptr)
- n += ei.sizer(p, ei.tagsize)
- }
- return n
-}
-
-// appendV1Extensions marshals a V1-API extension field to the end of byte slice b.
-func (u *marshalInfo) appendV1Extensions(b []byte, m map[int32]Extension, deterministic bool) ([]byte, error) {
- if m == nil {
- return b, nil
- }
-
- // Sort the keys to provide a deterministic encoding.
- keys := make([]int, 0, len(m))
- for k := range m {
- keys = append(keys, int(k))
- }
- sort.Ints(keys)
-
- var err error
- for _, k := range keys {
- e := m[int32(k)]
- if e.value == nil || e.desc == nil {
- // Extension is only in its encoded form.
- b = append(b, e.enc...)
- continue
- }
-
- // We don't skip extensions that have an encoded form set,
- // because the extension value may have been mutated after
- // the last time this function was called.
-
- ei := u.getExtElemInfo(e.desc)
- v := e.value
- p := toAddrPointer(&v, ei.isptr)
- b, err = ei.marshaler(b, p, ei.wiretag, deterministic)
- if err != nil {
- return b, err
- }
- }
- return b, nil
-}
-
-// newMarshaler is the interface representing objects that can marshal themselves.
-//
-// This exists to support protoc-gen-go generated messages.
-// The proto package will stop type-asserting to this interface in the future.
-//
-// DO NOT DEPEND ON THIS.
-type newMarshaler interface {
- XXX_Size() int
- XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
-}
-
-// Size returns the encoded size of a protocol buffer message.
-// This is the main entry point.
-func Size(pb Message) int {
- if m, ok := pb.(newMarshaler); ok {
- return m.XXX_Size()
- }
- if m, ok := pb.(Marshaler); ok {
- // If the message can marshal itself, let it do it, for compatibility.
- // NOTE: This is not efficient.
- b, _ := m.Marshal()
- return len(b)
- }
- // in case somehow we didn't generate the wrapper
- if pb == nil {
- return 0
- }
- var info InternalMessageInfo
- return info.Size(pb)
-}
-
-// Marshal takes a protocol buffer message
-// and encodes it into the wire format, returning the data.
-// This is the main entry point.
-func Marshal(pb Message) ([]byte, error) {
- if m, ok := pb.(newMarshaler); ok {
- siz := m.XXX_Size()
- b := make([]byte, 0, siz)
- return m.XXX_Marshal(b, false)
- }
- if m, ok := pb.(Marshaler); ok {
- // If the message can marshal itself, let it do it, for compatibility.
- // NOTE: This is not efficient.
- return m.Marshal()
- }
- // in case somehow we didn't generate the wrapper
- if pb == nil {
- return nil, ErrNil
- }
- var info InternalMessageInfo
- siz := info.Size(pb)
- b := make([]byte, 0, siz)
- return info.Marshal(b, pb, false)
-}
-
-// Marshal takes a protocol buffer message
-// and encodes it into the wire format, writing the result to the
-// Buffer.
-// This is an alternative entry point. It is not necessary to use
-// a Buffer for most applications.
-func (p *Buffer) Marshal(pb Message) error {
- var err error
- if m, ok := pb.(newMarshaler); ok {
- siz := m.XXX_Size()
- p.grow(siz) // make sure buf has enough capacity
- p.buf, err = m.XXX_Marshal(p.buf, p.deterministic)
- return err
- }
- if m, ok := pb.(Marshaler); ok {
- // If the message can marshal itself, let it do it, for compatibility.
- // NOTE: This is not efficient.
- var b []byte
- b, err = m.Marshal()
- p.buf = append(p.buf, b...)
- return err
- }
- // in case somehow we didn't generate the wrapper
- if pb == nil {
- return ErrNil
- }
- var info InternalMessageInfo
- siz := info.Size(pb)
- p.grow(siz) // make sure buf has enough capacity
- p.buf, err = info.Marshal(p.buf, pb, p.deterministic)
- return err
-}
-
-// grow grows the buffer's capacity, if necessary, to guarantee space for
-// another n bytes. After grow(n), at least n bytes can be written to the
-// buffer without another allocation.
-func (p *Buffer) grow(n int) {
- need := len(p.buf) + n
- if need <= cap(p.buf) {
- return
- }
- newCap := len(p.buf) * 2
- if newCap < need {
- newCap = need
- }
- p.buf = append(make([]byte, 0, newCap), p.buf...)
-}
diff --git a/vendor/github.com/gogo/protobuf/proto/table_marshal_gogo.go b/vendor/github.com/gogo/protobuf/proto/table_marshal_gogo.go
deleted file mode 100644
index 997f57c1e1..0000000000
--- a/vendor/github.com/gogo/protobuf/proto/table_marshal_gogo.go
+++ /dev/null
@@ -1,388 +0,0 @@
-// Protocol Buffers for Go with Gadgets
-//
-// Copyright (c) 2018, The GoGo Authors. All rights reserved.
-// http://github.com/gogo/protobuf
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-package proto
-
-import (
- "reflect"
- "time"
-)
-
-// makeMessageRefMarshaler differs a bit from makeMessageMarshaler
-// It marshal a message T instead of a *T
-func makeMessageRefMarshaler(u *marshalInfo) (sizer, marshaler) {
- return func(ptr pointer, tagsize int) int {
- siz := u.size(ptr)
- return siz + SizeVarint(uint64(siz)) + tagsize
- },
- func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) {
- b = appendVarint(b, wiretag)
- siz := u.cachedsize(ptr)
- b = appendVarint(b, uint64(siz))
- return u.marshal(b, ptr, deterministic)
- }
-}
-
-// makeMessageRefSliceMarshaler differs quite a lot from makeMessageSliceMarshaler
-// It marshals a slice of messages []T instead of []*T
-func makeMessageRefSliceMarshaler(u *marshalInfo) (sizer, marshaler) {
- return func(ptr pointer, tagsize int) int {
- s := ptr.getSlice(u.typ)
- n := 0
- for i := 0; i < s.Len(); i++ {
- elem := s.Index(i)
- e := elem.Interface()
- v := toAddrPointer(&e, false)
- siz := u.size(v)
- n += siz + SizeVarint(uint64(siz)) + tagsize
- }
- return n
- },
- func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) {
- s := ptr.getSlice(u.typ)
- var err, errreq error
- for i := 0; i < s.Len(); i++ {
- elem := s.Index(i)
- e := elem.Interface()
- v := toAddrPointer(&e, false)
- b = appendVarint(b, wiretag)
- siz := u.size(v)
- b = appendVarint(b, uint64(siz))
- b, err = u.marshal(b, v, deterministic)
-
- if err != nil {
- if _, ok := err.(*RequiredNotSetError); ok {
- // Required field in submessage is not set.
- // We record the error but keep going, to give a complete marshaling.
- if errreq == nil {
- errreq = err
- }
- continue
- }
- if err == ErrNil {
- err = errRepeatedHasNil
- }
- return b, err
- }
- }
-
- return b, errreq
- }
-}
-
-func makeCustomPtrMarshaler(u *marshalInfo) (sizer, marshaler) {
- return func(ptr pointer, tagsize int) int {
- if ptr.isNil() {
- return 0
- }
- m := ptr.asPointerTo(reflect.PtrTo(u.typ)).Elem().Interface().(custom)
- siz := m.Size()
- return tagsize + SizeVarint(uint64(siz)) + siz
- }, func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) {
- if ptr.isNil() {
- return b, nil
- }
- m := ptr.asPointerTo(reflect.PtrTo(u.typ)).Elem().Interface().(custom)
- siz := m.Size()
- buf, err := m.Marshal()
- if err != nil {
- return nil, err
- }
- b = appendVarint(b, wiretag)
- b = appendVarint(b, uint64(siz))
- b = append(b, buf...)
- return b, nil
- }
-}
-
-func makeCustomMarshaler(u *marshalInfo) (sizer, marshaler) {
- return func(ptr pointer, tagsize int) int {
- m := ptr.asPointerTo(u.typ).Interface().(custom)
- siz := m.Size()
- return tagsize + SizeVarint(uint64(siz)) + siz
- }, func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) {
- m := ptr.asPointerTo(u.typ).Interface().(custom)
- siz := m.Size()
- buf, err := m.Marshal()
- if err != nil {
- return nil, err
- }
- b = appendVarint(b, wiretag)
- b = appendVarint(b, uint64(siz))
- b = append(b, buf...)
- return b, nil
- }
-}
-
-func makeTimeMarshaler(u *marshalInfo) (sizer, marshaler) {
- return func(ptr pointer, tagsize int) int {
- t := ptr.asPointerTo(u.typ).Interface().(*time.Time)
- ts, err := timestampProto(*t)
- if err != nil {
- return 0
- }
- siz := Size(ts)
- return tagsize + SizeVarint(uint64(siz)) + siz
- }, func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) {
- t := ptr.asPointerTo(u.typ).Interface().(*time.Time)
- ts, err := timestampProto(*t)
- if err != nil {
- return nil, err
- }
- buf, err := Marshal(ts)
- if err != nil {
- return nil, err
- }
- b = appendVarint(b, wiretag)
- b = appendVarint(b, uint64(len(buf)))
- b = append(b, buf...)
- return b, nil
- }
-}
-
-func makeTimePtrMarshaler(u *marshalInfo) (sizer, marshaler) {
- return func(ptr pointer, tagsize int) int {
- if ptr.isNil() {
- return 0
- }
- t := ptr.asPointerTo(reflect.PtrTo(u.typ)).Elem().Interface().(*time.Time)
- ts, err := timestampProto(*t)
- if err != nil {
- return 0
- }
- siz := Size(ts)
- return tagsize + SizeVarint(uint64(siz)) + siz
- }, func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) {
- if ptr.isNil() {
- return b, nil
- }
- t := ptr.asPointerTo(reflect.PtrTo(u.typ)).Elem().Interface().(*time.Time)
- ts, err := timestampProto(*t)
- if err != nil {
- return nil, err
- }
- buf, err := Marshal(ts)
- if err != nil {
- return nil, err
- }
- b = appendVarint(b, wiretag)
- b = appendVarint(b, uint64(len(buf)))
- b = append(b, buf...)
- return b, nil
- }
-}
-
-func makeTimeSliceMarshaler(u *marshalInfo) (sizer, marshaler) {
- return func(ptr pointer, tagsize int) int {
- s := ptr.getSlice(u.typ)
- n := 0
- for i := 0; i < s.Len(); i++ {
- elem := s.Index(i)
- t := elem.Interface().(time.Time)
- ts, err := timestampProto(t)
- if err != nil {
- return 0
- }
- siz := Size(ts)
- n += siz + SizeVarint(uint64(siz)) + tagsize
- }
- return n
- },
- func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) {
- s := ptr.getSlice(u.typ)
- for i := 0; i < s.Len(); i++ {
- elem := s.Index(i)
- t := elem.Interface().(time.Time)
- ts, err := timestampProto(t)
- if err != nil {
- return nil, err
- }
- siz := Size(ts)
- buf, err := Marshal(ts)
- if err != nil {
- return nil, err
- }
- b = appendVarint(b, wiretag)
- b = appendVarint(b, uint64(siz))
- b = append(b, buf...)
- }
-
- return b, nil
- }
-}
-
-func makeTimePtrSliceMarshaler(u *marshalInfo) (sizer, marshaler) {
- return func(ptr pointer, tagsize int) int {
- s := ptr.getSlice(reflect.PtrTo(u.typ))
- n := 0
- for i := 0; i < s.Len(); i++ {
- elem := s.Index(i)
- t := elem.Interface().(*time.Time)
- ts, err := timestampProto(*t)
- if err != nil {
- return 0
- }
- siz := Size(ts)
- n += siz + SizeVarint(uint64(siz)) + tagsize
- }
- return n
- },
- func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) {
- s := ptr.getSlice(reflect.PtrTo(u.typ))
- for i := 0; i < s.Len(); i++ {
- elem := s.Index(i)
- t := elem.Interface().(*time.Time)
- ts, err := timestampProto(*t)
- if err != nil {
- return nil, err
- }
- siz := Size(ts)
- buf, err := Marshal(ts)
- if err != nil {
- return nil, err
- }
- b = appendVarint(b, wiretag)
- b = appendVarint(b, uint64(siz))
- b = append(b, buf...)
- }
-
- return b, nil
- }
-}
-
-func makeDurationMarshaler(u *marshalInfo) (sizer, marshaler) {
- return func(ptr pointer, tagsize int) int {
- d := ptr.asPointerTo(u.typ).Interface().(*time.Duration)
- dur := durationProto(*d)
- siz := Size(dur)
- return tagsize + SizeVarint(uint64(siz)) + siz
- }, func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) {
- d := ptr.asPointerTo(u.typ).Interface().(*time.Duration)
- dur := durationProto(*d)
- buf, err := Marshal(dur)
- if err != nil {
- return nil, err
- }
- b = appendVarint(b, wiretag)
- b = appendVarint(b, uint64(len(buf)))
- b = append(b, buf...)
- return b, nil
- }
-}
-
-func makeDurationPtrMarshaler(u *marshalInfo) (sizer, marshaler) {
- return func(ptr pointer, tagsize int) int {
- if ptr.isNil() {
- return 0
- }
- d := ptr.asPointerTo(reflect.PtrTo(u.typ)).Elem().Interface().(*time.Duration)
- dur := durationProto(*d)
- siz := Size(dur)
- return tagsize + SizeVarint(uint64(siz)) + siz
- }, func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) {
- if ptr.isNil() {
- return b, nil
- }
- d := ptr.asPointerTo(reflect.PtrTo(u.typ)).Elem().Interface().(*time.Duration)
- dur := durationProto(*d)
- buf, err := Marshal(dur)
- if err != nil {
- return nil, err
- }
- b = appendVarint(b, wiretag)
- b = appendVarint(b, uint64(len(buf)))
- b = append(b, buf...)
- return b, nil
- }
-}
-
-func makeDurationSliceMarshaler(u *marshalInfo) (sizer, marshaler) {
- return func(ptr pointer, tagsize int) int {
- s := ptr.getSlice(u.typ)
- n := 0
- for i := 0; i < s.Len(); i++ {
- elem := s.Index(i)
- d := elem.Interface().(time.Duration)
- dur := durationProto(d)
- siz := Size(dur)
- n += siz + SizeVarint(uint64(siz)) + tagsize
- }
- return n
- },
- func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) {
- s := ptr.getSlice(u.typ)
- for i := 0; i < s.Len(); i++ {
- elem := s.Index(i)
- d := elem.Interface().(time.Duration)
- dur := durationProto(d)
- siz := Size(dur)
- buf, err := Marshal(dur)
- if err != nil {
- return nil, err
- }
- b = appendVarint(b, wiretag)
- b = appendVarint(b, uint64(siz))
- b = append(b, buf...)
- }
-
- return b, nil
- }
-}
-
-func makeDurationPtrSliceMarshaler(u *marshalInfo) (sizer, marshaler) {
- return func(ptr pointer, tagsize int) int {
- s := ptr.getSlice(reflect.PtrTo(u.typ))
- n := 0
- for i := 0; i < s.Len(); i++ {
- elem := s.Index(i)
- d := elem.Interface().(*time.Duration)
- dur := durationProto(*d)
- siz := Size(dur)
- n += siz + SizeVarint(uint64(siz)) + tagsize
- }
- return n
- },
- func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) {
- s := ptr.getSlice(reflect.PtrTo(u.typ))
- for i := 0; i < s.Len(); i++ {
- elem := s.Index(i)
- d := elem.Interface().(*time.Duration)
- dur := durationProto(*d)
- siz := Size(dur)
- buf, err := Marshal(dur)
- if err != nil {
- return nil, err
- }
- b = appendVarint(b, wiretag)
- b = appendVarint(b, uint64(siz))
- b = append(b, buf...)
- }
-
- return b, nil
- }
-}
diff --git a/vendor/github.com/gogo/protobuf/proto/table_merge.go b/vendor/github.com/gogo/protobuf/proto/table_merge.go
deleted file mode 100644
index f520106e09..0000000000
--- a/vendor/github.com/gogo/protobuf/proto/table_merge.go
+++ /dev/null
@@ -1,657 +0,0 @@
-// Go support for Protocol Buffers - Google's data interchange format
-//
-// Copyright 2016 The Go Authors. All rights reserved.
-// https://github.com/golang/protobuf
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-package proto
-
-import (
- "fmt"
- "reflect"
- "strings"
- "sync"
- "sync/atomic"
-)
-
-// Merge merges the src message into dst.
-// This assumes that dst and src of the same type and are non-nil.
-func (a *InternalMessageInfo) Merge(dst, src Message) {
- mi := atomicLoadMergeInfo(&a.merge)
- if mi == nil {
- mi = getMergeInfo(reflect.TypeOf(dst).Elem())
- atomicStoreMergeInfo(&a.merge, mi)
- }
- mi.merge(toPointer(&dst), toPointer(&src))
-}
-
-type mergeInfo struct {
- typ reflect.Type
-
- initialized int32 // 0: only typ is valid, 1: everything is valid
- lock sync.Mutex
-
- fields []mergeFieldInfo
- unrecognized field // Offset of XXX_unrecognized
-}
-
-type mergeFieldInfo struct {
- field field // Offset of field, guaranteed to be valid
-
- // isPointer reports whether the value in the field is a pointer.
- // This is true for the following situations:
- // * Pointer to struct
- // * Pointer to basic type (proto2 only)
- // * Slice (first value in slice header is a pointer)
- // * String (first value in string header is a pointer)
- isPointer bool
-
- // basicWidth reports the width of the field assuming that it is directly
- // embedded in the struct (as is the case for basic types in proto3).
- // The possible values are:
- // 0: invalid
- // 1: bool
- // 4: int32, uint32, float32
- // 8: int64, uint64, float64
- basicWidth int
-
- // Where dst and src are pointers to the types being merged.
- merge func(dst, src pointer)
-}
-
-var (
- mergeInfoMap = map[reflect.Type]*mergeInfo{}
- mergeInfoLock sync.Mutex
-)
-
-func getMergeInfo(t reflect.Type) *mergeInfo {
- mergeInfoLock.Lock()
- defer mergeInfoLock.Unlock()
- mi := mergeInfoMap[t]
- if mi == nil {
- mi = &mergeInfo{typ: t}
- mergeInfoMap[t] = mi
- }
- return mi
-}
-
-// merge merges src into dst assuming they are both of type *mi.typ.
-func (mi *mergeInfo) merge(dst, src pointer) {
- if dst.isNil() {
- panic("proto: nil destination")
- }
- if src.isNil() {
- return // Nothing to do.
- }
-
- if atomic.LoadInt32(&mi.initialized) == 0 {
- mi.computeMergeInfo()
- }
-
- for _, fi := range mi.fields {
- sfp := src.offset(fi.field)
-
- // As an optimization, we can avoid the merge function call cost
- // if we know for sure that the source will have no effect
- // by checking if it is the zero value.
- if unsafeAllowed {
- if fi.isPointer && sfp.getPointer().isNil() { // Could be slice or string
- continue
- }
- if fi.basicWidth > 0 {
- switch {
- case fi.basicWidth == 1 && !*sfp.toBool():
- continue
- case fi.basicWidth == 4 && *sfp.toUint32() == 0:
- continue
- case fi.basicWidth == 8 && *sfp.toUint64() == 0:
- continue
- }
- }
- }
-
- dfp := dst.offset(fi.field)
- fi.merge(dfp, sfp)
- }
-
- // TODO: Make this faster?
- out := dst.asPointerTo(mi.typ).Elem()
- in := src.asPointerTo(mi.typ).Elem()
- if emIn, err := extendable(in.Addr().Interface()); err == nil {
- emOut, _ := extendable(out.Addr().Interface())
- mIn, muIn := emIn.extensionsRead()
- if mIn != nil {
- mOut := emOut.extensionsWrite()
- muIn.Lock()
- mergeExtension(mOut, mIn)
- muIn.Unlock()
- }
- }
-
- if mi.unrecognized.IsValid() {
- if b := *src.offset(mi.unrecognized).toBytes(); len(b) > 0 {
- *dst.offset(mi.unrecognized).toBytes() = append([]byte(nil), b...)
- }
- }
-}
-
-func (mi *mergeInfo) computeMergeInfo() {
- mi.lock.Lock()
- defer mi.lock.Unlock()
- if mi.initialized != 0 {
- return
- }
- t := mi.typ
- n := t.NumField()
-
- props := GetProperties(t)
- for i := 0; i < n; i++ {
- f := t.Field(i)
- if strings.HasPrefix(f.Name, "XXX_") {
- continue
- }
-
- mfi := mergeFieldInfo{field: toField(&f)}
- tf := f.Type
-
- // As an optimization, we can avoid the merge function call cost
- // if we know for sure that the source will have no effect
- // by checking if it is the zero value.
- if unsafeAllowed {
- switch tf.Kind() {
- case reflect.Ptr, reflect.Slice, reflect.String:
- // As a special case, we assume slices and strings are pointers
- // since we know that the first field in the SliceSlice or
- // StringHeader is a data pointer.
- mfi.isPointer = true
- case reflect.Bool:
- mfi.basicWidth = 1
- case reflect.Int32, reflect.Uint32, reflect.Float32:
- mfi.basicWidth = 4
- case reflect.Int64, reflect.Uint64, reflect.Float64:
- mfi.basicWidth = 8
- }
- }
-
- // Unwrap tf to get at its most basic type.
- var isPointer, isSlice bool
- if tf.Kind() == reflect.Slice && tf.Elem().Kind() != reflect.Uint8 {
- isSlice = true
- tf = tf.Elem()
- }
- if tf.Kind() == reflect.Ptr {
- isPointer = true
- tf = tf.Elem()
- }
- if isPointer && isSlice && tf.Kind() != reflect.Struct {
- panic("both pointer and slice for basic type in " + tf.Name())
- }
-
- switch tf.Kind() {
- case reflect.Int32:
- switch {
- case isSlice: // E.g., []int32
- mfi.merge = func(dst, src pointer) {
- // NOTE: toInt32Slice is not defined (see pointer_reflect.go).
- /*
- sfsp := src.toInt32Slice()
- if *sfsp != nil {
- dfsp := dst.toInt32Slice()
- *dfsp = append(*dfsp, *sfsp...)
- if *dfsp == nil {
- *dfsp = []int64{}
- }
- }
- */
- sfs := src.getInt32Slice()
- if sfs != nil {
- dfs := dst.getInt32Slice()
- dfs = append(dfs, sfs...)
- if dfs == nil {
- dfs = []int32{}
- }
- dst.setInt32Slice(dfs)
- }
- }
- case isPointer: // E.g., *int32
- mfi.merge = func(dst, src pointer) {
- // NOTE: toInt32Ptr is not defined (see pointer_reflect.go).
- /*
- sfpp := src.toInt32Ptr()
- if *sfpp != nil {
- dfpp := dst.toInt32Ptr()
- if *dfpp == nil {
- *dfpp = Int32(**sfpp)
- } else {
- **dfpp = **sfpp
- }
- }
- */
- sfp := src.getInt32Ptr()
- if sfp != nil {
- dfp := dst.getInt32Ptr()
- if dfp == nil {
- dst.setInt32Ptr(*sfp)
- } else {
- *dfp = *sfp
- }
- }
- }
- default: // E.g., int32
- mfi.merge = func(dst, src pointer) {
- if v := *src.toInt32(); v != 0 {
- *dst.toInt32() = v
- }
- }
- }
- case reflect.Int64:
- switch {
- case isSlice: // E.g., []int64
- mfi.merge = func(dst, src pointer) {
- sfsp := src.toInt64Slice()
- if *sfsp != nil {
- dfsp := dst.toInt64Slice()
- *dfsp = append(*dfsp, *sfsp...)
- if *dfsp == nil {
- *dfsp = []int64{}
- }
- }
- }
- case isPointer: // E.g., *int64
- mfi.merge = func(dst, src pointer) {
- sfpp := src.toInt64Ptr()
- if *sfpp != nil {
- dfpp := dst.toInt64Ptr()
- if *dfpp == nil {
- *dfpp = Int64(**sfpp)
- } else {
- **dfpp = **sfpp
- }
- }
- }
- default: // E.g., int64
- mfi.merge = func(dst, src pointer) {
- if v := *src.toInt64(); v != 0 {
- *dst.toInt64() = v
- }
- }
- }
- case reflect.Uint32:
- switch {
- case isSlice: // E.g., []uint32
- mfi.merge = func(dst, src pointer) {
- sfsp := src.toUint32Slice()
- if *sfsp != nil {
- dfsp := dst.toUint32Slice()
- *dfsp = append(*dfsp, *sfsp...)
- if *dfsp == nil {
- *dfsp = []uint32{}
- }
- }
- }
- case isPointer: // E.g., *uint32
- mfi.merge = func(dst, src pointer) {
- sfpp := src.toUint32Ptr()
- if *sfpp != nil {
- dfpp := dst.toUint32Ptr()
- if *dfpp == nil {
- *dfpp = Uint32(**sfpp)
- } else {
- **dfpp = **sfpp
- }
- }
- }
- default: // E.g., uint32
- mfi.merge = func(dst, src pointer) {
- if v := *src.toUint32(); v != 0 {
- *dst.toUint32() = v
- }
- }
- }
- case reflect.Uint64:
- switch {
- case isSlice: // E.g., []uint64
- mfi.merge = func(dst, src pointer) {
- sfsp := src.toUint64Slice()
- if *sfsp != nil {
- dfsp := dst.toUint64Slice()
- *dfsp = append(*dfsp, *sfsp...)
- if *dfsp == nil {
- *dfsp = []uint64{}
- }
- }
- }
- case isPointer: // E.g., *uint64
- mfi.merge = func(dst, src pointer) {
- sfpp := src.toUint64Ptr()
- if *sfpp != nil {
- dfpp := dst.toUint64Ptr()
- if *dfpp == nil {
- *dfpp = Uint64(**sfpp)
- } else {
- **dfpp = **sfpp
- }
- }
- }
- default: // E.g., uint64
- mfi.merge = func(dst, src pointer) {
- if v := *src.toUint64(); v != 0 {
- *dst.toUint64() = v
- }
- }
- }
- case reflect.Float32:
- switch {
- case isSlice: // E.g., []float32
- mfi.merge = func(dst, src pointer) {
- sfsp := src.toFloat32Slice()
- if *sfsp != nil {
- dfsp := dst.toFloat32Slice()
- *dfsp = append(*dfsp, *sfsp...)
- if *dfsp == nil {
- *dfsp = []float32{}
- }
- }
- }
- case isPointer: // E.g., *float32
- mfi.merge = func(dst, src pointer) {
- sfpp := src.toFloat32Ptr()
- if *sfpp != nil {
- dfpp := dst.toFloat32Ptr()
- if *dfpp == nil {
- *dfpp = Float32(**sfpp)
- } else {
- **dfpp = **sfpp
- }
- }
- }
- default: // E.g., float32
- mfi.merge = func(dst, src pointer) {
- if v := *src.toFloat32(); v != 0 {
- *dst.toFloat32() = v
- }
- }
- }
- case reflect.Float64:
- switch {
- case isSlice: // E.g., []float64
- mfi.merge = func(dst, src pointer) {
- sfsp := src.toFloat64Slice()
- if *sfsp != nil {
- dfsp := dst.toFloat64Slice()
- *dfsp = append(*dfsp, *sfsp...)
- if *dfsp == nil {
- *dfsp = []float64{}
- }
- }
- }
- case isPointer: // E.g., *float64
- mfi.merge = func(dst, src pointer) {
- sfpp := src.toFloat64Ptr()
- if *sfpp != nil {
- dfpp := dst.toFloat64Ptr()
- if *dfpp == nil {
- *dfpp = Float64(**sfpp)
- } else {
- **dfpp = **sfpp
- }
- }
- }
- default: // E.g., float64
- mfi.merge = func(dst, src pointer) {
- if v := *src.toFloat64(); v != 0 {
- *dst.toFloat64() = v
- }
- }
- }
- case reflect.Bool:
- switch {
- case isSlice: // E.g., []bool
- mfi.merge = func(dst, src pointer) {
- sfsp := src.toBoolSlice()
- if *sfsp != nil {
- dfsp := dst.toBoolSlice()
- *dfsp = append(*dfsp, *sfsp...)
- if *dfsp == nil {
- *dfsp = []bool{}
- }
- }
- }
- case isPointer: // E.g., *bool
- mfi.merge = func(dst, src pointer) {
- sfpp := src.toBoolPtr()
- if *sfpp != nil {
- dfpp := dst.toBoolPtr()
- if *dfpp == nil {
- *dfpp = Bool(**sfpp)
- } else {
- **dfpp = **sfpp
- }
- }
- }
- default: // E.g., bool
- mfi.merge = func(dst, src pointer) {
- if v := *src.toBool(); v {
- *dst.toBool() = v
- }
- }
- }
- case reflect.String:
- switch {
- case isSlice: // E.g., []string
- mfi.merge = func(dst, src pointer) {
- sfsp := src.toStringSlice()
- if *sfsp != nil {
- dfsp := dst.toStringSlice()
- *dfsp = append(*dfsp, *sfsp...)
- if *dfsp == nil {
- *dfsp = []string{}
- }
- }
- }
- case isPointer: // E.g., *string
- mfi.merge = func(dst, src pointer) {
- sfpp := src.toStringPtr()
- if *sfpp != nil {
- dfpp := dst.toStringPtr()
- if *dfpp == nil {
- *dfpp = String(**sfpp)
- } else {
- **dfpp = **sfpp
- }
- }
- }
- default: // E.g., string
- mfi.merge = func(dst, src pointer) {
- if v := *src.toString(); v != "" {
- *dst.toString() = v
- }
- }
- }
- case reflect.Slice:
- isProto3 := props.Prop[i].proto3
- switch {
- case isPointer:
- panic("bad pointer in byte slice case in " + tf.Name())
- case tf.Elem().Kind() != reflect.Uint8:
- panic("bad element kind in byte slice case in " + tf.Name())
- case isSlice: // E.g., [][]byte
- mfi.merge = func(dst, src pointer) {
- sbsp := src.toBytesSlice()
- if *sbsp != nil {
- dbsp := dst.toBytesSlice()
- for _, sb := range *sbsp {
- if sb == nil {
- *dbsp = append(*dbsp, nil)
- } else {
- *dbsp = append(*dbsp, append([]byte{}, sb...))
- }
- }
- if *dbsp == nil {
- *dbsp = [][]byte{}
- }
- }
- }
- default: // E.g., []byte
- mfi.merge = func(dst, src pointer) {
- sbp := src.toBytes()
- if *sbp != nil {
- dbp := dst.toBytes()
- if !isProto3 || len(*sbp) > 0 {
- *dbp = append([]byte{}, *sbp...)
- }
- }
- }
- }
- case reflect.Struct:
- switch {
- case !isPointer:
- mergeInfo := getMergeInfo(tf)
- mfi.merge = func(dst, src pointer) {
- mergeInfo.merge(dst, src)
- }
- case isSlice: // E.g., []*pb.T
- mergeInfo := getMergeInfo(tf)
- mfi.merge = func(dst, src pointer) {
- sps := src.getPointerSlice()
- if sps != nil {
- dps := dst.getPointerSlice()
- for _, sp := range sps {
- var dp pointer
- if !sp.isNil() {
- dp = valToPointer(reflect.New(tf))
- mergeInfo.merge(dp, sp)
- }
- dps = append(dps, dp)
- }
- if dps == nil {
- dps = []pointer{}
- }
- dst.setPointerSlice(dps)
- }
- }
- default: // E.g., *pb.T
- mergeInfo := getMergeInfo(tf)
- mfi.merge = func(dst, src pointer) {
- sp := src.getPointer()
- if !sp.isNil() {
- dp := dst.getPointer()
- if dp.isNil() {
- dp = valToPointer(reflect.New(tf))
- dst.setPointer(dp)
- }
- mergeInfo.merge(dp, sp)
- }
- }
- }
- case reflect.Map:
- switch {
- case isPointer || isSlice:
- panic("bad pointer or slice in map case in " + tf.Name())
- default: // E.g., map[K]V
- mfi.merge = func(dst, src pointer) {
- sm := src.asPointerTo(tf).Elem()
- if sm.Len() == 0 {
- return
- }
- dm := dst.asPointerTo(tf).Elem()
- if dm.IsNil() {
- dm.Set(reflect.MakeMap(tf))
- }
-
- switch tf.Elem().Kind() {
- case reflect.Ptr: // Proto struct (e.g., *T)
- for _, key := range sm.MapKeys() {
- val := sm.MapIndex(key)
- val = reflect.ValueOf(Clone(val.Interface().(Message)))
- dm.SetMapIndex(key, val)
- }
- case reflect.Slice: // E.g. Bytes type (e.g., []byte)
- for _, key := range sm.MapKeys() {
- val := sm.MapIndex(key)
- val = reflect.ValueOf(append([]byte{}, val.Bytes()...))
- dm.SetMapIndex(key, val)
- }
- default: // Basic type (e.g., string)
- for _, key := range sm.MapKeys() {
- val := sm.MapIndex(key)
- dm.SetMapIndex(key, val)
- }
- }
- }
- }
- case reflect.Interface:
- // Must be oneof field.
- switch {
- case isPointer || isSlice:
- panic("bad pointer or slice in interface case in " + tf.Name())
- default: // E.g., interface{}
- // TODO: Make this faster?
- mfi.merge = func(dst, src pointer) {
- su := src.asPointerTo(tf).Elem()
- if !su.IsNil() {
- du := dst.asPointerTo(tf).Elem()
- typ := su.Elem().Type()
- if du.IsNil() || du.Elem().Type() != typ {
- du.Set(reflect.New(typ.Elem())) // Initialize interface if empty
- }
- sv := su.Elem().Elem().Field(0)
- if sv.Kind() == reflect.Ptr && sv.IsNil() {
- return
- }
- dv := du.Elem().Elem().Field(0)
- if dv.Kind() == reflect.Ptr && dv.IsNil() {
- dv.Set(reflect.New(sv.Type().Elem())) // Initialize proto message if empty
- }
- switch sv.Type().Kind() {
- case reflect.Ptr: // Proto struct (e.g., *T)
- Merge(dv.Interface().(Message), sv.Interface().(Message))
- case reflect.Slice: // E.g. Bytes type (e.g., []byte)
- dv.Set(reflect.ValueOf(append([]byte{}, sv.Bytes()...)))
- default: // Basic type (e.g., string)
- dv.Set(sv)
- }
- }
- }
- }
- default:
- panic(fmt.Sprintf("merger not found for type:%s", tf))
- }
- mi.fields = append(mi.fields, mfi)
- }
-
- mi.unrecognized = invalidField
- if f, ok := t.FieldByName("XXX_unrecognized"); ok {
- if f.Type != reflect.TypeOf([]byte{}) {
- panic("expected XXX_unrecognized to be of type []byte")
- }
- mi.unrecognized = toField(&f)
- }
-
- atomic.StoreInt32(&mi.initialized, 1)
-}
diff --git a/vendor/github.com/gogo/protobuf/proto/table_unmarshal.go b/vendor/github.com/gogo/protobuf/proto/table_unmarshal.go
deleted file mode 100644
index 910e2dd6ad..0000000000
--- a/vendor/github.com/gogo/protobuf/proto/table_unmarshal.go
+++ /dev/null
@@ -1,2048 +0,0 @@
-// Go support for Protocol Buffers - Google's data interchange format
-//
-// Copyright 2016 The Go Authors. All rights reserved.
-// https://github.com/golang/protobuf
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-package proto
-
-import (
- "errors"
- "fmt"
- "io"
- "math"
- "reflect"
- "strconv"
- "strings"
- "sync"
- "sync/atomic"
- "unicode/utf8"
-)
-
-// Unmarshal is the entry point from the generated .pb.go files.
-// This function is not intended to be used by non-generated code.
-// This function is not subject to any compatibility guarantee.
-// msg contains a pointer to a protocol buffer struct.
-// b is the data to be unmarshaled into the protocol buffer.
-// a is a pointer to a place to store cached unmarshal information.
-func (a *InternalMessageInfo) Unmarshal(msg Message, b []byte) error {
- // Load the unmarshal information for this message type.
- // The atomic load ensures memory consistency.
- u := atomicLoadUnmarshalInfo(&a.unmarshal)
- if u == nil {
- // Slow path: find unmarshal info for msg, update a with it.
- u = getUnmarshalInfo(reflect.TypeOf(msg).Elem())
- atomicStoreUnmarshalInfo(&a.unmarshal, u)
- }
- // Then do the unmarshaling.
- err := u.unmarshal(toPointer(&msg), b)
- return err
-}
-
-type unmarshalInfo struct {
- typ reflect.Type // type of the protobuf struct
-
- // 0 = only typ field is initialized
- // 1 = completely initialized
- initialized int32
- lock sync.Mutex // prevents double initialization
- dense []unmarshalFieldInfo // fields indexed by tag #
- sparse map[uint64]unmarshalFieldInfo // fields indexed by tag #
- reqFields []string // names of required fields
- reqMask uint64 // 1< 0 {
- // Read tag and wire type.
- // Special case 1 and 2 byte varints.
- var x uint64
- if b[0] < 128 {
- x = uint64(b[0])
- b = b[1:]
- } else if len(b) >= 2 && b[1] < 128 {
- x = uint64(b[0]&0x7f) + uint64(b[1])<<7
- b = b[2:]
- } else {
- var n int
- x, n = decodeVarint(b)
- if n == 0 {
- return io.ErrUnexpectedEOF
- }
- b = b[n:]
- }
- tag := x >> 3
- wire := int(x) & 7
-
- // Dispatch on the tag to one of the unmarshal* functions below.
- var f unmarshalFieldInfo
- if tag < uint64(len(u.dense)) {
- f = u.dense[tag]
- } else {
- f = u.sparse[tag]
- }
- if fn := f.unmarshal; fn != nil {
- var err error
- b, err = fn(b, m.offset(f.field), wire)
- if err == nil {
- reqMask |= f.reqMask
- continue
- }
- if r, ok := err.(*RequiredNotSetError); ok {
- // Remember this error, but keep parsing. We need to produce
- // a full parse even if a required field is missing.
- rnse = r
- reqMask |= f.reqMask
- continue
- }
- if err != errInternalBadWireType {
- return err
- }
- // Fragments with bad wire type are treated as unknown fields.
- }
-
- // Unknown tag.
- if !u.unrecognized.IsValid() {
- // Don't keep unrecognized data; just skip it.
- var err error
- b, err = skipField(b, wire)
- if err != nil {
- return err
- }
- continue
- }
- // Keep unrecognized data around.
- // maybe in extensions, maybe in the unrecognized field.
- z := m.offset(u.unrecognized).toBytes()
- var emap map[int32]Extension
- var e Extension
- for _, r := range u.extensionRanges {
- if uint64(r.Start) <= tag && tag <= uint64(r.End) {
- if u.extensions.IsValid() {
- mp := m.offset(u.extensions).toExtensions()
- emap = mp.extensionsWrite()
- e = emap[int32(tag)]
- z = &e.enc
- break
- }
- if u.oldExtensions.IsValid() {
- p := m.offset(u.oldExtensions).toOldExtensions()
- emap = *p
- if emap == nil {
- emap = map[int32]Extension{}
- *p = emap
- }
- e = emap[int32(tag)]
- z = &e.enc
- break
- }
- if u.bytesExtensions.IsValid() {
- z = m.offset(u.bytesExtensions).toBytes()
- break
- }
- panic("no extensions field available")
- }
- }
- // Use wire type to skip data.
- var err error
- b0 := b
- b, err = skipField(b, wire)
- if err != nil {
- return err
- }
- *z = encodeVarint(*z, tag<<3|uint64(wire))
- *z = append(*z, b0[:len(b0)-len(b)]...)
-
- if emap != nil {
- emap[int32(tag)] = e
- }
- }
- if rnse != nil {
- // A required field of a submessage/group is missing. Return that error.
- return rnse
- }
- if reqMask != u.reqMask {
- // A required field of this message is missing.
- for _, n := range u.reqFields {
- if reqMask&1 == 0 {
- return &RequiredNotSetError{n}
- }
- reqMask >>= 1
- }
- }
- return nil
-}
-
-// computeUnmarshalInfo fills in u with information for use
-// in unmarshaling protocol buffers of type u.typ.
-func (u *unmarshalInfo) computeUnmarshalInfo() {
- u.lock.Lock()
- defer u.lock.Unlock()
- if u.initialized != 0 {
- return
- }
- t := u.typ
- n := t.NumField()
-
- // Set up the "not found" value for the unrecognized byte buffer.
- // This is the default for proto3.
- u.unrecognized = invalidField
- u.extensions = invalidField
- u.oldExtensions = invalidField
- u.bytesExtensions = invalidField
-
- // List of the generated type and offset for each oneof field.
- type oneofField struct {
- ityp reflect.Type // interface type of oneof field
- field field // offset in containing message
- }
- var oneofFields []oneofField
-
- for i := 0; i < n; i++ {
- f := t.Field(i)
- if f.Name == "XXX_unrecognized" {
- // The byte slice used to hold unrecognized input is special.
- if f.Type != reflect.TypeOf(([]byte)(nil)) {
- panic("bad type for XXX_unrecognized field: " + f.Type.Name())
- }
- u.unrecognized = toField(&f)
- continue
- }
- if f.Name == "XXX_InternalExtensions" {
- // Ditto here.
- if f.Type != reflect.TypeOf(XXX_InternalExtensions{}) {
- panic("bad type for XXX_InternalExtensions field: " + f.Type.Name())
- }
- u.extensions = toField(&f)
- if f.Tag.Get("protobuf_messageset") == "1" {
- u.isMessageSet = true
- }
- continue
- }
- if f.Name == "XXX_extensions" {
- // An older form of the extensions field.
- if f.Type == reflect.TypeOf((map[int32]Extension)(nil)) {
- u.oldExtensions = toField(&f)
- continue
- } else if f.Type == reflect.TypeOf(([]byte)(nil)) {
- u.bytesExtensions = toField(&f)
- continue
- }
- panic("bad type for XXX_extensions field: " + f.Type.Name())
- }
- if f.Name == "XXX_NoUnkeyedLiteral" || f.Name == "XXX_sizecache" {
- continue
- }
-
- oneof := f.Tag.Get("protobuf_oneof")
- if oneof != "" {
- oneofFields = append(oneofFields, oneofField{f.Type, toField(&f)})
- // The rest of oneof processing happens below.
- continue
- }
-
- tags := f.Tag.Get("protobuf")
- tagArray := strings.Split(tags, ",")
- if len(tagArray) < 2 {
- panic("protobuf tag not enough fields in " + t.Name() + "." + f.Name + ": " + tags)
- }
- tag, err := strconv.Atoi(tagArray[1])
- if err != nil {
- panic("protobuf tag field not an integer: " + tagArray[1])
- }
-
- name := ""
- for _, tag := range tagArray[3:] {
- if strings.HasPrefix(tag, "name=") {
- name = tag[5:]
- }
- }
-
- // Extract unmarshaling function from the field (its type and tags).
- unmarshal := fieldUnmarshaler(&f)
-
- // Required field?
- var reqMask uint64
- if tagArray[2] == "req" {
- bit := len(u.reqFields)
- u.reqFields = append(u.reqFields, name)
- reqMask = uint64(1) << uint(bit)
- // TODO: if we have more than 64 required fields, we end up
- // not verifying that all required fields are present.
- // Fix this, perhaps using a count of required fields?
- }
-
- // Store the info in the correct slot in the message.
- u.setTag(tag, toField(&f), unmarshal, reqMask)
- }
-
- // Find any types associated with oneof fields.
- // TODO: XXX_OneofFuncs returns more info than we need. Get rid of some of it?
- fn := reflect.Zero(reflect.PtrTo(t)).MethodByName("XXX_OneofFuncs")
- // gogo: len(oneofFields) > 0 is needed for embedded oneof messages, without a marshaler and unmarshaler
- if fn.IsValid() && len(oneofFields) > 0 {
- res := fn.Call(nil)[3] // last return value from XXX_OneofFuncs: []interface{}
- for i := res.Len() - 1; i >= 0; i-- {
- v := res.Index(i) // interface{}
- tptr := reflect.ValueOf(v.Interface()).Type() // *Msg_X
- typ := tptr.Elem() // Msg_X
-
- f := typ.Field(0) // oneof implementers have one field
- baseUnmarshal := fieldUnmarshaler(&f)
- tagstr := strings.Split(f.Tag.Get("protobuf"), ",")[1]
- tag, err := strconv.Atoi(tagstr)
- if err != nil {
- panic("protobuf tag field not an integer: " + tagstr)
- }
-
- // Find the oneof field that this struct implements.
- // Might take O(n^2) to process all of the oneofs, but who cares.
- for _, of := range oneofFields {
- if tptr.Implements(of.ityp) {
- // We have found the corresponding interface for this struct.
- // That lets us know where this struct should be stored
- // when we encounter it during unmarshaling.
- unmarshal := makeUnmarshalOneof(typ, of.ityp, baseUnmarshal)
- u.setTag(tag, of.field, unmarshal, 0)
- }
- }
- }
- }
-
- // Get extension ranges, if any.
- fn = reflect.Zero(reflect.PtrTo(t)).MethodByName("ExtensionRangeArray")
- if fn.IsValid() {
- if !u.extensions.IsValid() && !u.oldExtensions.IsValid() && !u.bytesExtensions.IsValid() {
- panic("a message with extensions, but no extensions field in " + t.Name())
- }
- u.extensionRanges = fn.Call(nil)[0].Interface().([]ExtensionRange)
- }
-
- // Explicitly disallow tag 0. This will ensure we flag an error
- // when decoding a buffer of all zeros. Without this code, we
- // would decode and skip an all-zero buffer of even length.
- // [0 0] is [tag=0/wiretype=varint varint-encoded-0].
- u.setTag(0, zeroField, func(b []byte, f pointer, w int) ([]byte, error) {
- return nil, fmt.Errorf("proto: %s: illegal tag 0 (wire type %d)", t, w)
- }, 0)
-
- // Set mask for required field check.
- u.reqMask = uint64(1)<= 0 && (tag < 16 || tag < 2*n) { // TODO: what are the right numbers here?
- for len(u.dense) <= tag {
- u.dense = append(u.dense, unmarshalFieldInfo{})
- }
- u.dense[tag] = i
- return
- }
- if u.sparse == nil {
- u.sparse = map[uint64]unmarshalFieldInfo{}
- }
- u.sparse[uint64(tag)] = i
-}
-
-// fieldUnmarshaler returns an unmarshaler for the given field.
-func fieldUnmarshaler(f *reflect.StructField) unmarshaler {
- if f.Type.Kind() == reflect.Map {
- return makeUnmarshalMap(f)
- }
- return typeUnmarshaler(f.Type, f.Tag.Get("protobuf"))
-}
-
-// typeUnmarshaler returns an unmarshaler for the given field type / field tag pair.
-func typeUnmarshaler(t reflect.Type, tags string) unmarshaler {
- tagArray := strings.Split(tags, ",")
- encoding := tagArray[0]
- name := "unknown"
- ctype := false
- isTime := false
- isDuration := false
- for _, tag := range tagArray[3:] {
- if strings.HasPrefix(tag, "name=") {
- name = tag[5:]
- }
- if strings.HasPrefix(tag, "customtype=") {
- ctype = true
- }
- if tag == "stdtime" {
- isTime = true
- }
- if tag == "stdduration" {
- isDuration = true
- }
- }
-
- // Figure out packaging (pointer, slice, or both)
- slice := false
- pointer := false
- if t.Kind() == reflect.Slice && t.Elem().Kind() != reflect.Uint8 {
- slice = true
- t = t.Elem()
- }
- if t.Kind() == reflect.Ptr {
- pointer = true
- t = t.Elem()
- }
-
- if ctype {
- if reflect.PtrTo(t).Implements(customType) {
- if slice {
- return makeUnmarshalCustomSlice(getUnmarshalInfo(t), name)
- }
- if pointer {
- return makeUnmarshalCustomPtr(getUnmarshalInfo(t), name)
- }
- return makeUnmarshalCustom(getUnmarshalInfo(t), name)
- } else {
- panic(fmt.Sprintf("custom type: type: %v, does not implement the proto.custom interface", t))
- }
- }
-
- if isTime {
- if pointer {
- if slice {
- return makeUnmarshalTimePtrSlice(getUnmarshalInfo(t), name)
- }
- return makeUnmarshalTimePtr(getUnmarshalInfo(t), name)
- }
- if slice {
- return makeUnmarshalTimeSlice(getUnmarshalInfo(t), name)
- }
- return makeUnmarshalTime(getUnmarshalInfo(t), name)
- }
-
- if isDuration {
- if pointer {
- if slice {
- return makeUnmarshalDurationPtrSlice(getUnmarshalInfo(t), name)
- }
- return makeUnmarshalDurationPtr(getUnmarshalInfo(t), name)
- }
- if slice {
- return makeUnmarshalDurationSlice(getUnmarshalInfo(t), name)
- }
- return makeUnmarshalDuration(getUnmarshalInfo(t), name)
- }
-
- // We'll never have both pointer and slice for basic types.
- if pointer && slice && t.Kind() != reflect.Struct {
- panic("both pointer and slice for basic type in " + t.Name())
- }
-
- switch t.Kind() {
- case reflect.Bool:
- if pointer {
- return unmarshalBoolPtr
- }
- if slice {
- return unmarshalBoolSlice
- }
- return unmarshalBoolValue
- case reflect.Int32:
- switch encoding {
- case "fixed32":
- if pointer {
- return unmarshalFixedS32Ptr
- }
- if slice {
- return unmarshalFixedS32Slice
- }
- return unmarshalFixedS32Value
- case "varint":
- // this could be int32 or enum
- if pointer {
- return unmarshalInt32Ptr
- }
- if slice {
- return unmarshalInt32Slice
- }
- return unmarshalInt32Value
- case "zigzag32":
- if pointer {
- return unmarshalSint32Ptr
- }
- if slice {
- return unmarshalSint32Slice
- }
- return unmarshalSint32Value
- }
- case reflect.Int64:
- switch encoding {
- case "fixed64":
- if pointer {
- return unmarshalFixedS64Ptr
- }
- if slice {
- return unmarshalFixedS64Slice
- }
- return unmarshalFixedS64Value
- case "varint":
- if pointer {
- return unmarshalInt64Ptr
- }
- if slice {
- return unmarshalInt64Slice
- }
- return unmarshalInt64Value
- case "zigzag64":
- if pointer {
- return unmarshalSint64Ptr
- }
- if slice {
- return unmarshalSint64Slice
- }
- return unmarshalSint64Value
- }
- case reflect.Uint32:
- switch encoding {
- case "fixed32":
- if pointer {
- return unmarshalFixed32Ptr
- }
- if slice {
- return unmarshalFixed32Slice
- }
- return unmarshalFixed32Value
- case "varint":
- if pointer {
- return unmarshalUint32Ptr
- }
- if slice {
- return unmarshalUint32Slice
- }
- return unmarshalUint32Value
- }
- case reflect.Uint64:
- switch encoding {
- case "fixed64":
- if pointer {
- return unmarshalFixed64Ptr
- }
- if slice {
- return unmarshalFixed64Slice
- }
- return unmarshalFixed64Value
- case "varint":
- if pointer {
- return unmarshalUint64Ptr
- }
- if slice {
- return unmarshalUint64Slice
- }
- return unmarshalUint64Value
- }
- case reflect.Float32:
- if pointer {
- return unmarshalFloat32Ptr
- }
- if slice {
- return unmarshalFloat32Slice
- }
- return unmarshalFloat32Value
- case reflect.Float64:
- if pointer {
- return unmarshalFloat64Ptr
- }
- if slice {
- return unmarshalFloat64Slice
- }
- return unmarshalFloat64Value
- case reflect.Map:
- panic("map type in typeUnmarshaler in " + t.Name())
- case reflect.Slice:
- if pointer {
- panic("bad pointer in slice case in " + t.Name())
- }
- if slice {
- return unmarshalBytesSlice
- }
- return unmarshalBytesValue
- case reflect.String:
- if pointer {
- return unmarshalStringPtr
- }
- if slice {
- return unmarshalStringSlice
- }
- return unmarshalStringValue
- case reflect.Struct:
- // message or group field
- if !pointer {
- switch encoding {
- case "bytes":
- if slice {
- return makeUnmarshalMessageSlice(getUnmarshalInfo(t), name)
- }
- return makeUnmarshalMessage(getUnmarshalInfo(t), name)
- }
- }
- switch encoding {
- case "bytes":
- if slice {
- return makeUnmarshalMessageSlicePtr(getUnmarshalInfo(t), name)
- }
- return makeUnmarshalMessagePtr(getUnmarshalInfo(t), name)
- case "group":
- if slice {
- return makeUnmarshalGroupSlicePtr(getUnmarshalInfo(t), name)
- }
- return makeUnmarshalGroupPtr(getUnmarshalInfo(t), name)
- }
- }
- panic(fmt.Sprintf("unmarshaler not found type:%s encoding:%s", t, encoding))
-}
-
-// Below are all the unmarshalers for individual fields of various types.
-
-func unmarshalInt64Value(b []byte, f pointer, w int) ([]byte, error) {
- if w != WireVarint {
- return b, errInternalBadWireType
- }
- x, n := decodeVarint(b)
- if n == 0 {
- return nil, io.ErrUnexpectedEOF
- }
- b = b[n:]
- v := int64(x)
- *f.toInt64() = v
- return b, nil
-}
-
-func unmarshalInt64Ptr(b []byte, f pointer, w int) ([]byte, error) {
- if w != WireVarint {
- return b, errInternalBadWireType
- }
- x, n := decodeVarint(b)
- if n == 0 {
- return nil, io.ErrUnexpectedEOF
- }
- b = b[n:]
- v := int64(x)
- *f.toInt64Ptr() = &v
- return b, nil
-}
-
-func unmarshalInt64Slice(b []byte, f pointer, w int) ([]byte, error) {
- if w == WireBytes { // packed
- x, n := decodeVarint(b)
- if n == 0 {
- return nil, io.ErrUnexpectedEOF
- }
- b = b[n:]
- if x > uint64(len(b)) {
- return nil, io.ErrUnexpectedEOF
- }
- res := b[x:]
- b = b[:x]
- for len(b) > 0 {
- x, n = decodeVarint(b)
- if n == 0 {
- return nil, io.ErrUnexpectedEOF
- }
- b = b[n:]
- v := int64(x)
- s := f.toInt64Slice()
- *s = append(*s, v)
- }
- return res, nil
- }
- if w != WireVarint {
- return b, errInternalBadWireType
- }
- x, n := decodeVarint(b)
- if n == 0 {
- return nil, io.ErrUnexpectedEOF
- }
- b = b[n:]
- v := int64(x)
- s := f.toInt64Slice()
- *s = append(*s, v)
- return b, nil
-}
-
-func unmarshalSint64Value(b []byte, f pointer, w int) ([]byte, error) {
- if w != WireVarint {
- return b, errInternalBadWireType
- }
- x, n := decodeVarint(b)
- if n == 0 {
- return nil, io.ErrUnexpectedEOF
- }
- b = b[n:]
- v := int64(x>>1) ^ int64(x)<<63>>63
- *f.toInt64() = v
- return b, nil
-}
-
-func unmarshalSint64Ptr(b []byte, f pointer, w int) ([]byte, error) {
- if w != WireVarint {
- return b, errInternalBadWireType
- }
- x, n := decodeVarint(b)
- if n == 0 {
- return nil, io.ErrUnexpectedEOF
- }
- b = b[n:]
- v := int64(x>>1) ^ int64(x)<<63>>63
- *f.toInt64Ptr() = &v
- return b, nil
-}
-
-func unmarshalSint64Slice(b []byte, f pointer, w int) ([]byte, error) {
- if w == WireBytes { // packed
- x, n := decodeVarint(b)
- if n == 0 {
- return nil, io.ErrUnexpectedEOF
- }
- b = b[n:]
- if x > uint64(len(b)) {
- return nil, io.ErrUnexpectedEOF
- }
- res := b[x:]
- b = b[:x]
- for len(b) > 0 {
- x, n = decodeVarint(b)
- if n == 0 {
- return nil, io.ErrUnexpectedEOF
- }
- b = b[n:]
- v := int64(x>>1) ^ int64(x)<<63>>63
- s := f.toInt64Slice()
- *s = append(*s, v)
- }
- return res, nil
- }
- if w != WireVarint {
- return b, errInternalBadWireType
- }
- x, n := decodeVarint(b)
- if n == 0 {
- return nil, io.ErrUnexpectedEOF
- }
- b = b[n:]
- v := int64(x>>1) ^ int64(x)<<63>>63
- s := f.toInt64Slice()
- *s = append(*s, v)
- return b, nil
-}
-
-func unmarshalUint64Value(b []byte, f pointer, w int) ([]byte, error) {
- if w != WireVarint {
- return b, errInternalBadWireType
- }
- x, n := decodeVarint(b)
- if n == 0 {
- return nil, io.ErrUnexpectedEOF
- }
- b = b[n:]
- v := uint64(x)
- *f.toUint64() = v
- return b, nil
-}
-
-func unmarshalUint64Ptr(b []byte, f pointer, w int) ([]byte, error) {
- if w != WireVarint {
- return b, errInternalBadWireType
- }
- x, n := decodeVarint(b)
- if n == 0 {
- return nil, io.ErrUnexpectedEOF
- }
- b = b[n:]
- v := uint64(x)
- *f.toUint64Ptr() = &v
- return b, nil
-}
-
-func unmarshalUint64Slice(b []byte, f pointer, w int) ([]byte, error) {
- if w == WireBytes { // packed
- x, n := decodeVarint(b)
- if n == 0 {
- return nil, io.ErrUnexpectedEOF
- }
- b = b[n:]
- if x > uint64(len(b)) {
- return nil, io.ErrUnexpectedEOF
- }
- res := b[x:]
- b = b[:x]
- for len(b) > 0 {
- x, n = decodeVarint(b)
- if n == 0 {
- return nil, io.ErrUnexpectedEOF
- }
- b = b[n:]
- v := uint64(x)
- s := f.toUint64Slice()
- *s = append(*s, v)
- }
- return res, nil
- }
- if w != WireVarint {
- return b, errInternalBadWireType
- }
- x, n := decodeVarint(b)
- if n == 0 {
- return nil, io.ErrUnexpectedEOF
- }
- b = b[n:]
- v := uint64(x)
- s := f.toUint64Slice()
- *s = append(*s, v)
- return b, nil
-}
-
-func unmarshalInt32Value(b []byte, f pointer, w int) ([]byte, error) {
- if w != WireVarint {
- return b, errInternalBadWireType
- }
- x, n := decodeVarint(b)
- if n == 0 {
- return nil, io.ErrUnexpectedEOF
- }
- b = b[n:]
- v := int32(x)
- *f.toInt32() = v
- return b, nil
-}
-
-func unmarshalInt32Ptr(b []byte, f pointer, w int) ([]byte, error) {
- if w != WireVarint {
- return b, errInternalBadWireType
- }
- x, n := decodeVarint(b)
- if n == 0 {
- return nil, io.ErrUnexpectedEOF
- }
- b = b[n:]
- v := int32(x)
- f.setInt32Ptr(v)
- return b, nil
-}
-
-func unmarshalInt32Slice(b []byte, f pointer, w int) ([]byte, error) {
- if w == WireBytes { // packed
- x, n := decodeVarint(b)
- if n == 0 {
- return nil, io.ErrUnexpectedEOF
- }
- b = b[n:]
- if x > uint64(len(b)) {
- return nil, io.ErrUnexpectedEOF
- }
- res := b[x:]
- b = b[:x]
- for len(b) > 0 {
- x, n = decodeVarint(b)
- if n == 0 {
- return nil, io.ErrUnexpectedEOF
- }
- b = b[n:]
- v := int32(x)
- f.appendInt32Slice(v)
- }
- return res, nil
- }
- if w != WireVarint {
- return b, errInternalBadWireType
- }
- x, n := decodeVarint(b)
- if n == 0 {
- return nil, io.ErrUnexpectedEOF
- }
- b = b[n:]
- v := int32(x)
- f.appendInt32Slice(v)
- return b, nil
-}
-
-func unmarshalSint32Value(b []byte, f pointer, w int) ([]byte, error) {
- if w != WireVarint {
- return b, errInternalBadWireType
- }
- x, n := decodeVarint(b)
- if n == 0 {
- return nil, io.ErrUnexpectedEOF
- }
- b = b[n:]
- v := int32(x>>1) ^ int32(x)<<31>>31
- *f.toInt32() = v
- return b, nil
-}
-
-func unmarshalSint32Ptr(b []byte, f pointer, w int) ([]byte, error) {
- if w != WireVarint {
- return b, errInternalBadWireType
- }
- x, n := decodeVarint(b)
- if n == 0 {
- return nil, io.ErrUnexpectedEOF
- }
- b = b[n:]
- v := int32(x>>1) ^ int32(x)<<31>>31
- f.setInt32Ptr(v)
- return b, nil
-}
-
-func unmarshalSint32Slice(b []byte, f pointer, w int) ([]byte, error) {
- if w == WireBytes { // packed
- x, n := decodeVarint(b)
- if n == 0 {
- return nil, io.ErrUnexpectedEOF
- }
- b = b[n:]
- if x > uint64(len(b)) {
- return nil, io.ErrUnexpectedEOF
- }
- res := b[x:]
- b = b[:x]
- for len(b) > 0 {
- x, n = decodeVarint(b)
- if n == 0 {
- return nil, io.ErrUnexpectedEOF
- }
- b = b[n:]
- v := int32(x>>1) ^ int32(x)<<31>>31
- f.appendInt32Slice(v)
- }
- return res, nil
- }
- if w != WireVarint {
- return b, errInternalBadWireType
- }
- x, n := decodeVarint(b)
- if n == 0 {
- return nil, io.ErrUnexpectedEOF
- }
- b = b[n:]
- v := int32(x>>1) ^ int32(x)<<31>>31
- f.appendInt32Slice(v)
- return b, nil
-}
-
-func unmarshalUint32Value(b []byte, f pointer, w int) ([]byte, error) {
- if w != WireVarint {
- return b, errInternalBadWireType
- }
- x, n := decodeVarint(b)
- if n == 0 {
- return nil, io.ErrUnexpectedEOF
- }
- b = b[n:]
- v := uint32(x)
- *f.toUint32() = v
- return b, nil
-}
-
-func unmarshalUint32Ptr(b []byte, f pointer, w int) ([]byte, error) {
- if w != WireVarint {
- return b, errInternalBadWireType
- }
- x, n := decodeVarint(b)
- if n == 0 {
- return nil, io.ErrUnexpectedEOF
- }
- b = b[n:]
- v := uint32(x)
- *f.toUint32Ptr() = &v
- return b, nil
-}
-
-func unmarshalUint32Slice(b []byte, f pointer, w int) ([]byte, error) {
- if w == WireBytes { // packed
- x, n := decodeVarint(b)
- if n == 0 {
- return nil, io.ErrUnexpectedEOF
- }
- b = b[n:]
- if x > uint64(len(b)) {
- return nil, io.ErrUnexpectedEOF
- }
- res := b[x:]
- b = b[:x]
- for len(b) > 0 {
- x, n = decodeVarint(b)
- if n == 0 {
- return nil, io.ErrUnexpectedEOF
- }
- b = b[n:]
- v := uint32(x)
- s := f.toUint32Slice()
- *s = append(*s, v)
- }
- return res, nil
- }
- if w != WireVarint {
- return b, errInternalBadWireType
- }
- x, n := decodeVarint(b)
- if n == 0 {
- return nil, io.ErrUnexpectedEOF
- }
- b = b[n:]
- v := uint32(x)
- s := f.toUint32Slice()
- *s = append(*s, v)
- return b, nil
-}
-
-func unmarshalFixed64Value(b []byte, f pointer, w int) ([]byte, error) {
- if w != WireFixed64 {
- return b, errInternalBadWireType
- }
- if len(b) < 8 {
- return nil, io.ErrUnexpectedEOF
- }
- v := uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24 | uint64(b[4])<<32 | uint64(b[5])<<40 | uint64(b[6])<<48 | uint64(b[7])<<56
- *f.toUint64() = v
- return b[8:], nil
-}
-
-func unmarshalFixed64Ptr(b []byte, f pointer, w int) ([]byte, error) {
- if w != WireFixed64 {
- return b, errInternalBadWireType
- }
- if len(b) < 8 {
- return nil, io.ErrUnexpectedEOF
- }
- v := uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24 | uint64(b[4])<<32 | uint64(b[5])<<40 | uint64(b[6])<<48 | uint64(b[7])<<56
- *f.toUint64Ptr() = &v
- return b[8:], nil
-}
-
-func unmarshalFixed64Slice(b []byte, f pointer, w int) ([]byte, error) {
- if w == WireBytes { // packed
- x, n := decodeVarint(b)
- if n == 0 {
- return nil, io.ErrUnexpectedEOF
- }
- b = b[n:]
- if x > uint64(len(b)) {
- return nil, io.ErrUnexpectedEOF
- }
- res := b[x:]
- b = b[:x]
- for len(b) > 0 {
- if len(b) < 8 {
- return nil, io.ErrUnexpectedEOF
- }
- v := uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24 | uint64(b[4])<<32 | uint64(b[5])<<40 | uint64(b[6])<<48 | uint64(b[7])<<56
- s := f.toUint64Slice()
- *s = append(*s, v)
- b = b[8:]
- }
- return res, nil
- }
- if w != WireFixed64 {
- return b, errInternalBadWireType
- }
- if len(b) < 8 {
- return nil, io.ErrUnexpectedEOF
- }
- v := uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24 | uint64(b[4])<<32 | uint64(b[5])<<40 | uint64(b[6])<<48 | uint64(b[7])<<56
- s := f.toUint64Slice()
- *s = append(*s, v)
- return b[8:], nil
-}
-
-func unmarshalFixedS64Value(b []byte, f pointer, w int) ([]byte, error) {
- if w != WireFixed64 {
- return b, errInternalBadWireType
- }
- if len(b) < 8 {
- return nil, io.ErrUnexpectedEOF
- }
- v := int64(b[0]) | int64(b[1])<<8 | int64(b[2])<<16 | int64(b[3])<<24 | int64(b[4])<<32 | int64(b[5])<<40 | int64(b[6])<<48 | int64(b[7])<<56
- *f.toInt64() = v
- return b[8:], nil
-}
-
-func unmarshalFixedS64Ptr(b []byte, f pointer, w int) ([]byte, error) {
- if w != WireFixed64 {
- return b, errInternalBadWireType
- }
- if len(b) < 8 {
- return nil, io.ErrUnexpectedEOF
- }
- v := int64(b[0]) | int64(b[1])<<8 | int64(b[2])<<16 | int64(b[3])<<24 | int64(b[4])<<32 | int64(b[5])<<40 | int64(b[6])<<48 | int64(b[7])<<56
- *f.toInt64Ptr() = &v
- return b[8:], nil
-}
-
-func unmarshalFixedS64Slice(b []byte, f pointer, w int) ([]byte, error) {
- if w == WireBytes { // packed
- x, n := decodeVarint(b)
- if n == 0 {
- return nil, io.ErrUnexpectedEOF
- }
- b = b[n:]
- if x > uint64(len(b)) {
- return nil, io.ErrUnexpectedEOF
- }
- res := b[x:]
- b = b[:x]
- for len(b) > 0 {
- if len(b) < 8 {
- return nil, io.ErrUnexpectedEOF
- }
- v := int64(b[0]) | int64(b[1])<<8 | int64(b[2])<<16 | int64(b[3])<<24 | int64(b[4])<<32 | int64(b[5])<<40 | int64(b[6])<<48 | int64(b[7])<<56
- s := f.toInt64Slice()
- *s = append(*s, v)
- b = b[8:]
- }
- return res, nil
- }
- if w != WireFixed64 {
- return b, errInternalBadWireType
- }
- if len(b) < 8 {
- return nil, io.ErrUnexpectedEOF
- }
- v := int64(b[0]) | int64(b[1])<<8 | int64(b[2])<<16 | int64(b[3])<<24 | int64(b[4])<<32 | int64(b[5])<<40 | int64(b[6])<<48 | int64(b[7])<<56
- s := f.toInt64Slice()
- *s = append(*s, v)
- return b[8:], nil
-}
-
-func unmarshalFixed32Value(b []byte, f pointer, w int) ([]byte, error) {
- if w != WireFixed32 {
- return b, errInternalBadWireType
- }
- if len(b) < 4 {
- return nil, io.ErrUnexpectedEOF
- }
- v := uint32(b[0]) | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24
- *f.toUint32() = v
- return b[4:], nil
-}
-
-func unmarshalFixed32Ptr(b []byte, f pointer, w int) ([]byte, error) {
- if w != WireFixed32 {
- return b, errInternalBadWireType
- }
- if len(b) < 4 {
- return nil, io.ErrUnexpectedEOF
- }
- v := uint32(b[0]) | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24
- *f.toUint32Ptr() = &v
- return b[4:], nil
-}
-
-func unmarshalFixed32Slice(b []byte, f pointer, w int) ([]byte, error) {
- if w == WireBytes { // packed
- x, n := decodeVarint(b)
- if n == 0 {
- return nil, io.ErrUnexpectedEOF
- }
- b = b[n:]
- if x > uint64(len(b)) {
- return nil, io.ErrUnexpectedEOF
- }
- res := b[x:]
- b = b[:x]
- for len(b) > 0 {
- if len(b) < 4 {
- return nil, io.ErrUnexpectedEOF
- }
- v := uint32(b[0]) | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24
- s := f.toUint32Slice()
- *s = append(*s, v)
- b = b[4:]
- }
- return res, nil
- }
- if w != WireFixed32 {
- return b, errInternalBadWireType
- }
- if len(b) < 4 {
- return nil, io.ErrUnexpectedEOF
- }
- v := uint32(b[0]) | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24
- s := f.toUint32Slice()
- *s = append(*s, v)
- return b[4:], nil
-}
-
-func unmarshalFixedS32Value(b []byte, f pointer, w int) ([]byte, error) {
- if w != WireFixed32 {
- return b, errInternalBadWireType
- }
- if len(b) < 4 {
- return nil, io.ErrUnexpectedEOF
- }
- v := int32(b[0]) | int32(b[1])<<8 | int32(b[2])<<16 | int32(b[3])<<24
- *f.toInt32() = v
- return b[4:], nil
-}
-
-func unmarshalFixedS32Ptr(b []byte, f pointer, w int) ([]byte, error) {
- if w != WireFixed32 {
- return b, errInternalBadWireType
- }
- if len(b) < 4 {
- return nil, io.ErrUnexpectedEOF
- }
- v := int32(b[0]) | int32(b[1])<<8 | int32(b[2])<<16 | int32(b[3])<<24
- f.setInt32Ptr(v)
- return b[4:], nil
-}
-
-func unmarshalFixedS32Slice(b []byte, f pointer, w int) ([]byte, error) {
- if w == WireBytes { // packed
- x, n := decodeVarint(b)
- if n == 0 {
- return nil, io.ErrUnexpectedEOF
- }
- b = b[n:]
- if x > uint64(len(b)) {
- return nil, io.ErrUnexpectedEOF
- }
- res := b[x:]
- b = b[:x]
- for len(b) > 0 {
- if len(b) < 4 {
- return nil, io.ErrUnexpectedEOF
- }
- v := int32(b[0]) | int32(b[1])<<8 | int32(b[2])<<16 | int32(b[3])<<24
- f.appendInt32Slice(v)
- b = b[4:]
- }
- return res, nil
- }
- if w != WireFixed32 {
- return b, errInternalBadWireType
- }
- if len(b) < 4 {
- return nil, io.ErrUnexpectedEOF
- }
- v := int32(b[0]) | int32(b[1])<<8 | int32(b[2])<<16 | int32(b[3])<<24
- f.appendInt32Slice(v)
- return b[4:], nil
-}
-
-func unmarshalBoolValue(b []byte, f pointer, w int) ([]byte, error) {
- if w != WireVarint {
- return b, errInternalBadWireType
- }
- // Note: any length varint is allowed, even though any sane
- // encoder will use one byte.
- // See https://github.com/golang/protobuf/issues/76
- x, n := decodeVarint(b)
- if n == 0 {
- return nil, io.ErrUnexpectedEOF
- }
- // TODO: check if x>1? Tests seem to indicate no.
- v := x != 0
- *f.toBool() = v
- return b[n:], nil
-}
-
-func unmarshalBoolPtr(b []byte, f pointer, w int) ([]byte, error) {
- if w != WireVarint {
- return b, errInternalBadWireType
- }
- x, n := decodeVarint(b)
- if n == 0 {
- return nil, io.ErrUnexpectedEOF
- }
- v := x != 0
- *f.toBoolPtr() = &v
- return b[n:], nil
-}
-
-func unmarshalBoolSlice(b []byte, f pointer, w int) ([]byte, error) {
- if w == WireBytes { // packed
- x, n := decodeVarint(b)
- if n == 0 {
- return nil, io.ErrUnexpectedEOF
- }
- b = b[n:]
- if x > uint64(len(b)) {
- return nil, io.ErrUnexpectedEOF
- }
- res := b[x:]
- b = b[:x]
- for len(b) > 0 {
- x, n = decodeVarint(b)
- if n == 0 {
- return nil, io.ErrUnexpectedEOF
- }
- v := x != 0
- s := f.toBoolSlice()
- *s = append(*s, v)
- b = b[n:]
- }
- return res, nil
- }
- if w != WireVarint {
- return b, errInternalBadWireType
- }
- x, n := decodeVarint(b)
- if n == 0 {
- return nil, io.ErrUnexpectedEOF
- }
- v := x != 0
- s := f.toBoolSlice()
- *s = append(*s, v)
- return b[n:], nil
-}
-
-func unmarshalFloat64Value(b []byte, f pointer, w int) ([]byte, error) {
- if w != WireFixed64 {
- return b, errInternalBadWireType
- }
- if len(b) < 8 {
- return nil, io.ErrUnexpectedEOF
- }
- v := math.Float64frombits(uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24 | uint64(b[4])<<32 | uint64(b[5])<<40 | uint64(b[6])<<48 | uint64(b[7])<<56)
- *f.toFloat64() = v
- return b[8:], nil
-}
-
-func unmarshalFloat64Ptr(b []byte, f pointer, w int) ([]byte, error) {
- if w != WireFixed64 {
- return b, errInternalBadWireType
- }
- if len(b) < 8 {
- return nil, io.ErrUnexpectedEOF
- }
- v := math.Float64frombits(uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24 | uint64(b[4])<<32 | uint64(b[5])<<40 | uint64(b[6])<<48 | uint64(b[7])<<56)
- *f.toFloat64Ptr() = &v
- return b[8:], nil
-}
-
-func unmarshalFloat64Slice(b []byte, f pointer, w int) ([]byte, error) {
- if w == WireBytes { // packed
- x, n := decodeVarint(b)
- if n == 0 {
- return nil, io.ErrUnexpectedEOF
- }
- b = b[n:]
- if x > uint64(len(b)) {
- return nil, io.ErrUnexpectedEOF
- }
- res := b[x:]
- b = b[:x]
- for len(b) > 0 {
- if len(b) < 8 {
- return nil, io.ErrUnexpectedEOF
- }
- v := math.Float64frombits(uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24 | uint64(b[4])<<32 | uint64(b[5])<<40 | uint64(b[6])<<48 | uint64(b[7])<<56)
- s := f.toFloat64Slice()
- *s = append(*s, v)
- b = b[8:]
- }
- return res, nil
- }
- if w != WireFixed64 {
- return b, errInternalBadWireType
- }
- if len(b) < 8 {
- return nil, io.ErrUnexpectedEOF
- }
- v := math.Float64frombits(uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24 | uint64(b[4])<<32 | uint64(b[5])<<40 | uint64(b[6])<<48 | uint64(b[7])<<56)
- s := f.toFloat64Slice()
- *s = append(*s, v)
- return b[8:], nil
-}
-
-func unmarshalFloat32Value(b []byte, f pointer, w int) ([]byte, error) {
- if w != WireFixed32 {
- return b, errInternalBadWireType
- }
- if len(b) < 4 {
- return nil, io.ErrUnexpectedEOF
- }
- v := math.Float32frombits(uint32(b[0]) | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24)
- *f.toFloat32() = v
- return b[4:], nil
-}
-
-func unmarshalFloat32Ptr(b []byte, f pointer, w int) ([]byte, error) {
- if w != WireFixed32 {
- return b, errInternalBadWireType
- }
- if len(b) < 4 {
- return nil, io.ErrUnexpectedEOF
- }
- v := math.Float32frombits(uint32(b[0]) | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24)
- *f.toFloat32Ptr() = &v
- return b[4:], nil
-}
-
-func unmarshalFloat32Slice(b []byte, f pointer, w int) ([]byte, error) {
- if w == WireBytes { // packed
- x, n := decodeVarint(b)
- if n == 0 {
- return nil, io.ErrUnexpectedEOF
- }
- b = b[n:]
- if x > uint64(len(b)) {
- return nil, io.ErrUnexpectedEOF
- }
- res := b[x:]
- b = b[:x]
- for len(b) > 0 {
- if len(b) < 4 {
- return nil, io.ErrUnexpectedEOF
- }
- v := math.Float32frombits(uint32(b[0]) | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24)
- s := f.toFloat32Slice()
- *s = append(*s, v)
- b = b[4:]
- }
- return res, nil
- }
- if w != WireFixed32 {
- return b, errInternalBadWireType
- }
- if len(b) < 4 {
- return nil, io.ErrUnexpectedEOF
- }
- v := math.Float32frombits(uint32(b[0]) | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24)
- s := f.toFloat32Slice()
- *s = append(*s, v)
- return b[4:], nil
-}
-
-func unmarshalStringValue(b []byte, f pointer, w int) ([]byte, error) {
- if w != WireBytes {
- return b, errInternalBadWireType
- }
- x, n := decodeVarint(b)
- if n == 0 {
- return nil, io.ErrUnexpectedEOF
- }
- b = b[n:]
- if x > uint64(len(b)) {
- return nil, io.ErrUnexpectedEOF
- }
- v := string(b[:x])
- if !utf8.ValidString(v) {
- return nil, errInvalidUTF8
- }
- *f.toString() = v
- return b[x:], nil
-}
-
-func unmarshalStringPtr(b []byte, f pointer, w int) ([]byte, error) {
- if w != WireBytes {
- return b, errInternalBadWireType
- }
- x, n := decodeVarint(b)
- if n == 0 {
- return nil, io.ErrUnexpectedEOF
- }
- b = b[n:]
- if x > uint64(len(b)) {
- return nil, io.ErrUnexpectedEOF
- }
- v := string(b[:x])
- if !utf8.ValidString(v) {
- return nil, errInvalidUTF8
- }
- *f.toStringPtr() = &v
- return b[x:], nil
-}
-
-func unmarshalStringSlice(b []byte, f pointer, w int) ([]byte, error) {
- if w != WireBytes {
- return b, errInternalBadWireType
- }
- x, n := decodeVarint(b)
- if n == 0 {
- return nil, io.ErrUnexpectedEOF
- }
- b = b[n:]
- if x > uint64(len(b)) {
- return nil, io.ErrUnexpectedEOF
- }
- v := string(b[:x])
- if !utf8.ValidString(v) {
- return nil, errInvalidUTF8
- }
- s := f.toStringSlice()
- *s = append(*s, v)
- return b[x:], nil
-}
-
-var emptyBuf [0]byte
-
-func unmarshalBytesValue(b []byte, f pointer, w int) ([]byte, error) {
- if w != WireBytes {
- return b, errInternalBadWireType
- }
- x, n := decodeVarint(b)
- if n == 0 {
- return nil, io.ErrUnexpectedEOF
- }
- b = b[n:]
- if x > uint64(len(b)) {
- return nil, io.ErrUnexpectedEOF
- }
- // The use of append here is a trick which avoids the zeroing
- // that would be required if we used a make/copy pair.
- // We append to emptyBuf instead of nil because we want
- // a non-nil result even when the length is 0.
- v := append(emptyBuf[:], b[:x]...)
- *f.toBytes() = v
- return b[x:], nil
-}
-
-func unmarshalBytesSlice(b []byte, f pointer, w int) ([]byte, error) {
- if w != WireBytes {
- return b, errInternalBadWireType
- }
- x, n := decodeVarint(b)
- if n == 0 {
- return nil, io.ErrUnexpectedEOF
- }
- b = b[n:]
- if x > uint64(len(b)) {
- return nil, io.ErrUnexpectedEOF
- }
- v := append(emptyBuf[:], b[:x]...)
- s := f.toBytesSlice()
- *s = append(*s, v)
- return b[x:], nil
-}
-
-func makeUnmarshalMessagePtr(sub *unmarshalInfo, name string) unmarshaler {
- return func(b []byte, f pointer, w int) ([]byte, error) {
- if w != WireBytes {
- return b, errInternalBadWireType
- }
- x, n := decodeVarint(b)
- if n == 0 {
- return nil, io.ErrUnexpectedEOF
- }
- b = b[n:]
- if x > uint64(len(b)) {
- return nil, io.ErrUnexpectedEOF
- }
- // First read the message field to see if something is there.
- // The semantics of multiple submessages are weird. Instead of
- // the last one winning (as it is for all other fields), multiple
- // submessages are merged.
- v := f.getPointer()
- if v.isNil() {
- v = valToPointer(reflect.New(sub.typ))
- f.setPointer(v)
- }
- err := sub.unmarshal(v, b[:x])
- if err != nil {
- if r, ok := err.(*RequiredNotSetError); ok {
- r.field = name + "." + r.field
- } else {
- return nil, err
- }
- }
- return b[x:], err
- }
-}
-
-func makeUnmarshalMessageSlicePtr(sub *unmarshalInfo, name string) unmarshaler {
- return func(b []byte, f pointer, w int) ([]byte, error) {
- if w != WireBytes {
- return b, errInternalBadWireType
- }
- x, n := decodeVarint(b)
- if n == 0 {
- return nil, io.ErrUnexpectedEOF
- }
- b = b[n:]
- if x > uint64(len(b)) {
- return nil, io.ErrUnexpectedEOF
- }
- v := valToPointer(reflect.New(sub.typ))
- err := sub.unmarshal(v, b[:x])
- if err != nil {
- if r, ok := err.(*RequiredNotSetError); ok {
- r.field = name + "." + r.field
- } else {
- return nil, err
- }
- }
- f.appendPointer(v)
- return b[x:], err
- }
-}
-
-func makeUnmarshalGroupPtr(sub *unmarshalInfo, name string) unmarshaler {
- return func(b []byte, f pointer, w int) ([]byte, error) {
- if w != WireStartGroup {
- return b, errInternalBadWireType
- }
- x, y := findEndGroup(b)
- if x < 0 {
- return nil, io.ErrUnexpectedEOF
- }
- v := f.getPointer()
- if v.isNil() {
- v = valToPointer(reflect.New(sub.typ))
- f.setPointer(v)
- }
- err := sub.unmarshal(v, b[:x])
- if err != nil {
- if r, ok := err.(*RequiredNotSetError); ok {
- r.field = name + "." + r.field
- } else {
- return nil, err
- }
- }
- return b[y:], err
- }
-}
-
-func makeUnmarshalGroupSlicePtr(sub *unmarshalInfo, name string) unmarshaler {
- return func(b []byte, f pointer, w int) ([]byte, error) {
- if w != WireStartGroup {
- return b, errInternalBadWireType
- }
- x, y := findEndGroup(b)
- if x < 0 {
- return nil, io.ErrUnexpectedEOF
- }
- v := valToPointer(reflect.New(sub.typ))
- err := sub.unmarshal(v, b[:x])
- if err != nil {
- if r, ok := err.(*RequiredNotSetError); ok {
- r.field = name + "." + r.field
- } else {
- return nil, err
- }
- }
- f.appendPointer(v)
- return b[y:], err
- }
-}
-
-func makeUnmarshalMap(f *reflect.StructField) unmarshaler {
- t := f.Type
- kt := t.Key()
- vt := t.Elem()
- tagArray := strings.Split(f.Tag.Get("protobuf"), ",")
- valTags := strings.Split(f.Tag.Get("protobuf_val"), ",")
- for _, t := range tagArray {
- if strings.HasPrefix(t, "customtype=") {
- valTags = append(valTags, t)
- }
- if t == "stdtime" {
- valTags = append(valTags, t)
- }
- if t == "stdduration" {
- valTags = append(valTags, t)
- }
- }
- unmarshalKey := typeUnmarshaler(kt, f.Tag.Get("protobuf_key"))
- unmarshalVal := typeUnmarshaler(vt, strings.Join(valTags, ","))
- return func(b []byte, f pointer, w int) ([]byte, error) {
- // The map entry is a submessage. Figure out how big it is.
- if w != WireBytes {
- return nil, fmt.Errorf("proto: bad wiretype for map field: got %d want %d", w, WireBytes)
- }
- x, n := decodeVarint(b)
- if n == 0 {
- return nil, io.ErrUnexpectedEOF
- }
- b = b[n:]
- if x > uint64(len(b)) {
- return nil, io.ErrUnexpectedEOF
- }
- r := b[x:] // unused data to return
- b = b[:x] // data for map entry
-
- // Note: we could use #keys * #values ~= 200 functions
- // to do map decoding without reflection. Probably not worth it.
- // Maps will be somewhat slow. Oh well.
-
- // Read key and value from data.
- k := reflect.New(kt)
- v := reflect.New(vt)
- for len(b) > 0 {
- x, n := decodeVarint(b)
- if n == 0 {
- return nil, io.ErrUnexpectedEOF
- }
- wire := int(x) & 7
- b = b[n:]
-
- var err error
- switch x >> 3 {
- case 1:
- b, err = unmarshalKey(b, valToPointer(k), wire)
- case 2:
- b, err = unmarshalVal(b, valToPointer(v), wire)
- default:
- err = errInternalBadWireType // skip unknown tag
- }
-
- if err == nil {
- continue
- }
- if err != errInternalBadWireType {
- return nil, err
- }
-
- // Skip past unknown fields.
- b, err = skipField(b, wire)
- if err != nil {
- return nil, err
- }
- }
-
- // Get map, allocate if needed.
- m := f.asPointerTo(t).Elem() // an addressable map[K]T
- if m.IsNil() {
- m.Set(reflect.MakeMap(t))
- }
-
- // Insert into map.
- m.SetMapIndex(k.Elem(), v.Elem())
-
- return r, nil
- }
-}
-
-// makeUnmarshalOneof makes an unmarshaler for oneof fields.
-// for:
-// message Msg {
-// oneof F {
-// int64 X = 1;
-// float64 Y = 2;
-// }
-// }
-// typ is the type of the concrete entry for a oneof case (e.g. Msg_X).
-// ityp is the interface type of the oneof field (e.g. isMsg_F).
-// unmarshal is the unmarshaler for the base type of the oneof case (e.g. int64).
-// Note that this function will be called once for each case in the oneof.
-func makeUnmarshalOneof(typ, ityp reflect.Type, unmarshal unmarshaler) unmarshaler {
- sf := typ.Field(0)
- field0 := toField(&sf)
- return func(b []byte, f pointer, w int) ([]byte, error) {
- // Allocate holder for value.
- v := reflect.New(typ)
-
- // Unmarshal data into holder.
- // We unmarshal into the first field of the holder object.
- var err error
- b, err = unmarshal(b, valToPointer(v).offset(field0), w)
- if err != nil {
- return nil, err
- }
-
- // Write pointer to holder into target field.
- f.asPointerTo(ityp).Elem().Set(v)
-
- return b, nil
- }
-}
-
-// Error used by decode internally.
-var errInternalBadWireType = errors.New("proto: internal error: bad wiretype")
-
-// skipField skips past a field of type wire and returns the remaining bytes.
-func skipField(b []byte, wire int) ([]byte, error) {
- switch wire {
- case WireVarint:
- _, k := decodeVarint(b)
- if k == 0 {
- return b, io.ErrUnexpectedEOF
- }
- b = b[k:]
- case WireFixed32:
- if len(b) < 4 {
- return b, io.ErrUnexpectedEOF
- }
- b = b[4:]
- case WireFixed64:
- if len(b) < 8 {
- return b, io.ErrUnexpectedEOF
- }
- b = b[8:]
- case WireBytes:
- m, k := decodeVarint(b)
- if k == 0 || uint64(len(b)-k) < m {
- return b, io.ErrUnexpectedEOF
- }
- b = b[uint64(k)+m:]
- case WireStartGroup:
- _, i := findEndGroup(b)
- if i == -1 {
- return b, io.ErrUnexpectedEOF
- }
- b = b[i:]
- default:
- return b, fmt.Errorf("proto: can't skip unknown wire type %d", wire)
- }
- return b, nil
-}
-
-// findEndGroup finds the index of the next EndGroup tag.
-// Groups may be nested, so the "next" EndGroup tag is the first
-// unpaired EndGroup.
-// findEndGroup returns the indexes of the start and end of the EndGroup tag.
-// Returns (-1,-1) if it can't find one.
-func findEndGroup(b []byte) (int, int) {
- depth := 1
- i := 0
- for {
- x, n := decodeVarint(b[i:])
- if n == 0 {
- return -1, -1
- }
- j := i
- i += n
- switch x & 7 {
- case WireVarint:
- _, k := decodeVarint(b[i:])
- if k == 0 {
- return -1, -1
- }
- i += k
- case WireFixed32:
- if len(b)-4 < i {
- return -1, -1
- }
- i += 4
- case WireFixed64:
- if len(b)-8 < i {
- return -1, -1
- }
- i += 8
- case WireBytes:
- m, k := decodeVarint(b[i:])
- if k == 0 {
- return -1, -1
- }
- i += k
- if uint64(len(b)-i) < m {
- return -1, -1
- }
- i += int(m)
- case WireStartGroup:
- depth++
- case WireEndGroup:
- depth--
- if depth == 0 {
- return j, i
- }
- default:
- return -1, -1
- }
- }
-}
-
-// encodeVarint appends a varint-encoded integer to b and returns the result.
-func encodeVarint(b []byte, x uint64) []byte {
- for x >= 1<<7 {
- b = append(b, byte(x&0x7f|0x80))
- x >>= 7
- }
- return append(b, byte(x))
-}
-
-// decodeVarint reads a varint-encoded integer from b.
-// Returns the decoded integer and the number of bytes read.
-// If there is an error, it returns 0,0.
-func decodeVarint(b []byte) (uint64, int) {
- var x, y uint64
- if len(b) <= 0 {
- goto bad
- }
- x = uint64(b[0])
- if x < 0x80 {
- return x, 1
- }
- x -= 0x80
-
- if len(b) <= 1 {
- goto bad
- }
- y = uint64(b[1])
- x += y << 7
- if y < 0x80 {
- return x, 2
- }
- x -= 0x80 << 7
-
- if len(b) <= 2 {
- goto bad
- }
- y = uint64(b[2])
- x += y << 14
- if y < 0x80 {
- return x, 3
- }
- x -= 0x80 << 14
-
- if len(b) <= 3 {
- goto bad
- }
- y = uint64(b[3])
- x += y << 21
- if y < 0x80 {
- return x, 4
- }
- x -= 0x80 << 21
-
- if len(b) <= 4 {
- goto bad
- }
- y = uint64(b[4])
- x += y << 28
- if y < 0x80 {
- return x, 5
- }
- x -= 0x80 << 28
-
- if len(b) <= 5 {
- goto bad
- }
- y = uint64(b[5])
- x += y << 35
- if y < 0x80 {
- return x, 6
- }
- x -= 0x80 << 35
-
- if len(b) <= 6 {
- goto bad
- }
- y = uint64(b[6])
- x += y << 42
- if y < 0x80 {
- return x, 7
- }
- x -= 0x80 << 42
-
- if len(b) <= 7 {
- goto bad
- }
- y = uint64(b[7])
- x += y << 49
- if y < 0x80 {
- return x, 8
- }
- x -= 0x80 << 49
-
- if len(b) <= 8 {
- goto bad
- }
- y = uint64(b[8])
- x += y << 56
- if y < 0x80 {
- return x, 9
- }
- x -= 0x80 << 56
-
- if len(b) <= 9 {
- goto bad
- }
- y = uint64(b[9])
- x += y << 63
- if y < 2 {
- return x, 10
- }
-
-bad:
- return 0, 0
-}
diff --git a/vendor/github.com/gogo/protobuf/proto/table_unmarshal_gogo.go b/vendor/github.com/gogo/protobuf/proto/table_unmarshal_gogo.go
deleted file mode 100644
index 00d6c7ad93..0000000000
--- a/vendor/github.com/gogo/protobuf/proto/table_unmarshal_gogo.go
+++ /dev/null
@@ -1,385 +0,0 @@
-// Protocol Buffers for Go with Gadgets
-//
-// Copyright (c) 2018, The GoGo Authors. All rights reserved.
-// http://github.com/gogo/protobuf
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-package proto
-
-import (
- "io"
- "reflect"
-)
-
-func makeUnmarshalMessage(sub *unmarshalInfo, name string) unmarshaler {
- return func(b []byte, f pointer, w int) ([]byte, error) {
- if w != WireBytes {
- return nil, errInternalBadWireType
- }
- x, n := decodeVarint(b)
- if n == 0 {
- return nil, io.ErrUnexpectedEOF
- }
- b = b[n:]
- if x > uint64(len(b)) {
- return nil, io.ErrUnexpectedEOF
- }
- // First read the message field to see if something is there.
- // The semantics of multiple submessages are weird. Instead of
- // the last one winning (as it is for all other fields), multiple
- // submessages are merged.
- v := f // gogo: changed from v := f.getPointer()
- if v.isNil() {
- v = valToPointer(reflect.New(sub.typ))
- f.setPointer(v)
- }
- err := sub.unmarshal(v, b[:x])
- if err != nil {
- if r, ok := err.(*RequiredNotSetError); ok {
- r.field = name + "." + r.field
- } else {
- return nil, err
- }
- }
- return b[x:], err
- }
-}
-
-func makeUnmarshalMessageSlice(sub *unmarshalInfo, name string) unmarshaler {
- return func(b []byte, f pointer, w int) ([]byte, error) {
- if w != WireBytes {
- return nil, errInternalBadWireType
- }
- x, n := decodeVarint(b)
- if n == 0 {
- return nil, io.ErrUnexpectedEOF
- }
- b = b[n:]
- if x > uint64(len(b)) {
- return nil, io.ErrUnexpectedEOF
- }
- v := valToPointer(reflect.New(sub.typ))
- err := sub.unmarshal(v, b[:x])
- if err != nil {
- if r, ok := err.(*RequiredNotSetError); ok {
- r.field = name + "." + r.field
- } else {
- return nil, err
- }
- }
- f.appendRef(v, sub.typ) // gogo: changed from f.appendPointer(v)
- return b[x:], err
- }
-}
-
-func makeUnmarshalCustomPtr(sub *unmarshalInfo, name string) unmarshaler {
- return func(b []byte, f pointer, w int) ([]byte, error) {
- if w != WireBytes {
- return nil, errInternalBadWireType
- }
- x, n := decodeVarint(b)
- if n == 0 {
- return nil, io.ErrUnexpectedEOF
- }
- b = b[n:]
- if x > uint64(len(b)) {
- return nil, io.ErrUnexpectedEOF
- }
-
- s := f.asPointerTo(reflect.PtrTo(sub.typ)).Elem()
- s.Set(reflect.New(sub.typ))
- m := s.Interface().(custom)
- if err := m.Unmarshal(b[:x]); err != nil {
- return nil, err
- }
- return b[x:], nil
- }
-}
-
-func makeUnmarshalCustomSlice(sub *unmarshalInfo, name string) unmarshaler {
- return func(b []byte, f pointer, w int) ([]byte, error) {
- if w != WireBytes {
- return nil, errInternalBadWireType
- }
- x, n := decodeVarint(b)
- if n == 0 {
- return nil, io.ErrUnexpectedEOF
- }
- b = b[n:]
- if x > uint64(len(b)) {
- return nil, io.ErrUnexpectedEOF
- }
- m := reflect.New(sub.typ)
- c := m.Interface().(custom)
- if err := c.Unmarshal(b[:x]); err != nil {
- return nil, err
- }
- v := valToPointer(m)
- f.appendRef(v, sub.typ)
- return b[x:], nil
- }
-}
-
-func makeUnmarshalCustom(sub *unmarshalInfo, name string) unmarshaler {
- return func(b []byte, f pointer, w int) ([]byte, error) {
- if w != WireBytes {
- return nil, errInternalBadWireType
- }
- x, n := decodeVarint(b)
- if n == 0 {
- return nil, io.ErrUnexpectedEOF
- }
- b = b[n:]
- if x > uint64(len(b)) {
- return nil, io.ErrUnexpectedEOF
- }
-
- m := f.asPointerTo(sub.typ).Interface().(custom)
- if err := m.Unmarshal(b[:x]); err != nil {
- return nil, err
- }
- return b[x:], nil
- }
-}
-
-func makeUnmarshalTime(sub *unmarshalInfo, name string) unmarshaler {
- return func(b []byte, f pointer, w int) ([]byte, error) {
- if w != WireBytes {
- return nil, errInternalBadWireType
- }
- x, n := decodeVarint(b)
- if n == 0 {
- return nil, io.ErrUnexpectedEOF
- }
- b = b[n:]
- if x > uint64(len(b)) {
- return nil, io.ErrUnexpectedEOF
- }
- m := ×tamp{}
- if err := Unmarshal(b[:x], m); err != nil {
- return nil, err
- }
- t, err := timestampFromProto(m)
- if err != nil {
- return nil, err
- }
- s := f.asPointerTo(sub.typ).Elem()
- s.Set(reflect.ValueOf(t))
- return b[x:], nil
- }
-}
-
-func makeUnmarshalTimePtr(sub *unmarshalInfo, name string) unmarshaler {
- return func(b []byte, f pointer, w int) ([]byte, error) {
- if w != WireBytes {
- return nil, errInternalBadWireType
- }
- x, n := decodeVarint(b)
- if n == 0 {
- return nil, io.ErrUnexpectedEOF
- }
- b = b[n:]
- if x > uint64(len(b)) {
- return nil, io.ErrUnexpectedEOF
- }
- m := ×tamp{}
- if err := Unmarshal(b[:x], m); err != nil {
- return nil, err
- }
- t, err := timestampFromProto(m)
- if err != nil {
- return nil, err
- }
- s := f.asPointerTo(reflect.PtrTo(sub.typ)).Elem()
- s.Set(reflect.ValueOf(&t))
- return b[x:], nil
- }
-}
-
-func makeUnmarshalTimePtrSlice(sub *unmarshalInfo, name string) unmarshaler {
- return func(b []byte, f pointer, w int) ([]byte, error) {
- if w != WireBytes {
- return nil, errInternalBadWireType
- }
- x, n := decodeVarint(b)
- if n == 0 {
- return nil, io.ErrUnexpectedEOF
- }
- b = b[n:]
- if x > uint64(len(b)) {
- return nil, io.ErrUnexpectedEOF
- }
- m := ×tamp{}
- if err := Unmarshal(b[:x], m); err != nil {
- return nil, err
- }
- t, err := timestampFromProto(m)
- if err != nil {
- return nil, err
- }
- slice := f.getSlice(reflect.PtrTo(sub.typ))
- newSlice := reflect.Append(slice, reflect.ValueOf(&t))
- slice.Set(newSlice)
- return b[x:], nil
- }
-}
-
-func makeUnmarshalTimeSlice(sub *unmarshalInfo, name string) unmarshaler {
- return func(b []byte, f pointer, w int) ([]byte, error) {
- if w != WireBytes {
- return nil, errInternalBadWireType
- }
- x, n := decodeVarint(b)
- if n == 0 {
- return nil, io.ErrUnexpectedEOF
- }
- b = b[n:]
- if x > uint64(len(b)) {
- return nil, io.ErrUnexpectedEOF
- }
- m := ×tamp{}
- if err := Unmarshal(b[:x], m); err != nil {
- return nil, err
- }
- t, err := timestampFromProto(m)
- if err != nil {
- return nil, err
- }
- slice := f.getSlice(sub.typ)
- newSlice := reflect.Append(slice, reflect.ValueOf(t))
- slice.Set(newSlice)
- return b[x:], nil
- }
-}
-
-func makeUnmarshalDurationPtr(sub *unmarshalInfo, name string) unmarshaler {
- return func(b []byte, f pointer, w int) ([]byte, error) {
- if w != WireBytes {
- return nil, errInternalBadWireType
- }
- x, n := decodeVarint(b)
- if n == 0 {
- return nil, io.ErrUnexpectedEOF
- }
- b = b[n:]
- if x > uint64(len(b)) {
- return nil, io.ErrUnexpectedEOF
- }
- m := &duration{}
- if err := Unmarshal(b[:x], m); err != nil {
- return nil, err
- }
- d, err := durationFromProto(m)
- if err != nil {
- return nil, err
- }
- s := f.asPointerTo(reflect.PtrTo(sub.typ)).Elem()
- s.Set(reflect.ValueOf(&d))
- return b[x:], nil
- }
-}
-
-func makeUnmarshalDuration(sub *unmarshalInfo, name string) unmarshaler {
- return func(b []byte, f pointer, w int) ([]byte, error) {
- if w != WireBytes {
- return nil, errInternalBadWireType
- }
- x, n := decodeVarint(b)
- if n == 0 {
- return nil, io.ErrUnexpectedEOF
- }
- b = b[n:]
- if x > uint64(len(b)) {
- return nil, io.ErrUnexpectedEOF
- }
- m := &duration{}
- if err := Unmarshal(b[:x], m); err != nil {
- return nil, err
- }
- d, err := durationFromProto(m)
- if err != nil {
- return nil, err
- }
- s := f.asPointerTo(sub.typ).Elem()
- s.Set(reflect.ValueOf(d))
- return b[x:], nil
- }
-}
-
-func makeUnmarshalDurationPtrSlice(sub *unmarshalInfo, name string) unmarshaler {
- return func(b []byte, f pointer, w int) ([]byte, error) {
- if w != WireBytes {
- return nil, errInternalBadWireType
- }
- x, n := decodeVarint(b)
- if n == 0 {
- return nil, io.ErrUnexpectedEOF
- }
- b = b[n:]
- if x > uint64(len(b)) {
- return nil, io.ErrUnexpectedEOF
- }
- m := &duration{}
- if err := Unmarshal(b[:x], m); err != nil {
- return nil, err
- }
- d, err := durationFromProto(m)
- if err != nil {
- return nil, err
- }
- slice := f.getSlice(reflect.PtrTo(sub.typ))
- newSlice := reflect.Append(slice, reflect.ValueOf(&d))
- slice.Set(newSlice)
- return b[x:], nil
- }
-}
-
-func makeUnmarshalDurationSlice(sub *unmarshalInfo, name string) unmarshaler {
- return func(b []byte, f pointer, w int) ([]byte, error) {
- if w != WireBytes {
- return nil, errInternalBadWireType
- }
- x, n := decodeVarint(b)
- if n == 0 {
- return nil, io.ErrUnexpectedEOF
- }
- b = b[n:]
- if x > uint64(len(b)) {
- return nil, io.ErrUnexpectedEOF
- }
- m := &duration{}
- if err := Unmarshal(b[:x], m); err != nil {
- return nil, err
- }
- d, err := durationFromProto(m)
- if err != nil {
- return nil, err
- }
- slice := f.getSlice(sub.typ)
- newSlice := reflect.Append(slice, reflect.ValueOf(d))
- slice.Set(newSlice)
- return b[x:], nil
- }
-}
diff --git a/vendor/github.com/gogo/protobuf/proto/text.go b/vendor/github.com/gogo/protobuf/proto/text.go
index 4f5706dc5f..f609d1d453 100644
--- a/vendor/github.com/gogo/protobuf/proto/text.go
+++ b/vendor/github.com/gogo/protobuf/proto/text.go
@@ -57,6 +57,7 @@ import (
var (
newline = []byte("\n")
spaces = []byte(" ")
+ gtNewline = []byte(">\n")
endBraceNewline = []byte("}\n")
backslashN = []byte{'\\', 'n'}
backslashR = []byte{'\\', 'r'}
@@ -176,6 +177,11 @@ func writeName(w *textWriter, props *Properties) error {
return nil
}
+// raw is the interface satisfied by RawMessage.
+type raw interface {
+ Bytes() []byte
+}
+
func requiresQuotes(u string) bool {
// When type URL contains any characters except [0-9A-Za-z./\-]*, it must be quoted.
for _, ch := range u {
@@ -270,10 +276,6 @@ func (tm *TextMarshaler) writeStruct(w *textWriter, sv reflect.Value) error {
props := sprops.Prop[i]
name := st.Field(i).Name
- if name == "XXX_NoUnkeyedLiteral" {
- continue
- }
-
if strings.HasPrefix(name, "XXX_") {
// There are two XXX_ fields:
// XXX_unrecognized []byte
@@ -445,6 +447,12 @@ func (tm *TextMarshaler) writeStruct(w *textWriter, sv reflect.Value) error {
return err
}
}
+ if b, ok := fv.Interface().(raw); ok {
+ if err := writeRaw(w, b.Bytes()); err != nil {
+ return err
+ }
+ continue
+ }
if len(props.Enum) > 0 {
if err := tm.writeEnum(w, fv, props); err != nil {
@@ -467,7 +475,7 @@ func (tm *TextMarshaler) writeStruct(w *textWriter, sv reflect.Value) error {
pv = reflect.New(sv.Type())
pv.Elem().Set(sv)
}
- if _, err := extendable(pv.Interface()); err == nil {
+ if pv.Type().Implements(extensionRangeType) {
if err := tm.writeExtensions(w, pv); err != nil {
return err
}
@@ -476,6 +484,27 @@ func (tm *TextMarshaler) writeStruct(w *textWriter, sv reflect.Value) error {
return nil
}
+// writeRaw writes an uninterpreted raw message.
+func writeRaw(w *textWriter, b []byte) error {
+ if err := w.WriteByte('<'); err != nil {
+ return err
+ }
+ if !w.compact {
+ if err := w.WriteByte('\n'); err != nil {
+ return err
+ }
+ }
+ w.indent()
+ if err := writeUnknownStruct(w, b); err != nil {
+ return err
+ }
+ w.unindent()
+ if err := w.WriteByte('>'); err != nil {
+ return err
+ }
+ return nil
+}
+
// writeAny writes an arbitrary field.
func (tm *TextMarshaler) writeAny(w *textWriter, v reflect.Value, props *Properties) error {
v = reflect.Indirect(v)
@@ -576,19 +605,6 @@ func (tm *TextMarshaler) writeAny(w *textWriter, v reflect.Value, props *Propert
}
}
w.indent()
- if v.CanAddr() {
- // Calling v.Interface on a struct causes the reflect package to
- // copy the entire struct. This is racy with the new Marshaler
- // since we atomically update the XXX_sizecache.
- //
- // Thus, we retrieve a pointer to the struct if possible to avoid
- // a race since v.Interface on the pointer doesn't copy the struct.
- //
- // If v is not addressable, then we are not worried about a race
- // since it implies that the binary Marshaler cannot possibly be
- // mutating this value.
- v = v.Addr()
- }
if etm, ok := v.Interface().(encoding.TextMarshaler); ok {
text, err := etm.MarshalText()
if err != nil {
@@ -597,13 +613,8 @@ func (tm *TextMarshaler) writeAny(w *textWriter, v reflect.Value, props *Propert
if _, err = w.Write(text); err != nil {
return err
}
- } else {
- if v.Kind() == reflect.Ptr {
- v = v.Elem()
- }
- if err := tm.writeStruct(w, v); err != nil {
- return err
- }
+ } else if err := tm.writeStruct(w, v); err != nil {
+ return err
}
w.unindent()
if err := w.WriteByte(ket); err != nil {
diff --git a/vendor/github.com/gogo/protobuf/proto/text_parser.go b/vendor/github.com/gogo/protobuf/proto/text_parser.go
index fbb000d374..f1276729a3 100644
--- a/vendor/github.com/gogo/protobuf/proto/text_parser.go
+++ b/vendor/github.com/gogo/protobuf/proto/text_parser.go
@@ -212,6 +212,7 @@ func (p *textParser) advance() {
var (
errBadUTF8 = errors.New("proto: bad UTF-8")
+ errBadHex = errors.New("proto: bad hexadecimal")
)
func unquoteC(s string, quote rune) (string, error) {
@@ -282,47 +283,60 @@ func unescape(s string) (ch string, tail string, err error) {
return "?", s, nil // trigraph workaround
case '\'', '"', '\\':
return string(r), s, nil
- case '0', '1', '2', '3', '4', '5', '6', '7':
+ case '0', '1', '2', '3', '4', '5', '6', '7', 'x', 'X':
if len(s) < 2 {
return "", "", fmt.Errorf(`\%c requires 2 following digits`, r)
}
- ss := string(r) + s[:2]
+ base := 8
+ ss := s[:2]
s = s[2:]
- i, err := strconv.ParseUint(ss, 8, 8)
+ if r == 'x' || r == 'X' {
+ base = 16
+ } else {
+ ss = string(r) + ss
+ }
+ i, err := strconv.ParseUint(ss, base, 8)
if err != nil {
- return "", "", fmt.Errorf(`\%s contains non-octal digits`, ss)
+ return "", "", err
}
return string([]byte{byte(i)}), s, nil
- case 'x', 'X', 'u', 'U':
- var n int
- switch r {
- case 'x', 'X':
- n = 2
- case 'u':
- n = 4
- case 'U':
+ case 'u', 'U':
+ n := 4
+ if r == 'U' {
n = 8
}
if len(s) < n {
- return "", "", fmt.Errorf(`\%c requires %d following digits`, r, n)
+ return "", "", fmt.Errorf(`\%c requires %d digits`, r, n)
+ }
+
+ bs := make([]byte, n/2)
+ for i := 0; i < n; i += 2 {
+ a, ok1 := unhex(s[i])
+ b, ok2 := unhex(s[i+1])
+ if !ok1 || !ok2 {
+ return "", "", errBadHex
+ }
+ bs[i/2] = a<<4 | b
}
- ss := s[:n]
s = s[n:]
- i, err := strconv.ParseUint(ss, 16, 64)
- if err != nil {
- return "", "", fmt.Errorf(`\%c%s contains non-hexadecimal digits`, r, ss)
- }
- if r == 'x' || r == 'X' {
- return string([]byte{byte(i)}), s, nil
- }
- if i > utf8.MaxRune {
- return "", "", fmt.Errorf(`\%c%s is not a valid Unicode code point`, r, ss)
- }
- return string(i), s, nil
+ return string(bs), s, nil
}
return "", "", fmt.Errorf(`unknown escape \%c`, r)
}
+// Adapted from src/pkg/strconv/quote.go.
+func unhex(b byte) (v byte, ok bool) {
+ switch {
+ case '0' <= b && b <= '9':
+ return b - '0', true
+ case 'a' <= b && b <= 'f':
+ return b - 'a' + 10, true
+ case 'A' <= b && b <= 'F':
+ return b - 'A' + 10, true
+ }
+ return 0, false
+}
+
// Back off the parser by one token. Can only be done between calls to next().
// It makes the next advance() a no-op.
func (p *textParser) back() { p.backed = true }
@@ -720,9 +734,6 @@ func (p *textParser) consumeExtName() (string, error) {
if tok.err != nil {
return "", p.errorf("unrecognized type_url or extension name: %s", tok.err)
}
- if p.done && tok.value != "]" {
- return "", p.errorf("unclosed type_url or extension name")
- }
}
return strings.Join(parts, ""), nil
}
@@ -972,7 +983,7 @@ func (p *textParser) readAny(v reflect.Value, props *Properties) error {
return p.readStruct(fv, terminator)
case reflect.Uint32:
if x, err := strconv.ParseUint(tok.value, 0, 32); err == nil {
- fv.SetUint(uint64(x))
+ fv.SetUint(x)
return nil
}
case reflect.Uint64:
@@ -990,9 +1001,13 @@ func (p *textParser) readAny(v reflect.Value, props *Properties) error {
// UnmarshalText returns *RequiredNotSetError.
func UnmarshalText(s string, pb Message) error {
if um, ok := pb.(encoding.TextUnmarshaler); ok {
- return um.UnmarshalText([]byte(s))
+ err := um.UnmarshalText([]byte(s))
+ return err
}
pb.Reset()
v := reflect.ValueOf(pb)
- return newTextParser(s).readStruct(v.Elem(), "")
+ if pe := newTextParser(s).readStruct(v.Elem(), ""); pe != nil {
+ return pe
+ }
+ return nil
}
diff --git a/vendor/github.com/gogo/protobuf/proto/timestamp_gogo.go b/vendor/github.com/gogo/protobuf/proto/timestamp_gogo.go
index 38439fa990..d427647436 100644
--- a/vendor/github.com/gogo/protobuf/proto/timestamp_gogo.go
+++ b/vendor/github.com/gogo/protobuf/proto/timestamp_gogo.go
@@ -47,3 +47,183 @@ func (*timestamp) String() string { return "timestamp" }
func init() {
RegisterType((*timestamp)(nil), "gogo.protobuf.proto.timestamp")
}
+
+func (o *Buffer) decTimestamp() (time.Time, error) {
+ b, err := o.DecodeRawBytes(true)
+ if err != nil {
+ return time.Time{}, err
+ }
+ tproto := ×tamp{}
+ if err := Unmarshal(b, tproto); err != nil {
+ return time.Time{}, err
+ }
+ return timestampFromProto(tproto)
+}
+
+func (o *Buffer) dec_time(p *Properties, base structPointer) error {
+ t, err := o.decTimestamp()
+ if err != nil {
+ return err
+ }
+ setPtrCustomType(base, p.field, &t)
+ return nil
+}
+
+func (o *Buffer) dec_ref_time(p *Properties, base structPointer) error {
+ t, err := o.decTimestamp()
+ if err != nil {
+ return err
+ }
+ setCustomType(base, p.field, &t)
+ return nil
+}
+
+func (o *Buffer) dec_slice_time(p *Properties, base structPointer) error {
+ t, err := o.decTimestamp()
+ if err != nil {
+ return err
+ }
+ newBas := appendStructPointer(base, p.field, reflect.SliceOf(reflect.PtrTo(timeType)))
+ var zero field
+ setPtrCustomType(newBas, zero, &t)
+ return nil
+}
+
+func (o *Buffer) dec_slice_ref_time(p *Properties, base structPointer) error {
+ t, err := o.decTimestamp()
+ if err != nil {
+ return err
+ }
+ newBas := appendStructPointer(base, p.field, reflect.SliceOf(timeType))
+ var zero field
+ setCustomType(newBas, zero, &t)
+ return nil
+}
+
+func size_time(p *Properties, base structPointer) (n int) {
+ structp := structPointer_GetStructPointer(base, p.field)
+ if structPointer_IsNil(structp) {
+ return 0
+ }
+ tim := structPointer_Interface(structp, timeType).(*time.Time)
+ t, err := timestampProto(*tim)
+ if err != nil {
+ return 0
+ }
+ size := Size(t)
+ return size + sizeVarint(uint64(size)) + len(p.tagcode)
+}
+
+func (o *Buffer) enc_time(p *Properties, base structPointer) error {
+ structp := structPointer_GetStructPointer(base, p.field)
+ if structPointer_IsNil(structp) {
+ return ErrNil
+ }
+ tim := structPointer_Interface(structp, timeType).(*time.Time)
+ t, err := timestampProto(*tim)
+ if err != nil {
+ return err
+ }
+ data, err := Marshal(t)
+ if err != nil {
+ return err
+ }
+ o.buf = append(o.buf, p.tagcode...)
+ o.EncodeRawBytes(data)
+ return nil
+}
+
+func size_ref_time(p *Properties, base structPointer) (n int) {
+ tim := structPointer_InterfaceAt(base, p.field, timeType).(*time.Time)
+ t, err := timestampProto(*tim)
+ if err != nil {
+ return 0
+ }
+ size := Size(t)
+ return size + sizeVarint(uint64(size)) + len(p.tagcode)
+}
+
+func (o *Buffer) enc_ref_time(p *Properties, base structPointer) error {
+ tim := structPointer_InterfaceAt(base, p.field, timeType).(*time.Time)
+ t, err := timestampProto(*tim)
+ if err != nil {
+ return err
+ }
+ data, err := Marshal(t)
+ if err != nil {
+ return err
+ }
+ o.buf = append(o.buf, p.tagcode...)
+ o.EncodeRawBytes(data)
+ return nil
+}
+
+func size_slice_time(p *Properties, base structPointer) (n int) {
+ ptims := structPointer_InterfaceAt(base, p.field, reflect.SliceOf(reflect.PtrTo(timeType))).(*[]*time.Time)
+ tims := *ptims
+ for i := 0; i < len(tims); i++ {
+ if tims[i] == nil {
+ return 0
+ }
+ tproto, err := timestampProto(*tims[i])
+ if err != nil {
+ return 0
+ }
+ size := Size(tproto)
+ n += len(p.tagcode) + size + sizeVarint(uint64(size))
+ }
+ return n
+}
+
+func (o *Buffer) enc_slice_time(p *Properties, base structPointer) error {
+ ptims := structPointer_InterfaceAt(base, p.field, reflect.SliceOf(reflect.PtrTo(timeType))).(*[]*time.Time)
+ tims := *ptims
+ for i := 0; i < len(tims); i++ {
+ if tims[i] == nil {
+ return errRepeatedHasNil
+ }
+ tproto, err := timestampProto(*tims[i])
+ if err != nil {
+ return err
+ }
+ data, err := Marshal(tproto)
+ if err != nil {
+ return err
+ }
+ o.buf = append(o.buf, p.tagcode...)
+ o.EncodeRawBytes(data)
+ }
+ return nil
+}
+
+func size_slice_ref_time(p *Properties, base structPointer) (n int) {
+ ptims := structPointer_InterfaceAt(base, p.field, reflect.SliceOf(timeType)).(*[]time.Time)
+ tims := *ptims
+ for i := 0; i < len(tims); i++ {
+ tproto, err := timestampProto(tims[i])
+ if err != nil {
+ return 0
+ }
+ size := Size(tproto)
+ n += len(p.tagcode) + size + sizeVarint(uint64(size))
+ }
+ return n
+}
+
+func (o *Buffer) enc_slice_ref_time(p *Properties, base structPointer) error {
+ ptims := structPointer_InterfaceAt(base, p.field, reflect.SliceOf(timeType)).(*[]time.Time)
+ tims := *ptims
+ for i := 0; i < len(tims); i++ {
+ tproto, err := timestampProto(tims[i])
+ if err != nil {
+ return err
+ }
+ data, err := Marshal(tproto)
+ if err != nil {
+ return err
+ }
+ o.buf = append(o.buf, p.tagcode...)
+ o.EncodeRawBytes(data)
+ }
+ return nil
+}
diff --git a/vendor/github.com/golang/glog/README b/vendor/github.com/golang/glog/README
index 387b4eb689..5f9c11485e 100644
--- a/vendor/github.com/golang/glog/README
+++ b/vendor/github.com/golang/glog/README
@@ -5,7 +5,7 @@ Leveled execution logs for Go.
This is an efficient pure Go implementation of leveled logs in the
manner of the open source C++ package
- https://github.com/google/glog
+ http://code.google.com/p/google-glog
By binding methods to booleans it is possible to use the log package
without paying the expense of evaluating the arguments to the log.
diff --git a/vendor/github.com/golang/glog/glog.go b/vendor/github.com/golang/glog/glog.go
index 54bd7afdca..3e63fffd5e 100644
--- a/vendor/github.com/golang/glog/glog.go
+++ b/vendor/github.com/golang/glog/glog.go
@@ -676,10 +676,7 @@ func (l *loggingT) output(s severity, buf *buffer, file string, line int, alsoTo
}
}
data := buf.Bytes()
- if !flag.Parsed() {
- os.Stderr.Write([]byte("ERROR: logging before flag.Parse: "))
- os.Stderr.Write(data)
- } else if l.toStderr {
+ if l.toStderr {
os.Stderr.Write(data)
} else {
if alsoToStderr || l.alsoToStderr || s >= l.stderrThreshold.get() {
diff --git a/vendor/github.com/golang/protobuf/LICENSE b/vendor/github.com/golang/protobuf/LICENSE
index 1b1b1921ef..0f646931a4 100644
--- a/vendor/github.com/golang/protobuf/LICENSE
+++ b/vendor/github.com/golang/protobuf/LICENSE
@@ -1,7 +1,4 @@
-Go support for Protocol Buffers - Google's data interchange format
-
Copyright 2010 The Go Authors. All rights reserved.
-https://github.com/golang/protobuf
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
diff --git a/vendor/github.com/golang/protobuf/proto/encode.go b/vendor/github.com/golang/protobuf/proto/encode.go
index c27d35f866..3abfed2cff 100644
--- a/vendor/github.com/golang/protobuf/proto/encode.go
+++ b/vendor/github.com/golang/protobuf/proto/encode.go
@@ -37,27 +37,9 @@ package proto
import (
"errors"
- "fmt"
"reflect"
)
-// RequiredNotSetError is the error returned if Marshal is called with
-// a protocol buffer struct whose required fields have not
-// all been initialized. It is also the error returned if Unmarshal is
-// called with an encoded protocol buffer that does not include all the
-// required fields.
-//
-// When printed, RequiredNotSetError reports the first unset required field in a
-// message. If the field cannot be precisely determined, it is reported as
-// "{Unknown}".
-type RequiredNotSetError struct {
- field string
-}
-
-func (e *RequiredNotSetError) Error() string {
- return fmt.Sprintf("proto: required field %q not set", e.field)
-}
-
var (
// errRepeatedHasNil is the error returned if Marshal is called with
// a struct with a repeated field containing a nil element.
diff --git a/vendor/github.com/golang/protobuf/proto/lib.go b/vendor/github.com/golang/protobuf/proto/lib.go
index 0e2191b8ad..75565cc6dc 100644
--- a/vendor/github.com/golang/protobuf/proto/lib.go
+++ b/vendor/github.com/golang/protobuf/proto/lib.go
@@ -265,7 +265,6 @@ package proto
import (
"encoding/json"
- "errors"
"fmt"
"log"
"reflect"
@@ -274,7 +273,66 @@ import (
"sync"
)
-var errInvalidUTF8 = errors.New("proto: invalid UTF-8 string")
+// RequiredNotSetError is an error type returned by either Marshal or Unmarshal.
+// Marshal reports this when a required field is not initialized.
+// Unmarshal reports this when a required field is missing from the wire data.
+type RequiredNotSetError struct{ field string }
+
+func (e *RequiredNotSetError) Error() string {
+ if e.field == "" {
+ return fmt.Sprintf("proto: required field not set")
+ }
+ return fmt.Sprintf("proto: required field %q not set", e.field)
+}
+func (e *RequiredNotSetError) RequiredNotSet() bool {
+ return true
+}
+
+type invalidUTF8Error struct{ field string }
+
+func (e *invalidUTF8Error) Error() string {
+ if e.field == "" {
+ return "proto: invalid UTF-8 detected"
+ }
+ return fmt.Sprintf("proto: field %q contains invalid UTF-8", e.field)
+}
+func (e *invalidUTF8Error) InvalidUTF8() bool {
+ return true
+}
+
+// errInvalidUTF8 is a sentinel error to identify fields with invalid UTF-8.
+// This error should not be exposed to the external API as such errors should
+// be recreated with the field information.
+var errInvalidUTF8 = &invalidUTF8Error{}
+
+// isNonFatal reports whether the error is either a RequiredNotSet error
+// or a InvalidUTF8 error.
+func isNonFatal(err error) bool {
+ if re, ok := err.(interface{ RequiredNotSet() bool }); ok && re.RequiredNotSet() {
+ return true
+ }
+ if re, ok := err.(interface{ InvalidUTF8() bool }); ok && re.InvalidUTF8() {
+ return true
+ }
+ return false
+}
+
+type nonFatal struct{ E error }
+
+// Merge merges err into nf and reports whether it was successful.
+// Otherwise it returns false for any fatal non-nil errors.
+func (nf *nonFatal) Merge(err error) (ok bool) {
+ if err == nil {
+ return true // not an error
+ }
+ if !isNonFatal(err) {
+ return false // fatal error
+ }
+ if nf.E == nil {
+ nf.E = err // store first instance of non-fatal error
+ }
+ return true
+}
// Message is implemented by generated protocol buffer messages.
type Message interface {
diff --git a/vendor/github.com/golang/protobuf/proto/properties.go b/vendor/github.com/golang/protobuf/proto/properties.go
index f710adab09..50b99b83a8 100644
--- a/vendor/github.com/golang/protobuf/proto/properties.go
+++ b/vendor/github.com/golang/protobuf/proto/properties.go
@@ -139,7 +139,7 @@ type Properties struct {
Repeated bool
Packed bool // relevant for repeated primitives only
Enum string // set for enum types only
- proto3 bool // whether this is known to be a proto3 field; set for []byte only
+ proto3 bool // whether this is known to be a proto3 field
oneof bool // whether this is a oneof field
Default string // default value
@@ -148,9 +148,9 @@ type Properties struct {
stype reflect.Type // set for struct types only
sprop *StructProperties // set for struct types only
- mtype reflect.Type // set for map types only
- mkeyprop *Properties // set for map types only
- mvalprop *Properties // set for map types only
+ mtype reflect.Type // set for map types only
+ MapKeyProp *Properties // set for map types only
+ MapValProp *Properties // set for map types only
}
// String formats the properties in the protobuf struct field tag style.
@@ -275,16 +275,16 @@ func (p *Properties) setFieldProps(typ reflect.Type, f *reflect.StructField, loc
case reflect.Map:
p.mtype = t1
- p.mkeyprop = &Properties{}
- p.mkeyprop.init(reflect.PtrTo(p.mtype.Key()), "Key", f.Tag.Get("protobuf_key"), nil, lockGetProp)
- p.mvalprop = &Properties{}
+ p.MapKeyProp = &Properties{}
+ p.MapKeyProp.init(reflect.PtrTo(p.mtype.Key()), "Key", f.Tag.Get("protobuf_key"), nil, lockGetProp)
+ p.MapValProp = &Properties{}
vtype := p.mtype.Elem()
if vtype.Kind() != reflect.Ptr && vtype.Kind() != reflect.Slice {
// The value type is not a message (*T) or bytes ([]byte),
// so we need encoders for the pointer to this type.
vtype = reflect.PtrTo(vtype)
}
- p.mvalprop.init(vtype, "Value", f.Tag.Get("protobuf_val"), nil, lockGetProp)
+ p.MapValProp.init(vtype, "Value", f.Tag.Get("protobuf_val"), nil, lockGetProp)
}
if p.stype != nil {
diff --git a/vendor/github.com/golang/protobuf/proto/table_marshal.go b/vendor/github.com/golang/protobuf/proto/table_marshal.go
index 0f212b3029..b16794496f 100644
--- a/vendor/github.com/golang/protobuf/proto/table_marshal.go
+++ b/vendor/github.com/golang/protobuf/proto/table_marshal.go
@@ -231,7 +231,7 @@ func (u *marshalInfo) marshal(b []byte, ptr pointer, deterministic bool) ([]byte
return b, err
}
- var err, errreq error
+ var err, errLater error
// The old marshaler encodes extensions at beginning.
if u.extensions.IsValid() {
e := ptr.offset(u.extensions).toExtensions()
@@ -252,11 +252,13 @@ func (u *marshalInfo) marshal(b []byte, ptr pointer, deterministic bool) ([]byte
}
}
for _, f := range u.fields {
- if f.required && errreq == nil {
+ if f.required {
if ptr.offset(f.field).getPointer().isNil() {
// Required field is not set.
// We record the error but keep going, to give a complete marshaling.
- errreq = &RequiredNotSetError{f.name}
+ if errLater == nil {
+ errLater = &RequiredNotSetError{f.name}
+ }
continue
}
}
@@ -269,14 +271,21 @@ func (u *marshalInfo) marshal(b []byte, ptr pointer, deterministic bool) ([]byte
if err1, ok := err.(*RequiredNotSetError); ok {
// Required field in submessage is not set.
// We record the error but keep going, to give a complete marshaling.
- if errreq == nil {
- errreq = &RequiredNotSetError{f.name + "." + err1.field}
+ if errLater == nil {
+ errLater = &RequiredNotSetError{f.name + "." + err1.field}
}
continue
}
if err == errRepeatedHasNil {
err = errors.New("proto: repeated field " + f.name + " has nil element")
}
+ if err == errInvalidUTF8 {
+ if errLater == nil {
+ fullName := revProtoTypes[reflect.PtrTo(u.typ)] + "." + f.name
+ errLater = &invalidUTF8Error{fullName}
+ }
+ continue
+ }
return b, err
}
}
@@ -284,7 +293,7 @@ func (u *marshalInfo) marshal(b []byte, ptr pointer, deterministic bool) ([]byte
s := *ptr.offset(u.unrecognized).toBytes()
b = append(b, s...)
}
- return b, errreq
+ return b, errLater
}
// computeMarshalInfo initializes the marshal info.
@@ -530,6 +539,7 @@ func typeMarshaler(t reflect.Type, tags []string, nozero, oneof bool) (sizer, ma
packed := false
proto3 := false
+ validateUTF8 := true
for i := 2; i < len(tags); i++ {
if tags[i] == "packed" {
packed = true
@@ -538,6 +548,7 @@ func typeMarshaler(t reflect.Type, tags []string, nozero, oneof bool) (sizer, ma
proto3 = true
}
}
+ validateUTF8 = validateUTF8 && proto3
switch t.Kind() {
case reflect.Bool:
@@ -735,6 +746,18 @@ func typeMarshaler(t reflect.Type, tags []string, nozero, oneof bool) (sizer, ma
}
return sizeFloat64Value, appendFloat64Value
case reflect.String:
+ if validateUTF8 {
+ if pointer {
+ return sizeStringPtr, appendUTF8StringPtr
+ }
+ if slice {
+ return sizeStringSlice, appendUTF8StringSlice
+ }
+ if nozero {
+ return sizeStringValueNoZero, appendUTF8StringValueNoZero
+ }
+ return sizeStringValue, appendUTF8StringValue
+ }
if pointer {
return sizeStringPtr, appendStringPtr
}
@@ -1984,9 +2007,6 @@ func appendBoolPackedSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byt
}
func appendStringValue(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
v := *ptr.toString()
- if !utf8.ValidString(v) {
- return nil, errInvalidUTF8
- }
b = appendVarint(b, wiretag)
b = appendVarint(b, uint64(len(v)))
b = append(b, v...)
@@ -1997,9 +2017,6 @@ func appendStringValueNoZero(b []byte, ptr pointer, wiretag uint64, _ bool) ([]b
if v == "" {
return b, nil
}
- if !utf8.ValidString(v) {
- return nil, errInvalidUTF8
- }
b = appendVarint(b, wiretag)
b = appendVarint(b, uint64(len(v)))
b = append(b, v...)
@@ -2011,24 +2028,83 @@ func appendStringPtr(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, err
return b, nil
}
v := *p
- if !utf8.ValidString(v) {
- return nil, errInvalidUTF8
- }
b = appendVarint(b, wiretag)
b = appendVarint(b, uint64(len(v)))
b = append(b, v...)
return b, nil
}
func appendStringSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ s := *ptr.toStringSlice()
+ for _, v := range s {
+ b = appendVarint(b, wiretag)
+ b = appendVarint(b, uint64(len(v)))
+ b = append(b, v...)
+ }
+ return b, nil
+}
+func appendUTF8StringValue(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ var invalidUTF8 bool
+ v := *ptr.toString()
+ if !utf8.ValidString(v) {
+ invalidUTF8 = true
+ }
+ b = appendVarint(b, wiretag)
+ b = appendVarint(b, uint64(len(v)))
+ b = append(b, v...)
+ if invalidUTF8 {
+ return b, errInvalidUTF8
+ }
+ return b, nil
+}
+func appendUTF8StringValueNoZero(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ var invalidUTF8 bool
+ v := *ptr.toString()
+ if v == "" {
+ return b, nil
+ }
+ if !utf8.ValidString(v) {
+ invalidUTF8 = true
+ }
+ b = appendVarint(b, wiretag)
+ b = appendVarint(b, uint64(len(v)))
+ b = append(b, v...)
+ if invalidUTF8 {
+ return b, errInvalidUTF8
+ }
+ return b, nil
+}
+func appendUTF8StringPtr(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ var invalidUTF8 bool
+ p := *ptr.toStringPtr()
+ if p == nil {
+ return b, nil
+ }
+ v := *p
+ if !utf8.ValidString(v) {
+ invalidUTF8 = true
+ }
+ b = appendVarint(b, wiretag)
+ b = appendVarint(b, uint64(len(v)))
+ b = append(b, v...)
+ if invalidUTF8 {
+ return b, errInvalidUTF8
+ }
+ return b, nil
+}
+func appendUTF8StringSlice(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
+ var invalidUTF8 bool
s := *ptr.toStringSlice()
for _, v := range s {
if !utf8.ValidString(v) {
- return nil, errInvalidUTF8
+ invalidUTF8 = true
}
b = appendVarint(b, wiretag)
b = appendVarint(b, uint64(len(v)))
b = append(b, v...)
}
+ if invalidUTF8 {
+ return b, errInvalidUTF8
+ }
return b, nil
}
func appendBytes(b []byte, ptr pointer, wiretag uint64, _ bool) ([]byte, error) {
@@ -2107,7 +2183,8 @@ func makeGroupSliceMarshaler(u *marshalInfo) (sizer, marshaler) {
},
func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) {
s := ptr.getPointerSlice()
- var err, errreq error
+ var err error
+ var nerr nonFatal
for _, v := range s {
if v.isNil() {
return b, errRepeatedHasNil
@@ -2115,22 +2192,14 @@ func makeGroupSliceMarshaler(u *marshalInfo) (sizer, marshaler) {
b = appendVarint(b, wiretag) // start group
b, err = u.marshal(b, v, deterministic)
b = appendVarint(b, wiretag+(WireEndGroup-WireStartGroup)) // end group
- if err != nil {
- if _, ok := err.(*RequiredNotSetError); ok {
- // Required field in submessage is not set.
- // We record the error but keep going, to give a complete marshaling.
- if errreq == nil {
- errreq = err
- }
- continue
- }
+ if !nerr.Merge(err) {
if err == ErrNil {
err = errRepeatedHasNil
}
return b, err
}
}
- return b, errreq
+ return b, nerr.E
}
}
@@ -2174,7 +2243,8 @@ func makeMessageSliceMarshaler(u *marshalInfo) (sizer, marshaler) {
},
func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) {
s := ptr.getPointerSlice()
- var err, errreq error
+ var err error
+ var nerr nonFatal
for _, v := range s {
if v.isNil() {
return b, errRepeatedHasNil
@@ -2184,22 +2254,14 @@ func makeMessageSliceMarshaler(u *marshalInfo) (sizer, marshaler) {
b = appendVarint(b, uint64(siz))
b, err = u.marshal(b, v, deterministic)
- if err != nil {
- if _, ok := err.(*RequiredNotSetError); ok {
- // Required field in submessage is not set.
- // We record the error but keep going, to give a complete marshaling.
- if errreq == nil {
- errreq = err
- }
- continue
- }
+ if !nerr.Merge(err) {
if err == ErrNil {
err = errRepeatedHasNil
}
return b, err
}
}
- return b, errreq
+ return b, nerr.E
}
}
@@ -2223,6 +2285,25 @@ func makeMapMarshaler(f *reflect.StructField) (sizer, marshaler) {
// value.
// Key cannot be pointer-typed.
valIsPtr := valType.Kind() == reflect.Ptr
+
+ // If value is a message with nested maps, calling
+ // valSizer in marshal may be quadratic. We should use
+ // cached version in marshal (but not in size).
+ // If value is not message type, we don't have size cache,
+ // but it cannot be nested either. Just use valSizer.
+ valCachedSizer := valSizer
+ if valIsPtr && valType.Elem().Kind() == reflect.Struct {
+ u := getMarshalInfo(valType.Elem())
+ valCachedSizer = func(ptr pointer, tagsize int) int {
+ // Same as message sizer, but use cache.
+ p := ptr.getPointer()
+ if p.isNil() {
+ return 0
+ }
+ siz := u.cachedsize(p)
+ return siz + SizeVarint(uint64(siz)) + tagsize
+ }
+ }
return func(ptr pointer, tagsize int) int {
m := ptr.asPointerTo(t).Elem() // the map
n := 0
@@ -2243,24 +2324,26 @@ func makeMapMarshaler(f *reflect.StructField) (sizer, marshaler) {
if len(keys) > 1 && deterministic {
sort.Sort(mapKeys(keys))
}
+
+ var nerr nonFatal
for _, k := range keys {
ki := k.Interface()
vi := m.MapIndex(k).Interface()
kaddr := toAddrPointer(&ki, false) // pointer to key
vaddr := toAddrPointer(&vi, valIsPtr) // pointer to value
b = appendVarint(b, tag)
- siz := keySizer(kaddr, 1) + valSizer(vaddr, 1) // tag of key = 1 (size=1), tag of val = 2 (size=1)
+ siz := keySizer(kaddr, 1) + valCachedSizer(vaddr, 1) // tag of key = 1 (size=1), tag of val = 2 (size=1)
b = appendVarint(b, uint64(siz))
b, err = keyMarshaler(b, kaddr, keyWireTag, deterministic)
- if err != nil {
+ if !nerr.Merge(err) {
return b, err
}
b, err = valMarshaler(b, vaddr, valWireTag, deterministic)
- if err != nil && err != ErrNil { // allow nil value in map
+ if err != ErrNil && !nerr.Merge(err) { // allow nil value in map
return b, err
}
}
- return b, nil
+ return b, nerr.E
}
}
@@ -2333,6 +2416,7 @@ func (u *marshalInfo) appendExtensions(b []byte, ext *XXX_InternalExtensions, de
defer mu.Unlock()
var err error
+ var nerr nonFatal
// Fast-path for common cases: zero or one extensions.
// Don't bother sorting the keys.
@@ -2352,11 +2436,11 @@ func (u *marshalInfo) appendExtensions(b []byte, ext *XXX_InternalExtensions, de
v := e.value
p := toAddrPointer(&v, ei.isptr)
b, err = ei.marshaler(b, p, ei.wiretag, deterministic)
- if err != nil {
+ if !nerr.Merge(err) {
return b, err
}
}
- return b, nil
+ return b, nerr.E
}
// Sort the keys to provide a deterministic encoding.
@@ -2383,11 +2467,11 @@ func (u *marshalInfo) appendExtensions(b []byte, ext *XXX_InternalExtensions, de
v := e.value
p := toAddrPointer(&v, ei.isptr)
b, err = ei.marshaler(b, p, ei.wiretag, deterministic)
- if err != nil {
+ if !nerr.Merge(err) {
return b, err
}
}
- return b, nil
+ return b, nerr.E
}
// message set format is:
@@ -2444,6 +2528,7 @@ func (u *marshalInfo) appendMessageSet(b []byte, ext *XXX_InternalExtensions, de
defer mu.Unlock()
var err error
+ var nerr nonFatal
// Fast-path for common cases: zero or one extensions.
// Don't bother sorting the keys.
@@ -2470,12 +2555,12 @@ func (u *marshalInfo) appendMessageSet(b []byte, ext *XXX_InternalExtensions, de
v := e.value
p := toAddrPointer(&v, ei.isptr)
b, err = ei.marshaler(b, p, 3<<3|WireBytes, deterministic)
- if err != nil {
+ if !nerr.Merge(err) {
return b, err
}
b = append(b, 1<<3|WireEndGroup)
}
- return b, nil
+ return b, nerr.E
}
// Sort the keys to provide a deterministic encoding.
@@ -2509,11 +2594,11 @@ func (u *marshalInfo) appendMessageSet(b []byte, ext *XXX_InternalExtensions, de
p := toAddrPointer(&v, ei.isptr)
b, err = ei.marshaler(b, p, 3<<3|WireBytes, deterministic)
b = append(b, 1<<3|WireEndGroup)
- if err != nil {
+ if !nerr.Merge(err) {
return b, err
}
}
- return b, nil
+ return b, nerr.E
}
// sizeV1Extensions computes the size of encoded data for a V1-API extension field.
@@ -2556,6 +2641,7 @@ func (u *marshalInfo) appendV1Extensions(b []byte, m map[int32]Extension, determ
sort.Ints(keys)
var err error
+ var nerr nonFatal
for _, k := range keys {
e := m[int32(k)]
if e.value == nil || e.desc == nil {
@@ -2572,11 +2658,11 @@ func (u *marshalInfo) appendV1Extensions(b []byte, m map[int32]Extension, determ
v := e.value
p := toAddrPointer(&v, ei.isptr)
b, err = ei.marshaler(b, p, ei.wiretag, deterministic)
- if err != nil {
+ if !nerr.Merge(err) {
return b, err
}
}
- return b, nil
+ return b, nerr.E
}
// newMarshaler is the interface representing objects that can marshal themselves.
diff --git a/vendor/github.com/golang/protobuf/proto/table_unmarshal.go b/vendor/github.com/golang/protobuf/proto/table_unmarshal.go
index 55f0340a3f..ebf1caa56a 100644
--- a/vendor/github.com/golang/protobuf/proto/table_unmarshal.go
+++ b/vendor/github.com/golang/protobuf/proto/table_unmarshal.go
@@ -97,6 +97,8 @@ type unmarshalFieldInfo struct {
// if a required field, contains a single set bit at this field's index in the required field list.
reqMask uint64
+
+ name string // name of the field, for error reporting
}
var (
@@ -136,8 +138,8 @@ func (u *unmarshalInfo) unmarshal(m pointer, b []byte) error {
if u.isMessageSet {
return UnmarshalMessageSet(b, m.offset(u.extensions).toExtensions())
}
- var reqMask uint64 // bitmask of required fields we've seen.
- var rnse *RequiredNotSetError // an instance of a RequiredNotSetError returned by a submessage.
+ var reqMask uint64 // bitmask of required fields we've seen.
+ var errLater error
for len(b) > 0 {
// Read tag and wire type.
// Special case 1 and 2 byte varints.
@@ -176,11 +178,20 @@ func (u *unmarshalInfo) unmarshal(m pointer, b []byte) error {
if r, ok := err.(*RequiredNotSetError); ok {
// Remember this error, but keep parsing. We need to produce
// a full parse even if a required field is missing.
- rnse = r
+ if errLater == nil {
+ errLater = r
+ }
reqMask |= f.reqMask
continue
}
if err != errInternalBadWireType {
+ if err == errInvalidUTF8 {
+ if errLater == nil {
+ fullName := revProtoTypes[reflect.PtrTo(u.typ)] + "." + f.name
+ errLater = &invalidUTF8Error{fullName}
+ }
+ continue
+ }
return err
}
// Fragments with bad wire type are treated as unknown fields.
@@ -239,20 +250,16 @@ func (u *unmarshalInfo) unmarshal(m pointer, b []byte) error {
emap[int32(tag)] = e
}
}
- if rnse != nil {
- // A required field of a submessage/group is missing. Return that error.
- return rnse
- }
- if reqMask != u.reqMask {
+ if reqMask != u.reqMask && errLater == nil {
// A required field of this message is missing.
for _, n := range u.reqFields {
if reqMask&1 == 0 {
- return &RequiredNotSetError{n}
+ errLater = &RequiredNotSetError{n}
}
reqMask >>= 1
}
}
- return nil
+ return errLater
}
// computeUnmarshalInfo fills in u with information for use
@@ -351,7 +358,7 @@ func (u *unmarshalInfo) computeUnmarshalInfo() {
}
// Store the info in the correct slot in the message.
- u.setTag(tag, toField(&f), unmarshal, reqMask)
+ u.setTag(tag, toField(&f), unmarshal, reqMask, name)
}
// Find any types associated with oneof fields.
@@ -366,10 +373,17 @@ func (u *unmarshalInfo) computeUnmarshalInfo() {
f := typ.Field(0) // oneof implementers have one field
baseUnmarshal := fieldUnmarshaler(&f)
- tagstr := strings.Split(f.Tag.Get("protobuf"), ",")[1]
- tag, err := strconv.Atoi(tagstr)
+ tags := strings.Split(f.Tag.Get("protobuf"), ",")
+ fieldNum, err := strconv.Atoi(tags[1])
if err != nil {
- panic("protobuf tag field not an integer: " + tagstr)
+ panic("protobuf tag field not an integer: " + tags[1])
+ }
+ var name string
+ for _, tag := range tags {
+ if strings.HasPrefix(tag, "name=") {
+ name = strings.TrimPrefix(tag, "name=")
+ break
+ }
}
// Find the oneof field that this struct implements.
@@ -380,7 +394,7 @@ func (u *unmarshalInfo) computeUnmarshalInfo() {
// That lets us know where this struct should be stored
// when we encounter it during unmarshaling.
unmarshal := makeUnmarshalOneof(typ, of.ityp, baseUnmarshal)
- u.setTag(tag, of.field, unmarshal, 0)
+ u.setTag(fieldNum, of.field, unmarshal, 0, name)
}
}
}
@@ -401,7 +415,7 @@ func (u *unmarshalInfo) computeUnmarshalInfo() {
// [0 0] is [tag=0/wiretype=varint varint-encoded-0].
u.setTag(0, zeroField, func(b []byte, f pointer, w int) ([]byte, error) {
return nil, fmt.Errorf("proto: %s: illegal tag 0 (wire type %d)", t, w)
- }, 0)
+ }, 0, "")
// Set mask for required field check.
u.reqMask = uint64(1)<= 0 && (tag < 16 || tag < 2*n) { // TODO: what are the right numbers here?
for len(u.dense) <= tag {
@@ -442,11 +457,17 @@ func typeUnmarshaler(t reflect.Type, tags string) unmarshaler {
tagArray := strings.Split(tags, ",")
encoding := tagArray[0]
name := "unknown"
+ proto3 := false
+ validateUTF8 := true
for _, tag := range tagArray[3:] {
if strings.HasPrefix(tag, "name=") {
name = tag[5:]
}
+ if tag == "proto3" {
+ proto3 = true
+ }
}
+ validateUTF8 = validateUTF8 && proto3
// Figure out packaging (pointer, slice, or both)
slice := false
@@ -594,6 +615,15 @@ func typeUnmarshaler(t reflect.Type, tags string) unmarshaler {
}
return unmarshalBytesValue
case reflect.String:
+ if validateUTF8 {
+ if pointer {
+ return unmarshalUTF8StringPtr
+ }
+ if slice {
+ return unmarshalUTF8StringSlice
+ }
+ return unmarshalUTF8StringValue
+ }
if pointer {
return unmarshalStringPtr
}
@@ -1448,9 +1478,6 @@ func unmarshalStringValue(b []byte, f pointer, w int) ([]byte, error) {
return nil, io.ErrUnexpectedEOF
}
v := string(b[:x])
- if !utf8.ValidString(v) {
- return nil, errInvalidUTF8
- }
*f.toString() = v
return b[x:], nil
}
@@ -1468,9 +1495,6 @@ func unmarshalStringPtr(b []byte, f pointer, w int) ([]byte, error) {
return nil, io.ErrUnexpectedEOF
}
v := string(b[:x])
- if !utf8.ValidString(v) {
- return nil, errInvalidUTF8
- }
*f.toStringPtr() = &v
return b[x:], nil
}
@@ -1488,14 +1512,72 @@ func unmarshalStringSlice(b []byte, f pointer, w int) ([]byte, error) {
return nil, io.ErrUnexpectedEOF
}
v := string(b[:x])
- if !utf8.ValidString(v) {
- return nil, errInvalidUTF8
- }
s := f.toStringSlice()
*s = append(*s, v)
return b[x:], nil
}
+func unmarshalUTF8StringValue(b []byte, f pointer, w int) ([]byte, error) {
+ if w != WireBytes {
+ return b, errInternalBadWireType
+ }
+ x, n := decodeVarint(b)
+ if n == 0 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ b = b[n:]
+ if x > uint64(len(b)) {
+ return nil, io.ErrUnexpectedEOF
+ }
+ v := string(b[:x])
+ *f.toString() = v
+ if !utf8.ValidString(v) {
+ return b[x:], errInvalidUTF8
+ }
+ return b[x:], nil
+}
+
+func unmarshalUTF8StringPtr(b []byte, f pointer, w int) ([]byte, error) {
+ if w != WireBytes {
+ return b, errInternalBadWireType
+ }
+ x, n := decodeVarint(b)
+ if n == 0 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ b = b[n:]
+ if x > uint64(len(b)) {
+ return nil, io.ErrUnexpectedEOF
+ }
+ v := string(b[:x])
+ *f.toStringPtr() = &v
+ if !utf8.ValidString(v) {
+ return b[x:], errInvalidUTF8
+ }
+ return b[x:], nil
+}
+
+func unmarshalUTF8StringSlice(b []byte, f pointer, w int) ([]byte, error) {
+ if w != WireBytes {
+ return b, errInternalBadWireType
+ }
+ x, n := decodeVarint(b)
+ if n == 0 {
+ return nil, io.ErrUnexpectedEOF
+ }
+ b = b[n:]
+ if x > uint64(len(b)) {
+ return nil, io.ErrUnexpectedEOF
+ }
+ v := string(b[:x])
+ s := f.toStringSlice()
+ *s = append(*s, v)
+ if !utf8.ValidString(v) {
+ return b[x:], errInvalidUTF8
+ }
+ return b[x:], nil
+}
+
var emptyBuf [0]byte
func unmarshalBytesValue(b []byte, f pointer, w int) ([]byte, error) {
@@ -1674,6 +1756,7 @@ func makeUnmarshalMap(f *reflect.StructField) unmarshaler {
// Maps will be somewhat slow. Oh well.
// Read key and value from data.
+ var nerr nonFatal
k := reflect.New(kt)
v := reflect.New(vt)
for len(b) > 0 {
@@ -1694,7 +1777,7 @@ func makeUnmarshalMap(f *reflect.StructField) unmarshaler {
err = errInternalBadWireType // skip unknown tag
}
- if err == nil {
+ if nerr.Merge(err) {
continue
}
if err != errInternalBadWireType {
@@ -1717,7 +1800,7 @@ func makeUnmarshalMap(f *reflect.StructField) unmarshaler {
// Insert into map.
m.SetMapIndex(k.Elem(), v.Elem())
- return r, nil
+ return r, nerr.E
}
}
@@ -1743,15 +1826,16 @@ func makeUnmarshalOneof(typ, ityp reflect.Type, unmarshal unmarshaler) unmarshal
// Unmarshal data into holder.
// We unmarshal into the first field of the holder object.
var err error
+ var nerr nonFatal
b, err = unmarshal(b, valToPointer(v).offset(field0), w)
- if err != nil {
+ if !nerr.Merge(err) {
return nil, err
}
// Write pointer to holder into target field.
f.asPointerTo(ityp).Elem().Set(v)
- return b, nil
+ return b, nerr.E
}
}
diff --git a/vendor/github.com/golang/protobuf/proto/text.go b/vendor/github.com/golang/protobuf/proto/text.go
index 2205fdaadf..1aaee725b4 100644
--- a/vendor/github.com/golang/protobuf/proto/text.go
+++ b/vendor/github.com/golang/protobuf/proto/text.go
@@ -353,7 +353,7 @@ func (tm *TextMarshaler) writeStruct(w *textWriter, sv reflect.Value) error {
return err
}
}
- if err := tm.writeAny(w, key, props.mkeyprop); err != nil {
+ if err := tm.writeAny(w, key, props.MapKeyProp); err != nil {
return err
}
if err := w.WriteByte('\n'); err != nil {
@@ -370,7 +370,7 @@ func (tm *TextMarshaler) writeStruct(w *textWriter, sv reflect.Value) error {
return err
}
}
- if err := tm.writeAny(w, val, props.mvalprop); err != nil {
+ if err := tm.writeAny(w, val, props.MapValProp); err != nil {
return err
}
if err := w.WriteByte('\n'); err != nil {
diff --git a/vendor/github.com/golang/protobuf/proto/text_parser.go b/vendor/github.com/golang/protobuf/proto/text_parser.go
index 0685bae36d..bb55a3af27 100644
--- a/vendor/github.com/golang/protobuf/proto/text_parser.go
+++ b/vendor/github.com/golang/protobuf/proto/text_parser.go
@@ -630,17 +630,17 @@ func (p *textParser) readStruct(sv reflect.Value, terminator string) error {
if err := p.consumeToken(":"); err != nil {
return err
}
- if err := p.readAny(key, props.mkeyprop); err != nil {
+ if err := p.readAny(key, props.MapKeyProp); err != nil {
return err
}
if err := p.consumeOptionalSeparator(); err != nil {
return err
}
case "value":
- if err := p.checkForColon(props.mvalprop, dst.Type().Elem()); err != nil {
+ if err := p.checkForColon(props.MapValProp, dst.Type().Elem()); err != nil {
return err
}
- if err := p.readAny(val, props.mvalprop); err != nil {
+ if err := p.readAny(val, props.MapValProp); err != nil {
return err
}
if err := p.consumeOptionalSeparator(); err != nil {
diff --git a/vendor/github.com/golang/protobuf/ptypes/any.go b/vendor/github.com/golang/protobuf/ptypes/any.go
index b2af97f4a9..70276e8f5c 100644
--- a/vendor/github.com/golang/protobuf/ptypes/any.go
+++ b/vendor/github.com/golang/protobuf/ptypes/any.go
@@ -130,10 +130,12 @@ func UnmarshalAny(any *any.Any, pb proto.Message) error {
// Is returns true if any value contains a given message type.
func Is(any *any.Any, pb proto.Message) bool {
- aname, err := AnyMessageName(any)
- if err != nil {
+ // The following is equivalent to AnyMessageName(any) == proto.MessageName(pb),
+ // but it avoids scanning TypeUrl for the slash.
+ if any == nil {
return false
}
-
- return aname == proto.MessageName(pb)
+ name := proto.MessageName(pb)
+ prefix := len(any.TypeUrl) - len(name)
+ return prefix >= 1 && any.TypeUrl[prefix-1] == '/' && any.TypeUrl[prefix:] == name
}
diff --git a/vendor/github.com/golang/protobuf/ptypes/any/any.pb.go b/vendor/github.com/golang/protobuf/ptypes/any/any.pb.go
index f67edc7dc2..e3c56d3ffa 100644
--- a/vendor/github.com/golang/protobuf/ptypes/any/any.pb.go
+++ b/vendor/github.com/golang/protobuf/ptypes/any/any.pb.go
@@ -121,7 +121,7 @@ type Any struct {
// Schemes other than `http`, `https` (or the empty scheme) might be
// used with implementation specific semantics.
//
- TypeUrl string `protobuf:"bytes,1,opt,name=type_url,json=typeUrl" json:"type_url,omitempty"`
+ TypeUrl string `protobuf:"bytes,1,opt,name=type_url,json=typeUrl,proto3" json:"type_url,omitempty"`
// Must be a valid serialized protocol buffer of the above specified type.
Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
diff --git a/vendor/github.com/golang/protobuf/ptypes/duration/duration.pb.go b/vendor/github.com/golang/protobuf/ptypes/duration/duration.pb.go
index 4d75473b8b..a7beb2c414 100644
--- a/vendor/github.com/golang/protobuf/ptypes/duration/duration.pb.go
+++ b/vendor/github.com/golang/protobuf/ptypes/duration/duration.pb.go
@@ -82,14 +82,14 @@ type Duration struct {
// Signed seconds of the span of time. Must be from -315,576,000,000
// to +315,576,000,000 inclusive. Note: these bounds are computed from:
// 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years
- Seconds int64 `protobuf:"varint,1,opt,name=seconds" json:"seconds,omitempty"`
+ Seconds int64 `protobuf:"varint,1,opt,name=seconds,proto3" json:"seconds,omitempty"`
// Signed fractions of a second at nanosecond resolution of the span
// of time. Durations less than one second are represented with a 0
// `seconds` field and a positive or negative `nanos` field. For durations
// of one second or more, a non-zero value for the `nanos` field must be
// of the same sign as the `seconds` field. Must be from -999,999,999
// to +999,999,999 inclusive.
- Nanos int32 `protobuf:"varint,2,opt,name=nanos" json:"nanos,omitempty"`
+ Nanos int32 `protobuf:"varint,2,opt,name=nanos,proto3" json:"nanos,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
diff --git a/vendor/github.com/golang/protobuf/ptypes/timestamp/timestamp.pb.go b/vendor/github.com/golang/protobuf/ptypes/timestamp/timestamp.pb.go
index e9c2222821..8e76ae9763 100644
--- a/vendor/github.com/golang/protobuf/ptypes/timestamp/timestamp.pb.go
+++ b/vendor/github.com/golang/protobuf/ptypes/timestamp/timestamp.pb.go
@@ -100,12 +100,12 @@ type Timestamp struct {
// Represents seconds of UTC time since Unix epoch
// 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
// 9999-12-31T23:59:59Z inclusive.
- Seconds int64 `protobuf:"varint,1,opt,name=seconds" json:"seconds,omitempty"`
+ Seconds int64 `protobuf:"varint,1,opt,name=seconds,proto3" json:"seconds,omitempty"`
// Non-negative fractions of a second at nanosecond resolution. Negative
// second values with fractions must still have non-negative nanos values
// that count forward in time. Must be from 0 to 999,999,999
// inclusive.
- Nanos int32 `protobuf:"varint,2,opt,name=nanos" json:"nanos,omitempty"`
+ Nanos int32 `protobuf:"varint,2,opt,name=nanos,proto3" json:"nanos,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
diff --git a/vendor/github.com/google/btree/btree.go b/vendor/github.com/google/btree/btree.go
index 7e4551d73b..6ff062f9bb 100644
--- a/vendor/github.com/google/btree/btree.go
+++ b/vendor/github.com/google/btree/btree.go
@@ -500,13 +500,14 @@ const (
// thus creating a "greaterOrEqual" or "lessThanEqual" rather than just a
// "greaterThan" or "lessThan" queries.
func (n *node) iterate(dir direction, start, stop Item, includeStart bool, hit bool, iter ItemIterator) (bool, bool) {
- var ok bool
+ var ok, found bool
+ var index int
switch dir {
case ascend:
- for i := 0; i < len(n.items); i++ {
- if start != nil && n.items[i].Less(start) {
- continue
- }
+ if start != nil {
+ index, _ = n.items.find(start)
+ }
+ for i := index; i < len(n.items); i++ {
if len(n.children) > 0 {
if hit, ok = n.children[i].iterate(dir, start, stop, includeStart, hit, iter); !ok {
return hit, false
@@ -530,7 +531,15 @@ func (n *node) iterate(dir direction, start, stop Item, includeStart bool, hit b
}
}
case descend:
- for i := len(n.items) - 1; i >= 0; i-- {
+ if start != nil {
+ index, found = n.items.find(start)
+ if !found {
+ index = index - 1
+ }
+ } else {
+ index = len(n.items) - 1
+ }
+ for i := index; i >= 0; i-- {
if start != nil && !n.items[i].Less(start) {
if !includeStart || hit || start.Less(n.items[i]) {
continue
diff --git a/vendor/github.com/google/gofuzz/fuzz.go b/vendor/github.com/google/gofuzz/fuzz.go
index 1dfa80a6fc..4f888fbc8f 100644
--- a/vendor/github.com/google/gofuzz/fuzz.go
+++ b/vendor/github.com/google/gofuzz/fuzz.go
@@ -34,27 +34,21 @@ type Fuzzer struct {
nilChance float64
minElements int
maxElements int
- maxDepth int
}
// New returns a new Fuzzer. Customize your Fuzzer further by calling Funcs,
// RandSource, NilChance, or NumElements in any order.
func New() *Fuzzer {
- return NewWithSeed(time.Now().UnixNano())
-}
-
-func NewWithSeed(seed int64) *Fuzzer {
f := &Fuzzer{
defaultFuzzFuncs: fuzzFuncMap{
reflect.TypeOf(&time.Time{}): reflect.ValueOf(fuzzTime),
},
fuzzFuncs: fuzzFuncMap{},
- r: rand.New(rand.NewSource(seed)),
+ r: rand.New(rand.NewSource(time.Now().UnixNano())),
nilChance: .2,
minElements: 1,
maxElements: 10,
- maxDepth: 100,
}
return f
}
@@ -142,14 +136,6 @@ func (f *Fuzzer) genShouldFill() bool {
return f.r.Float64() > f.nilChance
}
-// MaxDepth sets the maximum number of recursive fuzz calls that will be made
-// before stopping. This includes struct members, pointers, and map and slice
-// elements.
-func (f *Fuzzer) MaxDepth(d int) *Fuzzer {
- f.maxDepth = d
- return f
-}
-
// Fuzz recursively fills all of obj's fields with something random. First
// this tries to find a custom fuzz function (see Funcs). If there is no
// custom function this tests whether the object implements fuzz.Interface and,
@@ -158,19 +144,17 @@ func (f *Fuzzer) MaxDepth(d int) *Fuzzer {
// fails, this will generate random values for all primitive fields and then
// recurse for all non-primitives.
//
-// This is safe for cyclic or tree-like structs, up to a limit. Use the
-// MaxDepth method to adjust how deep you need it to recurse.
+// Not safe for cyclic or tree-like structs!
//
-// obj must be a pointer. Only exported (public) fields can be set (thanks,
-// golang :/ ) Intended for tests, so will panic on bad input or unimplemented
-// fields.
+// obj must be a pointer. Only exported (public) fields can be set (thanks, golang :/ )
+// Intended for tests, so will panic on bad input or unimplemented fields.
func (f *Fuzzer) Fuzz(obj interface{}) {
v := reflect.ValueOf(obj)
if v.Kind() != reflect.Ptr {
panic("needed ptr!")
}
v = v.Elem()
- f.fuzzWithContext(v, 0)
+ f.doFuzz(v, 0)
}
// FuzzNoCustom is just like Fuzz, except that any custom fuzz function for
@@ -186,7 +170,7 @@ func (f *Fuzzer) FuzzNoCustom(obj interface{}) {
panic("needed ptr!")
}
v = v.Elem()
- f.fuzzWithContext(v, flagNoCustomFuzz)
+ f.doFuzz(v, flagNoCustomFuzz)
}
const (
@@ -194,87 +178,69 @@ const (
flagNoCustomFuzz uint64 = 1 << iota
)
-func (f *Fuzzer) fuzzWithContext(v reflect.Value, flags uint64) {
- fc := &fuzzerContext{fuzzer: f}
- fc.doFuzz(v, flags)
-}
-
-// fuzzerContext carries context about a single fuzzing run, which lets Fuzzer
-// be thread-safe.
-type fuzzerContext struct {
- fuzzer *Fuzzer
- curDepth int
-}
-
-func (fc *fuzzerContext) doFuzz(v reflect.Value, flags uint64) {
- if fc.curDepth >= fc.fuzzer.maxDepth {
- return
- }
- fc.curDepth++
- defer func() { fc.curDepth-- }()
-
+func (f *Fuzzer) doFuzz(v reflect.Value, flags uint64) {
if !v.CanSet() {
return
}
if flags&flagNoCustomFuzz == 0 {
// Check for both pointer and non-pointer custom functions.
- if v.CanAddr() && fc.tryCustom(v.Addr()) {
+ if v.CanAddr() && f.tryCustom(v.Addr()) {
return
}
- if fc.tryCustom(v) {
+ if f.tryCustom(v) {
return
}
}
if fn, ok := fillFuncMap[v.Kind()]; ok {
- fn(v, fc.fuzzer.r)
+ fn(v, f.r)
return
}
switch v.Kind() {
case reflect.Map:
- if fc.fuzzer.genShouldFill() {
+ if f.genShouldFill() {
v.Set(reflect.MakeMap(v.Type()))
- n := fc.fuzzer.genElementCount()
+ n := f.genElementCount()
for i := 0; i < n; i++ {
key := reflect.New(v.Type().Key()).Elem()
- fc.doFuzz(key, 0)
+ f.doFuzz(key, 0)
val := reflect.New(v.Type().Elem()).Elem()
- fc.doFuzz(val, 0)
+ f.doFuzz(val, 0)
v.SetMapIndex(key, val)
}
return
}
v.Set(reflect.Zero(v.Type()))
case reflect.Ptr:
- if fc.fuzzer.genShouldFill() {
+ if f.genShouldFill() {
v.Set(reflect.New(v.Type().Elem()))
- fc.doFuzz(v.Elem(), 0)
+ f.doFuzz(v.Elem(), 0)
return
}
v.Set(reflect.Zero(v.Type()))
case reflect.Slice:
- if fc.fuzzer.genShouldFill() {
- n := fc.fuzzer.genElementCount()
+ if f.genShouldFill() {
+ n := f.genElementCount()
v.Set(reflect.MakeSlice(v.Type(), n, n))
for i := 0; i < n; i++ {
- fc.doFuzz(v.Index(i), 0)
+ f.doFuzz(v.Index(i), 0)
}
return
}
v.Set(reflect.Zero(v.Type()))
case reflect.Array:
- if fc.fuzzer.genShouldFill() {
+ if f.genShouldFill() {
n := v.Len()
for i := 0; i < n; i++ {
- fc.doFuzz(v.Index(i), 0)
+ f.doFuzz(v.Index(i), 0)
}
return
}
v.Set(reflect.Zero(v.Type()))
case reflect.Struct:
for i := 0; i < v.NumField(); i++ {
- fc.doFuzz(v.Field(i), 0)
+ f.doFuzz(v.Field(i), 0)
}
case reflect.Chan:
fallthrough
@@ -289,20 +255,20 @@ func (fc *fuzzerContext) doFuzz(v reflect.Value, flags uint64) {
// tryCustom searches for custom handlers, and returns true iff it finds a match
// and successfully randomizes v.
-func (fc *fuzzerContext) tryCustom(v reflect.Value) bool {
+func (f *Fuzzer) tryCustom(v reflect.Value) bool {
// First: see if we have a fuzz function for it.
- doCustom, ok := fc.fuzzer.fuzzFuncs[v.Type()]
+ doCustom, ok := f.fuzzFuncs[v.Type()]
if !ok {
// Second: see if it can fuzz itself.
if v.CanInterface() {
intf := v.Interface()
if fuzzable, ok := intf.(Interface); ok {
- fuzzable.Fuzz(Continue{fc: fc, Rand: fc.fuzzer.r})
+ fuzzable.Fuzz(Continue{f: f, Rand: f.r})
return true
}
}
// Finally: see if there is a default fuzz function.
- doCustom, ok = fc.fuzzer.defaultFuzzFuncs[v.Type()]
+ doCustom, ok = f.defaultFuzzFuncs[v.Type()]
if !ok {
return false
}
@@ -328,8 +294,8 @@ func (fc *fuzzerContext) tryCustom(v reflect.Value) bool {
}
doCustom.Call([]reflect.Value{v, reflect.ValueOf(Continue{
- fc: fc,
- Rand: fc.fuzzer.r,
+ f: f,
+ Rand: f.r,
})})
return true
}
@@ -344,7 +310,7 @@ type Interface interface {
// Continue can be passed to custom fuzzing functions to allow them to use
// the correct source of randomness and to continue fuzzing their members.
type Continue struct {
- fc *fuzzerContext
+ f *Fuzzer
// For convenience, Continue implements rand.Rand via embedding.
// Use this for generating any randomness if you want your fuzzing
@@ -359,7 +325,7 @@ func (c Continue) Fuzz(obj interface{}) {
panic("needed ptr!")
}
v = v.Elem()
- c.fc.doFuzz(v, 0)
+ c.f.doFuzz(v, 0)
}
// FuzzNoCustom continues fuzzing obj, except that any custom fuzz function for
@@ -372,7 +338,7 @@ func (c Continue) FuzzNoCustom(obj interface{}) {
panic("needed ptr!")
}
v = v.Elem()
- c.fc.doFuzz(v, flagNoCustomFuzz)
+ c.f.doFuzz(v, flagNoCustomFuzz)
}
// RandString makes a random string up to 20 characters long. The returned string
diff --git a/vendor/github.com/google/uuid/dce.go b/vendor/github.com/google/uuid/dce.go
index a6479dbae0..fa820b9d30 100644
--- a/vendor/github.com/google/uuid/dce.go
+++ b/vendor/github.com/google/uuid/dce.go
@@ -42,7 +42,7 @@ func NewDCESecurity(domain Domain, id uint32) (UUID, error) {
// NewDCEPerson returns a DCE Security (Version 2) UUID in the person
// domain with the id returned by os.Getuid.
//
-// NewDCEPerson(Person, uint32(os.Getuid()))
+// NewDCESecurity(Person, uint32(os.Getuid()))
func NewDCEPerson() (UUID, error) {
return NewDCESecurity(Person, uint32(os.Getuid()))
}
@@ -50,7 +50,7 @@ func NewDCEPerson() (UUID, error) {
// NewDCEGroup returns a DCE Security (Version 2) UUID in the group
// domain with the id returned by os.Getgid.
//
-// NewDCEGroup(Group, uint32(os.Getgid()))
+// NewDCESecurity(Group, uint32(os.Getgid()))
func NewDCEGroup() (UUID, error) {
return NewDCESecurity(Group, uint32(os.Getgid()))
}
diff --git a/vendor/github.com/google/uuid/sql.go b/vendor/github.com/google/uuid/sql.go
index 528ad0de51..f326b54db3 100644
--- a/vendor/github.com/google/uuid/sql.go
+++ b/vendor/github.com/google/uuid/sql.go
@@ -13,35 +13,36 @@ import (
// Currently, database types that map to string and []byte are supported. Please
// consult database-specific driver documentation for matching types.
func (uuid *UUID) Scan(src interface{}) error {
- switch src.(type) {
+ switch src := src.(type) {
+ case nil:
+ return nil
+
case string:
// if an empty UUID comes from a table, we return a null UUID
- if src.(string) == "" {
+ if src == "" {
return nil
}
// see Parse for required string format
- u, err := Parse(src.(string))
-
+ u, err := Parse(src)
if err != nil {
return fmt.Errorf("Scan: %v", err)
}
*uuid = u
- case []byte:
- b := src.([]byte)
+ case []byte:
// if an empty UUID comes from a table, we return a null UUID
- if len(b) == 0 {
+ if len(src) == 0 {
return nil
}
// assumes a simple slice of bytes if 16 bytes
// otherwise attempts to parse
- if len(b) != 16 {
- return uuid.Scan(string(b))
+ if len(src) != 16 {
+ return uuid.Scan(string(src))
}
- copy((*uuid)[:], b)
+ copy((*uuid)[:], src)
default:
return fmt.Errorf("Scan: unable to scan type %T into UUID", src)
diff --git a/vendor/github.com/google/uuid/uuid.go b/vendor/github.com/google/uuid/uuid.go
index b7b9ced315..23161a86c0 100644
--- a/vendor/github.com/google/uuid/uuid.go
+++ b/vendor/github.com/google/uuid/uuid.go
@@ -176,7 +176,7 @@ func (v Variant) String() string {
return fmt.Sprintf("BadVariant%d", int(v))
}
-// SetRand sets the random number generator to r, which implents io.Reader.
+// SetRand sets the random number generator to r, which implements io.Reader.
// If r.Read returns an error when the package requests random data then
// a panic will be issued.
//
diff --git a/vendor/github.com/google/uuid/version1.go b/vendor/github.com/google/uuid/version1.go
index 22dc07cdce..199a1ac654 100644
--- a/vendor/github.com/google/uuid/version1.go
+++ b/vendor/github.com/google/uuid/version1.go
@@ -13,7 +13,7 @@ import (
// or SetNodeInterface then it will be set automatically. If the NodeID cannot
// be set NewUUID returns nil. If clock sequence has not been set by
// SetClockSequence then it will be set automatically. If GetTime fails to
-// return the current NewUUID returns Nil and an error.
+// return the current NewUUID returns nil and an error.
//
// In most cases, New should be used.
func NewUUID() (UUID, error) {
diff --git a/vendor/github.com/google/uuid/version4.go b/vendor/github.com/google/uuid/version4.go
index 390dd2cad4..74c4e6c9f5 100644
--- a/vendor/github.com/google/uuid/version4.go
+++ b/vendor/github.com/google/uuid/version4.go
@@ -6,7 +6,7 @@ package uuid
import "io"
-// New is creates a new random UUID or panics. New is equivalent to
+// New creates a new random UUID or panics. New is equivalent to
// the expression
//
// uuid.Must(uuid.NewRandom())
@@ -19,7 +19,7 @@ func New() UUID {
// The strength of the UUIDs is based on the strength of the crypto/rand
// package.
//
-// A note about uniqueness derived from from the UUID Wikipedia entry:
+// A note about uniqueness derived from the UUID Wikipedia entry:
//
// Randomly generated UUIDs have 122 random bits. One's annual risk of being
// hit by a meteorite is estimated to be one chance in 17 billion, that
diff --git a/vendor/github.com/googollee/go-socket.io/.gitignore b/vendor/github.com/googollee/go-socket.io/.gitignore
new file mode 100644
index 0000000000..615566c1e5
--- /dev/null
+++ b/vendor/github.com/googollee/go-socket.io/.gitignore
@@ -0,0 +1,4 @@
+
+.DS_Store
+.idea/
+go.sum
\ No newline at end of file
diff --git a/vendor/github.com/googollee/go-socket.io/.travis.yml b/vendor/github.com/googollee/go-socket.io/.travis.yml
index 7141eabd29..2b5f7929c8 100644
--- a/vendor/github.com/googollee/go-socket.io/.travis.yml
+++ b/vendor/github.com/googollee/go-socket.io/.travis.yml
@@ -1,5 +1,7 @@
language: go
-go: 1.5
+go:
+- 1.7
+- 1.11
install:
- go get "github.com/smartystreets/goconvey/convey"
- go get -v .
diff --git a/vendor/github.com/googollee/go-socket.io/server.go b/vendor/github.com/googollee/go-socket.io/server.go
index 4e8d687c12..02fd438637 100644
--- a/vendor/github.com/googollee/go-socket.io/server.go
+++ b/vendor/github.com/googollee/go-socket.io/server.go
@@ -93,8 +93,8 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
// BroadcastTo is a server level broadcast function.
-func (s *Server) BroadcastTo(room, message string, args ...interface{}) {
- s.namespace.BroadcastTo(room, message, args...)
+func (s *Server) BroadcastTo(room, event string, args ...interface{}) {
+ s.namespace.BroadcastTo(room, event, args...)
}
func (s *Server) loop() {
diff --git a/vendor/github.com/gregjones/httpcache/.travis.yml b/vendor/github.com/gregjones/httpcache/.travis.yml
index b5ffbe03d8..2bca4c599f 100644
--- a/vendor/github.com/gregjones/httpcache/.travis.yml
+++ b/vendor/github.com/gregjones/httpcache/.travis.yml
@@ -4,7 +4,6 @@ go:
- 1.6.x
- 1.7.x
- 1.8.x
- - 1.9.x
- master
matrix:
allow_failures:
diff --git a/vendor/github.com/gregjones/httpcache/README.md b/vendor/github.com/gregjones/httpcache/README.md
index 09c9e7c173..61bd830e57 100644
--- a/vendor/github.com/gregjones/httpcache/README.md
+++ b/vendor/github.com/gregjones/httpcache/README.md
@@ -3,7 +3,7 @@ httpcache
[](https://travis-ci.org/gregjones/httpcache) [](https://godoc.org/github.com/gregjones/httpcache)
-Package httpcache provides a http.RoundTripper implementation that works as a mostly [RFC 7234](https://tools.ietf.org/html/rfc7234) compliant cache for http responses.
+Package httpcache provides a http.RoundTripper implementation that works as a mostly RFC-compliant cache for http responses.
It is only suitable for use as a 'private' cache (i.e. for a web-browser or an API-client and not for a shared proxy).
@@ -17,7 +17,6 @@ Cache Backends
- [`github.com/gregjones/httpcache/leveldbcache`](https://github.com/gregjones/httpcache/tree/master/leveldbcache) provides a filesystem-backed cache using [leveldb](https://github.com/syndtr/goleveldb/leveldb).
- [`github.com/die-net/lrucache`](https://github.com/die-net/lrucache) provides an in-memory cache that will evict least-recently used entries.
- [`github.com/die-net/lrucache/twotier`](https://github.com/die-net/lrucache/tree/master/twotier) allows caches to be combined, for example to use lrucache above with a persistent disk-cache.
-- [`github.com/birkelund/boltdbcache`](https://github.com/birkelund/boltdbcache) provides a BoltDB implementation (based on the [bbolt](https://github.com/coreos/bbolt) fork).
License
-------
diff --git a/vendor/github.com/gregjones/httpcache/httpcache.go b/vendor/github.com/gregjones/httpcache/httpcache.go
index f6a2ec4a53..8239edc2cb 100644
--- a/vendor/github.com/gregjones/httpcache/httpcache.go
+++ b/vendor/github.com/gregjones/httpcache/httpcache.go
@@ -10,6 +10,7 @@ import (
"bufio"
"bytes"
"errors"
+ "fmt"
"io"
"io/ioutil"
"net/http"
@@ -40,11 +41,7 @@ type Cache interface {
// cacheKey returns the cache key for req.
func cacheKey(req *http.Request) string {
- if req.Method == http.MethodGet {
- return req.URL.String()
- } else {
- return req.Method + " " + req.URL.String()
- }
+ return req.URL.String()
}
// CachedResponse returns the cached http.Response for req if present, and nil
@@ -192,11 +189,16 @@ func (t *Transport) RoundTrip(req *http.Request) (resp *http.Response, err error
for _, header := range endToEndHeaders {
cachedResp.Header[header] = resp.Header[header]
}
+ cachedResp.Status = fmt.Sprintf("%d %s", http.StatusOK, http.StatusText(http.StatusOK))
+ cachedResp.StatusCode = http.StatusOK
+
resp = cachedResp
} else if (err != nil || (cachedResp != nil && resp.StatusCode >= 500)) &&
req.Method == "GET" && canStaleOnError(cachedResp.Header, req.Header) {
// In case of transport failure and stale-if-error activated, returns cached content
// when available
+ cachedResp.Status = fmt.Sprintf("%d %s", http.StatusOK, http.StatusText(http.StatusOK))
+ cachedResp.StatusCode = http.StatusOK
return cachedResp, nil
} else {
if err != nil || resp.StatusCode != http.StatusOK {
diff --git a/vendor/github.com/imdario/mergo/.gitignore b/vendor/github.com/imdario/mergo/.gitignore
deleted file mode 100644
index 529c3412ba..0000000000
--- a/vendor/github.com/imdario/mergo/.gitignore
+++ /dev/null
@@ -1,33 +0,0 @@
-#### joe made this: http://goel.io/joe
-
-#### go ####
-# Binaries for programs and plugins
-*.exe
-*.dll
-*.so
-*.dylib
-
-# Test binary, build with `go test -c`
-*.test
-
-# Output of the go coverage tool, specifically when used with LiteIDE
-*.out
-
-# Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736
-.glide/
-
-#### vim ####
-# Swap
-[._]*.s[a-v][a-z]
-[._]*.sw[a-p]
-[._]s[a-v][a-z]
-[._]sw[a-p]
-
-# Session
-Session.vim
-
-# Temporary
-.netrwhist
-*~
-# Auto-generated tag files
-tags
diff --git a/vendor/github.com/imdario/mergo/.travis.yml b/vendor/github.com/imdario/mergo/.travis.yml
index b13a50ed1f..9d91c6339f 100644
--- a/vendor/github.com/imdario/mergo/.travis.yml
+++ b/vendor/github.com/imdario/mergo/.travis.yml
@@ -1,7 +1,2 @@
language: go
-install:
- - go get -t
- - go get golang.org/x/tools/cmd/cover
- - go get github.com/mattn/goveralls
-script:
- - $HOME/gopath/bin/goveralls -service=travis-ci -repotoken $COVERALLS_TOKEN
+install: go get -t
diff --git a/vendor/github.com/imdario/mergo/CODE_OF_CONDUCT.md b/vendor/github.com/imdario/mergo/CODE_OF_CONDUCT.md
deleted file mode 100644
index 469b44907a..0000000000
--- a/vendor/github.com/imdario/mergo/CODE_OF_CONDUCT.md
+++ /dev/null
@@ -1,46 +0,0 @@
-# Contributor Covenant Code of Conduct
-
-## Our Pledge
-
-In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
-
-## Our Standards
-
-Examples of behavior that contributes to creating a positive environment include:
-
-* Using welcoming and inclusive language
-* Being respectful of differing viewpoints and experiences
-* Gracefully accepting constructive criticism
-* Focusing on what is best for the community
-* Showing empathy towards other community members
-
-Examples of unacceptable behavior by participants include:
-
-* The use of sexualized language or imagery and unwelcome sexual attention or advances
-* Trolling, insulting/derogatory comments, and personal or political attacks
-* Public or private harassment
-* Publishing others' private information, such as a physical or electronic address, without explicit permission
-* Other conduct which could reasonably be considered inappropriate in a professional setting
-
-## Our Responsibilities
-
-Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
-
-Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
-
-## Scope
-
-This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
-
-## Enforcement
-
-Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at i@dario.im. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
-
-Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
-
-## Attribution
-
-This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
-
-[homepage]: http://contributor-covenant.org
-[version]: http://contributor-covenant.org/version/1/4/
diff --git a/vendor/github.com/imdario/mergo/README.md b/vendor/github.com/imdario/mergo/README.md
index 8b76f1fbf3..cdcea0f659 100644
--- a/vendor/github.com/imdario/mergo/README.md
+++ b/vendor/github.com/imdario/mergo/README.md
@@ -2,72 +2,14 @@
A helper to merge structs and maps in Golang. Useful for configuration default values, avoiding messy if-statements.
-Also a lovely [comune](http://en.wikipedia.org/wiki/Mergo) (municipality) in the Province of Ancona in the Italian region of Marche.
+Also a lovely [comune](http://en.wikipedia.org/wiki/Mergo) (municipality) in the Province of Ancona in the Italian region Marche.
+
+
## Status
-It is ready for production use. [It is used in several projects by Docker, Google, The Linux Foundation, VMWare, Shopify, etc](https://github.com/imdario/mergo#mergo-in-the-wild).
+It is ready for production use. It works fine although it may use more of testing. Here some projects in the wild using Mergo:
-[![GoDoc][3]][4]
-[![GoCard][5]][6]
-[![Build Status][1]][2]
-[![Coverage Status][7]][8]
-[![Sourcegraph][9]][10]
-
-[1]: https://travis-ci.org/imdario/mergo.png
-[2]: https://travis-ci.org/imdario/mergo
-[3]: https://godoc.org/github.com/imdario/mergo?status.svg
-[4]: https://godoc.org/github.com/imdario/mergo
-[5]: https://goreportcard.com/badge/imdario/mergo
-[6]: https://goreportcard.com/report/github.com/imdario/mergo
-[7]: https://coveralls.io/repos/github/imdario/mergo/badge.svg?branch=master
-[8]: https://coveralls.io/github/imdario/mergo?branch=master
-[9]: https://sourcegraph.com/github.com/imdario/mergo/-/badge.svg
-[10]: https://sourcegraph.com/github.com/imdario/mergo?badge
-
-### Latest release
-
-[Release v0.3.6](https://github.com/imdario/mergo/releases/tag/v0.3.6).
-
-### Important note
-
-Please keep in mind that in [0.3.2](//github.com/imdario/mergo/releases/tag/0.3.2) Mergo changed `Merge()`and `Map()` signatures to support [transformers](#transformers). An optional/variadic argument has been added, so it won't break existing code.
-
-If you were using Mergo **before** April 6th 2015, please check your project works as intended after updating your local copy with ```go get -u github.com/imdario/mergo```. I apologize for any issue caused by its previous behavior and any future bug that Mergo could cause (I hope it won't!) in existing projects after the change (release 0.2.0).
-
-### Donations
-
-If Mergo is useful to you, consider buying me a coffee, a beer or making a monthly donation so I can keep building great free software. :heart_eyes:
-
-
-[](https://beerpay.io/imdario/mergo)
-[](https://beerpay.io/imdario/mergo)
-
-
-### Mergo in the wild
-
-- [moby/moby](https://github.com/moby/moby)
-- [kubernetes/kubernetes](https://github.com/kubernetes/kubernetes)
-- [vmware/dispatch](https://github.com/vmware/dispatch)
-- [Shopify/themekit](https://github.com/Shopify/themekit)
-- [imdario/zas](https://github.com/imdario/zas)
-- [matcornic/hermes](https://github.com/matcornic/hermes)
-- [OpenBazaar/openbazaar-go](https://github.com/OpenBazaar/openbazaar-go)
-- [kataras/iris](https://github.com/kataras/iris)
-- [michaelsauter/crane](https://github.com/michaelsauter/crane)
-- [go-task/task](https://github.com/go-task/task)
-- [sensu/uchiwa](https://github.com/sensu/uchiwa)
-- [ory/hydra](https://github.com/ory/hydra)
-- [sisatech/vcli](https://github.com/sisatech/vcli)
-- [dairycart/dairycart](https://github.com/dairycart/dairycart)
-- [projectcalico/felix](https://github.com/projectcalico/felix)
-- [resin-os/balena](https://github.com/resin-os/balena)
-- [go-kivik/kivik](https://github.com/go-kivik/kivik)
-- [Telefonica/govice](https://github.com/Telefonica/govice)
-- [supergiant/supergiant](supergiant/supergiant)
-- [SergeyTsalkov/brooce](https://github.com/SergeyTsalkov/brooce)
-- [soniah/dnsmadeeasy](https://github.com/soniah/dnsmadeeasy)
-- [ohsu-comp-bio/funnel](https://github.com/ohsu-comp-bio/funnel)
- [EagerIO/Stout](https://github.com/EagerIO/Stout)
- [lynndylanhurley/defsynth-api](https://github.com/lynndylanhurley/defsynth-api)
- [russross/canvasassignments](https://github.com/russross/canvasassignments)
@@ -75,17 +17,12 @@ If Mergo is useful to you, consider buying me a coffee, a beer or making a month
- [casualjim/exeggutor](https://github.com/casualjim/exeggutor)
- [divshot/gitling](https://github.com/divshot/gitling)
- [RWJMurphy/gorl](https://github.com/RWJMurphy/gorl)
-- [andrerocker/deploy42](https://github.com/andrerocker/deploy42)
-- [elwinar/rambler](https://github.com/elwinar/rambler)
-- [tmaiaroto/gopartman](https://github.com/tmaiaroto/gopartman)
-- [jfbus/impressionist](https://github.com/jfbus/impressionist)
-- [Jmeyering/zealot](https://github.com/Jmeyering/zealot)
-- [godep-migrator/rigger-host](https://github.com/godep-migrator/rigger-host)
-- [Dronevery/MultiwaySwitch-Go](https://github.com/Dronevery/MultiwaySwitch-Go)
-- [thoas/picfit](https://github.com/thoas/picfit)
-- [mantasmatelis/whooplist-server](https://github.com/mantasmatelis/whooplist-server)
-- [jnuthong/item_search](https://github.com/jnuthong/item_search)
-- [bukalapak/snowboard](https://github.com/bukalapak/snowboard)
+
+[![Build Status][1]][2]
+[](https://godoc.org/github.com/imdario/mergo)
+
+[1]: https://travis-ci.org/imdario/mergo.png
+[2]: https://travis-ci.org/imdario/mergo
## Installation
@@ -98,116 +35,25 @@ If Mergo is useful to you, consider buying me a coffee, a beer or making a month
## Usage
-You can only merge same-type structs with exported fields initialized as zero value of their type and same-types maps. Mergo won't merge unexported (private) fields but will do recursively any exported one. It won't merge empty structs value as [they are not considered zero values](https://golang.org/ref/spec#The_zero_value) either. Also maps will be merged recursively except for structs inside maps (because they are not addressable using Go reflection).
+You can only merge same-type structs with exported fields initialized as zero value of their type and same-types maps. Mergo won't merge unexported (private) fields but will do recursively any exported one. Also maps will be merged recursively except for structs inside maps (because they are not addressable using Go reflection).
-```go
-if err := mergo.Merge(&dst, src); err != nil {
- // ...
-}
-```
+ if err := mergo.Merge(&dst, src); err != nil {
+ // ...
+ }
-Also, you can merge overwriting values using the transformer `WithOverride`.
+Additionally, you can map a map[string]interface{} to a struct (and otherwise, from struct to map), following the same restrictions as in Merge(). Keys are capitalized to find each corresponding exported field.
-```go
-if err := mergo.Merge(&dst, src, mergo.WithOverride); err != nil {
- // ...
-}
-```
+ if err := mergo.Map(&dst, srcMap); err != nil {
+ // ...
+ }
-Additionally, you can map a `map[string]interface{}` to a struct (and otherwise, from struct to map), following the same restrictions as in `Merge()`. Keys are capitalized to find each corresponding exported field.
-
-```go
-if err := mergo.Map(&dst, srcMap); err != nil {
- // ...
-}
-```
-
-Warning: if you map a struct to map, it won't do it recursively. Don't expect Mergo to map struct members of your struct as `map[string]interface{}`. They will be just assigned as values.
+Warning: if you map a struct to map, it won't do it recursively. Don't expect Mergo to map struct members of your struct as map[string]interface{}. They will be just assigned as values.
More information and examples in [godoc documentation](http://godoc.org/github.com/imdario/mergo).
-### Nice example
-
-```go
-package main
-
-import (
- "fmt"
- "github.com/imdario/mergo"
-)
-
-type Foo struct {
- A string
- B int64
-}
-
-func main() {
- src := Foo{
- A: "one",
- B: 2,
- }
- dest := Foo{
- A: "two",
- }
- mergo.Merge(&dest, src)
- fmt.Println(dest)
- // Will print
- // {two 2}
-}
-```
-
Note: if test are failing due missing package, please execute:
- go get gopkg.in/yaml.v2
-
-### Transformers
-
-Transformers allow to merge specific types differently than in the default behavior. In other words, now you can customize how some types are merged. For example, `time.Time` is a struct; it doesn't have zero value but IsZero can return true because it has fields with zero value. How can we merge a non-zero `time.Time`?
-
-```go
-package main
-
-import (
- "fmt"
- "github.com/imdario/mergo"
- "reflect"
- "time"
-)
-
-type timeTransfomer struct {
-}
-
-func (t timeTransfomer) Transformer(typ reflect.Type) func(dst, src reflect.Value) error {
- if typ == reflect.TypeOf(time.Time{}) {
- return func(dst, src reflect.Value) error {
- if dst.CanSet() {
- isZero := dst.MethodByName("IsZero")
- result := isZero.Call([]reflect.Value{})
- if result[0].Bool() {
- dst.Set(src)
- }
- }
- return nil
- }
- }
- return nil
-}
-
-type Snapshot struct {
- Time time.Time
- // ...
-}
-
-func main() {
- src := Snapshot{time.Now()}
- dest := Snapshot{}
- mergo.Merge(&dest, src, mergo.WithTransformers(timeTransfomer{}))
- fmt.Println(dest)
- // Will print
- // { 2018-01-12 01:15:00 +0000 UTC m=+0.000000001 }
-}
-```
-
+ go get gopkg.in/yaml.v1
## Contact me
diff --git a/vendor/github.com/imdario/mergo/map.go b/vendor/github.com/imdario/mergo/map.go
index 6ea38e636b..44361e88be 100644
--- a/vendor/github.com/imdario/mergo/map.go
+++ b/vendor/github.com/imdario/mergo/map.go
@@ -31,8 +31,7 @@ func isExported(field reflect.StructField) bool {
// Traverses recursively both values, assigning src's fields values to dst.
// The map argument tracks comparisons that have already been seen, which allows
// short circuiting on recursive types.
-func deepMap(dst, src reflect.Value, visited map[uintptr]*visit, depth int, config *Config) (err error) {
- overwrite := config.Overwrite
+func deepMap(dst, src reflect.Value, visited map[uintptr]*visit, depth int) (err error) {
if dst.CanAddr() {
addr := dst.UnsafeAddr()
h := 17 * addr
@@ -58,17 +57,10 @@ func deepMap(dst, src reflect.Value, visited map[uintptr]*visit, depth int, conf
}
fieldName := field.Name
fieldName = changeInitialCase(fieldName, unicode.ToLower)
- if v, ok := dstMap[fieldName]; !ok || (isEmptyValue(reflect.ValueOf(v)) || overwrite) {
+ if v, ok := dstMap[fieldName]; !ok || isEmptyValue(reflect.ValueOf(v)) {
dstMap[fieldName] = src.Field(i).Interface()
}
}
- case reflect.Ptr:
- if dst.IsNil() {
- v := reflect.New(dst.Type().Elem())
- dst.Set(v)
- }
- dst = dst.Elem()
- fallthrough
case reflect.Struct:
srcMap := src.Interface().(map[string]interface{})
for key := range srcMap {
@@ -93,24 +85,21 @@ func deepMap(dst, src reflect.Value, visited map[uintptr]*visit, depth int, conf
srcKind = reflect.Ptr
}
}
-
if !srcElement.IsValid() {
continue
}
if srcKind == dstKind {
- if err = deepMerge(dstElement, srcElement, visited, depth+1, config); err != nil {
- return
- }
- } else if dstKind == reflect.Interface && dstElement.Kind() == reflect.Interface {
- if err = deepMerge(dstElement, srcElement, visited, depth+1, config); err != nil {
- return
- }
- } else if srcKind == reflect.Map {
- if err = deepMap(dstElement, srcElement, visited, depth+1, config); err != nil {
+ if err = deepMerge(dstElement, srcElement, visited, depth+1); err != nil {
return
}
} else {
- return fmt.Errorf("type mismatch on %s field: found %v, expected %v", fieldName, srcKind, dstKind)
+ if srcKind == reflect.Map {
+ if err = deepMap(dstElement, srcElement, visited, depth+1); err != nil {
+ return
+ }
+ } else {
+ return fmt.Errorf("type mismatch on %s field: found %v, expected %v", fieldName, srcKind, dstKind)
+ }
}
}
}
@@ -128,35 +117,18 @@ func deepMap(dst, src reflect.Value, visited map[uintptr]*visit, depth int, conf
// doesn't apply if dst is a map.
// This is separated method from Merge because it is cleaner and it keeps sane
// semantics: merging equal types, mapping different (restricted) types.
-func Map(dst, src interface{}, opts ...func(*Config)) error {
- return _map(dst, src, opts...)
-}
-
-// MapWithOverwrite will do the same as Map except that non-empty dst attributes will be overridden by
-// non-empty src attribute values.
-// Deprecated: Use Map(…) with WithOverride
-func MapWithOverwrite(dst, src interface{}, opts ...func(*Config)) error {
- return _map(dst, src, append(opts, WithOverride)...)
-}
-
-func _map(dst, src interface{}, opts ...func(*Config)) error {
+func Map(dst, src interface{}) error {
var (
vDst, vSrc reflect.Value
err error
)
- config := &Config{}
-
- for _, opt := range opts {
- opt(config)
- }
-
if vDst, vSrc, err = resolveValues(dst, src); err != nil {
return err
}
// To be friction-less, we redirect equal-type arguments
// to deepMerge. Only because arguments can be anything.
if vSrc.Kind() == vDst.Kind() {
- return deepMerge(vDst, vSrc, make(map[uintptr]*visit), 0, config)
+ return deepMerge(vDst, vSrc, make(map[uintptr]*visit), 0)
}
switch vSrc.Kind() {
case reflect.Struct:
@@ -170,5 +142,5 @@ func _map(dst, src interface{}, opts ...func(*Config)) error {
default:
return ErrNotSupported
}
- return deepMap(vDst, vSrc, make(map[uintptr]*visit), 0, config)
+ return deepMap(vDst, vSrc, make(map[uintptr]*visit), 0)
}
diff --git a/vendor/github.com/imdario/mergo/merge.go b/vendor/github.com/imdario/mergo/merge.go
index 44f70a89d9..5d328b1fe7 100644
--- a/vendor/github.com/imdario/mergo/merge.go
+++ b/vendor/github.com/imdario/mergo/merge.go
@@ -9,38 +9,13 @@
package mergo
import (
- "fmt"
"reflect"
)
-func hasExportedField(dst reflect.Value) (exported bool) {
- for i, n := 0, dst.NumField(); i < n; i++ {
- field := dst.Type().Field(i)
- if field.Anonymous && dst.Field(i).Kind() == reflect.Struct {
- exported = exported || hasExportedField(dst.Field(i))
- } else {
- exported = exported || len(field.PkgPath) == 0
- }
- }
- return
-}
-
-type Config struct {
- Overwrite bool
- AppendSlice bool
- Transformers Transformers
-}
-
-type Transformers interface {
- Transformer(reflect.Type) func(dst, src reflect.Value) error
-}
-
// Traverses recursively both values, assigning src's fields values to dst.
// The map argument tracks comparisons that have already been seen, which allows
// short circuiting on recursive types.
-func deepMerge(dst, src reflect.Value, visited map[uintptr]*visit, depth int, config *Config) (err error) {
- overwrite := config.Overwrite
-
+func deepMerge(dst, src reflect.Value, visited map[uintptr]*visit, depth int) (err error) {
if !src.IsValid() {
return
}
@@ -57,196 +32,68 @@ func deepMerge(dst, src reflect.Value, visited map[uintptr]*visit, depth int, co
// Remember, remember...
visited[h] = &visit{addr, typ, seen}
}
-
- if config.Transformers != nil && !isEmptyValue(dst) {
- if fn := config.Transformers.Transformer(dst.Type()); fn != nil {
- err = fn(dst, src)
- return
- }
- }
-
switch dst.Kind() {
case reflect.Struct:
- if hasExportedField(dst) {
- for i, n := 0, dst.NumField(); i < n; i++ {
- if err = deepMerge(dst.Field(i), src.Field(i), visited, depth+1, config); err != nil {
- return
- }
- }
- } else {
- if dst.CanSet() && !isEmptyValue(src) && (overwrite || isEmptyValue(dst)) {
- dst.Set(src)
+ for i, n := 0, dst.NumField(); i < n; i++ {
+ if err = deepMerge(dst.Field(i), src.Field(i), visited, depth+1); err != nil {
+ return
}
}
case reflect.Map:
- if dst.IsNil() && !src.IsNil() {
- dst.Set(reflect.MakeMap(dst.Type()))
- }
for _, key := range src.MapKeys() {
srcElement := src.MapIndex(key)
if !srcElement.IsValid() {
continue
}
dstElement := dst.MapIndex(key)
- switch srcElement.Kind() {
- case reflect.Chan, reflect.Func, reflect.Map, reflect.Interface, reflect.Slice:
- if srcElement.IsNil() {
- continue
- }
+ switch reflect.TypeOf(srcElement.Interface()).Kind() {
+ case reflect.Struct:
fallthrough
- default:
- if !srcElement.CanInterface() {
- continue
- }
- switch reflect.TypeOf(srcElement.Interface()).Kind() {
- case reflect.Struct:
- fallthrough
- case reflect.Ptr:
- fallthrough
- case reflect.Map:
- srcMapElm := srcElement
- dstMapElm := dstElement
- if srcMapElm.CanInterface() {
- srcMapElm = reflect.ValueOf(srcMapElm.Interface())
- if dstMapElm.IsValid() {
- dstMapElm = reflect.ValueOf(dstMapElm.Interface())
- }
- }
- if err = deepMerge(dstMapElm, srcMapElm, visited, depth+1, config); err != nil {
- return
- }
- case reflect.Slice:
- srcSlice := reflect.ValueOf(srcElement.Interface())
-
- var dstSlice reflect.Value
- if !dstElement.IsValid() || dstElement.IsNil() {
- dstSlice = reflect.MakeSlice(srcSlice.Type(), 0, srcSlice.Len())
- } else {
- dstSlice = reflect.ValueOf(dstElement.Interface())
- }
-
- if !isEmptyValue(src) && (overwrite || isEmptyValue(dst)) && !config.AppendSlice {
- dstSlice = srcSlice
- } else if config.AppendSlice {
- if srcSlice.Type() != dstSlice.Type() {
- return fmt.Errorf("cannot append two slice with different type (%s, %s)", srcSlice.Type(), dstSlice.Type())
- }
- dstSlice = reflect.AppendSlice(dstSlice, srcSlice)
- }
- dst.SetMapIndex(key, dstSlice)
+ case reflect.Map:
+ if err = deepMerge(dstElement, srcElement, visited, depth+1); err != nil {
+ return
}
}
- if dstElement.IsValid() && reflect.TypeOf(srcElement.Interface()).Kind() == reflect.Map {
- continue
- }
-
- if srcElement.IsValid() && (overwrite || (!dstElement.IsValid() || isEmptyValue(dstElement))) {
- if dst.IsNil() {
- dst.Set(reflect.MakeMap(dst.Type()))
- }
+ if !dstElement.IsValid() {
dst.SetMapIndex(key, srcElement)
}
}
- case reflect.Slice:
- if !dst.CanSet() {
- break
- }
- if !isEmptyValue(src) && (overwrite || isEmptyValue(dst)) && !config.AppendSlice {
- dst.Set(src)
- } else if config.AppendSlice {
- if src.Type() != dst.Type() {
- return fmt.Errorf("cannot append two slice with different type (%s, %s)", src.Type(), dst.Type())
- }
- dst.Set(reflect.AppendSlice(dst, src))
- }
case reflect.Ptr:
fallthrough
case reflect.Interface:
if src.IsNil() {
break
- }
- if src.Kind() != reflect.Interface {
- if dst.IsNil() || overwrite {
- if dst.CanSet() && (overwrite || isEmptyValue(dst)) {
- dst.Set(src)
- }
- } else if src.Kind() == reflect.Ptr {
- if err = deepMerge(dst.Elem(), src.Elem(), visited, depth+1, config); err != nil {
- return
- }
- } else if dst.Elem().Type() == src.Type() {
- if err = deepMerge(dst.Elem(), src, visited, depth+1, config); err != nil {
- return
- }
- } else {
- return ErrDifferentArgumentsTypes
- }
- break
- }
- if dst.IsNil() || overwrite {
- if dst.CanSet() && (overwrite || isEmptyValue(dst)) {
+ } else if dst.IsNil() {
+ if dst.CanSet() && isEmptyValue(dst) {
dst.Set(src)
}
- } else if err = deepMerge(dst.Elem(), src.Elem(), visited, depth+1, config); err != nil {
+ } else if err = deepMerge(dst.Elem(), src.Elem(), visited, depth+1); err != nil {
return
}
default:
- if dst.CanSet() && !isEmptyValue(src) && (overwrite || isEmptyValue(dst)) {
+ if dst.CanSet() && !isEmptyValue(src) {
dst.Set(src)
}
}
return
}
-// Merge will fill any empty for value type attributes on the dst struct using corresponding
-// src attributes if they themselves are not empty. dst and src must be valid same-type structs
-// and dst must be a pointer to struct.
-// It won't merge unexported (private) fields and will do recursively any exported field.
-func Merge(dst, src interface{}, opts ...func(*Config)) error {
- return merge(dst, src, opts...)
-}
-
-// MergeWithOverwrite will do the same as Merge except that non-empty dst attributes will be overriden by
-// non-empty src attribute values.
-// Deprecated: use Merge(…) with WithOverride
-func MergeWithOverwrite(dst, src interface{}, opts ...func(*Config)) error {
- return merge(dst, src, append(opts, WithOverride)...)
-}
-
-// WithTransformers adds transformers to merge, allowing to customize the merging of some types.
-func WithTransformers(transformers Transformers) func(*Config) {
- return func(config *Config) {
- config.Transformers = transformers
- }
-}
-
-// WithOverride will make merge override non-empty dst attributes with non-empty src attributes values.
-func WithOverride(config *Config) {
- config.Overwrite = true
-}
-
-// WithAppendSlice will make merge append slices instead of overwriting it
-func WithAppendSlice(config *Config) {
- config.AppendSlice = true
-}
-
-func merge(dst, src interface{}, opts ...func(*Config)) error {
+// Merge sets fields' values in dst from src if they have a zero
+// value of their type.
+// dst and src must be valid same-type structs and dst must be
+// a pointer to struct.
+// It won't merge unexported (private) fields and will do recursively
+// any exported field.
+func Merge(dst, src interface{}) error {
var (
vDst, vSrc reflect.Value
err error
)
-
- config := &Config{}
-
- for _, opt := range opts {
- opt(config)
- }
-
if vDst, vSrc, err = resolveValues(dst, src); err != nil {
return err
}
if vDst.Type() != vSrc.Type() {
return ErrDifferentArgumentsTypes
}
- return deepMerge(vDst, vSrc, make(map[uintptr]*visit), 0, config)
+ return deepMerge(vDst, vSrc, make(map[uintptr]*visit), 0)
}
diff --git a/vendor/github.com/imdario/mergo/mergo.go b/vendor/github.com/imdario/mergo/mergo.go
index a82fea2fdc..f8a0991ec6 100644
--- a/vendor/github.com/imdario/mergo/mergo.go
+++ b/vendor/github.com/imdario/mergo/mergo.go
@@ -32,7 +32,7 @@ type visit struct {
next *visit
}
-// From src/pkg/encoding/json/encode.go.
+// From src/pkg/encoding/json.
func isEmptyValue(v reflect.Value) bool {
switch v.Kind() {
case reflect.Array, reflect.Map, reflect.Slice, reflect.String:
@@ -46,14 +46,7 @@ func isEmptyValue(v reflect.Value) bool {
case reflect.Float32, reflect.Float64:
return v.Float() == 0
case reflect.Interface, reflect.Ptr:
- if v.IsNil() {
- return true
- }
- return isEmptyValue(v.Elem())
- case reflect.Func:
return v.IsNil()
- case reflect.Invalid:
- return true
}
return false
}
diff --git a/vendor/github.com/imdario/mergo/testdata/license.yml b/vendor/github.com/imdario/mergo/testdata/license.yml
index 2f1ad0082b..62fdb61ec3 100644
--- a/vendor/github.com/imdario/mergo/testdata/license.yml
+++ b/vendor/github.com/imdario/mergo/testdata/license.yml
@@ -1,4 +1,3 @@
import: ../../../../fossene/db/schema/thing.yml
fields:
site: string
- author: root
diff --git a/vendor/github.com/json-iterator/go/adapter.go b/vendor/github.com/json-iterator/go/adapter.go
index f371bfed76..e674d0f397 100644
--- a/vendor/github.com/json-iterator/go/adapter.go
+++ b/vendor/github.com/json-iterator/go/adapter.go
@@ -81,10 +81,12 @@ func (adapter *Decoder) More() bool {
if iter.Error != nil {
return false
}
- if iter.head != iter.tail {
- return true
+ c := iter.nextToken()
+ if c == 0 {
+ return false
}
- return iter.loadMore()
+ iter.unreadByte()
+ return c != ']' && c != '}'
}
// Buffered remaining buffer
@@ -98,7 +100,7 @@ func (adapter *Decoder) Buffered() io.Reader {
func (adapter *Decoder) UseNumber() {
cfg := adapter.iter.cfg.configBeforeFrozen
cfg.UseNumber = true
- adapter.iter.cfg = cfg.frozeWithCacheReuse()
+ adapter.iter.cfg = cfg.frozeWithCacheReuse(adapter.iter.cfg.extraExtensions)
}
// DisallowUnknownFields causes the Decoder to return an error when the destination
@@ -107,7 +109,7 @@ func (adapter *Decoder) UseNumber() {
func (adapter *Decoder) DisallowUnknownFields() {
cfg := adapter.iter.cfg.configBeforeFrozen
cfg.DisallowUnknownFields = true
- adapter.iter.cfg = cfg.frozeWithCacheReuse()
+ adapter.iter.cfg = cfg.frozeWithCacheReuse(adapter.iter.cfg.extraExtensions)
}
// NewEncoder same as json.NewEncoder
@@ -132,14 +134,14 @@ func (adapter *Encoder) Encode(val interface{}) error {
func (adapter *Encoder) SetIndent(prefix, indent string) {
config := adapter.stream.cfg.configBeforeFrozen
config.IndentionStep = len(indent)
- adapter.stream.cfg = config.frozeWithCacheReuse()
+ adapter.stream.cfg = config.frozeWithCacheReuse(adapter.stream.cfg.extraExtensions)
}
// SetEscapeHTML escape html by default, set to false to disable
func (adapter *Encoder) SetEscapeHTML(escapeHTML bool) {
config := adapter.stream.cfg.configBeforeFrozen
config.EscapeHTML = escapeHTML
- adapter.stream.cfg = config.frozeWithCacheReuse()
+ adapter.stream.cfg = config.frozeWithCacheReuse(adapter.stream.cfg.extraExtensions)
}
// Valid reports whether data is a valid JSON encoding.
diff --git a/vendor/github.com/json-iterator/go/config.go b/vendor/github.com/json-iterator/go/config.go
index 835819129c..8c58fcba59 100644
--- a/vendor/github.com/json-iterator/go/config.go
+++ b/vendor/github.com/json-iterator/go/config.go
@@ -74,7 +74,9 @@ type frozenConfig struct {
disallowUnknownFields bool
decoderCache *concurrent.Map
encoderCache *concurrent.Map
- extensions []Extension
+ encoderExtension Extension
+ decoderExtension Extension
+ extraExtensions []Extension
streamPool *sync.Pool
iteratorPool *sync.Pool
caseSensitive bool
@@ -158,22 +160,21 @@ func (cfg Config) Froze() API {
if cfg.ValidateJsonRawMessage {
api.validateJsonRawMessage(encoderExtension)
}
- if len(encoderExtension) > 0 {
- api.extensions = append(api.extensions, encoderExtension)
- }
- if len(decoderExtension) > 0 {
- api.extensions = append(api.extensions, decoderExtension)
- }
+ api.encoderExtension = encoderExtension
+ api.decoderExtension = decoderExtension
api.configBeforeFrozen = cfg
return api
}
-func (cfg Config) frozeWithCacheReuse() *frozenConfig {
+func (cfg Config) frozeWithCacheReuse(extraExtensions []Extension) *frozenConfig {
api := getFrozenConfigFromCache(cfg)
if api != nil {
return api
}
api = cfg.Froze().(*frozenConfig)
+ for _, extension := range extraExtensions {
+ api.RegisterExtension(extension)
+ }
addFrozenConfigToCache(cfg, api)
return api
}
@@ -190,7 +191,7 @@ func (cfg *frozenConfig) validateJsonRawMessage(extension EncoderExtension) {
stream.WriteRaw(string(rawMessage))
}
}, func(ptr unsafe.Pointer) bool {
- return false
+ return len(*((*json.RawMessage)(ptr))) == 0
}}
extension[reflect2.TypeOfPtr((*json.RawMessage)(nil)).Elem()] = encoder
extension[reflect2.TypeOfPtr((*RawMessage)(nil)).Elem()] = encoder
@@ -219,7 +220,9 @@ func (cfg *frozenConfig) getTagKey() string {
}
func (cfg *frozenConfig) RegisterExtension(extension Extension) {
- cfg.extensions = append(cfg.extensions, extension)
+ cfg.extraExtensions = append(cfg.extraExtensions, extension)
+ copied := cfg.configBeforeFrozen
+ cfg.configBeforeFrozen = copied
}
type lossyFloat32Encoder struct {
@@ -314,7 +317,7 @@ func (cfg *frozenConfig) MarshalIndent(v interface{}, prefix, indent string) ([]
}
newCfg := cfg.configBeforeFrozen
newCfg.IndentionStep = len(indent)
- return newCfg.frozeWithCacheReuse().Marshal(v)
+ return newCfg.frozeWithCacheReuse(cfg.extraExtensions).Marshal(v)
}
func (cfg *frozenConfig) UnmarshalFromString(str string, v interface{}) error {
diff --git a/vendor/github.com/json-iterator/go/iter_object.go b/vendor/github.com/json-iterator/go/iter_object.go
index 6e7c370abe..1c57576713 100644
--- a/vendor/github.com/json-iterator/go/iter_object.go
+++ b/vendor/github.com/json-iterator/go/iter_object.go
@@ -2,7 +2,7 @@ package jsoniter
import (
"fmt"
- "unicode"
+ "strings"
)
// ReadObject read one field from object.
@@ -96,13 +96,12 @@ func (iter *Iterator) readFieldHash() int64 {
}
func calcHash(str string, caseSensitive bool) int64 {
+ if !caseSensitive {
+ str = strings.ToLower(str)
+ }
hash := int64(0x811c9dc5)
- for _, b := range str {
- if caseSensitive {
- hash ^= int64(b)
- } else {
- hash ^= int64(unicode.ToLower(b))
- }
+ for _, b := range []byte(str) {
+ hash ^= int64(b)
hash *= 0x1000193
}
return int64(hash)
diff --git a/vendor/github.com/json-iterator/go/reflect.go b/vendor/github.com/json-iterator/go/reflect.go
index be7a0e2188..4459e203fb 100644
--- a/vendor/github.com/json-iterator/go/reflect.go
+++ b/vendor/github.com/json-iterator/go/reflect.go
@@ -120,7 +120,8 @@ func decoderOfType(ctx *ctx, typ reflect2.Type) ValDecoder {
for _, extension := range extensions {
decoder = extension.DecorateDecoder(typ, decoder)
}
- for _, extension := range ctx.extensions {
+ decoder = ctx.decoderExtension.DecorateDecoder(typ, decoder)
+ for _, extension := range ctx.extraExtensions {
decoder = extension.DecorateDecoder(typ, decoder)
}
return decoder
@@ -222,7 +223,8 @@ func encoderOfType(ctx *ctx, typ reflect2.Type) ValEncoder {
for _, extension := range extensions {
encoder = extension.DecorateEncoder(typ, encoder)
}
- for _, extension := range ctx.extensions {
+ encoder = ctx.encoderExtension.DecorateEncoder(typ, encoder)
+ for _, extension := range ctx.extraExtensions {
encoder = extension.DecorateEncoder(typ, encoder)
}
return encoder
diff --git a/vendor/github.com/json-iterator/go/reflect_extension.go b/vendor/github.com/json-iterator/go/reflect_extension.go
index 917bbe84ec..04f68756bf 100644
--- a/vendor/github.com/json-iterator/go/reflect_extension.go
+++ b/vendor/github.com/json-iterator/go/reflect_extension.go
@@ -246,7 +246,8 @@ func getTypeDecoderFromExtension(ctx *ctx, typ reflect2.Type) ValDecoder {
for _, extension := range extensions {
decoder = extension.DecorateDecoder(typ, decoder)
}
- for _, extension := range ctx.extensions {
+ decoder = ctx.decoderExtension.DecorateDecoder(typ, decoder)
+ for _, extension := range ctx.extraExtensions {
decoder = extension.DecorateDecoder(typ, decoder)
}
}
@@ -259,14 +260,18 @@ func _getTypeDecoderFromExtension(ctx *ctx, typ reflect2.Type) ValDecoder {
return decoder
}
}
- for _, extension := range ctx.extensions {
+ decoder := ctx.decoderExtension.CreateDecoder(typ)
+ if decoder != nil {
+ return decoder
+ }
+ for _, extension := range ctx.extraExtensions {
decoder := extension.CreateDecoder(typ)
if decoder != nil {
return decoder
}
}
typeName := typ.String()
- decoder := typeDecoders[typeName]
+ decoder = typeDecoders[typeName]
if decoder != nil {
return decoder
}
@@ -286,7 +291,8 @@ func getTypeEncoderFromExtension(ctx *ctx, typ reflect2.Type) ValEncoder {
for _, extension := range extensions {
encoder = extension.DecorateEncoder(typ, encoder)
}
- for _, extension := range ctx.extensions {
+ encoder = ctx.encoderExtension.DecorateEncoder(typ, encoder)
+ for _, extension := range ctx.extraExtensions {
encoder = extension.DecorateEncoder(typ, encoder)
}
}
@@ -300,14 +306,18 @@ func _getTypeEncoderFromExtension(ctx *ctx, typ reflect2.Type) ValEncoder {
return encoder
}
}
- for _, extension := range ctx.extensions {
+ encoder := ctx.encoderExtension.CreateEncoder(typ)
+ if encoder != nil {
+ return encoder
+ }
+ for _, extension := range ctx.extraExtensions {
encoder := extension.CreateEncoder(typ)
if encoder != nil {
return encoder
}
}
typeName := typ.String()
- encoder := typeEncoders[typeName]
+ encoder = typeEncoders[typeName]
if encoder != nil {
return encoder
}
@@ -393,7 +403,9 @@ func createStructDescriptor(ctx *ctx, typ reflect2.Type, bindings []*Binding, em
for _, extension := range extensions {
extension.UpdateStructDescriptor(structDescriptor)
}
- for _, extension := range ctx.extensions {
+ ctx.encoderExtension.UpdateStructDescriptor(structDescriptor)
+ ctx.decoderExtension.UpdateStructDescriptor(structDescriptor)
+ for _, extension := range ctx.extraExtensions {
extension.UpdateStructDescriptor(structDescriptor)
}
processTags(structDescriptor, ctx.frozenConfig)
diff --git a/vendor/github.com/json-iterator/go/reflect_map.go b/vendor/github.com/json-iterator/go/reflect_map.go
index 8812f08501..7f66a88b04 100644
--- a/vendor/github.com/json-iterator/go/reflect_map.go
+++ b/vendor/github.com/json-iterator/go/reflect_map.go
@@ -39,7 +39,11 @@ func encoderOfMap(ctx *ctx, typ reflect2.Type) ValEncoder {
}
func decoderOfMapKey(ctx *ctx, typ reflect2.Type) ValDecoder {
- for _, extension := range ctx.extensions {
+ decoder := ctx.decoderExtension.CreateMapKeyDecoder(typ)
+ if decoder != nil {
+ return decoder
+ }
+ for _, extension := range ctx.extraExtensions {
decoder := extension.CreateMapKeyDecoder(typ)
if decoder != nil {
return decoder
@@ -77,7 +81,11 @@ func decoderOfMapKey(ctx *ctx, typ reflect2.Type) ValDecoder {
}
func encoderOfMapKey(ctx *ctx, typ reflect2.Type) ValEncoder {
- for _, extension := range ctx.extensions {
+ encoder := ctx.encoderExtension.CreateMapKeyEncoder(typ)
+ if encoder != nil {
+ return encoder
+ }
+ for _, extension := range ctx.extraExtensions {
encoder := extension.CreateMapKeyEncoder(typ)
if encoder != nil {
return encoder
diff --git a/vendor/github.com/konsorten/go-windows-terminal-sequences/LICENSE b/vendor/github.com/konsorten/go-windows-terminal-sequences/LICENSE
new file mode 100644
index 0000000000..14127cd831
--- /dev/null
+++ b/vendor/github.com/konsorten/go-windows-terminal-sequences/LICENSE
@@ -0,0 +1,9 @@
+(The MIT License)
+
+Copyright (c) 2017 marvin + konsorten GmbH (open-source@konsorten.de)
+
+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/vendor/github.com/konsorten/go-windows-terminal-sequences/README.md b/vendor/github.com/konsorten/go-windows-terminal-sequences/README.md
new file mode 100644
index 0000000000..949b77e304
--- /dev/null
+++ b/vendor/github.com/konsorten/go-windows-terminal-sequences/README.md
@@ -0,0 +1,40 @@
+# Windows Terminal Sequences
+
+This library allow for enabling Windows terminal color support for Go.
+
+See [Console Virtual Terminal Sequences](https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences) for details.
+
+## Usage
+
+```go
+import (
+ "syscall"
+
+ sequences "github.com/konsorten/go-windows-terminal-sequences"
+)
+
+func main() {
+ sequences.EnableVirtualTerminalProcessing(syscall.Stdout, true)
+}
+
+```
+
+## Authors
+
+The tool is sponsored by the [marvin + konsorten GmbH](http://www.konsorten.de).
+
+We thank all the authors who provided code to this library:
+
+* Felix Kollmann
+
+## License
+
+(The MIT License)
+
+Copyright (c) 2018 marvin + konsorten GmbH (open-source@konsorten.de)
+
+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/vendor/github.com/konsorten/go-windows-terminal-sequences/go.mod b/vendor/github.com/konsorten/go-windows-terminal-sequences/go.mod
new file mode 100644
index 0000000000..716c613125
--- /dev/null
+++ b/vendor/github.com/konsorten/go-windows-terminal-sequences/go.mod
@@ -0,0 +1 @@
+module github.com/konsorten/go-windows-terminal-sequences
diff --git a/vendor/github.com/konsorten/go-windows-terminal-sequences/sequences.go b/vendor/github.com/konsorten/go-windows-terminal-sequences/sequences.go
new file mode 100644
index 0000000000..ef18d8f978
--- /dev/null
+++ b/vendor/github.com/konsorten/go-windows-terminal-sequences/sequences.go
@@ -0,0 +1,36 @@
+// +build windows
+
+package sequences
+
+import (
+ "syscall"
+ "unsafe"
+)
+
+var (
+ kernel32Dll *syscall.LazyDLL = syscall.NewLazyDLL("Kernel32.dll")
+ setConsoleMode *syscall.LazyProc = kernel32Dll.NewProc("SetConsoleMode")
+)
+
+func EnableVirtualTerminalProcessing(stream syscall.Handle, enable bool) error {
+ const ENABLE_VIRTUAL_TERMINAL_PROCESSING uint32 = 0x4
+
+ var mode uint32
+ err := syscall.GetConsoleMode(syscall.Stdout, &mode)
+ if err != nil {
+ return err
+ }
+
+ if enable {
+ mode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING
+ } else {
+ mode &^= ENABLE_VIRTUAL_TERMINAL_PROCESSING
+ }
+
+ ret, _, err := setConsoleMode.Call(uintptr(unsafe.Pointer(stream)), uintptr(mode))
+ if ret == 0 {
+ return err
+ }
+
+ return nil
+}
diff --git a/vendor/github.com/kr/pty/run.go b/vendor/github.com/kr/pty/run.go
index baecca8af9..2d7f96119d 100644
--- a/vendor/github.com/kr/pty/run.go
+++ b/vendor/github.com/kr/pty/run.go
@@ -12,11 +12,27 @@ import (
// and c.Stderr, calls c.Start, and returns the File of the tty's
// corresponding pty.
func Start(c *exec.Cmd) (pty *os.File, err error) {
+ return StartWithSize(c, nil)
+}
+
+// StartWithSize assigns a pseudo-terminal tty os.File to c.Stdin, c.Stdout,
+// and c.Stderr, calls c.Start, and returns the File of the tty's
+// corresponding pty.
+//
+// This will resize the pty to the specified size before starting the command
+func StartWithSize(c *exec.Cmd, sz *Winsize) (pty *os.File, err error) {
pty, tty, err := Open()
if err != nil {
return nil, err
}
defer tty.Close()
+ if sz != nil {
+ err = Setsize(pty, sz)
+ if err != nil {
+ pty.Close()
+ return nil, err
+ }
+ }
c.Stdout = tty
c.Stdin = tty
c.Stderr = tty
diff --git a/vendor/github.com/mattn/go-isatty/.travis.yml b/vendor/github.com/mattn/go-isatty/.travis.yml
index b9f8b239c0..5597e026dd 100644
--- a/vendor/github.com/mattn/go-isatty/.travis.yml
+++ b/vendor/github.com/mattn/go-isatty/.travis.yml
@@ -2,6 +2,10 @@ language: go
go:
- tip
+os:
+ - linux
+ - osx
+
before_install:
- go get github.com/mattn/goveralls
- go get golang.org/x/tools/cmd/cover
diff --git a/vendor/github.com/mattn/go-isatty/isatty_others.go b/vendor/github.com/mattn/go-isatty/isatty_others.go
index ff4de3d9a5..9d8b4a5996 100644
--- a/vendor/github.com/mattn/go-isatty/isatty_others.go
+++ b/vendor/github.com/mattn/go-isatty/isatty_others.go
@@ -3,7 +3,7 @@
package isatty
-// IsCygwinTerminal() return true if the file descriptor is a cygwin or msys2
+// IsCygwinTerminal return true if the file descriptor is a cygwin or msys2
// terminal. This is also always false on this environment.
func IsCygwinTerminal(fd uintptr) bool {
return false
diff --git a/vendor/github.com/mattn/go-tty/LICENSE b/vendor/github.com/mattn/go-tty/LICENSE
new file mode 100644
index 0000000000..e364750d2b
--- /dev/null
+++ b/vendor/github.com/mattn/go-tty/LICENSE
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2018 Yasuhiro Matsumoto
+
+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/vendor/github.com/miekg/dns/.travis.yml b/vendor/github.com/miekg/dns/.travis.yml
index 542dd68c0f..18259374e5 100644
--- a/vendor/github.com/miekg/dns/.travis.yml
+++ b/vendor/github.com/miekg/dns/.travis.yml
@@ -1,12 +1,10 @@
language: go
sudo: false
-go:
- - 1.9.x
- - tip
-env:
- - TESTS="-race -v -bench=. -coverprofile=coverage.txt -covermode=atomic"
- - TESTS="-race -v ./..."
+go:
+ - 1.10.x
+ - 1.11.x
+ - tip
before_install:
# don't use the miekg/dns when testing forks
@@ -14,7 +12,7 @@ before_install:
- ln -s $TRAVIS_BUILD_DIR $GOPATH/src/github.com/miekg/ || true
script:
- - go test $TESTS
+ - go test -race -v -bench=. -coverprofile=coverage.txt -covermode=atomic ./...
after_success:
- bash <(curl -s https://codecov.io/bash)
diff --git a/vendor/github.com/miekg/dns/Gopkg.lock b/vendor/github.com/miekg/dns/Gopkg.lock
index 0c73a64444..686632207a 100644
--- a/vendor/github.com/miekg/dns/Gopkg.lock
+++ b/vendor/github.com/miekg/dns/Gopkg.lock
@@ -3,19 +3,55 @@
[[projects]]
branch = "master"
+ digest = "1:6914c49eed986dfb8dffb33516fa129c49929d4d873f41e073c83c11c372b870"
name = "golang.org/x/crypto"
- packages = ["ed25519","ed25519/internal/edwards25519"]
- revision = "b080dc9a8c480b08e698fb1219160d598526310f"
+ packages = [
+ "ed25519",
+ "ed25519/internal/edwards25519",
+ ]
+ pruneopts = ""
+ revision = "e3636079e1a4c1f337f212cc5cd2aca108f6c900"
[[projects]]
branch = "master"
+ digest = "1:08e41d63f8dac84d83797368b56cf0b339e42d0224e5e56668963c28aec95685"
name = "golang.org/x/net"
- packages = ["bpf","internal/iana","internal/socket","ipv4","ipv6"]
- revision = "894f8ed5849b15b810ae41e9590a0d05395bba27"
+ packages = [
+ "bpf",
+ "context",
+ "internal/iana",
+ "internal/socket",
+ "ipv4",
+ "ipv6",
+ ]
+ pruneopts = ""
+ revision = "4dfa2610cdf3b287375bbba5b8f2a14d3b01d8de"
+
+[[projects]]
+ branch = "master"
+ digest = "1:b2ea75de0ccb2db2ac79356407f8a4cd8f798fe15d41b381c00abf3ae8e55ed1"
+ name = "golang.org/x/sync"
+ packages = ["errgroup"]
+ pruneopts = ""
+ revision = "1d60e4601c6fd243af51cc01ddf169918a5407ca"
+
+[[projects]]
+ branch = "master"
+ digest = "1:149a432fabebb8221a80f77731b1cd63597197ded4f14af606ebe3a0959004ec"
+ name = "golang.org/x/sys"
+ packages = ["unix"]
+ pruneopts = ""
+ revision = "e4b3c5e9061176387e7cea65e4dc5853801f3fb7"
[solve-meta]
analyzer-name = "dep"
analyzer-version = 1
- inputs-digest = "c4abc38abaeeeeb9be92455c9c02cae32841122b8982aaa067ef25bb8e86ff9d"
+ input-imports = [
+ "golang.org/x/crypto/ed25519",
+ "golang.org/x/net/ipv4",
+ "golang.org/x/net/ipv6",
+ "golang.org/x/sync/errgroup",
+ "golang.org/x/sys/unix",
+ ]
solver-name = "gps-cdcl"
solver-version = 1
diff --git a/vendor/github.com/miekg/dns/Gopkg.toml b/vendor/github.com/miekg/dns/Gopkg.toml
index 2f655b2c7b..85e6ff31b2 100644
--- a/vendor/github.com/miekg/dns/Gopkg.toml
+++ b/vendor/github.com/miekg/dns/Gopkg.toml
@@ -24,3 +24,15 @@
[[constraint]]
branch = "master"
name = "golang.org/x/crypto"
+
+[[constraint]]
+ branch = "master"
+ name = "golang.org/x/net"
+
+[[constraint]]
+ branch = "master"
+ name = "golang.org/x/sys"
+
+[[constraint]]
+ branch = "master"
+ name = "golang.org/x/sync"
diff --git a/vendor/github.com/miekg/dns/README.md b/vendor/github.com/miekg/dns/README.md
index 1ad23c7516..77874642be 100644
--- a/vendor/github.com/miekg/dns/README.md
+++ b/vendor/github.com/miekg/dns/README.md
@@ -64,6 +64,9 @@ A not-so-up-to-date-list-that-may-be-actually-current:
* https://github.com/oif/apex
* https://github.com/jedisct1/dnscrypt-proxy
* https://github.com/jedisct1/rpdns
+* https://github.com/xor-gate/sshfp
+* https://github.com/rs/dnstrace
+* https://blitiri.com.ar/p/dnss ([github mirror](https://github.com/albertito/dnss))
Send pull request if you want to be listed here.
diff --git a/vendor/github.com/miekg/dns/client.go b/vendor/github.com/miekg/dns/client.go
index dd6b512afb..63ced2bd06 100644
--- a/vendor/github.com/miekg/dns/client.go
+++ b/vendor/github.com/miekg/dns/client.go
@@ -89,32 +89,22 @@ func (c *Client) Dial(address string) (conn *Conn, err error) {
// create a new dialer with the appropriate timeout
var d net.Dialer
if c.Dialer == nil {
- d = net.Dialer{Timeout:c.getTimeoutForRequest(c.dialTimeout())}
+ d = net.Dialer{Timeout: c.getTimeoutForRequest(c.dialTimeout())}
} else {
- d = net.Dialer(*c.Dialer)
+ d = *c.Dialer
}
- network := "udp"
- useTLS := false
-
- switch c.Net {
- case "tcp-tls":
- network = "tcp"
- useTLS = true
- case "tcp4-tls":
- network = "tcp4"
- useTLS = true
- case "tcp6-tls":
- network = "tcp6"
- useTLS = true
- default:
- if c.Net != "" {
- network = c.Net
- }
+ network := c.Net
+ if network == "" {
+ network = "udp"
}
+ useTLS := strings.HasPrefix(network, "tcp") && strings.HasSuffix(network, "-tls")
+
conn = new(Conn)
if useTLS {
+ network = strings.TrimSuffix(network, "-tls")
+
conn.Conn, err = tls.DialWithDialer(&d, network, address, c.TLSConfig)
} else {
conn.Conn, err = d.Dial(network, address)
@@ -122,6 +112,7 @@ func (c *Client) Dial(address string) (conn *Conn, err error) {
if err != nil {
return nil, err
}
+
return conn, nil
}
@@ -576,7 +567,7 @@ func (c *Client) ExchangeContext(ctx context.Context, m *Msg, a string) (r *Msg,
if deadline, ok := ctx.Deadline(); !ok {
timeout = 0
} else {
- timeout = deadline.Sub(time.Now())
+ timeout = time.Until(deadline)
}
// not passing the context to the underlying calls, as the API does not support
// context. For timeouts you should set up Client.Dialer and call Client.Exchange.
diff --git a/vendor/github.com/miekg/dns/dnssec.go b/vendor/github.com/miekg/dns/dnssec.go
index 7e6bac4287..26b512e7da 100644
--- a/vendor/github.com/miekg/dns/dnssec.go
+++ b/vendor/github.com/miekg/dns/dnssec.go
@@ -173,7 +173,7 @@ func (k *DNSKEY) KeyTag() uint16 {
keytag += int(v) << 8
}
}
- keytag += (keytag >> 16) & 0xFFFF
+ keytag += keytag >> 16 & 0xFFFF
keytag &= 0xFFFF
}
return uint16(keytag)
@@ -512,8 +512,8 @@ func (rr *RRSIG) ValidityPeriod(t time.Time) bool {
}
modi := (int64(rr.Inception) - utc) / year68
mode := (int64(rr.Expiration) - utc) / year68
- ti := int64(rr.Inception) + (modi * year68)
- te := int64(rr.Expiration) + (mode * year68)
+ ti := int64(rr.Inception) + modi*year68
+ te := int64(rr.Expiration) + mode*year68
return ti <= utc && utc <= te
}
@@ -533,6 +533,11 @@ func (k *DNSKEY) publicKeyRSA() *rsa.PublicKey {
return nil
}
+ if len(keybuf) < 1+1+64 {
+ // Exponent must be at least 1 byte and modulus at least 64
+ return nil
+ }
+
// RFC 2537/3110, section 2. RSA Public KEY Resource Records
// Length is in the 0th byte, unless its zero, then it
// it in bytes 1 and 2 and its a 16 bit number
@@ -542,13 +547,22 @@ func (k *DNSKEY) publicKeyRSA() *rsa.PublicKey {
explen = uint16(keybuf[1])<<8 | uint16(keybuf[2])
keyoff = 3
}
- if explen > 4 {
- // Larger exponent than supported by the crypto package.
+
+ if explen > 4 || explen == 0 || keybuf[keyoff] == 0 {
+ // Exponent larger than supported by the crypto package,
+ // empty, or contains prohibited leading zero.
return nil
}
+
+ modoff := keyoff + int(explen)
+ modlen := len(keybuf) - modoff
+ if modlen < 64 || modlen > 512 || keybuf[modoff] == 0 {
+ // Modulus is too small, large, or contains prohibited leading zero.
+ return nil
+ }
+
pubkey := new(rsa.PublicKey)
- pubkey.N = big.NewInt(0)
expo := uint64(0)
for i := 0; i < int(explen); i++ {
expo <<= 8
@@ -560,7 +574,9 @@ func (k *DNSKEY) publicKeyRSA() *rsa.PublicKey {
}
pubkey.E = int(expo)
- pubkey.N.SetBytes(keybuf[keyoff+int(explen):])
+ pubkey.N = big.NewInt(0)
+ pubkey.N.SetBytes(keybuf[modoff:])
+
return pubkey
}
diff --git a/vendor/github.com/miekg/dns/dnssec_keyscan.go b/vendor/github.com/miekg/dns/dnssec_keyscan.go
index e2d9d8f924..719198659a 100644
--- a/vendor/github.com/miekg/dns/dnssec_keyscan.go
+++ b/vendor/github.com/miekg/dns/dnssec_keyscan.go
@@ -1,7 +1,6 @@
package dns
import (
- "bytes"
"crypto"
"crypto/dsa"
"crypto/ecdsa"
@@ -181,22 +180,10 @@ func readPrivateKeyED25519(m map[string]string) (ed25519.PrivateKey, error) {
if err != nil {
return nil, err
}
- if len(p1) != 32 {
+ if len(p1) != ed25519.SeedSize {
return nil, ErrPrivKey
}
- // RFC 8080 and Golang's x/crypto/ed25519 differ as to how the
- // private keys are represented. RFC 8080 specifies that private
- // keys be stored solely as the seed value (p1 above) while the
- // ed25519 package represents them as the seed value concatenated
- // to the public key, which is derived from the seed value.
- //
- // ed25519.GenerateKey reads exactly 32 bytes from the passed in
- // io.Reader and uses them as the seed. It also derives the
- // public key and produces a compatible private key.
- _, p, err = ed25519.GenerateKey(bytes.NewReader(p1))
- if err != nil {
- return nil, err
- }
+ p = ed25519.NewKeyFromSeed(p1)
case "created", "publish", "activate":
/* not used in Go (yet) */
}
diff --git a/vendor/github.com/miekg/dns/dnssec_privkey.go b/vendor/github.com/miekg/dns/dnssec_privkey.go
index 46f3215c8f..0c65be17bc 100644
--- a/vendor/github.com/miekg/dns/dnssec_privkey.go
+++ b/vendor/github.com/miekg/dns/dnssec_privkey.go
@@ -82,7 +82,7 @@ func (r *DNSKEY) PrivateKeyString(p crypto.PrivateKey) string {
"Public_value(y): " + pub + "\n"
case ed25519.PrivateKey:
- private := toBase64(p[:32])
+ private := toBase64(p.Seed())
return format +
"Algorithm: " + algorithm + "\n" +
"PrivateKey: " + private + "\n"
diff --git a/vendor/github.com/miekg/dns/duplicate.go b/vendor/github.com/miekg/dns/duplicate.go
new file mode 100644
index 0000000000..6372e8a194
--- /dev/null
+++ b/vendor/github.com/miekg/dns/duplicate.go
@@ -0,0 +1,25 @@
+package dns
+
+//go:generate go run duplicate_generate.go
+
+// IsDuplicate checks of r1 and r2 are duplicates of each other, excluding the TTL.
+// So this means the header data is equal *and* the RDATA is the same. Return true
+// is so, otherwise false.
+// It's is a protocol violation to have identical RRs in a message.
+func IsDuplicate(r1, r2 RR) bool {
+ if r1.Header().Class != r2.Header().Class {
+ return false
+ }
+ if r1.Header().Rrtype != r2.Header().Rrtype {
+ return false
+ }
+ if !isDulicateName(r1.Header().Name, r2.Header().Name) {
+ return false
+ }
+ // ignore TTL
+
+ return isDuplicateRdata(r1, r2)
+}
+
+// isDulicateName checks if the domain names s1 and s2 are equal.
+func isDulicateName(s1, s2 string) bool { return equal(s1, s2) }
diff --git a/vendor/github.com/miekg/dns/duplicate_generate.go b/vendor/github.com/miekg/dns/duplicate_generate.go
new file mode 100644
index 0000000000..83ac1cf770
--- /dev/null
+++ b/vendor/github.com/miekg/dns/duplicate_generate.go
@@ -0,0 +1,158 @@
+//+build ignore
+
+// types_generate.go is meant to run with go generate. It will use
+// go/{importer,types} to track down all the RR struct types. Then for each type
+// it will generate conversion tables (TypeToRR and TypeToString) and banal
+// methods (len, Header, copy) based on the struct tags. The generated source is
+// written to ztypes.go, and is meant to be checked into git.
+package main
+
+import (
+ "bytes"
+ "fmt"
+ "go/format"
+ "go/importer"
+ "go/types"
+ "log"
+ "os"
+)
+
+var packageHdr = `
+// Code generated by "go run duplicate_generate.go"; DO NOT EDIT.
+
+package dns
+
+`
+
+func getTypeStruct(t types.Type, scope *types.Scope) (*types.Struct, bool) {
+ st, ok := t.Underlying().(*types.Struct)
+ if !ok {
+ return nil, false
+ }
+ if st.Field(0).Type() == scope.Lookup("RR_Header").Type() {
+ return st, false
+ }
+ if st.Field(0).Anonymous() {
+ st, _ := getTypeStruct(st.Field(0).Type(), scope)
+ return st, true
+ }
+ return nil, false
+}
+
+func main() {
+ // Import and type-check the package
+ pkg, err := importer.Default().Import("github.com/miekg/dns")
+ fatalIfErr(err)
+ scope := pkg.Scope()
+
+ // Collect actual types (*X)
+ var namedTypes []string
+ for _, name := range scope.Names() {
+ o := scope.Lookup(name)
+ if o == nil || !o.Exported() {
+ continue
+ }
+
+ if st, _ := getTypeStruct(o.Type(), scope); st == nil {
+ continue
+ }
+
+ if name == "PrivateRR" || name == "RFC3597" {
+ continue
+ }
+ if name == "OPT" || name == "ANY" || name == "IXFR" || name == "AXFR" {
+ continue
+ }
+
+ namedTypes = append(namedTypes, o.Name())
+ }
+
+ b := &bytes.Buffer{}
+ b.WriteString(packageHdr)
+
+ // Generate the giant switch that calls the correct function for each type.
+ fmt.Fprint(b, "// isDuplicateRdata calls the rdata specific functions\n")
+ fmt.Fprint(b, "func isDuplicateRdata(r1, r2 RR) bool {\n")
+ fmt.Fprint(b, "switch r1.Header().Rrtype {\n")
+
+ for _, name := range namedTypes {
+
+ o := scope.Lookup(name)
+ _, isEmbedded := getTypeStruct(o.Type(), scope)
+ if isEmbedded {
+ continue
+ }
+ fmt.Fprintf(b, "case Type%s:\nreturn isDuplicate%s(r1.(*%s), r2.(*%s))\n", name, name, name, name)
+ }
+ fmt.Fprintf(b, "}\nreturn false\n}\n")
+
+ // Generate the duplicate check for each type.
+ fmt.Fprint(b, "// isDuplicate() functions\n\n")
+ for _, name := range namedTypes {
+
+ o := scope.Lookup(name)
+ st, isEmbedded := getTypeStruct(o.Type(), scope)
+ if isEmbedded {
+ continue
+ }
+ fmt.Fprintf(b, "func isDuplicate%s(r1, r2 *%s) bool {\n", name, name)
+ for i := 1; i < st.NumFields(); i++ {
+ field := st.Field(i).Name()
+ o2 := func(s string) { fmt.Fprintf(b, s+"\n", field, field) }
+ o3 := func(s string) { fmt.Fprintf(b, s+"\n", field, field, field) }
+
+ // For some reason, a and aaaa don't pop up as *types.Slice here (mostly like because the are
+ // *indirectly* defined as a slice in the net package).
+ if _, ok := st.Field(i).Type().(*types.Slice); ok || st.Tag(i) == `dns:"a"` || st.Tag(i) == `dns:"aaaa"` {
+ o2("if len(r1.%s) != len(r2.%s) {\nreturn false\n}")
+
+ if st.Tag(i) == `dns:"cdomain-name"` || st.Tag(i) == `dns:"domain-name"` {
+ o3(`for i := 0; i < len(r1.%s); i++ {
+ if !isDulicateName(r1.%s[i], r2.%s[i]) {
+ return false
+ }
+ }`)
+
+ continue
+ }
+
+ o3(`for i := 0; i < len(r1.%s); i++ {
+ if r1.%s[i] != r2.%s[i] {
+ return false
+ }
+ }`)
+
+ continue
+ }
+
+ switch st.Tag(i) {
+ case `dns:"-"`:
+ // ignored
+ case `dns:"cdomain-name"`, `dns:"domain-name"`:
+ o2("if !isDulicateName(r1.%s, r2.%s) {\nreturn false\n}")
+ default:
+ o2("if r1.%s != r2.%s {\nreturn false\n}")
+ }
+ }
+ fmt.Fprintf(b, "return true\n}\n\n")
+ }
+
+ // gofmt
+ res, err := format.Source(b.Bytes())
+ if err != nil {
+ b.WriteTo(os.Stderr)
+ log.Fatal(err)
+ }
+
+ // write result
+ f, err := os.Create("zduplicate.go")
+ fatalIfErr(err)
+ defer f.Close()
+ f.Write(res)
+}
+
+func fatalIfErr(err error) {
+ if err != nil {
+ log.Fatal(err)
+ }
+}
diff --git a/vendor/github.com/miekg/dns/edns.go b/vendor/github.com/miekg/dns/edns.go
index 55059eb14a..18d054139b 100644
--- a/vendor/github.com/miekg/dns/edns.go
+++ b/vendor/github.com/miekg/dns/edns.go
@@ -92,17 +92,17 @@ func (rr *OPT) len() int {
// Version returns the EDNS version used. Only zero is defined.
func (rr *OPT) Version() uint8 {
- return uint8((rr.Hdr.Ttl & 0x00FF0000) >> 16)
+ return uint8(rr.Hdr.Ttl & 0x00FF0000 >> 16)
}
// SetVersion sets the version of EDNS. This is usually zero.
func (rr *OPT) SetVersion(v uint8) {
- rr.Hdr.Ttl = rr.Hdr.Ttl&0xFF00FFFF | (uint32(v) << 16)
+ rr.Hdr.Ttl = rr.Hdr.Ttl&0xFF00FFFF | uint32(v)<<16
}
// ExtendedRcode returns the EDNS extended RCODE field (the upper 8 bits of the TTL).
func (rr *OPT) ExtendedRcode() int {
- return int((rr.Hdr.Ttl&0xFF000000)>>24) + 15
+ return int(rr.Hdr.Ttl&0xFF000000>>24) + 15
}
// SetExtendedRcode sets the EDNS extended RCODE field.
@@ -110,7 +110,7 @@ func (rr *OPT) SetExtendedRcode(v uint8) {
if v < RcodeBadVers { // Smaller than 16.. Use the 4 bits you have!
return
}
- rr.Hdr.Ttl = rr.Hdr.Ttl&0x00FFFFFF | (uint32(v-15) << 24)
+ rr.Hdr.Ttl = rr.Hdr.Ttl&0x00FFFFFF | uint32(v-15)<<24
}
// UDPSize returns the UDP buffer size.
diff --git a/vendor/github.com/miekg/dns/generate.go b/vendor/github.com/miekg/dns/generate.go
index e4481a4b0d..91d928c834 100644
--- a/vendor/github.com/miekg/dns/generate.go
+++ b/vendor/github.com/miekg/dns/generate.go
@@ -107,6 +107,8 @@ BuildRR:
mod, offset, err = modToPrintf(s[j+2 : j+2+sep])
if err != nil {
return err.Error()
+ } else if start + offset < 0 || end + offset > 1<<31-1 {
+ return "bad offset in $GENERATE"
}
j += 2 + sep // Jump to it
}
@@ -133,16 +135,26 @@ BuildRR:
// Convert a $GENERATE modifier 0,0,d to something Printf can deal with.
func modToPrintf(s string) (string, int, error) {
- xs := strings.SplitN(s, ",", 3)
- if len(xs) != 3 {
+ xs := strings.Split(s, ",")
+
+ // Modifier is { offset [ ,width [ ,base ] ] } - provide default
+ // values for optional width and type, if necessary.
+ switch len(xs) {
+ case 1:
+ xs = append(xs, "0", "d")
+ case 2:
+ xs = append(xs, "d")
+ case 3:
+ default:
return "", 0, errors.New("bad modifier in $GENERATE")
}
+
// xs[0] is offset, xs[1] is width, xs[2] is base
if xs[2] != "o" && xs[2] != "d" && xs[2] != "x" && xs[2] != "X" {
return "", 0, errors.New("bad base in $GENERATE")
}
offset, err := strconv.Atoi(xs[0])
- if err != nil || offset > 255 {
+ if err != nil {
return "", 0, errors.New("bad offset in $GENERATE")
}
width, err := strconv.Atoi(xs[1])
diff --git a/vendor/github.com/miekg/dns/labels.go b/vendor/github.com/miekg/dns/labels.go
index 760b89e711..577fc59d2c 100644
--- a/vendor/github.com/miekg/dns/labels.go
+++ b/vendor/github.com/miekg/dns/labels.go
@@ -178,10 +178,10 @@ func equal(a, b string) bool {
ai := a[i]
bi := b[i]
if ai >= 'A' && ai <= 'Z' {
- ai |= ('a' - 'A')
+ ai |= 'a' - 'A'
}
if bi >= 'A' && bi <= 'Z' {
- bi |= ('a' - 'A')
+ bi |= 'a' - 'A'
}
if ai != bi {
return false
diff --git a/vendor/github.com/miekg/dns/listen_go111.go b/vendor/github.com/miekg/dns/listen_go111.go
new file mode 100644
index 0000000000..fad195cfeb
--- /dev/null
+++ b/vendor/github.com/miekg/dns/listen_go111.go
@@ -0,0 +1,44 @@
+// +build go1.11
+// +build aix darwin dragonfly freebsd linux netbsd openbsd
+
+package dns
+
+import (
+ "context"
+ "net"
+ "syscall"
+
+ "golang.org/x/sys/unix"
+)
+
+const supportsReusePort = true
+
+func reuseportControl(network, address string, c syscall.RawConn) error {
+ var opErr error
+ err := c.Control(func(fd uintptr) {
+ opErr = unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_REUSEPORT, 1)
+ })
+ if err != nil {
+ return err
+ }
+
+ return opErr
+}
+
+func listenTCP(network, addr string, reuseport bool) (net.Listener, error) {
+ var lc net.ListenConfig
+ if reuseport {
+ lc.Control = reuseportControl
+ }
+
+ return lc.Listen(context.Background(), network, addr)
+}
+
+func listenUDP(network, addr string, reuseport bool) (net.PacketConn, error) {
+ var lc net.ListenConfig
+ if reuseport {
+ lc.Control = reuseportControl
+ }
+
+ return lc.ListenPacket(context.Background(), network, addr)
+}
diff --git a/vendor/github.com/miekg/dns/listen_go_not111.go b/vendor/github.com/miekg/dns/listen_go_not111.go
new file mode 100644
index 0000000000..b9201417ab
--- /dev/null
+++ b/vendor/github.com/miekg/dns/listen_go_not111.go
@@ -0,0 +1,23 @@
+// +build !go1.11 !aix,!darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd
+
+package dns
+
+import "net"
+
+const supportsReusePort = false
+
+func listenTCP(network, addr string, reuseport bool) (net.Listener, error) {
+ if reuseport {
+ // TODO(tmthrgd): return an error?
+ }
+
+ return net.Listen(network, addr)
+}
+
+func listenUDP(network, addr string, reuseport bool) (net.PacketConn, error) {
+ if reuseport {
+ // TODO(tmthrgd): return an error?
+ }
+
+ return net.ListenPacket(network, addr)
+}
diff --git a/vendor/github.com/miekg/dns/msg.go b/vendor/github.com/miekg/dns/msg.go
index dcd3b6a5e1..47ac6cf281 100644
--- a/vendor/github.com/miekg/dns/msg.go
+++ b/vendor/github.com/miekg/dns/msg.go
@@ -302,6 +302,12 @@ func packDomainName(s string, msg []byte, off int, compression map[string]int, c
}
// If we did compression and we find something add the pointer here
if pointer != -1 {
+ // Clear the msg buffer after the pointer location, otherwise
+ // packDataNsec writes the wrong data to msg.
+ tainted := msg[nameoffset:off]
+ for i := range tainted {
+ tainted[i] = 0
+ }
// We have two bytes (14 bits) to put the pointer in
// if msg == nil, we will never do compression
binary.BigEndian.PutUint16(msg[nameoffset:], uint16(pointer^0xC000))
@@ -367,12 +373,10 @@ Loop:
var buf [3]byte
bufs := strconv.AppendInt(buf[:0], int64(b), 10)
s = append(s, '\\')
- for i := 0; i < 3-len(bufs); i++ {
+ for i := len(bufs); i < 3; i++ {
s = append(s, '0')
}
- for _, r := range bufs {
- s = append(s, r)
- }
+ s = append(s, bufs...)
// presentation-format \DDD escapes add 3 extra bytes
maxLen += 3
} else {
@@ -512,7 +516,7 @@ func unpackTxt(msg []byte, off0 int) (ss []string, off int, err error) {
off = off0
var s string
for off < len(msg) && err == nil {
- s, off, err = unpackTxtString(msg, off)
+ s, off, err = unpackString(msg, off)
if err == nil {
ss = append(ss, s)
}
@@ -520,39 +524,6 @@ func unpackTxt(msg []byte, off0 int) (ss []string, off int, err error) {
return
}
-func unpackTxtString(msg []byte, offset int) (string, int, error) {
- if offset+1 > len(msg) {
- return "", offset, &Error{err: "overflow unpacking txt"}
- }
- l := int(msg[offset])
- if offset+l+1 > len(msg) {
- return "", offset, &Error{err: "overflow unpacking txt"}
- }
- s := make([]byte, 0, l)
- for _, b := range msg[offset+1 : offset+1+l] {
- switch b {
- case '"', '\\':
- s = append(s, '\\', b)
- default:
- if b < 32 || b > 127 { // unprintable
- var buf [3]byte
- bufs := strconv.AppendInt(buf[:0], int64(b), 10)
- s = append(s, '\\')
- for i := 0; i < 3-len(bufs); i++ {
- s = append(s, '0')
- }
- for _, r := range bufs {
- s = append(s, r)
- }
- } else {
- s = append(s, b)
- }
- }
- }
- offset += 1 + l
- return string(s), offset, nil
-}
-
// Helpers for dealing with escaped bytes
func isDigit(b byte) bool { return b >= '0' && b <= '9' }
@@ -560,6 +531,10 @@ func dddToByte(s []byte) byte {
return byte((s[0]-'0')*100 + (s[1]-'0')*10 + (s[2] - '0'))
}
+func dddStringToByte(s string) byte {
+ return byte((s[0]-'0')*100 + (s[1]-'0')*10 + (s[2] - '0'))
+}
+
// Helper function for packing and unpacking
func intToBytes(i *big.Int, length int) []byte {
buf := i.Bytes()
@@ -808,15 +783,15 @@ func (dns *Msg) Unpack(msg []byte) (err error) {
}
dns.Id = dh.Id
- dns.Response = (dh.Bits & _QR) != 0
+ dns.Response = dh.Bits&_QR != 0
dns.Opcode = int(dh.Bits>>11) & 0xF
- dns.Authoritative = (dh.Bits & _AA) != 0
- dns.Truncated = (dh.Bits & _TC) != 0
- dns.RecursionDesired = (dh.Bits & _RD) != 0
- dns.RecursionAvailable = (dh.Bits & _RA) != 0
- dns.Zero = (dh.Bits & _Z) != 0
- dns.AuthenticatedData = (dh.Bits & _AD) != 0
- dns.CheckingDisabled = (dh.Bits & _CD) != 0
+ dns.Authoritative = dh.Bits&_AA != 0
+ dns.Truncated = dh.Bits&_TC != 0
+ dns.RecursionDesired = dh.Bits&_RD != 0
+ dns.RecursionAvailable = dh.Bits&_RA != 0
+ dns.Zero = dh.Bits&_Z != 0
+ dns.AuthenticatedData = dh.Bits&_AD != 0
+ dns.CheckingDisabled = dh.Bits&_CD != 0
dns.Rcode = int(dh.Bits & 0xF)
// If we are at the end of the message we should return *just* the
diff --git a/vendor/github.com/miekg/dns/msg_helpers.go b/vendor/github.com/miekg/dns/msg_helpers.go
index 4a6e878de9..81fc2b1be3 100644
--- a/vendor/github.com/miekg/dns/msg_helpers.go
+++ b/vendor/github.com/miekg/dns/msg_helpers.go
@@ -6,7 +6,7 @@ import (
"encoding/binary"
"encoding/hex"
"net"
- "strconv"
+ "strings"
)
// helper functions called from the generated zmsg.go
@@ -223,8 +223,8 @@ func unpackUint48(msg []byte, off int) (i uint64, off1 int, err error) {
return 0, len(msg), &Error{err: "overflow unpacking uint64 as uint48"}
}
// Used in TSIG where the last 48 bits are occupied, so for now, assume a uint48 (6 bytes)
- i = (uint64(uint64(msg[off])<<40 | uint64(msg[off+1])<<32 | uint64(msg[off+2])<<24 | uint64(msg[off+3])<<16 |
- uint64(msg[off+4])<<8 | uint64(msg[off+5])))
+ i = uint64(uint64(msg[off])<<40 | uint64(msg[off+1])<<32 | uint64(msg[off+2])<<24 | uint64(msg[off+3])<<16 |
+ uint64(msg[off+4])<<8 | uint64(msg[off+5]))
off += 6
return i, off, nil
}
@@ -267,29 +267,21 @@ func unpackString(msg []byte, off int) (string, int, error) {
if off+l+1 > len(msg) {
return "", off, &Error{err: "overflow unpacking txt"}
}
- s := make([]byte, 0, l)
+ var s strings.Builder
+ s.Grow(l)
for _, b := range msg[off+1 : off+1+l] {
- switch b {
- case '"', '\\':
- s = append(s, '\\', b)
+ switch {
+ case b == '"' || b == '\\':
+ s.WriteByte('\\')
+ s.WriteByte(b)
+ case b < ' ' || b > '~': // unprintable
+ writeEscapedByte(&s, b)
default:
- if b < 32 || b > 127 { // unprintable
- var buf [3]byte
- bufs := strconv.AppendInt(buf[:0], int64(b), 10)
- s = append(s, '\\')
- for i := 0; i < 3-len(bufs); i++ {
- s = append(s, '0')
- }
- for _, r := range bufs {
- s = append(s, r)
- }
- } else {
- s = append(s, b)
- }
+ s.WriteByte(b)
}
}
off += 1 + l
- return string(s), off, nil
+ return s.String(), off, nil
}
func packString(s string, msg []byte, off int) (int, error) {
@@ -363,7 +355,7 @@ func packStringHex(s string, msg []byte, off int) (int, error) {
if err != nil {
return len(msg), err
}
- if off+(len(h)) > len(msg) {
+ if off+len(h) > len(msg) {
return len(msg), &Error{err: "overflow packing hex"}
}
copy(msg[off:off+len(h)], h)
@@ -603,7 +595,7 @@ func packDataNsec(bitmap []uint16, msg []byte, off int) (int, error) {
// Setting the octets length
msg[off+1] = byte(length)
// Setting the bit value for the type in the right octet
- msg[off+1+int(length)] |= byte(1 << (7 - (t % 8)))
+ msg[off+1+int(length)] |= byte(1 << (7 - t%8))
lastwindow, lastlength = window, length
}
off += int(lastlength) + 2
diff --git a/vendor/github.com/miekg/dns/privaterr.go b/vendor/github.com/miekg/dns/privaterr.go
index 41989e7aee..d931da7efb 100644
--- a/vendor/github.com/miekg/dns/privaterr.go
+++ b/vendor/github.com/miekg/dns/privaterr.go
@@ -134,7 +134,7 @@ func PrivateHandle(rtypestr string, rtype uint16, generator func() PrivateRdata)
typeToparserFunc[rtype] = parserFunc{setPrivateRR, true}
}
-// PrivateHandleRemove removes defenitions required to support private RR type.
+// PrivateHandleRemove removes definitions required to support private RR type.
func PrivateHandleRemove(rtype uint16) {
rtypestr, ok := TypeToString[rtype]
if ok {
@@ -144,5 +144,4 @@ func PrivateHandleRemove(rtype uint16) {
delete(StringToType, rtypestr)
delete(typeToUnpack, rtype)
}
- return
}
diff --git a/vendor/github.com/miekg/dns/sanitize.go b/vendor/github.com/miekg/dns/sanitize.go
index c415bdd6c3..cac15787ad 100644
--- a/vendor/github.com/miekg/dns/sanitize.go
+++ b/vendor/github.com/miekg/dns/sanitize.go
@@ -5,6 +5,7 @@ package dns
// rrs.
// m is used to store the RRs temporary. If it is nil a new map will be allocated.
func Dedup(rrs []RR, m map[string]RR) []RR {
+
if m == nil {
m = make(map[string]RR)
}
diff --git a/vendor/github.com/miekg/dns/scan.go b/vendor/github.com/miekg/dns/scan.go
index f9cd47401d..a752dbd018 100644
--- a/vendor/github.com/miekg/dns/scan.go
+++ b/vendor/github.com/miekg/dns/scan.go
@@ -10,7 +10,6 @@ import (
)
const maxTok = 2048 // Largest token we can return.
-const maxUint16 = 1<<16 - 1
// Tokinize a RFC 1035 zone file. The tokenizer will normalize it:
// * Add ownernames if they are left blank;
@@ -80,9 +79,9 @@ type lex struct {
length int // length of the token
err bool // when true, token text has lexer error
value uint8 // value: zString, _BLANK, etc.
+ torc uint16 // type or class as parsed in the lexer, we only need to look this up in the grammar
line int // line in the file
column int // column in the file
- torc uint16 // type or class as parsed in the lexer, we only need to look this up in the grammar
comment string // any comment text seen
}
@@ -209,10 +208,9 @@ func parseZone(r io.Reader, origin, f string, defttl *ttlState, t chan *Token, i
var prevName string
for l := range c {
// Lexer spotted an error already
- if l.err == true {
+ if l.err {
t <- &Token{Error: &ParseError{f, l.token, l}}
return
-
}
switch st {
case zExpectOwnerDir:
@@ -639,7 +637,6 @@ func zlexer(s *scan, c chan lex) {
if quote {
str[stri] = x
stri++
- break
}
// discard if outside of quotes
case '\n':
diff --git a/vendor/github.com/miekg/dns/scan_rr.go b/vendor/github.com/miekg/dns/scan_rr.go
index fb6f95d1da..67f884b0d4 100644
--- a/vendor/github.com/miekg/dns/scan_rr.go
+++ b/vendor/github.com/miekg/dns/scan_rr.go
@@ -893,19 +893,19 @@ Altitude:
if !ok {
return nil, &ParseError{f, "bad LOC Size", l}, ""
}
- rr.Size = (e & 0x0f) | (m << 4 & 0xf0)
+ rr.Size = e&0x0f | m<<4&0xf0
case 1: // HorizPre
e, m, ok := stringToCm(l.token)
if !ok {
return nil, &ParseError{f, "bad LOC HorizPre", l}, ""
}
- rr.HorizPre = (e & 0x0f) | (m << 4 & 0xf0)
+ rr.HorizPre = e&0x0f | m<<4&0xf0
case 2: // VertPre
e, m, ok := stringToCm(l.token)
if !ok {
return nil, &ParseError{f, "bad LOC VertPre", l}, ""
}
- rr.VertPre = (e & 0x0f) | (m << 4 & 0xf0)
+ rr.VertPre = e&0x0f | m<<4&0xf0
}
count++
case zBlank:
@@ -1665,9 +1665,9 @@ func setTA(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) {
return nil, &ParseError{f, "bad TA DigestType", l}, ""
}
rr.DigestType = uint8(i)
- s, e, c1 := endingToString(c, "bad TA Digest", f)
- if e != nil {
- return nil, e.(*ParseError), c1
+ s, err, c1 := endingToString(c, "bad TA Digest", f)
+ if err != nil {
+ return nil, err, c1
}
rr.Digest = s
return rr, nil, c1
diff --git a/vendor/github.com/miekg/dns/scanner.go b/vendor/github.com/miekg/dns/scanner.go
index 424e5af9f5..5b124ec595 100644
--- a/vendor/github.com/miekg/dns/scanner.go
+++ b/vendor/github.com/miekg/dns/scanner.go
@@ -42,7 +42,7 @@ func (s *scan) tokenText() (byte, error) {
// delay the newline handling until the next token is delivered,
// fixes off-by-one errors when reporting a parse error.
- if s.eof == true {
+ if s.eof {
s.position.Line++
s.position.Column = 0
s.eof = false
diff --git a/vendor/github.com/miekg/dns/serve_mux.go b/vendor/github.com/miekg/dns/serve_mux.go
new file mode 100644
index 0000000000..ae304db530
--- /dev/null
+++ b/vendor/github.com/miekg/dns/serve_mux.go
@@ -0,0 +1,147 @@
+package dns
+
+import (
+ "strings"
+ "sync"
+)
+
+// ServeMux is an DNS request multiplexer. It matches the zone name of
+// each incoming request against a list of registered patterns add calls
+// the handler for the pattern that most closely matches the zone name.
+//
+// ServeMux is DNSSEC aware, meaning that queries for the DS record are
+// redirected to the parent zone (if that is also registered), otherwise
+// the child gets the query.
+//
+// ServeMux is also safe for concurrent access from multiple goroutines.
+//
+// The zero ServeMux is empty and ready for use.
+type ServeMux struct {
+ z map[string]Handler
+ m sync.RWMutex
+}
+
+// NewServeMux allocates and returns a new ServeMux.
+func NewServeMux() *ServeMux {
+ return new(ServeMux)
+}
+
+// DefaultServeMux is the default ServeMux used by Serve.
+var DefaultServeMux = NewServeMux()
+
+func (mux *ServeMux) match(q string, t uint16) Handler {
+ mux.m.RLock()
+ defer mux.m.RUnlock()
+ if mux.z == nil {
+ return nil
+ }
+
+ var handler Handler
+
+ // TODO(tmthrgd): Once https://go-review.googlesource.com/c/go/+/137575
+ // lands in a go release, replace the following with strings.ToLower.
+ var sb strings.Builder
+ for i := 0; i < len(q); i++ {
+ c := q[i]
+ if !(c >= 'A' && c <= 'Z') {
+ continue
+ }
+
+ sb.Grow(len(q))
+ sb.WriteString(q[:i])
+
+ for ; i < len(q); i++ {
+ c := q[i]
+ if c >= 'A' && c <= 'Z' {
+ c += 'a' - 'A'
+ }
+
+ sb.WriteByte(c)
+ }
+
+ q = sb.String()
+ break
+ }
+
+ for off, end := 0, false; !end; off, end = NextLabel(q, off) {
+ if h, ok := mux.z[q[off:]]; ok {
+ if t != TypeDS {
+ return h
+ }
+ // Continue for DS to see if we have a parent too, if so delegate to the parent
+ handler = h
+ }
+ }
+
+ // Wildcard match, if we have found nothing try the root zone as a last resort.
+ if h, ok := mux.z["."]; ok {
+ return h
+ }
+
+ return handler
+}
+
+// Handle adds a handler to the ServeMux for pattern.
+func (mux *ServeMux) Handle(pattern string, handler Handler) {
+ if pattern == "" {
+ panic("dns: invalid pattern " + pattern)
+ }
+ mux.m.Lock()
+ if mux.z == nil {
+ mux.z = make(map[string]Handler)
+ }
+ mux.z[Fqdn(pattern)] = handler
+ mux.m.Unlock()
+}
+
+// HandleFunc adds a handler function to the ServeMux for pattern.
+func (mux *ServeMux) HandleFunc(pattern string, handler func(ResponseWriter, *Msg)) {
+ mux.Handle(pattern, HandlerFunc(handler))
+}
+
+// HandleRemove deregisters the handler specific for pattern from the ServeMux.
+func (mux *ServeMux) HandleRemove(pattern string) {
+ if pattern == "" {
+ panic("dns: invalid pattern " + pattern)
+ }
+ mux.m.Lock()
+ delete(mux.z, Fqdn(pattern))
+ mux.m.Unlock()
+}
+
+// ServeDNS dispatches the request to the handler whose pattern most
+// closely matches the request message.
+//
+// ServeDNS is DNSSEC aware, meaning that queries for the DS record
+// are redirected to the parent zone (if that is also registered),
+// otherwise the child gets the query.
+//
+// If no handler is found, or there is no question, a standard SERVFAIL
+// message is returned
+func (mux *ServeMux) ServeDNS(w ResponseWriter, req *Msg) {
+ var h Handler
+ if len(req.Question) >= 1 { // allow more than one question
+ h = mux.match(req.Question[0].Name, req.Question[0].Qtype)
+ }
+
+ if h != nil {
+ h.ServeDNS(w, req)
+ } else {
+ HandleFailed(w, req)
+ }
+}
+
+// Handle registers the handler with the given pattern
+// in the DefaultServeMux. The documentation for
+// ServeMux explains how patterns are matched.
+func Handle(pattern string, handler Handler) { DefaultServeMux.Handle(pattern, handler) }
+
+// HandleRemove deregisters the handle with the given pattern
+// in the DefaultServeMux.
+func HandleRemove(pattern string) { DefaultServeMux.HandleRemove(pattern) }
+
+// HandleFunc registers the handler function with the given pattern
+// in the DefaultServeMux.
+func HandleFunc(pattern string, handler func(ResponseWriter, *Msg)) {
+ DefaultServeMux.HandleFunc(pattern, handler)
+}
diff --git a/vendor/github.com/miekg/dns/server.go b/vendor/github.com/miekg/dns/server.go
index 2d98f14888..4b4ec33c8d 100644
--- a/vendor/github.com/miekg/dns/server.go
+++ b/vendor/github.com/miekg/dns/server.go
@@ -4,10 +4,13 @@ package dns
import (
"bytes"
+ "context"
"crypto/tls"
"encoding/binary"
+ "errors"
"io"
"net"
+ "strings"
"sync"
"sync/atomic"
"time"
@@ -16,17 +19,39 @@ import (
// Default maximum number of TCP queries before we close the socket.
const maxTCPQueries = 128
-// Interval for stop worker if no load
+// The maximum number of idle workers.
+//
+// This controls the maximum number of workers that are allowed to stay
+// idle waiting for incoming requests before being torn down.
+//
+// If this limit is reached, the server will just keep spawning new
+// workers (goroutines) for each incoming request. In this case, each
+// worker will only be used for a single request.
+const maxIdleWorkersCount = 10000
+
+// The maximum length of time a worker may idle for before being destroyed.
const idleWorkerTimeout = 10 * time.Second
-// Maximum number of workers
-const maxWorkersCount = 10000
+// aLongTimeAgo is a non-zero time, far in the past, used for
+// immediate cancelation of network operations.
+var aLongTimeAgo = time.Unix(1, 0)
// Handler is implemented by any value that implements ServeDNS.
type Handler interface {
ServeDNS(w ResponseWriter, r *Msg)
}
+// The HandlerFunc type is an adapter to allow the use of
+// ordinary functions as DNS handlers. If f is a function
+// with the appropriate signature, HandlerFunc(f) is a
+// Handler object that calls f.
+type HandlerFunc func(ResponseWriter, *Msg)
+
+// ServeDNS calls f(w, r).
+func (f HandlerFunc) ServeDNS(w ResponseWriter, r *Msg) {
+ f(w, r)
+}
+
// A ResponseWriter interface is used by an DNS handler to
// construct an DNS response.
type ResponseWriter interface {
@@ -49,46 +74,24 @@ type ResponseWriter interface {
Hijack()
}
+// A ConnectionStater interface is used by a DNS Handler to access TLS connection state
+// when available.
+type ConnectionStater interface {
+ ConnectionState() *tls.ConnectionState
+}
+
type response struct {
msg []byte
hijacked bool // connection has been hijacked by handler
- tsigStatus error
tsigTimersOnly bool
+ tsigStatus error
tsigRequestMAC string
tsigSecret map[string]string // the tsig secrets
udp *net.UDPConn // i/o connection if UDP was used
tcp net.Conn // i/o connection if TCP was used
udpSession *SessionUDP // oob data to get egress interface right
writer Writer // writer to output the raw DNS bits
-}
-
-// ServeMux is an DNS request multiplexer. It matches the
-// zone name of each incoming request against a list of
-// registered patterns add calls the handler for the pattern
-// that most closely matches the zone name. ServeMux is DNSSEC aware, meaning
-// that queries for the DS record are redirected to the parent zone (if that
-// is also registered), otherwise the child gets the query.
-// ServeMux is also safe for concurrent access from multiple goroutines.
-type ServeMux struct {
- z map[string]Handler
- m *sync.RWMutex
-}
-
-// NewServeMux allocates and returns a new ServeMux.
-func NewServeMux() *ServeMux { return &ServeMux{z: make(map[string]Handler), m: new(sync.RWMutex)} }
-
-// DefaultServeMux is the default ServeMux used by Serve.
-var DefaultServeMux = NewServeMux()
-
-// The HandlerFunc type is an adapter to allow the use of
-// ordinary functions as DNS handlers. If f is a function
-// with the appropriate signature, HandlerFunc(f) is a
-// Handler object that calls f.
-type HandlerFunc func(ResponseWriter, *Msg)
-
-// ServeDNS calls f(w, r).
-func (f HandlerFunc) ServeDNS(w ResponseWriter, r *Msg) {
- f(w, r)
+ wg *sync.WaitGroup // for gracefull shutdown
}
// HandleFailed returns a HandlerFunc that returns SERVFAIL for every request it gets.
@@ -99,8 +102,6 @@ func HandleFailed(w ResponseWriter, r *Msg) {
w.WriteMsg(m)
}
-func failedHandler() Handler { return HandlerFunc(HandleFailed) }
-
// ListenAndServe Starts a server on address and network specified Invoke handler
// for incoming queries.
func ListenAndServe(addr string, network string, handler Handler) error {
@@ -139,99 +140,6 @@ func ActivateAndServe(l net.Listener, p net.PacketConn, handler Handler) error {
return server.ActivateAndServe()
}
-func (mux *ServeMux) match(q string, t uint16) Handler {
- mux.m.RLock()
- defer mux.m.RUnlock()
- var handler Handler
- b := make([]byte, len(q)) // worst case, one label of length q
- off := 0
- end := false
- for {
- l := len(q[off:])
- for i := 0; i < l; i++ {
- b[i] = q[off+i]
- if b[i] >= 'A' && b[i] <= 'Z' {
- b[i] |= ('a' - 'A')
- }
- }
- if h, ok := mux.z[string(b[:l])]; ok { // causes garbage, might want to change the map key
- if t != TypeDS {
- return h
- }
- // Continue for DS to see if we have a parent too, if so delegeate to the parent
- handler = h
- }
- off, end = NextLabel(q, off)
- if end {
- break
- }
- }
- // Wildcard match, if we have found nothing try the root zone as a last resort.
- if h, ok := mux.z["."]; ok {
- return h
- }
- return handler
-}
-
-// Handle adds a handler to the ServeMux for pattern.
-func (mux *ServeMux) Handle(pattern string, handler Handler) {
- if pattern == "" {
- panic("dns: invalid pattern " + pattern)
- }
- mux.m.Lock()
- mux.z[Fqdn(pattern)] = handler
- mux.m.Unlock()
-}
-
-// HandleFunc adds a handler function to the ServeMux for pattern.
-func (mux *ServeMux) HandleFunc(pattern string, handler func(ResponseWriter, *Msg)) {
- mux.Handle(pattern, HandlerFunc(handler))
-}
-
-// HandleRemove deregistrars the handler specific for pattern from the ServeMux.
-func (mux *ServeMux) HandleRemove(pattern string) {
- if pattern == "" {
- panic("dns: invalid pattern " + pattern)
- }
- mux.m.Lock()
- delete(mux.z, Fqdn(pattern))
- mux.m.Unlock()
-}
-
-// ServeDNS dispatches the request to the handler whose
-// pattern most closely matches the request message. If DefaultServeMux
-// is used the correct thing for DS queries is done: a possible parent
-// is sought.
-// If no handler is found a standard SERVFAIL message is returned
-// If the request message does not have exactly one question in the
-// question section a SERVFAIL is returned, unlesss Unsafe is true.
-func (mux *ServeMux) ServeDNS(w ResponseWriter, request *Msg) {
- var h Handler
- if len(request.Question) < 1 { // allow more than one question
- h = failedHandler()
- } else {
- if h = mux.match(request.Question[0].Name, request.Question[0].Qtype); h == nil {
- h = failedHandler()
- }
- }
- h.ServeDNS(w, request)
-}
-
-// Handle registers the handler with the given pattern
-// in the DefaultServeMux. The documentation for
-// ServeMux explains how patterns are matched.
-func Handle(pattern string, handler Handler) { DefaultServeMux.Handle(pattern, handler) }
-
-// HandleRemove deregisters the handle with the given pattern
-// in the DefaultServeMux.
-func HandleRemove(pattern string) { DefaultServeMux.HandleRemove(pattern) }
-
-// HandleFunc registers the handler function with the given pattern
-// in the DefaultServeMux.
-func HandleFunc(pattern string, handler func(ResponseWriter, *Msg)) {
- DefaultServeMux.HandleFunc(pattern, handler)
-}
-
// Writer writes raw DNS messages; each call to Write should send an entire message.
type Writer interface {
io.Writer
@@ -305,14 +213,30 @@ type Server struct {
DecorateWriter DecorateWriter
// Maximum number of TCP queries before we close the socket. Default is maxTCPQueries (unlimited if -1).
MaxTCPQueries int
+ // Whether to set the SO_REUSEPORT socket option, allowing multiple listeners to be bound to a single address.
+ // It is only supported on go1.11+ and when using ListenAndServe.
+ ReusePort bool
// UDP packet or TCP connection queue
queue chan *response
// Workers count
workersCount int32
+
// Shutdown handling
- lock sync.RWMutex
- started bool
+ lock sync.RWMutex
+ started bool
+ shutdown chan struct{}
+ conns map[net.Conn]struct{}
+
+ // A pool for UDP message buffers.
+ udpPool sync.Pool
+}
+
+func (srv *Server) isStarted() bool {
+ srv.lock.RLock()
+ started := srv.started
+ srv.lock.RUnlock()
+ return started
}
func (srv *Server) worker(w *response) {
@@ -320,7 +244,7 @@ func (srv *Server) worker(w *response) {
for {
count := atomic.LoadInt32(&srv.workersCount)
- if count > maxWorkersCount {
+ if count > maxIdleWorkersCount {
return
}
if atomic.CompareAndSwapInt32(&srv.workersCount, count, count+1) {
@@ -360,10 +284,36 @@ func (srv *Server) spawnWorker(w *response) {
}
}
+func makeUDPBuffer(size int) func() interface{} {
+ return func() interface{} {
+ return make([]byte, size)
+ }
+}
+
+func (srv *Server) init() {
+ srv.queue = make(chan *response)
+
+ srv.shutdown = make(chan struct{})
+ srv.conns = make(map[net.Conn]struct{})
+
+ if srv.UDPSize == 0 {
+ srv.UDPSize = MinMsgSize
+ }
+
+ srv.udpPool.New = makeUDPBuffer(srv.UDPSize)
+}
+
+func unlockOnce(l sync.Locker) func() {
+ var once sync.Once
+ return func() { once.Do(l.Unlock) }
+}
+
// ListenAndServe starts a nameserver on the configured address in *Server.
func (srv *Server) ListenAndServe() error {
+ unlock := unlockOnce(&srv.lock)
srv.lock.Lock()
- defer srv.lock.Unlock()
+ defer unlock()
+
if srv.started {
return &Error{err: "server already started"}
}
@@ -372,63 +322,47 @@ func (srv *Server) ListenAndServe() error {
if addr == "" {
addr = ":domain"
}
- if srv.UDPSize == 0 {
- srv.UDPSize = MinMsgSize
- }
- srv.queue = make(chan *response)
+
+ srv.init()
defer close(srv.queue)
+
switch srv.Net {
case "tcp", "tcp4", "tcp6":
- a, err := net.ResolveTCPAddr(srv.Net, addr)
- if err != nil {
- return err
- }
- l, err := net.ListenTCP(srv.Net, a)
+ l, err := listenTCP(srv.Net, addr, srv.ReusePort)
if err != nil {
return err
}
srv.Listener = l
srv.started = true
- srv.lock.Unlock()
- err = srv.serveTCP(l)
- srv.lock.Lock() // to satisfy the defer at the top
- return err
+ unlock()
+ return srv.serveTCP(l)
case "tcp-tls", "tcp4-tls", "tcp6-tls":
- network := "tcp"
- if srv.Net == "tcp4-tls" {
- network = "tcp4"
- } else if srv.Net == "tcp6-tls" {
- network = "tcp6"
+ if srv.TLSConfig == nil || (len(srv.TLSConfig.Certificates) == 0 && srv.TLSConfig.GetCertificate == nil) {
+ return errors.New("dns: neither Certificates nor GetCertificate set in Config")
}
-
- l, err := tls.Listen(network, addr, srv.TLSConfig)
+ network := strings.TrimSuffix(srv.Net, "-tls")
+ l, err := listenTCP(network, addr, srv.ReusePort)
if err != nil {
return err
}
+ l = tls.NewListener(l, srv.TLSConfig)
srv.Listener = l
srv.started = true
- srv.lock.Unlock()
- err = srv.serveTCP(l)
- srv.lock.Lock() // to satisfy the defer at the top
- return err
+ unlock()
+ return srv.serveTCP(l)
case "udp", "udp4", "udp6":
- a, err := net.ResolveUDPAddr(srv.Net, addr)
+ l, err := listenUDP(srv.Net, addr, srv.ReusePort)
if err != nil {
return err
}
- l, err := net.ListenUDP(srv.Net, a)
- if err != nil {
- return err
- }
- if e := setUDPSocketOptions(l); e != nil {
+ u := l.(*net.UDPConn)
+ if e := setUDPSocketOptions(u); e != nil {
return e
}
srv.PacketConn = l
srv.started = true
- srv.lock.Unlock()
- err = srv.serveUDP(l)
- srv.lock.Lock() // to satisfy the defer at the top
- return err
+ unlock()
+ return srv.serveUDP(u)
}
return &Error{err: "bad network"}
}
@@ -436,20 +370,20 @@ func (srv *Server) ListenAndServe() error {
// ActivateAndServe starts a nameserver with the PacketConn or Listener
// configured in *Server. Its main use is to start a server from systemd.
func (srv *Server) ActivateAndServe() error {
+ unlock := unlockOnce(&srv.lock)
srv.lock.Lock()
- defer srv.lock.Unlock()
+ defer unlock()
+
if srv.started {
return &Error{err: "server already started"}
}
+ srv.init()
+ defer close(srv.queue)
+
pConn := srv.PacketConn
l := srv.Listener
- srv.queue = make(chan *response)
- defer close(srv.queue)
if pConn != nil {
- if srv.UDPSize == 0 {
- srv.UDPSize = MinMsgSize
- }
// Check PacketConn interface's type is valid and value
// is not nil
if t, ok := pConn.(*net.UDPConn); ok && t != nil {
@@ -457,18 +391,14 @@ func (srv *Server) ActivateAndServe() error {
return e
}
srv.started = true
- srv.lock.Unlock()
- e := srv.serveUDP(t)
- srv.lock.Lock() // to satisfy the defer at the top
- return e
+ unlock()
+ return srv.serveUDP(t)
}
}
if l != nil {
srv.started = true
- srv.lock.Unlock()
- e := srv.serveTCP(l)
- srv.lock.Lock() // to satisfy the defer at the top
- return e
+ unlock()
+ return srv.serveTCP(l)
}
return &Error{err: "bad listeners"}
}
@@ -476,23 +406,57 @@ func (srv *Server) ActivateAndServe() error {
// Shutdown shuts down a server. After a call to Shutdown, ListenAndServe and
// ActivateAndServe will return.
func (srv *Server) Shutdown() error {
+ return srv.ShutdownContext(context.Background())
+}
+
+// ShutdownContext shuts down a server. After a call to ShutdownContext,
+// ListenAndServe and ActivateAndServe will return.
+//
+// A context.Context may be passed to limit how long to wait for connections
+// to terminate.
+func (srv *Server) ShutdownContext(ctx context.Context) error {
srv.lock.Lock()
if !srv.started {
srv.lock.Unlock()
return &Error{err: "server not started"}
}
+
srv.started = false
+
+ if srv.PacketConn != nil {
+ srv.PacketConn.SetReadDeadline(aLongTimeAgo) // Unblock reads
+ }
+
+ if srv.Listener != nil {
+ srv.Listener.Close()
+ }
+
+ for rw := range srv.conns {
+ rw.SetReadDeadline(aLongTimeAgo) // Unblock reads
+ }
+
srv.lock.Unlock()
+ if testShutdownNotify != nil {
+ testShutdownNotify.Broadcast()
+ }
+
+ var ctxErr error
+ select {
+ case <-srv.shutdown:
+ case <-ctx.Done():
+ ctxErr = ctx.Err()
+ }
+
if srv.PacketConn != nil {
srv.PacketConn.Close()
}
- if srv.Listener != nil {
- srv.Listener.Close()
- }
- return nil
+
+ return ctxErr
}
+var testShutdownNotify *sync.Cond
+
// getReadTimeout is a helper func to use system timeout if server did not intend to change it.
func (srv *Server) getReadTimeout() time.Duration {
rtimeout := dnsTimeout
@@ -510,22 +474,36 @@ func (srv *Server) serveTCP(l net.Listener) error {
srv.NotifyStartedFunc()
}
- for {
+ var wg sync.WaitGroup
+ defer func() {
+ wg.Wait()
+ close(srv.shutdown)
+ }()
+
+ for srv.isStarted() {
rw, err := l.Accept()
- srv.lock.RLock()
- if !srv.started {
- srv.lock.RUnlock()
- return nil
- }
- srv.lock.RUnlock()
if err != nil {
+ if !srv.isStarted() {
+ return nil
+ }
if neterr, ok := err.(net.Error); ok && neterr.Temporary() {
continue
}
return err
}
- srv.spawnWorker(&response{tsigSecret: srv.TsigSecret, tcp: rw})
+ srv.lock.Lock()
+ // Track the connection to allow unblocking reads on shutdown.
+ srv.conns[rw] = struct{}{}
+ srv.lock.Unlock()
+ wg.Add(1)
+ srv.spawnWorker(&response{
+ tsigSecret: srv.TsigSecret,
+ tcp: rw,
+ wg: &wg,
+ })
}
+
+ return nil
}
// serveUDP starts a UDP listener for the server.
@@ -541,27 +519,42 @@ func (srv *Server) serveUDP(l *net.UDPConn) error {
reader = srv.DecorateReader(reader)
}
+ var wg sync.WaitGroup
+ defer func() {
+ wg.Wait()
+ close(srv.shutdown)
+ }()
+
rtimeout := srv.getReadTimeout()
// deadline is not used here
- for {
+ for srv.isStarted() {
m, s, err := reader.ReadUDP(l, rtimeout)
- srv.lock.RLock()
- if !srv.started {
- srv.lock.RUnlock()
- return nil
- }
- srv.lock.RUnlock()
if err != nil {
+ if !srv.isStarted() {
+ return nil
+ }
if netErr, ok := err.(net.Error); ok && netErr.Temporary() {
continue
}
return err
}
if len(m) < headerSize {
+ if cap(m) == srv.UDPSize {
+ srv.udpPool.Put(m[:srv.UDPSize])
+ }
continue
}
- srv.spawnWorker(&response{msg: m, tsigSecret: srv.TsigSecret, udp: l, udpSession: s})
+ wg.Add(1)
+ srv.spawnWorker(&response{
+ msg: m,
+ tsigSecret: srv.TsigSecret,
+ udp: l,
+ udpSession: s,
+ wg: &wg,
+ })
}
+
+ return nil
}
func (srv *Server) serve(w *response) {
@@ -574,20 +567,28 @@ func (srv *Server) serve(w *response) {
if w.udp != nil {
// serve UDP
srv.serveDNS(w)
- return
- }
- reader := Reader(&defaultReader{srv})
- if srv.DecorateReader != nil {
- reader = srv.DecorateReader(reader)
+ w.wg.Done()
+ return
}
defer func() {
if !w.hijacked {
w.Close()
}
+
+ srv.lock.Lock()
+ delete(srv.conns, w.tcp)
+ srv.lock.Unlock()
+
+ w.wg.Done()
}()
+ reader := Reader(&defaultReader{srv})
+ if srv.DecorateReader != nil {
+ reader = srv.DecorateReader(reader)
+ }
+
idleTimeout := tcpIdleTimeout
if srv.IdleTimeout != nil {
idleTimeout = srv.IdleTimeout()
@@ -600,7 +601,7 @@ func (srv *Server) serve(w *response) {
limit = maxTCPQueries
}
- for q := 0; q < limit || limit == -1; q++ {
+ for q := 0; (q < limit || limit == -1) && srv.isStarted(); q++ {
var err error
w.msg, err = reader.ReadTCP(w.tcp, timeout)
if err != nil {
@@ -620,6 +621,13 @@ func (srv *Server) serve(w *response) {
}
}
+func (srv *Server) disposeBuffer(w *response) {
+ if w.udp != nil && cap(w.msg) == srv.UDPSize {
+ srv.udpPool.Put(w.msg[:srv.UDPSize])
+ }
+ w.msg = nil
+}
+
func (srv *Server) serveDNS(w *response) {
req := new(Msg)
err := req.Unpack(w.msg)
@@ -627,9 +635,9 @@ func (srv *Server) serveDNS(w *response) {
x := new(Msg)
x.SetRcodeFormatError(req)
w.WriteMsg(x)
- return
}
- if !srv.Unsafe && req.Response {
+ if err != nil || !srv.Unsafe && req.Response {
+ srv.disposeBuffer(w)
return
}
@@ -646,6 +654,8 @@ func (srv *Server) serveDNS(w *response) {
}
}
+ srv.disposeBuffer(w)
+
handler := srv.Handler
if handler == nil {
handler = DefaultServeMux
@@ -655,7 +665,16 @@ func (srv *Server) serveDNS(w *response) {
}
func (srv *Server) readTCP(conn net.Conn, timeout time.Duration) ([]byte, error) {
- conn.SetReadDeadline(time.Now().Add(timeout))
+ // If we race with ShutdownContext, the read deadline may
+ // have been set in the distant past to unblock the read
+ // below. We must not override it, otherwise we may block
+ // ShutdownContext.
+ srv.lock.RLock()
+ if srv.started {
+ conn.SetReadDeadline(time.Now().Add(timeout))
+ }
+ srv.lock.RUnlock()
+
l := make([]byte, 2)
n, err := conn.Read(l)
if err != nil || n != 2 {
@@ -690,10 +709,17 @@ func (srv *Server) readTCP(conn net.Conn, timeout time.Duration) ([]byte, error)
}
func (srv *Server) readUDP(conn *net.UDPConn, timeout time.Duration) ([]byte, *SessionUDP, error) {
- conn.SetReadDeadline(time.Now().Add(timeout))
- m := make([]byte, srv.UDPSize)
+ srv.lock.RLock()
+ if srv.started {
+ // See the comment in readTCP above.
+ conn.SetReadDeadline(time.Now().Add(timeout))
+ }
+ srv.lock.RUnlock()
+
+ m := srv.udpPool.Get().([]byte)
n, s, err := ReadFromSessionUDP(conn, m)
if err != nil {
+ srv.udpPool.Put(m)
return nil, nil, err
}
m = m[:n]
@@ -741,24 +767,33 @@ func (w *response) Write(m []byte) (int, error) {
n, err := io.Copy(w.tcp, bytes.NewReader(m))
return int(n), err
+ default:
+ panic("dns: Write called after Close")
}
- panic("not reached")
}
// LocalAddr implements the ResponseWriter.LocalAddr method.
func (w *response) LocalAddr() net.Addr {
- if w.tcp != nil {
+ switch {
+ case w.udp != nil:
+ return w.udp.LocalAddr()
+ case w.tcp != nil:
return w.tcp.LocalAddr()
+ default:
+ panic("dns: LocalAddr called after Close")
}
- return w.udp.LocalAddr()
}
// RemoteAddr implements the ResponseWriter.RemoteAddr method.
func (w *response) RemoteAddr() net.Addr {
- if w.tcp != nil {
+ switch {
+ case w.udpSession != nil:
+ return w.udpSession.RemoteAddr()
+ case w.tcp != nil:
return w.tcp.RemoteAddr()
+ default:
+ panic("dns: RemoteAddr called after Close")
}
- return w.udpSession.RemoteAddr()
}
// TsigStatus implements the ResponseWriter.TsigStatus method.
@@ -780,3 +815,15 @@ func (w *response) Close() error {
}
return nil
}
+
+// ConnectionState() implements the ConnectionStater.ConnectionState() interface.
+func (w *response) ConnectionState() *tls.ConnectionState {
+ type tlsConnectionStater interface {
+ ConnectionState() tls.ConnectionState
+ }
+ if v, ok := w.tcp.(tlsConnectionStater); ok {
+ t := v.ConnectionState()
+ return &t
+ }
+ return nil
+}
diff --git a/vendor/github.com/miekg/dns/sig0.go b/vendor/github.com/miekg/dns/sig0.go
index f31e9e6843..07c2acb196 100644
--- a/vendor/github.com/miekg/dns/sig0.go
+++ b/vendor/github.com/miekg/dns/sig0.go
@@ -127,8 +127,7 @@ func (rr *SIG) Verify(k *KEY, buf []byte) error {
if offset+1 >= buflen {
continue
}
- var rdlen uint16
- rdlen = binary.BigEndian.Uint16(buf[offset:])
+ rdlen := binary.BigEndian.Uint16(buf[offset:])
offset += 2
offset += int(rdlen)
}
diff --git a/vendor/github.com/miekg/dns/types.go b/vendor/github.com/miekg/dns/types.go
index a779ca8abc..115f2c7bd0 100644
--- a/vendor/github.com/miekg/dns/types.go
+++ b/vendor/github.com/miekg/dns/types.go
@@ -330,7 +330,7 @@ func (rr *MX) String() string {
type AFSDB struct {
Hdr RR_Header
Subtype uint16
- Hostname string `dns:"cdomain-name"`
+ Hostname string `dns:"domain-name"`
}
func (rr *AFSDB) String() string {
@@ -419,128 +419,130 @@ type TXT struct {
func (rr *TXT) String() string { return rr.Hdr.String() + sprintTxt(rr.Txt) }
func sprintName(s string) string {
- src := []byte(s)
- dst := make([]byte, 0, len(src))
- for i := 0; i < len(src); {
- if i+1 < len(src) && src[i] == '\\' && src[i+1] == '.' {
- dst = append(dst, src[i:i+2]...)
+ var dst strings.Builder
+ dst.Grow(len(s))
+ for i := 0; i < len(s); {
+ if i+1 < len(s) && s[i] == '\\' && s[i+1] == '.' {
+ dst.WriteString(s[i : i+2])
i += 2
- } else {
- b, n := nextByte(src, i)
- if n == 0 {
- i++ // dangling back slash
- } else if b == '.' {
- dst = append(dst, b)
- } else {
- dst = appendDomainNameByte(dst, b)
- }
- i += n
+ continue
}
+
+ b, n := nextByte(s, i)
+ switch {
+ case n == 0:
+ i++ // dangling back slash
+ case b == '.':
+ dst.WriteByte('.')
+ default:
+ writeDomainNameByte(&dst, b)
+ }
+ i += n
}
- return string(dst)
+ return dst.String()
}
func sprintTxtOctet(s string) string {
- src := []byte(s)
- dst := make([]byte, 0, len(src))
- dst = append(dst, '"')
- for i := 0; i < len(src); {
- if i+1 < len(src) && src[i] == '\\' && src[i+1] == '.' {
- dst = append(dst, src[i:i+2]...)
+ var dst strings.Builder
+ dst.Grow(2 + len(s))
+ dst.WriteByte('"')
+ for i := 0; i < len(s); {
+ if i+1 < len(s) && s[i] == '\\' && s[i+1] == '.' {
+ dst.WriteString(s[i : i+2])
i += 2
- } else {
- b, n := nextByte(src, i)
- if n == 0 {
- i++ // dangling back slash
- } else if b == '.' {
- dst = append(dst, b)
- } else {
- if b < ' ' || b > '~' {
- dst = appendByte(dst, b)
- } else {
- dst = append(dst, b)
- }
- }
- i += n
+ continue
}
+
+ b, n := nextByte(s, i)
+ switch {
+ case n == 0:
+ i++ // dangling back slash
+ case b == '.':
+ dst.WriteByte('.')
+ case b < ' ' || b > '~':
+ writeEscapedByte(&dst, b)
+ default:
+ dst.WriteByte(b)
+ }
+ i += n
}
- dst = append(dst, '"')
- return string(dst)
+ dst.WriteByte('"')
+ return dst.String()
}
func sprintTxt(txt []string) string {
- var out []byte
+ var out strings.Builder
for i, s := range txt {
+ out.Grow(3 + len(s))
if i > 0 {
- out = append(out, ` "`...)
+ out.WriteString(` "`)
} else {
- out = append(out, '"')
+ out.WriteByte('"')
}
- bs := []byte(s)
- for j := 0; j < len(bs); {
- b, n := nextByte(bs, j)
+ for j := 0; j < len(s); {
+ b, n := nextByte(s, j)
if n == 0 {
break
}
- out = appendTXTStringByte(out, b)
+ writeTXTStringByte(&out, b)
j += n
}
- out = append(out, '"')
+ out.WriteByte('"')
}
- return string(out)
+ return out.String()
}
-func appendDomainNameByte(s []byte, b byte) []byte {
+func writeDomainNameByte(s *strings.Builder, b byte) {
switch b {
case '.', ' ', '\'', '@', ';', '(', ')': // additional chars to escape
- return append(s, '\\', b)
+ s.WriteByte('\\')
+ s.WriteByte(b)
+ default:
+ writeTXTStringByte(s, b)
}
- return appendTXTStringByte(s, b)
}
-func appendTXTStringByte(s []byte, b byte) []byte {
- switch b {
- case '"', '\\':
- return append(s, '\\', b)
+func writeTXTStringByte(s *strings.Builder, b byte) {
+ switch {
+ case b == '"' || b == '\\':
+ s.WriteByte('\\')
+ s.WriteByte(b)
+ case b < ' ' || b > '~':
+ writeEscapedByte(s, b)
+ default:
+ s.WriteByte(b)
}
- if b < ' ' || b > '~' {
- return appendByte(s, b)
- }
- return append(s, b)
}
-func appendByte(s []byte, b byte) []byte {
+func writeEscapedByte(s *strings.Builder, b byte) {
var buf [3]byte
bufs := strconv.AppendInt(buf[:0], int64(b), 10)
- s = append(s, '\\')
- for i := 0; i < 3-len(bufs); i++ {
- s = append(s, '0')
+ s.WriteByte('\\')
+ for i := len(bufs); i < 3; i++ {
+ s.WriteByte('0')
}
- for _, r := range bufs {
- s = append(s, r)
- }
- return s
+ s.Write(bufs)
}
-func nextByte(b []byte, offset int) (byte, int) {
- if offset >= len(b) {
+func nextByte(s string, offset int) (byte, int) {
+ if offset >= len(s) {
return 0, 0
}
- if b[offset] != '\\' {
+ if s[offset] != '\\' {
// not an escape sequence
- return b[offset], 1
+ return s[offset], 1
}
- switch len(b) - offset {
+ switch len(s) - offset {
case 1: // dangling escape
return 0, 0
case 2, 3: // too short to be \ddd
default: // maybe \ddd
- if isDigit(b[offset+1]) && isDigit(b[offset+2]) && isDigit(b[offset+3]) {
- return dddToByte(b[offset+1:]), 4
+ if isDigit(s[offset+1]) && isDigit(s[offset+2]) && isDigit(s[offset+3]) {
+ return dddStringToByte(s[offset+1:]), 4
}
}
// not \ddd, just an RFC 1035 "quoted" character
- return b[offset+1], 2
+ return s[offset+1], 2
}
// SPF RR. See RFC 4408, Section 3.1.1.
@@ -728,7 +730,7 @@ func (rr *LOC) String() string {
lat = lat % LOC_DEGREES
m := lat / LOC_HOURS
lat = lat % LOC_HOURS
- s += fmt.Sprintf("%02d %02d %0.3f %s ", h, m, (float64(lat) / 1000), ns)
+ s += fmt.Sprintf("%02d %02d %0.3f %s ", h, m, float64(lat)/1000, ns)
lon := rr.Longitude
ew := "E"
@@ -742,7 +744,7 @@ func (rr *LOC) String() string {
lon = lon % LOC_DEGREES
m = lon / LOC_HOURS
lon = lon % LOC_HOURS
- s += fmt.Sprintf("%02d %02d %0.3f %s ", h, m, (float64(lon) / 1000), ew)
+ s += fmt.Sprintf("%02d %02d %0.3f %s ", h, m, float64(lon)/1000, ew)
var alt = float64(rr.Altitude) / 100
alt -= LOC_ALTITUDEBASE
@@ -752,9 +754,9 @@ func (rr *LOC) String() string {
s += fmt.Sprintf("%.0fm ", alt)
}
- s += cmToM((rr.Size&0xf0)>>4, rr.Size&0x0f) + "m "
- s += cmToM((rr.HorizPre&0xf0)>>4, rr.HorizPre&0x0f) + "m "
- s += cmToM((rr.VertPre&0xf0)>>4, rr.VertPre&0x0f) + "m"
+ s += cmToM(rr.Size&0xf0>>4, rr.Size&0x0f) + "m "
+ s += cmToM(rr.HorizPre&0xf0>>4, rr.HorizPre&0x0f) + "m "
+ s += cmToM(rr.VertPre&0xf0>>4, rr.VertPre&0x0f) + "m"
return s
}
@@ -1306,11 +1308,11 @@ func (rr *CSYNC) len() int {
// string representation used when printing the record.
// It takes serial arithmetic (RFC 1982) into account.
func TimeToString(t uint32) string {
- mod := ((int64(t) - time.Now().Unix()) / year68) - 1
+ mod := (int64(t)-time.Now().Unix())/year68 - 1
if mod < 0 {
mod = 0
}
- ti := time.Unix(int64(t)-(mod*year68), 0).UTC()
+ ti := time.Unix(int64(t)-mod*year68, 0).UTC()
return ti.Format("20060102150405")
}
@@ -1322,11 +1324,11 @@ func StringToTime(s string) (uint32, error) {
if err != nil {
return 0, err
}
- mod := (t.Unix() / year68) - 1
+ mod := t.Unix()/year68 - 1
if mod < 0 {
mod = 0
}
- return uint32(t.Unix() - (mod * year68)), nil
+ return uint32(t.Unix() - mod*year68), nil
}
// saltToString converts a NSECX salt to uppercase and returns "-" when it is empty.
diff --git a/vendor/github.com/miekg/dns/version.go b/vendor/github.com/miekg/dns/version.go
index dcc84e4a7d..403b9ef978 100644
--- a/vendor/github.com/miekg/dns/version.go
+++ b/vendor/github.com/miekg/dns/version.go
@@ -3,7 +3,7 @@ package dns
import "fmt"
// Version is current version of this library.
-var Version = V{1, 0, 8}
+var Version = V{1, 0, 13}
// V holds the version of this library.
type V struct {
diff --git a/vendor/github.com/miekg/dns/zcompress.go b/vendor/github.com/miekg/dns/zcompress.go
index a2c09dd483..6391a3501f 100644
--- a/vendor/github.com/miekg/dns/zcompress.go
+++ b/vendor/github.com/miekg/dns/zcompress.go
@@ -109,9 +109,6 @@ func compressionLenHelperType(c map[string]int, r RR, initLen int) int {
func compressionLenSearchType(c map[string]int, r RR) (int, bool, int) {
switch x := r.(type) {
- case *AFSDB:
- k1, ok1, sz1 := compressionLenSearch(c, x.Hostname)
- return k1, ok1, sz1
case *CNAME:
k1, ok1, sz1 := compressionLenSearch(c, x.Target)
return k1, ok1, sz1
diff --git a/vendor/github.com/miekg/dns/zduplicate.go b/vendor/github.com/miekg/dns/zduplicate.go
new file mode 100644
index 0000000000..ba9863b233
--- /dev/null
+++ b/vendor/github.com/miekg/dns/zduplicate.go
@@ -0,0 +1,943 @@
+// Code generated by "go run duplicate_generate.go"; DO NOT EDIT.
+
+package dns
+
+// isDuplicateRdata calls the rdata specific functions
+func isDuplicateRdata(r1, r2 RR) bool {
+ switch r1.Header().Rrtype {
+ case TypeA:
+ return isDuplicateA(r1.(*A), r2.(*A))
+ case TypeAAAA:
+ return isDuplicateAAAA(r1.(*AAAA), r2.(*AAAA))
+ case TypeAFSDB:
+ return isDuplicateAFSDB(r1.(*AFSDB), r2.(*AFSDB))
+ case TypeAVC:
+ return isDuplicateAVC(r1.(*AVC), r2.(*AVC))
+ case TypeCAA:
+ return isDuplicateCAA(r1.(*CAA), r2.(*CAA))
+ case TypeCERT:
+ return isDuplicateCERT(r1.(*CERT), r2.(*CERT))
+ case TypeCNAME:
+ return isDuplicateCNAME(r1.(*CNAME), r2.(*CNAME))
+ case TypeCSYNC:
+ return isDuplicateCSYNC(r1.(*CSYNC), r2.(*CSYNC))
+ case TypeDHCID:
+ return isDuplicateDHCID(r1.(*DHCID), r2.(*DHCID))
+ case TypeDNAME:
+ return isDuplicateDNAME(r1.(*DNAME), r2.(*DNAME))
+ case TypeDNSKEY:
+ return isDuplicateDNSKEY(r1.(*DNSKEY), r2.(*DNSKEY))
+ case TypeDS:
+ return isDuplicateDS(r1.(*DS), r2.(*DS))
+ case TypeEID:
+ return isDuplicateEID(r1.(*EID), r2.(*EID))
+ case TypeEUI48:
+ return isDuplicateEUI48(r1.(*EUI48), r2.(*EUI48))
+ case TypeEUI64:
+ return isDuplicateEUI64(r1.(*EUI64), r2.(*EUI64))
+ case TypeGID:
+ return isDuplicateGID(r1.(*GID), r2.(*GID))
+ case TypeGPOS:
+ return isDuplicateGPOS(r1.(*GPOS), r2.(*GPOS))
+ case TypeHINFO:
+ return isDuplicateHINFO(r1.(*HINFO), r2.(*HINFO))
+ case TypeHIP:
+ return isDuplicateHIP(r1.(*HIP), r2.(*HIP))
+ case TypeKX:
+ return isDuplicateKX(r1.(*KX), r2.(*KX))
+ case TypeL32:
+ return isDuplicateL32(r1.(*L32), r2.(*L32))
+ case TypeL64:
+ return isDuplicateL64(r1.(*L64), r2.(*L64))
+ case TypeLOC:
+ return isDuplicateLOC(r1.(*LOC), r2.(*LOC))
+ case TypeLP:
+ return isDuplicateLP(r1.(*LP), r2.(*LP))
+ case TypeMB:
+ return isDuplicateMB(r1.(*MB), r2.(*MB))
+ case TypeMD:
+ return isDuplicateMD(r1.(*MD), r2.(*MD))
+ case TypeMF:
+ return isDuplicateMF(r1.(*MF), r2.(*MF))
+ case TypeMG:
+ return isDuplicateMG(r1.(*MG), r2.(*MG))
+ case TypeMINFO:
+ return isDuplicateMINFO(r1.(*MINFO), r2.(*MINFO))
+ case TypeMR:
+ return isDuplicateMR(r1.(*MR), r2.(*MR))
+ case TypeMX:
+ return isDuplicateMX(r1.(*MX), r2.(*MX))
+ case TypeNAPTR:
+ return isDuplicateNAPTR(r1.(*NAPTR), r2.(*NAPTR))
+ case TypeNID:
+ return isDuplicateNID(r1.(*NID), r2.(*NID))
+ case TypeNIMLOC:
+ return isDuplicateNIMLOC(r1.(*NIMLOC), r2.(*NIMLOC))
+ case TypeNINFO:
+ return isDuplicateNINFO(r1.(*NINFO), r2.(*NINFO))
+ case TypeNS:
+ return isDuplicateNS(r1.(*NS), r2.(*NS))
+ case TypeNSAPPTR:
+ return isDuplicateNSAPPTR(r1.(*NSAPPTR), r2.(*NSAPPTR))
+ case TypeNSEC:
+ return isDuplicateNSEC(r1.(*NSEC), r2.(*NSEC))
+ case TypeNSEC3:
+ return isDuplicateNSEC3(r1.(*NSEC3), r2.(*NSEC3))
+ case TypeNSEC3PARAM:
+ return isDuplicateNSEC3PARAM(r1.(*NSEC3PARAM), r2.(*NSEC3PARAM))
+ case TypeOPENPGPKEY:
+ return isDuplicateOPENPGPKEY(r1.(*OPENPGPKEY), r2.(*OPENPGPKEY))
+ case TypePTR:
+ return isDuplicatePTR(r1.(*PTR), r2.(*PTR))
+ case TypePX:
+ return isDuplicatePX(r1.(*PX), r2.(*PX))
+ case TypeRKEY:
+ return isDuplicateRKEY(r1.(*RKEY), r2.(*RKEY))
+ case TypeRP:
+ return isDuplicateRP(r1.(*RP), r2.(*RP))
+ case TypeRRSIG:
+ return isDuplicateRRSIG(r1.(*RRSIG), r2.(*RRSIG))
+ case TypeRT:
+ return isDuplicateRT(r1.(*RT), r2.(*RT))
+ case TypeSMIMEA:
+ return isDuplicateSMIMEA(r1.(*SMIMEA), r2.(*SMIMEA))
+ case TypeSOA:
+ return isDuplicateSOA(r1.(*SOA), r2.(*SOA))
+ case TypeSPF:
+ return isDuplicateSPF(r1.(*SPF), r2.(*SPF))
+ case TypeSRV:
+ return isDuplicateSRV(r1.(*SRV), r2.(*SRV))
+ case TypeSSHFP:
+ return isDuplicateSSHFP(r1.(*SSHFP), r2.(*SSHFP))
+ case TypeTA:
+ return isDuplicateTA(r1.(*TA), r2.(*TA))
+ case TypeTALINK:
+ return isDuplicateTALINK(r1.(*TALINK), r2.(*TALINK))
+ case TypeTKEY:
+ return isDuplicateTKEY(r1.(*TKEY), r2.(*TKEY))
+ case TypeTLSA:
+ return isDuplicateTLSA(r1.(*TLSA), r2.(*TLSA))
+ case TypeTSIG:
+ return isDuplicateTSIG(r1.(*TSIG), r2.(*TSIG))
+ case TypeTXT:
+ return isDuplicateTXT(r1.(*TXT), r2.(*TXT))
+ case TypeUID:
+ return isDuplicateUID(r1.(*UID), r2.(*UID))
+ case TypeUINFO:
+ return isDuplicateUINFO(r1.(*UINFO), r2.(*UINFO))
+ case TypeURI:
+ return isDuplicateURI(r1.(*URI), r2.(*URI))
+ case TypeX25:
+ return isDuplicateX25(r1.(*X25), r2.(*X25))
+ }
+ return false
+}
+
+// isDuplicate() functions
+
+func isDuplicateA(r1, r2 *A) bool {
+ if len(r1.A) != len(r2.A) {
+ return false
+ }
+ for i := 0; i < len(r1.A); i++ {
+ if r1.A[i] != r2.A[i] {
+ return false
+ }
+ }
+ return true
+}
+
+func isDuplicateAAAA(r1, r2 *AAAA) bool {
+ if len(r1.AAAA) != len(r2.AAAA) {
+ return false
+ }
+ for i := 0; i < len(r1.AAAA); i++ {
+ if r1.AAAA[i] != r2.AAAA[i] {
+ return false
+ }
+ }
+ return true
+}
+
+func isDuplicateAFSDB(r1, r2 *AFSDB) bool {
+ if r1.Subtype != r2.Subtype {
+ return false
+ }
+ if !isDulicateName(r1.Hostname, r2.Hostname) {
+ return false
+ }
+ return true
+}
+
+func isDuplicateAVC(r1, r2 *AVC) bool {
+ if len(r1.Txt) != len(r2.Txt) {
+ return false
+ }
+ for i := 0; i < len(r1.Txt); i++ {
+ if r1.Txt[i] != r2.Txt[i] {
+ return false
+ }
+ }
+ return true
+}
+
+func isDuplicateCAA(r1, r2 *CAA) bool {
+ if r1.Flag != r2.Flag {
+ return false
+ }
+ if r1.Tag != r2.Tag {
+ return false
+ }
+ if r1.Value != r2.Value {
+ return false
+ }
+ return true
+}
+
+func isDuplicateCERT(r1, r2 *CERT) bool {
+ if r1.Type != r2.Type {
+ return false
+ }
+ if r1.KeyTag != r2.KeyTag {
+ return false
+ }
+ if r1.Algorithm != r2.Algorithm {
+ return false
+ }
+ if r1.Certificate != r2.Certificate {
+ return false
+ }
+ return true
+}
+
+func isDuplicateCNAME(r1, r2 *CNAME) bool {
+ if !isDulicateName(r1.Target, r2.Target) {
+ return false
+ }
+ return true
+}
+
+func isDuplicateCSYNC(r1, r2 *CSYNC) bool {
+ if r1.Serial != r2.Serial {
+ return false
+ }
+ if r1.Flags != r2.Flags {
+ return false
+ }
+ if len(r1.TypeBitMap) != len(r2.TypeBitMap) {
+ return false
+ }
+ for i := 0; i < len(r1.TypeBitMap); i++ {
+ if r1.TypeBitMap[i] != r2.TypeBitMap[i] {
+ return false
+ }
+ }
+ return true
+}
+
+func isDuplicateDHCID(r1, r2 *DHCID) bool {
+ if r1.Digest != r2.Digest {
+ return false
+ }
+ return true
+}
+
+func isDuplicateDNAME(r1, r2 *DNAME) bool {
+ if !isDulicateName(r1.Target, r2.Target) {
+ return false
+ }
+ return true
+}
+
+func isDuplicateDNSKEY(r1, r2 *DNSKEY) bool {
+ if r1.Flags != r2.Flags {
+ return false
+ }
+ if r1.Protocol != r2.Protocol {
+ return false
+ }
+ if r1.Algorithm != r2.Algorithm {
+ return false
+ }
+ if r1.PublicKey != r2.PublicKey {
+ return false
+ }
+ return true
+}
+
+func isDuplicateDS(r1, r2 *DS) bool {
+ if r1.KeyTag != r2.KeyTag {
+ return false
+ }
+ if r1.Algorithm != r2.Algorithm {
+ return false
+ }
+ if r1.DigestType != r2.DigestType {
+ return false
+ }
+ if r1.Digest != r2.Digest {
+ return false
+ }
+ return true
+}
+
+func isDuplicateEID(r1, r2 *EID) bool {
+ if r1.Endpoint != r2.Endpoint {
+ return false
+ }
+ return true
+}
+
+func isDuplicateEUI48(r1, r2 *EUI48) bool {
+ if r1.Address != r2.Address {
+ return false
+ }
+ return true
+}
+
+func isDuplicateEUI64(r1, r2 *EUI64) bool {
+ if r1.Address != r2.Address {
+ return false
+ }
+ return true
+}
+
+func isDuplicateGID(r1, r2 *GID) bool {
+ if r1.Gid != r2.Gid {
+ return false
+ }
+ return true
+}
+
+func isDuplicateGPOS(r1, r2 *GPOS) bool {
+ if r1.Longitude != r2.Longitude {
+ return false
+ }
+ if r1.Latitude != r2.Latitude {
+ return false
+ }
+ if r1.Altitude != r2.Altitude {
+ return false
+ }
+ return true
+}
+
+func isDuplicateHINFO(r1, r2 *HINFO) bool {
+ if r1.Cpu != r2.Cpu {
+ return false
+ }
+ if r1.Os != r2.Os {
+ return false
+ }
+ return true
+}
+
+func isDuplicateHIP(r1, r2 *HIP) bool {
+ if r1.HitLength != r2.HitLength {
+ return false
+ }
+ if r1.PublicKeyAlgorithm != r2.PublicKeyAlgorithm {
+ return false
+ }
+ if r1.PublicKeyLength != r2.PublicKeyLength {
+ return false
+ }
+ if r1.Hit != r2.Hit {
+ return false
+ }
+ if r1.PublicKey != r2.PublicKey {
+ return false
+ }
+ if len(r1.RendezvousServers) != len(r2.RendezvousServers) {
+ return false
+ }
+ for i := 0; i < len(r1.RendezvousServers); i++ {
+ if !isDulicateName(r1.RendezvousServers[i], r2.RendezvousServers[i]) {
+ return false
+ }
+ }
+ return true
+}
+
+func isDuplicateKX(r1, r2 *KX) bool {
+ if r1.Preference != r2.Preference {
+ return false
+ }
+ if !isDulicateName(r1.Exchanger, r2.Exchanger) {
+ return false
+ }
+ return true
+}
+
+func isDuplicateL32(r1, r2 *L32) bool {
+ if r1.Preference != r2.Preference {
+ return false
+ }
+ if len(r1.Locator32) != len(r2.Locator32) {
+ return false
+ }
+ for i := 0; i < len(r1.Locator32); i++ {
+ if r1.Locator32[i] != r2.Locator32[i] {
+ return false
+ }
+ }
+ return true
+}
+
+func isDuplicateL64(r1, r2 *L64) bool {
+ if r1.Preference != r2.Preference {
+ return false
+ }
+ if r1.Locator64 != r2.Locator64 {
+ return false
+ }
+ return true
+}
+
+func isDuplicateLOC(r1, r2 *LOC) bool {
+ if r1.Version != r2.Version {
+ return false
+ }
+ if r1.Size != r2.Size {
+ return false
+ }
+ if r1.HorizPre != r2.HorizPre {
+ return false
+ }
+ if r1.VertPre != r2.VertPre {
+ return false
+ }
+ if r1.Latitude != r2.Latitude {
+ return false
+ }
+ if r1.Longitude != r2.Longitude {
+ return false
+ }
+ if r1.Altitude != r2.Altitude {
+ return false
+ }
+ return true
+}
+
+func isDuplicateLP(r1, r2 *LP) bool {
+ if r1.Preference != r2.Preference {
+ return false
+ }
+ if !isDulicateName(r1.Fqdn, r2.Fqdn) {
+ return false
+ }
+ return true
+}
+
+func isDuplicateMB(r1, r2 *MB) bool {
+ if !isDulicateName(r1.Mb, r2.Mb) {
+ return false
+ }
+ return true
+}
+
+func isDuplicateMD(r1, r2 *MD) bool {
+ if !isDulicateName(r1.Md, r2.Md) {
+ return false
+ }
+ return true
+}
+
+func isDuplicateMF(r1, r2 *MF) bool {
+ if !isDulicateName(r1.Mf, r2.Mf) {
+ return false
+ }
+ return true
+}
+
+func isDuplicateMG(r1, r2 *MG) bool {
+ if !isDulicateName(r1.Mg, r2.Mg) {
+ return false
+ }
+ return true
+}
+
+func isDuplicateMINFO(r1, r2 *MINFO) bool {
+ if !isDulicateName(r1.Rmail, r2.Rmail) {
+ return false
+ }
+ if !isDulicateName(r1.Email, r2.Email) {
+ return false
+ }
+ return true
+}
+
+func isDuplicateMR(r1, r2 *MR) bool {
+ if !isDulicateName(r1.Mr, r2.Mr) {
+ return false
+ }
+ return true
+}
+
+func isDuplicateMX(r1, r2 *MX) bool {
+ if r1.Preference != r2.Preference {
+ return false
+ }
+ if !isDulicateName(r1.Mx, r2.Mx) {
+ return false
+ }
+ return true
+}
+
+func isDuplicateNAPTR(r1, r2 *NAPTR) bool {
+ if r1.Order != r2.Order {
+ return false
+ }
+ if r1.Preference != r2.Preference {
+ return false
+ }
+ if r1.Flags != r2.Flags {
+ return false
+ }
+ if r1.Service != r2.Service {
+ return false
+ }
+ if r1.Regexp != r2.Regexp {
+ return false
+ }
+ if !isDulicateName(r1.Replacement, r2.Replacement) {
+ return false
+ }
+ return true
+}
+
+func isDuplicateNID(r1, r2 *NID) bool {
+ if r1.Preference != r2.Preference {
+ return false
+ }
+ if r1.NodeID != r2.NodeID {
+ return false
+ }
+ return true
+}
+
+func isDuplicateNIMLOC(r1, r2 *NIMLOC) bool {
+ if r1.Locator != r2.Locator {
+ return false
+ }
+ return true
+}
+
+func isDuplicateNINFO(r1, r2 *NINFO) bool {
+ if len(r1.ZSData) != len(r2.ZSData) {
+ return false
+ }
+ for i := 0; i < len(r1.ZSData); i++ {
+ if r1.ZSData[i] != r2.ZSData[i] {
+ return false
+ }
+ }
+ return true
+}
+
+func isDuplicateNS(r1, r2 *NS) bool {
+ if !isDulicateName(r1.Ns, r2.Ns) {
+ return false
+ }
+ return true
+}
+
+func isDuplicateNSAPPTR(r1, r2 *NSAPPTR) bool {
+ if !isDulicateName(r1.Ptr, r2.Ptr) {
+ return false
+ }
+ return true
+}
+
+func isDuplicateNSEC(r1, r2 *NSEC) bool {
+ if !isDulicateName(r1.NextDomain, r2.NextDomain) {
+ return false
+ }
+ if len(r1.TypeBitMap) != len(r2.TypeBitMap) {
+ return false
+ }
+ for i := 0; i < len(r1.TypeBitMap); i++ {
+ if r1.TypeBitMap[i] != r2.TypeBitMap[i] {
+ return false
+ }
+ }
+ return true
+}
+
+func isDuplicateNSEC3(r1, r2 *NSEC3) bool {
+ if r1.Hash != r2.Hash {
+ return false
+ }
+ if r1.Flags != r2.Flags {
+ return false
+ }
+ if r1.Iterations != r2.Iterations {
+ return false
+ }
+ if r1.SaltLength != r2.SaltLength {
+ return false
+ }
+ if r1.Salt != r2.Salt {
+ return false
+ }
+ if r1.HashLength != r2.HashLength {
+ return false
+ }
+ if r1.NextDomain != r2.NextDomain {
+ return false
+ }
+ if len(r1.TypeBitMap) != len(r2.TypeBitMap) {
+ return false
+ }
+ for i := 0; i < len(r1.TypeBitMap); i++ {
+ if r1.TypeBitMap[i] != r2.TypeBitMap[i] {
+ return false
+ }
+ }
+ return true
+}
+
+func isDuplicateNSEC3PARAM(r1, r2 *NSEC3PARAM) bool {
+ if r1.Hash != r2.Hash {
+ return false
+ }
+ if r1.Flags != r2.Flags {
+ return false
+ }
+ if r1.Iterations != r2.Iterations {
+ return false
+ }
+ if r1.SaltLength != r2.SaltLength {
+ return false
+ }
+ if r1.Salt != r2.Salt {
+ return false
+ }
+ return true
+}
+
+func isDuplicateOPENPGPKEY(r1, r2 *OPENPGPKEY) bool {
+ if r1.PublicKey != r2.PublicKey {
+ return false
+ }
+ return true
+}
+
+func isDuplicatePTR(r1, r2 *PTR) bool {
+ if !isDulicateName(r1.Ptr, r2.Ptr) {
+ return false
+ }
+ return true
+}
+
+func isDuplicatePX(r1, r2 *PX) bool {
+ if r1.Preference != r2.Preference {
+ return false
+ }
+ if !isDulicateName(r1.Map822, r2.Map822) {
+ return false
+ }
+ if !isDulicateName(r1.Mapx400, r2.Mapx400) {
+ return false
+ }
+ return true
+}
+
+func isDuplicateRKEY(r1, r2 *RKEY) bool {
+ if r1.Flags != r2.Flags {
+ return false
+ }
+ if r1.Protocol != r2.Protocol {
+ return false
+ }
+ if r1.Algorithm != r2.Algorithm {
+ return false
+ }
+ if r1.PublicKey != r2.PublicKey {
+ return false
+ }
+ return true
+}
+
+func isDuplicateRP(r1, r2 *RP) bool {
+ if !isDulicateName(r1.Mbox, r2.Mbox) {
+ return false
+ }
+ if !isDulicateName(r1.Txt, r2.Txt) {
+ return false
+ }
+ return true
+}
+
+func isDuplicateRRSIG(r1, r2 *RRSIG) bool {
+ if r1.TypeCovered != r2.TypeCovered {
+ return false
+ }
+ if r1.Algorithm != r2.Algorithm {
+ return false
+ }
+ if r1.Labels != r2.Labels {
+ return false
+ }
+ if r1.OrigTtl != r2.OrigTtl {
+ return false
+ }
+ if r1.Expiration != r2.Expiration {
+ return false
+ }
+ if r1.Inception != r2.Inception {
+ return false
+ }
+ if r1.KeyTag != r2.KeyTag {
+ return false
+ }
+ if !isDulicateName(r1.SignerName, r2.SignerName) {
+ return false
+ }
+ if r1.Signature != r2.Signature {
+ return false
+ }
+ return true
+}
+
+func isDuplicateRT(r1, r2 *RT) bool {
+ if r1.Preference != r2.Preference {
+ return false
+ }
+ if !isDulicateName(r1.Host, r2.Host) {
+ return false
+ }
+ return true
+}
+
+func isDuplicateSMIMEA(r1, r2 *SMIMEA) bool {
+ if r1.Usage != r2.Usage {
+ return false
+ }
+ if r1.Selector != r2.Selector {
+ return false
+ }
+ if r1.MatchingType != r2.MatchingType {
+ return false
+ }
+ if r1.Certificate != r2.Certificate {
+ return false
+ }
+ return true
+}
+
+func isDuplicateSOA(r1, r2 *SOA) bool {
+ if !isDulicateName(r1.Ns, r2.Ns) {
+ return false
+ }
+ if !isDulicateName(r1.Mbox, r2.Mbox) {
+ return false
+ }
+ if r1.Serial != r2.Serial {
+ return false
+ }
+ if r1.Refresh != r2.Refresh {
+ return false
+ }
+ if r1.Retry != r2.Retry {
+ return false
+ }
+ if r1.Expire != r2.Expire {
+ return false
+ }
+ if r1.Minttl != r2.Minttl {
+ return false
+ }
+ return true
+}
+
+func isDuplicateSPF(r1, r2 *SPF) bool {
+ if len(r1.Txt) != len(r2.Txt) {
+ return false
+ }
+ for i := 0; i < len(r1.Txt); i++ {
+ if r1.Txt[i] != r2.Txt[i] {
+ return false
+ }
+ }
+ return true
+}
+
+func isDuplicateSRV(r1, r2 *SRV) bool {
+ if r1.Priority != r2.Priority {
+ return false
+ }
+ if r1.Weight != r2.Weight {
+ return false
+ }
+ if r1.Port != r2.Port {
+ return false
+ }
+ if !isDulicateName(r1.Target, r2.Target) {
+ return false
+ }
+ return true
+}
+
+func isDuplicateSSHFP(r1, r2 *SSHFP) bool {
+ if r1.Algorithm != r2.Algorithm {
+ return false
+ }
+ if r1.Type != r2.Type {
+ return false
+ }
+ if r1.FingerPrint != r2.FingerPrint {
+ return false
+ }
+ return true
+}
+
+func isDuplicateTA(r1, r2 *TA) bool {
+ if r1.KeyTag != r2.KeyTag {
+ return false
+ }
+ if r1.Algorithm != r2.Algorithm {
+ return false
+ }
+ if r1.DigestType != r2.DigestType {
+ return false
+ }
+ if r1.Digest != r2.Digest {
+ return false
+ }
+ return true
+}
+
+func isDuplicateTALINK(r1, r2 *TALINK) bool {
+ if !isDulicateName(r1.PreviousName, r2.PreviousName) {
+ return false
+ }
+ if !isDulicateName(r1.NextName, r2.NextName) {
+ return false
+ }
+ return true
+}
+
+func isDuplicateTKEY(r1, r2 *TKEY) bool {
+ if !isDulicateName(r1.Algorithm, r2.Algorithm) {
+ return false
+ }
+ if r1.Inception != r2.Inception {
+ return false
+ }
+ if r1.Expiration != r2.Expiration {
+ return false
+ }
+ if r1.Mode != r2.Mode {
+ return false
+ }
+ if r1.Error != r2.Error {
+ return false
+ }
+ if r1.KeySize != r2.KeySize {
+ return false
+ }
+ if r1.Key != r2.Key {
+ return false
+ }
+ if r1.OtherLen != r2.OtherLen {
+ return false
+ }
+ if r1.OtherData != r2.OtherData {
+ return false
+ }
+ return true
+}
+
+func isDuplicateTLSA(r1, r2 *TLSA) bool {
+ if r1.Usage != r2.Usage {
+ return false
+ }
+ if r1.Selector != r2.Selector {
+ return false
+ }
+ if r1.MatchingType != r2.MatchingType {
+ return false
+ }
+ if r1.Certificate != r2.Certificate {
+ return false
+ }
+ return true
+}
+
+func isDuplicateTSIG(r1, r2 *TSIG) bool {
+ if !isDulicateName(r1.Algorithm, r2.Algorithm) {
+ return false
+ }
+ if r1.TimeSigned != r2.TimeSigned {
+ return false
+ }
+ if r1.Fudge != r2.Fudge {
+ return false
+ }
+ if r1.MACSize != r2.MACSize {
+ return false
+ }
+ if r1.MAC != r2.MAC {
+ return false
+ }
+ if r1.OrigId != r2.OrigId {
+ return false
+ }
+ if r1.Error != r2.Error {
+ return false
+ }
+ if r1.OtherLen != r2.OtherLen {
+ return false
+ }
+ if r1.OtherData != r2.OtherData {
+ return false
+ }
+ return true
+}
+
+func isDuplicateTXT(r1, r2 *TXT) bool {
+ if len(r1.Txt) != len(r2.Txt) {
+ return false
+ }
+ for i := 0; i < len(r1.Txt); i++ {
+ if r1.Txt[i] != r2.Txt[i] {
+ return false
+ }
+ }
+ return true
+}
+
+func isDuplicateUID(r1, r2 *UID) bool {
+ if r1.Uid != r2.Uid {
+ return false
+ }
+ return true
+}
+
+func isDuplicateUINFO(r1, r2 *UINFO) bool {
+ if r1.Uinfo != r2.Uinfo {
+ return false
+ }
+ return true
+}
+
+func isDuplicateURI(r1, r2 *URI) bool {
+ if r1.Priority != r2.Priority {
+ return false
+ }
+ if r1.Weight != r2.Weight {
+ return false
+ }
+ if r1.Target != r2.Target {
+ return false
+ }
+ return true
+}
+
+func isDuplicateX25(r1, r2 *X25) bool {
+ if r1.PSDNAddress != r2.PSDNAddress {
+ return false
+ }
+ return true
+}
diff --git a/vendor/github.com/miekg/dns/zmsg.go b/vendor/github.com/miekg/dns/zmsg.go
index 0d1f6f4daa..1a68f74da2 100644
--- a/vendor/github.com/miekg/dns/zmsg.go
+++ b/vendor/github.com/miekg/dns/zmsg.go
@@ -42,7 +42,7 @@ func (rr *AFSDB) pack(msg []byte, off int, compression map[string]int, compress
if err != nil {
return off, err
}
- off, err = PackDomainName(rr.Hostname, msg, off, compression, compress)
+ off, err = PackDomainName(rr.Hostname, msg, off, compression, false)
if err != nil {
return off, err
}
diff --git a/vendor/github.com/mohae/deepcopy/.gitignore b/vendor/github.com/mohae/deepcopy/.gitignore
new file mode 100644
index 0000000000..5846dd1531
--- /dev/null
+++ b/vendor/github.com/mohae/deepcopy/.gitignore
@@ -0,0 +1,26 @@
+# 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
+*~
+*.out
+*.log
diff --git a/vendor/github.com/mohae/deepcopy/.travis.yml b/vendor/github.com/mohae/deepcopy/.travis.yml
new file mode 100644
index 0000000000..fd47a8cf78
--- /dev/null
+++ b/vendor/github.com/mohae/deepcopy/.travis.yml
@@ -0,0 +1,11 @@
+language: go
+
+go:
+ - tip
+
+matrix:
+ allow_failures:
+ - go: tip
+
+script:
+ - go test ./...
diff --git a/vendor/github.com/mohae/deepcopy/LICENSE b/vendor/github.com/mohae/deepcopy/LICENSE
new file mode 100644
index 0000000000..419673f005
--- /dev/null
+++ b/vendor/github.com/mohae/deepcopy/LICENSE
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2014 Joel
+
+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/vendor/github.com/mohae/deepcopy/README.md b/vendor/github.com/mohae/deepcopy/README.md
new file mode 100644
index 0000000000..f81841885b
--- /dev/null
+++ b/vendor/github.com/mohae/deepcopy/README.md
@@ -0,0 +1,8 @@
+deepCopy
+========
+[](https://godoc.org/github.com/mohae/deepcopy)[](https://travis-ci.org/mohae/deepcopy)
+
+DeepCopy makes deep copies of things: unexported field values are not copied.
+
+## Usage
+ cpy := deepcopy.Copy(orig)
diff --git a/vendor/github.com/mohae/deepcopy/deepcopy.go b/vendor/github.com/mohae/deepcopy/deepcopy.go
new file mode 100644
index 0000000000..ba763ad091
--- /dev/null
+++ b/vendor/github.com/mohae/deepcopy/deepcopy.go
@@ -0,0 +1,125 @@
+// deepcopy makes deep copies of things. A standard copy will copy the
+// pointers: deep copy copies the values pointed to. Unexported field
+// values are not copied.
+//
+// Copyright (c)2014-2016, Joel Scoble (github.com/mohae), all rights reserved.
+// License: MIT, for more details check the included LICENSE file.
+package deepcopy
+
+import (
+ "reflect"
+ "time"
+)
+
+// Interface for delegating copy process to type
+type Interface interface {
+ DeepCopy() interface{}
+}
+
+// Iface is an alias to Copy; this exists for backwards compatibility reasons.
+func Iface(iface interface{}) interface{} {
+ return Copy(iface)
+}
+
+// Copy creates a deep copy of whatever is passed to it and returns the copy
+// in an interface{}. The returned value will need to be asserted to the
+// correct type.
+func Copy(src interface{}) interface{} {
+ if src == nil {
+ return nil
+ }
+
+ // Make the interface a reflect.Value
+ original := reflect.ValueOf(src)
+
+ // Make a copy of the same type as the original.
+ cpy := reflect.New(original.Type()).Elem()
+
+ // Recursively copy the original.
+ copyRecursive(original, cpy)
+
+ // Return the copy as an interface.
+ return cpy.Interface()
+}
+
+// copyRecursive does the actual copying of the interface. It currently has
+// limited support for what it can handle. Add as needed.
+func copyRecursive(original, cpy reflect.Value) {
+ // check for implement deepcopy.Interface
+ if original.CanInterface() {
+ if copier, ok := original.Interface().(Interface); ok {
+ cpy.Set(reflect.ValueOf(copier.DeepCopy()))
+ return
+ }
+ }
+
+ // handle according to original's Kind
+ switch original.Kind() {
+ case reflect.Ptr:
+ // Get the actual value being pointed to.
+ originalValue := original.Elem()
+
+ // if it isn't valid, return.
+ if !originalValue.IsValid() {
+ return
+ }
+ cpy.Set(reflect.New(originalValue.Type()))
+ copyRecursive(originalValue, cpy.Elem())
+
+ case reflect.Interface:
+ // If this is a nil, don't do anything
+ if original.IsNil() {
+ return
+ }
+ // Get the value for the interface, not the pointer.
+ originalValue := original.Elem()
+
+ // Get the value by calling Elem().
+ copyValue := reflect.New(originalValue.Type()).Elem()
+ copyRecursive(originalValue, copyValue)
+ cpy.Set(copyValue)
+
+ case reflect.Struct:
+ t, ok := original.Interface().(time.Time)
+ if ok {
+ cpy.Set(reflect.ValueOf(t))
+ return
+ }
+ // Go through each field of the struct and copy it.
+ for i := 0; i < original.NumField(); i++ {
+ // The Type's StructField for a given field is checked to see if StructField.PkgPath
+ // is set to determine if the field is exported or not because CanSet() returns false
+ // for settable fields. I'm not sure why. -mohae
+ if original.Type().Field(i).PkgPath != "" {
+ continue
+ }
+ copyRecursive(original.Field(i), cpy.Field(i))
+ }
+
+ case reflect.Slice:
+ if original.IsNil() {
+ return
+ }
+ // Make a new slice and copy each element.
+ cpy.Set(reflect.MakeSlice(original.Type(), original.Len(), original.Cap()))
+ for i := 0; i < original.Len(); i++ {
+ copyRecursive(original.Index(i), cpy.Index(i))
+ }
+
+ case reflect.Map:
+ if original.IsNil() {
+ return
+ }
+ cpy.Set(reflect.MakeMap(original.Type()))
+ for _, key := range original.MapKeys() {
+ originalValue := original.MapIndex(key)
+ copyValue := reflect.New(originalValue.Type()).Elem()
+ copyRecursive(originalValue, copyValue)
+ copyKey := Copy(key.Interface())
+ cpy.SetMapIndex(reflect.ValueOf(copyKey), copyValue)
+ }
+
+ default:
+ cpy.Set(original)
+ }
+}
diff --git a/vendor/github.com/pierrec/lz4/.travis.yml b/vendor/github.com/pierrec/lz4/.travis.yml
index b2c806d577..204afe1d26 100644
--- a/vendor/github.com/pierrec/lz4/.travis.yml
+++ b/vendor/github.com/pierrec/lz4/.travis.yml
@@ -1,9 +1,13 @@
language: go
+env:
+ - GO111MODULE=off
+ - GO111MODULE=on
+
go:
- - 1.8.x
- 1.9.x
- 1.10.x
+ - 1.11.x
- master
matrix:
diff --git a/vendor/github.com/pierrec/lz4/README.md b/vendor/github.com/pierrec/lz4/README.md
index f2f2764c28..e71ebd59d4 100644
--- a/vendor/github.com/pierrec/lz4/README.md
+++ b/vendor/github.com/pierrec/lz4/README.md
@@ -6,14 +6,16 @@ LZ4 compression and decompression in pure Go.
## Usage
```go
-import "github.com/pierrec/lz4"
+import "github.com/pierrec/lz4/v2"
```
## Description
Package lz4 implements reading and writing lz4 compressed data (a frame),
as specified in http://fastcompression.blogspot.fr/2013/04/lz4-streaming-format-final.html.
-Although the block level compression and decompression functions are exposed and are fully compatible
-with the lz4 block format definition, they are low level and should not be used directly.
+
+This package is **compatible with the LZ4 frame format** although the block level compression
+and decompression functions are exposed and are fully compatible with the lz4 block format
+definition, they are low level and should not be used directly.
For a complete description of an lz4 compressed block, see:
http://fastcompression.blogspot.fr/2011/05/lz4-explained.html
diff --git a/vendor/github.com/pierrec/lz4/block.go b/vendor/github.com/pierrec/lz4/block.go
index ef24f17e57..00b1111b92 100644
--- a/vendor/github.com/pierrec/lz4/block.go
+++ b/vendor/github.com/pierrec/lz4/block.go
@@ -286,7 +286,7 @@ func CompressBlockHC(src, dst []byte, depth int) (di int, err error) {
for ml < sn-si && src[next+ml] == src[si+ml] {
ml++
}
- if ml+1 < minMatch || ml <= mLen {
+ if ml < minMatch || ml <= mLen {
// Match too small ( 0 {
// Uncompressed block.
bLen &= compressedBlockMask
- debug("uncompressed block size %d", bLen)
+ if debugFlag {
+ debug("uncompressed block size %d", bLen)
+ }
if int(bLen) > cap(z.data) {
return 0, fmt.Errorf("lz4: invalid block size: %d", bLen)
}
@@ -207,7 +223,9 @@ func (z *Reader) Read(buf []byte) (int, error) {
} else {
// Compressed block.
- debug("compressed block size %d", bLen)
+ if debugFlag {
+ debug("compressed block size %d", bLen)
+ }
if int(bLen) > cap(z.data) {
return 0, fmt.Errorf("lz4: invalid block size: %d", bLen)
}
@@ -238,14 +256,18 @@ func (z *Reader) Read(buf []byte) (int, error) {
if !z.NoChecksum {
z.checksum.Write(z.data)
- debug("current frame checksum %x", z.checksum.Sum32())
+ if debugFlag {
+ debug("current frame checksum %x", z.checksum.Sum32())
+ }
}
z.idx = 0
}
n := copy(buf, z.data[z.idx:])
z.idx += n
- debug("copied %d bytes to input", n)
+ if debugFlag {
+ debug("copied %d bytes to input", n)
+ }
return n, nil
}
diff --git a/vendor/github.com/pierrec/lz4/writer.go b/vendor/github.com/pierrec/lz4/writer.go
index 62a561703c..0120438025 100644
--- a/vendor/github.com/pierrec/lz4/writer.go
+++ b/vendor/github.com/pierrec/lz4/writer.go
@@ -86,7 +86,9 @@ func (z *Writer) writeHeader() error {
return err
}
z.Header.done = true
- debug("wrote header %v", z.Header)
+ if debugFlag {
+ debug("wrote header %v", z.Header)
+ }
return nil
}
@@ -99,24 +101,36 @@ func (z *Writer) Write(buf []byte) (int, error) {
return 0, err
}
}
-
- if !z.NoChecksum {
- z.checksum.Write(buf)
+ if debugFlag {
+ debug("input buffer len=%d index=%d", len(buf), z.idx)
}
- debug("input buffer len=%d index=%d", len(buf), z.idx)
+ zn := len(z.data)
var n int
for len(buf) > 0 {
+ if z.idx == 0 && len(buf) >= zn {
+ // Avoid a copy as there is enough data for a block.
+ if err := z.compressBlock(buf[:zn]); err != nil {
+ return n, err
+ }
+ n += zn
+ buf = buf[zn:]
+ continue
+ }
// Accumulate the data to be compressed.
m := copy(z.data[z.idx:], buf)
n += m
z.idx += m
buf = buf[m:]
- debug("%d bytes copied to buf, current index %d", n, z.idx)
+ if debugFlag {
+ debug("%d bytes copied to buf, current index %d", n, z.idx)
+ }
if z.idx < len(z.data) {
// Buffer not filled.
- debug("need more data for compression")
+ if debugFlag {
+ debug("need more data for compression")
+ }
return n, nil
}
@@ -132,6 +146,10 @@ func (z *Writer) Write(buf []byte) (int, error) {
// compressBlock compresses a block.
func (z *Writer) compressBlock(data []byte) error {
+ if !z.NoChecksum {
+ z.checksum.Write(data)
+ }
+
// The compressed block size cannot exceed the input's.
var zn int
var err error
@@ -144,7 +162,9 @@ func (z *Writer) compressBlock(data []byte) error {
var zdata []byte
var bLen uint32
- debug("block compression %d => %d", len(data), zn)
+ if debugFlag {
+ debug("block compression %d => %d", len(data), zn)
+ }
if err == nil && zn > 0 && zn < len(data) {
// Compressible and compressed size smaller than uncompressed: ok!
bLen = uint32(zn)
@@ -154,7 +174,9 @@ func (z *Writer) compressBlock(data []byte) error {
bLen = uint32(len(data)) | compressedBlockFlag
zdata = data
}
- debug("block compression to be written len=%d data len=%d", bLen, len(zdata))
+ if debugFlag {
+ debug("block compression to be written len=%d data len=%d", bLen, len(zdata))
+ }
// Write the block.
if err := z.writeUint32(bLen); err != nil {
@@ -166,12 +188,16 @@ func (z *Writer) compressBlock(data []byte) error {
if z.BlockChecksum {
checksum := xxh32.ChecksumZero(zdata)
- debug("block checksum %x", checksum)
+ if debugFlag {
+ debug("block checksum %x", checksum)
+ }
if err := z.writeUint32(checksum); err != nil {
return err
}
}
- debug("current frame checksum %x", z.checksum.Sum32())
+ if debugFlag {
+ debug("current frame checksum %x", z.checksum.Sum32())
+ }
return nil
}
@@ -180,7 +206,9 @@ func (z *Writer) compressBlock(data []byte) error {
// Flush does not return until the data has been written.
// If the underlying writer returns an error, Flush returns that error.
func (z *Writer) Flush() error {
- debug("flush with index %d", z.idx)
+ if debugFlag {
+ debug("flush with index %d", z.idx)
+ }
if z.idx == 0 {
return nil
}
@@ -200,13 +228,17 @@ func (z *Writer) Close() error {
return err
}
- debug("writing last empty block")
+ if debugFlag {
+ debug("writing last empty block")
+ }
if err := z.writeUint32(0); err != nil {
return err
}
if !z.NoChecksum {
checksum := z.checksum.Sum32()
- debug("stream checksum %x", checksum)
+ if debugFlag {
+ debug("stream checksum %x", checksum)
+ }
if err := z.writeUint32(checksum); err != nil {
return err
}
diff --git a/vendor/github.com/prometheus/common/expfmt/text_parse.go b/vendor/github.com/prometheus/common/expfmt/text_parse.go
index b86290afa3..ec3d86ba7c 100644
--- a/vendor/github.com/prometheus/common/expfmt/text_parse.go
+++ b/vendor/github.com/prometheus/common/expfmt/text_parse.go
@@ -359,7 +359,7 @@ func (p *TextParser) startLabelValue() stateFn {
}
return p.readingValue
default:
- p.parseError(fmt.Sprintf("unexpected end of label value %q", p.currentLabelPair.Value))
+ p.parseError(fmt.Sprintf("unexpected end of label value %q", p.currentLabelPair.GetValue()))
return nil
}
}
diff --git a/vendor/github.com/prometheus/procfs/.travis.yml b/vendor/github.com/prometheus/procfs/.travis.yml
deleted file mode 100644
index 66a0b7cf79..0000000000
--- a/vendor/github.com/prometheus/procfs/.travis.yml
+++ /dev/null
@@ -1,12 +0,0 @@
-sudo: false
-
-language: go
-
-go:
-- 1.9.x
-- 1.10.x
-
-go_import_path: github.com/prometheus/procfs
-
-script:
-- make style check_license vet test staticcheck
diff --git a/vendor/github.com/prometheus/procfs/fixtures.ttar b/vendor/github.com/prometheus/procfs/fixtures.ttar
index 3ee8291e81..13c831ef59 100644
--- a/vendor/github.com/prometheus/procfs/fixtures.ttar
+++ b/vendor/github.com/prometheus/procfs/fixtures.ttar
@@ -15,6 +15,9 @@ Lines: 1
vim
Mode: 644
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+Path: fixtures/26231/cwd
+SymlinkTo: /usr/bin
+# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Path: fixtures/26231/exe
SymlinkTo: /usr/bin/vim
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@@ -111,6 +114,9 @@ SymlinkTo: mnt:[4026531840]
Path: fixtures/26231/ns/net
SymlinkTo: net:[4026531993]
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+Path: fixtures/26231/root
+SymlinkTo: /
+# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Path: fixtures/26231/stat
Lines: 1
26231 (vim) R 5392 7446 5392 34835 7446 4218880 32533 309516 26 82 1677 44 158 99 20 0 1 0 82375 56274944 1981 18446744073709551615 4194304 6294284 140736914091744 140736914087944 139965136429984 0 0 12288 1870679807 0 0 0 17 0 0 0 31 0 0 8391624 8481048 16420864 140736914093252 140736914093279 140736914093279 140736914096107 0
@@ -128,6 +134,9 @@ Lines: 1
ata_sff
Mode: 644
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+Path: fixtures/26232/cwd
+SymlinkTo: /does/not/exist
+# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Directory: fixtures/26232/fd
Mode: 755
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@@ -167,6 +176,9 @@ Max realtime priority 0 0
Max realtime timeout unlimited unlimited us
Mode: 644
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+Path: fixtures/26232/root
+SymlinkTo: /does/not/exist
+# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Path: fixtures/26232/stat
Lines: 1
33 (ata_sff) S 2 0 0 0 -1 69238880 0 0 0 0 0 0 0 0 0 -20 1 0 5 0 0 18446744073709551615 0 0 0 0 0 0 0 2147483647 0 18446744073709551615 0 0 17 1 0 0 0 0 0 0 0 0 0 0 0 0 0
@@ -444,3 +456,7 @@ Path: fixtures/symlinktargets/xyz
Lines: 0
Mode: 644
# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+Path: fixtures/.unpacked
+Lines: 0
+Mode: 664
+# ttar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/vendor/github.com/prometheus/procfs/internal/util/parse.go b/vendor/github.com/prometheus/procfs/internal/util/parse.go
index 1ad21c91a3..2ff228e9d1 100644
--- a/vendor/github.com/prometheus/procfs/internal/util/parse.go
+++ b/vendor/github.com/prometheus/procfs/internal/util/parse.go
@@ -13,7 +13,11 @@
package util
-import "strconv"
+import (
+ "io/ioutil"
+ "strconv"
+ "strings"
+)
// ParseUint32s parses a slice of strings into a slice of uint32s.
func ParseUint32s(ss []string) ([]uint32, error) {
@@ -44,3 +48,12 @@ func ParseUint64s(ss []string) ([]uint64, error) {
return us, nil
}
+
+// ReadUintFromFile reads a file and attempts to parse a uint64 from it.
+func ReadUintFromFile(path string) (uint64, error) {
+ data, err := ioutil.ReadFile(path)
+ if err != nil {
+ return 0, err
+ }
+ return strconv.ParseUint(strings.TrimSpace(string(data)), 10, 64)
+}
diff --git a/vendor/github.com/prometheus/procfs/internal/util/sysreadfile_linux.go b/vendor/github.com/prometheus/procfs/internal/util/sysreadfile_linux.go
new file mode 100644
index 0000000000..df0d567b78
--- /dev/null
+++ b/vendor/github.com/prometheus/procfs/internal/util/sysreadfile_linux.go
@@ -0,0 +1,45 @@
+// Copyright 2018 The Prometheus Authors
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// +build !windows
+
+package util
+
+import (
+ "bytes"
+ "os"
+ "syscall"
+)
+
+// SysReadFile is a simplified ioutil.ReadFile that invokes syscall.Read directly.
+// https://github.com/prometheus/node_exporter/pull/728/files
+func SysReadFile(file string) (string, error) {
+ f, err := os.Open(file)
+ if err != nil {
+ return "", err
+ }
+ defer f.Close()
+
+ // On some machines, hwmon drivers are broken and return EAGAIN. This causes
+ // Go's ioutil.ReadFile implementation to poll forever.
+ //
+ // Since we either want to read data or bail immediately, do the simplest
+ // possible read using syscall directly.
+ b := make([]byte, 128)
+ n, err := syscall.Read(int(f.Fd()), b)
+ if err != nil {
+ return "", err
+ }
+
+ return string(bytes.TrimSpace(b[:n])), nil
+}
diff --git a/vendor/github.com/prometheus/procfs/proc.go b/vendor/github.com/prometheus/procfs/proc.go
index 7cf5b8acf9..06bed0ef4a 100644
--- a/vendor/github.com/prometheus/procfs/proc.go
+++ b/vendor/github.com/prometheus/procfs/proc.go
@@ -156,6 +156,26 @@ func (p Proc) Executable() (string, error) {
return exe, err
}
+// Cwd returns the absolute path to the current working directory of the process.
+func (p Proc) Cwd() (string, error) {
+ wd, err := os.Readlink(p.path("cwd"))
+ if os.IsNotExist(err) {
+ return "", nil
+ }
+
+ return wd, err
+}
+
+// RootDir returns the absolute path to the process's root directory (as set by chroot)
+func (p Proc) RootDir() (string, error) {
+ rdir, err := os.Readlink(p.path("root"))
+ if os.IsNotExist(err) {
+ return "", nil
+ }
+
+ return rdir, err
+}
+
// FileDescriptors returns the currently open file descriptors of a process.
func (p Proc) FileDescriptors() ([]uintptr, error) {
names, err := p.fileDescriptors()
diff --git a/vendor/github.com/sirupsen/logrus/.travis.yml b/vendor/github.com/sirupsen/logrus/.travis.yml
index 2f19b4a757..1f953bebdc 100644
--- a/vendor/github.com/sirupsen/logrus/.travis.yml
+++ b/vendor/github.com/sirupsen/logrus/.travis.yml
@@ -1,13 +1,51 @@
language: go
-go:
- - 1.9.x
- - 1.10.x
env:
- GOMAXPROCS=4 GORACE=halt_on_error=1
-install:
- - go get github.com/stretchr/testify/assert
- - go get gopkg.in/gemnasium/logrus-airbrake-hook.v2
- - go get golang.org/x/sys/unix
- - go get golang.org/x/sys/windows
-script:
- - go test -race -v ./...
+matrix:
+ include:
+ - go: 1.10.x
+ install:
+ - go get github.com/stretchr/testify/assert
+ - go get golang.org/x/crypto/ssh/terminal
+ - go get golang.org/x/sys/unix
+ - go get golang.org/x/sys/windows
+ script:
+ - go test -race -v ./...
+ - go: 1.11.x
+ env: GO111MODULE=on
+ install:
+ - go mod download
+ script:
+ - go test -race -v ./...
+ - go: 1.11.x
+ env: GO111MODULE=off
+ install:
+ - go get github.com/stretchr/testify/assert
+ - go get golang.org/x/crypto/ssh/terminal
+ - go get golang.org/x/sys/unix
+ - go get golang.org/x/sys/windows
+ script:
+ - go test -race -v ./...
+ - go: 1.10.x
+ install:
+ - go get github.com/stretchr/testify/assert
+ - go get golang.org/x/crypto/ssh/terminal
+ - go get golang.org/x/sys/unix
+ - go get golang.org/x/sys/windows
+ script:
+ - go test -race -v -tags appengine ./...
+ - go: 1.11.x
+ env: GO111MODULE=on
+ install:
+ - go mod download
+ script:
+ - go test -race -v -tags appengine ./...
+ - go: 1.11.x
+ env: GO111MODULE=off
+ install:
+ - go get github.com/stretchr/testify/assert
+ - go get golang.org/x/crypto/ssh/terminal
+ - go get golang.org/x/sys/unix
+ - go get golang.org/x/sys/windows
+ script:
+ - go test -race -v -tags appengine ./...
diff --git a/vendor/github.com/sirupsen/logrus/CHANGELOG.md b/vendor/github.com/sirupsen/logrus/CHANGELOG.md
index 1bd1deb294..ff04718690 100644
--- a/vendor/github.com/sirupsen/logrus/CHANGELOG.md
+++ b/vendor/github.com/sirupsen/logrus/CHANGELOG.md
@@ -1,3 +1,38 @@
+# 1.1.1
+This is a bug fix release.
+ * fix the build break on Solaris
+ * don't drop a whole trace in JSONFormatter when a field param is a function pointer which can not be serialized
+
+# 1.1.0
+This new release introduces:
+ * several fixes:
+ * a fix for a race condition on entry formatting
+ * proper cleanup of previously used entries before putting them back in the pool
+ * the extra new line at the end of message in text formatter has been removed
+ * a new global public API to check if a level is activated: IsLevelEnabled
+ * the following methods have been added to the Logger object
+ * IsLevelEnabled
+ * SetFormatter
+ * SetOutput
+ * ReplaceHooks
+ * introduction of go module
+ * an indent configuration for the json formatter
+ * output colour support for windows
+ * the field sort function is now configurable for text formatter
+ * the CLICOLOR and CLICOLOR\_FORCE environment variable support in text formater
+
+# 1.0.6
+
+This new release introduces:
+ * a new api WithTime which allows to easily force the time of the log entry
+ which is mostly useful for logger wrapper
+ * a fix reverting the immutability of the entry given as parameter to the hooks
+ a new configuration field of the json formatter in order to put all the fields
+ in a nested dictionnary
+ * a new SetOutput method in the Logger
+ * a new configuration of the textformatter to configure the name of the default keys
+ * a new configuration of the text formatter to disable the level truncation
+
# 1.0.5
* Fix hooks race (#707)
diff --git a/vendor/github.com/sirupsen/logrus/entry.go b/vendor/github.com/sirupsen/logrus/entry.go
index 473bd1a0d3..ca634a6097 100644
--- a/vendor/github.com/sirupsen/logrus/entry.go
+++ b/vendor/github.com/sirupsen/logrus/entry.go
@@ -4,6 +4,7 @@ import (
"bytes"
"fmt"
"os"
+ "reflect"
"sync"
"time"
)
@@ -41,8 +42,11 @@ type Entry struct {
// Message passed to Debug, Info, Warn, Error, Fatal or Panic
Message string
- // When formatter is called in entry.log(), an Buffer may be set to entry
+ // When formatter is called in entry.log(), a Buffer may be set to entry
Buffer *bytes.Buffer
+
+ // err may contain a field formatting error
+ err string
}
func NewEntry(logger *Logger) *Entry {
@@ -80,10 +84,18 @@ func (entry *Entry) WithFields(fields Fields) *Entry {
for k, v := range entry.Data {
data[k] = v
}
+ var field_err string
for k, v := range fields {
- data[k] = v
+ if t := reflect.TypeOf(v); t != nil && t.Kind() == reflect.Func {
+ field_err = fmt.Sprintf("can not add field %q", k)
+ if entry.err != "" {
+ field_err = entry.err + ", " + field_err
+ }
+ } else {
+ data[k] = v
+ }
}
- return &Entry{Logger: entry.Logger, Data: data, Time: entry.Time}
+ return &Entry{Logger: entry.Logger, Data: data, Time: entry.Time, err: field_err}
}
// Overrides the time of the Entry.
@@ -137,9 +149,9 @@ func (entry *Entry) fireHooks() {
}
func (entry *Entry) write() {
- serialized, err := entry.Logger.Formatter.Format(entry)
entry.Logger.mu.Lock()
defer entry.Logger.mu.Unlock()
+ serialized, err := entry.Logger.Formatter.Format(entry)
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to obtain reader, %v\n", err)
} else {
@@ -151,7 +163,7 @@ func (entry *Entry) write() {
}
func (entry *Entry) Debug(args ...interface{}) {
- if entry.Logger.level() >= DebugLevel {
+ if entry.Logger.IsLevelEnabled(DebugLevel) {
entry.log(DebugLevel, fmt.Sprint(args...))
}
}
@@ -161,13 +173,13 @@ func (entry *Entry) Print(args ...interface{}) {
}
func (entry *Entry) Info(args ...interface{}) {
- if entry.Logger.level() >= InfoLevel {
+ if entry.Logger.IsLevelEnabled(InfoLevel) {
entry.log(InfoLevel, fmt.Sprint(args...))
}
}
func (entry *Entry) Warn(args ...interface{}) {
- if entry.Logger.level() >= WarnLevel {
+ if entry.Logger.IsLevelEnabled(WarnLevel) {
entry.log(WarnLevel, fmt.Sprint(args...))
}
}
@@ -177,20 +189,20 @@ func (entry *Entry) Warning(args ...interface{}) {
}
func (entry *Entry) Error(args ...interface{}) {
- if entry.Logger.level() >= ErrorLevel {
+ if entry.Logger.IsLevelEnabled(ErrorLevel) {
entry.log(ErrorLevel, fmt.Sprint(args...))
}
}
func (entry *Entry) Fatal(args ...interface{}) {
- if entry.Logger.level() >= FatalLevel {
+ if entry.Logger.IsLevelEnabled(FatalLevel) {
entry.log(FatalLevel, fmt.Sprint(args...))
}
Exit(1)
}
func (entry *Entry) Panic(args ...interface{}) {
- if entry.Logger.level() >= PanicLevel {
+ if entry.Logger.IsLevelEnabled(PanicLevel) {
entry.log(PanicLevel, fmt.Sprint(args...))
}
panic(fmt.Sprint(args...))
@@ -199,13 +211,13 @@ func (entry *Entry) Panic(args ...interface{}) {
// Entry Printf family functions
func (entry *Entry) Debugf(format string, args ...interface{}) {
- if entry.Logger.level() >= DebugLevel {
+ if entry.Logger.IsLevelEnabled(DebugLevel) {
entry.Debug(fmt.Sprintf(format, args...))
}
}
func (entry *Entry) Infof(format string, args ...interface{}) {
- if entry.Logger.level() >= InfoLevel {
+ if entry.Logger.IsLevelEnabled(InfoLevel) {
entry.Info(fmt.Sprintf(format, args...))
}
}
@@ -215,7 +227,7 @@ func (entry *Entry) Printf(format string, args ...interface{}) {
}
func (entry *Entry) Warnf(format string, args ...interface{}) {
- if entry.Logger.level() >= WarnLevel {
+ if entry.Logger.IsLevelEnabled(WarnLevel) {
entry.Warn(fmt.Sprintf(format, args...))
}
}
@@ -225,20 +237,20 @@ func (entry *Entry) Warningf(format string, args ...interface{}) {
}
func (entry *Entry) Errorf(format string, args ...interface{}) {
- if entry.Logger.level() >= ErrorLevel {
+ if entry.Logger.IsLevelEnabled(ErrorLevel) {
entry.Error(fmt.Sprintf(format, args...))
}
}
func (entry *Entry) Fatalf(format string, args ...interface{}) {
- if entry.Logger.level() >= FatalLevel {
+ if entry.Logger.IsLevelEnabled(FatalLevel) {
entry.Fatal(fmt.Sprintf(format, args...))
}
Exit(1)
}
func (entry *Entry) Panicf(format string, args ...interface{}) {
- if entry.Logger.level() >= PanicLevel {
+ if entry.Logger.IsLevelEnabled(PanicLevel) {
entry.Panic(fmt.Sprintf(format, args...))
}
}
@@ -246,13 +258,13 @@ func (entry *Entry) Panicf(format string, args ...interface{}) {
// Entry Println family functions
func (entry *Entry) Debugln(args ...interface{}) {
- if entry.Logger.level() >= DebugLevel {
+ if entry.Logger.IsLevelEnabled(DebugLevel) {
entry.Debug(entry.sprintlnn(args...))
}
}
func (entry *Entry) Infoln(args ...interface{}) {
- if entry.Logger.level() >= InfoLevel {
+ if entry.Logger.IsLevelEnabled(InfoLevel) {
entry.Info(entry.sprintlnn(args...))
}
}
@@ -262,7 +274,7 @@ func (entry *Entry) Println(args ...interface{}) {
}
func (entry *Entry) Warnln(args ...interface{}) {
- if entry.Logger.level() >= WarnLevel {
+ if entry.Logger.IsLevelEnabled(WarnLevel) {
entry.Warn(entry.sprintlnn(args...))
}
}
@@ -272,20 +284,20 @@ func (entry *Entry) Warningln(args ...interface{}) {
}
func (entry *Entry) Errorln(args ...interface{}) {
- if entry.Logger.level() >= ErrorLevel {
+ if entry.Logger.IsLevelEnabled(ErrorLevel) {
entry.Error(entry.sprintlnn(args...))
}
}
func (entry *Entry) Fatalln(args ...interface{}) {
- if entry.Logger.level() >= FatalLevel {
+ if entry.Logger.IsLevelEnabled(FatalLevel) {
entry.Fatal(entry.sprintlnn(args...))
}
Exit(1)
}
func (entry *Entry) Panicln(args ...interface{}) {
- if entry.Logger.level() >= PanicLevel {
+ if entry.Logger.IsLevelEnabled(PanicLevel) {
entry.Panic(entry.sprintlnn(args...))
}
}
diff --git a/vendor/github.com/sirupsen/logrus/exported.go b/vendor/github.com/sirupsen/logrus/exported.go
index eb612a6f3e..fb2a7a1f07 100644
--- a/vendor/github.com/sirupsen/logrus/exported.go
+++ b/vendor/github.com/sirupsen/logrus/exported.go
@@ -21,30 +21,27 @@ func SetOutput(out io.Writer) {
// SetFormatter sets the standard logger formatter.
func SetFormatter(formatter Formatter) {
- std.mu.Lock()
- defer std.mu.Unlock()
- std.Formatter = formatter
+ std.SetFormatter(formatter)
}
// SetLevel sets the standard logger level.
func SetLevel(level Level) {
- std.mu.Lock()
- defer std.mu.Unlock()
std.SetLevel(level)
}
// GetLevel returns the standard logger level.
func GetLevel() Level {
- std.mu.Lock()
- defer std.mu.Unlock()
- return std.level()
+ return std.GetLevel()
+}
+
+// IsLevelEnabled checks if the log level of the standard logger is greater than the level param
+func IsLevelEnabled(level Level) bool {
+ return std.IsLevelEnabled(level)
}
// AddHook adds a hook to the standard logger hooks.
func AddHook(hook Hook) {
- std.mu.Lock()
- defer std.mu.Unlock()
- std.Hooks.Add(hook)
+ std.AddHook(hook)
}
// WithError creates an entry from the standard logger and adds an error to it, using the value defined in ErrorKey as key.
diff --git a/vendor/github.com/sirupsen/logrus/formatter.go b/vendor/github.com/sirupsen/logrus/formatter.go
index 83c74947be..be2f3fcee8 100644
--- a/vendor/github.com/sirupsen/logrus/formatter.go
+++ b/vendor/github.com/sirupsen/logrus/formatter.go
@@ -2,7 +2,14 @@ package logrus
import "time"
-const defaultTimestampFormat = time.RFC3339
+// Default key names for the default fields
+const (
+ defaultTimestampFormat = time.RFC3339
+ FieldKeyMsg = "msg"
+ FieldKeyLevel = "level"
+ FieldKeyTime = "time"
+ FieldKeyLogrusError = "logrus_error"
+)
// The Formatter interface is used to implement a custom Formatter. It takes an
// `Entry`. It exposes all the fields, including the default ones:
@@ -48,4 +55,10 @@ func prefixFieldClashes(data Fields, fieldMap FieldMap) {
data["fields."+levelKey] = l
delete(data, levelKey)
}
+
+ logrusErrKey := fieldMap.resolve(FieldKeyLogrusError)
+ if l, ok := data[logrusErrKey]; ok {
+ data["fields."+logrusErrKey] = l
+ delete(data, logrusErrKey)
+ }
}
diff --git a/vendor/github.com/sirupsen/logrus/go.mod b/vendor/github.com/sirupsen/logrus/go.mod
new file mode 100644
index 0000000000..f4fed02fb8
--- /dev/null
+++ b/vendor/github.com/sirupsen/logrus/go.mod
@@ -0,0 +1,10 @@
+module github.com/sirupsen/logrus
+
+require (
+ github.com/davecgh/go-spew v1.1.1 // indirect
+ github.com/konsorten/go-windows-terminal-sequences v0.0.0-20180402223658-b729f2633dfe
+ github.com/pmezard/go-difflib v1.0.0 // indirect
+ github.com/stretchr/testify v1.2.2
+ golang.org/x/crypto v0.0.0-20180904163835-0709b304e793
+ golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33
+)
diff --git a/vendor/github.com/sirupsen/logrus/go.sum b/vendor/github.com/sirupsen/logrus/go.sum
new file mode 100644
index 0000000000..1f0d71964c
--- /dev/null
+++ b/vendor/github.com/sirupsen/logrus/go.sum
@@ -0,0 +1,12 @@
+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/konsorten/go-windows-terminal-sequences v0.0.0-20180402223658-b729f2633dfe h1:CHRGQ8V7OlCYtwaKPJi3iA7J+YdNKdo8j7nG5IgDhjs=
+github.com/konsorten/go-windows-terminal-sequences v0.0.0-20180402223658-b729f2633dfe/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
+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/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
+github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
+golang.org/x/crypto v0.0.0-20180904163835-0709b304e793 h1:u+LnwYTOOW7Ukr/fppxEb1Nwz0AtPflrblfvUudpo+I=
+golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
+golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33 h1:I6FyU15t786LL7oL/hn43zqTuEGr4PN7F4XJ1p4E3Y8=
+golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
diff --git a/vendor/github.com/sirupsen/logrus/json_formatter.go b/vendor/github.com/sirupsen/logrus/json_formatter.go
index dab17610f1..ef8d074608 100644
--- a/vendor/github.com/sirupsen/logrus/json_formatter.go
+++ b/vendor/github.com/sirupsen/logrus/json_formatter.go
@@ -1,6 +1,7 @@
package logrus
import (
+ "bytes"
"encoding/json"
"fmt"
)
@@ -10,13 +11,6 @@ type fieldKey string
// FieldMap allows customization of the key names for default fields.
type FieldMap map[fieldKey]string
-// Default key names for the default fields
-const (
- FieldKeyMsg = "msg"
- FieldKeyLevel = "level"
- FieldKeyTime = "time"
-)
-
func (f FieldMap) resolve(key fieldKey) string {
if k, ok := f[key]; ok {
return k
@@ -46,6 +40,9 @@ type JSONFormatter struct {
// },
// }
FieldMap FieldMap
+
+ // PrettyPrint will indent all json logs
+ PrettyPrint bool
}
// Format renders a single log entry
@@ -75,15 +72,29 @@ func (f *JSONFormatter) Format(entry *Entry) ([]byte, error) {
timestampFormat = defaultTimestampFormat
}
+ if entry.err != "" {
+ data[f.FieldMap.resolve(FieldKeyLogrusError)] = entry.err
+ }
if !f.DisableTimestamp {
data[f.FieldMap.resolve(FieldKeyTime)] = entry.Time.Format(timestampFormat)
}
data[f.FieldMap.resolve(FieldKeyMsg)] = entry.Message
data[f.FieldMap.resolve(FieldKeyLevel)] = entry.Level.String()
- serialized, err := json.Marshal(data)
- if err != nil {
+ var b *bytes.Buffer
+ if entry.Buffer != nil {
+ b = entry.Buffer
+ } else {
+ b = &bytes.Buffer{}
+ }
+
+ encoder := json.NewEncoder(b)
+ if f.PrettyPrint {
+ encoder.SetIndent("", " ")
+ }
+ if err := encoder.Encode(data); err != nil {
return nil, fmt.Errorf("Failed to marshal fields to JSON, %v", err)
}
- return append(serialized, '\n'), nil
+
+ return b.Bytes(), nil
}
diff --git a/vendor/github.com/sirupsen/logrus/logger.go b/vendor/github.com/sirupsen/logrus/logger.go
index 342f7977d8..b67bfcbd3c 100644
--- a/vendor/github.com/sirupsen/logrus/logger.go
+++ b/vendor/github.com/sirupsen/logrus/logger.go
@@ -11,7 +11,7 @@ import (
type Logger struct {
// The logs are `io.Copy`'d to this in a mutex. It's common to set this to a
// file, or leave it default which is `os.Stderr`. You can also set this to
- // something more adventorous, such as logging to Kafka.
+ // something more adventurous, such as logging to Kafka.
Out io.Writer
// Hooks for the logger instance. These allow firing events based on logging
// levels and log entries. For example, to send errors to an error tracking
@@ -85,6 +85,7 @@ func (logger *Logger) newEntry() *Entry {
}
func (logger *Logger) releaseEntry(entry *Entry) {
+ entry.Data = map[string]interface{}{}
logger.entryPool.Put(entry)
}
@@ -121,7 +122,7 @@ func (logger *Logger) WithTime(t time.Time) *Entry {
}
func (logger *Logger) Debugf(format string, args ...interface{}) {
- if logger.level() >= DebugLevel {
+ if logger.IsLevelEnabled(DebugLevel) {
entry := logger.newEntry()
entry.Debugf(format, args...)
logger.releaseEntry(entry)
@@ -129,7 +130,7 @@ func (logger *Logger) Debugf(format string, args ...interface{}) {
}
func (logger *Logger) Infof(format string, args ...interface{}) {
- if logger.level() >= InfoLevel {
+ if logger.IsLevelEnabled(InfoLevel) {
entry := logger.newEntry()
entry.Infof(format, args...)
logger.releaseEntry(entry)
@@ -143,7 +144,7 @@ func (logger *Logger) Printf(format string, args ...interface{}) {
}
func (logger *Logger) Warnf(format string, args ...interface{}) {
- if logger.level() >= WarnLevel {
+ if logger.IsLevelEnabled(WarnLevel) {
entry := logger.newEntry()
entry.Warnf(format, args...)
logger.releaseEntry(entry)
@@ -151,7 +152,7 @@ func (logger *Logger) Warnf(format string, args ...interface{}) {
}
func (logger *Logger) Warningf(format string, args ...interface{}) {
- if logger.level() >= WarnLevel {
+ if logger.IsLevelEnabled(WarnLevel) {
entry := logger.newEntry()
entry.Warnf(format, args...)
logger.releaseEntry(entry)
@@ -159,7 +160,7 @@ func (logger *Logger) Warningf(format string, args ...interface{}) {
}
func (logger *Logger) Errorf(format string, args ...interface{}) {
- if logger.level() >= ErrorLevel {
+ if logger.IsLevelEnabled(ErrorLevel) {
entry := logger.newEntry()
entry.Errorf(format, args...)
logger.releaseEntry(entry)
@@ -167,7 +168,7 @@ func (logger *Logger) Errorf(format string, args ...interface{}) {
}
func (logger *Logger) Fatalf(format string, args ...interface{}) {
- if logger.level() >= FatalLevel {
+ if logger.IsLevelEnabled(FatalLevel) {
entry := logger.newEntry()
entry.Fatalf(format, args...)
logger.releaseEntry(entry)
@@ -176,7 +177,7 @@ func (logger *Logger) Fatalf(format string, args ...interface{}) {
}
func (logger *Logger) Panicf(format string, args ...interface{}) {
- if logger.level() >= PanicLevel {
+ if logger.IsLevelEnabled(PanicLevel) {
entry := logger.newEntry()
entry.Panicf(format, args...)
logger.releaseEntry(entry)
@@ -184,7 +185,7 @@ func (logger *Logger) Panicf(format string, args ...interface{}) {
}
func (logger *Logger) Debug(args ...interface{}) {
- if logger.level() >= DebugLevel {
+ if logger.IsLevelEnabled(DebugLevel) {
entry := logger.newEntry()
entry.Debug(args...)
logger.releaseEntry(entry)
@@ -192,7 +193,7 @@ func (logger *Logger) Debug(args ...interface{}) {
}
func (logger *Logger) Info(args ...interface{}) {
- if logger.level() >= InfoLevel {
+ if logger.IsLevelEnabled(InfoLevel) {
entry := logger.newEntry()
entry.Info(args...)
logger.releaseEntry(entry)
@@ -206,7 +207,7 @@ func (logger *Logger) Print(args ...interface{}) {
}
func (logger *Logger) Warn(args ...interface{}) {
- if logger.level() >= WarnLevel {
+ if logger.IsLevelEnabled(WarnLevel) {
entry := logger.newEntry()
entry.Warn(args...)
logger.releaseEntry(entry)
@@ -214,7 +215,7 @@ func (logger *Logger) Warn(args ...interface{}) {
}
func (logger *Logger) Warning(args ...interface{}) {
- if logger.level() >= WarnLevel {
+ if logger.IsLevelEnabled(WarnLevel) {
entry := logger.newEntry()
entry.Warn(args...)
logger.releaseEntry(entry)
@@ -222,7 +223,7 @@ func (logger *Logger) Warning(args ...interface{}) {
}
func (logger *Logger) Error(args ...interface{}) {
- if logger.level() >= ErrorLevel {
+ if logger.IsLevelEnabled(ErrorLevel) {
entry := logger.newEntry()
entry.Error(args...)
logger.releaseEntry(entry)
@@ -230,7 +231,7 @@ func (logger *Logger) Error(args ...interface{}) {
}
func (logger *Logger) Fatal(args ...interface{}) {
- if logger.level() >= FatalLevel {
+ if logger.IsLevelEnabled(FatalLevel) {
entry := logger.newEntry()
entry.Fatal(args...)
logger.releaseEntry(entry)
@@ -239,7 +240,7 @@ func (logger *Logger) Fatal(args ...interface{}) {
}
func (logger *Logger) Panic(args ...interface{}) {
- if logger.level() >= PanicLevel {
+ if logger.IsLevelEnabled(PanicLevel) {
entry := logger.newEntry()
entry.Panic(args...)
logger.releaseEntry(entry)
@@ -247,7 +248,7 @@ func (logger *Logger) Panic(args ...interface{}) {
}
func (logger *Logger) Debugln(args ...interface{}) {
- if logger.level() >= DebugLevel {
+ if logger.IsLevelEnabled(DebugLevel) {
entry := logger.newEntry()
entry.Debugln(args...)
logger.releaseEntry(entry)
@@ -255,7 +256,7 @@ func (logger *Logger) Debugln(args ...interface{}) {
}
func (logger *Logger) Infoln(args ...interface{}) {
- if logger.level() >= InfoLevel {
+ if logger.IsLevelEnabled(InfoLevel) {
entry := logger.newEntry()
entry.Infoln(args...)
logger.releaseEntry(entry)
@@ -269,7 +270,7 @@ func (logger *Logger) Println(args ...interface{}) {
}
func (logger *Logger) Warnln(args ...interface{}) {
- if logger.level() >= WarnLevel {
+ if logger.IsLevelEnabled(WarnLevel) {
entry := logger.newEntry()
entry.Warnln(args...)
logger.releaseEntry(entry)
@@ -277,7 +278,7 @@ func (logger *Logger) Warnln(args ...interface{}) {
}
func (logger *Logger) Warningln(args ...interface{}) {
- if logger.level() >= WarnLevel {
+ if logger.IsLevelEnabled(WarnLevel) {
entry := logger.newEntry()
entry.Warnln(args...)
logger.releaseEntry(entry)
@@ -285,7 +286,7 @@ func (logger *Logger) Warningln(args ...interface{}) {
}
func (logger *Logger) Errorln(args ...interface{}) {
- if logger.level() >= ErrorLevel {
+ if logger.IsLevelEnabled(ErrorLevel) {
entry := logger.newEntry()
entry.Errorln(args...)
logger.releaseEntry(entry)
@@ -293,7 +294,7 @@ func (logger *Logger) Errorln(args ...interface{}) {
}
func (logger *Logger) Fatalln(args ...interface{}) {
- if logger.level() >= FatalLevel {
+ if logger.IsLevelEnabled(FatalLevel) {
entry := logger.newEntry()
entry.Fatalln(args...)
logger.releaseEntry(entry)
@@ -302,7 +303,7 @@ func (logger *Logger) Fatalln(args ...interface{}) {
}
func (logger *Logger) Panicln(args ...interface{}) {
- if logger.level() >= PanicLevel {
+ if logger.IsLevelEnabled(PanicLevel) {
entry := logger.newEntry()
entry.Panicln(args...)
logger.releaseEntry(entry)
@@ -320,18 +321,47 @@ func (logger *Logger) level() Level {
return Level(atomic.LoadUint32((*uint32)(&logger.Level)))
}
+// SetLevel sets the logger level.
func (logger *Logger) SetLevel(level Level) {
atomic.StoreUint32((*uint32)(&logger.Level), uint32(level))
}
-func (logger *Logger) SetOutput(out io.Writer) {
- logger.mu.Lock()
- defer logger.mu.Unlock()
- logger.Out = out
+// GetLevel returns the logger level.
+func (logger *Logger) GetLevel() Level {
+ return logger.level()
}
+// AddHook adds a hook to the logger hooks.
func (logger *Logger) AddHook(hook Hook) {
logger.mu.Lock()
defer logger.mu.Unlock()
logger.Hooks.Add(hook)
}
+
+// IsLevelEnabled checks if the log level of the logger is greater than the level param
+func (logger *Logger) IsLevelEnabled(level Level) bool {
+ return logger.level() >= level
+}
+
+// SetFormatter sets the logger formatter.
+func (logger *Logger) SetFormatter(formatter Formatter) {
+ logger.mu.Lock()
+ defer logger.mu.Unlock()
+ logger.Formatter = formatter
+}
+
+// SetOutput sets the logger output.
+func (logger *Logger) SetOutput(output io.Writer) {
+ logger.mu.Lock()
+ defer logger.mu.Unlock()
+ logger.Out = output
+}
+
+// ReplaceHooks replaces the logger hooks and returns the old ones
+func (logger *Logger) ReplaceHooks(hooks LevelHooks) LevelHooks {
+ logger.mu.Lock()
+ oldHooks := logger.Hooks
+ logger.Hooks = hooks
+ logger.mu.Unlock()
+ return oldHooks
+}
diff --git a/vendor/github.com/sirupsen/logrus/logrus.go b/vendor/github.com/sirupsen/logrus/logrus.go
index dd38999741..fa0b9dea8a 100644
--- a/vendor/github.com/sirupsen/logrus/logrus.go
+++ b/vendor/github.com/sirupsen/logrus/logrus.go
@@ -140,4 +140,11 @@ type FieldLogger interface {
Errorln(args ...interface{})
Fatalln(args ...interface{})
Panicln(args ...interface{})
+
+ // IsDebugEnabled() bool
+ // IsInfoEnabled() bool
+ // IsWarnEnabled() bool
+ // IsErrorEnabled() bool
+ // IsFatalEnabled() bool
+ // IsPanicEnabled() bool
}
diff --git a/vendor/github.com/sirupsen/logrus/terminal_bsd.go b/vendor/github.com/sirupsen/logrus/terminal_bsd.go
deleted file mode 100644
index 4880d13d26..0000000000
--- a/vendor/github.com/sirupsen/logrus/terminal_bsd.go
+++ /dev/null
@@ -1,10 +0,0 @@
-// +build darwin freebsd openbsd netbsd dragonfly
-// +build !appengine,!gopherjs
-
-package logrus
-
-import "golang.org/x/sys/unix"
-
-const ioctlReadTermios = unix.TIOCGETA
-
-type Termios unix.Termios
diff --git a/vendor/github.com/sirupsen/logrus/terminal_check_appengine.go b/vendor/github.com/sirupsen/logrus/terminal_check_appengine.go
index 3de08e802f..2403de9819 100644
--- a/vendor/github.com/sirupsen/logrus/terminal_check_appengine.go
+++ b/vendor/github.com/sirupsen/logrus/terminal_check_appengine.go
@@ -1,4 +1,4 @@
-// +build appengine gopherjs
+// +build appengine
package logrus
diff --git a/vendor/github.com/sirupsen/logrus/terminal_check_js.go b/vendor/github.com/sirupsen/logrus/terminal_check_js.go
new file mode 100644
index 0000000000..0c209750a3
--- /dev/null
+++ b/vendor/github.com/sirupsen/logrus/terminal_check_js.go
@@ -0,0 +1,11 @@
+// +build js
+
+package logrus
+
+import (
+ "io"
+)
+
+func checkIfTerminal(w io.Writer) bool {
+ return false
+}
diff --git a/vendor/github.com/sirupsen/logrus/terminal_check_notappengine.go b/vendor/github.com/sirupsen/logrus/terminal_check_notappengine.go
index 067047a123..cf309d6fb6 100644
--- a/vendor/github.com/sirupsen/logrus/terminal_check_notappengine.go
+++ b/vendor/github.com/sirupsen/logrus/terminal_check_notappengine.go
@@ -1,4 +1,4 @@
-// +build !appengine,!gopherjs
+// +build !appengine,!js,!windows
package logrus
diff --git a/vendor/github.com/sirupsen/logrus/terminal_check_windows.go b/vendor/github.com/sirupsen/logrus/terminal_check_windows.go
new file mode 100644
index 0000000000..3b9d2864ca
--- /dev/null
+++ b/vendor/github.com/sirupsen/logrus/terminal_check_windows.go
@@ -0,0 +1,20 @@
+// +build !appengine,!js,windows
+
+package logrus
+
+import (
+ "io"
+ "os"
+ "syscall"
+)
+
+func checkIfTerminal(w io.Writer) bool {
+ switch v := w.(type) {
+ case *os.File:
+ var mode uint32
+ err := syscall.GetConsoleMode(syscall.Handle(v.Fd()), &mode)
+ return err == nil
+ default:
+ return false
+ }
+}
diff --git a/vendor/github.com/sirupsen/logrus/terminal_linux.go b/vendor/github.com/sirupsen/logrus/terminal_linux.go
deleted file mode 100644
index f29a0097c8..0000000000
--- a/vendor/github.com/sirupsen/logrus/terminal_linux.go
+++ /dev/null
@@ -1,14 +0,0 @@
-// Based on ssh/terminal:
-// Copyright 2013 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// +build !appengine,!gopherjs
-
-package logrus
-
-import "golang.org/x/sys/unix"
-
-const ioctlReadTermios = unix.TCGETS
-
-type Termios unix.Termios
diff --git a/vendor/github.com/sirupsen/logrus/terminal_notwindows.go b/vendor/github.com/sirupsen/logrus/terminal_notwindows.go
new file mode 100644
index 0000000000..3dbd237203
--- /dev/null
+++ b/vendor/github.com/sirupsen/logrus/terminal_notwindows.go
@@ -0,0 +1,8 @@
+// +build !windows
+
+package logrus
+
+import "io"
+
+func initTerminal(w io.Writer) {
+}
diff --git a/vendor/github.com/sirupsen/logrus/terminal_windows.go b/vendor/github.com/sirupsen/logrus/terminal_windows.go
new file mode 100644
index 0000000000..b4ef5286cd
--- /dev/null
+++ b/vendor/github.com/sirupsen/logrus/terminal_windows.go
@@ -0,0 +1,18 @@
+// +build !appengine,!js,windows
+
+package logrus
+
+import (
+ "io"
+ "os"
+ "syscall"
+
+ sequences "github.com/konsorten/go-windows-terminal-sequences"
+)
+
+func initTerminal(w io.Writer) {
+ switch v := w.(type) {
+ case *os.File:
+ sequences.EnableVirtualTerminalProcessing(syscall.Handle(v.Fd()), true)
+ }
+}
diff --git a/vendor/github.com/sirupsen/logrus/text_formatter.go b/vendor/github.com/sirupsen/logrus/text_formatter.go
index 3e55040304..d4663b8c2a 100644
--- a/vendor/github.com/sirupsen/logrus/text_formatter.go
+++ b/vendor/github.com/sirupsen/logrus/text_formatter.go
@@ -3,6 +3,7 @@ package logrus
import (
"bytes"
"fmt"
+ "os"
"sort"
"strings"
"sync"
@@ -35,6 +36,9 @@ type TextFormatter struct {
// Force disabling colors.
DisableColors bool
+ // Override coloring based on CLICOLOR and CLICOLOR_FORCE. - https://bixense.com/clicolors/
+ EnvironmentOverrideColors bool
+
// Disable timestamp logging. useful when output is redirected to logging
// system that already adds timestamps.
DisableTimestamp bool
@@ -51,6 +55,9 @@ type TextFormatter struct {
// be desired.
DisableSorting bool
+ // The keys sorting function, when uninitialized it uses sort.Strings.
+ SortingFunc func([]string)
+
// Disables the truncation of the level text to 4 characters.
DisableLevelTruncation bool
@@ -69,15 +76,35 @@ type TextFormatter struct {
// FieldKeyMsg: "@message"}}
FieldMap FieldMap
- sync.Once
+ terminalInitOnce sync.Once
}
func (f *TextFormatter) init(entry *Entry) {
if entry.Logger != nil {
f.isTerminal = checkIfTerminal(entry.Logger.Out)
+
+ if f.isTerminal {
+ initTerminal(entry.Logger.Out)
+ }
}
}
+func (f *TextFormatter) isColored() bool {
+ isColored := f.ForceColors || f.isTerminal
+
+ if f.EnvironmentOverrideColors {
+ if force, ok := os.LookupEnv("CLICOLOR_FORCE"); ok && force != "0" {
+ isColored = true
+ } else if ok && force == "0" {
+ isColored = false
+ } else if os.Getenv("CLICOLOR") == "0" {
+ isColored = false
+ }
+ }
+
+ return isColored && !f.DisableColors
+}
+
// Format renders a single log entry
func (f *TextFormatter) Format(entry *Entry) ([]byte, error) {
prefixFieldClashes(entry.Data, f.FieldMap)
@@ -87,8 +114,32 @@ func (f *TextFormatter) Format(entry *Entry) ([]byte, error) {
keys = append(keys, k)
}
+ fixedKeys := make([]string, 0, 4+len(entry.Data))
+ if !f.DisableTimestamp {
+ fixedKeys = append(fixedKeys, f.FieldMap.resolve(FieldKeyTime))
+ }
+ fixedKeys = append(fixedKeys, f.FieldMap.resolve(FieldKeyLevel))
+ if entry.Message != "" {
+ fixedKeys = append(fixedKeys, f.FieldMap.resolve(FieldKeyMsg))
+ }
+ if entry.err != "" {
+ fixedKeys = append(fixedKeys, f.FieldMap.resolve(FieldKeyLogrusError))
+ }
+
if !f.DisableSorting {
- sort.Strings(keys)
+ if f.SortingFunc == nil {
+ sort.Strings(keys)
+ fixedKeys = append(fixedKeys, keys...)
+ } else {
+ if !f.isColored() {
+ fixedKeys = append(fixedKeys, keys...)
+ f.SortingFunc(fixedKeys)
+ } else {
+ f.SortingFunc(keys)
+ }
+ }
+ } else {
+ fixedKeys = append(fixedKeys, keys...)
}
var b *bytes.Buffer
@@ -98,26 +149,30 @@ func (f *TextFormatter) Format(entry *Entry) ([]byte, error) {
b = &bytes.Buffer{}
}
- f.Do(func() { f.init(entry) })
-
- isColored := (f.ForceColors || f.isTerminal) && !f.DisableColors
+ f.terminalInitOnce.Do(func() { f.init(entry) })
timestampFormat := f.TimestampFormat
if timestampFormat == "" {
timestampFormat = defaultTimestampFormat
}
- if isColored {
+ if f.isColored() {
f.printColored(b, entry, keys, timestampFormat)
} else {
- if !f.DisableTimestamp {
- f.appendKeyValue(b, f.FieldMap.resolve(FieldKeyTime), entry.Time.Format(timestampFormat))
- }
- f.appendKeyValue(b, f.FieldMap.resolve(FieldKeyLevel), entry.Level.String())
- if entry.Message != "" {
- f.appendKeyValue(b, f.FieldMap.resolve(FieldKeyMsg), entry.Message)
- }
- for _, key := range keys {
- f.appendKeyValue(b, key, entry.Data[key])
+ for _, key := range fixedKeys {
+ var value interface{}
+ switch key {
+ case f.FieldMap.resolve(FieldKeyTime):
+ value = entry.Time.Format(timestampFormat)
+ case f.FieldMap.resolve(FieldKeyLevel):
+ value = entry.Level.String()
+ case f.FieldMap.resolve(FieldKeyMsg):
+ value = entry.Message
+ case f.FieldMap.resolve(FieldKeyLogrusError):
+ value = entry.err
+ default:
+ value = entry.Data[key]
+ }
+ f.appendKeyValue(b, key, value)
}
}
@@ -143,6 +198,10 @@ func (f *TextFormatter) printColored(b *bytes.Buffer, entry *Entry, keys []strin
levelText = levelText[0:4]
}
+ // Remove a single newline if it already exists in the message to keep
+ // the behavior of logrus text_formatter the same as the stdlib log package
+ entry.Message = strings.TrimSuffix(entry.Message, "\n")
+
if f.DisableTimestamp {
fmt.Fprintf(b, "\x1b[%dm%s\x1b[0m %-44s ", levelColor, levelText, entry.Message)
} else if !f.FullTimestamp {
diff --git a/vendor/github.com/ugorji/go/codec/0doc.go b/vendor/github.com/ugorji/go/codec/0doc.go
index b61a8180e4..209f9ebad5 100644
--- a/vendor/github.com/ugorji/go/codec/0doc.go
+++ b/vendor/github.com/ugorji/go/codec/0doc.go
@@ -1,10 +1,9 @@
-// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved.
+// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved.
// Use of this source code is governed by a MIT license found in the LICENSE file.
/*
-Package codec provides a
-High Performance, Feature-Rich Idiomatic Go 1.4+ codec/encoding library
-for binc, msgpack, cbor, json.
+High Performance, Feature-Rich Idiomatic Go codec/encoding library for
+binc, msgpack, cbor, json.
Supported Serialization formats are:
@@ -12,17 +11,21 @@ Supported Serialization formats are:
- 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:
+ - 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.
+This package understands the 'unsafe' tag, to allow using unsafe semantics:
+
+ - When decoding into a struct, you need to read the field name as a string
+ so you can find the struct field it is mapped to.
+ Using `unsafe` will bypass the allocation and copying overhead of []byte->string conversion.
+
+To install using unsafe, pass the 'unsafe' tag:
+
+ go get -tags=unsafe github.com/ugorji/go/codec
For detailed usage information, read the primer at http://ugorji.net/blog/go-codec-primer .
@@ -32,16 +35,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
- - 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
- - Coerce types where appropriate
- e.g. decode an int in the stream into a float, decode numbers from formatted strings, etc
- - Corner Cases:
+ - Multiple conversions:
+ Package coerces types where appropriate
+ e.g. decode an int in the stream into a float, 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
@@ -49,21 +48,15 @@ Rich Feature Set includes:
(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
+ - 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.
@@ -75,12 +68,12 @@ Rich Feature Set includes:
- 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
+ - 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
@@ -99,27 +92,6 @@ encoded as an empty map because it has no exported fields, while UUID
would be encoded as a string. However, with extension support, you can
encode any of these however you like.
-Custom Encoding and Decoding
-
-This package maintains symmetry in the encoding and decoding halfs.
-We determine how to encode or decode by walking this decision tree
-
- - is type a codec.Selfer?
- - is there an extension registered for the type?
- - is format binary, and is type a encoding.BinaryMarshaler and BinaryUnmarshaler?
- - is format specifically json, and is type a encoding/json.Marshaler and Unmarshaler?
- - is format text-based, and type an encoding.TextMarshaler?
- - else we use a pair of functions based on the "kind" of the type e.g. map, slice, int64, etc
-
-This symmetry is important to reduce chances of issues happening because the
-encoding and decoding sides are out of sync e.g. decoded via very specific
-encoding.TextUnmarshaler but encoded via kind-specific generalized mode.
-
-Consequently, if a type only defines one-half of the symmetry
-(e.g. it implements UnmarshalJSON() but not MarshalJSON() ),
-then that type doesn't satisfy the check and we will continue walking down the
-decision tree.
-
RPC
RPC Client and Server Codecs are implemented, so the codecs can be used
@@ -188,77 +160,40 @@ Sample usage model:
//OR rpcCodec := codec.MsgpackSpecRpc.ClientCodec(conn, h)
client := rpc.NewClientWithCodec(rpcCodec)
-Running Tests
-
-To run tests, use the following:
-
- go test
-
-To run the full suite of tests, use the following:
-
- go test -tags alltests -run Suite
-
-You can run the tag 'safe' to run tests or build in safe mode. e.g.
-
- go test -tags safe -run Json
- go test -tags "alltests safe" -run Suite
-
-Running Benchmarks
-
-Please see http://github.com/ugorji/go-codec-bench .
-
-Caveats
-
-Struct fields matching the following are ignored during encoding and decoding
- - struct tag value set to -
- - func, complex numbers, unsafe pointers
- - unexported and not embedded
- - unexported and embedded and not struct kind
- - unexported and embedded pointers (from go1.10)
-
-Every other field in a struct will be encoded/decoded.
-
-Embedded fields are encoded as if they exist in the top-level struct,
-with some caveats. See Encode documentation.
-
*/
package codec
+// Benefits of go-codec:
+//
+// - encoding/json always reads whole file into memory first.
+// This makes it unsuitable for parsing very large files.
+// - encoding/xml cannot parse into a map[string]interface{}
+// I found this out on reading https://github.com/clbanning/mxj
+
// TODO:
-// - For Go 1.11, when mid-stack inlining is enabled,
-// we should use committed functions for writeXXX and readXXX calls.
-// This involves uncommenting the methods for decReaderSwitch and encWriterSwitch
-// and using those (decReaderSwitch and encWriterSwitch) in all handles
-// instead of encWriter and decReader.
-// The benefit is that, for the (En|De)coder over []byte, the encWriter/decReader
-// will be inlined, giving a performance bump for that typical case.
-// However, it will only be inlined if mid-stack inlining is enabled,
-// as we call panic to raise errors, and panic currently prevents inlining.
//
-// PUNTED:
-// - To make Handle comparable, make extHandle in BasicHandle a non-embedded pointer,
-// and use overlay methods on *BasicHandle to call through to extHandle after initializing
-// the "xh *extHandle" to point to a real slice.
-//
-// BEFORE EACH RELEASE:
-// - Look through and fix padding for each type, to eliminate false sharing
-// - critical shared objects that are read many times
-// TypeInfos
-// - pooled objects:
-// decNaked, decNakedContainers, codecFner, typeInfoLoadArray,
-// - small objects allocated independently, that we read/use much across threads:
-// codecFn, typeInfo
-// - Objects allocated independently and used a lot
-// Decoder, Encoder,
-// xxxHandle, xxxEncDriver, xxxDecDriver (xxx = json, msgpack, cbor, binc, simple)
-// - In all above, arrange values modified together to be close to each other.
-//
-// For all of these, either ensure that they occupy full cache lines,
-// or ensure that the things just past the cache line boundary are hardly read/written
-// e.g. JsonHandle.RawBytesExt - which is copied into json(En|De)cDriver at init
-//
-// Occupying full cache lines means they occupy 8*N words (where N is an integer).
-// Check this out by running: ./run.sh -z
-// - look at those tagged ****, meaning they are not occupying full cache lines
-// - look at those tagged <<<<, meaning they are larger than 32 words (something to watch)
-// - Run "golint -min_confidence 0.81"
+// - optimization for codecgen:
+// if len of entity is <= 3 words, then support a value receiver for encode.
+// - (En|De)coder should store an error when it occurs.
+// Until reset, subsequent calls return that error that was stored.
+// This means that free panics must go away.
+// All errors must be raised through errorf method.
+// - Decoding using a chan is good, but incurs concurrency costs.
+// This is because there's no fast way to use a channel without it
+// having to switch goroutines constantly.
+// Callback pattern is still the best. Maybe consider supporting something like:
+// type X struct {
+// Name string
+// Ys []Y
+// Ys chan <- Y
+// Ys func(Y) -> call this function for each entry
+// }
+// - Consider adding a isZeroer interface { isZero() bool }
+// It is used within isEmpty, for omitEmpty support.
+// - Consider making Handle used AS-IS within the encoding/decoding session.
+// This means that we don't cache Handle information within the (En|De)coder,
+// except we really need it at Reset(...)
+// - Consider adding math/big support
+// - Consider reducing the size of the generated functions:
+// Maybe use one loop, and put the conditionals in the loop.
+// for ... { if cLen > 0 { if j == cLen { break } } else if dd.CheckBreak() { break } }
diff --git a/vendor/github.com/ugorji/go/codec/README.md b/vendor/github.com/ugorji/go/codec/README.md
index 50d65e550d..91cb3a27bd 100644
--- a/vendor/github.com/ugorji/go/codec/README.md
+++ b/vendor/github.com/ugorji/go/codec/README.md
@@ -15,11 +15,17 @@ 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.
+This package understands the `unsafe` tag, to allow using unsafe semantics:
+
+ - When decoding into a struct, you need to read the field name as a string
+ so you can find the struct field it is mapped to.
+ Using `unsafe` will bypass the allocation and copying overhead of `[]byte->string` conversion.
+
+To use it, you must pass the `unsafe` tag during install:
+
+```
+go install -tags=unsafe github.com/ugorji/go/codec
+```
Online documentation: http://godoc.org/github.com/ugorji/go/codec
Detailed Usage/How-to Primer: http://ugorji.net/blog/go-codec-primer
@@ -30,15 +36,11 @@ 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
- - Coerce types where appropriate
- e.g. decode an int in the stream into a float, decode numbers from formatted strings, etc
+ - Multiple conversions:
+ Package coerces types where appropriate
+ e.g. decode an int in the stream into a float, etc.
- Corner Cases:
Overflows, nil maps/slices, nil values in streams are handled correctly
- Standard field renaming via tags
@@ -47,16 +49,10 @@ Rich Feature Set includes:
(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.
@@ -96,27 +92,6 @@ encoded as an empty map because it has no exported fields, while UUID
would be encoded as a string. However, with extension support, you can
encode any of these however you like.
-## Custom Encoding and Decoding
-
-This package maintains symmetry in the encoding and decoding halfs.
-We determine how to encode or decode by walking this decision tree
-
- - is type a codec.Selfer?
- - is there an extension registered for the type?
- - is format binary, and is type a encoding.BinaryMarshaler and BinaryUnmarshaler?
- - is format specifically json, and is type a encoding/json.Marshaler and Unmarshaler?
- - is format text-based, and type an encoding.TextMarshaler?
- - else we use a pair of functions based on the "kind" of the type e.g. map, slice, int64, etc
-
-This symmetry is important to reduce chances of issues happening because the
-encoding and decoding sides are out of sync e.g. decoded via very specific
-encoding.TextUnmarshaler but encoded via kind-specific generalized mode.
-
-Consequently, if a type only defines one-half of the symmetry
-(e.g. it implements UnmarshalJSON() but not MarshalJSON() ),
-then that type doesn't satisfy the check and we will continue walking down the
-decision tree.
-
## RPC
RPC Client and Server Codecs are implemented, so the codecs can be used
@@ -171,36 +146,3 @@ Typical usage model:
//OR rpcCodec := codec.MsgpackSpecRpc.ClientCodec(conn, h)
client := rpc.NewClientWithCodec(rpcCodec)
-## Running Tests
-
-To run tests, use the following:
-
- go test
-
-To run the full suite of tests, use the following:
-
- go test -tags alltests -run Suite
-
-You can run the tag 'safe' to run tests or build in safe mode. e.g.
-
- go test -tags safe -run Json
- go test -tags "alltests safe" -run Suite
-
-## Running Benchmarks
-
-Please see http://github.com/ugorji/go-codec-bench .
-
-## Caveats
-
-Struct fields matching the following are ignored during encoding and decoding
-
- - struct tag value set to -
- - func, complex numbers, unsafe pointers
- - unexported and not embedded
- - unexported and embedded and not struct kind
- - unexported and embedded pointers (from go1.10)
-
-Every other field in a struct will be encoded/decoded.
-
-Embedded fields are encoded as if they exist in the top-level struct,
-with some caveats. See Encode documentation.
diff --git a/vendor/github.com/ugorji/go/codec/binc.go b/vendor/github.com/ugorji/go/codec/binc.go
index a3c96fe741..33120dcb61 100644
--- a/vendor/github.com/ugorji/go/codec/binc.go
+++ b/vendor/github.com/ugorji/go/codec/binc.go
@@ -1,4 +1,4 @@
-// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved.
+// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved.
// Use of this source code is governed by a MIT license found in the LICENSE file.
package codec
@@ -55,77 +55,39 @@ const (
// others not currently supported
)
-func bincdesc(vd, vs byte) string {
- switch vd {
- case bincVdSpecial:
- switch vs {
- case bincSpNil:
- return "nil"
- case bincSpFalse:
- return "false"
- case bincSpTrue:
- return "true"
- case bincSpNan, bincSpPosInf, bincSpNegInf, bincSpZeroFloat:
- return "float"
- case bincSpZero:
- return "uint"
- case bincSpNegOne:
- return "int"
- default:
- return "unknown"
- }
- case bincVdSmallInt, bincVdPosInt:
- return "uint"
- case bincVdNegInt:
- return "int"
- case bincVdFloat:
- return "float"
- case bincVdSymbol:
- return "string"
- case bincVdString:
- return "string"
- case bincVdByteArray:
- return "bytes"
- case bincVdTimestamp:
- return "time"
- case bincVdCustomExt:
- return "ext"
- case bincVdArray:
- return "array"
- case bincVdMap:
- return "map"
- default:
- return "unknown"
- }
-}
-
type bincEncDriver struct {
e *Encoder
- h *BincHandle
w encWriter
m map[string]uint16 // symbols
- b [16]byte // scratch, used for encoding numbers - bigendian style
- s uint16 // symbols sequencer
- // c containerState
- encDriverTrackContainerWriter
- noBuiltInTypes
- // encNoSeparator
+ b [scratchByteArrayLen]byte
+ s uint16 // symbols sequencer
+ encNoSeparator
+}
+
+func (e *bincEncDriver) IsBuiltinType(rt uintptr) bool {
+ return rt == timeTypId
+}
+
+func (e *bincEncDriver) EncodeBuiltin(rt uintptr, v interface{}) {
+ if rt == timeTypId {
+ var bs []byte
+ switch x := v.(type) {
+ case time.Time:
+ bs = encodeTime(x)
+ case *time.Time:
+ bs = encodeTime(*x)
+ default:
+ e.e.errorf("binc error encoding builtin: expect time.Time, received %T", v)
+ }
+ e.w.writen1(bincVdTimestamp<<4 | uint8(len(bs)))
+ e.w.writeb(bs)
+ }
}
func (e *bincEncDriver) EncodeNil() {
e.w.writen1(bincVdSpecial<<4 | bincSpNil)
}
-func (e *bincEncDriver) EncodeTime(t time.Time) {
- if t.IsZero() {
- e.EncodeNil()
- } else {
- bs := bincEncodeTime(t)
- e.w.writen1(bincVdTimestamp<<4 | uint8(len(bs)))
- e.w.writeb(bs)
- }
-}
-
func (e *bincEncDriver) EncodeBool(b bool) {
if b {
e.w.writen1(bincVdSpecial<<4 | bincSpTrue)
@@ -233,21 +195,15 @@ func (e *bincEncDriver) encodeExtPreamble(xtag byte, length int) {
e.w.writen1(xtag)
}
-func (e *bincEncDriver) WriteArrayStart(length int) {
+func (e *bincEncDriver) EncodeArrayStart(length int) {
e.encLen(bincVdArray<<4, uint64(length))
- e.c = containerArrayStart
}
-func (e *bincEncDriver) WriteMapStart(length int) {
+func (e *bincEncDriver) EncodeMapStart(length int) {
e.encLen(bincVdMap<<4, uint64(length))
- e.c = containerMapStart
}
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)
- return
- }
l := uint64(len(v))
e.encBytesLen(c, l)
if l > 0 {
@@ -257,7 +213,7 @@ func (e *bincEncDriver) EncodeString(c charEncoding, v string) {
func (e *bincEncDriver) EncodeSymbol(v string) {
// if WriteSymbolsNoRefs {
- // e.encodeString(cUTF8, v)
+ // e.encodeString(c_UTF8, v)
// return
// }
@@ -267,10 +223,10 @@ func (e *bincEncDriver) EncodeSymbol(v string) {
l := len(v)
if l == 0 {
- e.encBytesLen(cUTF8, 0)
+ e.encBytesLen(c_UTF8, 0)
return
} else if l == 1 {
- e.encBytesLen(cUTF8, 1)
+ e.encBytesLen(c_UTF8, 1)
e.w.writen1(v[0])
return
}
@@ -320,10 +276,6 @@ func (e *bincEncDriver) EncodeSymbol(v string) {
}
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 {
@@ -333,7 +285,7 @@ func (e *bincEncDriver) EncodeStringBytes(c charEncoding, v []byte) {
func (e *bincEncDriver) encBytesLen(c charEncoding, length uint64) {
//TODO: support bincUnicodeOther (for now, just use string or bytearray)
- if c == cRAW {
+ if c == c_RAW {
e.encLen(bincVdByteArray<<4, length)
} else {
e.encLen(bincVdString<<4, length)
@@ -372,9 +324,6 @@ type bincDecSymbol struct {
}
type bincDecDriver struct {
- decDriverNoopContainerReader
- noBuiltInTypes
-
d *Decoder
h *BincHandle
r decReader
@@ -383,15 +332,13 @@ type bincDecDriver struct {
bd byte
vd byte
vs byte
- _ [3]byte // padding
+ noStreamingCodec
+ decNoSeparator
+ b [scratchByteArrayLen]byte
+
// linear searching on this slice is ok,
// because we typically expect < 32 symbols in each stream.
s []bincDecSymbol
-
- // noStreamingCodec
- // decNoSeparator
-
- b [8 * 8]byte // scratch
}
func (d *bincDecDriver) readNextBd() {
@@ -409,9 +356,6 @@ func (d *bincDecDriver) uncacheRead() {
}
func (d *bincDecDriver) ContainerType() (vt valueType) {
- if !d.bdRead {
- d.readNextBd()
- }
if d.vd == bincVdSpecial && d.vs == bincSpNil {
return valueTypeNil
} else if d.vd == bincVdByteArray {
@@ -422,10 +366,9 @@ func (d *bincDecDriver) ContainerType() (vt valueType) {
return valueTypeArray
} else if d.vd == bincVdMap {
return valueTypeMap
+ } else {
+ // d.d.errorf("isContainerType: unsupported parameter: %v", vt)
}
- // else {
- // d.d.errorf("isContainerType: unsupported parameter: %v", vt)
- // }
return valueTypeUnset
}
@@ -440,24 +383,27 @@ func (d *bincDecDriver) TryDecodeAsNil() bool {
return false
}
-func (d *bincDecDriver) DecodeTime() (t time.Time) {
+func (d *bincDecDriver) IsBuiltinType(rt uintptr) bool {
+ return rt == timeTypId
+}
+
+func (d *bincDecDriver) DecodeBuiltin(rt uintptr, v interface{}) {
if !d.bdRead {
d.readNextBd()
}
- if d.bd == bincVdSpecial<<4|bincSpNil {
+ if rt == timeTypId {
+ if d.vd != bincVdTimestamp {
+ d.d.errorf("Invalid d.vd. Expecting 0x%x. Received: 0x%x", bincVdTimestamp, d.vd)
+ return
+ }
+ tt, err := decodeTime(d.r.readx(int(d.vs)))
+ if err != nil {
+ panic(err)
+ }
+ var vt *time.Time = v.(*time.Time)
+ *vt = tt
d.bdRead = false
- 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(int(d.vs)))
- if err != nil {
- panic(err)
- }
- d.bdRead = false
- return
}
func (d *bincDecDriver) decFloatPre(vs, defaultLen byte) {
@@ -466,7 +412,7 @@ func (d *bincDecDriver) decFloatPre(vs, defaultLen byte) {
} else {
l := d.r.readn1()
if l > 8 {
- d.d.errorf("cannot read float - at most 8 bytes used to represent float - received %v bytes", l)
+ d.d.errorf("At most 8 bytes used to represent float. Received: %v bytes", l)
return
}
for i := l; i < 8; i++ {
@@ -485,7 +431,7 @@ func (d *bincDecDriver) decFloat() (f float64) {
d.decFloatPre(d.vs, 8)
f = math.Float64frombits(bigen.Uint64(d.b[0:8]))
} else {
- d.d.errorf("read float - only float32 and float64 are supported - %s %x-%x/%s", msgBadDesc, d.vd, d.vs, bincdesc(d.vd, d.vs))
+ d.d.errorf("only float32 and float64 are supported. d.vd: 0x%x, d.vs: 0x%x", d.vd, d.vs)
return
}
return
@@ -542,38 +488,49 @@ func (d *bincDecDriver) decCheckInteger() (ui uint64, neg bool) {
neg = true
ui = 1
} else {
- d.d.errorf("integer decode fails - invalid special value from descriptor %x-%x/%s",
- d.vd, d.vs, bincdesc(d.vd, d.vs))
+ d.d.errorf("numeric decode fails for special value: d.vs: 0x%x", d.vs)
return
}
} else {
- d.d.errorf("integer can only be decoded from int/uint. d.bd: 0x%x, d.vd: 0x%x", d.bd, d.vd)
+ d.d.errorf("number can only be decoded from uint or int values. d.bd: 0x%x, d.vd: 0x%x", d.bd, d.vd)
return
}
return
}
-func (d *bincDecDriver) DecodeInt64() (i int64) {
+func (d *bincDecDriver) DecodeInt(bitsize uint8) (i int64) {
ui, neg := d.decCheckInteger()
- i = chkOvf.SignedIntV(ui)
+ i, overflow := chkOvf.SignedInt(ui)
+ if overflow {
+ d.d.errorf("simple: overflow converting %v to signed integer", ui)
+ return
+ }
if neg {
i = -i
}
- d.bdRead = false
- return
-}
-
-func (d *bincDecDriver) DecodeUint64() (ui uint64) {
- ui, neg := d.decCheckInteger()
- if neg {
- d.d.errorf("assigning negative signed value to unsigned integer type")
+ if chkOvf.Int(i, bitsize) {
+ d.d.errorf("binc: overflow integer: %v", i)
return
}
d.bdRead = false
return
}
-func (d *bincDecDriver) DecodeFloat64() (f float64) {
+func (d *bincDecDriver) DecodeUint(bitsize uint8) (ui uint64) {
+ ui, neg := d.decCheckInteger()
+ if neg {
+ d.d.errorf("Assigning negative signed value to unsigned type")
+ return
+ }
+ if chkOvf.Uint(ui, bitsize) {
+ d.d.errorf("binc: overflow integer: %v", ui)
+ return
+ }
+ d.bdRead = false
+ return
+}
+
+func (d *bincDecDriver) DecodeFloat(chkOverflow32 bool) (f float64) {
if !d.bdRead {
d.readNextBd()
}
@@ -589,14 +546,17 @@ func (d *bincDecDriver) DecodeFloat64() (f float64) {
} else if vs == bincSpNegInf {
return math.Inf(-1)
} else {
- d.d.errorf("float - invalid special value from descriptor %x-%x/%s",
- d.vd, d.vs, bincdesc(d.vd, d.vs))
+ d.d.errorf("Invalid d.vs decoding float where d.vd=bincVdSpecial: %v", d.vs)
return
}
} else if vd == bincVdFloat {
f = d.decFloat()
} else {
- f = float64(d.DecodeInt64())
+ f = float64(d.DecodeInt(64))
+ }
+ if chkOverflow32 && chkOvf.Float32(f) {
+ d.d.errorf("binc: float32 overflow: %v", f)
+ return
}
d.bdRead = false
return
@@ -612,7 +572,7 @@ func (d *bincDecDriver) DecodeBool() (b bool) {
} else if bd == (bincVdSpecial | bincSpTrue) {
b = true
} else {
- d.d.errorf("bool - %s %x-%x/%s", msgBadDesc, d.vd, d.vs, bincdesc(d.vd, d.vs))
+ d.d.errorf("Invalid single-byte value for bool: %s: %x", msgBadDesc, d.bd)
return
}
d.bdRead = false
@@ -620,11 +580,8 @@ func (d *bincDecDriver) DecodeBool() (b bool) {
}
func (d *bincDecDriver) ReadMapStart() (length int) {
- if !d.bdRead {
- d.readNextBd()
- }
if d.vd != bincVdMap {
- d.d.errorf("map - %s %x-%x/%s", msgBadDesc, d.vd, d.vs, bincdesc(d.vd, d.vs))
+ d.d.errorf("Invalid d.vd for map. Expecting 0x%x. Got: 0x%x", bincVdMap, d.vd)
return
}
length = d.decLen()
@@ -633,11 +590,8 @@ func (d *bincDecDriver) ReadMapStart() (length int) {
}
func (d *bincDecDriver) ReadArrayStart() (length int) {
- if !d.bdRead {
- d.readNextBd()
- }
if d.vd != bincVdArray {
- d.d.errorf("array - %s %x-%x/%s", msgBadDesc, d.vd, d.vs, bincdesc(d.vd, d.vs))
+ d.d.errorf("Invalid d.vd for array. Expecting 0x%x. Got: 0x%x", bincVdArray, d.vd)
return
}
length = d.decLen()
@@ -668,8 +622,7 @@ func (d *bincDecDriver) decLenNumber() (v uint64) {
return
}
-func (d *bincDecDriver) decStringAndBytes(bs []byte, withString, zerocopy bool) (
- bs2 []byte, s string) {
+func (d *bincDecDriver) decStringAndBytes(bs []byte, withString, zerocopy bool) (bs2 []byte, s string) {
if !d.bdRead {
d.readNextBd()
}
@@ -677,7 +630,7 @@ func (d *bincDecDriver) decStringAndBytes(bs []byte, withString, zerocopy bool)
d.bdRead = false
return
}
- var slen = -1
+ var slen int = -1
// var ok bool
switch d.vd {
case bincVdString, bincVdByteArray:
@@ -686,12 +639,12 @@ func (d *bincDecDriver) decStringAndBytes(bs []byte, withString, zerocopy bool)
if d.br {
bs2 = d.r.readx(slen)
} else if len(bs) == 0 {
- bs2 = decByteSlice(d.r, slen, d.d.h.MaxInitLen, d.b[:])
+ bs2 = decByteSlice(d.r, slen, d.b[:])
} else {
- bs2 = decByteSlice(d.r, slen, d.d.h.MaxInitLen, bs)
+ bs2 = decByteSlice(d.r, slen, bs)
}
} else {
- bs2 = decByteSlice(d.r, slen, d.d.h.MaxInitLen, bs)
+ bs2 = decByteSlice(d.r, slen, bs)
}
if withString {
s = string(bs2)
@@ -743,14 +696,15 @@ func (d *bincDecDriver) decStringAndBytes(bs []byte, withString, zerocopy bool)
// 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)
+ bs2 = decByteSlice(d.r, slen, nil)
if withString {
s = string(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))
+ d.d.errorf("Invalid d.vd. Expecting string:0x%x, bytearray:0x%x or symbol: 0x%x. Got: 0x%x",
+ bincVdString, bincVdByteArray, bincVdSymbol, d.vd)
return
}
d.bdRead = false
@@ -765,12 +719,11 @@ func (d *bincDecDriver) DecodeString() (s string) {
return
}
-func (d *bincDecDriver) DecodeStringAsBytes() (s []byte) {
- s, _ = d.decStringAndBytes(d.b[:], false, true)
- return
-}
-
-func (d *bincDecDriver) DecodeBytes(bs []byte, zerocopy bool) (bsOut []byte) {
+func (d *bincDecDriver) DecodeBytes(bs []byte, isstring, zerocopy bool) (bsOut []byte) {
+ if isstring {
+ bsOut, _ = d.decStringAndBytes(bs, false, zerocopy)
+ return
+ }
if !d.bdRead {
d.readNextBd()
}
@@ -778,16 +731,12 @@ func (d *bincDecDriver) DecodeBytes(bs []byte, zerocopy bool) (bsOut []byte) {
d.bdRead = false
return nil
}
- // 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
- }
var clen int
if d.vd == bincVdString || d.vd == bincVdByteArray {
clen = d.decLen()
} else {
- d.d.errorf("bytes - %s %x-%x/%s", msgBadDesc, d.vd, d.vs, bincdesc(d.vd, d.vs))
+ d.d.errorf("Invalid d.vd for bytes. Expecting string:0x%x or bytearray:0x%x. Got: 0x%x",
+ bincVdString, bincVdByteArray, d.vd)
return
}
d.bdRead = false
@@ -798,12 +747,12 @@ func (d *bincDecDriver) DecodeBytes(bs []byte, zerocopy bool) (bsOut []byte) {
bs = d.b[:]
}
}
- return decByteSlice(d.r, clen, d.d.h.MaxInitLen, bs)
+ return decByteSlice(d.r, clen, bs)
}
func (d *bincDecDriver) DecodeExt(rv interface{}, xtag uint64, ext Ext) (realxtag uint64) {
if xtag > 0xff {
- d.d.errorf("ext: tag must be <= 0xff; got: %v", xtag)
+ d.d.errorf("decodeExt: tag must be <= 0xff; got: %v", xtag)
return
}
realxtag1, xbs := d.decodeExtV(ext != nil, uint8(xtag))
@@ -826,14 +775,14 @@ func (d *bincDecDriver) decodeExtV(verifyTag bool, tag byte) (xtag byte, xbs []b
l := d.decLen()
xtag = d.r.readn1()
if verifyTag && xtag != tag {
- d.d.errorf("wrong extension tag - got %b, expecting: %v", xtag, tag)
+ d.d.errorf("Wrong extension tag. Got %b. Expecting: %v", xtag, tag)
return
}
xbs = d.r.readx(l)
} else if d.vd == bincVdByteArray {
- xbs = d.DecodeBytes(nil, true)
+ xbs = d.DecodeBytes(nil, false, true)
} else {
- d.d.errorf("ext - expecting extensions or byte array - %s %x-%x/%s", msgBadDesc, d.vd, d.vs, bincdesc(d.vd, d.vs))
+ d.d.errorf("Invalid d.vd for extensions (Expecting extensions or byte array). Got: 0x%x", d.vd)
return
}
d.bdRead = false
@@ -845,7 +794,7 @@ func (d *bincDecDriver) DecodeNaked() {
d.readNextBd()
}
- n := d.d.n
+ n := &d.d.n
var decodeFurther bool
switch d.vd {
@@ -878,7 +827,7 @@ func (d *bincDecDriver) DecodeNaked() {
n.v = valueTypeInt
n.i = int64(-1) // int8(-1)
default:
- d.d.errorf("cannot infer value - unrecognized special value from descriptor %x-%x/%s", d.vd, d.vs, bincdesc(d.vd, d.vs))
+ d.d.errorf("decodeNaked: Unrecognized special value 0x%x", d.vs)
}
case bincVdSmallInt:
n.v = valueTypeUint
@@ -900,10 +849,10 @@ func (d *bincDecDriver) DecodeNaked() {
n.s = d.DecodeString()
case bincVdByteArray:
n.v = valueTypeBytes
- n.l = d.DecodeBytes(nil, false)
+ n.l = d.DecodeBytes(nil, false, false)
case bincVdTimestamp:
- n.v = valueTypeTime
- tt, err := bincDecodeTime(d.r.readx(int(d.vs)))
+ n.v = valueTypeTimestamp
+ tt, err := decodeTime(d.r.readx(int(d.vs)))
if err != nil {
panic(err)
}
@@ -920,7 +869,7 @@ func (d *bincDecDriver) DecodeNaked() {
n.v = valueTypeMap
decodeFurther = true
default:
- d.d.errorf("cannot infer value - %s %x-%x/%s", msgBadDesc, d.vd, d.vs, bincdesc(d.vd, d.vs))
+ d.d.errorf("decodeNaked: Unrecognized d.vd: 0x%x", d.vd)
}
if !decodeFurther {
@@ -950,219 +899,31 @@ func (d *bincDecDriver) DecodeNaked() {
type BincHandle struct {
BasicHandle
binaryEncodingType
- noElemSeparators
-
- // AsSymbols defines what should be encoded as symbols.
- //
- // Encoding as symbols can reduce the encoded size significantly.
- //
- // However, during decoding, each string to be encoded as a symbol must
- // be checked to see if it has been seen before. Consequently, encoding time
- // will increase if using symbols, because string comparisons has a clear cost.
- //
- // Values:
- // - 0: default: library uses best judgement
- // - 1: use symbols
- // - 2: do not use symbols
- AsSymbols uint8
-
- // AsSymbols: may later on introduce more options ...
- // - m: map keys
- // - s: struct fields
- // - n: none
- // - a: all: same as m, s, ...
-
- // _ [1]uint64 // padding
}
-// 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{}})
+ return h.SetExt(rt, tag, &setExtWrapper{b: ext})
}
func (h *BincHandle) newEncDriver(e *Encoder) encDriver {
- return &bincEncDriver{e: e, h: h, w: e.w}
+ return &bincEncDriver{e: e, w: e.w}
}
func (h *BincHandle) newDecDriver(d *Decoder) decDriver {
- return &bincDecDriver{d: d, h: h, r: d.r, br: d.bytes}
+ return &bincDecDriver{d: d, r: d.r, h: h, br: d.bytes}
}
func (e *bincEncDriver) reset() {
e.w = e.e.w
e.s = 0
- e.c = 0
e.m = nil
}
func (d *bincDecDriver) reset() {
- d.r, d.br = d.d.r, d.d.bytes
+ d.r = d.d.r
d.s = nil
d.bd, d.bdRead, d.vd, d.vs = 0, false, 0, 0
}
-// var timeDigits = [...]byte{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'}
-
-// EncodeTime encodes a time.Time as a []byte, including
-// information on the instant in time and UTC offset.
-//
-// Format Description
-//
-// A timestamp is composed of 3 components:
-//
-// - secs: signed integer representing seconds since unix epoch
-// - nsces: unsigned integer representing fractional seconds as a
-// nanosecond offset within secs, in the range 0 <= nsecs < 1e9
-// - tz: signed integer representing timezone offset in minutes east of UTC,
-// and a dst (daylight savings time) flag
-//
-// When encoding a timestamp, the first byte is the descriptor, which
-// defines which components are encoded and how many bytes are used to
-// encode secs and nsecs components. *If secs/nsecs is 0 or tz is UTC, it
-// is not encoded in the byte array explicitly*.
-//
-// Descriptor 8 bits are of the form `A B C DDD EE`:
-// A: Is secs component encoded? 1 = true
-// B: Is nsecs component encoded? 1 = true
-// C: Is tz component encoded? 1 = true
-// DDD: Number of extra bytes for secs (range 0-7).
-// If A = 1, secs encoded in DDD+1 bytes.
-// If A = 0, secs is not encoded, and is assumed to be 0.
-// If A = 1, then we need at least 1 byte to encode secs.
-// DDD says the number of extra bytes beyond that 1.
-// E.g. if DDD=0, then secs is represented in 1 byte.
-// if DDD=2, then secs is represented in 3 bytes.
-// EE: Number of extra bytes for nsecs (range 0-3).
-// If B = 1, nsecs encoded in EE+1 bytes (similar to secs/DDD above)
-//
-// Following the descriptor bytes, subsequent bytes are:
-//
-// secs component encoded in `DDD + 1` bytes (if A == 1)
-// nsecs component encoded in `EE + 1` bytes (if B == 1)
-// tz component encoded in 2 bytes (if C == 1)
-//
-// secs and nsecs components are integers encoded in a BigEndian
-// 2-complement encoding format.
-//
-// tz component is encoded as 2 bytes (16 bits). Most significant bit 15 to
-// Least significant bit 0 are described below:
-//
-// Timezone offset has a range of -12:00 to +14:00 (ie -720 to +840 minutes).
-// Bit 15 = have\_dst: set to 1 if we set the dst flag.
-// Bit 14 = dst\_on: set to 1 if dst is in effect at the time, or 0 if not.
-// 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)
- tsecs, tnsecs := t.Unix(), t.Nanosecond()
- var (
- bd byte
- btmp [8]byte
- bs [16]byte
- i int = 1
- )
- l := t.Location()
- if l == time.UTC {
- l = nil
- }
- if tsecs != 0 {
- bd = bd | 0x80
- bigen.PutUint64(btmp[:], uint64(tsecs))
- f := pruneSignExt(btmp[:], tsecs >= 0)
- bd = bd | (byte(7-f) << 2)
- copy(bs[i:], btmp[f:])
- i = i + (8 - f)
- }
- if tnsecs != 0 {
- bd = bd | 0x40
- bigen.PutUint32(btmp[:4], uint32(tnsecs))
- f := pruneSignExt(btmp[:4], true)
- bd = bd | byte(3-f)
- copy(bs[i:], btmp[f:4])
- i = i + (4 - f)
- }
- if l != nil {
- bd = bd | 0x20
- // Note that Go Libs do not give access to dst flag.
- _, zoneOffset := t.Zone()
- //zoneName, zoneOffset := t.Zone()
- zoneOffset /= 60
- z := uint16(zoneOffset)
- bigen.PutUint16(btmp[:2], z)
- // clear dst flags
- bs[i] = btmp[0] & 0x3f
- bs[i+1] = btmp[1]
- i = i + 2
- }
- bs[0] = bd
- return bs[0:i]
-}
-
-// bincDecodeTime decodes a []byte into a time.Time.
-func bincDecodeTime(bs []byte) (tt time.Time, err error) {
- bd := bs[0]
- var (
- tsec int64
- tnsec uint32
- tz uint16
- i byte = 1
- i2 byte
- n byte
- )
- if bd&(1<<7) != 0 {
- var btmp [8]byte
- 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 bs[i]&(1<<7) != 0 {
- copy(btmp[0:8-n], bsAll0xff)
- //for j,k := byte(0), 8-n; j < k; j++ { btmp[j] = 0xff }
- }
- i = i2
- tsec = int64(bigen.Uint64(btmp[:]))
- }
- if bd&(1<<6) != 0 {
- var btmp [4]byte
- n = (bd & 0x3) + 1
- i2 = i + n
- copy(btmp[4-n:], bs[i:i2])
- i = i2
- tnsec = bigen.Uint32(btmp[:])
- }
- if bd&(1<<5) == 0 {
- tt = time.Unix(tsec, int64(tnsec)).UTC()
- 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.
- // Zone name is in form: UTC-08:00.
- // Note that Go Libs do not give access to dst flag, so we ignore dst bits
-
- i2 = i + 2
- tz = bigen.Uint16(bs[i:i2])
- // i = i2
- // sign extend sign bit into top 2 MSB (which were dst bits):
- if tz&(1<<13) == 0 { // positive
- tz = tz & 0x3fff //clear 2 MSBs: dst bits
- } else { // negative
- tz = tz | 0xc000 //set 2 MSBs: dst bits
- }
- tzint := int16(tz)
- if tzint == 0 {
- tt = time.Unix(tsec, int64(tnsec)).UTC()
- } else {
- // For Go Time, do not use a descriptive timezone.
- // It's unnecessary, and makes it harder to do a reflect.DeepEqual.
- // The Offset already tells what the offset should be, if not on UTC and unknown zone name.
- // var zoneName = timeLocUTCName(tzint)
- tt = time.Unix(tsec, int64(tnsec)).In(time.FixedZone("", int(tzint)*60))
- }
- return
-}
-
var _ decDriver = (*bincDecDriver)(nil)
var _ encDriver = (*bincEncDriver)(nil)
diff --git a/vendor/github.com/ugorji/go/codec/cbor.go b/vendor/github.com/ugorji/go/codec/cbor.go
index 7633c04ac3..4fa349ac87 100644
--- a/vendor/github.com/ugorji/go/codec/cbor.go
+++ b/vendor/github.com/ugorji/go/codec/cbor.go
@@ -1,4 +1,4 @@
-// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved.
+// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved.
// Use of this source code is governed by a MIT license found in the LICENSE file.
package codec
@@ -6,7 +6,6 @@ package codec
import (
"math"
"reflect"
- "time"
)
const (
@@ -39,8 +38,6 @@ const (
cborBdBreak = 0xff
)
-// These define some in-stream descriptors for
-// manual encoding e.g. when doing explicit indefinite-length
const (
CborStreamBytes byte = 0x5f
CborStreamString = 0x7f
@@ -60,57 +57,15 @@ const (
cborBaseSimple = 0xe0
)
-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"
- default:
- return "unknown"
- }
- }
-}
-
// -------------------
type cborEncDriver struct {
noBuiltInTypes
- encDriverNoopContainerWriter
- // encNoSeparator
+ encNoSeparator
e *Encoder
w encWriter
h *CborHandle
x [8]byte
- _ [3]uint64 // padding
}
func (e *cborEncDriver) EncodeNil() {
@@ -168,24 +123,6 @@ func (e *cborEncDriver) encLen(bd byte, length int) {
e.encUint(uint64(length), bd)
}
-func (e *cborEncDriver) EncodeTime(t time.Time) {
- if t.IsZero() {
- e.EncodeNil()
- } else if e.h.TimeRFC3339 {
- e.encUint(0, cborBaseTag)
- e.EncodeString(cUTF8, t.Format(time.RFC3339Nano))
- } else {
- e.encUint(1, cborBaseTag)
- t = t.UTC().Round(time.Microsecond)
- sec, nsec := t.Unix(), uint64(t.Nanosecond())
- if nsec == 0 {
- e.EncodeInt(sec)
- } else {
- e.EncodeFloat64(float64(sec) + float64(nsec)/1e9)
- }
- }
-}
-
func (e *cborEncDriver) EncodeExt(rv interface{}, xtag uint64, ext Ext, en *Encoder) {
e.encUint(uint64(xtag), cborBaseTag)
if v := ext.ConvertExt(rv); v == nil {
@@ -197,103 +134,53 @@ func (e *cborEncDriver) EncodeExt(rv interface{}, xtag uint64, ext Ext, en *Enco
func (e *cborEncDriver) EncodeRawExt(re *RawExt, en *Encoder) {
e.encUint(uint64(re.Tag), cborBaseTag)
- if false && re.Data != nil {
+ if re.Data != nil {
en.encode(re.Data)
- } else if re.Value != nil {
- en.encode(re.Value)
- } else {
+ } else if re.Value == nil {
e.EncodeNil()
- }
-}
-
-func (e *cborEncDriver) WriteArrayStart(length int) {
- if e.h.IndefiniteLength {
- e.w.writen1(cborBdIndefiniteArray)
} else {
- e.encLen(cborBaseArray, length)
+ en.encode(re.Value)
}
}
-func (e *cborEncDriver) WriteMapStart(length int) {
- if e.h.IndefiniteLength {
- e.w.writen1(cborBdIndefiniteMap)
- } else {
- e.encLen(cborBaseMap, length)
- }
+func (e *cborEncDriver) EncodeArrayStart(length int) {
+ e.encLen(cborBaseArray, length)
}
-func (e *cborEncDriver) WriteMapEnd() {
- if e.h.IndefiniteLength {
- e.w.writen1(cborBdBreak)
- }
-}
-
-func (e *cborEncDriver) WriteArrayEnd() {
- if e.h.IndefiniteLength {
- e.w.writen1(cborBdBreak)
- }
+func (e *cborEncDriver) EncodeMapStart(length int) {
+ e.encLen(cborBaseMap, length)
}
func (e *cborEncDriver) EncodeString(c charEncoding, v string) {
- e.encStringBytesS(cborBaseString, v)
+ e.encLen(cborBaseString, len(v))
+ e.w.writestr(v)
+}
+
+func (e *cborEncDriver) EncodeSymbol(v string) {
+ e.EncodeString(c_UTF8, v)
}
func (e *cborEncDriver) EncodeStringBytes(c charEncoding, v []byte) {
- if v == nil {
- e.EncodeNil()
- } else if c == cRAW {
- e.encStringBytesS(cborBaseBytes, stringView(v))
+ if c == c_RAW {
+ e.encLen(cborBaseBytes, len(v))
} else {
- e.encStringBytesS(cborBaseString, stringView(v))
- }
-}
-
-func (e *cborEncDriver) encStringBytesS(bb byte, v string) {
- if e.h.IndefiniteLength {
- if bb == cborBaseBytes {
- e.w.writen1(cborBdIndefiniteBytes)
- } else {
- e.w.writen1(cborBdIndefiniteString)
- }
- blen := len(v) / 4
- if blen == 0 {
- blen = 64
- } else if blen > 1024 {
- blen = 1024
- }
- for i := 0; i < len(v); {
- var v2 string
- i2 := i + blen
- if i2 < len(v) {
- v2 = v[i:i2]
- } else {
- v2 = v[i:]
- }
- e.encLen(bb, len(v2))
- e.w.writestr(v2)
- i = i2
- }
- e.w.writen1(cborBdBreak)
- } else {
- e.encLen(bb, len(v))
- e.w.writestr(v)
+ e.encLen(cborBaseString, len(v))
}
+ e.w.writeb(v)
}
// ----------------------
type cborDecDriver struct {
- d *Decoder
- h *CborHandle
- r decReader
- // b [scratchByteArrayLen]byte
+ d *Decoder
+ h *CborHandle
+ r decReader
+ b [scratchByteArrayLen]byte
br bool // bytes reader
bdRead bool
bd byte
noBuiltInTypes
- // decNoSeparator
- decDriverNoopContainerReader
- _ [3]uint64 // padding
+ decNoSeparator
}
func (d *cborDecDriver) readNextBd() {
@@ -309,9 +196,6 @@ func (d *cborDecDriver) uncacheRead() {
}
func (d *cborDecDriver) ContainerType() (vt valueType) {
- if !d.bdRead {
- d.readNextBd()
- }
if d.bd == cborBdNil {
return valueTypeNil
} else if d.bd == cborBdIndefiniteBytes || (d.bd >= cborBaseBytes && d.bd < cborBaseString) {
@@ -322,10 +206,9 @@ func (d *cborDecDriver) ContainerType() (vt valueType) {
return valueTypeArray
} else if d.bd == cborBdIndefiniteMap || (d.bd >= cborBaseMap && d.bd < cborBaseTag) {
return valueTypeMap
+ } else {
+ // d.d.errorf("isContainerType: unsupported parameter: %v", vt)
}
- // else {
- // d.d.errorf("isContainerType: unsupported parameter: %v", vt)
- // }
return valueTypeUnset
}
@@ -366,7 +249,7 @@ func (d *cborDecDriver) decUint() (ui uint64) {
} else if v == 0x1b {
ui = uint64(bigen.Uint64(d.r.readx(8)))
} else {
- d.d.errorf("invalid descriptor decoding uint: %x/%s", d.bd, cbordesc(d.bd))
+ d.d.errorf("decUint: Invalid descriptor: %v", d.bd)
return
}
}
@@ -382,36 +265,52 @@ func (d *cborDecDriver) decCheckInteger() (neg bool) {
} 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))
+ d.d.errorf("invalid major: %v (bd: %v)", major, d.bd)
return
}
return
}
-func (d *cborDecDriver) DecodeInt64() (i int64) {
+func (d *cborDecDriver) DecodeInt(bitsize uint8) (i int64) {
neg := d.decCheckInteger()
ui := d.decUint()
// check if this number can be converted to an int without overflow
+ var overflow bool
if neg {
- i = -(chkOvf.SignedIntV(ui + 1))
+ if i, overflow = chkOvf.SignedInt(ui + 1); overflow {
+ d.d.errorf("cbor: overflow converting %v to signed integer", ui+1)
+ return
+ }
+ i = -i
} else {
- i = chkOvf.SignedIntV(ui)
+ if i, overflow = chkOvf.SignedInt(ui); overflow {
+ d.d.errorf("cbor: overflow converting %v to signed integer", ui)
+ return
+ }
+ }
+ if chkOvf.Int(i, bitsize) {
+ d.d.errorf("cbor: overflow integer: %v", i)
+ return
}
d.bdRead = false
return
}
-func (d *cborDecDriver) DecodeUint64() (ui uint64) {
+func (d *cborDecDriver) DecodeUint(bitsize uint8) (ui uint64) {
if d.decCheckInteger() {
- d.d.errorf("assigning negative signed value to unsigned type")
+ d.d.errorf("Assigning negative signed value to unsigned type")
return
}
ui = d.decUint()
+ if chkOvf.Uint(ui, bitsize) {
+ d.d.errorf("cbor: overflow integer: %v", ui)
+ return
+ }
d.bdRead = false
return
}
-func (d *cborDecDriver) DecodeFloat64() (f float64) {
+func (d *cborDecDriver) DecodeFloat(chkOverflow32 bool) (f float64) {
if !d.bdRead {
d.readNextBd()
}
@@ -422,9 +321,13 @@ func (d *cborDecDriver) DecodeFloat64() (f float64) {
} else if bd == cborBdFloat64 {
f = math.Float64frombits(bigen.Uint64(d.r.readx(8)))
} else if bd >= cborBaseUint && bd < cborBaseBytes {
- f = float64(d.DecodeInt64())
+ f = float64(d.DecodeInt(64))
} else {
- d.d.errorf("float only valid from float16/32/64 - invalid descriptor %x/%s", bd, cbordesc(bd))
+ d.d.errorf("Float only valid from float16/32/64: Invalid descriptor: %v", bd)
+ return
+ }
+ if chkOverflow32 && chkOvf.Float32(f) {
+ d.d.errorf("cbor: float32 overflow: %v", f)
return
}
d.bdRead = false
@@ -440,7 +343,7 @@ func (d *cborDecDriver) DecodeBool() (b bool) {
b = true
} else if bd == cborBdFalse {
} else {
- d.d.errorf("not bool - %s %x/%s", msgBadDesc, d.bd, cbordesc(d.bd))
+ d.d.errorf("Invalid single-byte value for bool: %s: %x", msgBadDesc, d.bd)
return
}
d.bdRead = false
@@ -448,9 +351,6 @@ func (d *cborDecDriver) DecodeBool() (b bool) {
}
func (d *cborDecDriver) ReadMapStart() (length int) {
- if !d.bdRead {
- d.readNextBd()
- }
d.bdRead = false
if d.bd == cborBdIndefiniteMap {
return -1
@@ -459,9 +359,6 @@ func (d *cborDecDriver) ReadMapStart() (length int) {
}
func (d *cborDecDriver) ReadArrayStart() (length int) {
- if !d.bdRead {
- d.readNextBd()
- }
d.bdRead = false
if d.bd == cborBdIndefiniteArray {
return -1
@@ -480,8 +377,7 @@ func (d *cborDecDriver) decAppendIndefiniteBytes(bs []byte) []byte {
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))
+ d.d.errorf("cbor: expect bytes or string major type in indefinite string/bytes; got: %v, byte: %v", major, d.bd)
return nil
}
n := d.decLen()
@@ -502,7 +398,7 @@ func (d *cborDecDriver) decAppendIndefiniteBytes(bs []byte) []byte {
return bs
}
-func (d *cborDecDriver) DecodeBytes(bs []byte, zerocopy bool) (bsOut []byte) {
+func (d *cborDecDriver) DecodeBytes(bs []byte, isstring, zerocopy bool) (bsOut []byte) {
if !d.bdRead {
d.readNextBd()
}
@@ -511,84 +407,25 @@ func (d *cborDecDriver) DecodeBytes(bs []byte, zerocopy bool) (bsOut []byte) {
return nil
}
if d.bd == cborBdIndefiniteBytes || d.bd == cborBdIndefiniteString {
- d.bdRead = false
if bs == nil {
- if zerocopy {
- return d.decAppendIndefiniteBytes(d.d.b[:0])
- }
- return d.decAppendIndefiniteBytes(zeroByteSlice)
+ return d.decAppendIndefiniteBytes(nil)
}
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
- }
clen := d.decLen()
d.bdRead = false
if zerocopy {
if d.br {
return d.r.readx(clen)
} else if len(bs) == 0 {
- bs = d.d.b[:]
+ bs = d.b[:]
}
}
- return decByteSlice(d.r, clen, d.h.MaxInitLen, bs)
+ return decByteSlice(d.r, clen, bs)
}
func (d *cborDecDriver) DecodeString() (s string) {
- return string(d.DecodeBytes(d.d.b[:], true))
-}
-
-func (d *cborDecDriver) DecodeStringAsBytes() (s []byte) {
- return d.DecodeBytes(d.d.b[:], true)
-}
-
-func (d *cborDecDriver) DecodeTime() (t time.Time) {
- if !d.bdRead {
- d.readNextBd()
- }
- if d.bd == cborBdNil || d.bd == cborBdUndefined {
- d.bdRead = false
- return
- }
- 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
- if t, err = time.Parse(time.RFC3339, stringView(d.DecodeStringAsBytes())); err != nil {
- 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)")
- }
- default:
- d.d.errorf("invalid tag for time.Time - expecting 0 or 1, got 0x%x", xtag)
- }
- t = t.UTC().Round(time.Microsecond)
- return
+ return string(d.DecodeBytes(d.b[:], true, true))
}
func (d *cborDecDriver) DecodeExt(rv interface{}, xtag uint64, ext Ext) (realxtag uint64) {
@@ -619,7 +456,7 @@ func (d *cborDecDriver) DecodeNaked() {
d.readNextBd()
}
- n := d.d.n
+ n := &d.d.n
var decodeFurther bool
switch d.bd {
@@ -631,12 +468,15 @@ func (d *cborDecDriver) DecodeNaked() {
case cborBdTrue:
n.v = valueTypeBool
n.b = true
- case cborBdFloat16, cborBdFloat32, cborBdFloat64:
+ case cborBdFloat16, cborBdFloat32:
n.v = valueTypeFloat
- n.f = d.DecodeFloat64()
+ n.f = d.DecodeFloat(true)
+ case cborBdFloat64:
+ n.v = valueTypeFloat
+ n.f = d.DecodeFloat(false)
case cborBdIndefiniteBytes:
n.v = valueTypeBytes
- n.l = d.DecodeBytes(nil, false)
+ n.l = d.DecodeBytes(nil, false, false)
case cborBdIndefiniteString:
n.v = valueTypeString
n.s = d.DecodeString()
@@ -651,17 +491,17 @@ func (d *cborDecDriver) DecodeNaked() {
case d.bd >= cborBaseUint && d.bd < cborBaseNegInt:
if d.h.SignedInteger {
n.v = valueTypeInt
- n.i = d.DecodeInt64()
+ n.i = d.DecodeInt(64)
} else {
n.v = valueTypeUint
- n.u = d.DecodeUint64()
+ n.u = d.DecodeUint(64)
}
case d.bd >= cborBaseNegInt && d.bd < cborBaseBytes:
n.v = valueTypeInt
- n.i = d.DecodeInt64()
+ n.i = d.DecodeInt(64)
case d.bd >= cborBaseBytes && d.bd < cborBaseString:
n.v = valueTypeBytes
- n.l = d.DecodeBytes(nil, false)
+ n.l = d.DecodeBytes(nil, false, false)
case d.bd >= cborBaseString && d.bd < cborBaseArray:
n.v = valueTypeString
n.s = d.DecodeString()
@@ -675,11 +515,6 @@ func (d *cborDecDriver) DecodeNaked() {
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
@@ -710,29 +545,30 @@ func (d *cborDecDriver) DecodeNaked() {
//
// None of the optional extensions (with tags) defined in the spec are supported out-of-the-box.
// Users can implement them as needed (using SetExt), including spec-documented ones:
-// - timestamp, BigNum, BigFloat, Decimals,
-// - Encoded Text (e.g. URL, regexp, base64, MIME Message), etc.
+// - timestamp, BigNum, BigFloat, Decimals, Encoded Text (e.g. URL, regexp, base64, MIME Message), etc.
+//
+// To encode with indefinite lengths (streaming), users will use
+// (Must)Encode methods of *Encoder, along with writing CborStreamXXX constants.
+//
+// For example, to encode "one-byte" as an indefinite length string:
+// var buf bytes.Buffer
+// e := NewEncoder(&buf, new(CborHandle))
+// buf.WriteByte(CborStreamString)
+// e.MustEncode("one-")
+// e.MustEncode("byte")
+// buf.WriteByte(CborStreamBreak)
+// encodedBytes := buf.Bytes()
+// var vv interface{}
+// NewDecoderBytes(buf.Bytes(), new(CborHandle)).MustDecode(&vv)
+// // Now, vv contains the same string "one-byte"
+//
type CborHandle struct {
binaryEncodingType
- noElemSeparators
BasicHandle
-
- // IndefiniteLength=true, means that we encode using indefinitelength
- IndefiniteLength bool
-
- // TimeRFC3339 says to encode time.Time using RFC3339 format.
- // If unset, we encode time.Time using seconds past epoch.
- TimeRFC3339 bool
-
- // _ [1]uint64 // padding
}
-// 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})
+ return h.SetExt(rt, tag, &setExtWrapper{i: ext})
}
func (h *CborHandle) newEncDriver(e *Encoder) encDriver {
@@ -740,7 +576,7 @@ func (h *CborHandle) newEncDriver(e *Encoder) encDriver {
}
func (h *CborHandle) newDecDriver(d *Decoder) decDriver {
- return &cborDecDriver{d: d, h: h, r: d.r, br: d.bytes}
+ return &cborDecDriver{d: d, r: d.r, h: h, br: d.bytes}
}
func (e *cborEncDriver) reset() {
@@ -748,7 +584,7 @@ func (e *cborEncDriver) reset() {
}
func (d *cborDecDriver) reset() {
- d.r, d.br = d.d.r, d.d.bytes
+ d.r = d.d.r
d.bd, d.bdRead = 0, false
}
diff --git a/vendor/github.com/ugorji/go/codec/decode.go b/vendor/github.com/ugorji/go/codec/decode.go
index c8be0bc568..52c1dfe836 100644
--- a/vendor/github.com/ugorji/go/codec/decode.go
+++ b/vendor/github.com/ugorji/go/codec/decode.go
@@ -1,4 +1,4 @@
-// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved.
+// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved.
// Use of this source code is governed by a MIT license found in the LICENSE file.
package codec
@@ -9,33 +9,18 @@ import (
"fmt"
"io"
"reflect"
- "strconv"
- "sync"
"time"
)
// Some tagging information for error messages.
const (
- msgBadDesc = "unrecognized descriptor byte"
+ msgBadDesc = "Unrecognized descriptor byte"
msgDecCannotExpandArr = "cannot expand go array from %v to stream length: %v"
)
-const decDefSliceCap = 8
-const decDefChanCap = 64 // should be large, as cap cannot be expanded
-const decScratchByteArrayLen = cacheLineSize - 8
-
var (
- errstrOnlyMapOrArrayCanDecodeIntoStruct = "only encoded map or array can be decoded into a struct"
- errstrCannotDecodeIntoNil = "cannot decode into nil"
-
- errmsgExpandSliceOverflow = "expand slice: slice overflow"
- errmsgExpandSliceCannotChange = "expand slice: cannot change"
-
- errDecoderNotInitialized = errors.New("Decoder not initialized")
-
- errDecUnreadByteNothingToRead = errors.New("cannot unread - nothing has been read")
- errDecUnreadByteLastByteNotRead = errors.New("cannot unread - last byte has not been read")
- errDecUnreadByteUnknown = errors.New("cannot unread - reason unknown")
+ onlyMapOrArrayCanDecodeIntoStructErr = errors.New("only encoded map or array can be decoded into a struct")
+ cannotDecodeIntoNilErr = errors.New("cannot decode into nil")
)
// decReader abstracts the reading source, allowing implementations that can
@@ -49,29 +34,25 @@ type decReader interface {
readx(n int) []byte
readb([]byte)
readn1() uint8
+ readn1eof() (v uint8, eof bool)
numread() int // 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)
+type decReaderByteScanner interface {
+ io.Reader
+ io.ByteScanner
}
type decDriver interface {
// this will check if the next token is a break.
CheckBreak() bool
- // 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
// vt is one of: Bytes, String, Nil, Slice or Map. Return unSet if not known.
ContainerType() (vt valueType)
- // IsBuiltinType(rt uintptr) bool
+ IsBuiltinType(rt uintptr) bool
+ DecodeBuiltin(rt uintptr, v interface{})
// 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
@@ -85,15 +66,9 @@ type decDriver interface {
// extensions should also use readx to decode them, for efficiency.
// 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)
+ DecodeInt(bitsize uint8) (i int64)
+ DecodeUint(bitsize uint8) (ui uint64)
+ DecodeFloat(chkOverflow32 bool) (f float64)
DecodeBool() (b bool)
// DecodeString can also decode symbols.
// It looks redundant as DecodeBytes is available.
@@ -101,69 +76,45 @@ type decDriver interface {
// return a pre-stored string value, meaning that it can bypass
// the cost of []byte->string conversion.
DecodeString() (s string)
- DecodeStringAsBytes() (v []byte)
// DecodeBytes may be called directly, without going through reflection.
// Consequently, it must be designed to handle possible nil.
- DecodeBytes(bs []byte, zerocopy bool) (bsOut []byte)
- // DecodeBytes(bs []byte, isstring, 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(verifyTag bool, tag byte) (xtag byte, xbs []byte)
-
- DecodeTime() (t time.Time)
-
- ReadArrayStart() int
- ReadArrayElem()
- ReadArrayEnd()
ReadMapStart() int
- ReadMapElemKey()
- ReadMapElemValue()
- ReadMapEnd()
+ ReadArrayStart() int
reset()
uncacheRead()
}
-type decDriverNoopContainerReader struct{}
+type decNoSeparator 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 (_ decNoSeparator) ReadEnd() {}
-// func (x decNoSeparator) uncacheRead() {}
+// func (_ decNoSeparator) uncacheRead() {}
-// DecodeOptions captures configuration options during decode.
type DecodeOptions struct {
// MapType specifies type to use during schema-less decoding of a map in the stream.
- // If nil (unset), we default to map[string]interface{} iff json handle and MapStringAsKey=true,
- // else map[interface{}]interface{}.
+ // If nil, we use map[interface{}]interface{}
MapType reflect.Type
// SliceType specifies type to use during schema-less decoding of an array in the stream.
- // If nil (unset), we default to []interface{} for all formats.
+ // If nil, we use []interface{}
SliceType reflect.Type
- // MaxInitLen defines the maxinum initial length that we "make" a collection
- // (string, slice, map, chan). If 0 or negative, we default to a sensible value
- // based on the size of an element in the collection.
+ // MaxInitLen defines the initial length that we "make" a collection (slice, chan or map) with.
+ // If 0 or negative, we default to a sensible value based on the size of an element in the collection.
//
- // For example, when decoding, a stream may say that it has 2^64 elements.
- // We should not auto-matically provision a slice of that size, to prevent Out-Of-Memory crash.
+ // For example, when decoding, a stream may say that it has MAX_UINT elements.
+ // We should not auto-matically provision a slice of that length, to prevent Out-Of-Memory crash.
// Instead, we provision up to MaxInitLen, fill that up, and start appending after that.
MaxInitLen int
- // ReaderBufferSize is the size of the buffer used when reading.
- //
- // if > 0, we use a smart buffer internally for performance purposes.
- ReaderBufferSize int
-
// If ErrorIfNoField, return an error when decoding a map
// from a codec stream into a struct, and no matching struct field is found.
ErrorIfNoField bool
@@ -190,11 +141,6 @@ type DecodeOptions struct {
// or is an interface.
MapValueReset bool
- // SliceElementReset: on decoding a slice, reset the element to a zero value first.
- //
- // concern: if the slice already contained some garbage, we will decode into that garbage.
- SliceElementReset bool
-
// InterfaceReset controls how we decode into an interface.
//
// By default, when we see a field that is an interface{...},
@@ -215,9 +161,7 @@ type DecodeOptions struct {
// look them up from a map (than to allocate them afresh).
//
// Note: Handles will be smart when using the intern functionality.
- // Every string should not be interned.
- // An excellent use-case for interning is struct field names,
- // or map keys where key type is string.
+ // So everything will not be interned.
InternString bool
// PreferArrayOverSlice controls whether to decode to an array or a slice.
@@ -228,355 +172,20 @@ type DecodeOptions struct {
// *Note*: This only applies if using go1.5 and above,
// as it requires reflect.ArrayOf support which was absent before go1.5.
PreferArrayOverSlice bool
-
- // DeleteOnNilMapValue controls how to decode a nil value in the stream.
- //
- // If true, we will delete the mapping of the key.
- // Else, just set the mapping to the zero value of the type.
- DeleteOnNilMapValue bool
}
// ------------------------------------
-type bufioDecReader struct {
- buf []byte
- r io.Reader
-
- c int // cursor
- n int // num read
- err error
-
- tr []byte
- trb bool
- b [4]byte
+// ioDecByteScanner implements Read(), ReadByte(...), UnreadByte(...) methods
+// of io.Reader, io.ByteScanner.
+type ioDecByteScanner struct {
+ r io.Reader
+ l byte // last byte
+ ls byte // last byte status. 0: init-canDoNothing, 1: canRead, 2: canUnread
+ b [1]byte // tiny buffer for reading single bytes
}
-func (z *bufioDecReader) reset(r io.Reader) {
- z.r, z.c, z.n, z.err, z.trb = r, 0, 0, nil, false
- if z.tr != nil {
- z.tr = z.tr[:0]
- }
-}
-
-func (z *bufioDecReader) Read(p []byte) (n int, err error) {
- if z.err != nil {
- return 0, z.err
- }
- p0 := p
- n = copy(p, z.buf[z.c:])
- z.c += n
- if z.c == len(z.buf) {
- z.c = 0
- }
- z.n += n
- if len(p) == n {
- 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]...)
- }
- return
- }
- p = p[n:]
- var n2 int
- // if we are here, then z.buf is all read
- if len(p) > len(z.buf) {
- n2, err = decReadFull(z.r, p)
- n += n2
- z.n += n2
- z.err = err
- // don't return EOF if some bytes were read. keep for next time.
- if n > 0 && err == io.EOF {
- err = nil
- }
- // 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) <= len(z.buf)
- for len(p) > 0 && z.err == nil {
- // println("len(p) loop starting ... ")
- z.c = 0
- z.buf = z.buf[0:cap(z.buf)]
- n2, err = z.r.Read(z.buf)
- if n2 > 0 {
- if err == io.EOF {
- err = nil
- }
- z.buf = z.buf[:n2]
- n2 = copy(p, z.buf)
- z.c = n2
- n += n2
- z.n += n2
- p = p[n2:]
- }
- z.err = err
- // println("... len(p) loop done")
- }
- 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]...)
- }
- return
-}
-
-func (z *bufioDecReader) ReadByte() (b byte, err error) {
- z.b[0] = 0
- _, err = z.Read(z.b[:1])
- b = z.b[0]
- return
-}
-
-func (z *bufioDecReader) UnreadByte() (err error) {
- if z.err != nil {
- return z.err
- }
- if z.c > 0 {
- z.c--
- z.n--
- if z.trb {
- z.tr = z.tr[:len(z.tr)-1]
- }
- return
- }
- return errDecUnreadByteNothingToRead
-}
-
-func (z *bufioDecReader) numread() int {
- return z.n
-}
-
-func (z *bufioDecReader) readx(n int) (bs []byte) {
- if n <= 0 || z.err != nil {
- return
- }
- if z.c+n <= 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...)
- }
- return
- }
- bs = make([]byte, n)
- _, err := z.Read(bs)
- if err != nil {
- panic(err)
- }
- return
-}
-
-func (z *bufioDecReader) readb(bs []byte) {
- _, err := z.Read(bs)
- if err != nil {
- panic(err)
- }
-}
-
-// func (z *bufioDecReader) readn1eof() (b uint8, eof bool) {
-// b, err := z.ReadByte()
-// if err != nil {
-// if err == io.EOF {
-// eof = true
-// } else {
-// panic(err)
-// }
-// }
-// return
-// }
-
-func (z *bufioDecReader) readn1() (b uint8) {
- b, err := z.ReadByte()
- if err != nil {
- panic(err)
- }
- return
-}
-
-func (z *bufioDecReader) search(in []byte, accept *bitset256, stop, flag uint8) (token byte, out []byte) {
- // flag: 1 (skip), 2 (readTo), 4 (readUntil)
- if flag == 4 {
- for i := z.c; i < len(z.buf); i++ {
- if z.buf[i] == stop {
- token = z.buf[i]
- z.n = 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.c = i
- return
- }
- }
- } else {
- for i := z.c; i < len(z.buf); i++ {
- if !accept.isset(z.buf[i]) {
- token = z.buf[i]
- z.n = z.n + (i - z.c) - 1
- if flag == 1 {
- i++
- } else {
- out = z.buf[z.c:i]
- }
- if z.trb {
- z.tr = append(z.tr, z.buf[z.c:i]...)
- }
- z.c = i
- return
- }
- }
- }
- z.n += len(z.buf) - z.c
- if flag != 1 {
- out = append(in, z.buf[z.c:]...)
- }
- if z.trb {
- z.tr = append(z.tr, z.buf[z.c:]...)
- }
- var n2 int
- if z.err != nil {
- return
- }
- for {
- z.c = 0
- z.buf = z.buf[0:cap(z.buf)]
- n2, z.err = z.r.Read(z.buf)
- if n2 > 0 && z.err != nil {
- z.err = nil
- }
- z.buf = z.buf[:n2]
- if flag == 4 {
- for i := 0; i < n2; i++ {
- if z.buf[i] == stop {
- token = z.buf[i]
- z.n += i - 1
- i++
- out = append(out, z.buf[z.c:i]...)
- if z.trb {
- z.tr = append(z.tr, z.buf[z.c:i]...)
- }
- z.c = i
- return
- }
- }
- } else {
- for i := 0; i < n2; i++ {
- if !accept.isset(z.buf[i]) {
- token = z.buf[i]
- z.n += i - 1
- if flag == 1 {
- i++
- }
- if flag != 1 {
- out = append(out, z.buf[z.c:i]...)
- }
- if z.trb {
- z.tr = append(z.tr, z.buf[z.c:i]...)
- }
- z.c = i
- return
- }
- }
- }
- if flag != 1 {
- out = append(out, z.buf[:n2]...)
- }
- z.n += n2
- if z.err != nil {
- return
- }
- if z.trb {
- z.tr = append(z.tr, z.buf[:n2]...)
- }
- }
-}
-
-func (z *bufioDecReader) skip(accept *bitset256) (token byte) {
- token, _ = z.search(nil, accept, 0, 1)
- return
-}
-
-func (z *bufioDecReader) readTo(in []byte, accept *bitset256) (out []byte) {
- _, out = z.search(in, accept, 0, 2)
- return
-}
-
-func (z *bufioDecReader) readUntil(in []byte, stop byte) (out []byte) {
- _, out = z.search(in, nil, stop, 4)
- return
-}
-
-func (z *bufioDecReader) unreadn1() {
- err := z.UnreadByte()
- if err != nil {
- panic(err)
- }
-}
-
-func (z *bufioDecReader) track() {
- if z.tr != nil {
- z.tr = z.tr[:0]
- }
- z.trb = true
-}
-
-func (z *bufioDecReader) 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 {
- r io.Reader // the reader passed in
-
- rr io.Reader
- br io.ByteScanner
-
- l byte // last byte
- ls byte // last byte status. 0: init-canDoNothing, 1: canRead, 2: canUnread
- trb bool // tracking bytes turned on
- _ bool
- b [4]byte // tiny buffer for reading single bytes
-
- x [scratchByteArrayLen]byte // for: get struct field name, swallow valueTypeBytes, etc
- n int // num read
- tr []byte // tracking bytes read
-}
-
-func (z *ioDecReader) reset(r io.Reader) {
- z.r = r
- z.rr = r
- z.l, z.ls, z.n, z.trb = 0, 0, 0, false
- if z.tr != nil {
- z.tr = z.tr[:0]
- }
- var ok bool
- if z.br, ok = r.(io.ByteScanner); !ok {
- z.br = z
- z.rr = z
- }
-}
-
-func (z *ioDecReader) Read(p []byte) (n int, err error) {
- if len(p) == 0 {
- return
- }
+func (z *ioDecByteScanner) Read(p []byte) (n int, err error) {
var firstByte bool
if z.ls == 1 {
z.ls = 2
@@ -602,8 +211,8 @@ func (z *ioDecReader) Read(p []byte) (n int, err error) {
return
}
-func (z *ioDecReader) ReadByte() (c byte, err error) {
- n, err := z.Read(z.b[:1])
+func (z *ioDecByteScanner) ReadByte() (c byte, err error) {
+ n, err := z.Read(z.b[:])
if n == 1 {
c = z.b[0]
if err == io.EOF {
@@ -613,20 +222,30 @@ func (z *ioDecReader) ReadByte() (c byte, err error) {
return
}
-func (z *ioDecReader) UnreadByte() (err error) {
- switch z.ls {
- case 2:
+func (z *ioDecByteScanner) UnreadByte() (err error) {
+ x := z.ls
+ if x == 0 {
+ err = errors.New("cannot unread - nothing has been read")
+ } else if x == 1 {
+ err = errors.New("cannot unread - last byte has not been read")
+ } else if x == 2 {
z.ls = 1
- case 0:
- err = errDecUnreadByteNothingToRead
- case 1:
- err = errDecUnreadByteLastByteNotRead
- default:
- err = errDecUnreadByteUnknown
}
return
}
+// ioDecReader is a decReader that reads off an io.Reader
+type ioDecReader struct {
+ br decReaderByteScanner
+ // temp byte array re-used internally for efficiency during read.
+ // shares buffer with Decoder, so we keep size of struct within 8 words.
+ x *[scratchByteArrayLen]byte
+ bs ioDecByteScanner
+ n int // num read
+ tr []byte // tracking bytes read
+ trb bool
+}
+
func (z *ioDecReader) numread() int {
return z.n
}
@@ -640,7 +259,7 @@ func (z *ioDecReader) readx(n int) (bs []byte) {
} else {
bs = make([]byte, n)
}
- if _, err := decReadFull(z.rr, bs); err != nil {
+ if _, err := io.ReadAtLeast(z.br, bs, n); err != nil {
panic(err)
}
z.n += len(bs)
@@ -651,18 +270,31 @@ func (z *ioDecReader) readx(n int) (bs []byte) {
}
func (z *ioDecReader) readb(bs []byte) {
- // if len(bs) == 0 {
- // return
- // }
- if _, err := decReadFull(z.rr, bs); err != nil {
+ if len(bs) == 0 {
+ return
+ }
+ n, err := io.ReadAtLeast(z.br, bs, len(bs))
+ z.n += n
+ if err != nil {
panic(err)
}
- z.n += len(bs)
if z.trb {
z.tr = append(z.tr, bs...)
}
}
+func (z *ioDecReader) readn1() (b uint8) {
+ b, err := z.br.ReadByte()
+ if err != nil {
+ panic(err)
+ }
+ z.n++
+ if z.trb {
+ z.tr = append(z.tr, b)
+ }
+ return b
+}
+
func (z *ioDecReader) readn1eof() (b uint8, eof bool) {
b, err := z.br.ReadByte()
if err == nil {
@@ -678,62 +310,6 @@ func (z *ioDecReader) readn1eof() (b uint8, eof bool) {
return
}
-func (z *ioDecReader) readn1() (b uint8) {
- var err error
- if b, err = z.br.ReadByte(); err == nil {
- z.n++
- if z.trb {
- z.tr = append(z.tr, b)
- }
- return
- }
- panic(err)
-}
-
-func (z *ioDecReader) skip(accept *bitset256) (token byte) {
- for {
- var eof bool
- token, eof = z.readn1eof()
- if eof {
- return
- }
- if accept.isset(token) {
- continue
- }
- return
- }
-}
-
-func (z *ioDecReader) readTo(in []byte, accept *bitset256) (out []byte) {
- out = in
- for {
- token, eof := z.readn1eof()
- if eof {
- return
- }
- if accept.isset(token) {
- out = append(out, token)
- } else {
- z.unreadn1()
- return
- }
- }
-}
-
-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
- }
- }
-}
-
func (z *ioDecReader) unreadn1() {
err := z.br.UnreadByte()
if err != nil {
@@ -761,7 +337,7 @@ func (z *ioDecReader) stopTrack() (bs []byte) {
// ------------------------------------
-var errBytesDecReaderCannotUnread = errors.New("cannot unread last byte read")
+var bytesDecReaderCannotUnreadErr = errors.New("cannot unread last byte read")
// bytesDecReader is a decReader that reads off a byte slice with zero copying
type bytesDecReader struct {
@@ -784,7 +360,7 @@ func (z *bytesDecReader) numread() int {
func (z *bytesDecReader) unreadn1() {
if z.c == 0 || len(z.b) == 0 {
- panic(errBytesDecReaderCannotUnread)
+ panic(bytesDecReaderCannotUnreadErr)
}
z.c--
z.a++
@@ -810,10 +386,6 @@ func (z *bytesDecReader) readx(n int) (bs []byte) {
return
}
-func (z *bytesDecReader) readb(bs []byte) {
- copy(bs, z.readx(len(bs)))
-}
-
func (z *bytesDecReader) readn1() (v uint8) {
if z.a == 0 {
panic(io.EOF)
@@ -824,69 +396,19 @@ func (z *bytesDecReader) readn1() (v uint8) {
return
}
-// func (z *bytesDecReader) readn1eof() (v uint8, eof bool) {
-// if z.a == 0 {
-// eof = true
-// return
-// }
-// v = z.b[z.c]
-// z.c++
-// z.a--
-// return
-// }
-
-func (z *bytesDecReader) skip(accept *bitset256) (token byte) {
+func (z *bytesDecReader) readn1eof() (v uint8, eof bool) {
if z.a == 0 {
+ eof = true
return
}
- blen := len(z.b)
- 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
- }
- }
- z.a, z.c = 0, blen
+ v = z.b[z.c]
+ z.c++
+ z.a--
return
}
-func (z *bytesDecReader) readTo(_ []byte, accept *bitset256) (out []byte) {
- if z.a == 0 {
- return
- }
- blen := len(z.b)
- 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
-}
-
-func (z *bytesDecReader) readUntil(_ []byte, stop byte) (out []byte) {
- if z.a == 0 {
- panic(io.EOF)
- }
- blen := len(z.b)
- 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
- }
- }
- z.a, z.c = 0, blen
- panic(io.EOF)
+func (z *bytesDecReader) readb(bs []byte) {
+ copy(bs, z.readx(len(bs)))
}
func (z *bytesDecReader) track() {
@@ -897,66 +419,172 @@ func (z *bytesDecReader) stopTrack() (bs []byte) {
return z.b[z.t:z.c]
}
+// ------------------------------------
+
+type decFnInfo struct {
+ d *Decoder
+ ti *typeInfo
+ xfFn Ext
+ xfTag uint64
+ seq seqType
+}
+
// ----------------------------------------
-// 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)
+type decFn struct {
+ i decFnInfo
+ f func(*decFnInfo, reflect.Value)
}
-func (d *Decoder) ext(f *codecFnInfo, rv reflect.Value) {
- d.d.DecodeExt(rv2i(rv), f.xfTag, f.xfFn)
+func (f *decFnInfo) builtin(rv reflect.Value) {
+ f.d.d.DecodeBuiltin(f.ti.rtid, rv.Addr().Interface())
}
-func (d *Decoder) selferUnmarshal(f *codecFnInfo, rv reflect.Value) {
- rv2i(rv).(Selfer).CodecDecodeSelf(d)
+func (f *decFnInfo) rawExt(rv reflect.Value) {
+ f.d.d.DecodeExt(rv.Addr().Interface(), 0, nil)
}
-func (d *Decoder) binaryUnmarshal(f *codecFnInfo, rv reflect.Value) {
- bm := rv2i(rv).(encoding.BinaryUnmarshaler)
- xbs := d.d.DecodeBytes(nil, true)
+func (f *decFnInfo) raw(rv reflect.Value) {
+ rv.SetBytes(f.d.raw())
+}
+
+func (f *decFnInfo) ext(rv reflect.Value) {
+ f.d.d.DecodeExt(rv.Addr().Interface(), f.xfTag, f.xfFn)
+}
+
+func (f *decFnInfo) getValueForUnmarshalInterface(rv reflect.Value, indir int8) (v interface{}) {
+ if indir == -1 {
+ v = rv.Addr().Interface()
+ } else if indir == 0 {
+ v = rv.Interface()
+ } else {
+ for j := int8(0); j < indir; j++ {
+ if rv.IsNil() {
+ rv.Set(reflect.New(rv.Type().Elem()))
+ }
+ rv = rv.Elem()
+ }
+ v = rv.Interface()
+ }
+ return
+}
+
+func (f *decFnInfo) selferUnmarshal(rv reflect.Value) {
+ f.getValueForUnmarshalInterface(rv, f.ti.csIndir).(Selfer).CodecDecodeSelf(f.d)
+}
+
+func (f *decFnInfo) binaryUnmarshal(rv reflect.Value) {
+ bm := f.getValueForUnmarshalInterface(rv, f.ti.bunmIndir).(encoding.BinaryUnmarshaler)
+ xbs := f.d.d.DecodeBytes(nil, false, true)
if fnerr := bm.UnmarshalBinary(xbs); fnerr != nil {
panic(fnerr)
}
}
-func (d *Decoder) textUnmarshal(f *codecFnInfo, rv reflect.Value) {
- tm := rv2i(rv).(encoding.TextUnmarshaler)
- fnerr := tm.UnmarshalText(d.d.DecodeStringAsBytes())
+func (f *decFnInfo) textUnmarshal(rv reflect.Value) {
+ tm := f.getValueForUnmarshalInterface(rv, f.ti.tunmIndir).(encoding.TextUnmarshaler)
+ fnerr := tm.UnmarshalText(f.d.d.DecodeBytes(f.d.b[:], true, true))
if fnerr != nil {
panic(fnerr)
}
}
-func (d *Decoder) jsonUnmarshal(f *codecFnInfo, rv reflect.Value) {
- tm := rv2i(rv).(jsonUnmarshaler)
- // bs := d.d.DecodeBytes(d.b[:], true, true)
+func (f *decFnInfo) jsonUnmarshal(rv reflect.Value) {
+ tm := f.getValueForUnmarshalInterface(rv, f.ti.junmIndir).(jsonUnmarshaler)
+ // bs := f.d.d.DecodeBytes(f.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())
+ fnerr := tm.UnmarshalJSON(f.d.nextValueBytes())
if fnerr != nil {
panic(fnerr)
}
}
-func (d *Decoder) kErr(f *codecFnInfo, rv reflect.Value) {
- d.errorf("no decoding function defined for kind %v", rv.Kind())
+func (f *decFnInfo) kErr(rv reflect.Value) {
+ f.d.errorf("no decoding function defined for kind %v", rv.Kind())
}
+func (f *decFnInfo) kString(rv reflect.Value) {
+ rv.SetString(f.d.d.DecodeString())
+}
+
+func (f *decFnInfo) kBool(rv reflect.Value) {
+ rv.SetBool(f.d.d.DecodeBool())
+}
+
+func (f *decFnInfo) kInt(rv reflect.Value) {
+ rv.SetInt(f.d.d.DecodeInt(intBitsize))
+}
+
+func (f *decFnInfo) kInt64(rv reflect.Value) {
+ rv.SetInt(f.d.d.DecodeInt(64))
+}
+
+func (f *decFnInfo) kInt32(rv reflect.Value) {
+ rv.SetInt(f.d.d.DecodeInt(32))
+}
+
+func (f *decFnInfo) kInt8(rv reflect.Value) {
+ rv.SetInt(f.d.d.DecodeInt(8))
+}
+
+func (f *decFnInfo) kInt16(rv reflect.Value) {
+ rv.SetInt(f.d.d.DecodeInt(16))
+}
+
+func (f *decFnInfo) kFloat32(rv reflect.Value) {
+ rv.SetFloat(f.d.d.DecodeFloat(true))
+}
+
+func (f *decFnInfo) kFloat64(rv reflect.Value) {
+ rv.SetFloat(f.d.d.DecodeFloat(false))
+}
+
+func (f *decFnInfo) kUint8(rv reflect.Value) {
+ rv.SetUint(f.d.d.DecodeUint(8))
+}
+
+func (f *decFnInfo) kUint64(rv reflect.Value) {
+ rv.SetUint(f.d.d.DecodeUint(64))
+}
+
+func (f *decFnInfo) kUint(rv reflect.Value) {
+ rv.SetUint(f.d.d.DecodeUint(uintBitsize))
+}
+
+func (f *decFnInfo) kUintptr(rv reflect.Value) {
+ rv.SetUint(f.d.d.DecodeUint(uintBitsize))
+}
+
+func (f *decFnInfo) kUint32(rv reflect.Value) {
+ rv.SetUint(f.d.d.DecodeUint(32))
+}
+
+func (f *decFnInfo) kUint16(rv reflect.Value) {
+ rv.SetUint(f.d.d.DecodeUint(16))
+}
+
+// func (f *decFnInfo) kPtr(rv reflect.Value) {
+// debugf(">>>>>>> ??? decode kPtr called - shouldn't get called")
+// if rv.IsNil() {
+// rv.Set(reflect.New(rv.Type().Elem()))
+// }
+// f.d.decodeValue(rv.Elem())
+// }
+
// var kIntfCtr uint64
-func (d *Decoder) kInterfaceNaked(f *codecFnInfo) (rvn reflect.Value) {
+func (f *decFnInfo) kInterfaceNaked() (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 := f.d
d.d.DecodeNaked()
+ n := &d.n
if n.v == valueTypeNil {
return
}
// We cannot decode non-nil stream value into nil interface with methods (e.g. io.Reader).
+ // if num := f.ti.rt.NumMethod(); num > 0 {
if f.ti.numMeth > 0 {
d.errorf("cannot decode non-nil codec value into nil %v (%v methods)", f.ti.rt, f.ti.numMeth)
return
@@ -964,311 +592,268 @@ func (d *Decoder) kInterfaceNaked(f *codecFnInfo) (rvn reflect.Value) {
// var useRvn bool
switch n.v {
case valueTypeMap:
- // if json, default to a map type with string keys
- mtid := d.mtid
- if mtid == 0 {
- if d.jsms {
- mtid = mapStrIntfTypId
- } else {
- mtid = mapIntfIntfTypId
- }
- }
- if mtid == mapIntfIntfTypId {
- n.initContainers()
- if n.lm < arrayCacheLen {
- n.ma[n.lm] = nil
- rvn = n.rma[n.lm]
- n.lm++
- d.decode(&n.ma[n.lm-1])
- n.lm--
- } else {
- var v2 map[interface{}]interface{}
- d.decode(&v2)
- rvn = reflect.ValueOf(&v2).Elem()
- }
- } else if mtid == mapStrIntfTypId { // for json performance
- n.initContainers()
- if n.ln < arrayCacheLen {
- n.na[n.ln] = nil
- rvn = n.rna[n.ln]
- n.ln++
- d.decode(&n.na[n.ln-1])
- n.ln--
- } else {
- var v2 map[string]interface{}
- d.decode(&v2)
- rvn = reflect.ValueOf(&v2).Elem()
- }
+ // if d.h.MapType == nil || d.h.MapType == mapIntfIntfTyp {
+ // } else if d.h.MapType == mapStrIntfTyp { // for json performance
+ // }
+ if d.mtid == 0 || d.mtid == mapIntfIntfTypId {
+ l := len(n.ms)
+ n.ms = append(n.ms, nil)
+ var v2 interface{} = &n.ms[l]
+ d.decode(v2)
+ rvn = reflect.ValueOf(v2).Elem()
+ n.ms = n.ms[:l]
+ } else if d.mtid == mapStrIntfTypId { // for json performance
+ l := len(n.ns)
+ n.ns = append(n.ns, nil)
+ var v2 interface{} = &n.ns[l]
+ d.decode(v2)
+ rvn = reflect.ValueOf(v2).Elem()
+ n.ns = n.ns[:l]
} 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 = reflect.New(d.h.MapType).Elem()
+ d.decodeValue(rvn, nil)
}
case valueTypeArray:
+ // if d.h.SliceType == nil || d.h.SliceType == intfSliceTyp {
if d.stid == 0 || d.stid == intfSliceTypId {
- n.initContainers()
- if n.ls < arrayCacheLen {
- n.sa[n.ls] = nil
- rvn = n.rsa[n.ls]
- n.ls++
- d.decode(&n.sa[n.ls-1])
- n.ls--
- } else {
- var v2 []interface{}
- d.decode(&v2)
- rvn = reflect.ValueOf(&v2).Elem()
- }
+ l := len(n.ss)
+ n.ss = append(n.ss, nil)
+ var v2 interface{} = &n.ss[l]
+ d.decode(v2)
+ n.ss = n.ss[:l]
+ 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 = reflectArrayOf(rvn)
}
} 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 = reflect.New(d.h.SliceType).Elem()
+ d.decodeValue(rvn, nil)
}
case valueTypeExt:
var v interface{}
tag, bytes := n.u, n.l // calling decode below might taint the values
if bytes == nil {
- n.initContainers()
- if n.li < arrayCacheLen {
- n.ia[n.li] = nil
- n.li++
- d.decode(&n.ia[n.li-1])
- // v = *(&n.ia[l])
- n.li--
- v = n.ia[n.li]
- n.ia[n.li] = nil
- } else {
- d.decode(&v)
- }
+ l := len(n.is)
+ n.is = append(n.is, nil)
+ v2 := &n.is[l]
+ d.decode(v2)
+ v = *v2
+ n.is = n.is[:l]
}
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()
+ rvn = reflect.ValueOf(re)
} else {
rvnA := reflect.New(bfn.rt)
- if bytes != nil {
- bfn.ext.ReadExt(rv2i(rvnA), bytes)
- } else {
- bfn.ext.UpdateExt(rv2i(rvnA), v)
- }
rvn = rvnA.Elem()
+ if bytes != nil {
+ bfn.ext.ReadExt(rvnA.Interface(), bytes)
+ } else {
+ bfn.ext.UpdateExt(rvnA.Interface(), v)
+ }
}
case valueTypeNil:
// no-op
case valueTypeInt:
- rvn = n.ri
+ rvn = reflect.ValueOf(&n.i).Elem()
case valueTypeUint:
- rvn = n.ru
+ rvn = reflect.ValueOf(&n.u).Elem()
case valueTypeFloat:
- rvn = n.rf
+ rvn = reflect.ValueOf(&n.f).Elem()
case valueTypeBool:
- rvn = n.rb
+ rvn = reflect.ValueOf(&n.b).Elem()
case valueTypeString, valueTypeSymbol:
- rvn = n.rs
+ rvn = reflect.ValueOf(&n.s).Elem()
case valueTypeBytes:
- rvn = n.rl
- case valueTypeTime:
- rvn = n.rt
+ rvn = reflect.ValueOf(&n.l).Elem()
+ case valueTypeTimestamp:
+ rvn = reflect.ValueOf(&n.t).Elem()
default:
- panicv.errorf("kInterfaceNaked: unexpected valueType: %d", n.v)
+ panic(fmt.Errorf("kInterfaceNaked: unexpected valueType: %d", n.v))
}
return
}
-func (d *Decoder) kInterface(f *codecFnInfo, rv reflect.Value) {
+func (f *decFnInfo) kInterface(rv reflect.Value) {
+ // debugf("\t===> kInterface")
+
// Note:
// A consequence of how kInterface works, is that
// if an interface already contains something, we try
// to decode into what was there before.
// We do not replace with a generic value (as got from decodeNaked).
- // every interface passed here MUST be settable.
var rvn reflect.Value
- if rv.IsNil() || d.h.InterfaceReset {
- // check if mapping to a type: if so, initialize it and move on
- rvn = d.h.intf2impl(f.ti.rtid)
+ if rv.IsNil() {
+ rvn = f.kInterfaceNaked()
+ if rvn.IsValid() {
+ rv.Set(rvn)
+ }
+ } else if f.d.h.InterfaceReset {
+ rvn = f.kInterfaceNaked()
if rvn.IsValid() {
rv.Set(rvn)
} else {
- rvn = d.kInterfaceNaked(f)
- 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()))
- }
- return
+ // reset to zero value based on current type in there.
+ rv.Set(reflect.Zero(rv.Elem().Type()))
}
} else {
- // now we have a non-nil interface value, meaning it contains a type
rvn = rv.Elem()
+ // Note: interface{} is settable, but underlying type may not be.
+ // Consequently, we have to set the reflect.Value directly.
+ // if underlying type is settable (e.g. ptr or interface),
+ // we just decode into it.
+ // Else we create a settable value, decode into it, and set on the interface.
+ if rvn.CanSet() {
+ f.d.decodeValue(rvn, nil)
+ } else {
+ rvn2 := reflect.New(rvn.Type()).Elem()
+ rvn2.Set(rvn)
+ f.d.decodeValue(rvn2, nil)
+ rv.Set(rvn2)
+ }
}
- 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)
- return
- }
-
- rvn2 = reflect.New(rvn.Type()).Elem()
- rvn2.Set(rvn)
- d.decodeValue(rvn2, nil, true)
- rv.Set(rvn2)
}
-func decStructFieldKey(dd decDriver, keyType valueType, b *[decScratchByteArrayLen]byte) (rvkencname []byte) {
- // use if-else-if, not switch (which compiles to binary-search)
- // since keyType is typically valueTypeString, branch prediction is pretty good.
-
- if keyType == valueTypeString {
- rvkencname = dd.DecodeStringAsBytes()
- } else if keyType == valueTypeInt {
- rvkencname = strconv.AppendInt(b[:0], dd.DecodeInt64(), 10)
- } else if keyType == valueTypeUint {
- rvkencname = strconv.AppendUint(b[:0], dd.DecodeUint64(), 10)
- } else if keyType == valueTypeFloat {
- rvkencname = strconv.AppendFloat(b[:0], dd.DecodeFloat64(), 'f', -1, 64)
- } else {
- rvkencname = dd.DecodeStringAsBytes()
- }
- return rvkencname
-}
-
-func (d *Decoder) kStruct(f *codecFnInfo, rv reflect.Value) {
+func (f *decFnInfo) kStruct(rv reflect.Value) {
fti := f.ti
+ d := f.d
dd := d.d
- elemsep := d.esep
- sfn := structFieldNode{v: rv, update: true}
+ cr := d.cr
ctyp := dd.ContainerType()
if ctyp == valueTypeMap {
containerLen := dd.ReadMapStart()
if containerLen == 0 {
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
return
}
- tisfi := fti.sfiSort
+ tisfi := fti.sfi
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 {
- si := tisfi[k]
- if dd.TryDecodeAsNil() {
- si.setToZeroValue(rv)
- } else {
- d.decodeValue(sfn.field(si), nil, true)
+ if hasLen {
+ for j := 0; j < containerLen; j++ {
+ // rvkencname := dd.DecodeString()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ rvkencname := stringView(dd.DecodeBytes(f.d.b[:], true, true))
+ // rvksi := ti.getForEncName(rvkencname)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ if k := fti.indexForEncName(rvkencname); k > -1 {
+ si := tisfi[k]
+ if dd.TryDecodeAsNil() {
+ si.setToZeroValue(rv)
+ } else {
+ d.decodeValue(si.field(rv, true), nil)
+ }
+ } else {
+ d.structFieldNotFound(-1, rvkencname)
+ }
+ }
+ } else {
+ for j := 0; !dd.CheckBreak(); j++ {
+ // rvkencname := dd.DecodeString()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ rvkencname := stringView(dd.DecodeBytes(f.d.b[:], true, true))
+ // rvksi := ti.getForEncName(rvkencname)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ if k := fti.indexForEncName(rvkencname); k > -1 {
+ si := tisfi[k]
+ if dd.TryDecodeAsNil() {
+ si.setToZeroValue(rv)
+ } else {
+ d.decodeValue(si.field(rv, true), nil)
+ }
+ } else {
+ d.structFieldNotFound(-1, rvkencname)
}
- } else {
- d.structFieldNotFound(-1, stringView(rvkencname))
}
- // keepAlive4StringView(rvkencnameB) // not needed, as reference is outside loop
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
} else if ctyp == valueTypeArray {
containerLen := dd.ReadArrayStart()
if containerLen == 0 {
- dd.ReadArrayEnd()
+ if cr != nil {
+ cr.sendContainerState(containerArrayEnd)
+ }
return
}
// Not much gain from doing it two ways for array.
// Arrays are not used as much for structs.
hasLen := containerLen >= 0
- for j, si := range fti.sfiSrc {
- if (hasLen && j == containerLen) || (!hasLen && dd.CheckBreak()) {
+ for j, si := range fti.sfip {
+ if hasLen {
+ if j == containerLen {
+ break
+ }
+ } else if dd.CheckBreak() {
break
}
- if elemsep {
- dd.ReadArrayElem()
+ if cr != nil {
+ cr.sendContainerState(containerArrayElem)
}
if dd.TryDecodeAsNil() {
si.setToZeroValue(rv)
} else {
- d.decodeValue(sfn.field(si), nil, true)
+ d.decodeValue(si.field(rv, true), nil)
}
}
- if containerLen > len(fti.sfiSrc) {
+ if containerLen > len(fti.sfip) {
// read remaining values and throw away
- for j := len(fti.sfiSrc); j < containerLen; j++ {
- if elemsep {
- dd.ReadArrayElem()
+ for j := len(fti.sfip); j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerArrayElem)
}
d.structFieldNotFound(j, "")
}
}
- dd.ReadArrayEnd()
+ if cr != nil {
+ cr.sendContainerState(containerArrayEnd)
+ }
} else {
- d.errorstr(errstrOnlyMapOrArrayCanDecodeIntoStruct)
+ f.d.error(onlyMapOrArrayCanDecodeIntoStructErr)
return
}
}
-func (d *Decoder) kSlice(f *codecFnInfo, rv reflect.Value) {
+func (f *decFnInfo) kSlice(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")
- }
+ d := f.d
dd := d.d
- rtelem0 := ti.elem
+ rtelem0 := ti.rt.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)
+ f.d.errorf("bytes or string in the stream must be decoded into a slice or array of bytes, not %v", 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)
- }
+ bs2 := dd.DecodeBytes(nil, false, true)
+ ch := rv.Interface().(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]) {
+ bs2 := dd.DecodeBytes(rvbs, false, false)
+ if rvbs == nil && bs2 != nil || rvbs != nil && bs2 == nil || len(bs2) != len(rvbs) {
if rv.CanSet() {
rv.SetBytes(bs2)
- } else if len(rvbs) > 0 && len(bs2) > 0 {
+ } else {
copy(rvbs, bs2)
}
}
@@ -1280,225 +865,199 @@ func (d *Decoder) kSlice(f *codecFnInfo, rv reflect.Value) {
slh, containerLenS := d.decSliceHelperStart() // only expects valueType(Array|Map)
- // an array can never return a nil slice. so no need to check f.array here.
+ // // 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 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))
}
}
slh.End()
return
}
- rtelem0Size := int(rtelem0.Size())
- rtElem0Kind := rtelem0.Kind()
- rtelem0Mut := !isImmutableKind(rtElem0Kind)
rtelem := rtelem0
- rtelemkind := rtelem.Kind()
- for rtelemkind == reflect.Ptr {
+ for rtelem.Kind() == reflect.Ptr {
rtelem = rtelem.Elem()
- rtelemkind = rtelem.Kind()
}
+ fn := d.getDecFn(rtelem, true, true)
- var fn *codecFn
+ var rv0, rv9 reflect.Value
+ rv0 = rv
+ rvChanged := false
- var rvCanset = rv.CanSet()
- var rvChanged bool
- var rv0 = rv
- var rv9 reflect.Value
-
- rvlen := rv.Len()
- rvcap := rv.Cap()
- hasLen := containerLenS > 0
- if hasLen && f.seq == seqTypeSlice {
- if containerLenS > rvcap {
- oldRvlenGtZero := rvlen > 0
- rvlen = decInferLen(containerLenS, d.h.MaxInitLen, int(rtelem0.Size()))
- if rvlen <= rvcap {
- if rvCanset {
- rv.SetLen(rvlen)
- }
- } else if rvCanset {
- rv = reflect.MakeSlice(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)
- }
- } else if containerLenS != rvlen {
- rvlen = containerLenS
- if rvCanset {
- rv.SetLen(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
- d.cfer()
- for ; (hasLen && j < containerLenS) || !(hasLen || dd.CheckBreak()); j++ {
- if j == 0 && (f.seq == seqTypeSlice || f.seq == seqTypeChan) && rv.IsNil() {
- if hasLen {
- rvlen = decInferLen(containerLenS, d.h.MaxInitLen, rtelem0Size)
- } else if f.seq == seqTypeSlice {
- rvlen = decDefSliceCap
- } else {
- rvlen = decDefChanCap
- }
- if rvCanset {
- if f.seq == seqTypeSlice {
- rv = reflect.MakeSlice(ti.rt, rvlen, rvlen)
- rvChanged = true
- } else { // chan
- // xdebugf(">>>>>> haslen = %v, make chan of type '%v' with length: %v", hasLen, ti.rt, rvlen)
- rv = reflect.MakeChan(ti.rt, rvlen)
- rvChanged = true
- }
- } else {
- d.errorf("cannot decode into non-settable slice")
- }
- }
- slh.ElemContainerState(j)
- decodeAsNil = dd.TryDecodeAsNil()
+ // for j := 0; j < containerLenS; j++ {
+ var rvlen int
+ if containerLenS > 0 { // hasLen
if f.seq == seqTypeChan {
- if decodeAsNil {
- rv.Send(reflect.Zero(rtelem0))
- continue
+ if rv.IsNil() {
+ rvlen, _ = decInferLen(containerLenS, f.d.h.MaxInitLen, int(rtelem0.Size()))
+ rv.Set(reflect.MakeChan(ti.rt, rvlen))
}
- if rtelem0Mut || !rv9.IsValid() { // || (rtElem0Kind == reflect.Ptr && rv9.IsNil()) {
+ // handle chan specially:
+ for j := 0; j < containerLenS; j++ {
rv9 = reflect.New(rtelem0).Elem()
+ slh.ElemContainerState(j)
+ d.decodeValue(rv9, fn)
+ rv.Send(rv9)
}
- if fn == nil {
- fn = d.cf.get(rtelem, true, true)
- }
- d.decodeValue(rv9, fn, true)
- // xdebugf(">>>> rv9 sent on %v during decode: %v, with len=%v, cap=%v", rv.Type(), rv9, rv.Len(), rv.Cap())
- rv.Send(rv9)
- } else {
- // if indefinite, etc, then expand the slice if necessary
- var decodeIntoBlank bool
- if j >= rvlen {
+ } else { // slice or array
+ var truncated bool // says len of sequence is not same as expected number of elements
+ numToRead := containerLenS // if truncated, reset numToRead
+
+ rvcap := rv.Cap()
+ rvlen = rv.Len()
+ if containerLenS > rvcap {
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)
+ d.arrayCannotExpand(rvlen, containerLenS)
+ } else {
+ oldRvlenGtZero := rvlen > 0
+ rvlen, truncated = decInferLen(containerLenS, f.d.h.MaxInitLen, int(rtelem0.Size()))
+ if truncated {
+ if rvlen <= rvcap {
+ rv.SetLen(rvlen)
+ } else {
+ rv = reflect.MakeSlice(ti.rt, rvlen, rvlen)
+ rvChanged = true
+ }
+ } else {
+ rv = reflect.MakeSlice(ti.rt, rvlen, rvlen)
+ rvChanged = true
}
- rvlen++
- if rvChanged {
- rv = rv9
- rvcap = rvcap2
+ if rvChanged && oldRvlenGtZero && !isImmutableKind(rtelem0.Kind()) {
+ reflect.Copy(rv, rv0) // only copy up to length NOT cap i.e. rv0.Slice(0, rvcap)
}
+ rvcap = rvlen
+ }
+ numToRead = rvlen
+ } else if containerLenS != rvlen {
+ if f.seq == seqTypeSlice {
+ rv.SetLen(containerLenS)
+ rvlen = containerLenS
}
}
- if decodeIntoBlank {
- if !decodeAsNil {
+ j := 0
+ // we read up to the numToRead
+ for ; j < numToRead; j++ {
+ slh.ElemContainerState(j)
+ d.decodeValue(rv.Index(j), fn)
+ }
+
+ // if slice, expand and read up to containerLenS (or EOF) iff truncated
+ // if array, swallow all the rest.
+
+ if f.seq == seqTypeArray {
+ for ; j < containerLenS; j++ {
+ slh.ElemContainerState(j)
d.swallow()
}
- } else {
- rv9 = rv.Index(j)
- if d.h.SliceElementReset || decodeAsNil {
- if !rtelem0ZeroValid {
- rtelem0ZeroValid = true
- rtelem0Zero = reflect.Zero(rtelem0)
+ } else if truncated { // slice was truncated, as chan NOT in this block
+ for ; j < containerLenS; j++ {
+ rv = expandSliceValue(rv, 1)
+ rv9 = rv.Index(j)
+ if resetSliceElemToZeroValue {
+ rv9.Set(reflect.Zero(rtelem0))
}
- rv9.Set(rtelem0Zero)
+ slh.ElemContainerState(j)
+ d.decodeValue(rv9, fn)
}
- if decodeAsNil {
- continue
- }
-
- if fn == nil {
- fn = d.cf.get(rtelem, true, true)
- }
- d.decodeValue(rv9, fn, true)
}
}
- }
- if f.seq == seqTypeSlice {
- if j < rvlen {
- if rv.CanSet() {
+ } else {
+ rvlen = rv.Len()
+ j := 0
+ for ; !dd.CheckBreak(); j++ {
+ if f.seq == seqTypeChan {
+ slh.ElemContainerState(j)
+ rv9 = reflect.New(rtelem0).Elem()
+ d.decodeValue(rv9, fn)
+ 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)) // uses append logic, plus varargs
+ rv = expandSliceValue(rv, 1)
+ rv9 = rv.Index(j)
+ // rv.Index(rv.Len() - 1).Set(reflect.Zero(rtelem0))
+ if resetSliceElemToZeroValue {
+ rv9.Set(reflect.Zero(rtelem0))
+ }
+ rvlen++
+ rvChanged = true
+ }
+ } else { // slice or array
+ rv9 = rv.Index(j)
+ }
+ slh.ElemContainerState(j)
+ if decodeIntoBlank {
+ d.swallow()
+ } else { // seqTypeSlice
+ d.decodeValue(rv9, fn)
+ }
+ }
+ }
+ if f.seq == seqTypeSlice {
+ if j < rvlen {
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 rvCanset {
+ } else if j == 0 && rv.IsNil() {
rv = reflect.MakeSlice(ti.rt, 0, 0)
rvChanged = true
- } // else { d.errorf("kSlice: cannot change non-settable slice") }
+ }
}
}
slh.End()
- if rvChanged { // infers rvCanset=true, so it can be reset
+ if rvChanged {
rv0.Set(rv)
}
}
-// func (d *Decoder) kArray(f *codecFnInfo, rv reflect.Value) {
-// // d.decodeValueFn(rv.Slice(0, rv.Len()))
-// f.kSlice(rv.Slice(0, rv.Len()))
-// }
+func (f *decFnInfo) kArray(rv reflect.Value) {
+ // f.d.decodeValue(rv.Slice(0, rv.Len()))
+ f.kSlice(rv.Slice(0, rv.Len()))
+}
-func (d *Decoder) kMap(f *codecFnInfo, rv reflect.Value) {
+func (f *decFnInfo) kMap(rv reflect.Value) {
+ d := f.d
dd := d.d
containerLen := dd.ReadMapStart()
- elemsep := d.esep
+ cr := d.cr
ti := f.ti
if rv.IsNil() {
- rv.Set(makeMapReflect(ti.rt, containerLen))
+ rv.Set(reflect.MakeMap(ti.rt))
}
if containerLen == 0 {
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
return
}
- ktype, vtype := ti.key, ti.elem
- ktypeId := rt2id(ktype)
+ ktype, vtype := ti.rt.Key(), ti.rt.Elem()
+ ktypeId := reflect.ValueOf(ktype).Pointer()
vtypeKind := vtype.Kind()
-
- var keyFn, valFn *codecFn
- var ktypeLo, vtypeLo reflect.Type
-
- for ktypeLo = ktype; ktypeLo.Kind() == reflect.Ptr; ktypeLo = ktypeLo.Elem() {
+ var keyFn, valFn *decFn
+ var xtyp reflect.Type
+ for xtyp = ktype; xtyp.Kind() == reflect.Ptr; xtyp = xtyp.Elem() {
}
-
- for vtypeLo = vtype; vtypeLo.Kind() == reflect.Ptr; vtypeLo = vtypeLo.Elem() {
+ keyFn = d.getDecFn(xtyp, true, true)
+ for xtyp = vtype; xtyp.Kind() == reflect.Ptr; xtyp = xtyp.Elem() {
}
-
+ valFn = d.getDecFn(xtyp, true, true)
var mapGet, mapSet bool
- rvvImmut := isImmutableKind(vtypeKind)
- if !d.h.MapValueReset {
+ if !f.d.h.MapValueReset {
// if pointer, mapGet = true
// if interface, mapGet = true if !DecodeNakedAlways (else false)
// if builtin, mapGet = false
@@ -1506,124 +1065,118 @@ func (d *Decoder) kMap(f *codecFnInfo, rv reflect.Value) {
if vtypeKind == reflect.Ptr {
mapGet = true
} else if vtypeKind == reflect.Interface {
- if !d.h.InterfaceReset {
+ if !f.d.h.InterfaceReset {
mapGet = true
}
- } else if !rvvImmut {
+ } else if !isImmutableKind(vtypeKind) {
mapGet = true
}
}
- var rvk, rvkp, rvv, rvz reflect.Value
- 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
- d.cfer()
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if rvkMut || !rvkp.IsValid() {
- rvkp = reflect.New(ktype)
- rvk = rvkp.Elem()
- }
- if elemsep {
- dd.ReadMapElemKey()
- }
- 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 {
- kstrbs = dd.DecodeStringAsBytes()
- rvk.SetString(stringView(kstrbs))
- // NOTE: if doing an insert, you MUST use a real string (not stringview)
- } else {
- if keyFn == nil {
- keyFn = d.cf.get(ktypeLo, true, true)
+ var rvk, rvv, rvz reflect.Value
+
+ // for j := 0; j < containerLen; j++ {
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ rvk = reflect.New(ktype).Elem()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- d.decodeValue(rvk, keyFn, true)
- }
- // special case if 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
+ d.decodeValue(rvk, keyFn)
+
+ // special case if a byte array.
+ if ktypeId == intfTypId {
+ rvk = rvk.Elem()
+ if rvk.Type() == uint8SliceTyp {
+ rvk = reflect.ValueOf(d.string(rvk.Bytes()))
}
}
- }
-
- if elemsep {
- dd.ReadMapElemValue()
- }
-
- // 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{})
+ mapSet = true // set to false if u do a get, and its a pointer, and exists
+ if mapGet {
+ rvv = rv.MapIndex(rvk)
+ if rvv.IsValid() {
+ if vtypeKind == reflect.Ptr {
+ mapSet = false
+ }
+ } else {
+ if rvz.IsValid() {
+ rvz.Set(reflect.Zero(vtype))
+ } else {
+ rvz = reflect.New(vtype).Elem()
+ }
+ rvv = rvz
+ }
} else {
- rv.SetMapIndex(rvk, reflect.Zero(vtype))
- }
- 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()
+ if rvz.IsValid() {
+ rvz.Set(reflect.Zero(vtype))
} else {
- mapSet = false
+ rvz = reflect.New(vtype).Elem()
}
- } 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)
- }
- rvv = rvv2
+ rvv = rvz
}
- // else it is ~mutable, and we can just decode into it directly
- } else if rvvImmut {
- if !rvz.IsValid() {
- rvz = reflect.New(vtype).Elem()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ d.decodeValue(rvv, valFn)
+ if mapSet {
+ rv.SetMapIndex(rvk, rvv)
}
- rvv = rvz
- } else {
- rvv = reflect.New(vtype).Elem()
}
+ } else {
+ for j := 0; !dd.CheckBreak(); j++ {
+ rvk = reflect.New(ktype).Elem()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ d.decodeValue(rvk, keyFn)
- // 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))
+ // special case if a byte array.
+ if ktypeId == intfTypId {
+ rvk = rvk.Elem()
+ if rvk.Type() == uint8SliceTyp {
+ rvk = reflect.ValueOf(d.string(rvk.Bytes()))
+ }
+ }
+ mapSet = true // set to false if u do a get, and its a pointer, and exists
+ if mapGet {
+ rvv = rv.MapIndex(rvk)
+ if rvv.IsValid() {
+ if vtypeKind == reflect.Ptr {
+ mapSet = false
+ }
+ } else {
+ if rvz.IsValid() {
+ rvz.Set(reflect.Zero(vtype))
+ } else {
+ rvz = reflect.New(vtype).Elem()
+ }
+ rvv = rvz
+ }
+ } else {
+ if rvz.IsValid() {
+ rvz.Set(reflect.Zero(vtype))
+ } else {
+ rvz = reflect.New(vtype).Elem()
+ }
+ rvv = rvz
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ d.decodeValue(rvv, valFn)
+ if mapSet {
+ rv.SetMapIndex(rvk, rvv)
+ }
}
- if valFn == nil {
- valFn = d.cf.get(vtypeLo, true, true)
- }
- d.decodeValue(rvv, valFn, true)
- // d.decodeValueFn(rvv, valFn)
- if mapSet {
- rv.SetMapIndex(rvk, rvv)
- }
- // if ktypeIsString {
- // // keepAlive4StringView(kstrbs) // not needed, as reference is outside loop
- // }
}
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
- dd.ReadMapEnd()
+type decRtidFn struct {
+ rtid uintptr
+ fn decFn
}
// decNaked is used to keep track of the primitives decoded.
@@ -1644,202 +1197,80 @@ func (d *Decoder) kMap(f *codecFnInfo, rv reflect.Value) {
//
// kInterfaceNaked will ensure that there is no allocation for the common
// uses.
-
-type decNakedContainers struct {
- // array/stacks for reducing allocation
- // keep arrays at the bottom? Chance is that they are not used much.
- ia [arrayCacheLen]interface{}
- ma [arrayCacheLen]map[interface{}]interface{}
- na [arrayCacheLen]map[string]interface{}
- sa [arrayCacheLen][]interface{}
-
- // ria [arrayCacheLen]reflect.Value // not needed, as we decode directly into &ia[n]
- rma, rna, rsa [arrayCacheLen]reflect.Value // reflect.Value mapping to above
-}
-
-func (n *decNakedContainers) init() {
- for i := 0; i < arrayCacheLen; i++ {
- // n.ria[i] = reflect.ValueOf(&(n.ia[i])).Elem()
- n.rma[i] = reflect.ValueOf(&(n.ma[i])).Elem()
- n.rna[i] = reflect.ValueOf(&(n.na[i])).Elem()
- n.rsa[i] = reflect.ValueOf(&(n.sa[i])).Elem()
- }
-}
-
type decNaked struct {
// r RawExt // used for RawExt, uint, []byte.
-
- // primitives below
u uint64
i int64
f float64
l []byte
s string
-
- // ---- cpu cache line boundary?
t time.Time
b bool
+ v valueType
- // state
- v valueType
- li, lm, ln, ls int8
- inited bool
+ // stacks for reducing allocation
+ is []interface{}
+ ms []map[interface{}]interface{}
+ ns []map[string]interface{}
+ ss [][]interface{}
+ // rs []RawExt
- *decNakedContainers
-
- ru, ri, rf, rl, rs, rb, rt reflect.Value // mapping to the primitives above
-
- // _ [6]uint64 // padding // no padding - rt goes into next cache line
-}
-
-func (n *decNaked) init() {
- if n.inited {
- return
- }
- 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.inited = true
- // n.rr[] = reflect.ValueOf(&n.)
-}
-
-func (n *decNaked) initContainers() {
- if n.decNakedContainers == nil {
- n.decNakedContainers = new(decNakedContainers)
- n.decNakedContainers.init()
- }
+ // keep arrays at the bottom? Chance is that they are not used much.
+ ia [4]interface{}
+ ma [4]map[interface{}]interface{}
+ na [4]map[string]interface{}
+ sa [4][]interface{}
+ // ra [2]RawExt
}
func (n *decNaked) reset() {
- if n == nil {
- return
+ if n.ss != nil {
+ n.ss = n.ss[:0]
+ }
+ if n.is != nil {
+ n.is = n.is[:0]
+ }
+ if n.ms != nil {
+ n.ms = n.ms[:0]
+ }
+ if n.ns != nil {
+ n.ns = n.ns[:0]
}
- n.li, n.lm, n.ln, n.ls = 0, 0, 0, 0
}
-type rtid2rv struct {
- rtid uintptr
- rv reflect.Value
-}
-
-// --------------
-
-type decReaderSwitch struct {
- rb bytesDecReader
- // ---- cpu cache line boundary?
- ri *ioDecReader
- mtr, str bool // whether maptype or slicetype are known types
-
- be bool // is binary encoding
- bytes bool // is bytes reader
- js bool // is json handle
- jsms bool // is json handle, and MapKeyAsString
- esep bool // has elem separators
-}
-
-// TODO: Uncomment after mid-stack inlining enabled in go 1.11
-//
-// func (z *decReaderSwitch) unreadn1() {
-// if z.bytes {
-// z.rb.unreadn1()
-// } else {
-// z.ri.unreadn1()
-// }
-// }
-// func (z *decReaderSwitch) readx(n int) []byte {
-// if z.bytes {
-// return z.rb.readx(n)
-// }
-// return z.ri.readx(n)
-// }
-// func (z *decReaderSwitch) readb(s []byte) {
-// if z.bytes {
-// z.rb.readb(s)
-// } else {
-// z.ri.readb(s)
-// }
-// }
-// func (z *decReaderSwitch) readn1() uint8 {
-// if z.bytes {
-// return z.rb.readn1()
-// }
-// return z.ri.readn1()
-// }
-// func (z *decReaderSwitch) numread() int {
-// if z.bytes {
-// return z.rb.numread()
-// }
-// return z.ri.numread()
-// }
-// func (z *decReaderSwitch) track() {
-// if z.bytes {
-// z.rb.track()
-// } else {
-// z.ri.track()
-// }
-// }
-// func (z *decReaderSwitch) stopTrack() []byte {
-// if z.bytes {
-// return z.rb.stopTrack()
-// }
-// return z.ri.stopTrack()
-// }
-// func (z *decReaderSwitch) skip(accept *bitset256) (token byte) {
-// if z.bytes {
-// return z.rb.skip(accept)
-// }
-// return z.ri.skip(accept)
-// }
-// func (z *decReaderSwitch) readTo(in []byte, accept *bitset256) (out []byte) {
-// if z.bytes {
-// return z.rb.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.readUntil(in, stop)
-// }
-// return z.ri.readUntil(in, stop)
-// }
-
// A Decoder reads and decodes an object from an input stream in the codec format.
type Decoder struct {
- panicHdl
// hopefully, reduce derefencing cost by laying the decReader inside the Decoder.
// Try to put things that go together to fit within a cache line (8 words).
d decDriver
// NOTE: Decoder shouldn't call it's read methods,
// as the handler MAY need to do some coordination.
- r decReader
+ r decReader
+ // sa [initCollectionCap]decRtidFn
h *BasicHandle
- bi *bufioDecReader
+ hh Handle
+
+ be bool // is binary encoding
+ bytes bool // is bytes reader
+ js bool // is json handle
+
+ rb bytesDecReader
+ ri ioDecReader
+ cr containerStateRecv
+
+ s []decRtidFn
+ f map[uintptr]*decFn
+
+ // _ uintptr // for alignment purposes, so next one starts from a cache line
+
// cache the mapTypeId and sliceTypeId for faster comparisons
mtid uintptr
stid uintptr
- // ---- cpu cache line boundary?
- decReaderSwitch
-
- // ---- cpu cache line boundary?
- codecFnPooler
- // cr containerStateRecv
- n *decNaked
- nsp *sync.Pool
- err error
-
- // ---- cpu cache line boundary?
- b [decScratchByteArrayLen]byte // scratch buffer, used by Decoder and xxxEncDrivers
- is map[string]string // used for interning strings
-
- // padding - false sharing help // modify 232 if Decoder struct changes.
- // _ [cacheLineSize - 232%cacheLineSize]byte
+ n decNaked
+ b [scratchByteArrayLen]byte
+ is map[string]string // used for interning strings
}
// NewDecoder returns a Decoder for decoding a stream of bytes from an io.Reader.
@@ -1860,100 +1291,63 @@ func NewDecoderBytes(in []byte, h Handle) *Decoder {
return d
}
-var defaultDecNaked decNaked
-
func newDecoder(h Handle) *Decoder {
- d := &Decoder{h: h.getBasicHandle(), err: errDecoderNotInitialized}
- 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()
+ d := &Decoder{hh: h, h: h.getBasicHandle(), be: h.isBinary()}
+ n := &d.n
+ // n.rs = n.ra[:0]
+ n.ms = n.ma[:0]
+ n.is = n.ia[:0]
+ n.ns = n.na[:0]
+ n.ss = n.sa[:0]
+ _, d.js = h.(*JsonHandle)
if d.h.InternString {
d.is = make(map[string]string, 32)
}
d.d = h.newDecDriver(d)
- // d.cr, _ = d.d.(containerStateRecv)
+ d.cr, _ = d.d.(containerStateRecv)
+ // d.d = h.newDecDriver(decReaderT{true, &d.rb, &d.ri})
return d
}
func (d *Decoder) resetCommon() {
d.n.reset()
d.d.reset()
- d.err = nil
- // reset all things which were cached from the Handle, but could change
+ // reset all things which were cached from the Handle,
+ // but could be changed.
d.mtid, d.stid = 0, 0
- d.mtr, d.str = false, false
if d.h.MapType != nil {
- d.mtid = rt2id(d.h.MapType)
- d.mtr = fastpathAV.index(d.mtid) != -1
+ d.mtid = reflect.ValueOf(d.h.MapType).Pointer()
}
if d.h.SliceType != nil {
- d.stid = rt2id(d.h.SliceType)
- d.str = fastpathAV.index(d.stid) != -1
+ d.stid = reflect.ValueOf(d.h.SliceType).Pointer()
}
}
-// Reset the Decoder with a new Reader to decode from,
-// clearing all state from last run(s).
func (d *Decoder) Reset(r io.Reader) {
- if r == nil {
- return
- }
- if d.bi == nil {
- d.bi = new(bufioDecReader)
- }
- d.bytes = false
- if d.h.ReaderBufferSize > 0 {
- d.bi.buf = make([]byte, 0, d.h.ReaderBufferSize)
- d.bi.reset(r)
- d.r = d.bi
- } 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.ri.x = &d.b
+ // d.s = d.sa[:0]
+ d.ri.bs.r = r
+ var ok bool
+ d.ri.br, ok = r.(decReaderByteScanner)
+ if !ok {
+ d.ri.br = &d.ri.bs
}
+ d.r = &d.ri
d.resetCommon()
}
-// ResetBytes resets the Decoder with a new []byte to decode from,
-// clearing all state from last run(s).
func (d *Decoder) ResetBytes(in []byte) {
- if in == nil {
- return
- }
- d.bytes = true
+ // d.s = d.sa[:0]
d.rb.reset(in)
d.r = &d.rb
d.resetCommon()
}
-// naked must be called before each call to .DecodeNaked,
-// as they will use it.
-func (d *Decoder) 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 *Decoder) sendContainerState(c containerState) {
+// if d.cr != nil {
+// d.cr.sendContainerState(c)
+// }
+// }
// Decode decodes the stream from reader and stores the result in the
// value pointed to by v. v cannot be a nil pointer. v can also be
@@ -2005,282 +1399,424 @@ func (d *Decoder) naked() *decNaked {
// However, when decoding a stream nil, we reset the destination container
// to its "zero" value (e.g. nil for slice/map, etc).
//
-// Note: we allow nil values in the stream anywhere except for map keys.
-// A nil value in the encoded stream where a map key is expected is treated as an error.
func (d *Decoder) Decode(v interface{}) (err error) {
- defer d.deferred(&err)
- d.MustDecode(v)
+ defer panicToErr(&err)
+ d.decode(v)
return
}
-// 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.err != nil {
- panic(d.err)
- }
- if d.d.TryDecodeAsNil() {
- setZero(v)
- } else {
- d.decode(v)
- }
- d.alwaysAtEnd()
- // xprintf(">>>>>>>> >>>>>>>> num decFns: %v\n", d.cf.sn)
+// this is not a smart swallow, as it allocates objects and does unnecessary work.
+func (d *Decoder) swallowViaHammer() {
+ var blank interface{}
+ d.decodeValue(reflect.ValueOf(&blank).Elem(), nil)
}
-func (d *Decoder) deferred(err1 *error) {
- d.alwaysAtEnd()
- if recoverPanicToErr {
- if x := recover(); x != nil {
- panicValToErr(d, x, err1)
- panicValToErr(d, x, &d.err)
- }
- }
-}
-
-func (d *Decoder) alwaysAtEnd() {
- 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
- }
- d.codecFnPooler.alwaysAtEnd()
-}
-
-// // 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
+ cr := d.cr
switch dd.ContainerType() {
case valueTypeMap:
containerLen := dd.ReadMapStart()
- 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()
+ clenGtEqualZero := containerLen >= 0
+ for j := 0; ; j++ {
+ if clenGtEqualZero {
+ if j >= containerLen {
+ break
+ }
+ } else if dd.CheckBreak() {
+ break
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
d.swallow()
- if elemsep {
- dd.ReadMapElemValue()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
d.swallow()
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
case valueTypeArray:
- containerLen := dd.ReadArrayStart()
- hasLen := containerLen >= 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if elemsep {
- dd.ReadArrayElem()
+ containerLenS := dd.ReadArrayStart()
+ clenGtEqualZero := containerLenS >= 0
+ for j := 0; ; j++ {
+ if clenGtEqualZero {
+ if j >= containerLenS {
+ break
+ }
+ } else if dd.CheckBreak() {
+ break
+ }
+ if cr != nil {
+ cr.sendContainerState(containerArrayElem)
}
d.swallow()
}
- dd.ReadArrayEnd()
+ if cr != nil {
+ cr.sendContainerState(containerArrayEnd)
+ }
case valueTypeBytes:
- dd.DecodeBytes(d.b[:], true)
+ dd.DecodeBytes(d.b[:], false, true)
case valueTypeString:
- dd.DecodeStringAsBytes()
+ dd.DecodeBytes(d.b[:], true, true)
+ // dd.DecodeStringAsBytes(d.b[:])
default:
// these are all primitives, which we can get from decodeNaked
// if RawExt using Value, complete the processing.
- n := d.naked()
dd.DecodeNaked()
- if n.v == valueTypeExt && n.l == nil {
- n.initContainers()
- if n.li < arrayCacheLen {
- n.ia[n.li] = nil
- n.li++
- d.decode(&n.ia[n.li-1])
- n.ia[n.li-1] = nil
- n.li--
- } else {
- var v2 interface{}
- d.decode(&v2)
- }
+ if n := &d.n; n.v == valueTypeExt && n.l == nil {
+ l := len(n.is)
+ n.is = append(n.is, nil)
+ v2 := &n.is[l]
+ d.decode(v2)
+ n.is = n.is[:l]
}
}
}
-func setZero(iv interface{}) {
- if iv == nil || definitelyNil(iv) {
- return
- }
- var canDecode bool
- switch v := iv.(type) {
- case *string:
- *v = ""
- case *bool:
- *v = false
- case *int:
- *v = 0
- case *int8:
- *v = 0
- case *int16:
- *v = 0
- case *int32:
- *v = 0
- case *int64:
- *v = 0
- case *uint:
- *v = 0
- case *uint8:
- *v = 0
- case *uint16:
- *v = 0
- case *uint32:
- *v = 0
- case *uint64:
- *v = 0
- case *float32:
- *v = 0
- case *float64:
- *v = 0
- case *[]uint8:
- *v = nil
- case *Raw:
- *v = nil
- 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???
- 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???
- }
- }
+// 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{}) {
+ d.decode(v)
}
func (d *Decoder) decode(iv interface{}) {
- // check nil and interfaces explicitly,
- // so that type switches just have a run of constant non-interface types.
- if iv == nil {
- d.errorstr(errstrCannotDecodeIntoNil)
- return
- }
- if v, ok := iv.(Selfer); ok {
- v.CodecDecodeSelf(d)
+ // if ics, ok := iv.(Selfer); ok {
+ // ics.CodecDecodeSelf(d)
+ // return
+ // }
+
+ if d.d.TryDecodeAsNil() {
+ switch v := iv.(type) {
+ case nil:
+ case *string:
+ *v = ""
+ case *bool:
+ *v = false
+ case *int:
+ *v = 0
+ case *int8:
+ *v = 0
+ case *int16:
+ *v = 0
+ case *int32:
+ *v = 0
+ case *int64:
+ *v = 0
+ case *uint:
+ *v = 0
+ case *uint8:
+ *v = 0
+ case *uint16:
+ *v = 0
+ case *uint32:
+ *v = 0
+ case *uint64:
+ *v = 0
+ case *float32:
+ *v = 0
+ case *float64:
+ *v = 0
+ case *[]uint8:
+ *v = nil
+ case *Raw:
+ *v = nil
+ case reflect.Value:
+ if v.Kind() != reflect.Ptr || v.IsNil() {
+ d.errNotValidPtrValue(v)
+ }
+ // d.chkPtrValue(v)
+ v = v.Elem()
+ if v.IsValid() {
+ v.Set(reflect.Zero(v.Type()))
+ }
+ default:
+ rv := reflect.ValueOf(iv)
+ if rv.Kind() != reflect.Ptr || rv.IsNil() {
+ d.errNotValidPtrValue(rv)
+ }
+ // d.chkPtrValue(rv)
+ rv = rv.Elem()
+ if rv.IsValid() {
+ rv.Set(reflect.Zero(rv.Type()))
+ }
+ }
return
}
switch v := iv.(type) {
- // case nil:
- // case Selfer:
+ case nil:
+ d.error(cannotDecodeIntoNilErr)
+ return
+
+ case Selfer:
+ v.CodecDecodeSelf(d)
case reflect.Value:
- v = d.ensureDecodeable(v)
- d.decodeValue(v, nil, true)
+ if v.Kind() != reflect.Ptr || v.IsNil() {
+ d.errNotValidPtrValue(v)
+ }
+ // d.chkPtrValue(v)
+ d.decodeValueNotNil(v.Elem(), nil)
case *string:
*v = d.d.DecodeString()
case *bool:
*v = d.d.DecodeBool()
case *int:
- *v = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize))
+ *v = int(d.d.DecodeInt(intBitsize))
case *int8:
- *v = int8(chkOvf.IntV(d.d.DecodeInt64(), 8))
+ *v = int8(d.d.DecodeInt(8))
case *int16:
- *v = int16(chkOvf.IntV(d.d.DecodeInt64(), 16))
+ *v = int16(d.d.DecodeInt(16))
case *int32:
- *v = int32(chkOvf.IntV(d.d.DecodeInt64(), 32))
+ *v = int32(d.d.DecodeInt(32))
case *int64:
- *v = d.d.DecodeInt64()
+ *v = d.d.DecodeInt(64)
case *uint:
- *v = uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize))
+ *v = uint(d.d.DecodeUint(uintBitsize))
case *uint8:
- *v = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8))
+ *v = uint8(d.d.DecodeUint(8))
case *uint16:
- *v = uint16(chkOvf.UintV(d.d.DecodeUint64(), 16))
+ *v = uint16(d.d.DecodeUint(16))
case *uint32:
- *v = uint32(chkOvf.UintV(d.d.DecodeUint64(), 32))
+ *v = uint32(d.d.DecodeUint(32))
case *uint64:
- *v = d.d.DecodeUint64()
+ *v = d.d.DecodeUint(64)
case *float32:
- f64 := d.d.DecodeFloat64()
- if chkOvf.Float32(f64) {
- d.errorf("float32 overflow: %v", f64)
- }
- *v = float32(f64)
+ *v = float32(d.d.DecodeFloat(true))
case *float64:
- *v = d.d.DecodeFloat64()
+ *v = d.d.DecodeFloat(false)
case *[]uint8:
- *v = d.d.DecodeBytes(*v, false)
- case []uint8:
- b := d.d.DecodeBytes(v, false)
- if !(len(b) > 0 && len(b) == len(v) && &b[0] == &v[0]) {
- copy(v, b)
- }
- case *time.Time:
- *v = d.d.DecodeTime()
+ *v = d.d.DecodeBytes(*v, false, false)
+
case *Raw:
- *v = d.rawBytes()
+ *v = d.raw()
case *interface{}:
- d.decodeValue(reflect.ValueOf(iv).Elem(), nil, true)
- // d.decodeValueNotNil(reflect.ValueOf(iv).Elem())
+ d.decodeValueNotNil(reflect.ValueOf(iv).Elem(), nil)
default:
if !fastpathDecodeTypeSwitch(iv, d) {
- v := reflect.ValueOf(iv)
- v = d.ensureDecodeable(v)
- d.decodeValue(v, nil, false)
- // d.decodeValueFallback(v)
+ d.decodeI(iv, true, false, false, false)
}
}
}
-func (d *Decoder) decodeValue(rv reflect.Value, fn *codecFn, chkAll bool) {
+func (d *Decoder) preDecodeValue(rv reflect.Value, tryNil bool) (rv2 reflect.Value, proceed bool) {
+ if tryNil && d.d.TryDecodeAsNil() {
+ // No need to check if a ptr, recursively, to determine
+ // whether to set value to nil.
+ // Just always set value to its zero type.
+ if rv.IsValid() { // rv.CanSet() // always settable, except it's invalid
+ rv.Set(reflect.Zero(rv.Type()))
+ }
+ return
+ }
+
// 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 {
- rvpValid = true
- for {
- if rv.IsNil() {
- rv.Set(reflect.New(rv.Type().Elem()))
- }
- rvp = rv
- rv = rv.Elem()
- if rv.Kind() != reflect.Ptr {
+ for rv.Kind() == reflect.Ptr {
+ if rv.IsNil() {
+ rv.Set(reflect.New(rv.Type().Elem()))
+ }
+ rv = rv.Elem()
+ }
+ return rv, true
+}
+
+func (d *Decoder) decodeI(iv interface{}, checkPtr, tryNil, checkFastpath, checkCodecSelfer bool) {
+ rv := reflect.ValueOf(iv)
+ if checkPtr {
+ if rv.Kind() != reflect.Ptr || rv.IsNil() {
+ d.errNotValidPtrValue(rv)
+ }
+ // d.chkPtrValue(rv)
+ }
+ rv, proceed := d.preDecodeValue(rv, tryNil)
+ if proceed {
+ fn := d.getDecFn(rv.Type(), checkFastpath, checkCodecSelfer)
+ fn.f(&fn.i, rv)
+ }
+}
+
+func (d *Decoder) decodeValue(rv reflect.Value, fn *decFn) {
+ if rv, proceed := d.preDecodeValue(rv, true); proceed {
+ if fn == nil {
+ fn = d.getDecFn(rv.Type(), true, true)
+ }
+ fn.f(&fn.i, rv)
+ }
+}
+
+func (d *Decoder) decodeValueNotNil(rv reflect.Value, fn *decFn) {
+ if rv, proceed := d.preDecodeValue(rv, false); proceed {
+ if fn == nil {
+ fn = d.getDecFn(rv.Type(), true, true)
+ }
+ fn.f(&fn.i, rv)
+ }
+}
+
+func (d *Decoder) getDecFn(rt reflect.Type, checkFastpath, checkCodecSelfer bool) (fn *decFn) {
+ rtid := reflect.ValueOf(rt).Pointer()
+
+ // retrieve or register a focus'ed function for this type
+ // to eliminate need to do the retrieval multiple times
+
+ // if d.f == nil && d.s == nil { debugf("---->Creating new dec f map for type: %v\n", rt) }
+ var ok bool
+ if useMapForCodecCache {
+ fn, ok = d.f[rtid]
+ } else {
+ for i := range d.s {
+ v := &(d.s[i])
+ if v.rtid == rtid {
+ fn, ok = &(v.fn), true
break
}
}
}
+ if ok {
+ return
+ }
- if fn == nil {
- // always pass checkCodecSelfer=true, in case T or ****T is passed, where *T is a Selfer
- fn = d.cfer().get(rv.Type(), chkAll, true) // chkAll, chkAll)
- }
- if fn.i.addrD {
- if rvpValid {
- fn.fd(d, &fn.i, rvp)
- } else if rv.CanAddr() {
- fn.fd(d, &fn.i, rv.Addr())
- } else if !fn.i.addrF {
- fn.fd(d, &fn.i, rv)
- } else {
- d.errorf("cannot decode into a non-pointer value")
+ if useMapForCodecCache {
+ if d.f == nil {
+ d.f = make(map[uintptr]*decFn, initCollectionCap)
}
+ fn = new(decFn)
+ d.f[rtid] = fn
} else {
- fn.fd(d, &fn.i, rv)
+ if d.s == nil {
+ d.s = make([]decRtidFn, 0, initCollectionCap)
+ }
+ d.s = append(d.s, decRtidFn{rtid: rtid})
+ fn = &(d.s[len(d.s)-1]).fn
}
- // return rv
+
+ // debugf("\tCreating new dec fn for type: %v\n", rt)
+ ti := d.h.getTypeInfo(rtid, rt)
+ fi := &(fn.i)
+ fi.d = d
+ fi.ti = ti
+
+ // An extension can be registered for any type, regardless of the Kind
+ // (e.g. type BitSet int64, type MyStruct { / * unexported fields * / }, type X []int, etc.
+ //
+ // We can't check if it's an extension byte here first, because the user may have
+ // registered a pointer or non-pointer type, meaning we may have to recurse first
+ // before matching a mapped type, even though the extension byte is already detected.
+ //
+ // NOTE: if decoding into a nil interface{}, we return a non-nil
+ // value except even if the container registers a length of 0.
+ if checkCodecSelfer && ti.cs {
+ fn.f = (*decFnInfo).selferUnmarshal
+ } else if rtid == rawExtTypId {
+ fn.f = (*decFnInfo).rawExt
+ } else if rtid == rawTypId {
+ fn.f = (*decFnInfo).raw
+ } else if d.d.IsBuiltinType(rtid) {
+ fn.f = (*decFnInfo).builtin
+ } else if xfFn := d.h.getExt(rtid); xfFn != nil {
+ fi.xfTag, fi.xfFn = xfFn.tag, xfFn.ext
+ fn.f = (*decFnInfo).ext
+ } else if supportMarshalInterfaces && d.be && ti.bunm {
+ fn.f = (*decFnInfo).binaryUnmarshal
+ } else if supportMarshalInterfaces && !d.be && d.js && ti.junm {
+ //If JSON, we should check JSONUnmarshal before textUnmarshal
+ fn.f = (*decFnInfo).jsonUnmarshal
+ } else if supportMarshalInterfaces && !d.be && ti.tunm {
+ fn.f = (*decFnInfo).textUnmarshal
+ } else {
+ rk := rt.Kind()
+ if fastpathEnabled && checkFastpath && (rk == reflect.Map || rk == reflect.Slice) {
+ if rt.PkgPath() == "" {
+ if idx := fastpathAV.index(rtid); idx != -1 {
+ fn.f = fastpathAV[idx].decfn
+ }
+ } else {
+ // use mapping for underlying type if there
+ ok = false
+ var rtu reflect.Type
+ if rk == reflect.Map {
+ rtu = reflect.MapOf(rt.Key(), rt.Elem())
+ } else {
+ rtu = reflect.SliceOf(rt.Elem())
+ }
+ rtuid := reflect.ValueOf(rtu).Pointer()
+ if idx := fastpathAV.index(rtuid); idx != -1 {
+ xfnf := fastpathAV[idx].decfn
+ xrt := fastpathAV[idx].rt
+ fn.f = func(xf *decFnInfo, xrv reflect.Value) {
+ // xfnf(xf, xrv.Convert(xrt))
+ xfnf(xf, xrv.Addr().Convert(reflect.PtrTo(xrt)).Elem())
+ }
+ }
+ }
+ }
+ if fn.f == nil {
+ switch rk {
+ case reflect.String:
+ fn.f = (*decFnInfo).kString
+ case reflect.Bool:
+ fn.f = (*decFnInfo).kBool
+ case reflect.Int:
+ fn.f = (*decFnInfo).kInt
+ case reflect.Int64:
+ fn.f = (*decFnInfo).kInt64
+ case reflect.Int32:
+ fn.f = (*decFnInfo).kInt32
+ case reflect.Int8:
+ fn.f = (*decFnInfo).kInt8
+ case reflect.Int16:
+ fn.f = (*decFnInfo).kInt16
+ case reflect.Float32:
+ fn.f = (*decFnInfo).kFloat32
+ case reflect.Float64:
+ fn.f = (*decFnInfo).kFloat64
+ case reflect.Uint8:
+ fn.f = (*decFnInfo).kUint8
+ case reflect.Uint64:
+ fn.f = (*decFnInfo).kUint64
+ case reflect.Uint:
+ fn.f = (*decFnInfo).kUint
+ case reflect.Uint32:
+ fn.f = (*decFnInfo).kUint32
+ case reflect.Uint16:
+ fn.f = (*decFnInfo).kUint16
+ // case reflect.Ptr:
+ // fn.f = (*decFnInfo).kPtr
+ case reflect.Uintptr:
+ fn.f = (*decFnInfo).kUintptr
+ case reflect.Interface:
+ fn.f = (*decFnInfo).kInterface
+ case reflect.Struct:
+ fn.f = (*decFnInfo).kStruct
+ case reflect.Chan:
+ fi.seq = seqTypeChan
+ fn.f = (*decFnInfo).kSlice
+ case reflect.Slice:
+ fi.seq = seqTypeSlice
+ fn.f = (*decFnInfo).kSlice
+ case reflect.Array:
+ fi.seq = seqTypeArray
+ fn.f = (*decFnInfo).kArray
+ case reflect.Map:
+ fn.f = (*decFnInfo).kMap
+ default:
+ fn.f = (*decFnInfo).kErr
+ }
+ }
+ }
+
+ return
}
func (d *Decoder) structFieldNotFound(index int, rvkencname string) {
@@ -2303,73 +1839,66 @@ func (d *Decoder) arrayCannotExpand(sliceLen, streamLen int) {
}
}
-func isDecodeable(rv reflect.Value) (rv2 reflect.Value, canDecode bool) {
- switch rv.Kind() {
- case reflect.Array:
- return rv, true
- case reflect.Ptr:
- if !rv.IsNil() {
- return rv.Elem(), true
- }
- case reflect.Slice, reflect.Chan, reflect.Map:
- if !rv.IsNil() {
- return rv, true
- }
- }
- return
-}
-
-func (d *Decoder) ensureDecodeable(rv reflect.Value) (rv2 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 {
+func (d *Decoder) chkPtrValue(rv reflect.Value) {
+ // We can only decode into a non-nil pointer
+ if rv.Kind() == reflect.Ptr && !rv.IsNil() {
return
}
+ d.errNotValidPtrValue(rv)
+}
+
+func (d *Decoder) errNotValidPtrValue(rv reflect.Value) {
if !rv.IsValid() {
- d.errorstr(errstrCannotDecodeIntoNil)
+ d.error(cannotDecodeIntoNilErr)
return
}
if !rv.CanInterface() {
d.errorf("cannot decode into a value without an interface: %v", rv)
return
}
- rvi := rv2i(rv)
- rvk := rv.Kind()
- d.errorf("cannot decode into value of kind: %v, type: %T, %v", rvk, rvi, rvi)
- return
+ rvi := rv.Interface()
+ d.errorf("cannot decode into non-pointer or nil pointer. Got: %v, %T, %v", rv.Kind(), rvi, rvi)
+}
+
+func (d *Decoder) error(err error) {
+ panic(err)
+}
+
+func (d *Decoder) errorf(format string, params ...interface{}) {
+ params2 := make([]interface{}, len(params)+1)
+ params2[0] = d.r.numread()
+ copy(params2[1:], params)
+ err := fmt.Errorf("[pos %d]: "+format, params2...)
+ panic(err)
}
-// Possibly get an interned version of a string
-//
-// 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 d.is == nil {
- return string(v) // don't return stringView, as we need a real string here.
+ if d.is != nil {
+ s, ok := d.is[string(v)] // no allocation here.
+ if !ok {
+ s = string(v)
+ d.is[s] = s
+ }
+ return s
}
- s, ok := d.is[string(v)] // no allocation here, per go implementation
- if !ok {
- s = string(v) // new allocation here
+ return string(v) // don't return stringView, as we need a real string here.
+}
+
+func (d *Decoder) intern(s string) {
+ if d.is != nil {
d.is[s] = s
}
- return s
}
// nextValueBytes returns the next value in the stream as a set of bytes.
-func (d *Decoder) nextValueBytes() (bs []byte) {
+func (d *Decoder) nextValueBytes() []byte {
d.d.uncacheRead()
d.r.track()
d.swallow()
- bs = d.r.stopTrack()
- return
+ return d.r.stopTrack()
}
-func (d *Decoder) rawBytes() []byte {
+func (d *Decoder) raw() []byte {
// ensure that this is not a view into the bytes
// i.e. make new copy always.
bs := d.nextValueBytes()
@@ -2378,14 +1907,6 @@ func (d *Decoder) rawBytes() []byte {
return bs2
}
-func (d *Decoder) wrapErrstr(v interface{}, err *error) {
- *err = fmt.Errorf("%s decode error [pos %d]: %v", d.hh.Name(), d.r.numread(), v)
-}
-
-func (d *Decoder) NumBytesRead() int {
- return d.r.numread()
-}
-
// --------------------------------------------------
// decSliceHelper assists when decoding into a slice, from a map or an array in the stream.
@@ -2399,13 +1920,12 @@ type decSliceHelper struct {
func (d *Decoder) decSliceHelperStart() (x decSliceHelper, clen int) {
dd := d.d
ctyp := dd.ContainerType()
- switch ctyp {
- case valueTypeArray:
+ if ctyp == valueTypeArray {
x.array = true
clen = dd.ReadArrayStart()
- case valueTypeMap:
+ } else if ctyp == valueTypeMap {
clen = dd.ReadMapStart() * 2
- default:
+ } else {
d.errorf("only encoded map or array can be decoded into a slice (%d)", ctyp)
}
// x.ct = ctyp
@@ -2414,47 +1934,45 @@ func (d *Decoder) decSliceHelperStart() (x decSliceHelper, clen int) {
}
func (x decSliceHelper) End() {
+ cr := x.d.cr
+ if cr == nil {
+ return
+ }
if x.array {
- x.d.d.ReadArrayEnd()
+ cr.sendContainerState(containerArrayEnd)
} else {
- x.d.d.ReadMapEnd()
+ cr.sendContainerState(containerMapEnd)
}
}
func (x decSliceHelper) ElemContainerState(index int) {
+ cr := x.d.cr
+ if cr == nil {
+ return
+ }
if x.array {
- x.d.d.ReadArrayElem()
- } else if index%2 == 0 {
- x.d.d.ReadMapElemKey()
+ cr.sendContainerState(containerArrayElem)
} else {
- x.d.d.ReadMapElemValue()
+ if index%2 == 0 {
+ cr.sendContainerState(containerMapKey)
+ } else {
+ cr.sendContainerState(containerMapValue)
+ }
}
}
-func decByteSlice(r decReader, clen, maxInitLen int, bs []byte) (bsOut []byte) {
+func decByteSlice(r decReader, clen int, bs []byte) (bsOut []byte) {
if clen == 0 {
return zeroByteSlice
}
if len(bs) == clen {
bsOut = bs
- r.readb(bsOut)
} else if cap(bs) >= clen {
bsOut = bs[:clen]
- r.readb(bsOut)
} else {
- // bsOut = make([]byte, clen)
- len2 := decInferLen(clen, maxInitLen, 1)
- bsOut = make([]byte, len2)
- r.readb(bsOut)
- for len2 < clen {
- len3 := decInferLen(clen-len2, maxInitLen, 1)
- bs3 := bsOut
- bsOut = make([]byte, len2+len3)
- copy(bsOut, bs3)
- r.readb(bsOut[len2:])
- len2 += len3
- }
+ bsOut = make([]byte, clen)
}
+ r.readb(bsOut)
return
}
@@ -2478,14 +1996,11 @@ func detachZeroCopyBytes(isBytesReader bool, dest []byte, in []byte) (out []byte
// - maxlen: max length to be returned.
// 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) {
+func decInferLen(clen, maxlen, unit int) (rvlen int, truncated bool) {
// handle when maxlen is not set i.e. <= 0
if clen <= 0 {
return
}
- if unit == 0 {
- return clen
- }
if maxlen <= 0 {
// no maxlen defined. Use maximum of 256K memory, with a floor of 4K items.
// maxlen = 256 * 1024 / unit
@@ -2500,57 +2015,39 @@ func decInferLen(clen, maxlen, unit int) (rvlen int) {
}
if clen > maxlen {
rvlen = maxlen
+ truncated = true
} else {
rvlen = clen
}
return
+ // if clen <= 0 {
+ // rvlen = 0
+ // } else if maxlen > 0 && clen > maxlen {
+ // rvlen = maxlen
+ // truncated = true
+ // } else {
+ // rvlen = clen
+ // }
+ // 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 int, err error) {
- var nn int
- for n < len(bs) && err == nil {
- nn, err = r.Read(bs[n:])
- if nn > 0 {
- if err == io.EOF {
- // leave EOF for next time
- err = nil
- }
- n += nn
- }
- }
-
- // do not do this - it serves no purpose
- // if n != len(bs) && err == io.EOF { err = io.ErrUnexpectedEOF }
- return
-}
+// // implement overall decReader wrapping both, for possible use inline:
+// type decReaderT struct {
+// bytes bool
+// rb *bytesDecReader
+// ri *ioDecReader
+// }
+//
+// // implement *Decoder as a decReader.
+// // Using decReaderT (defined just above) caused performance degradation
+// // possibly because of constant copying the value,
+// // and some value->interface conversion causing allocation.
+// func (d *Decoder) unreadn1() {
+// if d.bytes {
+// d.rb.unreadn1()
+// } else {
+// d.ri.unreadn1()
+// }
+// }
+// ... for other methods of decReader.
+// Testing showed that performance improvement was negligible.
diff --git a/vendor/github.com/ugorji/go/codec/decode_go.go b/vendor/github.com/ugorji/go/codec/decode_go.go
new file mode 100644
index 0000000000..ba289cef61
--- /dev/null
+++ b/vendor/github.com/ugorji/go/codec/decode_go.go
@@ -0,0 +1,16 @@
+// Copyright (c) 2012-2015 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 "reflect"
+
+const reflectArrayOfSupported = true
+
+func reflectArrayOf(rvn reflect.Value) (rvn2 reflect.Value) {
+ rvn2 = reflect.New(reflect.ArrayOf(rvn.Len(), intfTyp)).Elem()
+ reflect.Copy(rvn2, rvn)
+ return
+}
diff --git a/vendor/github.com/ugorji/go/codec/decode_go14.go b/vendor/github.com/ugorji/go/codec/decode_go14.go
new file mode 100644
index 0000000000..50063bc8fc
--- /dev/null
+++ b/vendor/github.com/ugorji/go/codec/decode_go14.go
@@ -0,0 +1,14 @@
+// Copyright (c) 2012-2015 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 "reflect"
+
+const reflectArrayOfSupported = false
+
+func reflectArrayOf(rvn reflect.Value) (rvn2 reflect.Value) {
+ panic("reflect.ArrayOf unsupported")
+}
diff --git a/vendor/github.com/ugorji/go/codec/encode.go b/vendor/github.com/ugorji/go/codec/encode.go
index ef4652945f..c2cef812ec 100644
--- a/vendor/github.com/ugorji/go/codec/encode.go
+++ b/vendor/github.com/ugorji/go/codec/encode.go
@@ -1,24 +1,42 @@
-// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved.
+// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved.
// Use of this source code is governed by a MIT license found in the LICENSE file.
package codec
import (
- "bufio"
"encoding"
- "errors"
"fmt"
"io"
"reflect"
"sort"
- "strconv"
"sync"
- "time"
)
-const defEncByteBufSize = 1 << 6 // 4:16, 6:64, 8:256, 10:1024
+const (
+ defEncByteBufSize = 1 << 6 // 4:16, 6:64, 8:256, 10:1024
+)
-var errEncoderNotInitialized = errors.New("Encoder not initialized")
+// AsSymbolFlag defines what should be encoded as symbols.
+type AsSymbolFlag uint8
+
+const (
+ // AsSymbolDefault is default.
+ // Currently, this means only encode struct field names as symbols.
+ // The default is subject to change.
+ AsSymbolDefault AsSymbolFlag = iota
+
+ // AsSymbolAll means encode anything which could be a symbol as a symbol.
+ AsSymbolAll = 0xfe
+
+ // AsSymbolNone means do not encode anything as a symbol.
+ AsSymbolNone = 1 << iota
+
+ // AsSymbolMapStringKeys means encode keys in map[string]XXX as symbols.
+ AsSymbolMapStringKeysFlag
+
+ // AsSymbolStructFieldName means encode struct field names as symbols.
+ AsSymbolStructFieldNameFlag
+)
// encWriter abstracts writing to a byte array or to an io.Writer.
type encWriter interface {
@@ -31,6 +49,8 @@ type encWriter interface {
// encDriver abstracts the actual codec (binc vs msgpack, etc)
type encDriver interface {
+ IsBuiltinType(rt uintptr) bool
+ EncodeBuiltin(rt uintptr, v interface{})
EncodeNil()
EncodeInt(i int64)
EncodeUint(i uint64)
@@ -40,78 +60,38 @@ type encDriver interface {
// encodeExtPreamble(xtag byte, length int)
EncodeRawExt(re *RawExt, e *Encoder)
EncodeExt(v interface{}, xtag uint64, ext Ext, e *Encoder)
+ EncodeArrayStart(length int)
+ EncodeMapStart(length int)
EncodeString(c charEncoding, v string)
- // EncodeSymbol(v string)
+ EncodeSymbol(v string)
EncodeStringBytes(c charEncoding, v []byte)
- EncodeTime(time.Time)
+ //TODO
//encBignum(f *big.Int)
//encStringRunes(c charEncoding, v []rune)
- WriteArrayStart(length int)
- WriteArrayElem()
- WriteArrayEnd()
- WriteMapStart(length int)
- WriteMapElemKey()
- WriteMapElemValue()
- WriteMapEnd()
reset()
- atEndOfEncode()
-}
-
-type ioEncStringWriter interface {
- WriteString(s string) (n int, err error)
}
type encDriverAsis interface {
EncodeAsis(v []byte)
}
-type encDriverNoopContainerWriter struct{}
+type encNoSeparator 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() {}
+func (_ encNoSeparator) EncodeEnd() {}
-type encDriverTrackContainerWriter struct {
- c containerState
+type ioEncWriterWriter interface {
+ WriteByte(c byte) error
+ WriteString(s string) (n int, err error)
+ Write(p []byte) (n int, err error)
}
-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 ioEncStringWriter interface {
+ WriteString(s string) (n int, err error)
+}
-// 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.
- //
- // if > 0, we use a smart buffer internally for performance purposes.
- WriterBufferSize int
-
- // ChanRecvTimeout is the timeout used when selecting from a chan.
- //
- // Configuring this controls how we receive from a chan during the encoding process.
- // - If ==0, we only consume the elements currently available in the chan.
- // - if <0, we consume until the chan is closed.
- // - If >0, we consume until this timeout.
- ChanRecvTimeout time.Duration
-
- // StructToArray specifies to encode a struct as an array, and not as a map
+ // Encode a struct as an array, and not as a map
StructToArray bool
// Canonical representation means that encoding a value will always result in the same
@@ -152,191 +132,330 @@ type EncodeOptions struct {
// If unset, we error out.
Raw bool
- // // AsSymbols defines what should be encoded as symbols.
- // //
- // // Encoding as symbols can reduce the encoded size significantly.
- // //
- // // However, during decoding, each string to be encoded as a symbol must
- // // be checked to see if it has been seen before. Consequently, encoding time
- // // will increase if using symbols, because string comparisons has a clear cost.
- // //
- // // Sample values:
- // // AsSymbolNone
- // // AsSymbolAll
- // // AsSymbolMapStringKeys
- // // AsSymbolMapStringKeysFlag | AsSymbolStructFieldNameFlag
- // AsSymbols AsSymbolFlag
+ // AsSymbols defines what should be encoded as symbols.
+ //
+ // Encoding as symbols can reduce the encoded size significantly.
+ //
+ // However, during decoding, each string to be encoded as a symbol must
+ // be checked to see if it has been seen before. Consequently, encoding time
+ // will increase if using symbols, because string comparisons has a clear cost.
+ //
+ // Sample values:
+ // AsSymbolNone
+ // AsSymbolAll
+ // AsSymbolMapStringKeys
+ // AsSymbolMapStringKeysFlag | AsSymbolStructFieldNameFlag
+ AsSymbols AsSymbolFlag
}
// ---------------------------------------------
-// ioEncWriter implements encWriter and can write to an io.Writer implementation
-type ioEncWriter struct {
+type simpleIoEncWriterWriter struct {
w io.Writer
- ww io.Writer
bw io.ByteWriter
sw ioEncStringWriter
- fw ioFlusher
- b [8]byte
+ bs [1]byte
}
-func (z *ioEncWriter) WriteByte(b byte) (err error) {
- z.b[0] = b
- _, err = z.w.Write(z.b[:1])
+func (o *simpleIoEncWriterWriter) WriteByte(c byte) (err error) {
+ if o.bw != nil {
+ return o.bw.WriteByte(c)
+ }
+ // _, err = o.w.Write([]byte{c})
+ o.bs[0] = c
+ _, err = o.w.Write(o.bs[:])
return
}
-func (z *ioEncWriter) WriteString(s string) (n int, err error) {
- return z.w.Write(bytesView(s))
+func (o *simpleIoEncWriterWriter) WriteString(s string) (n int, err error) {
+ if o.sw != nil {
+ return o.sw.WriteString(s)
+ }
+ // return o.w.Write([]byte(s))
+ return o.w.Write(bytesView(s))
+}
+
+func (o *simpleIoEncWriterWriter) Write(p []byte) (n int, err error) {
+ return o.w.Write(p)
+}
+
+// ----------------------------------------
+
+// ioEncWriter implements encWriter and can write to an io.Writer implementation
+type ioEncWriter struct {
+ w ioEncWriterWriter
+ s simpleIoEncWriterWriter
+ // x [8]byte // temp byte array re-used internally for efficiency
}
func (z *ioEncWriter) writeb(bs []byte) {
- if _, err := z.ww.Write(bs); err != nil {
+ if len(bs) == 0 {
+ return
+ }
+ n, err := z.w.Write(bs)
+ if err != nil {
panic(err)
}
+ if n != len(bs) {
+ panic(fmt.Errorf("incorrect num bytes written. Expecting: %v, Wrote: %v", len(bs), n))
+ }
}
func (z *ioEncWriter) writestr(s string) {
- if _, err := z.sw.WriteString(s); err != nil {
+ n, err := z.w.WriteString(s)
+ if err != nil {
panic(err)
}
+ if n != len(s) {
+ panic(fmt.Errorf("incorrect num bytes written. Expecting: %v, Wrote: %v", len(s), n))
+ }
}
func (z *ioEncWriter) writen1(b byte) {
- if err := z.bw.WriteByte(b); err != nil {
+ if err := z.w.WriteByte(b); err != nil {
panic(err)
}
}
-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 (z *ioEncWriter) writen2(b1 byte, b2 byte) {
+ z.writen1(b1)
+ z.writen1(b2)
}
-// 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)
-// }
-// }
+func (z *ioEncWriter) atEndOfEncode() {}
-func (z *ioEncWriter) atEndOfEncode() {
- if z.fw != nil {
- if err := z.fw.Flush(); err != nil {
- panic(err)
- }
- }
-}
+// ----------------------------------------
-// ---------------------------------------------
-
-// bytesEncAppender implements encWriter and can write to an byte slice.
-type bytesEncAppender struct {
+// bytesEncWriter implements encWriter and can write to an byte slice.
+// It is used by Marshal function.
+type bytesEncWriter struct {
b []byte
- out *[]byte
+ c int // cursor
+ out *[]byte // write out on atEndOfEncode
}
-func (z *bytesEncAppender) writeb(s []byte) {
- z.b = append(z.b, s...)
+func (z *bytesEncWriter) writeb(s []byte) {
+ if len(s) == 0 {
+ return
+ }
+ oc, a := z.growNoAlloc(len(s))
+ if a {
+ z.growAlloc(len(s), oc)
+ }
+ copy(z.b[oc:], s)
}
-func (z *bytesEncAppender) writestr(s string) {
- z.b = append(z.b, s...)
+
+func (z *bytesEncWriter) writestr(s string) {
+ if len(s) == 0 {
+ return
+ }
+ oc, a := z.growNoAlloc(len(s))
+ if a {
+ z.growAlloc(len(s), oc)
+ }
+ copy(z.b[oc:], s)
}
-func (z *bytesEncAppender) writen1(b1 byte) {
- z.b = append(z.b, b1)
+
+func (z *bytesEncWriter) writen1(b1 byte) {
+ oc, a := z.growNoAlloc(1)
+ if a {
+ z.growAlloc(1, oc)
+ }
+ z.b[oc] = b1
}
-func (z *bytesEncAppender) writen2(b1, b2 byte) {
- z.b = append(z.b, b1, b2)
+
+func (z *bytesEncWriter) writen2(b1 byte, b2 byte) {
+ oc, a := z.growNoAlloc(2)
+ if a {
+ z.growAlloc(2, oc)
+ }
+ z.b[oc+1] = b2
+ z.b[oc] = b1
}
-func (z *bytesEncAppender) atEndOfEncode() {
- *(z.out) = z.b
+
+func (z *bytesEncWriter) atEndOfEncode() {
+ *(z.out) = z.b[:z.c]
}
-func (z *bytesEncAppender) reset(in []byte, out *[]byte) {
- z.b = in[:0]
- z.out = out
+
+// have a growNoalloc(n int), which can be inlined.
+// if allocation is needed, then call growAlloc(n int)
+
+func (z *bytesEncWriter) growNoAlloc(n int) (oldcursor int, allocNeeded bool) {
+ oldcursor = z.c
+ z.c = z.c + n
+ if z.c > len(z.b) {
+ if z.c > cap(z.b) {
+ allocNeeded = true
+ } else {
+ z.b = z.b[:cap(z.b)]
+ }
+ }
+ return
+}
+
+func (z *bytesEncWriter) growAlloc(n int, oldcursor int) {
+ // appendslice logic (if cap < 1024, *2, else *1.25): more expensive. many copy calls.
+ // bytes.Buffer model (2*cap + n): much better
+ // bs := make([]byte, 2*cap(z.b)+n)
+ bs := make([]byte, growCap(cap(z.b), 1, n))
+ copy(bs, z.b[:oldcursor])
+ z.b = bs
}
// ---------------------------------------------
-func (e *Encoder) rawExt(f *codecFnInfo, rv reflect.Value) {
- e.e.EncodeRawExt(rv2i(rv).(*RawExt), e)
+type encFnInfo struct {
+ e *Encoder
+ ti *typeInfo
+ xfFn Ext
+ xfTag uint64
+ seq seqType
}
-func (e *Encoder) ext(f *codecFnInfo, rv reflect.Value) {
- e.e.EncodeExt(rv2i(rv), f.xfTag, f.xfFn, e)
+func (f *encFnInfo) builtin(rv reflect.Value) {
+ f.e.e.EncodeBuiltin(f.ti.rtid, rv.Interface())
}
-func (e *Encoder) selferMarshal(f *codecFnInfo, rv reflect.Value) {
- rv2i(rv).(Selfer).CodecEncodeSelf(e)
+func (f *encFnInfo) raw(rv reflect.Value) {
+ f.e.raw(rv.Interface().(Raw))
}
-func (e *Encoder) binaryMarshal(f *codecFnInfo, rv reflect.Value) {
- bs, fnerr := rv2i(rv).(encoding.BinaryMarshaler).MarshalBinary()
- e.marshal(bs, fnerr, false, cRAW)
+func (f *encFnInfo) rawExt(rv reflect.Value) {
+ // rev := rv.Interface().(RawExt)
+ // f.e.e.EncodeRawExt(&rev, f.e)
+ var re *RawExt
+ if rv.CanAddr() {
+ re = rv.Addr().Interface().(*RawExt)
+ } else {
+ rev := rv.Interface().(RawExt)
+ re = &rev
+ }
+ f.e.e.EncodeRawExt(re, f.e)
}
-func (e *Encoder) textMarshal(f *codecFnInfo, rv reflect.Value) {
- bs, fnerr := rv2i(rv).(encoding.TextMarshaler).MarshalText()
- e.marshal(bs, fnerr, false, cUTF8)
+func (f *encFnInfo) ext(rv reflect.Value) {
+ // if this is a struct|array and it was addressable, then pass the address directly (not the value)
+ if k := rv.Kind(); (k == reflect.Struct || k == reflect.Array) && rv.CanAddr() {
+ rv = rv.Addr()
+ }
+ f.e.e.EncodeExt(rv.Interface(), f.xfTag, f.xfFn, f.e)
}
-func (e *Encoder) jsonMarshal(f *codecFnInfo, rv reflect.Value) {
- bs, fnerr := rv2i(rv).(jsonMarshaler).MarshalJSON()
- e.marshal(bs, fnerr, true, cUTF8)
+func (f *encFnInfo) getValueForMarshalInterface(rv reflect.Value, indir int8) (v interface{}, proceed bool) {
+ if indir == 0 {
+ v = rv.Interface()
+ } else if indir == -1 {
+ // If a non-pointer was passed to Encode(), then that value is not addressable.
+ // Take addr if addressable, else copy value to an addressable value.
+ if rv.CanAddr() {
+ v = rv.Addr().Interface()
+ } else {
+ rv2 := reflect.New(rv.Type())
+ rv2.Elem().Set(rv)
+ v = rv2.Interface()
+ // fmt.Printf("rv.Type: %v, rv2.Type: %v, v: %v\n", rv.Type(), rv2.Type(), v)
+ }
+ } else {
+ for j := int8(0); j < indir; j++ {
+ if rv.IsNil() {
+ f.e.e.EncodeNil()
+ return
+ }
+ rv = rv.Elem()
+ }
+ v = rv.Interface()
+ }
+ return v, true
}
-func (e *Encoder) raw(f *codecFnInfo, rv reflect.Value) {
- e.rawBytes(rv2i(rv).(Raw))
+func (f *encFnInfo) selferMarshal(rv reflect.Value) {
+ if v, proceed := f.getValueForMarshalInterface(rv, f.ti.csIndir); proceed {
+ v.(Selfer).CodecEncodeSelf(f.e)
+ }
}
-func (e *Encoder) kInvalid(f *codecFnInfo, rv reflect.Value) {
- e.e.EncodeNil()
+func (f *encFnInfo) binaryMarshal(rv reflect.Value) {
+ if v, proceed := f.getValueForMarshalInterface(rv, f.ti.bmIndir); proceed {
+ bs, fnerr := v.(encoding.BinaryMarshaler).MarshalBinary()
+ f.e.marshal(bs, fnerr, false, c_RAW)
+ }
}
-func (e *Encoder) kErr(f *codecFnInfo, rv reflect.Value) {
- e.errorf("unsupported kind %s, for %#v", rv.Kind(), rv)
+func (f *encFnInfo) textMarshal(rv reflect.Value) {
+ if v, proceed := f.getValueForMarshalInterface(rv, f.ti.tmIndir); proceed {
+ // debugf(">>>> encoding.TextMarshaler: %T", rv.Interface())
+ bs, fnerr := v.(encoding.TextMarshaler).MarshalText()
+ f.e.marshal(bs, fnerr, false, c_UTF8)
+ }
}
-func (e *Encoder) kSlice(f *codecFnInfo, rv reflect.Value) {
+func (f *encFnInfo) jsonMarshal(rv reflect.Value) {
+ if v, proceed := f.getValueForMarshalInterface(rv, f.ti.jmIndir); proceed {
+ bs, fnerr := v.(jsonMarshaler).MarshalJSON()
+ f.e.marshal(bs, fnerr, true, c_UTF8)
+ }
+}
+
+func (f *encFnInfo) kBool(rv reflect.Value) {
+ f.e.e.EncodeBool(rv.Bool())
+}
+
+func (f *encFnInfo) kString(rv reflect.Value) {
+ f.e.e.EncodeString(c_UTF8, rv.String())
+}
+
+func (f *encFnInfo) kFloat64(rv reflect.Value) {
+ f.e.e.EncodeFloat64(rv.Float())
+}
+
+func (f *encFnInfo) kFloat32(rv reflect.Value) {
+ f.e.e.EncodeFloat32(float32(rv.Float()))
+}
+
+func (f *encFnInfo) kInt(rv reflect.Value) {
+ f.e.e.EncodeInt(rv.Int())
+}
+
+func (f *encFnInfo) kUint(rv reflect.Value) {
+ f.e.e.EncodeUint(rv.Uint())
+}
+
+func (f *encFnInfo) kInvalid(rv reflect.Value) {
+ f.e.e.EncodeNil()
+}
+
+func (f *encFnInfo) kErr(rv reflect.Value) {
+ f.e.errorf("unsupported kind %s, for %#v", rv.Kind(), rv)
+}
+
+func (f *encFnInfo) kSlice(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".
+ e := f.e
if f.seq != seqTypeArray {
if rv.IsNil() {
- ee.EncodeNil()
+ e.e.EncodeNil()
return
}
// If in this method, then there was no extension function defined.
// So it's okay to treat as []byte.
if ti.rtid == uint8SliceTypId {
- ee.EncodeStringBytes(cRAW, rv.Bytes())
+ e.e.EncodeStringBytes(c_RAW, rv.Bytes())
return
}
}
- 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 {
+ cr := e.cr
+ rtelem := ti.rt.Elem()
+ l := rv.Len()
+ if ti.rtid == uint8SliceTypId || rtelem.Kind() == reflect.Uint8 {
switch f.seq {
- case seqTypeSlice:
- ee.EncodeStringBytes(cRAW, rv.Bytes())
case seqTypeArray:
- l = rv.Len()
+ // if l == 0 { e.e.encodeStringBytes(c_RAW, nil) } else
if rv.CanAddr() {
- ee.EncodeStringBytes(cRAW, rv.Slice(0, l).Bytes())
+ e.e.EncodeStringBytes(c_RAW, rv.Slice(0, l).Bytes())
} else {
var bs []byte
if l <= cap(e.b) {
@@ -345,263 +464,116 @@ func (e *Encoder) kSlice(f *codecFnInfo, rv reflect.Value) {
bs = make([]byte, l)
}
reflect.Copy(reflect.ValueOf(bs), rv)
- ee.EncodeStringBytes(cRAW, bs)
+ // TODO: Test that reflect.Copy works instead of manual one-by-one
+ // for i := 0; i < l; i++ {
+ // bs[i] = byte(rv.Index(i).Uint())
+ // }
+ e.e.EncodeStringBytes(c_RAW, bs)
}
+ case seqTypeSlice:
+ e.e.EncodeStringBytes(c_RAW, rv.Bytes())
case seqTypeChan:
+ bs := e.b[:0]
// 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()
- break
+ // for b := range rv.Interface().(<-chan byte) {
+ // bs = append(bs, b)
+ // }
+ ch := rv.Interface().(<-chan byte)
+ for i := 0; i < l; i++ {
+ bs = append(bs, <-ch)
}
- 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.EncodeStringBytes(cRAW, bs)
+ e.e.EncodeStringBytes(c_RAW, bs)
}
return
}
- // if chan, consume chan into a slice, and work off that slice.
- var rvcs reflect.Value
- 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
- }
-
- l = rv.Len()
if ti.mbs {
if l%2 == 1 {
e.errorf("mapBySlice requires even slice length, but got %v", l)
return
}
- ee.WriteMapStart(l / 2)
+ e.e.EncodeMapStart(l / 2)
} else {
- ee.WriteArrayStart(l)
+ e.e.EncodeArrayStart(l)
}
if l > 0 {
- var 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.
+ var fn *encFn
if rtelem.Kind() != reflect.Interface {
- fn = e.cfer().get(rtelem, true, true)
+ rtelemid := reflect.ValueOf(rtelem).Pointer()
+ fn = e.getEncFn(rtelemid, rtelem, true, true)
}
+ // TODO: Consider perf implication of encoding odd index values as symbols if type is string
for j := 0; j < l; j++ {
- if elemsep {
+ if cr != nil {
if ti.mbs {
if j%2 == 0 {
- ee.WriteMapElemKey()
+ cr.sendContainerState(containerMapKey)
} else {
- ee.WriteMapElemValue()
+ cr.sendContainerState(containerMapValue)
}
} else {
- ee.WriteArrayElem()
+ cr.sendContainerState(containerArrayElem)
}
}
- e.encodeValue(rv.Index(j), fn, true)
+ if f.seq == seqTypeChan {
+ if rv2, ok2 := rv.Recv(); ok2 {
+ e.encodeValue(rv2, fn)
+ } else {
+ e.encode(nil) // WE HAVE TO DO SOMETHING, so nil if nothing received.
+ }
+ } else {
+ e.encodeValue(rv.Index(j), fn)
+ }
}
}
- if ti.mbs {
- ee.WriteMapEnd()
- } else {
- ee.WriteArrayEnd()
- }
-}
-
-func (e *Encoder) kStructNoOmitempty(f *codecFnInfo, rv reflect.Value) {
- fti := f.ti
- elemsep := e.esep
- tisfi := fti.sfiSrc
- toMap := !(fti.toArray || e.h.StructToArray)
- if toMap {
- tisfi = fti.sfiSort
- }
- ee := e.e
-
- sfn := structFieldNode{v: rv, update: false}
- if toMap {
- ee.WriteMapStart(len(tisfi))
- if elemsep {
- for _, si := range tisfi {
- ee.WriteMapElemKey()
- // ee.EncodeString(cUTF8, si.encName)
- encStructFieldKey(ee, fti.keyType, si.encName)
- ee.WriteMapElemValue()
- e.encodeValue(sfn.field(si), nil, true)
- }
+ if cr != nil {
+ if ti.mbs {
+ cr.sendContainerState(containerMapEnd)
} else {
- for _, si := range tisfi {
- // ee.EncodeString(cUTF8, si.encName)
- encStructFieldKey(ee, fti.keyType, si.encName)
- e.encodeValue(sfn.field(si), nil, true)
- }
+ cr.sendContainerState(containerArrayEnd)
}
- ee.WriteMapEnd()
- } else {
- ee.WriteArrayStart(len(tisfi))
- if elemsep {
- 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)
- }
- }
- ee.WriteArrayEnd()
}
}
-func encStructFieldKey(ee encDriver, keyType valueType, s string) {
- var m must
-
- // use if-else-if, not switch (which compiles to binary-search)
- // since keyType is typically valueTypeString, branch prediction is pretty good.
-
- if keyType == valueTypeString {
- ee.EncodeString(cUTF8, s)
- } else if keyType == valueTypeInt {
- ee.EncodeInt(m.Int(strconv.ParseInt(s, 10, 64)))
- } else if keyType == valueTypeUint {
- ee.EncodeUint(m.Uint(strconv.ParseUint(s, 10, 64)))
- } else if keyType == valueTypeFloat {
- ee.EncodeFloat64(m.Float(strconv.ParseFloat(s, 64)))
- } else {
- ee.EncodeString(cUTF8, s)
- }
-}
-
-func (e *Encoder) kStruct(f *codecFnInfo, rv reflect.Value) {
+func (f *encFnInfo) kStruct(rv reflect.Value) {
fti := f.ti
- elemsep := e.esep
- tisfi := fti.sfiSrc
+ e := f.e
+ cr := e.cr
+ tisfi := fti.sfip
toMap := !(fti.toArray || e.h.StructToArray)
- // if toMap, use the sorted array. If toArray, use unsorted array (to match sequence in struct)
- if toMap {
- tisfi = fti.sfiSort
- }
- newlen := len(fti.sfiSort)
- ee := e.e
+ newlen := len(fti.sfi)
// 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.
+ pool, poolv, fkvs := encStructPoolGet(newlen)
- var spool *sync.Pool
- var poolv interface{}
- var fkvs []stringRv
- // fmt.Printf(">>>>>>>>>>>>>> encode.kStruct: newlen: %d\n", newlen)
- if newlen <= 8 {
- spool, poolv = pool.stringRv8()
- fkvs = poolv.(*[8]stringRv)[:newlen]
- } else if newlen <= 16 {
- spool, poolv = pool.stringRv16()
- fkvs = poolv.(*[16]stringRv)[:newlen]
- } else if newlen <= 32 {
- spool, poolv = pool.stringRv32()
- fkvs = poolv.(*[32]stringRv)[:newlen]
- } else if newlen <= 64 {
- spool, poolv = pool.stringRv64()
- fkvs = poolv.(*[64]stringRv)[:newlen]
- } else if newlen <= 128 {
- spool, poolv = pool.stringRv128()
- fkvs = poolv.(*[128]stringRv)[:newlen]
- } else {
- fkvs = make([]stringRv, newlen)
+ // if toMap, use the sorted array. If toArray, use unsorted array (to match sequence in struct)
+ if toMap {
+ tisfi = fti.sfi
}
-
newlen = 0
var kv stringRv
recur := e.h.RecursiveEmptyCheck
- sfn := structFieldNode{v: rv, update: false}
for _, si := range tisfi {
- // kv.r = si.field(rv, false)
- kv.r = sfn.field(si)
+ kv.r = si.field(rv, false)
if toMap {
- if si.omitEmpty() && isEmptyValue(kv.r, e.h.TypeInfos, recur, recur) {
+ if si.omitEmpty && isEmptyValue(kv.r, recur, recur) {
continue
}
kv.v = 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) {
+ if si.omitEmpty && isEmptyValue(kv.r, 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
@@ -612,64 +584,91 @@ func (e *Encoder) kStruct(f *codecFnInfo, rv reflect.Value) {
newlen++
}
+ // debugf(">>>> kStruct: newlen: %v", newlen)
+ // sep := !e.be
+ ee := e.e //don't dereference every time
+
if toMap {
- ee.WriteMapStart(newlen)
- if elemsep {
- for j := 0; j < newlen; j++ {
- kv = fkvs[j]
- ee.WriteMapElemKey()
- // ee.EncodeString(cUTF8, kv.v)
- encStructFieldKey(ee, fti.keyType, kv.v)
- ee.WriteMapElemValue()
- e.encodeValue(kv.r, nil, true)
+ ee.EncodeMapStart(newlen)
+ // asSymbols := e.h.AsSymbols&AsSymbolStructFieldNameFlag != 0
+ asSymbols := e.h.AsSymbols == AsSymbolDefault || e.h.AsSymbols&AsSymbolStructFieldNameFlag != 0
+ for j := 0; j < newlen; j++ {
+ kv = fkvs[j]
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for j := 0; j < newlen; j++ {
- kv = fkvs[j]
- // ee.EncodeString(cUTF8, kv.v)
- encStructFieldKey(ee, fti.keyType, kv.v)
- e.encodeValue(kv.r, nil, true)
+ if asSymbols {
+ ee.EncodeSymbol(kv.v)
+ } else {
+ ee.EncodeString(c_UTF8, kv.v)
}
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encodeValue(kv.r, nil)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
- ee.WriteMapEnd()
} else {
- ee.WriteArrayStart(newlen)
- if elemsep {
- for j := 0; j < newlen; j++ {
- ee.WriteArrayElem()
- e.encodeValue(fkvs[j].r, nil, true)
- }
- } else {
- for j := 0; j < newlen; j++ {
- e.encodeValue(fkvs[j].r, nil, true)
+ ee.EncodeArrayStart(newlen)
+ for j := 0; j < newlen; j++ {
+ kv = fkvs[j]
+ if cr != nil {
+ cr.sendContainerState(containerArrayElem)
}
+ e.encodeValue(kv.r, nil)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerArrayEnd)
}
- ee.WriteArrayEnd()
}
// 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.
- if spool != nil {
- spool.Put(poolv)
+ if pool != nil {
+ pool.Put(poolv)
}
}
-func (e *Encoder) kMap(f *codecFnInfo, rv reflect.Value) {
- ee := e.e
+// func (f *encFnInfo) kPtr(rv reflect.Value) {
+// debugf(">>>>>>> ??? encode kPtr called - shouldn't get called")
+// if rv.IsNil() {
+// f.e.e.encodeNil()
+// return
+// }
+// f.e.encodeValue(rv.Elem())
+// }
+
+// func (f *encFnInfo) kInterface(rv reflect.Value) {
+// println("kInterface called")
+// debug.PrintStack()
+// if rv.IsNil() {
+// f.e.e.EncodeNil()
+// return
+// }
+// f.e.encodeValue(rv.Elem(), nil)
+// }
+
+func (f *encFnInfo) kMap(rv reflect.Value) {
+ ee := f.e.e
if rv.IsNil() {
ee.EncodeNil()
return
}
l := rv.Len()
- ee.WriteMapStart(l)
- elemsep := e.esep
+ ee.EncodeMapStart(l)
+ e := f.e
+ cr := e.cr
if l == 0 {
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
return
}
- // var asSymbols bool
+ 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.
@@ -677,295 +676,269 @@ 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
+ var keyFn, valFn *encFn
ti := f.ti
- rtkey0 := ti.key
- rtkey := rtkey0
- rtval0 := ti.elem
- rtval := rtval0
- // rtkeyid := rt2id(rtkey0)
- for rtval.Kind() == reflect.Ptr {
- rtval = rtval.Elem()
- }
- if rtval.Kind() != reflect.Interface {
- valFn = e.cfer().get(rtval, true, true)
- }
- mks := rv.MapKeys()
-
- if e.h.Canonical {
- e.kMapCanonical(rtkey, rv, mks, valFn)
- ee.WriteMapEnd()
- return
- }
-
- var keyTypeIsString = stringTypId == rt2id(rtkey0) // rtkeyid
- if !keyTypeIsString {
+ rtkey := ti.rt.Key()
+ rtval := ti.rt.Elem()
+ rtkeyid := reflect.ValueOf(rtkey).Pointer()
+ // keyTypeIsString := f.ti.rt.Key().Kind() == reflect.String
+ var keyTypeIsString = rtkeyid == stringTypId
+ if keyTypeIsString {
+ asSymbols = e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0
+ } else {
for rtkey.Kind() == reflect.Ptr {
rtkey = rtkey.Elem()
}
if rtkey.Kind() != reflect.Interface {
- // rtkeyid = rt2id(rtkey)
- keyFn = e.cfer().get(rtkey, true, true)
+ rtkeyid = reflect.ValueOf(rtkey).Pointer()
+ keyFn = e.getEncFn(rtkeyid, rtkey, true, true)
}
}
-
+ for rtval.Kind() == reflect.Ptr {
+ rtval = rtval.Elem()
+ }
+ if rtval.Kind() != reflect.Interface {
+ rtvalid := reflect.ValueOf(rtval).Pointer()
+ valFn = e.getEncFn(rtvalid, rtval, true, true)
+ }
+ mks := rv.MapKeys()
// for j, lmks := 0, len(mks); j < lmks; j++ {
- for j := range mks {
- if elemsep {
- ee.WriteMapElemKey()
- }
- if keyTypeIsString {
- ee.EncodeString(cUTF8, mks[j].String())
- } else {
- e.encodeValue(mks[j], keyFn, true)
- }
- if elemsep {
- ee.WriteMapElemValue()
- }
- e.encodeValue(rv.MapIndex(mks[j]), valFn, true)
+ if e.h.Canonical {
+ e.kMapCanonical(rtkeyid, rtkey, rv, mks, valFn, asSymbols)
+ } else {
+ for j := range mks {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ if keyTypeIsString {
+ if asSymbols {
+ ee.EncodeSymbol(mks[j].String())
+ } else {
+ ee.EncodeString(c_UTF8, mks[j].String())
+ }
+ } else {
+ e.encodeValue(mks[j], keyFn)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encodeValue(rv.MapIndex(mks[j]), valFn)
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
- ee.WriteMapEnd()
}
-func (e *Encoder) kMapCanonical(rtkey reflect.Type, rv reflect.Value, mks []reflect.Value, valFn *codecFn) {
+func (e *Encoder) kMapCanonical(rtkeyid uintptr, rtkey reflect.Type, rv reflect.Value, mks []reflect.Value, valFn *encFn, asSymbols bool) {
ee := e.e
- elemsep := e.esep
+ cr := e.cr
// we previously did out-of-band if an extension was registered.
// This is not necessary, as the natural kind is sufficient for ordering.
- switch rtkey.Kind() {
- case reflect.Bool:
- mksv := make([]boolRv, len(mks))
+ if rtkeyid == uint8SliceTypId {
+ mksv := make([]bytesRv, len(mks))
for i, k := range mks {
v := &mksv[i]
v.r = k
- v.v = k.Bool()
+ v.v = k.Bytes()
}
- sort.Sort(boolRvSlice(mksv))
+ sort.Sort(bytesRvSlice(mksv))
for i := range mksv {
- if elemsep {
- ee.WriteMapElemKey()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- ee.EncodeBool(mksv[i].v)
- if elemsep {
- ee.WriteMapElemValue()
+ ee.EncodeStringBytes(c_RAW, mksv[i].v)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
- e.encodeValue(rv.MapIndex(mksv[i].r), valFn, true)
+ e.encodeValue(rv.MapIndex(mksv[i].r), valFn)
}
- case reflect.String:
- mksv := make([]stringRv, len(mks))
- for i, k := range mks {
- v := &mksv[i]
- v.r = k
- v.v = k.String()
- }
- sort.Sort(stringRvSlice(mksv))
- for i := range mksv {
- if elemsep {
- ee.WriteMapElemKey()
- }
- ee.EncodeString(cUTF8, mksv[i].v)
- if elemsep {
- ee.WriteMapElemValue()
- }
- e.encodeValue(rv.MapIndex(mksv[i].r), valFn, true)
- }
- case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint, reflect.Uintptr:
- mksv := make([]uintRv, len(mks))
- for i, k := range mks {
- v := &mksv[i]
- v.r = k
- v.v = k.Uint()
- }
- sort.Sort(uintRvSlice(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)
- }
- case reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int:
- mksv := make([]intRv, len(mks))
- for i, k := range mks {
- v := &mksv[i]
- v.r = k
- v.v = k.Int()
- }
- sort.Sort(intRvSlice(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)
- }
- case reflect.Float32:
- mksv := make([]floatRv, len(mks))
- for i, k := range mks {
- v := &mksv[i]
- v.r = k
- v.v = k.Float()
- }
- sort.Sort(floatRvSlice(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)
- }
- case reflect.Float64:
- mksv := make([]floatRv, len(mks))
- for i, k := range mks {
- v := &mksv[i]
- v.r = k
- v.v = k.Float()
- }
- sort.Sort(floatRvSlice(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)
- }
- case reflect.Struct:
- if rv.Type() == timeTyp {
- mksv := make([]timeRv, len(mks))
+ } else {
+ switch rtkey.Kind() {
+ case reflect.Bool:
+ mksv := make([]boolRv, len(mks))
for i, k := range mks {
v := &mksv[i]
v.r = k
- v.v = rv2i(k).(time.Time)
+ v.v = k.Bool()
}
- sort.Sort(timeRvSlice(mksv))
+ sort.Sort(boolRvSlice(mksv))
for i := range mksv {
- if elemsep {
- ee.WriteMapElemKey()
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- ee.EncodeTime(mksv[i].v)
- if elemsep {
- ee.WriteMapElemValue()
+ ee.EncodeBool(mksv[i].v)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
- e.encodeValue(rv.MapIndex(mksv[i].r), valFn, true)
+ e.encodeValue(rv.MapIndex(mksv[i].r), valFn)
}
- break
- }
- fallthrough
- 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
- e2 := NewEncoderBytes(&mksv, e.hh)
- mksbv := make([]bytesRv, len(mks))
- for i, k := range mks {
- v := &mksbv[i]
- l := len(mksv)
- e2.MustEncode(k)
- v.r = k
- v.v = mksv[l:]
- }
- sort.Sort(bytesRvSlice(mksbv))
- for j := range mksbv {
- if elemsep {
- ee.WriteMapElemKey()
+ case reflect.String:
+ mksv := make([]stringRv, len(mks))
+ for i, k := range mks {
+ v := &mksv[i]
+ v.r = k
+ v.v = k.String()
}
- e.asis(mksbv[j].v)
- if elemsep {
- ee.WriteMapElemValue()
+ sort.Sort(stringRvSlice(mksv))
+ for i := range mksv {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ if asSymbols {
+ ee.EncodeSymbol(mksv[i].v)
+ } else {
+ ee.EncodeString(c_UTF8, mksv[i].v)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encodeValue(rv.MapIndex(mksv[i].r), valFn)
+ }
+ case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint, reflect.Uintptr:
+ mksv := make([]uintRv, len(mks))
+ for i, k := range mks {
+ v := &mksv[i]
+ v.r = k
+ v.v = k.Uint()
+ }
+ sort.Sort(uintRvSlice(mksv))
+ for i := range mksv {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(mksv[i].v)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encodeValue(rv.MapIndex(mksv[i].r), valFn)
+ }
+ case reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int:
+ mksv := make([]intRv, len(mks))
+ for i, k := range mks {
+ v := &mksv[i]
+ v.r = k
+ v.v = k.Int()
+ }
+ sort.Sort(intRvSlice(mksv))
+ for i := range mksv {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeInt(mksv[i].v)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encodeValue(rv.MapIndex(mksv[i].r), valFn)
+ }
+ case reflect.Float32:
+ mksv := make([]floatRv, len(mks))
+ for i, k := range mks {
+ v := &mksv[i]
+ v.r = k
+ v.v = k.Float()
+ }
+ sort.Sort(floatRvSlice(mksv))
+ for i := range mksv {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat32(float32(mksv[i].v))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encodeValue(rv.MapIndex(mksv[i].r), valFn)
+ }
+ case reflect.Float64:
+ mksv := make([]floatRv, len(mks))
+ for i, k := range mks {
+ v := &mksv[i]
+ v.r = k
+ v.v = k.Float()
+ }
+ sort.Sort(floatRvSlice(mksv))
+ for i := range mksv {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat64(mksv[i].v)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encodeValue(rv.MapIndex(mksv[i].r), valFn)
+ }
+ 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
+ e2 := NewEncoderBytes(&mksv, e.hh)
+ mksbv := make([]bytesRv, len(mks))
+ for i, k := range mks {
+ v := &mksbv[i]
+ l := len(mksv)
+ e2.MustEncode(k)
+ v.r = k
+ v.v = mksv[l:]
+ // fmt.Printf(">>>>> %s\n", mksv[l:])
+ }
+ sort.Sort(bytesRvSlice(mksbv))
+ for j := range mksbv {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.asis(mksbv[j].v)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encodeValue(rv.MapIndex(mksbv[j].r), valFn)
}
- e.encodeValue(rv.MapIndex(mksbv[j].r), valFn, true)
}
}
}
-// // --------------------------------------------------
+// --------------------------------------------------
-type encWriterSwitch struct {
- wi *ioEncWriter
- // wb bytesEncWriter
- wb bytesEncAppender
- wx bool // if bytes, wx=true
- esep bool // whether it has elem separators
- isas bool // whether e.as != nil
+// encFn encapsulates the captured variables and the encode function.
+// This way, we only do some calculations one times, and pass to the
+// code block that should be called (encapsulated in a function)
+// instead of executing the checks every time.
+type encFn struct {
+ i encFnInfo
+ f func(*encFnInfo, reflect.Value)
}
-// // TODO: Uncomment after mid-stack inlining enabled in go 1.11
+// --------------------------------------------------
-// func (z *encWriterSwitch) writeb(s []byte) {
-// if z.wx {
-// z.wb.writeb(s)
-// } else {
-// z.wi.writeb(s)
-// }
-// }
-// func (z *encWriterSwitch) writestr(s string) {
-// if z.wx {
-// z.wb.writestr(s)
-// } else {
-// z.wi.writestr(s)
-// }
-// }
-// func (z *encWriterSwitch) writen1(b1 byte) {
-// if z.wx {
-// z.wb.writen1(b1)
-// } else {
-// z.wi.writen1(b1)
-// }
-// }
-// func (z *encWriterSwitch) writen2(b1, b2 byte) {
-// if z.wx {
-// z.wb.writen2(b1, b2)
-// } else {
-// z.wi.writen2(b1, b2)
-// }
-// }
+type encRtidFn struct {
+ rtid uintptr
+ fn encFn
+}
// An Encoder writes an object to an output stream in the codec format.
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 encWriter
+ w encWriter
+ s []encRtidFn
+ ci set
+ be bool // is binary encoding
+ js bool // is json handle
+
+ wi ioEncWriter
+ wb bytesEncWriter
h *BasicHandle
- bw *bufio.Writer
+ hh Handle
+
+ cr containerStateRecv
as encDriverAsis
- // ---- cpu cache line boundary?
-
- // ---- cpu cache line boundary?
- encWriterSwitch
- err error
-
- // ---- cpu cache line boundary?
- codecFnPooler
- ci set
- js bool // here, so that no need to piggy back on *codecFner for this
- be bool // here, so that no need to piggy back on *codecFner for this
- _ [6]byte // padding
-
- // ---- writable fields during execution --- *try* to keep in sep cache line
-
- // ---- cpu cache line boundary?
- // b [scratchByteArrayLen]byte
- // _ [cacheLineSize - scratchByteArrayLen]byte // padding
- b [cacheLineSize - 0]byte // used for encoding a chan or (non-addressable) array of bytes
+ f map[uintptr]*encFn
+ b [scratchByteArrayLen]byte
}
// NewEncoder returns an Encoder for encoding into an io.Writer.
@@ -990,95 +963,59 @@ func NewEncoderBytes(out *[]byte, h Handle) *Encoder {
}
func newEncoder(h Handle) *Encoder {
- e := &Encoder{h: h.getBasicHandle(), err: errEncoderNotInitialized}
- e.hh = h
- e.esep = h.hasElemSeparators()
+ e := &Encoder{hh: h, h: h.getBasicHandle(), be: h.isBinary()}
+ _, e.js = h.(*JsonHandle)
+ e.e = h.newEncDriver(e)
+ e.as, _ = e.e.(encDriverAsis)
+ e.cr, _ = e.e.(containerStateRecv)
return e
}
-func (e *Encoder) resetCommon() {
- 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()
- e.err = nil
-}
-
-// Reset resets the Encoder with a new output stream.
+// Reset the Encoder with a new output stream.
//
// This accommodates using the state of the Encoder,
// where it has "cached" information about sub-engines.
func (e *Encoder) Reset(w io.Writer) {
- if w == nil {
- return
- }
- if e.wi == nil {
- e.wi = new(ioEncWriter)
- }
- var ok bool
- e.wx = false
- e.wi.w = w
- if e.h.WriterBufferSize > 0 {
- e.bw = bufio.NewWriterSize(w, e.h.WriterBufferSize)
- e.wi.bw = e.bw
- e.wi.sw = e.bw
- e.wi.fw = e.bw
- e.wi.ww = e.bw
+ ww, ok := w.(ioEncWriterWriter)
+ if ok {
+ e.wi.w = ww
} else {
- if e.wi.bw, ok = w.(io.ByteWriter); !ok {
- e.wi.bw = e.wi
- }
- if e.wi.sw, ok = w.(ioEncStringWriter); !ok {
- e.wi.sw = e.wi
- }
- e.wi.fw, _ = w.(ioFlusher)
- e.wi.ww = w
+ sww := &e.wi.s
+ sww.w = w
+ sww.bw, _ = w.(io.ByteWriter)
+ sww.sw, _ = w.(ioEncStringWriter)
+ e.wi.w = sww
+ //ww = bufio.NewWriterSize(w, defEncByteBufSize)
}
- e.w = e.wi
- e.resetCommon()
+ e.w = &e.wi
+ e.e.reset()
}
-// ResetBytes resets the Encoder with a new destination output []byte.
func (e *Encoder) ResetBytes(out *[]byte) {
- if out == nil {
- return
- }
- var in []byte
- if out != nil {
- in = *out
- }
+ in := *out
if in == nil {
in = make([]byte, defEncByteBufSize)
}
- e.wx = true
- e.wb.reset(in, out)
+ e.wb.b, e.wb.out, e.wb.c = in, out, 0
e.w = &e.wb
- e.resetCommon()
+ e.e.reset()
}
+// func (e *Encoder) sendContainerState(c containerState) {
+// if e.cr != nil {
+// e.cr.sendContainerState(c)
+// }
+// }
+
// Encode writes an object into a stream.
//
// Encoding can be configured via the struct tag for the fields.
-// The key (in the struct tags) that we look at is configurable.
-//
-// By default, we look up the "codec" key in the struct field's tags,
-// and fall bak to the "json" key if "codec" is absent.
-// That key in struct field's tag value is the key name,
+// The "codec" key in struct field's tag value is the key name,
// followed by an optional comma and options.
+// Note that the "json" key is used in the absence of the "codec" key.
//
// To set an option on all fields (e.g. omitempty on all fields), you
-// can create a field called _struct, and set flags on it. The options
-// which can be set on _struct are:
-// - omitempty: so all fields are omitted if empty
-// - toarray: so struct is encoded as an array
-// - int: so struct key names are encoded as signed integers (instead of strings)
-// - uint: so struct key names are encoded as unsigned integers (instead of strings)
-// - float: so struct key names are encoded as floats (instead of strings)
-// More details on these below.
+// can create a field called _struct, and set flags on it.
//
// Struct values "usually" encode as maps. Each exported struct field is encoded unless:
// - the field's tag is "-", OR
@@ -1086,19 +1023,10 @@ func (e *Encoder) ResetBytes(out *[]byte) {
//
// When encoding as a map, the first string in the tag (before the comma)
// is the map key string to use when encoding.
-// ...
-// This key is typically encoded as a string.
-// However, there are instances where the encoded stream has mapping keys encoded as numbers.
-// For example, some cbor streams have keys as integer codes in the stream, but they should map
-// to fields in a structured object. Consequently, a struct is the natural representation in code.
-// For these, configure the struct to encode/decode the keys as numbers (instead of string).
-// This is done with the int,uint or float option on the _struct field (see above).
//
// However, struct values may encode as arrays. This happens when:
// - StructToArray Encode option is set, OR
// - the tag on the _struct field sets the "toarray" option
-// Note that omitempty is ignored when encoding struct values as arrays,
-// as an entry must be encoded for each field, to maintain its position.
//
// Values with types that implement MapBySlice are encoded as stream maps.
//
@@ -1125,77 +1053,51 @@ func (e *Encoder) ResetBytes(out *[]byte) {
// }
//
// type MyStruct struct {
-// _struct bool `codec:",toarray"` //encode struct as an array
-// }
-//
-// type MyStruct struct {
-// _struct bool `codec:",uint"` //encode struct with "unsigned integer" keys
-// Field1 string `codec:"1"` //encode Field1 key using: EncodeInt(1)
-// Field2 string `codec:"2"` //encode Field2 key using: EncodeInt(2)
+// _struct bool `codec:",omitempty,toarray"` //set omitempty for every field
+// //and encode struct as an array
// }
//
// The mode of encoding is based on the type of the value. When a value is seen:
// - If a Selfer, call its CodecEncodeSelf method
// - If an extension is registered for it, call that extension function
-// - If implements encoding.(Binary|Text|JSON)Marshaler, call Marshal(Binary|Text|JSON) method
+// - If it implements encoding.(Binary|Text|JSON)Marshaler, call its Marshal(Binary|Text|JSON) method
// - Else encode it based on its reflect.Kind
//
// Note that struct field names and keys in map[string]XXX will be treated as symbols.
// Some formats support symbols (e.g. binc) and will properly encode the string
// only once in the stream, and use a tag to refer to it thereafter.
func (e *Encoder) Encode(v interface{}) (err error) {
- defer e.deferred(&err)
- e.MustEncode(v)
+ defer panicToErr(&err)
+ e.encode(v)
+ e.w.atEndOfEncode()
return
}
// MustEncode is like Encode, but panics if unable to Encode.
// This provides insight to the code location that triggered the error.
func (e *Encoder) MustEncode(v interface{}) {
- if e.err != nil {
- panic(e.err)
- }
e.encode(v)
- e.e.atEndOfEncode()
e.w.atEndOfEncode()
- e.alwaysAtEnd()
}
-func (e *Encoder) deferred(err1 *error) {
- e.alwaysAtEnd()
- if recoverPanicToErr {
- if x := recover(); x != nil {
- panicValToErr(e, x, err1)
- panicValToErr(e, x, &e.err)
- }
- }
-}
-
-// func (e *Encoder) alwaysAtEnd() {
-// e.codecFnPooler.alwaysAtEnd()
-// }
-
func (e *Encoder) encode(iv interface{}) {
- if iv == nil || definitelyNil(iv) {
- e.e.EncodeNil()
- return
- }
- if v, ok := iv.(Selfer); ok {
- v.CodecEncodeSelf(e)
- return
- }
-
- // a switch with only concrete types can be optimized.
- // consequently, we deal with nil and interfaces outside.
+ // if ics, ok := iv.(Selfer); ok {
+ // ics.CodecEncodeSelf(e)
+ // return
+ // }
switch v := iv.(type) {
+ case nil:
+ e.e.EncodeNil()
+ case Selfer:
+ v.CodecEncodeSelf(e)
case Raw:
- e.rawBytes(v)
+ e.raw(v)
case reflect.Value:
- e.encodeValue(v, nil, true)
+ e.encodeValue(v, nil)
case string:
- e.e.EncodeString(cUTF8, v)
+ e.e.EncodeString(c_UTF8, v)
case bool:
e.e.EncodeBool(v)
case int:
@@ -1218,22 +1120,16 @@ func (e *Encoder) encode(iv interface{}) {
e.e.EncodeUint(uint64(v))
case uint64:
e.e.EncodeUint(v)
- case uintptr:
- e.e.EncodeUint(uint64(v))
case float32:
e.e.EncodeFloat32(v)
case float64:
e.e.EncodeFloat64(v)
- case time.Time:
- e.e.EncodeTime(v)
- case []uint8:
- e.e.EncodeStringBytes(cRAW, v)
- case *Raw:
- e.rawBytes(*v)
+ case []uint8:
+ e.e.EncodeStringBytes(c_RAW, v)
case *string:
- e.e.EncodeString(cUTF8, *v)
+ e.e.EncodeString(c_UTF8, *v)
case *bool:
e.e.EncodeBool(*v)
case *int:
@@ -1256,31 +1152,24 @@ func (e *Encoder) encode(iv interface{}) {
e.e.EncodeUint(uint64(*v))
case *uint64:
e.e.EncodeUint(*v)
- case *uintptr:
- e.e.EncodeUint(uint64(*v))
case *float32:
e.e.EncodeFloat32(*v)
case *float64:
e.e.EncodeFloat64(*v)
- case *time.Time:
- e.e.EncodeTime(*v)
case *[]uint8:
- e.e.EncodeStringBytes(cRAW, *v)
+ e.e.EncodeStringBytes(c_RAW, *v)
default:
+ const checkCodecSelfer1 = true // in case T is passed, where *T is a Selfer, still checkCodecSelfer
if !fastpathEncodeTypeSwitch(iv, e) {
- // checkfastpath=true (not false), as underlying slice/map type may be fast-path
- e.encodeValue(reflect.ValueOf(iv), nil, true)
+ e.encodeI(iv, false, checkCodecSelfer1)
}
}
}
-func (e *Encoder) encodeValue(rv reflect.Value, fn *codecFn, checkFastpath bool) {
- // if a valid fn is passed, it MUST BE for the dereferenced type of rv
- var sptr uintptr
- var rvp reflect.Value
- var rvpValid bool
+func (e *Encoder) preEncodeValue(rv reflect.Value) (rv2 reflect.Value, sptr uintptr, proceed bool) {
+ // use a goto statement instead of a recursive function for ptr/interface.
TOP:
switch rv.Kind() {
case reflect.Ptr:
@@ -1288,8 +1177,6 @@ TOP:
e.e.EncodeNil()
return
}
- rvpValid = true
- rvp = rv
rv = rv.Elem()
if e.h.CheckCircularRef && rv.Kind() == reflect.Struct {
// TODO: Movable pointers will be an issue here. Future problem.
@@ -1314,33 +1201,167 @@ TOP:
return
}
- if sptr != 0 && (&e.ci).add(sptr) {
- e.errorf("circular reference found: # %d", sptr)
- }
+ proceed = true
+ rv2 = rv
+ return
+}
+func (e *Encoder) doEncodeValue(rv reflect.Value, fn *encFn, sptr uintptr,
+ checkFastpath, checkCodecSelfer bool) {
+ if sptr != 0 {
+ if (&e.ci).add(sptr) {
+ e.errorf("circular reference found: # %d", sptr)
+ }
+ }
if fn == nil {
rt := rv.Type()
- // always pass checkCodecSelfer=true, in case T or ****T is passed, where *T is a Selfer
- fn = e.cfer().get(rt, checkFastpath, true)
- }
- if fn.i.addrE {
- if rvpValid {
- fn.fe(e, &fn.i, rvp)
- } else if rv.CanAddr() {
- fn.fe(e, &fn.i, rv.Addr())
- } else {
- rv2 := reflect.New(rv.Type())
- rv2.Elem().Set(rv)
- fn.fe(e, &fn.i, rv2)
- }
- } else {
- fn.fe(e, &fn.i, rv)
+ rtid := reflect.ValueOf(rt).Pointer()
+ // fn = e.getEncFn(rtid, rt, true, true)
+ fn = e.getEncFn(rtid, rt, checkFastpath, checkCodecSelfer)
}
+ fn.f(&fn.i, rv)
if sptr != 0 {
(&e.ci).remove(sptr)
}
}
+func (e *Encoder) encodeI(iv interface{}, checkFastpath, checkCodecSelfer bool) {
+ if rv, sptr, proceed := e.preEncodeValue(reflect.ValueOf(iv)); proceed {
+ e.doEncodeValue(rv, nil, sptr, checkFastpath, checkCodecSelfer)
+ }
+}
+
+func (e *Encoder) encodeValue(rv reflect.Value, fn *encFn) {
+ // if a valid fn is passed, it MUST BE for the dereferenced type of rv
+ if rv, sptr, proceed := e.preEncodeValue(rv); proceed {
+ e.doEncodeValue(rv, fn, sptr, true, true)
+ }
+}
+
+func (e *Encoder) getEncFn(rtid uintptr, rt reflect.Type, checkFastpath, checkCodecSelfer bool) (fn *encFn) {
+ // rtid := reflect.ValueOf(rt).Pointer()
+ var ok bool
+ if useMapForCodecCache {
+ fn, ok = e.f[rtid]
+ } else {
+ for i := range e.s {
+ v := &(e.s[i])
+ if v.rtid == rtid {
+ fn, ok = &(v.fn), true
+ break
+ }
+ }
+ }
+ if ok {
+ return
+ }
+
+ if useMapForCodecCache {
+ if e.f == nil {
+ e.f = make(map[uintptr]*encFn, initCollectionCap)
+ }
+ fn = new(encFn)
+ e.f[rtid] = fn
+ } else {
+ if e.s == nil {
+ e.s = make([]encRtidFn, 0, initCollectionCap)
+ }
+ e.s = append(e.s, encRtidFn{rtid: rtid})
+ fn = &(e.s[len(e.s)-1]).fn
+ }
+
+ ti := e.h.getTypeInfo(rtid, rt)
+ fi := &(fn.i)
+ fi.e = e
+ fi.ti = ti
+
+ if checkCodecSelfer && ti.cs {
+ fn.f = (*encFnInfo).selferMarshal
+ } else if rtid == rawTypId {
+ fn.f = (*encFnInfo).raw
+ } else if rtid == rawExtTypId {
+ fn.f = (*encFnInfo).rawExt
+ } else if e.e.IsBuiltinType(rtid) {
+ fn.f = (*encFnInfo).builtin
+ } else if xfFn := e.h.getExt(rtid); xfFn != nil {
+ fi.xfTag, fi.xfFn = xfFn.tag, xfFn.ext
+ fn.f = (*encFnInfo).ext
+ } else if supportMarshalInterfaces && e.be && ti.bm {
+ fn.f = (*encFnInfo).binaryMarshal
+ } else if supportMarshalInterfaces && !e.be && e.js && ti.jm {
+ //If JSON, we should check JSONMarshal before textMarshal
+ fn.f = (*encFnInfo).jsonMarshal
+ } else if supportMarshalInterfaces && !e.be && ti.tm {
+ fn.f = (*encFnInfo).textMarshal
+ } else {
+ rk := rt.Kind()
+ if fastpathEnabled && checkFastpath && (rk == reflect.Map || rk == reflect.Slice) {
+ if rt.PkgPath() == "" { // un-named slice or map
+ if idx := fastpathAV.index(rtid); idx != -1 {
+ fn.f = fastpathAV[idx].encfn
+ }
+ } else {
+ ok = false
+ // use mapping for underlying type if there
+ var rtu reflect.Type
+ if rk == reflect.Map {
+ rtu = reflect.MapOf(rt.Key(), rt.Elem())
+ } else {
+ rtu = reflect.SliceOf(rt.Elem())
+ }
+ rtuid := reflect.ValueOf(rtu).Pointer()
+ if idx := fastpathAV.index(rtuid); idx != -1 {
+ xfnf := fastpathAV[idx].encfn
+ xrt := fastpathAV[idx].rt
+ fn.f = func(xf *encFnInfo, xrv reflect.Value) {
+ xfnf(xf, xrv.Convert(xrt))
+ }
+ }
+ }
+ }
+ if fn.f == nil {
+ switch rk {
+ case reflect.Bool:
+ fn.f = (*encFnInfo).kBool
+ case reflect.String:
+ fn.f = (*encFnInfo).kString
+ case reflect.Float64:
+ fn.f = (*encFnInfo).kFloat64
+ case reflect.Float32:
+ fn.f = (*encFnInfo).kFloat32
+ case reflect.Int, reflect.Int8, reflect.Int64, reflect.Int32, reflect.Int16:
+ fn.f = (*encFnInfo).kInt
+ case reflect.Uint8, reflect.Uint64, reflect.Uint, reflect.Uint32, reflect.Uint16, reflect.Uintptr:
+ fn.f = (*encFnInfo).kUint
+ case reflect.Invalid:
+ fn.f = (*encFnInfo).kInvalid
+ case reflect.Chan:
+ fi.seq = seqTypeChan
+ fn.f = (*encFnInfo).kSlice
+ case reflect.Slice:
+ fi.seq = seqTypeSlice
+ fn.f = (*encFnInfo).kSlice
+ case reflect.Array:
+ fi.seq = seqTypeArray
+ fn.f = (*encFnInfo).kSlice
+ case reflect.Struct:
+ fn.f = (*encFnInfo).kStruct
+ // reflect.Ptr and reflect.Interface are handled already by preEncodeValue
+ // case reflect.Ptr:
+ // fn.f = (*encFnInfo).kPtr
+ // case reflect.Interface:
+ // fn.f = (*encFnInfo).kInterface
+ case reflect.Map:
+ fn.f = (*encFnInfo).kMap
+ default:
+ fn.f = (*encFnInfo).kErr
+ }
+ }
+ }
+
+ return
+}
+
func (e *Encoder) marshal(bs []byte, fnerr error, asis bool, c charEncoding) {
if fnerr != nil {
panic(fnerr)
@@ -1355,21 +1376,86 @@ func (e *Encoder) marshal(bs []byte, fnerr error, asis bool, c charEncoding) {
}
func (e *Encoder) asis(v []byte) {
- if e.isas {
- e.as.EncodeAsis(v)
- } else {
+ if e.as == nil {
e.w.writeb(v)
+ } else {
+ e.as.EncodeAsis(v)
}
}
-func (e *Encoder) rawBytes(vv Raw) {
+func (e *Encoder) raw(vv Raw) {
v := []byte(vv)
if !e.h.Raw {
e.errorf("Raw values cannot be encoded: %v", v)
}
- e.asis(v)
+ if e.as == nil {
+ e.w.writeb(v)
+ } else {
+ e.as.EncodeAsis(v)
+ }
}
-func (e *Encoder) wrapErrstr(v interface{}, err *error) {
- *err = fmt.Errorf("%s encode error: %v", e.hh.Name(), v)
+func (e *Encoder) errorf(format string, params ...interface{}) {
+ err := fmt.Errorf(format, params...)
+ panic(err)
}
+
+// ----------------------------------------
+
+const encStructPoolLen = 5
+
+// encStructPool is an array of sync.Pool.
+// 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.
+var encStructPool [encStructPoolLen]sync.Pool
+
+func init() {
+ encStructPool[0].New = func() interface{} { return new([8]stringRv) }
+ encStructPool[1].New = func() interface{} { return new([16]stringRv) }
+ encStructPool[2].New = func() interface{} { return new([32]stringRv) }
+ encStructPool[3].New = func() interface{} { return new([64]stringRv) }
+ encStructPool[4].New = func() interface{} { return new([128]stringRv) }
+}
+
+func encStructPoolGet(newlen int) (p *sync.Pool, v interface{}, s []stringRv) {
+ // if encStructPoolLen != 5 { // constant chec, so removed at build time.
+ // panic(errors.New("encStructPoolLen must be equal to 4")) // defensive, in case it is changed
+ // }
+ // idxpool := newlen / 8
+ if newlen <= 8 {
+ p = &encStructPool[0]
+ v = p.Get()
+ s = v.(*[8]stringRv)[:newlen]
+ } else if newlen <= 16 {
+ p = &encStructPool[1]
+ v = p.Get()
+ s = v.(*[16]stringRv)[:newlen]
+ } else if newlen <= 32 {
+ p = &encStructPool[2]
+ v = p.Get()
+ s = v.(*[32]stringRv)[:newlen]
+ } else if newlen <= 64 {
+ p = &encStructPool[3]
+ v = p.Get()
+ s = v.(*[64]stringRv)[:newlen]
+ } else if newlen <= 128 {
+ p = &encStructPool[4]
+ v = p.Get()
+ s = v.(*[128]stringRv)[:newlen]
+ } else {
+ s = make([]stringRv, newlen)
+ }
+ return
+}
+
+// ----------------------------------------
+
+// func encErr(format string, params ...interface{}) {
+// doPanic(msgTagEnc, format, params...)
+// }
diff --git a/vendor/github.com/ugorji/go/codec/fast-path.generated.go b/vendor/github.com/ugorji/go/codec/fast-path.generated.go
index 87f2562f65..f2e5d2dcf6 100644
--- a/vendor/github.com/ugorji/go/codec/fast-path.generated.go
+++ b/vendor/github.com/ugorji/go/codec/fast-path.generated.go
@@ -3,7 +3,10 @@
// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved.
// Use of this source code is governed by a MIT license found in the LICENSE file.
-// Code generated from fast-path.go.tmpl - DO NOT EDIT.
+// ************************************************************
+// DO NOT EDIT.
+// THIS FILE IS AUTO-GENERATED from fast-path.go.tmpl
+// ************************************************************
package codec
@@ -15,19 +18,19 @@ package codec
// This file can be omitted without causing a build failure.
//
// The advantage of fast paths is:
-// - Many calls bypass reflection altogether
+// - 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,
+// - map of all builtin types to string or interface value
+// - symmetrical maps of all builtin types (e.g. str-str, uint8-uint8)
// This should provide adequate "typical" implementations.
//
// Note that fast track decode functions must handle values for which an address cannot be obtained.
// For example:
-// m2 := map[string]int{}
-// p2 := []interface{}{m2}
-// // decoding into p2 will bomb if fast track functions do not treat like unaddressable.
+// m2 := map[string]int{}
+// p2 := []interface{}{m2}
+// // decoding into p2 will bomb if fast track functions do not treat like unaddressable.
//
import (
@@ -37,6 +40,9 @@ import (
const fastpathEnabled = true
+const fastpathCheckNilFalse = false // for reflect
+const fastpathCheckNilTrue = true // for type switch
+
type fastpathT struct{}
var fastpathTV fastpathT
@@ -44,8 +50,8 @@ var fastpathTV fastpathT
type fastpathE struct {
rtid uintptr
rt reflect.Type
- encfn func(*Encoder, *codecFnInfo, reflect.Value)
- decfn func(*Decoder, *codecFnInfo, reflect.Value)
+ encfn func(*encFnInfo, reflect.Value)
+ decfn func(*decFnInfo, reflect.Value)
}
type fastpathA [271]fastpathE
@@ -78,288 +84,286 @@ var fastpathAV fastpathA
// due to possible initialization loop error, make fastpath in an init()
func init() {
i := 0
- fn := func(v interface{},
- fe func(*Encoder, *codecFnInfo, reflect.Value),
- fd func(*Decoder, *codecFnInfo, reflect.Value)) (f fastpathE) {
+ fn := func(v interface{}, fe func(*encFnInfo, reflect.Value), fd func(*decFnInfo, reflect.Value)) (f fastpathE) {
xrt := reflect.TypeOf(v)
- xptr := rt2id(xrt)
+ xptr := reflect.ValueOf(xrt).Pointer()
fastpathAV[i] = fastpathE{xptr, xrt, fe, fd}
i++
return
}
- fn([]interface{}(nil), (*Encoder).fastpathEncSliceIntfR, (*Decoder).fastpathDecSliceIntfR)
- fn([]string(nil), (*Encoder).fastpathEncSliceStringR, (*Decoder).fastpathDecSliceStringR)
- 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)
- fn([]int32(nil), (*Encoder).fastpathEncSliceInt32R, (*Decoder).fastpathDecSliceInt32R)
- fn([]int64(nil), (*Encoder).fastpathEncSliceInt64R, (*Decoder).fastpathDecSliceInt64R)
- fn([]bool(nil), (*Encoder).fastpathEncSliceBoolR, (*Decoder).fastpathDecSliceBoolR)
+ fn([]interface{}(nil), (*encFnInfo).fastpathEncSliceIntfR, (*decFnInfo).fastpathDecSliceIntfR)
+ fn([]string(nil), (*encFnInfo).fastpathEncSliceStringR, (*decFnInfo).fastpathDecSliceStringR)
+ fn([]float32(nil), (*encFnInfo).fastpathEncSliceFloat32R, (*decFnInfo).fastpathDecSliceFloat32R)
+ fn([]float64(nil), (*encFnInfo).fastpathEncSliceFloat64R, (*decFnInfo).fastpathDecSliceFloat64R)
+ fn([]uint(nil), (*encFnInfo).fastpathEncSliceUintR, (*decFnInfo).fastpathDecSliceUintR)
+ fn([]uint16(nil), (*encFnInfo).fastpathEncSliceUint16R, (*decFnInfo).fastpathDecSliceUint16R)
+ fn([]uint32(nil), (*encFnInfo).fastpathEncSliceUint32R, (*decFnInfo).fastpathDecSliceUint32R)
+ fn([]uint64(nil), (*encFnInfo).fastpathEncSliceUint64R, (*decFnInfo).fastpathDecSliceUint64R)
+ fn([]uintptr(nil), (*encFnInfo).fastpathEncSliceUintptrR, (*decFnInfo).fastpathDecSliceUintptrR)
+ fn([]int(nil), (*encFnInfo).fastpathEncSliceIntR, (*decFnInfo).fastpathDecSliceIntR)
+ fn([]int8(nil), (*encFnInfo).fastpathEncSliceInt8R, (*decFnInfo).fastpathDecSliceInt8R)
+ fn([]int16(nil), (*encFnInfo).fastpathEncSliceInt16R, (*decFnInfo).fastpathDecSliceInt16R)
+ fn([]int32(nil), (*encFnInfo).fastpathEncSliceInt32R, (*decFnInfo).fastpathDecSliceInt32R)
+ fn([]int64(nil), (*encFnInfo).fastpathEncSliceInt64R, (*decFnInfo).fastpathDecSliceInt64R)
+ fn([]bool(nil), (*encFnInfo).fastpathEncSliceBoolR, (*decFnInfo).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]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]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]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]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]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]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)
+ fn(map[interface{}]interface{}(nil), (*encFnInfo).fastpathEncMapIntfIntfR, (*decFnInfo).fastpathDecMapIntfIntfR)
+ fn(map[interface{}]string(nil), (*encFnInfo).fastpathEncMapIntfStringR, (*decFnInfo).fastpathDecMapIntfStringR)
+ fn(map[interface{}]uint(nil), (*encFnInfo).fastpathEncMapIntfUintR, (*decFnInfo).fastpathDecMapIntfUintR)
+ fn(map[interface{}]uint8(nil), (*encFnInfo).fastpathEncMapIntfUint8R, (*decFnInfo).fastpathDecMapIntfUint8R)
+ fn(map[interface{}]uint16(nil), (*encFnInfo).fastpathEncMapIntfUint16R, (*decFnInfo).fastpathDecMapIntfUint16R)
+ fn(map[interface{}]uint32(nil), (*encFnInfo).fastpathEncMapIntfUint32R, (*decFnInfo).fastpathDecMapIntfUint32R)
+ fn(map[interface{}]uint64(nil), (*encFnInfo).fastpathEncMapIntfUint64R, (*decFnInfo).fastpathDecMapIntfUint64R)
+ fn(map[interface{}]uintptr(nil), (*encFnInfo).fastpathEncMapIntfUintptrR, (*decFnInfo).fastpathDecMapIntfUintptrR)
+ fn(map[interface{}]int(nil), (*encFnInfo).fastpathEncMapIntfIntR, (*decFnInfo).fastpathDecMapIntfIntR)
+ fn(map[interface{}]int8(nil), (*encFnInfo).fastpathEncMapIntfInt8R, (*decFnInfo).fastpathDecMapIntfInt8R)
+ fn(map[interface{}]int16(nil), (*encFnInfo).fastpathEncMapIntfInt16R, (*decFnInfo).fastpathDecMapIntfInt16R)
+ fn(map[interface{}]int32(nil), (*encFnInfo).fastpathEncMapIntfInt32R, (*decFnInfo).fastpathDecMapIntfInt32R)
+ fn(map[interface{}]int64(nil), (*encFnInfo).fastpathEncMapIntfInt64R, (*decFnInfo).fastpathDecMapIntfInt64R)
+ fn(map[interface{}]float32(nil), (*encFnInfo).fastpathEncMapIntfFloat32R, (*decFnInfo).fastpathDecMapIntfFloat32R)
+ fn(map[interface{}]float64(nil), (*encFnInfo).fastpathEncMapIntfFloat64R, (*decFnInfo).fastpathDecMapIntfFloat64R)
+ fn(map[interface{}]bool(nil), (*encFnInfo).fastpathEncMapIntfBoolR, (*decFnInfo).fastpathDecMapIntfBoolR)
+ fn(map[string]interface{}(nil), (*encFnInfo).fastpathEncMapStringIntfR, (*decFnInfo).fastpathDecMapStringIntfR)
+ fn(map[string]string(nil), (*encFnInfo).fastpathEncMapStringStringR, (*decFnInfo).fastpathDecMapStringStringR)
+ fn(map[string]uint(nil), (*encFnInfo).fastpathEncMapStringUintR, (*decFnInfo).fastpathDecMapStringUintR)
+ fn(map[string]uint8(nil), (*encFnInfo).fastpathEncMapStringUint8R, (*decFnInfo).fastpathDecMapStringUint8R)
+ fn(map[string]uint16(nil), (*encFnInfo).fastpathEncMapStringUint16R, (*decFnInfo).fastpathDecMapStringUint16R)
+ fn(map[string]uint32(nil), (*encFnInfo).fastpathEncMapStringUint32R, (*decFnInfo).fastpathDecMapStringUint32R)
+ fn(map[string]uint64(nil), (*encFnInfo).fastpathEncMapStringUint64R, (*decFnInfo).fastpathDecMapStringUint64R)
+ fn(map[string]uintptr(nil), (*encFnInfo).fastpathEncMapStringUintptrR, (*decFnInfo).fastpathDecMapStringUintptrR)
+ fn(map[string]int(nil), (*encFnInfo).fastpathEncMapStringIntR, (*decFnInfo).fastpathDecMapStringIntR)
+ fn(map[string]int8(nil), (*encFnInfo).fastpathEncMapStringInt8R, (*decFnInfo).fastpathDecMapStringInt8R)
+ fn(map[string]int16(nil), (*encFnInfo).fastpathEncMapStringInt16R, (*decFnInfo).fastpathDecMapStringInt16R)
+ fn(map[string]int32(nil), (*encFnInfo).fastpathEncMapStringInt32R, (*decFnInfo).fastpathDecMapStringInt32R)
+ fn(map[string]int64(nil), (*encFnInfo).fastpathEncMapStringInt64R, (*decFnInfo).fastpathDecMapStringInt64R)
+ fn(map[string]float32(nil), (*encFnInfo).fastpathEncMapStringFloat32R, (*decFnInfo).fastpathDecMapStringFloat32R)
+ fn(map[string]float64(nil), (*encFnInfo).fastpathEncMapStringFloat64R, (*decFnInfo).fastpathDecMapStringFloat64R)
+ fn(map[string]bool(nil), (*encFnInfo).fastpathEncMapStringBoolR, (*decFnInfo).fastpathDecMapStringBoolR)
+ fn(map[float32]interface{}(nil), (*encFnInfo).fastpathEncMapFloat32IntfR, (*decFnInfo).fastpathDecMapFloat32IntfR)
+ fn(map[float32]string(nil), (*encFnInfo).fastpathEncMapFloat32StringR, (*decFnInfo).fastpathDecMapFloat32StringR)
+ fn(map[float32]uint(nil), (*encFnInfo).fastpathEncMapFloat32UintR, (*decFnInfo).fastpathDecMapFloat32UintR)
+ fn(map[float32]uint8(nil), (*encFnInfo).fastpathEncMapFloat32Uint8R, (*decFnInfo).fastpathDecMapFloat32Uint8R)
+ fn(map[float32]uint16(nil), (*encFnInfo).fastpathEncMapFloat32Uint16R, (*decFnInfo).fastpathDecMapFloat32Uint16R)
+ fn(map[float32]uint32(nil), (*encFnInfo).fastpathEncMapFloat32Uint32R, (*decFnInfo).fastpathDecMapFloat32Uint32R)
+ fn(map[float32]uint64(nil), (*encFnInfo).fastpathEncMapFloat32Uint64R, (*decFnInfo).fastpathDecMapFloat32Uint64R)
+ fn(map[float32]uintptr(nil), (*encFnInfo).fastpathEncMapFloat32UintptrR, (*decFnInfo).fastpathDecMapFloat32UintptrR)
+ fn(map[float32]int(nil), (*encFnInfo).fastpathEncMapFloat32IntR, (*decFnInfo).fastpathDecMapFloat32IntR)
+ fn(map[float32]int8(nil), (*encFnInfo).fastpathEncMapFloat32Int8R, (*decFnInfo).fastpathDecMapFloat32Int8R)
+ fn(map[float32]int16(nil), (*encFnInfo).fastpathEncMapFloat32Int16R, (*decFnInfo).fastpathDecMapFloat32Int16R)
+ fn(map[float32]int32(nil), (*encFnInfo).fastpathEncMapFloat32Int32R, (*decFnInfo).fastpathDecMapFloat32Int32R)
+ fn(map[float32]int64(nil), (*encFnInfo).fastpathEncMapFloat32Int64R, (*decFnInfo).fastpathDecMapFloat32Int64R)
+ fn(map[float32]float32(nil), (*encFnInfo).fastpathEncMapFloat32Float32R, (*decFnInfo).fastpathDecMapFloat32Float32R)
+ fn(map[float32]float64(nil), (*encFnInfo).fastpathEncMapFloat32Float64R, (*decFnInfo).fastpathDecMapFloat32Float64R)
+ fn(map[float32]bool(nil), (*encFnInfo).fastpathEncMapFloat32BoolR, (*decFnInfo).fastpathDecMapFloat32BoolR)
+ fn(map[float64]interface{}(nil), (*encFnInfo).fastpathEncMapFloat64IntfR, (*decFnInfo).fastpathDecMapFloat64IntfR)
+ fn(map[float64]string(nil), (*encFnInfo).fastpathEncMapFloat64StringR, (*decFnInfo).fastpathDecMapFloat64StringR)
+ fn(map[float64]uint(nil), (*encFnInfo).fastpathEncMapFloat64UintR, (*decFnInfo).fastpathDecMapFloat64UintR)
+ fn(map[float64]uint8(nil), (*encFnInfo).fastpathEncMapFloat64Uint8R, (*decFnInfo).fastpathDecMapFloat64Uint8R)
+ fn(map[float64]uint16(nil), (*encFnInfo).fastpathEncMapFloat64Uint16R, (*decFnInfo).fastpathDecMapFloat64Uint16R)
+ fn(map[float64]uint32(nil), (*encFnInfo).fastpathEncMapFloat64Uint32R, (*decFnInfo).fastpathDecMapFloat64Uint32R)
+ fn(map[float64]uint64(nil), (*encFnInfo).fastpathEncMapFloat64Uint64R, (*decFnInfo).fastpathDecMapFloat64Uint64R)
+ fn(map[float64]uintptr(nil), (*encFnInfo).fastpathEncMapFloat64UintptrR, (*decFnInfo).fastpathDecMapFloat64UintptrR)
+ fn(map[float64]int(nil), (*encFnInfo).fastpathEncMapFloat64IntR, (*decFnInfo).fastpathDecMapFloat64IntR)
+ fn(map[float64]int8(nil), (*encFnInfo).fastpathEncMapFloat64Int8R, (*decFnInfo).fastpathDecMapFloat64Int8R)
+ fn(map[float64]int16(nil), (*encFnInfo).fastpathEncMapFloat64Int16R, (*decFnInfo).fastpathDecMapFloat64Int16R)
+ fn(map[float64]int32(nil), (*encFnInfo).fastpathEncMapFloat64Int32R, (*decFnInfo).fastpathDecMapFloat64Int32R)
+ fn(map[float64]int64(nil), (*encFnInfo).fastpathEncMapFloat64Int64R, (*decFnInfo).fastpathDecMapFloat64Int64R)
+ fn(map[float64]float32(nil), (*encFnInfo).fastpathEncMapFloat64Float32R, (*decFnInfo).fastpathDecMapFloat64Float32R)
+ fn(map[float64]float64(nil), (*encFnInfo).fastpathEncMapFloat64Float64R, (*decFnInfo).fastpathDecMapFloat64Float64R)
+ fn(map[float64]bool(nil), (*encFnInfo).fastpathEncMapFloat64BoolR, (*decFnInfo).fastpathDecMapFloat64BoolR)
+ fn(map[uint]interface{}(nil), (*encFnInfo).fastpathEncMapUintIntfR, (*decFnInfo).fastpathDecMapUintIntfR)
+ fn(map[uint]string(nil), (*encFnInfo).fastpathEncMapUintStringR, (*decFnInfo).fastpathDecMapUintStringR)
+ fn(map[uint]uint(nil), (*encFnInfo).fastpathEncMapUintUintR, (*decFnInfo).fastpathDecMapUintUintR)
+ fn(map[uint]uint8(nil), (*encFnInfo).fastpathEncMapUintUint8R, (*decFnInfo).fastpathDecMapUintUint8R)
+ fn(map[uint]uint16(nil), (*encFnInfo).fastpathEncMapUintUint16R, (*decFnInfo).fastpathDecMapUintUint16R)
+ fn(map[uint]uint32(nil), (*encFnInfo).fastpathEncMapUintUint32R, (*decFnInfo).fastpathDecMapUintUint32R)
+ fn(map[uint]uint64(nil), (*encFnInfo).fastpathEncMapUintUint64R, (*decFnInfo).fastpathDecMapUintUint64R)
+ fn(map[uint]uintptr(nil), (*encFnInfo).fastpathEncMapUintUintptrR, (*decFnInfo).fastpathDecMapUintUintptrR)
+ fn(map[uint]int(nil), (*encFnInfo).fastpathEncMapUintIntR, (*decFnInfo).fastpathDecMapUintIntR)
+ fn(map[uint]int8(nil), (*encFnInfo).fastpathEncMapUintInt8R, (*decFnInfo).fastpathDecMapUintInt8R)
+ fn(map[uint]int16(nil), (*encFnInfo).fastpathEncMapUintInt16R, (*decFnInfo).fastpathDecMapUintInt16R)
+ fn(map[uint]int32(nil), (*encFnInfo).fastpathEncMapUintInt32R, (*decFnInfo).fastpathDecMapUintInt32R)
+ fn(map[uint]int64(nil), (*encFnInfo).fastpathEncMapUintInt64R, (*decFnInfo).fastpathDecMapUintInt64R)
+ fn(map[uint]float32(nil), (*encFnInfo).fastpathEncMapUintFloat32R, (*decFnInfo).fastpathDecMapUintFloat32R)
+ fn(map[uint]float64(nil), (*encFnInfo).fastpathEncMapUintFloat64R, (*decFnInfo).fastpathDecMapUintFloat64R)
+ fn(map[uint]bool(nil), (*encFnInfo).fastpathEncMapUintBoolR, (*decFnInfo).fastpathDecMapUintBoolR)
+ fn(map[uint8]interface{}(nil), (*encFnInfo).fastpathEncMapUint8IntfR, (*decFnInfo).fastpathDecMapUint8IntfR)
+ fn(map[uint8]string(nil), (*encFnInfo).fastpathEncMapUint8StringR, (*decFnInfo).fastpathDecMapUint8StringR)
+ fn(map[uint8]uint(nil), (*encFnInfo).fastpathEncMapUint8UintR, (*decFnInfo).fastpathDecMapUint8UintR)
+ fn(map[uint8]uint8(nil), (*encFnInfo).fastpathEncMapUint8Uint8R, (*decFnInfo).fastpathDecMapUint8Uint8R)
+ fn(map[uint8]uint16(nil), (*encFnInfo).fastpathEncMapUint8Uint16R, (*decFnInfo).fastpathDecMapUint8Uint16R)
+ fn(map[uint8]uint32(nil), (*encFnInfo).fastpathEncMapUint8Uint32R, (*decFnInfo).fastpathDecMapUint8Uint32R)
+ fn(map[uint8]uint64(nil), (*encFnInfo).fastpathEncMapUint8Uint64R, (*decFnInfo).fastpathDecMapUint8Uint64R)
+ fn(map[uint8]uintptr(nil), (*encFnInfo).fastpathEncMapUint8UintptrR, (*decFnInfo).fastpathDecMapUint8UintptrR)
+ fn(map[uint8]int(nil), (*encFnInfo).fastpathEncMapUint8IntR, (*decFnInfo).fastpathDecMapUint8IntR)
+ fn(map[uint8]int8(nil), (*encFnInfo).fastpathEncMapUint8Int8R, (*decFnInfo).fastpathDecMapUint8Int8R)
+ fn(map[uint8]int16(nil), (*encFnInfo).fastpathEncMapUint8Int16R, (*decFnInfo).fastpathDecMapUint8Int16R)
+ fn(map[uint8]int32(nil), (*encFnInfo).fastpathEncMapUint8Int32R, (*decFnInfo).fastpathDecMapUint8Int32R)
+ fn(map[uint8]int64(nil), (*encFnInfo).fastpathEncMapUint8Int64R, (*decFnInfo).fastpathDecMapUint8Int64R)
+ fn(map[uint8]float32(nil), (*encFnInfo).fastpathEncMapUint8Float32R, (*decFnInfo).fastpathDecMapUint8Float32R)
+ fn(map[uint8]float64(nil), (*encFnInfo).fastpathEncMapUint8Float64R, (*decFnInfo).fastpathDecMapUint8Float64R)
+ fn(map[uint8]bool(nil), (*encFnInfo).fastpathEncMapUint8BoolR, (*decFnInfo).fastpathDecMapUint8BoolR)
+ fn(map[uint16]interface{}(nil), (*encFnInfo).fastpathEncMapUint16IntfR, (*decFnInfo).fastpathDecMapUint16IntfR)
+ fn(map[uint16]string(nil), (*encFnInfo).fastpathEncMapUint16StringR, (*decFnInfo).fastpathDecMapUint16StringR)
+ fn(map[uint16]uint(nil), (*encFnInfo).fastpathEncMapUint16UintR, (*decFnInfo).fastpathDecMapUint16UintR)
+ fn(map[uint16]uint8(nil), (*encFnInfo).fastpathEncMapUint16Uint8R, (*decFnInfo).fastpathDecMapUint16Uint8R)
+ fn(map[uint16]uint16(nil), (*encFnInfo).fastpathEncMapUint16Uint16R, (*decFnInfo).fastpathDecMapUint16Uint16R)
+ fn(map[uint16]uint32(nil), (*encFnInfo).fastpathEncMapUint16Uint32R, (*decFnInfo).fastpathDecMapUint16Uint32R)
+ fn(map[uint16]uint64(nil), (*encFnInfo).fastpathEncMapUint16Uint64R, (*decFnInfo).fastpathDecMapUint16Uint64R)
+ fn(map[uint16]uintptr(nil), (*encFnInfo).fastpathEncMapUint16UintptrR, (*decFnInfo).fastpathDecMapUint16UintptrR)
+ fn(map[uint16]int(nil), (*encFnInfo).fastpathEncMapUint16IntR, (*decFnInfo).fastpathDecMapUint16IntR)
+ fn(map[uint16]int8(nil), (*encFnInfo).fastpathEncMapUint16Int8R, (*decFnInfo).fastpathDecMapUint16Int8R)
+ fn(map[uint16]int16(nil), (*encFnInfo).fastpathEncMapUint16Int16R, (*decFnInfo).fastpathDecMapUint16Int16R)
+ fn(map[uint16]int32(nil), (*encFnInfo).fastpathEncMapUint16Int32R, (*decFnInfo).fastpathDecMapUint16Int32R)
+ fn(map[uint16]int64(nil), (*encFnInfo).fastpathEncMapUint16Int64R, (*decFnInfo).fastpathDecMapUint16Int64R)
+ fn(map[uint16]float32(nil), (*encFnInfo).fastpathEncMapUint16Float32R, (*decFnInfo).fastpathDecMapUint16Float32R)
+ fn(map[uint16]float64(nil), (*encFnInfo).fastpathEncMapUint16Float64R, (*decFnInfo).fastpathDecMapUint16Float64R)
+ fn(map[uint16]bool(nil), (*encFnInfo).fastpathEncMapUint16BoolR, (*decFnInfo).fastpathDecMapUint16BoolR)
+ fn(map[uint32]interface{}(nil), (*encFnInfo).fastpathEncMapUint32IntfR, (*decFnInfo).fastpathDecMapUint32IntfR)
+ fn(map[uint32]string(nil), (*encFnInfo).fastpathEncMapUint32StringR, (*decFnInfo).fastpathDecMapUint32StringR)
+ fn(map[uint32]uint(nil), (*encFnInfo).fastpathEncMapUint32UintR, (*decFnInfo).fastpathDecMapUint32UintR)
+ fn(map[uint32]uint8(nil), (*encFnInfo).fastpathEncMapUint32Uint8R, (*decFnInfo).fastpathDecMapUint32Uint8R)
+ fn(map[uint32]uint16(nil), (*encFnInfo).fastpathEncMapUint32Uint16R, (*decFnInfo).fastpathDecMapUint32Uint16R)
+ fn(map[uint32]uint32(nil), (*encFnInfo).fastpathEncMapUint32Uint32R, (*decFnInfo).fastpathDecMapUint32Uint32R)
+ fn(map[uint32]uint64(nil), (*encFnInfo).fastpathEncMapUint32Uint64R, (*decFnInfo).fastpathDecMapUint32Uint64R)
+ fn(map[uint32]uintptr(nil), (*encFnInfo).fastpathEncMapUint32UintptrR, (*decFnInfo).fastpathDecMapUint32UintptrR)
+ fn(map[uint32]int(nil), (*encFnInfo).fastpathEncMapUint32IntR, (*decFnInfo).fastpathDecMapUint32IntR)
+ fn(map[uint32]int8(nil), (*encFnInfo).fastpathEncMapUint32Int8R, (*decFnInfo).fastpathDecMapUint32Int8R)
+ fn(map[uint32]int16(nil), (*encFnInfo).fastpathEncMapUint32Int16R, (*decFnInfo).fastpathDecMapUint32Int16R)
+ fn(map[uint32]int32(nil), (*encFnInfo).fastpathEncMapUint32Int32R, (*decFnInfo).fastpathDecMapUint32Int32R)
+ fn(map[uint32]int64(nil), (*encFnInfo).fastpathEncMapUint32Int64R, (*decFnInfo).fastpathDecMapUint32Int64R)
+ fn(map[uint32]float32(nil), (*encFnInfo).fastpathEncMapUint32Float32R, (*decFnInfo).fastpathDecMapUint32Float32R)
+ fn(map[uint32]float64(nil), (*encFnInfo).fastpathEncMapUint32Float64R, (*decFnInfo).fastpathDecMapUint32Float64R)
+ fn(map[uint32]bool(nil), (*encFnInfo).fastpathEncMapUint32BoolR, (*decFnInfo).fastpathDecMapUint32BoolR)
+ fn(map[uint64]interface{}(nil), (*encFnInfo).fastpathEncMapUint64IntfR, (*decFnInfo).fastpathDecMapUint64IntfR)
+ fn(map[uint64]string(nil), (*encFnInfo).fastpathEncMapUint64StringR, (*decFnInfo).fastpathDecMapUint64StringR)
+ fn(map[uint64]uint(nil), (*encFnInfo).fastpathEncMapUint64UintR, (*decFnInfo).fastpathDecMapUint64UintR)
+ fn(map[uint64]uint8(nil), (*encFnInfo).fastpathEncMapUint64Uint8R, (*decFnInfo).fastpathDecMapUint64Uint8R)
+ fn(map[uint64]uint16(nil), (*encFnInfo).fastpathEncMapUint64Uint16R, (*decFnInfo).fastpathDecMapUint64Uint16R)
+ fn(map[uint64]uint32(nil), (*encFnInfo).fastpathEncMapUint64Uint32R, (*decFnInfo).fastpathDecMapUint64Uint32R)
+ fn(map[uint64]uint64(nil), (*encFnInfo).fastpathEncMapUint64Uint64R, (*decFnInfo).fastpathDecMapUint64Uint64R)
+ fn(map[uint64]uintptr(nil), (*encFnInfo).fastpathEncMapUint64UintptrR, (*decFnInfo).fastpathDecMapUint64UintptrR)
+ fn(map[uint64]int(nil), (*encFnInfo).fastpathEncMapUint64IntR, (*decFnInfo).fastpathDecMapUint64IntR)
+ fn(map[uint64]int8(nil), (*encFnInfo).fastpathEncMapUint64Int8R, (*decFnInfo).fastpathDecMapUint64Int8R)
+ fn(map[uint64]int16(nil), (*encFnInfo).fastpathEncMapUint64Int16R, (*decFnInfo).fastpathDecMapUint64Int16R)
+ fn(map[uint64]int32(nil), (*encFnInfo).fastpathEncMapUint64Int32R, (*decFnInfo).fastpathDecMapUint64Int32R)
+ fn(map[uint64]int64(nil), (*encFnInfo).fastpathEncMapUint64Int64R, (*decFnInfo).fastpathDecMapUint64Int64R)
+ fn(map[uint64]float32(nil), (*encFnInfo).fastpathEncMapUint64Float32R, (*decFnInfo).fastpathDecMapUint64Float32R)
+ fn(map[uint64]float64(nil), (*encFnInfo).fastpathEncMapUint64Float64R, (*decFnInfo).fastpathDecMapUint64Float64R)
+ fn(map[uint64]bool(nil), (*encFnInfo).fastpathEncMapUint64BoolR, (*decFnInfo).fastpathDecMapUint64BoolR)
+ fn(map[uintptr]interface{}(nil), (*encFnInfo).fastpathEncMapUintptrIntfR, (*decFnInfo).fastpathDecMapUintptrIntfR)
+ fn(map[uintptr]string(nil), (*encFnInfo).fastpathEncMapUintptrStringR, (*decFnInfo).fastpathDecMapUintptrStringR)
+ fn(map[uintptr]uint(nil), (*encFnInfo).fastpathEncMapUintptrUintR, (*decFnInfo).fastpathDecMapUintptrUintR)
+ fn(map[uintptr]uint8(nil), (*encFnInfo).fastpathEncMapUintptrUint8R, (*decFnInfo).fastpathDecMapUintptrUint8R)
+ fn(map[uintptr]uint16(nil), (*encFnInfo).fastpathEncMapUintptrUint16R, (*decFnInfo).fastpathDecMapUintptrUint16R)
+ fn(map[uintptr]uint32(nil), (*encFnInfo).fastpathEncMapUintptrUint32R, (*decFnInfo).fastpathDecMapUintptrUint32R)
+ fn(map[uintptr]uint64(nil), (*encFnInfo).fastpathEncMapUintptrUint64R, (*decFnInfo).fastpathDecMapUintptrUint64R)
+ fn(map[uintptr]uintptr(nil), (*encFnInfo).fastpathEncMapUintptrUintptrR, (*decFnInfo).fastpathDecMapUintptrUintptrR)
+ fn(map[uintptr]int(nil), (*encFnInfo).fastpathEncMapUintptrIntR, (*decFnInfo).fastpathDecMapUintptrIntR)
+ fn(map[uintptr]int8(nil), (*encFnInfo).fastpathEncMapUintptrInt8R, (*decFnInfo).fastpathDecMapUintptrInt8R)
+ fn(map[uintptr]int16(nil), (*encFnInfo).fastpathEncMapUintptrInt16R, (*decFnInfo).fastpathDecMapUintptrInt16R)
+ fn(map[uintptr]int32(nil), (*encFnInfo).fastpathEncMapUintptrInt32R, (*decFnInfo).fastpathDecMapUintptrInt32R)
+ fn(map[uintptr]int64(nil), (*encFnInfo).fastpathEncMapUintptrInt64R, (*decFnInfo).fastpathDecMapUintptrInt64R)
+ fn(map[uintptr]float32(nil), (*encFnInfo).fastpathEncMapUintptrFloat32R, (*decFnInfo).fastpathDecMapUintptrFloat32R)
+ fn(map[uintptr]float64(nil), (*encFnInfo).fastpathEncMapUintptrFloat64R, (*decFnInfo).fastpathDecMapUintptrFloat64R)
+ fn(map[uintptr]bool(nil), (*encFnInfo).fastpathEncMapUintptrBoolR, (*decFnInfo).fastpathDecMapUintptrBoolR)
+ fn(map[int]interface{}(nil), (*encFnInfo).fastpathEncMapIntIntfR, (*decFnInfo).fastpathDecMapIntIntfR)
+ fn(map[int]string(nil), (*encFnInfo).fastpathEncMapIntStringR, (*decFnInfo).fastpathDecMapIntStringR)
+ fn(map[int]uint(nil), (*encFnInfo).fastpathEncMapIntUintR, (*decFnInfo).fastpathDecMapIntUintR)
+ fn(map[int]uint8(nil), (*encFnInfo).fastpathEncMapIntUint8R, (*decFnInfo).fastpathDecMapIntUint8R)
+ fn(map[int]uint16(nil), (*encFnInfo).fastpathEncMapIntUint16R, (*decFnInfo).fastpathDecMapIntUint16R)
+ fn(map[int]uint32(nil), (*encFnInfo).fastpathEncMapIntUint32R, (*decFnInfo).fastpathDecMapIntUint32R)
+ fn(map[int]uint64(nil), (*encFnInfo).fastpathEncMapIntUint64R, (*decFnInfo).fastpathDecMapIntUint64R)
+ fn(map[int]uintptr(nil), (*encFnInfo).fastpathEncMapIntUintptrR, (*decFnInfo).fastpathDecMapIntUintptrR)
+ fn(map[int]int(nil), (*encFnInfo).fastpathEncMapIntIntR, (*decFnInfo).fastpathDecMapIntIntR)
+ fn(map[int]int8(nil), (*encFnInfo).fastpathEncMapIntInt8R, (*decFnInfo).fastpathDecMapIntInt8R)
+ fn(map[int]int16(nil), (*encFnInfo).fastpathEncMapIntInt16R, (*decFnInfo).fastpathDecMapIntInt16R)
+ fn(map[int]int32(nil), (*encFnInfo).fastpathEncMapIntInt32R, (*decFnInfo).fastpathDecMapIntInt32R)
+ fn(map[int]int64(nil), (*encFnInfo).fastpathEncMapIntInt64R, (*decFnInfo).fastpathDecMapIntInt64R)
+ fn(map[int]float32(nil), (*encFnInfo).fastpathEncMapIntFloat32R, (*decFnInfo).fastpathDecMapIntFloat32R)
+ fn(map[int]float64(nil), (*encFnInfo).fastpathEncMapIntFloat64R, (*decFnInfo).fastpathDecMapIntFloat64R)
+ fn(map[int]bool(nil), (*encFnInfo).fastpathEncMapIntBoolR, (*decFnInfo).fastpathDecMapIntBoolR)
+ fn(map[int8]interface{}(nil), (*encFnInfo).fastpathEncMapInt8IntfR, (*decFnInfo).fastpathDecMapInt8IntfR)
+ fn(map[int8]string(nil), (*encFnInfo).fastpathEncMapInt8StringR, (*decFnInfo).fastpathDecMapInt8StringR)
+ fn(map[int8]uint(nil), (*encFnInfo).fastpathEncMapInt8UintR, (*decFnInfo).fastpathDecMapInt8UintR)
+ fn(map[int8]uint8(nil), (*encFnInfo).fastpathEncMapInt8Uint8R, (*decFnInfo).fastpathDecMapInt8Uint8R)
+ fn(map[int8]uint16(nil), (*encFnInfo).fastpathEncMapInt8Uint16R, (*decFnInfo).fastpathDecMapInt8Uint16R)
+ fn(map[int8]uint32(nil), (*encFnInfo).fastpathEncMapInt8Uint32R, (*decFnInfo).fastpathDecMapInt8Uint32R)
+ fn(map[int8]uint64(nil), (*encFnInfo).fastpathEncMapInt8Uint64R, (*decFnInfo).fastpathDecMapInt8Uint64R)
+ fn(map[int8]uintptr(nil), (*encFnInfo).fastpathEncMapInt8UintptrR, (*decFnInfo).fastpathDecMapInt8UintptrR)
+ fn(map[int8]int(nil), (*encFnInfo).fastpathEncMapInt8IntR, (*decFnInfo).fastpathDecMapInt8IntR)
+ fn(map[int8]int8(nil), (*encFnInfo).fastpathEncMapInt8Int8R, (*decFnInfo).fastpathDecMapInt8Int8R)
+ fn(map[int8]int16(nil), (*encFnInfo).fastpathEncMapInt8Int16R, (*decFnInfo).fastpathDecMapInt8Int16R)
+ fn(map[int8]int32(nil), (*encFnInfo).fastpathEncMapInt8Int32R, (*decFnInfo).fastpathDecMapInt8Int32R)
+ fn(map[int8]int64(nil), (*encFnInfo).fastpathEncMapInt8Int64R, (*decFnInfo).fastpathDecMapInt8Int64R)
+ fn(map[int8]float32(nil), (*encFnInfo).fastpathEncMapInt8Float32R, (*decFnInfo).fastpathDecMapInt8Float32R)
+ fn(map[int8]float64(nil), (*encFnInfo).fastpathEncMapInt8Float64R, (*decFnInfo).fastpathDecMapInt8Float64R)
+ fn(map[int8]bool(nil), (*encFnInfo).fastpathEncMapInt8BoolR, (*decFnInfo).fastpathDecMapInt8BoolR)
+ fn(map[int16]interface{}(nil), (*encFnInfo).fastpathEncMapInt16IntfR, (*decFnInfo).fastpathDecMapInt16IntfR)
+ fn(map[int16]string(nil), (*encFnInfo).fastpathEncMapInt16StringR, (*decFnInfo).fastpathDecMapInt16StringR)
+ fn(map[int16]uint(nil), (*encFnInfo).fastpathEncMapInt16UintR, (*decFnInfo).fastpathDecMapInt16UintR)
+ fn(map[int16]uint8(nil), (*encFnInfo).fastpathEncMapInt16Uint8R, (*decFnInfo).fastpathDecMapInt16Uint8R)
+ fn(map[int16]uint16(nil), (*encFnInfo).fastpathEncMapInt16Uint16R, (*decFnInfo).fastpathDecMapInt16Uint16R)
+ fn(map[int16]uint32(nil), (*encFnInfo).fastpathEncMapInt16Uint32R, (*decFnInfo).fastpathDecMapInt16Uint32R)
+ fn(map[int16]uint64(nil), (*encFnInfo).fastpathEncMapInt16Uint64R, (*decFnInfo).fastpathDecMapInt16Uint64R)
+ fn(map[int16]uintptr(nil), (*encFnInfo).fastpathEncMapInt16UintptrR, (*decFnInfo).fastpathDecMapInt16UintptrR)
+ fn(map[int16]int(nil), (*encFnInfo).fastpathEncMapInt16IntR, (*decFnInfo).fastpathDecMapInt16IntR)
+ fn(map[int16]int8(nil), (*encFnInfo).fastpathEncMapInt16Int8R, (*decFnInfo).fastpathDecMapInt16Int8R)
+ fn(map[int16]int16(nil), (*encFnInfo).fastpathEncMapInt16Int16R, (*decFnInfo).fastpathDecMapInt16Int16R)
+ fn(map[int16]int32(nil), (*encFnInfo).fastpathEncMapInt16Int32R, (*decFnInfo).fastpathDecMapInt16Int32R)
+ fn(map[int16]int64(nil), (*encFnInfo).fastpathEncMapInt16Int64R, (*decFnInfo).fastpathDecMapInt16Int64R)
+ fn(map[int16]float32(nil), (*encFnInfo).fastpathEncMapInt16Float32R, (*decFnInfo).fastpathDecMapInt16Float32R)
+ fn(map[int16]float64(nil), (*encFnInfo).fastpathEncMapInt16Float64R, (*decFnInfo).fastpathDecMapInt16Float64R)
+ fn(map[int16]bool(nil), (*encFnInfo).fastpathEncMapInt16BoolR, (*decFnInfo).fastpathDecMapInt16BoolR)
+ fn(map[int32]interface{}(nil), (*encFnInfo).fastpathEncMapInt32IntfR, (*decFnInfo).fastpathDecMapInt32IntfR)
+ fn(map[int32]string(nil), (*encFnInfo).fastpathEncMapInt32StringR, (*decFnInfo).fastpathDecMapInt32StringR)
+ fn(map[int32]uint(nil), (*encFnInfo).fastpathEncMapInt32UintR, (*decFnInfo).fastpathDecMapInt32UintR)
+ fn(map[int32]uint8(nil), (*encFnInfo).fastpathEncMapInt32Uint8R, (*decFnInfo).fastpathDecMapInt32Uint8R)
+ fn(map[int32]uint16(nil), (*encFnInfo).fastpathEncMapInt32Uint16R, (*decFnInfo).fastpathDecMapInt32Uint16R)
+ fn(map[int32]uint32(nil), (*encFnInfo).fastpathEncMapInt32Uint32R, (*decFnInfo).fastpathDecMapInt32Uint32R)
+ fn(map[int32]uint64(nil), (*encFnInfo).fastpathEncMapInt32Uint64R, (*decFnInfo).fastpathDecMapInt32Uint64R)
+ fn(map[int32]uintptr(nil), (*encFnInfo).fastpathEncMapInt32UintptrR, (*decFnInfo).fastpathDecMapInt32UintptrR)
+ fn(map[int32]int(nil), (*encFnInfo).fastpathEncMapInt32IntR, (*decFnInfo).fastpathDecMapInt32IntR)
+ fn(map[int32]int8(nil), (*encFnInfo).fastpathEncMapInt32Int8R, (*decFnInfo).fastpathDecMapInt32Int8R)
+ fn(map[int32]int16(nil), (*encFnInfo).fastpathEncMapInt32Int16R, (*decFnInfo).fastpathDecMapInt32Int16R)
+ fn(map[int32]int32(nil), (*encFnInfo).fastpathEncMapInt32Int32R, (*decFnInfo).fastpathDecMapInt32Int32R)
+ fn(map[int32]int64(nil), (*encFnInfo).fastpathEncMapInt32Int64R, (*decFnInfo).fastpathDecMapInt32Int64R)
+ fn(map[int32]float32(nil), (*encFnInfo).fastpathEncMapInt32Float32R, (*decFnInfo).fastpathDecMapInt32Float32R)
+ fn(map[int32]float64(nil), (*encFnInfo).fastpathEncMapInt32Float64R, (*decFnInfo).fastpathDecMapInt32Float64R)
+ fn(map[int32]bool(nil), (*encFnInfo).fastpathEncMapInt32BoolR, (*decFnInfo).fastpathDecMapInt32BoolR)
+ fn(map[int64]interface{}(nil), (*encFnInfo).fastpathEncMapInt64IntfR, (*decFnInfo).fastpathDecMapInt64IntfR)
+ fn(map[int64]string(nil), (*encFnInfo).fastpathEncMapInt64StringR, (*decFnInfo).fastpathDecMapInt64StringR)
+ fn(map[int64]uint(nil), (*encFnInfo).fastpathEncMapInt64UintR, (*decFnInfo).fastpathDecMapInt64UintR)
+ fn(map[int64]uint8(nil), (*encFnInfo).fastpathEncMapInt64Uint8R, (*decFnInfo).fastpathDecMapInt64Uint8R)
+ fn(map[int64]uint16(nil), (*encFnInfo).fastpathEncMapInt64Uint16R, (*decFnInfo).fastpathDecMapInt64Uint16R)
+ fn(map[int64]uint32(nil), (*encFnInfo).fastpathEncMapInt64Uint32R, (*decFnInfo).fastpathDecMapInt64Uint32R)
+ fn(map[int64]uint64(nil), (*encFnInfo).fastpathEncMapInt64Uint64R, (*decFnInfo).fastpathDecMapInt64Uint64R)
+ fn(map[int64]uintptr(nil), (*encFnInfo).fastpathEncMapInt64UintptrR, (*decFnInfo).fastpathDecMapInt64UintptrR)
+ fn(map[int64]int(nil), (*encFnInfo).fastpathEncMapInt64IntR, (*decFnInfo).fastpathDecMapInt64IntR)
+ fn(map[int64]int8(nil), (*encFnInfo).fastpathEncMapInt64Int8R, (*decFnInfo).fastpathDecMapInt64Int8R)
+ fn(map[int64]int16(nil), (*encFnInfo).fastpathEncMapInt64Int16R, (*decFnInfo).fastpathDecMapInt64Int16R)
+ fn(map[int64]int32(nil), (*encFnInfo).fastpathEncMapInt64Int32R, (*decFnInfo).fastpathDecMapInt64Int32R)
+ fn(map[int64]int64(nil), (*encFnInfo).fastpathEncMapInt64Int64R, (*decFnInfo).fastpathDecMapInt64Int64R)
+ fn(map[int64]float32(nil), (*encFnInfo).fastpathEncMapInt64Float32R, (*decFnInfo).fastpathDecMapInt64Float32R)
+ fn(map[int64]float64(nil), (*encFnInfo).fastpathEncMapInt64Float64R, (*decFnInfo).fastpathDecMapInt64Float64R)
+ fn(map[int64]bool(nil), (*encFnInfo).fastpathEncMapInt64BoolR, (*decFnInfo).fastpathDecMapInt64BoolR)
+ fn(map[bool]interface{}(nil), (*encFnInfo).fastpathEncMapBoolIntfR, (*decFnInfo).fastpathDecMapBoolIntfR)
+ fn(map[bool]string(nil), (*encFnInfo).fastpathEncMapBoolStringR, (*decFnInfo).fastpathDecMapBoolStringR)
+ fn(map[bool]uint(nil), (*encFnInfo).fastpathEncMapBoolUintR, (*decFnInfo).fastpathDecMapBoolUintR)
+ fn(map[bool]uint8(nil), (*encFnInfo).fastpathEncMapBoolUint8R, (*decFnInfo).fastpathDecMapBoolUint8R)
+ fn(map[bool]uint16(nil), (*encFnInfo).fastpathEncMapBoolUint16R, (*decFnInfo).fastpathDecMapBoolUint16R)
+ fn(map[bool]uint32(nil), (*encFnInfo).fastpathEncMapBoolUint32R, (*decFnInfo).fastpathDecMapBoolUint32R)
+ fn(map[bool]uint64(nil), (*encFnInfo).fastpathEncMapBoolUint64R, (*decFnInfo).fastpathDecMapBoolUint64R)
+ fn(map[bool]uintptr(nil), (*encFnInfo).fastpathEncMapBoolUintptrR, (*decFnInfo).fastpathDecMapBoolUintptrR)
+ fn(map[bool]int(nil), (*encFnInfo).fastpathEncMapBoolIntR, (*decFnInfo).fastpathDecMapBoolIntR)
+ fn(map[bool]int8(nil), (*encFnInfo).fastpathEncMapBoolInt8R, (*decFnInfo).fastpathDecMapBoolInt8R)
+ fn(map[bool]int16(nil), (*encFnInfo).fastpathEncMapBoolInt16R, (*decFnInfo).fastpathDecMapBoolInt16R)
+ fn(map[bool]int32(nil), (*encFnInfo).fastpathEncMapBoolInt32R, (*decFnInfo).fastpathDecMapBoolInt32R)
+ fn(map[bool]int64(nil), (*encFnInfo).fastpathEncMapBoolInt64R, (*decFnInfo).fastpathDecMapBoolInt64R)
+ fn(map[bool]float32(nil), (*encFnInfo).fastpathEncMapBoolFloat32R, (*decFnInfo).fastpathDecMapBoolFloat32R)
+ fn(map[bool]float64(nil), (*encFnInfo).fastpathEncMapBoolFloat64R, (*decFnInfo).fastpathDecMapBoolFloat64R)
+ fn(map[bool]bool(nil), (*encFnInfo).fastpathEncMapBoolBoolR, (*decFnInfo).fastpathDecMapBoolBoolR)
sort.Sort(fastpathAslice(fastpathAV[:]))
}
@@ -371,1093 +375,2737 @@ func fastpathEncodeTypeSwitch(iv interface{}, e *Encoder) bool {
switch v := iv.(type) {
case []interface{}:
- fastpathTV.EncSliceIntfV(v, e)
+ fastpathTV.EncSliceIntfV(v, fastpathCheckNilTrue, e)
case *[]interface{}:
- fastpathTV.EncSliceIntfV(*v, e)
- case []string:
- fastpathTV.EncSliceStringV(v, e)
- case *[]string:
- fastpathTV.EncSliceStringV(*v, e)
- case []float32:
- fastpathTV.EncSliceFloat32V(v, e)
- case *[]float32:
- fastpathTV.EncSliceFloat32V(*v, e)
- case []float64:
- fastpathTV.EncSliceFloat64V(v, e)
- case *[]float64:
- fastpathTV.EncSliceFloat64V(*v, e)
- case []uint:
- fastpathTV.EncSliceUintV(v, e)
- case *[]uint:
- fastpathTV.EncSliceUintV(*v, e)
- case []uint16:
- fastpathTV.EncSliceUint16V(v, e)
- case *[]uint16:
- fastpathTV.EncSliceUint16V(*v, e)
- case []uint32:
- fastpathTV.EncSliceUint32V(v, e)
- case *[]uint32:
- 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)
- case []int:
- fastpathTV.EncSliceIntV(v, e)
- case *[]int:
- fastpathTV.EncSliceIntV(*v, e)
- case []int8:
- fastpathTV.EncSliceInt8V(v, e)
- case *[]int8:
- fastpathTV.EncSliceInt8V(*v, e)
- case []int16:
- fastpathTV.EncSliceInt16V(v, e)
- case *[]int16:
- fastpathTV.EncSliceInt16V(*v, e)
- case []int32:
- fastpathTV.EncSliceInt32V(v, e)
- case *[]int32:
- fastpathTV.EncSliceInt32V(*v, e)
- case []int64:
- fastpathTV.EncSliceInt64V(v, e)
- case *[]int64:
- fastpathTV.EncSliceInt64V(*v, e)
- case []bool:
- fastpathTV.EncSliceBoolV(v, e)
- case *[]bool:
- fastpathTV.EncSliceBoolV(*v, e)
+ fastpathTV.EncSliceIntfV(*v, fastpathCheckNilTrue, e)
case map[interface{}]interface{}:
- fastpathTV.EncMapIntfIntfV(v, e)
+ fastpathTV.EncMapIntfIntfV(v, fastpathCheckNilTrue, e)
case *map[interface{}]interface{}:
- fastpathTV.EncMapIntfIntfV(*v, e)
+ fastpathTV.EncMapIntfIntfV(*v, fastpathCheckNilTrue, e)
+
case map[interface{}]string:
- fastpathTV.EncMapIntfStringV(v, e)
+ fastpathTV.EncMapIntfStringV(v, fastpathCheckNilTrue, e)
case *map[interface{}]string:
- fastpathTV.EncMapIntfStringV(*v, e)
+ fastpathTV.EncMapIntfStringV(*v, fastpathCheckNilTrue, e)
+
case map[interface{}]uint:
- fastpathTV.EncMapIntfUintV(v, e)
+ fastpathTV.EncMapIntfUintV(v, fastpathCheckNilTrue, e)
case *map[interface{}]uint:
- fastpathTV.EncMapIntfUintV(*v, e)
+ fastpathTV.EncMapIntfUintV(*v, fastpathCheckNilTrue, e)
+
case map[interface{}]uint8:
- fastpathTV.EncMapIntfUint8V(v, e)
+ fastpathTV.EncMapIntfUint8V(v, fastpathCheckNilTrue, e)
case *map[interface{}]uint8:
- fastpathTV.EncMapIntfUint8V(*v, e)
+ fastpathTV.EncMapIntfUint8V(*v, fastpathCheckNilTrue, e)
+
case map[interface{}]uint16:
- fastpathTV.EncMapIntfUint16V(v, e)
+ fastpathTV.EncMapIntfUint16V(v, fastpathCheckNilTrue, e)
case *map[interface{}]uint16:
- fastpathTV.EncMapIntfUint16V(*v, e)
+ fastpathTV.EncMapIntfUint16V(*v, fastpathCheckNilTrue, e)
+
case map[interface{}]uint32:
- fastpathTV.EncMapIntfUint32V(v, e)
+ fastpathTV.EncMapIntfUint32V(v, fastpathCheckNilTrue, e)
case *map[interface{}]uint32:
- fastpathTV.EncMapIntfUint32V(*v, e)
+ fastpathTV.EncMapIntfUint32V(*v, fastpathCheckNilTrue, e)
+
case map[interface{}]uint64:
- fastpathTV.EncMapIntfUint64V(v, e)
+ fastpathTV.EncMapIntfUint64V(v, fastpathCheckNilTrue, e)
case *map[interface{}]uint64:
- fastpathTV.EncMapIntfUint64V(*v, e)
+ fastpathTV.EncMapIntfUint64V(*v, fastpathCheckNilTrue, e)
+
case map[interface{}]uintptr:
- fastpathTV.EncMapIntfUintptrV(v, e)
+ fastpathTV.EncMapIntfUintptrV(v, fastpathCheckNilTrue, e)
case *map[interface{}]uintptr:
- fastpathTV.EncMapIntfUintptrV(*v, e)
+ fastpathTV.EncMapIntfUintptrV(*v, fastpathCheckNilTrue, e)
+
case map[interface{}]int:
- fastpathTV.EncMapIntfIntV(v, e)
+ fastpathTV.EncMapIntfIntV(v, fastpathCheckNilTrue, e)
case *map[interface{}]int:
- fastpathTV.EncMapIntfIntV(*v, e)
+ fastpathTV.EncMapIntfIntV(*v, fastpathCheckNilTrue, e)
+
case map[interface{}]int8:
- fastpathTV.EncMapIntfInt8V(v, e)
+ fastpathTV.EncMapIntfInt8V(v, fastpathCheckNilTrue, e)
case *map[interface{}]int8:
- fastpathTV.EncMapIntfInt8V(*v, e)
+ fastpathTV.EncMapIntfInt8V(*v, fastpathCheckNilTrue, e)
+
case map[interface{}]int16:
- fastpathTV.EncMapIntfInt16V(v, e)
+ fastpathTV.EncMapIntfInt16V(v, fastpathCheckNilTrue, e)
case *map[interface{}]int16:
- fastpathTV.EncMapIntfInt16V(*v, e)
+ fastpathTV.EncMapIntfInt16V(*v, fastpathCheckNilTrue, e)
+
case map[interface{}]int32:
- fastpathTV.EncMapIntfInt32V(v, e)
+ fastpathTV.EncMapIntfInt32V(v, fastpathCheckNilTrue, e)
case *map[interface{}]int32:
- fastpathTV.EncMapIntfInt32V(*v, e)
+ fastpathTV.EncMapIntfInt32V(*v, fastpathCheckNilTrue, e)
+
case map[interface{}]int64:
- fastpathTV.EncMapIntfInt64V(v, e)
+ fastpathTV.EncMapIntfInt64V(v, fastpathCheckNilTrue, e)
case *map[interface{}]int64:
- fastpathTV.EncMapIntfInt64V(*v, e)
+ fastpathTV.EncMapIntfInt64V(*v, fastpathCheckNilTrue, e)
+
case map[interface{}]float32:
- fastpathTV.EncMapIntfFloat32V(v, e)
+ fastpathTV.EncMapIntfFloat32V(v, fastpathCheckNilTrue, e)
case *map[interface{}]float32:
- fastpathTV.EncMapIntfFloat32V(*v, e)
+ fastpathTV.EncMapIntfFloat32V(*v, fastpathCheckNilTrue, e)
+
case map[interface{}]float64:
- fastpathTV.EncMapIntfFloat64V(v, e)
+ fastpathTV.EncMapIntfFloat64V(v, fastpathCheckNilTrue, e)
case *map[interface{}]float64:
- fastpathTV.EncMapIntfFloat64V(*v, e)
+ fastpathTV.EncMapIntfFloat64V(*v, fastpathCheckNilTrue, e)
+
case map[interface{}]bool:
- fastpathTV.EncMapIntfBoolV(v, e)
+ fastpathTV.EncMapIntfBoolV(v, fastpathCheckNilTrue, e)
case *map[interface{}]bool:
- fastpathTV.EncMapIntfBoolV(*v, e)
+ fastpathTV.EncMapIntfBoolV(*v, fastpathCheckNilTrue, e)
+
+ case []string:
+ fastpathTV.EncSliceStringV(v, fastpathCheckNilTrue, e)
+ case *[]string:
+ fastpathTV.EncSliceStringV(*v, fastpathCheckNilTrue, e)
+
case map[string]interface{}:
- fastpathTV.EncMapStringIntfV(v, e)
+ fastpathTV.EncMapStringIntfV(v, fastpathCheckNilTrue, e)
case *map[string]interface{}:
- fastpathTV.EncMapStringIntfV(*v, e)
+ fastpathTV.EncMapStringIntfV(*v, fastpathCheckNilTrue, e)
+
case map[string]string:
- fastpathTV.EncMapStringStringV(v, e)
+ fastpathTV.EncMapStringStringV(v, fastpathCheckNilTrue, e)
case *map[string]string:
- fastpathTV.EncMapStringStringV(*v, e)
+ fastpathTV.EncMapStringStringV(*v, fastpathCheckNilTrue, e)
+
case map[string]uint:
- fastpathTV.EncMapStringUintV(v, e)
+ fastpathTV.EncMapStringUintV(v, fastpathCheckNilTrue, e)
case *map[string]uint:
- fastpathTV.EncMapStringUintV(*v, e)
+ fastpathTV.EncMapStringUintV(*v, fastpathCheckNilTrue, e)
+
case map[string]uint8:
- fastpathTV.EncMapStringUint8V(v, e)
+ fastpathTV.EncMapStringUint8V(v, fastpathCheckNilTrue, e)
case *map[string]uint8:
- fastpathTV.EncMapStringUint8V(*v, e)
+ fastpathTV.EncMapStringUint8V(*v, fastpathCheckNilTrue, e)
+
case map[string]uint16:
- fastpathTV.EncMapStringUint16V(v, e)
+ fastpathTV.EncMapStringUint16V(v, fastpathCheckNilTrue, e)
case *map[string]uint16:
- fastpathTV.EncMapStringUint16V(*v, e)
+ fastpathTV.EncMapStringUint16V(*v, fastpathCheckNilTrue, e)
+
case map[string]uint32:
- fastpathTV.EncMapStringUint32V(v, e)
+ fastpathTV.EncMapStringUint32V(v, fastpathCheckNilTrue, e)
case *map[string]uint32:
- fastpathTV.EncMapStringUint32V(*v, e)
+ fastpathTV.EncMapStringUint32V(*v, fastpathCheckNilTrue, e)
+
case map[string]uint64:
- fastpathTV.EncMapStringUint64V(v, e)
+ fastpathTV.EncMapStringUint64V(v, fastpathCheckNilTrue, e)
case *map[string]uint64:
- fastpathTV.EncMapStringUint64V(*v, e)
+ fastpathTV.EncMapStringUint64V(*v, fastpathCheckNilTrue, e)
+
case map[string]uintptr:
- fastpathTV.EncMapStringUintptrV(v, e)
+ fastpathTV.EncMapStringUintptrV(v, fastpathCheckNilTrue, e)
case *map[string]uintptr:
- fastpathTV.EncMapStringUintptrV(*v, e)
+ fastpathTV.EncMapStringUintptrV(*v, fastpathCheckNilTrue, e)
+
case map[string]int:
- fastpathTV.EncMapStringIntV(v, e)
+ fastpathTV.EncMapStringIntV(v, fastpathCheckNilTrue, e)
case *map[string]int:
- fastpathTV.EncMapStringIntV(*v, e)
+ fastpathTV.EncMapStringIntV(*v, fastpathCheckNilTrue, e)
+
case map[string]int8:
- fastpathTV.EncMapStringInt8V(v, e)
+ fastpathTV.EncMapStringInt8V(v, fastpathCheckNilTrue, e)
case *map[string]int8:
- fastpathTV.EncMapStringInt8V(*v, e)
+ fastpathTV.EncMapStringInt8V(*v, fastpathCheckNilTrue, e)
+
case map[string]int16:
- fastpathTV.EncMapStringInt16V(v, e)
+ fastpathTV.EncMapStringInt16V(v, fastpathCheckNilTrue, e)
case *map[string]int16:
- fastpathTV.EncMapStringInt16V(*v, e)
+ fastpathTV.EncMapStringInt16V(*v, fastpathCheckNilTrue, e)
+
case map[string]int32:
- fastpathTV.EncMapStringInt32V(v, e)
+ fastpathTV.EncMapStringInt32V(v, fastpathCheckNilTrue, e)
case *map[string]int32:
- fastpathTV.EncMapStringInt32V(*v, e)
+ fastpathTV.EncMapStringInt32V(*v, fastpathCheckNilTrue, e)
+
case map[string]int64:
- fastpathTV.EncMapStringInt64V(v, e)
+ fastpathTV.EncMapStringInt64V(v, fastpathCheckNilTrue, e)
case *map[string]int64:
- fastpathTV.EncMapStringInt64V(*v, e)
+ fastpathTV.EncMapStringInt64V(*v, fastpathCheckNilTrue, e)
+
case map[string]float32:
- fastpathTV.EncMapStringFloat32V(v, e)
+ fastpathTV.EncMapStringFloat32V(v, fastpathCheckNilTrue, e)
case *map[string]float32:
- fastpathTV.EncMapStringFloat32V(*v, e)
+ fastpathTV.EncMapStringFloat32V(*v, fastpathCheckNilTrue, e)
+
case map[string]float64:
- fastpathTV.EncMapStringFloat64V(v, e)
+ fastpathTV.EncMapStringFloat64V(v, fastpathCheckNilTrue, e)
case *map[string]float64:
- fastpathTV.EncMapStringFloat64V(*v, e)
+ fastpathTV.EncMapStringFloat64V(*v, fastpathCheckNilTrue, e)
+
case map[string]bool:
- fastpathTV.EncMapStringBoolV(v, e)
+ fastpathTV.EncMapStringBoolV(v, fastpathCheckNilTrue, e)
case *map[string]bool:
- fastpathTV.EncMapStringBoolV(*v, e)
+ fastpathTV.EncMapStringBoolV(*v, fastpathCheckNilTrue, e)
+
+ case []float32:
+ fastpathTV.EncSliceFloat32V(v, fastpathCheckNilTrue, e)
+ case *[]float32:
+ fastpathTV.EncSliceFloat32V(*v, fastpathCheckNilTrue, e)
+
case map[float32]interface{}:
- fastpathTV.EncMapFloat32IntfV(v, e)
+ fastpathTV.EncMapFloat32IntfV(v, fastpathCheckNilTrue, e)
case *map[float32]interface{}:
- fastpathTV.EncMapFloat32IntfV(*v, e)
+ fastpathTV.EncMapFloat32IntfV(*v, fastpathCheckNilTrue, e)
+
case map[float32]string:
- fastpathTV.EncMapFloat32StringV(v, e)
+ fastpathTV.EncMapFloat32StringV(v, fastpathCheckNilTrue, e)
case *map[float32]string:
- fastpathTV.EncMapFloat32StringV(*v, e)
+ fastpathTV.EncMapFloat32StringV(*v, fastpathCheckNilTrue, e)
+
case map[float32]uint:
- fastpathTV.EncMapFloat32UintV(v, e)
+ fastpathTV.EncMapFloat32UintV(v, fastpathCheckNilTrue, e)
case *map[float32]uint:
- fastpathTV.EncMapFloat32UintV(*v, e)
+ fastpathTV.EncMapFloat32UintV(*v, fastpathCheckNilTrue, e)
+
case map[float32]uint8:
- fastpathTV.EncMapFloat32Uint8V(v, e)
+ fastpathTV.EncMapFloat32Uint8V(v, fastpathCheckNilTrue, e)
case *map[float32]uint8:
- fastpathTV.EncMapFloat32Uint8V(*v, e)
+ fastpathTV.EncMapFloat32Uint8V(*v, fastpathCheckNilTrue, e)
+
case map[float32]uint16:
- fastpathTV.EncMapFloat32Uint16V(v, e)
+ fastpathTV.EncMapFloat32Uint16V(v, fastpathCheckNilTrue, e)
case *map[float32]uint16:
- fastpathTV.EncMapFloat32Uint16V(*v, e)
+ fastpathTV.EncMapFloat32Uint16V(*v, fastpathCheckNilTrue, e)
+
case map[float32]uint32:
- fastpathTV.EncMapFloat32Uint32V(v, e)
+ fastpathTV.EncMapFloat32Uint32V(v, fastpathCheckNilTrue, e)
case *map[float32]uint32:
- fastpathTV.EncMapFloat32Uint32V(*v, e)
+ fastpathTV.EncMapFloat32Uint32V(*v, fastpathCheckNilTrue, e)
+
case map[float32]uint64:
- fastpathTV.EncMapFloat32Uint64V(v, e)
+ fastpathTV.EncMapFloat32Uint64V(v, fastpathCheckNilTrue, e)
case *map[float32]uint64:
- fastpathTV.EncMapFloat32Uint64V(*v, e)
+ fastpathTV.EncMapFloat32Uint64V(*v, fastpathCheckNilTrue, e)
+
case map[float32]uintptr:
- fastpathTV.EncMapFloat32UintptrV(v, e)
+ fastpathTV.EncMapFloat32UintptrV(v, fastpathCheckNilTrue, e)
case *map[float32]uintptr:
- fastpathTV.EncMapFloat32UintptrV(*v, e)
+ fastpathTV.EncMapFloat32UintptrV(*v, fastpathCheckNilTrue, e)
+
case map[float32]int:
- fastpathTV.EncMapFloat32IntV(v, e)
+ fastpathTV.EncMapFloat32IntV(v, fastpathCheckNilTrue, e)
case *map[float32]int:
- fastpathTV.EncMapFloat32IntV(*v, e)
+ fastpathTV.EncMapFloat32IntV(*v, fastpathCheckNilTrue, e)
+
case map[float32]int8:
- fastpathTV.EncMapFloat32Int8V(v, e)
+ fastpathTV.EncMapFloat32Int8V(v, fastpathCheckNilTrue, e)
case *map[float32]int8:
- fastpathTV.EncMapFloat32Int8V(*v, e)
+ fastpathTV.EncMapFloat32Int8V(*v, fastpathCheckNilTrue, e)
+
case map[float32]int16:
- fastpathTV.EncMapFloat32Int16V(v, e)
+ fastpathTV.EncMapFloat32Int16V(v, fastpathCheckNilTrue, e)
case *map[float32]int16:
- fastpathTV.EncMapFloat32Int16V(*v, e)
+ fastpathTV.EncMapFloat32Int16V(*v, fastpathCheckNilTrue, e)
+
case map[float32]int32:
- fastpathTV.EncMapFloat32Int32V(v, e)
+ fastpathTV.EncMapFloat32Int32V(v, fastpathCheckNilTrue, e)
case *map[float32]int32:
- fastpathTV.EncMapFloat32Int32V(*v, e)
+ fastpathTV.EncMapFloat32Int32V(*v, fastpathCheckNilTrue, e)
+
case map[float32]int64:
- fastpathTV.EncMapFloat32Int64V(v, e)
+ fastpathTV.EncMapFloat32Int64V(v, fastpathCheckNilTrue, e)
case *map[float32]int64:
- fastpathTV.EncMapFloat32Int64V(*v, e)
+ fastpathTV.EncMapFloat32Int64V(*v, fastpathCheckNilTrue, e)
+
case map[float32]float32:
- fastpathTV.EncMapFloat32Float32V(v, e)
+ fastpathTV.EncMapFloat32Float32V(v, fastpathCheckNilTrue, e)
case *map[float32]float32:
- fastpathTV.EncMapFloat32Float32V(*v, e)
+ fastpathTV.EncMapFloat32Float32V(*v, fastpathCheckNilTrue, e)
+
case map[float32]float64:
- fastpathTV.EncMapFloat32Float64V(v, e)
+ fastpathTV.EncMapFloat32Float64V(v, fastpathCheckNilTrue, e)
case *map[float32]float64:
- fastpathTV.EncMapFloat32Float64V(*v, e)
+ fastpathTV.EncMapFloat32Float64V(*v, fastpathCheckNilTrue, e)
+
case map[float32]bool:
- fastpathTV.EncMapFloat32BoolV(v, e)
+ fastpathTV.EncMapFloat32BoolV(v, fastpathCheckNilTrue, e)
case *map[float32]bool:
- fastpathTV.EncMapFloat32BoolV(*v, e)
+ fastpathTV.EncMapFloat32BoolV(*v, fastpathCheckNilTrue, e)
+
+ case []float64:
+ fastpathTV.EncSliceFloat64V(v, fastpathCheckNilTrue, e)
+ case *[]float64:
+ fastpathTV.EncSliceFloat64V(*v, fastpathCheckNilTrue, e)
+
case map[float64]interface{}:
- fastpathTV.EncMapFloat64IntfV(v, e)
+ fastpathTV.EncMapFloat64IntfV(v, fastpathCheckNilTrue, e)
case *map[float64]interface{}:
- fastpathTV.EncMapFloat64IntfV(*v, e)
+ fastpathTV.EncMapFloat64IntfV(*v, fastpathCheckNilTrue, e)
+
case map[float64]string:
- fastpathTV.EncMapFloat64StringV(v, e)
+ fastpathTV.EncMapFloat64StringV(v, fastpathCheckNilTrue, e)
case *map[float64]string:
- fastpathTV.EncMapFloat64StringV(*v, e)
+ fastpathTV.EncMapFloat64StringV(*v, fastpathCheckNilTrue, e)
+
case map[float64]uint:
- fastpathTV.EncMapFloat64UintV(v, e)
+ fastpathTV.EncMapFloat64UintV(v, fastpathCheckNilTrue, e)
case *map[float64]uint:
- fastpathTV.EncMapFloat64UintV(*v, e)
+ fastpathTV.EncMapFloat64UintV(*v, fastpathCheckNilTrue, e)
+
case map[float64]uint8:
- fastpathTV.EncMapFloat64Uint8V(v, e)
+ fastpathTV.EncMapFloat64Uint8V(v, fastpathCheckNilTrue, e)
case *map[float64]uint8:
- fastpathTV.EncMapFloat64Uint8V(*v, e)
+ fastpathTV.EncMapFloat64Uint8V(*v, fastpathCheckNilTrue, e)
+
case map[float64]uint16:
- fastpathTV.EncMapFloat64Uint16V(v, e)
+ fastpathTV.EncMapFloat64Uint16V(v, fastpathCheckNilTrue, e)
case *map[float64]uint16:
- fastpathTV.EncMapFloat64Uint16V(*v, e)
+ fastpathTV.EncMapFloat64Uint16V(*v, fastpathCheckNilTrue, e)
+
case map[float64]uint32:
- fastpathTV.EncMapFloat64Uint32V(v, e)
+ fastpathTV.EncMapFloat64Uint32V(v, fastpathCheckNilTrue, e)
case *map[float64]uint32:
- fastpathTV.EncMapFloat64Uint32V(*v, e)
+ fastpathTV.EncMapFloat64Uint32V(*v, fastpathCheckNilTrue, e)
+
case map[float64]uint64:
- fastpathTV.EncMapFloat64Uint64V(v, e)
+ fastpathTV.EncMapFloat64Uint64V(v, fastpathCheckNilTrue, e)
case *map[float64]uint64:
- fastpathTV.EncMapFloat64Uint64V(*v, e)
+ fastpathTV.EncMapFloat64Uint64V(*v, fastpathCheckNilTrue, e)
+
case map[float64]uintptr:
- fastpathTV.EncMapFloat64UintptrV(v, e)
+ fastpathTV.EncMapFloat64UintptrV(v, fastpathCheckNilTrue, e)
case *map[float64]uintptr:
- fastpathTV.EncMapFloat64UintptrV(*v, e)
+ fastpathTV.EncMapFloat64UintptrV(*v, fastpathCheckNilTrue, e)
+
case map[float64]int:
- fastpathTV.EncMapFloat64IntV(v, e)
+ fastpathTV.EncMapFloat64IntV(v, fastpathCheckNilTrue, e)
case *map[float64]int:
- fastpathTV.EncMapFloat64IntV(*v, e)
+ fastpathTV.EncMapFloat64IntV(*v, fastpathCheckNilTrue, e)
+
case map[float64]int8:
- fastpathTV.EncMapFloat64Int8V(v, e)
+ fastpathTV.EncMapFloat64Int8V(v, fastpathCheckNilTrue, e)
case *map[float64]int8:
- fastpathTV.EncMapFloat64Int8V(*v, e)
+ fastpathTV.EncMapFloat64Int8V(*v, fastpathCheckNilTrue, e)
+
case map[float64]int16:
- fastpathTV.EncMapFloat64Int16V(v, e)
+ fastpathTV.EncMapFloat64Int16V(v, fastpathCheckNilTrue, e)
case *map[float64]int16:
- fastpathTV.EncMapFloat64Int16V(*v, e)
+ fastpathTV.EncMapFloat64Int16V(*v, fastpathCheckNilTrue, e)
+
case map[float64]int32:
- fastpathTV.EncMapFloat64Int32V(v, e)
+ fastpathTV.EncMapFloat64Int32V(v, fastpathCheckNilTrue, e)
case *map[float64]int32:
- fastpathTV.EncMapFloat64Int32V(*v, e)
+ fastpathTV.EncMapFloat64Int32V(*v, fastpathCheckNilTrue, e)
+
case map[float64]int64:
- fastpathTV.EncMapFloat64Int64V(v, e)
+ fastpathTV.EncMapFloat64Int64V(v, fastpathCheckNilTrue, e)
case *map[float64]int64:
- fastpathTV.EncMapFloat64Int64V(*v, e)
+ fastpathTV.EncMapFloat64Int64V(*v, fastpathCheckNilTrue, e)
+
case map[float64]float32:
- fastpathTV.EncMapFloat64Float32V(v, e)
+ fastpathTV.EncMapFloat64Float32V(v, fastpathCheckNilTrue, e)
case *map[float64]float32:
- fastpathTV.EncMapFloat64Float32V(*v, e)
+ fastpathTV.EncMapFloat64Float32V(*v, fastpathCheckNilTrue, e)
+
case map[float64]float64:
- fastpathTV.EncMapFloat64Float64V(v, e)
+ fastpathTV.EncMapFloat64Float64V(v, fastpathCheckNilTrue, e)
case *map[float64]float64:
- fastpathTV.EncMapFloat64Float64V(*v, e)
+ fastpathTV.EncMapFloat64Float64V(*v, fastpathCheckNilTrue, e)
+
case map[float64]bool:
- fastpathTV.EncMapFloat64BoolV(v, e)
+ fastpathTV.EncMapFloat64BoolV(v, fastpathCheckNilTrue, e)
case *map[float64]bool:
- fastpathTV.EncMapFloat64BoolV(*v, e)
+ fastpathTV.EncMapFloat64BoolV(*v, fastpathCheckNilTrue, e)
+
+ case []uint:
+ fastpathTV.EncSliceUintV(v, fastpathCheckNilTrue, e)
+ case *[]uint:
+ fastpathTV.EncSliceUintV(*v, fastpathCheckNilTrue, e)
+
case map[uint]interface{}:
- fastpathTV.EncMapUintIntfV(v, e)
+ fastpathTV.EncMapUintIntfV(v, fastpathCheckNilTrue, e)
case *map[uint]interface{}:
- fastpathTV.EncMapUintIntfV(*v, e)
+ fastpathTV.EncMapUintIntfV(*v, fastpathCheckNilTrue, e)
+
case map[uint]string:
- fastpathTV.EncMapUintStringV(v, e)
+ fastpathTV.EncMapUintStringV(v, fastpathCheckNilTrue, e)
case *map[uint]string:
- fastpathTV.EncMapUintStringV(*v, e)
+ fastpathTV.EncMapUintStringV(*v, fastpathCheckNilTrue, e)
+
case map[uint]uint:
- fastpathTV.EncMapUintUintV(v, e)
+ fastpathTV.EncMapUintUintV(v, fastpathCheckNilTrue, e)
case *map[uint]uint:
- fastpathTV.EncMapUintUintV(*v, e)
+ fastpathTV.EncMapUintUintV(*v, fastpathCheckNilTrue, e)
+
case map[uint]uint8:
- fastpathTV.EncMapUintUint8V(v, e)
+ fastpathTV.EncMapUintUint8V(v, fastpathCheckNilTrue, e)
case *map[uint]uint8:
- fastpathTV.EncMapUintUint8V(*v, e)
+ fastpathTV.EncMapUintUint8V(*v, fastpathCheckNilTrue, e)
+
case map[uint]uint16:
- fastpathTV.EncMapUintUint16V(v, e)
+ fastpathTV.EncMapUintUint16V(v, fastpathCheckNilTrue, e)
case *map[uint]uint16:
- fastpathTV.EncMapUintUint16V(*v, e)
+ fastpathTV.EncMapUintUint16V(*v, fastpathCheckNilTrue, e)
+
case map[uint]uint32:
- fastpathTV.EncMapUintUint32V(v, e)
+ fastpathTV.EncMapUintUint32V(v, fastpathCheckNilTrue, e)
case *map[uint]uint32:
- fastpathTV.EncMapUintUint32V(*v, e)
+ fastpathTV.EncMapUintUint32V(*v, fastpathCheckNilTrue, e)
+
case map[uint]uint64:
- fastpathTV.EncMapUintUint64V(v, e)
+ fastpathTV.EncMapUintUint64V(v, fastpathCheckNilTrue, e)
case *map[uint]uint64:
- fastpathTV.EncMapUintUint64V(*v, e)
+ fastpathTV.EncMapUintUint64V(*v, fastpathCheckNilTrue, e)
+
case map[uint]uintptr:
- fastpathTV.EncMapUintUintptrV(v, e)
+ fastpathTV.EncMapUintUintptrV(v, fastpathCheckNilTrue, e)
case *map[uint]uintptr:
- fastpathTV.EncMapUintUintptrV(*v, e)
+ fastpathTV.EncMapUintUintptrV(*v, fastpathCheckNilTrue, e)
+
case map[uint]int:
- fastpathTV.EncMapUintIntV(v, e)
+ fastpathTV.EncMapUintIntV(v, fastpathCheckNilTrue, e)
case *map[uint]int:
- fastpathTV.EncMapUintIntV(*v, e)
+ fastpathTV.EncMapUintIntV(*v, fastpathCheckNilTrue, e)
+
case map[uint]int8:
- fastpathTV.EncMapUintInt8V(v, e)
+ fastpathTV.EncMapUintInt8V(v, fastpathCheckNilTrue, e)
case *map[uint]int8:
- fastpathTV.EncMapUintInt8V(*v, e)
+ fastpathTV.EncMapUintInt8V(*v, fastpathCheckNilTrue, e)
+
case map[uint]int16:
- fastpathTV.EncMapUintInt16V(v, e)
+ fastpathTV.EncMapUintInt16V(v, fastpathCheckNilTrue, e)
case *map[uint]int16:
- fastpathTV.EncMapUintInt16V(*v, e)
+ fastpathTV.EncMapUintInt16V(*v, fastpathCheckNilTrue, e)
+
case map[uint]int32:
- fastpathTV.EncMapUintInt32V(v, e)
+ fastpathTV.EncMapUintInt32V(v, fastpathCheckNilTrue, e)
case *map[uint]int32:
- fastpathTV.EncMapUintInt32V(*v, e)
+ fastpathTV.EncMapUintInt32V(*v, fastpathCheckNilTrue, e)
+
case map[uint]int64:
- fastpathTV.EncMapUintInt64V(v, e)
+ fastpathTV.EncMapUintInt64V(v, fastpathCheckNilTrue, e)
case *map[uint]int64:
- fastpathTV.EncMapUintInt64V(*v, e)
+ fastpathTV.EncMapUintInt64V(*v, fastpathCheckNilTrue, e)
+
case map[uint]float32:
- fastpathTV.EncMapUintFloat32V(v, e)
+ fastpathTV.EncMapUintFloat32V(v, fastpathCheckNilTrue, e)
case *map[uint]float32:
- fastpathTV.EncMapUintFloat32V(*v, e)
+ fastpathTV.EncMapUintFloat32V(*v, fastpathCheckNilTrue, e)
+
case map[uint]float64:
- fastpathTV.EncMapUintFloat64V(v, e)
+ fastpathTV.EncMapUintFloat64V(v, fastpathCheckNilTrue, e)
case *map[uint]float64:
- fastpathTV.EncMapUintFloat64V(*v, e)
+ fastpathTV.EncMapUintFloat64V(*v, fastpathCheckNilTrue, e)
+
case map[uint]bool:
- fastpathTV.EncMapUintBoolV(v, e)
+ fastpathTV.EncMapUintBoolV(v, fastpathCheckNilTrue, e)
case *map[uint]bool:
- fastpathTV.EncMapUintBoolV(*v, e)
+ fastpathTV.EncMapUintBoolV(*v, fastpathCheckNilTrue, e)
+
case map[uint8]interface{}:
- fastpathTV.EncMapUint8IntfV(v, e)
+ fastpathTV.EncMapUint8IntfV(v, fastpathCheckNilTrue, e)
case *map[uint8]interface{}:
- fastpathTV.EncMapUint8IntfV(*v, e)
+ fastpathTV.EncMapUint8IntfV(*v, fastpathCheckNilTrue, e)
+
case map[uint8]string:
- fastpathTV.EncMapUint8StringV(v, e)
+ fastpathTV.EncMapUint8StringV(v, fastpathCheckNilTrue, e)
case *map[uint8]string:
- fastpathTV.EncMapUint8StringV(*v, e)
+ fastpathTV.EncMapUint8StringV(*v, fastpathCheckNilTrue, e)
+
case map[uint8]uint:
- fastpathTV.EncMapUint8UintV(v, e)
+ fastpathTV.EncMapUint8UintV(v, fastpathCheckNilTrue, e)
case *map[uint8]uint:
- fastpathTV.EncMapUint8UintV(*v, e)
+ fastpathTV.EncMapUint8UintV(*v, fastpathCheckNilTrue, e)
+
case map[uint8]uint8:
- fastpathTV.EncMapUint8Uint8V(v, e)
+ fastpathTV.EncMapUint8Uint8V(v, fastpathCheckNilTrue, e)
case *map[uint8]uint8:
- fastpathTV.EncMapUint8Uint8V(*v, e)
+ fastpathTV.EncMapUint8Uint8V(*v, fastpathCheckNilTrue, e)
+
case map[uint8]uint16:
- fastpathTV.EncMapUint8Uint16V(v, e)
+ fastpathTV.EncMapUint8Uint16V(v, fastpathCheckNilTrue, e)
case *map[uint8]uint16:
- fastpathTV.EncMapUint8Uint16V(*v, e)
+ fastpathTV.EncMapUint8Uint16V(*v, fastpathCheckNilTrue, e)
+
case map[uint8]uint32:
- fastpathTV.EncMapUint8Uint32V(v, e)
+ fastpathTV.EncMapUint8Uint32V(v, fastpathCheckNilTrue, e)
case *map[uint8]uint32:
- fastpathTV.EncMapUint8Uint32V(*v, e)
+ fastpathTV.EncMapUint8Uint32V(*v, fastpathCheckNilTrue, e)
+
case map[uint8]uint64:
- fastpathTV.EncMapUint8Uint64V(v, e)
+ fastpathTV.EncMapUint8Uint64V(v, fastpathCheckNilTrue, e)
case *map[uint8]uint64:
- fastpathTV.EncMapUint8Uint64V(*v, e)
+ fastpathTV.EncMapUint8Uint64V(*v, fastpathCheckNilTrue, e)
+
case map[uint8]uintptr:
- fastpathTV.EncMapUint8UintptrV(v, e)
+ fastpathTV.EncMapUint8UintptrV(v, fastpathCheckNilTrue, e)
case *map[uint8]uintptr:
- fastpathTV.EncMapUint8UintptrV(*v, e)
+ fastpathTV.EncMapUint8UintptrV(*v, fastpathCheckNilTrue, e)
+
case map[uint8]int:
- fastpathTV.EncMapUint8IntV(v, e)
+ fastpathTV.EncMapUint8IntV(v, fastpathCheckNilTrue, e)
case *map[uint8]int:
- fastpathTV.EncMapUint8IntV(*v, e)
+ fastpathTV.EncMapUint8IntV(*v, fastpathCheckNilTrue, e)
+
case map[uint8]int8:
- fastpathTV.EncMapUint8Int8V(v, e)
+ fastpathTV.EncMapUint8Int8V(v, fastpathCheckNilTrue, e)
case *map[uint8]int8:
- fastpathTV.EncMapUint8Int8V(*v, e)
+ fastpathTV.EncMapUint8Int8V(*v, fastpathCheckNilTrue, e)
+
case map[uint8]int16:
- fastpathTV.EncMapUint8Int16V(v, e)
+ fastpathTV.EncMapUint8Int16V(v, fastpathCheckNilTrue, e)
case *map[uint8]int16:
- fastpathTV.EncMapUint8Int16V(*v, e)
+ fastpathTV.EncMapUint8Int16V(*v, fastpathCheckNilTrue, e)
+
case map[uint8]int32:
- fastpathTV.EncMapUint8Int32V(v, e)
+ fastpathTV.EncMapUint8Int32V(v, fastpathCheckNilTrue, e)
case *map[uint8]int32:
- fastpathTV.EncMapUint8Int32V(*v, e)
+ fastpathTV.EncMapUint8Int32V(*v, fastpathCheckNilTrue, e)
+
case map[uint8]int64:
- fastpathTV.EncMapUint8Int64V(v, e)
+ fastpathTV.EncMapUint8Int64V(v, fastpathCheckNilTrue, e)
case *map[uint8]int64:
- fastpathTV.EncMapUint8Int64V(*v, e)
+ fastpathTV.EncMapUint8Int64V(*v, fastpathCheckNilTrue, e)
+
case map[uint8]float32:
- fastpathTV.EncMapUint8Float32V(v, e)
+ fastpathTV.EncMapUint8Float32V(v, fastpathCheckNilTrue, e)
case *map[uint8]float32:
- fastpathTV.EncMapUint8Float32V(*v, e)
+ fastpathTV.EncMapUint8Float32V(*v, fastpathCheckNilTrue, e)
+
case map[uint8]float64:
- fastpathTV.EncMapUint8Float64V(v, e)
+ fastpathTV.EncMapUint8Float64V(v, fastpathCheckNilTrue, e)
case *map[uint8]float64:
- fastpathTV.EncMapUint8Float64V(*v, e)
+ fastpathTV.EncMapUint8Float64V(*v, fastpathCheckNilTrue, e)
+
case map[uint8]bool:
- fastpathTV.EncMapUint8BoolV(v, e)
+ fastpathTV.EncMapUint8BoolV(v, fastpathCheckNilTrue, e)
case *map[uint8]bool:
- fastpathTV.EncMapUint8BoolV(*v, e)
+ fastpathTV.EncMapUint8BoolV(*v, fastpathCheckNilTrue, e)
+
+ case []uint16:
+ fastpathTV.EncSliceUint16V(v, fastpathCheckNilTrue, e)
+ case *[]uint16:
+ fastpathTV.EncSliceUint16V(*v, fastpathCheckNilTrue, e)
+
case map[uint16]interface{}:
- fastpathTV.EncMapUint16IntfV(v, e)
+ fastpathTV.EncMapUint16IntfV(v, fastpathCheckNilTrue, e)
case *map[uint16]interface{}:
- fastpathTV.EncMapUint16IntfV(*v, e)
+ fastpathTV.EncMapUint16IntfV(*v, fastpathCheckNilTrue, e)
+
case map[uint16]string:
- fastpathTV.EncMapUint16StringV(v, e)
+ fastpathTV.EncMapUint16StringV(v, fastpathCheckNilTrue, e)
case *map[uint16]string:
- fastpathTV.EncMapUint16StringV(*v, e)
+ fastpathTV.EncMapUint16StringV(*v, fastpathCheckNilTrue, e)
+
case map[uint16]uint:
- fastpathTV.EncMapUint16UintV(v, e)
+ fastpathTV.EncMapUint16UintV(v, fastpathCheckNilTrue, e)
case *map[uint16]uint:
- fastpathTV.EncMapUint16UintV(*v, e)
+ fastpathTV.EncMapUint16UintV(*v, fastpathCheckNilTrue, e)
+
case map[uint16]uint8:
- fastpathTV.EncMapUint16Uint8V(v, e)
+ fastpathTV.EncMapUint16Uint8V(v, fastpathCheckNilTrue, e)
case *map[uint16]uint8:
- fastpathTV.EncMapUint16Uint8V(*v, e)
+ fastpathTV.EncMapUint16Uint8V(*v, fastpathCheckNilTrue, e)
+
case map[uint16]uint16:
- fastpathTV.EncMapUint16Uint16V(v, e)
+ fastpathTV.EncMapUint16Uint16V(v, fastpathCheckNilTrue, e)
case *map[uint16]uint16:
- fastpathTV.EncMapUint16Uint16V(*v, e)
+ fastpathTV.EncMapUint16Uint16V(*v, fastpathCheckNilTrue, e)
+
case map[uint16]uint32:
- fastpathTV.EncMapUint16Uint32V(v, e)
+ fastpathTV.EncMapUint16Uint32V(v, fastpathCheckNilTrue, e)
case *map[uint16]uint32:
- fastpathTV.EncMapUint16Uint32V(*v, e)
+ fastpathTV.EncMapUint16Uint32V(*v, fastpathCheckNilTrue, e)
+
case map[uint16]uint64:
- fastpathTV.EncMapUint16Uint64V(v, e)
+ fastpathTV.EncMapUint16Uint64V(v, fastpathCheckNilTrue, e)
case *map[uint16]uint64:
- fastpathTV.EncMapUint16Uint64V(*v, e)
+ fastpathTV.EncMapUint16Uint64V(*v, fastpathCheckNilTrue, e)
+
case map[uint16]uintptr:
- fastpathTV.EncMapUint16UintptrV(v, e)
+ fastpathTV.EncMapUint16UintptrV(v, fastpathCheckNilTrue, e)
case *map[uint16]uintptr:
- fastpathTV.EncMapUint16UintptrV(*v, e)
+ fastpathTV.EncMapUint16UintptrV(*v, fastpathCheckNilTrue, e)
+
case map[uint16]int:
- fastpathTV.EncMapUint16IntV(v, e)
+ fastpathTV.EncMapUint16IntV(v, fastpathCheckNilTrue, e)
case *map[uint16]int:
- fastpathTV.EncMapUint16IntV(*v, e)
+ fastpathTV.EncMapUint16IntV(*v, fastpathCheckNilTrue, e)
+
case map[uint16]int8:
- fastpathTV.EncMapUint16Int8V(v, e)
+ fastpathTV.EncMapUint16Int8V(v, fastpathCheckNilTrue, e)
case *map[uint16]int8:
- fastpathTV.EncMapUint16Int8V(*v, e)
+ fastpathTV.EncMapUint16Int8V(*v, fastpathCheckNilTrue, e)
+
case map[uint16]int16:
- fastpathTV.EncMapUint16Int16V(v, e)
+ fastpathTV.EncMapUint16Int16V(v, fastpathCheckNilTrue, e)
case *map[uint16]int16:
- fastpathTV.EncMapUint16Int16V(*v, e)
+ fastpathTV.EncMapUint16Int16V(*v, fastpathCheckNilTrue, e)
+
case map[uint16]int32:
- fastpathTV.EncMapUint16Int32V(v, e)
+ fastpathTV.EncMapUint16Int32V(v, fastpathCheckNilTrue, e)
case *map[uint16]int32:
- fastpathTV.EncMapUint16Int32V(*v, e)
+ fastpathTV.EncMapUint16Int32V(*v, fastpathCheckNilTrue, e)
+
case map[uint16]int64:
- fastpathTV.EncMapUint16Int64V(v, e)
+ fastpathTV.EncMapUint16Int64V(v, fastpathCheckNilTrue, e)
case *map[uint16]int64:
- fastpathTV.EncMapUint16Int64V(*v, e)
+ fastpathTV.EncMapUint16Int64V(*v, fastpathCheckNilTrue, e)
+
case map[uint16]float32:
- fastpathTV.EncMapUint16Float32V(v, e)
+ fastpathTV.EncMapUint16Float32V(v, fastpathCheckNilTrue, e)
case *map[uint16]float32:
- fastpathTV.EncMapUint16Float32V(*v, e)
+ fastpathTV.EncMapUint16Float32V(*v, fastpathCheckNilTrue, e)
+
case map[uint16]float64:
- fastpathTV.EncMapUint16Float64V(v, e)
+ fastpathTV.EncMapUint16Float64V(v, fastpathCheckNilTrue, e)
case *map[uint16]float64:
- fastpathTV.EncMapUint16Float64V(*v, e)
+ fastpathTV.EncMapUint16Float64V(*v, fastpathCheckNilTrue, e)
+
case map[uint16]bool:
- fastpathTV.EncMapUint16BoolV(v, e)
+ fastpathTV.EncMapUint16BoolV(v, fastpathCheckNilTrue, e)
case *map[uint16]bool:
- fastpathTV.EncMapUint16BoolV(*v, e)
+ fastpathTV.EncMapUint16BoolV(*v, fastpathCheckNilTrue, e)
+
+ case []uint32:
+ fastpathTV.EncSliceUint32V(v, fastpathCheckNilTrue, e)
+ case *[]uint32:
+ fastpathTV.EncSliceUint32V(*v, fastpathCheckNilTrue, e)
+
case map[uint32]interface{}:
- fastpathTV.EncMapUint32IntfV(v, e)
+ fastpathTV.EncMapUint32IntfV(v, fastpathCheckNilTrue, e)
case *map[uint32]interface{}:
- fastpathTV.EncMapUint32IntfV(*v, e)
+ fastpathTV.EncMapUint32IntfV(*v, fastpathCheckNilTrue, e)
+
case map[uint32]string:
- fastpathTV.EncMapUint32StringV(v, e)
+ fastpathTV.EncMapUint32StringV(v, fastpathCheckNilTrue, e)
case *map[uint32]string:
- fastpathTV.EncMapUint32StringV(*v, e)
+ fastpathTV.EncMapUint32StringV(*v, fastpathCheckNilTrue, e)
+
case map[uint32]uint:
- fastpathTV.EncMapUint32UintV(v, e)
+ fastpathTV.EncMapUint32UintV(v, fastpathCheckNilTrue, e)
case *map[uint32]uint:
- fastpathTV.EncMapUint32UintV(*v, e)
+ fastpathTV.EncMapUint32UintV(*v, fastpathCheckNilTrue, e)
+
case map[uint32]uint8:
- fastpathTV.EncMapUint32Uint8V(v, e)
+ fastpathTV.EncMapUint32Uint8V(v, fastpathCheckNilTrue, e)
case *map[uint32]uint8:
- fastpathTV.EncMapUint32Uint8V(*v, e)
+ fastpathTV.EncMapUint32Uint8V(*v, fastpathCheckNilTrue, e)
+
case map[uint32]uint16:
- fastpathTV.EncMapUint32Uint16V(v, e)
+ fastpathTV.EncMapUint32Uint16V(v, fastpathCheckNilTrue, e)
case *map[uint32]uint16:
- fastpathTV.EncMapUint32Uint16V(*v, e)
+ fastpathTV.EncMapUint32Uint16V(*v, fastpathCheckNilTrue, e)
+
case map[uint32]uint32:
- fastpathTV.EncMapUint32Uint32V(v, e)
+ fastpathTV.EncMapUint32Uint32V(v, fastpathCheckNilTrue, e)
case *map[uint32]uint32:
- fastpathTV.EncMapUint32Uint32V(*v, e)
+ fastpathTV.EncMapUint32Uint32V(*v, fastpathCheckNilTrue, e)
+
case map[uint32]uint64:
- fastpathTV.EncMapUint32Uint64V(v, e)
+ fastpathTV.EncMapUint32Uint64V(v, fastpathCheckNilTrue, e)
case *map[uint32]uint64:
- fastpathTV.EncMapUint32Uint64V(*v, e)
+ fastpathTV.EncMapUint32Uint64V(*v, fastpathCheckNilTrue, e)
+
case map[uint32]uintptr:
- fastpathTV.EncMapUint32UintptrV(v, e)
+ fastpathTV.EncMapUint32UintptrV(v, fastpathCheckNilTrue, e)
case *map[uint32]uintptr:
- fastpathTV.EncMapUint32UintptrV(*v, e)
+ fastpathTV.EncMapUint32UintptrV(*v, fastpathCheckNilTrue, e)
+
case map[uint32]int:
- fastpathTV.EncMapUint32IntV(v, e)
+ fastpathTV.EncMapUint32IntV(v, fastpathCheckNilTrue, e)
case *map[uint32]int:
- fastpathTV.EncMapUint32IntV(*v, e)
+ fastpathTV.EncMapUint32IntV(*v, fastpathCheckNilTrue, e)
+
case map[uint32]int8:
- fastpathTV.EncMapUint32Int8V(v, e)
+ fastpathTV.EncMapUint32Int8V(v, fastpathCheckNilTrue, e)
case *map[uint32]int8:
- fastpathTV.EncMapUint32Int8V(*v, e)
+ fastpathTV.EncMapUint32Int8V(*v, fastpathCheckNilTrue, e)
+
case map[uint32]int16:
- fastpathTV.EncMapUint32Int16V(v, e)
+ fastpathTV.EncMapUint32Int16V(v, fastpathCheckNilTrue, e)
case *map[uint32]int16:
- fastpathTV.EncMapUint32Int16V(*v, e)
+ fastpathTV.EncMapUint32Int16V(*v, fastpathCheckNilTrue, e)
+
case map[uint32]int32:
- fastpathTV.EncMapUint32Int32V(v, e)
+ fastpathTV.EncMapUint32Int32V(v, fastpathCheckNilTrue, e)
case *map[uint32]int32:
- fastpathTV.EncMapUint32Int32V(*v, e)
+ fastpathTV.EncMapUint32Int32V(*v, fastpathCheckNilTrue, e)
+
case map[uint32]int64:
- fastpathTV.EncMapUint32Int64V(v, e)
+ fastpathTV.EncMapUint32Int64V(v, fastpathCheckNilTrue, e)
case *map[uint32]int64:
- fastpathTV.EncMapUint32Int64V(*v, e)
+ fastpathTV.EncMapUint32Int64V(*v, fastpathCheckNilTrue, e)
+
case map[uint32]float32:
- fastpathTV.EncMapUint32Float32V(v, e)
+ fastpathTV.EncMapUint32Float32V(v, fastpathCheckNilTrue, e)
case *map[uint32]float32:
- fastpathTV.EncMapUint32Float32V(*v, e)
+ fastpathTV.EncMapUint32Float32V(*v, fastpathCheckNilTrue, e)
+
case map[uint32]float64:
- fastpathTV.EncMapUint32Float64V(v, e)
+ fastpathTV.EncMapUint32Float64V(v, fastpathCheckNilTrue, e)
case *map[uint32]float64:
- fastpathTV.EncMapUint32Float64V(*v, e)
+ fastpathTV.EncMapUint32Float64V(*v, fastpathCheckNilTrue, e)
+
case map[uint32]bool:
- fastpathTV.EncMapUint32BoolV(v, e)
+ fastpathTV.EncMapUint32BoolV(v, fastpathCheckNilTrue, e)
case *map[uint32]bool:
- fastpathTV.EncMapUint32BoolV(*v, e)
+ fastpathTV.EncMapUint32BoolV(*v, fastpathCheckNilTrue, e)
+
+ case []uint64:
+ fastpathTV.EncSliceUint64V(v, fastpathCheckNilTrue, e)
+ case *[]uint64:
+ fastpathTV.EncSliceUint64V(*v, fastpathCheckNilTrue, e)
+
case map[uint64]interface{}:
- fastpathTV.EncMapUint64IntfV(v, e)
+ fastpathTV.EncMapUint64IntfV(v, fastpathCheckNilTrue, e)
case *map[uint64]interface{}:
- fastpathTV.EncMapUint64IntfV(*v, e)
+ fastpathTV.EncMapUint64IntfV(*v, fastpathCheckNilTrue, e)
+
case map[uint64]string:
- fastpathTV.EncMapUint64StringV(v, e)
+ fastpathTV.EncMapUint64StringV(v, fastpathCheckNilTrue, e)
case *map[uint64]string:
- fastpathTV.EncMapUint64StringV(*v, e)
+ fastpathTV.EncMapUint64StringV(*v, fastpathCheckNilTrue, e)
+
case map[uint64]uint:
- fastpathTV.EncMapUint64UintV(v, e)
+ fastpathTV.EncMapUint64UintV(v, fastpathCheckNilTrue, e)
case *map[uint64]uint:
- fastpathTV.EncMapUint64UintV(*v, e)
+ fastpathTV.EncMapUint64UintV(*v, fastpathCheckNilTrue, e)
+
case map[uint64]uint8:
- fastpathTV.EncMapUint64Uint8V(v, e)
+ fastpathTV.EncMapUint64Uint8V(v, fastpathCheckNilTrue, e)
case *map[uint64]uint8:
- fastpathTV.EncMapUint64Uint8V(*v, e)
+ fastpathTV.EncMapUint64Uint8V(*v, fastpathCheckNilTrue, e)
+
case map[uint64]uint16:
- fastpathTV.EncMapUint64Uint16V(v, e)
+ fastpathTV.EncMapUint64Uint16V(v, fastpathCheckNilTrue, e)
case *map[uint64]uint16:
- fastpathTV.EncMapUint64Uint16V(*v, e)
+ fastpathTV.EncMapUint64Uint16V(*v, fastpathCheckNilTrue, e)
+
case map[uint64]uint32:
- fastpathTV.EncMapUint64Uint32V(v, e)
+ fastpathTV.EncMapUint64Uint32V(v, fastpathCheckNilTrue, e)
case *map[uint64]uint32:
- fastpathTV.EncMapUint64Uint32V(*v, e)
+ fastpathTV.EncMapUint64Uint32V(*v, fastpathCheckNilTrue, e)
+
case map[uint64]uint64:
- fastpathTV.EncMapUint64Uint64V(v, e)
+ fastpathTV.EncMapUint64Uint64V(v, fastpathCheckNilTrue, e)
case *map[uint64]uint64:
- fastpathTV.EncMapUint64Uint64V(*v, e)
+ fastpathTV.EncMapUint64Uint64V(*v, fastpathCheckNilTrue, e)
+
case map[uint64]uintptr:
- fastpathTV.EncMapUint64UintptrV(v, e)
+ fastpathTV.EncMapUint64UintptrV(v, fastpathCheckNilTrue, e)
case *map[uint64]uintptr:
- fastpathTV.EncMapUint64UintptrV(*v, e)
+ fastpathTV.EncMapUint64UintptrV(*v, fastpathCheckNilTrue, e)
+
case map[uint64]int:
- fastpathTV.EncMapUint64IntV(v, e)
+ fastpathTV.EncMapUint64IntV(v, fastpathCheckNilTrue, e)
case *map[uint64]int:
- fastpathTV.EncMapUint64IntV(*v, e)
+ fastpathTV.EncMapUint64IntV(*v, fastpathCheckNilTrue, e)
+
case map[uint64]int8:
- fastpathTV.EncMapUint64Int8V(v, e)
+ fastpathTV.EncMapUint64Int8V(v, fastpathCheckNilTrue, e)
case *map[uint64]int8:
- fastpathTV.EncMapUint64Int8V(*v, e)
+ fastpathTV.EncMapUint64Int8V(*v, fastpathCheckNilTrue, e)
+
case map[uint64]int16:
- fastpathTV.EncMapUint64Int16V(v, e)
+ fastpathTV.EncMapUint64Int16V(v, fastpathCheckNilTrue, e)
case *map[uint64]int16:
- fastpathTV.EncMapUint64Int16V(*v, e)
+ fastpathTV.EncMapUint64Int16V(*v, fastpathCheckNilTrue, e)
+
case map[uint64]int32:
- fastpathTV.EncMapUint64Int32V(v, e)
+ fastpathTV.EncMapUint64Int32V(v, fastpathCheckNilTrue, e)
case *map[uint64]int32:
- fastpathTV.EncMapUint64Int32V(*v, e)
+ fastpathTV.EncMapUint64Int32V(*v, fastpathCheckNilTrue, e)
+
case map[uint64]int64:
- fastpathTV.EncMapUint64Int64V(v, e)
+ fastpathTV.EncMapUint64Int64V(v, fastpathCheckNilTrue, e)
case *map[uint64]int64:
- fastpathTV.EncMapUint64Int64V(*v, e)
+ fastpathTV.EncMapUint64Int64V(*v, fastpathCheckNilTrue, e)
+
case map[uint64]float32:
- fastpathTV.EncMapUint64Float32V(v, e)
+ fastpathTV.EncMapUint64Float32V(v, fastpathCheckNilTrue, e)
case *map[uint64]float32:
- fastpathTV.EncMapUint64Float32V(*v, e)
+ fastpathTV.EncMapUint64Float32V(*v, fastpathCheckNilTrue, e)
+
case map[uint64]float64:
- fastpathTV.EncMapUint64Float64V(v, e)
+ fastpathTV.EncMapUint64Float64V(v, fastpathCheckNilTrue, e)
case *map[uint64]float64:
- fastpathTV.EncMapUint64Float64V(*v, e)
+ fastpathTV.EncMapUint64Float64V(*v, fastpathCheckNilTrue, e)
+
case map[uint64]bool:
- fastpathTV.EncMapUint64BoolV(v, e)
+ fastpathTV.EncMapUint64BoolV(v, fastpathCheckNilTrue, e)
case *map[uint64]bool:
- fastpathTV.EncMapUint64BoolV(*v, e)
+ fastpathTV.EncMapUint64BoolV(*v, fastpathCheckNilTrue, e)
+
+ case []uintptr:
+ fastpathTV.EncSliceUintptrV(v, fastpathCheckNilTrue, e)
+ case *[]uintptr:
+ fastpathTV.EncSliceUintptrV(*v, fastpathCheckNilTrue, e)
+
case map[uintptr]interface{}:
- fastpathTV.EncMapUintptrIntfV(v, e)
+ fastpathTV.EncMapUintptrIntfV(v, fastpathCheckNilTrue, e)
case *map[uintptr]interface{}:
- fastpathTV.EncMapUintptrIntfV(*v, e)
+ fastpathTV.EncMapUintptrIntfV(*v, fastpathCheckNilTrue, e)
+
case map[uintptr]string:
- fastpathTV.EncMapUintptrStringV(v, e)
+ fastpathTV.EncMapUintptrStringV(v, fastpathCheckNilTrue, e)
case *map[uintptr]string:
- fastpathTV.EncMapUintptrStringV(*v, e)
+ fastpathTV.EncMapUintptrStringV(*v, fastpathCheckNilTrue, e)
+
case map[uintptr]uint:
- fastpathTV.EncMapUintptrUintV(v, e)
+ fastpathTV.EncMapUintptrUintV(v, fastpathCheckNilTrue, e)
case *map[uintptr]uint:
- fastpathTV.EncMapUintptrUintV(*v, e)
+ fastpathTV.EncMapUintptrUintV(*v, fastpathCheckNilTrue, e)
+
case map[uintptr]uint8:
- fastpathTV.EncMapUintptrUint8V(v, e)
+ fastpathTV.EncMapUintptrUint8V(v, fastpathCheckNilTrue, e)
case *map[uintptr]uint8:
- fastpathTV.EncMapUintptrUint8V(*v, e)
+ fastpathTV.EncMapUintptrUint8V(*v, fastpathCheckNilTrue, e)
+
case map[uintptr]uint16:
- fastpathTV.EncMapUintptrUint16V(v, e)
+ fastpathTV.EncMapUintptrUint16V(v, fastpathCheckNilTrue, e)
case *map[uintptr]uint16:
- fastpathTV.EncMapUintptrUint16V(*v, e)
+ fastpathTV.EncMapUintptrUint16V(*v, fastpathCheckNilTrue, e)
+
case map[uintptr]uint32:
- fastpathTV.EncMapUintptrUint32V(v, e)
+ fastpathTV.EncMapUintptrUint32V(v, fastpathCheckNilTrue, e)
case *map[uintptr]uint32:
- fastpathTV.EncMapUintptrUint32V(*v, e)
+ fastpathTV.EncMapUintptrUint32V(*v, fastpathCheckNilTrue, e)
+
case map[uintptr]uint64:
- fastpathTV.EncMapUintptrUint64V(v, e)
+ fastpathTV.EncMapUintptrUint64V(v, fastpathCheckNilTrue, e)
case *map[uintptr]uint64:
- fastpathTV.EncMapUintptrUint64V(*v, e)
+ fastpathTV.EncMapUintptrUint64V(*v, fastpathCheckNilTrue, e)
+
case map[uintptr]uintptr:
- fastpathTV.EncMapUintptrUintptrV(v, e)
+ fastpathTV.EncMapUintptrUintptrV(v, fastpathCheckNilTrue, e)
case *map[uintptr]uintptr:
- fastpathTV.EncMapUintptrUintptrV(*v, e)
+ fastpathTV.EncMapUintptrUintptrV(*v, fastpathCheckNilTrue, e)
+
case map[uintptr]int:
- fastpathTV.EncMapUintptrIntV(v, e)
+ fastpathTV.EncMapUintptrIntV(v, fastpathCheckNilTrue, e)
case *map[uintptr]int:
- fastpathTV.EncMapUintptrIntV(*v, e)
+ fastpathTV.EncMapUintptrIntV(*v, fastpathCheckNilTrue, e)
+
case map[uintptr]int8:
- fastpathTV.EncMapUintptrInt8V(v, e)
+ fastpathTV.EncMapUintptrInt8V(v, fastpathCheckNilTrue, e)
case *map[uintptr]int8:
- fastpathTV.EncMapUintptrInt8V(*v, e)
+ fastpathTV.EncMapUintptrInt8V(*v, fastpathCheckNilTrue, e)
+
case map[uintptr]int16:
- fastpathTV.EncMapUintptrInt16V(v, e)
+ fastpathTV.EncMapUintptrInt16V(v, fastpathCheckNilTrue, e)
case *map[uintptr]int16:
- fastpathTV.EncMapUintptrInt16V(*v, e)
+ fastpathTV.EncMapUintptrInt16V(*v, fastpathCheckNilTrue, e)
+
case map[uintptr]int32:
- fastpathTV.EncMapUintptrInt32V(v, e)
+ fastpathTV.EncMapUintptrInt32V(v, fastpathCheckNilTrue, e)
case *map[uintptr]int32:
- fastpathTV.EncMapUintptrInt32V(*v, e)
+ fastpathTV.EncMapUintptrInt32V(*v, fastpathCheckNilTrue, e)
+
case map[uintptr]int64:
- fastpathTV.EncMapUintptrInt64V(v, e)
+ fastpathTV.EncMapUintptrInt64V(v, fastpathCheckNilTrue, e)
case *map[uintptr]int64:
- fastpathTV.EncMapUintptrInt64V(*v, e)
+ fastpathTV.EncMapUintptrInt64V(*v, fastpathCheckNilTrue, e)
+
case map[uintptr]float32:
- fastpathTV.EncMapUintptrFloat32V(v, e)
+ fastpathTV.EncMapUintptrFloat32V(v, fastpathCheckNilTrue, e)
case *map[uintptr]float32:
- fastpathTV.EncMapUintptrFloat32V(*v, e)
+ fastpathTV.EncMapUintptrFloat32V(*v, fastpathCheckNilTrue, e)
+
case map[uintptr]float64:
- fastpathTV.EncMapUintptrFloat64V(v, e)
+ fastpathTV.EncMapUintptrFloat64V(v, fastpathCheckNilTrue, e)
case *map[uintptr]float64:
- fastpathTV.EncMapUintptrFloat64V(*v, e)
+ fastpathTV.EncMapUintptrFloat64V(*v, fastpathCheckNilTrue, e)
+
case map[uintptr]bool:
- fastpathTV.EncMapUintptrBoolV(v, e)
+ fastpathTV.EncMapUintptrBoolV(v, fastpathCheckNilTrue, e)
case *map[uintptr]bool:
- fastpathTV.EncMapUintptrBoolV(*v, e)
+ fastpathTV.EncMapUintptrBoolV(*v, fastpathCheckNilTrue, e)
+
+ case []int:
+ fastpathTV.EncSliceIntV(v, fastpathCheckNilTrue, e)
+ case *[]int:
+ fastpathTV.EncSliceIntV(*v, fastpathCheckNilTrue, e)
+
case map[int]interface{}:
- fastpathTV.EncMapIntIntfV(v, e)
+ fastpathTV.EncMapIntIntfV(v, fastpathCheckNilTrue, e)
case *map[int]interface{}:
- fastpathTV.EncMapIntIntfV(*v, e)
+ fastpathTV.EncMapIntIntfV(*v, fastpathCheckNilTrue, e)
+
case map[int]string:
- fastpathTV.EncMapIntStringV(v, e)
+ fastpathTV.EncMapIntStringV(v, fastpathCheckNilTrue, e)
case *map[int]string:
- fastpathTV.EncMapIntStringV(*v, e)
+ fastpathTV.EncMapIntStringV(*v, fastpathCheckNilTrue, e)
+
case map[int]uint:
- fastpathTV.EncMapIntUintV(v, e)
+ fastpathTV.EncMapIntUintV(v, fastpathCheckNilTrue, e)
case *map[int]uint:
- fastpathTV.EncMapIntUintV(*v, e)
+ fastpathTV.EncMapIntUintV(*v, fastpathCheckNilTrue, e)
+
case map[int]uint8:
- fastpathTV.EncMapIntUint8V(v, e)
+ fastpathTV.EncMapIntUint8V(v, fastpathCheckNilTrue, e)
case *map[int]uint8:
- fastpathTV.EncMapIntUint8V(*v, e)
+ fastpathTV.EncMapIntUint8V(*v, fastpathCheckNilTrue, e)
+
case map[int]uint16:
- fastpathTV.EncMapIntUint16V(v, e)
+ fastpathTV.EncMapIntUint16V(v, fastpathCheckNilTrue, e)
case *map[int]uint16:
- fastpathTV.EncMapIntUint16V(*v, e)
+ fastpathTV.EncMapIntUint16V(*v, fastpathCheckNilTrue, e)
+
case map[int]uint32:
- fastpathTV.EncMapIntUint32V(v, e)
+ fastpathTV.EncMapIntUint32V(v, fastpathCheckNilTrue, e)
case *map[int]uint32:
- fastpathTV.EncMapIntUint32V(*v, e)
+ fastpathTV.EncMapIntUint32V(*v, fastpathCheckNilTrue, e)
+
case map[int]uint64:
- fastpathTV.EncMapIntUint64V(v, e)
+ fastpathTV.EncMapIntUint64V(v, fastpathCheckNilTrue, e)
case *map[int]uint64:
- fastpathTV.EncMapIntUint64V(*v, e)
+ fastpathTV.EncMapIntUint64V(*v, fastpathCheckNilTrue, e)
+
case map[int]uintptr:
- fastpathTV.EncMapIntUintptrV(v, e)
+ fastpathTV.EncMapIntUintptrV(v, fastpathCheckNilTrue, e)
case *map[int]uintptr:
- fastpathTV.EncMapIntUintptrV(*v, e)
+ fastpathTV.EncMapIntUintptrV(*v, fastpathCheckNilTrue, e)
+
case map[int]int:
- fastpathTV.EncMapIntIntV(v, e)
+ fastpathTV.EncMapIntIntV(v, fastpathCheckNilTrue, e)
case *map[int]int:
- fastpathTV.EncMapIntIntV(*v, e)
+ fastpathTV.EncMapIntIntV(*v, fastpathCheckNilTrue, e)
+
case map[int]int8:
- fastpathTV.EncMapIntInt8V(v, e)
+ fastpathTV.EncMapIntInt8V(v, fastpathCheckNilTrue, e)
case *map[int]int8:
- fastpathTV.EncMapIntInt8V(*v, e)
+ fastpathTV.EncMapIntInt8V(*v, fastpathCheckNilTrue, e)
+
case map[int]int16:
- fastpathTV.EncMapIntInt16V(v, e)
+ fastpathTV.EncMapIntInt16V(v, fastpathCheckNilTrue, e)
case *map[int]int16:
- fastpathTV.EncMapIntInt16V(*v, e)
+ fastpathTV.EncMapIntInt16V(*v, fastpathCheckNilTrue, e)
+
case map[int]int32:
- fastpathTV.EncMapIntInt32V(v, e)
+ fastpathTV.EncMapIntInt32V(v, fastpathCheckNilTrue, e)
case *map[int]int32:
- fastpathTV.EncMapIntInt32V(*v, e)
+ fastpathTV.EncMapIntInt32V(*v, fastpathCheckNilTrue, e)
+
case map[int]int64:
- fastpathTV.EncMapIntInt64V(v, e)
+ fastpathTV.EncMapIntInt64V(v, fastpathCheckNilTrue, e)
case *map[int]int64:
- fastpathTV.EncMapIntInt64V(*v, e)
+ fastpathTV.EncMapIntInt64V(*v, fastpathCheckNilTrue, e)
+
case map[int]float32:
- fastpathTV.EncMapIntFloat32V(v, e)
+ fastpathTV.EncMapIntFloat32V(v, fastpathCheckNilTrue, e)
case *map[int]float32:
- fastpathTV.EncMapIntFloat32V(*v, e)
+ fastpathTV.EncMapIntFloat32V(*v, fastpathCheckNilTrue, e)
+
case map[int]float64:
- fastpathTV.EncMapIntFloat64V(v, e)
+ fastpathTV.EncMapIntFloat64V(v, fastpathCheckNilTrue, e)
case *map[int]float64:
- fastpathTV.EncMapIntFloat64V(*v, e)
+ fastpathTV.EncMapIntFloat64V(*v, fastpathCheckNilTrue, e)
+
case map[int]bool:
- fastpathTV.EncMapIntBoolV(v, e)
+ fastpathTV.EncMapIntBoolV(v, fastpathCheckNilTrue, e)
case *map[int]bool:
- fastpathTV.EncMapIntBoolV(*v, e)
+ fastpathTV.EncMapIntBoolV(*v, fastpathCheckNilTrue, e)
+
+ case []int8:
+ fastpathTV.EncSliceInt8V(v, fastpathCheckNilTrue, e)
+ case *[]int8:
+ fastpathTV.EncSliceInt8V(*v, fastpathCheckNilTrue, e)
+
case map[int8]interface{}:
- fastpathTV.EncMapInt8IntfV(v, e)
+ fastpathTV.EncMapInt8IntfV(v, fastpathCheckNilTrue, e)
case *map[int8]interface{}:
- fastpathTV.EncMapInt8IntfV(*v, e)
+ fastpathTV.EncMapInt8IntfV(*v, fastpathCheckNilTrue, e)
+
case map[int8]string:
- fastpathTV.EncMapInt8StringV(v, e)
+ fastpathTV.EncMapInt8StringV(v, fastpathCheckNilTrue, e)
case *map[int8]string:
- fastpathTV.EncMapInt8StringV(*v, e)
+ fastpathTV.EncMapInt8StringV(*v, fastpathCheckNilTrue, e)
+
case map[int8]uint:
- fastpathTV.EncMapInt8UintV(v, e)
+ fastpathTV.EncMapInt8UintV(v, fastpathCheckNilTrue, e)
case *map[int8]uint:
- fastpathTV.EncMapInt8UintV(*v, e)
+ fastpathTV.EncMapInt8UintV(*v, fastpathCheckNilTrue, e)
+
case map[int8]uint8:
- fastpathTV.EncMapInt8Uint8V(v, e)
+ fastpathTV.EncMapInt8Uint8V(v, fastpathCheckNilTrue, e)
case *map[int8]uint8:
- fastpathTV.EncMapInt8Uint8V(*v, e)
+ fastpathTV.EncMapInt8Uint8V(*v, fastpathCheckNilTrue, e)
+
case map[int8]uint16:
- fastpathTV.EncMapInt8Uint16V(v, e)
+ fastpathTV.EncMapInt8Uint16V(v, fastpathCheckNilTrue, e)
case *map[int8]uint16:
- fastpathTV.EncMapInt8Uint16V(*v, e)
+ fastpathTV.EncMapInt8Uint16V(*v, fastpathCheckNilTrue, e)
+
case map[int8]uint32:
- fastpathTV.EncMapInt8Uint32V(v, e)
+ fastpathTV.EncMapInt8Uint32V(v, fastpathCheckNilTrue, e)
case *map[int8]uint32:
- fastpathTV.EncMapInt8Uint32V(*v, e)
+ fastpathTV.EncMapInt8Uint32V(*v, fastpathCheckNilTrue, e)
+
case map[int8]uint64:
- fastpathTV.EncMapInt8Uint64V(v, e)
+ fastpathTV.EncMapInt8Uint64V(v, fastpathCheckNilTrue, e)
case *map[int8]uint64:
- fastpathTV.EncMapInt8Uint64V(*v, e)
+ fastpathTV.EncMapInt8Uint64V(*v, fastpathCheckNilTrue, e)
+
case map[int8]uintptr:
- fastpathTV.EncMapInt8UintptrV(v, e)
+ fastpathTV.EncMapInt8UintptrV(v, fastpathCheckNilTrue, e)
case *map[int8]uintptr:
- fastpathTV.EncMapInt8UintptrV(*v, e)
+ fastpathTV.EncMapInt8UintptrV(*v, fastpathCheckNilTrue, e)
+
case map[int8]int:
- fastpathTV.EncMapInt8IntV(v, e)
+ fastpathTV.EncMapInt8IntV(v, fastpathCheckNilTrue, e)
case *map[int8]int:
- fastpathTV.EncMapInt8IntV(*v, e)
+ fastpathTV.EncMapInt8IntV(*v, fastpathCheckNilTrue, e)
+
case map[int8]int8:
- fastpathTV.EncMapInt8Int8V(v, e)
+ fastpathTV.EncMapInt8Int8V(v, fastpathCheckNilTrue, e)
case *map[int8]int8:
- fastpathTV.EncMapInt8Int8V(*v, e)
+ fastpathTV.EncMapInt8Int8V(*v, fastpathCheckNilTrue, e)
+
case map[int8]int16:
- fastpathTV.EncMapInt8Int16V(v, e)
+ fastpathTV.EncMapInt8Int16V(v, fastpathCheckNilTrue, e)
case *map[int8]int16:
- fastpathTV.EncMapInt8Int16V(*v, e)
+ fastpathTV.EncMapInt8Int16V(*v, fastpathCheckNilTrue, e)
+
case map[int8]int32:
- fastpathTV.EncMapInt8Int32V(v, e)
+ fastpathTV.EncMapInt8Int32V(v, fastpathCheckNilTrue, e)
case *map[int8]int32:
- fastpathTV.EncMapInt8Int32V(*v, e)
+ fastpathTV.EncMapInt8Int32V(*v, fastpathCheckNilTrue, e)
+
case map[int8]int64:
- fastpathTV.EncMapInt8Int64V(v, e)
+ fastpathTV.EncMapInt8Int64V(v, fastpathCheckNilTrue, e)
case *map[int8]int64:
- fastpathTV.EncMapInt8Int64V(*v, e)
+ fastpathTV.EncMapInt8Int64V(*v, fastpathCheckNilTrue, e)
+
case map[int8]float32:
- fastpathTV.EncMapInt8Float32V(v, e)
+ fastpathTV.EncMapInt8Float32V(v, fastpathCheckNilTrue, e)
case *map[int8]float32:
- fastpathTV.EncMapInt8Float32V(*v, e)
+ fastpathTV.EncMapInt8Float32V(*v, fastpathCheckNilTrue, e)
+
case map[int8]float64:
- fastpathTV.EncMapInt8Float64V(v, e)
+ fastpathTV.EncMapInt8Float64V(v, fastpathCheckNilTrue, e)
case *map[int8]float64:
- fastpathTV.EncMapInt8Float64V(*v, e)
+ fastpathTV.EncMapInt8Float64V(*v, fastpathCheckNilTrue, e)
+
case map[int8]bool:
- fastpathTV.EncMapInt8BoolV(v, e)
+ fastpathTV.EncMapInt8BoolV(v, fastpathCheckNilTrue, e)
case *map[int8]bool:
- fastpathTV.EncMapInt8BoolV(*v, e)
+ fastpathTV.EncMapInt8BoolV(*v, fastpathCheckNilTrue, e)
+
+ case []int16:
+ fastpathTV.EncSliceInt16V(v, fastpathCheckNilTrue, e)
+ case *[]int16:
+ fastpathTV.EncSliceInt16V(*v, fastpathCheckNilTrue, e)
+
case map[int16]interface{}:
- fastpathTV.EncMapInt16IntfV(v, e)
+ fastpathTV.EncMapInt16IntfV(v, fastpathCheckNilTrue, e)
case *map[int16]interface{}:
- fastpathTV.EncMapInt16IntfV(*v, e)
+ fastpathTV.EncMapInt16IntfV(*v, fastpathCheckNilTrue, e)
+
case map[int16]string:
- fastpathTV.EncMapInt16StringV(v, e)
+ fastpathTV.EncMapInt16StringV(v, fastpathCheckNilTrue, e)
case *map[int16]string:
- fastpathTV.EncMapInt16StringV(*v, e)
+ fastpathTV.EncMapInt16StringV(*v, fastpathCheckNilTrue, e)
+
case map[int16]uint:
- fastpathTV.EncMapInt16UintV(v, e)
+ fastpathTV.EncMapInt16UintV(v, fastpathCheckNilTrue, e)
case *map[int16]uint:
- fastpathTV.EncMapInt16UintV(*v, e)
+ fastpathTV.EncMapInt16UintV(*v, fastpathCheckNilTrue, e)
+
case map[int16]uint8:
- fastpathTV.EncMapInt16Uint8V(v, e)
+ fastpathTV.EncMapInt16Uint8V(v, fastpathCheckNilTrue, e)
case *map[int16]uint8:
- fastpathTV.EncMapInt16Uint8V(*v, e)
+ fastpathTV.EncMapInt16Uint8V(*v, fastpathCheckNilTrue, e)
+
case map[int16]uint16:
- fastpathTV.EncMapInt16Uint16V(v, e)
+ fastpathTV.EncMapInt16Uint16V(v, fastpathCheckNilTrue, e)
case *map[int16]uint16:
- fastpathTV.EncMapInt16Uint16V(*v, e)
+ fastpathTV.EncMapInt16Uint16V(*v, fastpathCheckNilTrue, e)
+
case map[int16]uint32:
- fastpathTV.EncMapInt16Uint32V(v, e)
+ fastpathTV.EncMapInt16Uint32V(v, fastpathCheckNilTrue, e)
case *map[int16]uint32:
- fastpathTV.EncMapInt16Uint32V(*v, e)
+ fastpathTV.EncMapInt16Uint32V(*v, fastpathCheckNilTrue, e)
+
case map[int16]uint64:
- fastpathTV.EncMapInt16Uint64V(v, e)
+ fastpathTV.EncMapInt16Uint64V(v, fastpathCheckNilTrue, e)
case *map[int16]uint64:
- fastpathTV.EncMapInt16Uint64V(*v, e)
+ fastpathTV.EncMapInt16Uint64V(*v, fastpathCheckNilTrue, e)
+
case map[int16]uintptr:
- fastpathTV.EncMapInt16UintptrV(v, e)
+ fastpathTV.EncMapInt16UintptrV(v, fastpathCheckNilTrue, e)
case *map[int16]uintptr:
- fastpathTV.EncMapInt16UintptrV(*v, e)
+ fastpathTV.EncMapInt16UintptrV(*v, fastpathCheckNilTrue, e)
+
case map[int16]int:
- fastpathTV.EncMapInt16IntV(v, e)
+ fastpathTV.EncMapInt16IntV(v, fastpathCheckNilTrue, e)
case *map[int16]int:
- fastpathTV.EncMapInt16IntV(*v, e)
+ fastpathTV.EncMapInt16IntV(*v, fastpathCheckNilTrue, e)
+
case map[int16]int8:
- fastpathTV.EncMapInt16Int8V(v, e)
+ fastpathTV.EncMapInt16Int8V(v, fastpathCheckNilTrue, e)
case *map[int16]int8:
- fastpathTV.EncMapInt16Int8V(*v, e)
+ fastpathTV.EncMapInt16Int8V(*v, fastpathCheckNilTrue, e)
+
case map[int16]int16:
- fastpathTV.EncMapInt16Int16V(v, e)
+ fastpathTV.EncMapInt16Int16V(v, fastpathCheckNilTrue, e)
case *map[int16]int16:
- fastpathTV.EncMapInt16Int16V(*v, e)
+ fastpathTV.EncMapInt16Int16V(*v, fastpathCheckNilTrue, e)
+
case map[int16]int32:
- fastpathTV.EncMapInt16Int32V(v, e)
+ fastpathTV.EncMapInt16Int32V(v, fastpathCheckNilTrue, e)
case *map[int16]int32:
- fastpathTV.EncMapInt16Int32V(*v, e)
+ fastpathTV.EncMapInt16Int32V(*v, fastpathCheckNilTrue, e)
+
case map[int16]int64:
- fastpathTV.EncMapInt16Int64V(v, e)
+ fastpathTV.EncMapInt16Int64V(v, fastpathCheckNilTrue, e)
case *map[int16]int64:
- fastpathTV.EncMapInt16Int64V(*v, e)
+ fastpathTV.EncMapInt16Int64V(*v, fastpathCheckNilTrue, e)
+
case map[int16]float32:
- fastpathTV.EncMapInt16Float32V(v, e)
+ fastpathTV.EncMapInt16Float32V(v, fastpathCheckNilTrue, e)
case *map[int16]float32:
- fastpathTV.EncMapInt16Float32V(*v, e)
+ fastpathTV.EncMapInt16Float32V(*v, fastpathCheckNilTrue, e)
+
case map[int16]float64:
- fastpathTV.EncMapInt16Float64V(v, e)
+ fastpathTV.EncMapInt16Float64V(v, fastpathCheckNilTrue, e)
case *map[int16]float64:
- fastpathTV.EncMapInt16Float64V(*v, e)
+ fastpathTV.EncMapInt16Float64V(*v, fastpathCheckNilTrue, e)
+
case map[int16]bool:
- fastpathTV.EncMapInt16BoolV(v, e)
+ fastpathTV.EncMapInt16BoolV(v, fastpathCheckNilTrue, e)
case *map[int16]bool:
- fastpathTV.EncMapInt16BoolV(*v, e)
+ fastpathTV.EncMapInt16BoolV(*v, fastpathCheckNilTrue, e)
+
+ case []int32:
+ fastpathTV.EncSliceInt32V(v, fastpathCheckNilTrue, e)
+ case *[]int32:
+ fastpathTV.EncSliceInt32V(*v, fastpathCheckNilTrue, e)
+
case map[int32]interface{}:
- fastpathTV.EncMapInt32IntfV(v, e)
+ fastpathTV.EncMapInt32IntfV(v, fastpathCheckNilTrue, e)
case *map[int32]interface{}:
- fastpathTV.EncMapInt32IntfV(*v, e)
+ fastpathTV.EncMapInt32IntfV(*v, fastpathCheckNilTrue, e)
+
case map[int32]string:
- fastpathTV.EncMapInt32StringV(v, e)
+ fastpathTV.EncMapInt32StringV(v, fastpathCheckNilTrue, e)
case *map[int32]string:
- fastpathTV.EncMapInt32StringV(*v, e)
+ fastpathTV.EncMapInt32StringV(*v, fastpathCheckNilTrue, e)
+
case map[int32]uint:
- fastpathTV.EncMapInt32UintV(v, e)
+ fastpathTV.EncMapInt32UintV(v, fastpathCheckNilTrue, e)
case *map[int32]uint:
- fastpathTV.EncMapInt32UintV(*v, e)
+ fastpathTV.EncMapInt32UintV(*v, fastpathCheckNilTrue, e)
+
case map[int32]uint8:
- fastpathTV.EncMapInt32Uint8V(v, e)
+ fastpathTV.EncMapInt32Uint8V(v, fastpathCheckNilTrue, e)
case *map[int32]uint8:
- fastpathTV.EncMapInt32Uint8V(*v, e)
+ fastpathTV.EncMapInt32Uint8V(*v, fastpathCheckNilTrue, e)
+
case map[int32]uint16:
- fastpathTV.EncMapInt32Uint16V(v, e)
+ fastpathTV.EncMapInt32Uint16V(v, fastpathCheckNilTrue, e)
case *map[int32]uint16:
- fastpathTV.EncMapInt32Uint16V(*v, e)
+ fastpathTV.EncMapInt32Uint16V(*v, fastpathCheckNilTrue, e)
+
case map[int32]uint32:
- fastpathTV.EncMapInt32Uint32V(v, e)
+ fastpathTV.EncMapInt32Uint32V(v, fastpathCheckNilTrue, e)
case *map[int32]uint32:
- fastpathTV.EncMapInt32Uint32V(*v, e)
+ fastpathTV.EncMapInt32Uint32V(*v, fastpathCheckNilTrue, e)
+
case map[int32]uint64:
- fastpathTV.EncMapInt32Uint64V(v, e)
+ fastpathTV.EncMapInt32Uint64V(v, fastpathCheckNilTrue, e)
case *map[int32]uint64:
- fastpathTV.EncMapInt32Uint64V(*v, e)
+ fastpathTV.EncMapInt32Uint64V(*v, fastpathCheckNilTrue, e)
+
case map[int32]uintptr:
- fastpathTV.EncMapInt32UintptrV(v, e)
+ fastpathTV.EncMapInt32UintptrV(v, fastpathCheckNilTrue, e)
case *map[int32]uintptr:
- fastpathTV.EncMapInt32UintptrV(*v, e)
+ fastpathTV.EncMapInt32UintptrV(*v, fastpathCheckNilTrue, e)
+
case map[int32]int:
- fastpathTV.EncMapInt32IntV(v, e)
+ fastpathTV.EncMapInt32IntV(v, fastpathCheckNilTrue, e)
case *map[int32]int:
- fastpathTV.EncMapInt32IntV(*v, e)
+ fastpathTV.EncMapInt32IntV(*v, fastpathCheckNilTrue, e)
+
case map[int32]int8:
- fastpathTV.EncMapInt32Int8V(v, e)
+ fastpathTV.EncMapInt32Int8V(v, fastpathCheckNilTrue, e)
case *map[int32]int8:
- fastpathTV.EncMapInt32Int8V(*v, e)
+ fastpathTV.EncMapInt32Int8V(*v, fastpathCheckNilTrue, e)
+
case map[int32]int16:
- fastpathTV.EncMapInt32Int16V(v, e)
+ fastpathTV.EncMapInt32Int16V(v, fastpathCheckNilTrue, e)
case *map[int32]int16:
- fastpathTV.EncMapInt32Int16V(*v, e)
+ fastpathTV.EncMapInt32Int16V(*v, fastpathCheckNilTrue, e)
+
case map[int32]int32:
- fastpathTV.EncMapInt32Int32V(v, e)
+ fastpathTV.EncMapInt32Int32V(v, fastpathCheckNilTrue, e)
case *map[int32]int32:
- fastpathTV.EncMapInt32Int32V(*v, e)
+ fastpathTV.EncMapInt32Int32V(*v, fastpathCheckNilTrue, e)
+
case map[int32]int64:
- fastpathTV.EncMapInt32Int64V(v, e)
+ fastpathTV.EncMapInt32Int64V(v, fastpathCheckNilTrue, e)
case *map[int32]int64:
- fastpathTV.EncMapInt32Int64V(*v, e)
+ fastpathTV.EncMapInt32Int64V(*v, fastpathCheckNilTrue, e)
+
case map[int32]float32:
- fastpathTV.EncMapInt32Float32V(v, e)
+ fastpathTV.EncMapInt32Float32V(v, fastpathCheckNilTrue, e)
case *map[int32]float32:
- fastpathTV.EncMapInt32Float32V(*v, e)
+ fastpathTV.EncMapInt32Float32V(*v, fastpathCheckNilTrue, e)
+
case map[int32]float64:
- fastpathTV.EncMapInt32Float64V(v, e)
+ fastpathTV.EncMapInt32Float64V(v, fastpathCheckNilTrue, e)
case *map[int32]float64:
- fastpathTV.EncMapInt32Float64V(*v, e)
+ fastpathTV.EncMapInt32Float64V(*v, fastpathCheckNilTrue, e)
+
case map[int32]bool:
- fastpathTV.EncMapInt32BoolV(v, e)
+ fastpathTV.EncMapInt32BoolV(v, fastpathCheckNilTrue, e)
case *map[int32]bool:
- fastpathTV.EncMapInt32BoolV(*v, e)
+ fastpathTV.EncMapInt32BoolV(*v, fastpathCheckNilTrue, e)
+
+ case []int64:
+ fastpathTV.EncSliceInt64V(v, fastpathCheckNilTrue, e)
+ case *[]int64:
+ fastpathTV.EncSliceInt64V(*v, fastpathCheckNilTrue, e)
+
case map[int64]interface{}:
- fastpathTV.EncMapInt64IntfV(v, e)
+ fastpathTV.EncMapInt64IntfV(v, fastpathCheckNilTrue, e)
case *map[int64]interface{}:
- fastpathTV.EncMapInt64IntfV(*v, e)
+ fastpathTV.EncMapInt64IntfV(*v, fastpathCheckNilTrue, e)
+
case map[int64]string:
- fastpathTV.EncMapInt64StringV(v, e)
+ fastpathTV.EncMapInt64StringV(v, fastpathCheckNilTrue, e)
case *map[int64]string:
- fastpathTV.EncMapInt64StringV(*v, e)
+ fastpathTV.EncMapInt64StringV(*v, fastpathCheckNilTrue, e)
+
case map[int64]uint:
- fastpathTV.EncMapInt64UintV(v, e)
+ fastpathTV.EncMapInt64UintV(v, fastpathCheckNilTrue, e)
case *map[int64]uint:
- fastpathTV.EncMapInt64UintV(*v, e)
+ fastpathTV.EncMapInt64UintV(*v, fastpathCheckNilTrue, e)
+
case map[int64]uint8:
- fastpathTV.EncMapInt64Uint8V(v, e)
+ fastpathTV.EncMapInt64Uint8V(v, fastpathCheckNilTrue, e)
case *map[int64]uint8:
- fastpathTV.EncMapInt64Uint8V(*v, e)
+ fastpathTV.EncMapInt64Uint8V(*v, fastpathCheckNilTrue, e)
+
case map[int64]uint16:
- fastpathTV.EncMapInt64Uint16V(v, e)
+ fastpathTV.EncMapInt64Uint16V(v, fastpathCheckNilTrue, e)
case *map[int64]uint16:
- fastpathTV.EncMapInt64Uint16V(*v, e)
+ fastpathTV.EncMapInt64Uint16V(*v, fastpathCheckNilTrue, e)
+
case map[int64]uint32:
- fastpathTV.EncMapInt64Uint32V(v, e)
+ fastpathTV.EncMapInt64Uint32V(v, fastpathCheckNilTrue, e)
case *map[int64]uint32:
- fastpathTV.EncMapInt64Uint32V(*v, e)
+ fastpathTV.EncMapInt64Uint32V(*v, fastpathCheckNilTrue, e)
+
case map[int64]uint64:
- fastpathTV.EncMapInt64Uint64V(v, e)
+ fastpathTV.EncMapInt64Uint64V(v, fastpathCheckNilTrue, e)
case *map[int64]uint64:
- fastpathTV.EncMapInt64Uint64V(*v, e)
+ fastpathTV.EncMapInt64Uint64V(*v, fastpathCheckNilTrue, e)
+
case map[int64]uintptr:
- fastpathTV.EncMapInt64UintptrV(v, e)
+ fastpathTV.EncMapInt64UintptrV(v, fastpathCheckNilTrue, e)
case *map[int64]uintptr:
- fastpathTV.EncMapInt64UintptrV(*v, e)
+ fastpathTV.EncMapInt64UintptrV(*v, fastpathCheckNilTrue, e)
+
case map[int64]int:
- fastpathTV.EncMapInt64IntV(v, e)
+ fastpathTV.EncMapInt64IntV(v, fastpathCheckNilTrue, e)
case *map[int64]int:
- fastpathTV.EncMapInt64IntV(*v, e)
+ fastpathTV.EncMapInt64IntV(*v, fastpathCheckNilTrue, e)
+
case map[int64]int8:
- fastpathTV.EncMapInt64Int8V(v, e)
+ fastpathTV.EncMapInt64Int8V(v, fastpathCheckNilTrue, e)
case *map[int64]int8:
- fastpathTV.EncMapInt64Int8V(*v, e)
+ fastpathTV.EncMapInt64Int8V(*v, fastpathCheckNilTrue, e)
+
case map[int64]int16:
- fastpathTV.EncMapInt64Int16V(v, e)
+ fastpathTV.EncMapInt64Int16V(v, fastpathCheckNilTrue, e)
case *map[int64]int16:
- fastpathTV.EncMapInt64Int16V(*v, e)
+ fastpathTV.EncMapInt64Int16V(*v, fastpathCheckNilTrue, e)
+
case map[int64]int32:
- fastpathTV.EncMapInt64Int32V(v, e)
+ fastpathTV.EncMapInt64Int32V(v, fastpathCheckNilTrue, e)
case *map[int64]int32:
- fastpathTV.EncMapInt64Int32V(*v, e)
+ fastpathTV.EncMapInt64Int32V(*v, fastpathCheckNilTrue, e)
+
case map[int64]int64:
- fastpathTV.EncMapInt64Int64V(v, e)
+ fastpathTV.EncMapInt64Int64V(v, fastpathCheckNilTrue, e)
case *map[int64]int64:
- fastpathTV.EncMapInt64Int64V(*v, e)
+ fastpathTV.EncMapInt64Int64V(*v, fastpathCheckNilTrue, e)
+
case map[int64]float32:
- fastpathTV.EncMapInt64Float32V(v, e)
+ fastpathTV.EncMapInt64Float32V(v, fastpathCheckNilTrue, e)
case *map[int64]float32:
- fastpathTV.EncMapInt64Float32V(*v, e)
+ fastpathTV.EncMapInt64Float32V(*v, fastpathCheckNilTrue, e)
+
case map[int64]float64:
- fastpathTV.EncMapInt64Float64V(v, e)
+ fastpathTV.EncMapInt64Float64V(v, fastpathCheckNilTrue, e)
case *map[int64]float64:
- fastpathTV.EncMapInt64Float64V(*v, e)
+ fastpathTV.EncMapInt64Float64V(*v, fastpathCheckNilTrue, e)
+
case map[int64]bool:
- fastpathTV.EncMapInt64BoolV(v, e)
+ fastpathTV.EncMapInt64BoolV(v, fastpathCheckNilTrue, e)
case *map[int64]bool:
- fastpathTV.EncMapInt64BoolV(*v, e)
+ fastpathTV.EncMapInt64BoolV(*v, fastpathCheckNilTrue, e)
+
+ case []bool:
+ fastpathTV.EncSliceBoolV(v, fastpathCheckNilTrue, e)
+ case *[]bool:
+ fastpathTV.EncSliceBoolV(*v, fastpathCheckNilTrue, e)
+
case map[bool]interface{}:
- fastpathTV.EncMapBoolIntfV(v, e)
+ fastpathTV.EncMapBoolIntfV(v, fastpathCheckNilTrue, e)
case *map[bool]interface{}:
- fastpathTV.EncMapBoolIntfV(*v, e)
+ fastpathTV.EncMapBoolIntfV(*v, fastpathCheckNilTrue, e)
+
case map[bool]string:
- fastpathTV.EncMapBoolStringV(v, e)
+ fastpathTV.EncMapBoolStringV(v, fastpathCheckNilTrue, e)
case *map[bool]string:
- fastpathTV.EncMapBoolStringV(*v, e)
+ fastpathTV.EncMapBoolStringV(*v, fastpathCheckNilTrue, e)
+
case map[bool]uint:
- fastpathTV.EncMapBoolUintV(v, e)
+ fastpathTV.EncMapBoolUintV(v, fastpathCheckNilTrue, e)
case *map[bool]uint:
- fastpathTV.EncMapBoolUintV(*v, e)
+ fastpathTV.EncMapBoolUintV(*v, fastpathCheckNilTrue, e)
+
case map[bool]uint8:
- fastpathTV.EncMapBoolUint8V(v, e)
+ fastpathTV.EncMapBoolUint8V(v, fastpathCheckNilTrue, e)
case *map[bool]uint8:
- fastpathTV.EncMapBoolUint8V(*v, e)
+ fastpathTV.EncMapBoolUint8V(*v, fastpathCheckNilTrue, e)
+
case map[bool]uint16:
- fastpathTV.EncMapBoolUint16V(v, e)
+ fastpathTV.EncMapBoolUint16V(v, fastpathCheckNilTrue, e)
case *map[bool]uint16:
- fastpathTV.EncMapBoolUint16V(*v, e)
+ fastpathTV.EncMapBoolUint16V(*v, fastpathCheckNilTrue, e)
+
case map[bool]uint32:
- fastpathTV.EncMapBoolUint32V(v, e)
+ fastpathTV.EncMapBoolUint32V(v, fastpathCheckNilTrue, e)
case *map[bool]uint32:
- fastpathTV.EncMapBoolUint32V(*v, e)
+ fastpathTV.EncMapBoolUint32V(*v, fastpathCheckNilTrue, e)
+
case map[bool]uint64:
- fastpathTV.EncMapBoolUint64V(v, e)
+ fastpathTV.EncMapBoolUint64V(v, fastpathCheckNilTrue, e)
case *map[bool]uint64:
- fastpathTV.EncMapBoolUint64V(*v, e)
+ fastpathTV.EncMapBoolUint64V(*v, fastpathCheckNilTrue, e)
+
case map[bool]uintptr:
- fastpathTV.EncMapBoolUintptrV(v, e)
+ fastpathTV.EncMapBoolUintptrV(v, fastpathCheckNilTrue, e)
case *map[bool]uintptr:
- fastpathTV.EncMapBoolUintptrV(*v, e)
+ fastpathTV.EncMapBoolUintptrV(*v, fastpathCheckNilTrue, e)
+
case map[bool]int:
- fastpathTV.EncMapBoolIntV(v, e)
+ fastpathTV.EncMapBoolIntV(v, fastpathCheckNilTrue, e)
case *map[bool]int:
- fastpathTV.EncMapBoolIntV(*v, e)
+ fastpathTV.EncMapBoolIntV(*v, fastpathCheckNilTrue, e)
+
case map[bool]int8:
- fastpathTV.EncMapBoolInt8V(v, e)
+ fastpathTV.EncMapBoolInt8V(v, fastpathCheckNilTrue, e)
case *map[bool]int8:
- fastpathTV.EncMapBoolInt8V(*v, e)
+ fastpathTV.EncMapBoolInt8V(*v, fastpathCheckNilTrue, e)
+
case map[bool]int16:
- fastpathTV.EncMapBoolInt16V(v, e)
+ fastpathTV.EncMapBoolInt16V(v, fastpathCheckNilTrue, e)
case *map[bool]int16:
- fastpathTV.EncMapBoolInt16V(*v, e)
+ fastpathTV.EncMapBoolInt16V(*v, fastpathCheckNilTrue, e)
+
case map[bool]int32:
- fastpathTV.EncMapBoolInt32V(v, e)
+ fastpathTV.EncMapBoolInt32V(v, fastpathCheckNilTrue, e)
case *map[bool]int32:
- fastpathTV.EncMapBoolInt32V(*v, e)
+ fastpathTV.EncMapBoolInt32V(*v, fastpathCheckNilTrue, e)
+
case map[bool]int64:
- fastpathTV.EncMapBoolInt64V(v, e)
+ fastpathTV.EncMapBoolInt64V(v, fastpathCheckNilTrue, e)
case *map[bool]int64:
- fastpathTV.EncMapBoolInt64V(*v, e)
+ fastpathTV.EncMapBoolInt64V(*v, fastpathCheckNilTrue, e)
+
case map[bool]float32:
- fastpathTV.EncMapBoolFloat32V(v, e)
+ fastpathTV.EncMapBoolFloat32V(v, fastpathCheckNilTrue, e)
case *map[bool]float32:
- fastpathTV.EncMapBoolFloat32V(*v, e)
+ fastpathTV.EncMapBoolFloat32V(*v, fastpathCheckNilTrue, e)
+
case map[bool]float64:
- fastpathTV.EncMapBoolFloat64V(v, e)
+ fastpathTV.EncMapBoolFloat64V(v, fastpathCheckNilTrue, e)
case *map[bool]float64:
- fastpathTV.EncMapBoolFloat64V(*v, e)
+ fastpathTV.EncMapBoolFloat64V(*v, fastpathCheckNilTrue, e)
+
case map[bool]bool:
- fastpathTV.EncMapBoolBoolV(v, e)
+ fastpathTV.EncMapBoolBoolV(v, fastpathCheckNilTrue, e)
case *map[bool]bool:
- fastpathTV.EncMapBoolBoolV(*v, e)
+ fastpathTV.EncMapBoolBoolV(*v, fastpathCheckNilTrue, e)
default:
- _ = v // workaround https://github.com/golang/go/issues/12927 seen in go1.4
+ _ = v // TODO: workaround https://github.com/golang/go/issues/12927 (remove after go 1.6 release)
+ return false
+ }
+ return true
+}
+
+func fastpathEncodeTypeSwitchSlice(iv interface{}, e *Encoder) bool {
+ switch v := iv.(type) {
+
+ case []interface{}:
+ fastpathTV.EncSliceIntfV(v, fastpathCheckNilTrue, e)
+ case *[]interface{}:
+ fastpathTV.EncSliceIntfV(*v, fastpathCheckNilTrue, e)
+
+ case []string:
+ fastpathTV.EncSliceStringV(v, fastpathCheckNilTrue, e)
+ case *[]string:
+ fastpathTV.EncSliceStringV(*v, fastpathCheckNilTrue, e)
+
+ case []float32:
+ fastpathTV.EncSliceFloat32V(v, fastpathCheckNilTrue, e)
+ case *[]float32:
+ fastpathTV.EncSliceFloat32V(*v, fastpathCheckNilTrue, e)
+
+ case []float64:
+ fastpathTV.EncSliceFloat64V(v, fastpathCheckNilTrue, e)
+ case *[]float64:
+ fastpathTV.EncSliceFloat64V(*v, fastpathCheckNilTrue, e)
+
+ case []uint:
+ fastpathTV.EncSliceUintV(v, fastpathCheckNilTrue, e)
+ case *[]uint:
+ fastpathTV.EncSliceUintV(*v, fastpathCheckNilTrue, e)
+
+ case []uint16:
+ fastpathTV.EncSliceUint16V(v, fastpathCheckNilTrue, e)
+ case *[]uint16:
+ fastpathTV.EncSliceUint16V(*v, fastpathCheckNilTrue, e)
+
+ case []uint32:
+ fastpathTV.EncSliceUint32V(v, fastpathCheckNilTrue, e)
+ case *[]uint32:
+ fastpathTV.EncSliceUint32V(*v, fastpathCheckNilTrue, e)
+
+ case []uint64:
+ fastpathTV.EncSliceUint64V(v, fastpathCheckNilTrue, e)
+ case *[]uint64:
+ fastpathTV.EncSliceUint64V(*v, fastpathCheckNilTrue, e)
+
+ case []uintptr:
+ fastpathTV.EncSliceUintptrV(v, fastpathCheckNilTrue, e)
+ case *[]uintptr:
+ fastpathTV.EncSliceUintptrV(*v, fastpathCheckNilTrue, e)
+
+ case []int:
+ fastpathTV.EncSliceIntV(v, fastpathCheckNilTrue, e)
+ case *[]int:
+ fastpathTV.EncSliceIntV(*v, fastpathCheckNilTrue, e)
+
+ case []int8:
+ fastpathTV.EncSliceInt8V(v, fastpathCheckNilTrue, e)
+ case *[]int8:
+ fastpathTV.EncSliceInt8V(*v, fastpathCheckNilTrue, e)
+
+ case []int16:
+ fastpathTV.EncSliceInt16V(v, fastpathCheckNilTrue, e)
+ case *[]int16:
+ fastpathTV.EncSliceInt16V(*v, fastpathCheckNilTrue, e)
+
+ case []int32:
+ fastpathTV.EncSliceInt32V(v, fastpathCheckNilTrue, e)
+ case *[]int32:
+ fastpathTV.EncSliceInt32V(*v, fastpathCheckNilTrue, e)
+
+ case []int64:
+ fastpathTV.EncSliceInt64V(v, fastpathCheckNilTrue, e)
+ case *[]int64:
+ fastpathTV.EncSliceInt64V(*v, fastpathCheckNilTrue, e)
+
+ case []bool:
+ fastpathTV.EncSliceBoolV(v, fastpathCheckNilTrue, e)
+ case *[]bool:
+ fastpathTV.EncSliceBoolV(*v, fastpathCheckNilTrue, e)
+
+ default:
+ _ = v // TODO: workaround https://github.com/golang/go/issues/12927 (remove after go 1.6 release)
+ return false
+ }
+ return true
+}
+
+func fastpathEncodeTypeSwitchMap(iv interface{}, e *Encoder) bool {
+ switch v := iv.(type) {
+
+ case map[interface{}]interface{}:
+ fastpathTV.EncMapIntfIntfV(v, fastpathCheckNilTrue, e)
+ case *map[interface{}]interface{}:
+ fastpathTV.EncMapIntfIntfV(*v, fastpathCheckNilTrue, e)
+
+ case map[interface{}]string:
+ fastpathTV.EncMapIntfStringV(v, fastpathCheckNilTrue, e)
+ case *map[interface{}]string:
+ fastpathTV.EncMapIntfStringV(*v, fastpathCheckNilTrue, e)
+
+ case map[interface{}]uint:
+ fastpathTV.EncMapIntfUintV(v, fastpathCheckNilTrue, e)
+ case *map[interface{}]uint:
+ fastpathTV.EncMapIntfUintV(*v, fastpathCheckNilTrue, e)
+
+ case map[interface{}]uint8:
+ fastpathTV.EncMapIntfUint8V(v, fastpathCheckNilTrue, e)
+ case *map[interface{}]uint8:
+ fastpathTV.EncMapIntfUint8V(*v, fastpathCheckNilTrue, e)
+
+ case map[interface{}]uint16:
+ fastpathTV.EncMapIntfUint16V(v, fastpathCheckNilTrue, e)
+ case *map[interface{}]uint16:
+ fastpathTV.EncMapIntfUint16V(*v, fastpathCheckNilTrue, e)
+
+ case map[interface{}]uint32:
+ fastpathTV.EncMapIntfUint32V(v, fastpathCheckNilTrue, e)
+ case *map[interface{}]uint32:
+ fastpathTV.EncMapIntfUint32V(*v, fastpathCheckNilTrue, e)
+
+ case map[interface{}]uint64:
+ fastpathTV.EncMapIntfUint64V(v, fastpathCheckNilTrue, e)
+ case *map[interface{}]uint64:
+ fastpathTV.EncMapIntfUint64V(*v, fastpathCheckNilTrue, e)
+
+ case map[interface{}]uintptr:
+ fastpathTV.EncMapIntfUintptrV(v, fastpathCheckNilTrue, e)
+ case *map[interface{}]uintptr:
+ fastpathTV.EncMapIntfUintptrV(*v, fastpathCheckNilTrue, e)
+
+ case map[interface{}]int:
+ fastpathTV.EncMapIntfIntV(v, fastpathCheckNilTrue, e)
+ case *map[interface{}]int:
+ fastpathTV.EncMapIntfIntV(*v, fastpathCheckNilTrue, e)
+
+ case map[interface{}]int8:
+ fastpathTV.EncMapIntfInt8V(v, fastpathCheckNilTrue, e)
+ case *map[interface{}]int8:
+ fastpathTV.EncMapIntfInt8V(*v, fastpathCheckNilTrue, e)
+
+ case map[interface{}]int16:
+ fastpathTV.EncMapIntfInt16V(v, fastpathCheckNilTrue, e)
+ case *map[interface{}]int16:
+ fastpathTV.EncMapIntfInt16V(*v, fastpathCheckNilTrue, e)
+
+ case map[interface{}]int32:
+ fastpathTV.EncMapIntfInt32V(v, fastpathCheckNilTrue, e)
+ case *map[interface{}]int32:
+ fastpathTV.EncMapIntfInt32V(*v, fastpathCheckNilTrue, e)
+
+ case map[interface{}]int64:
+ fastpathTV.EncMapIntfInt64V(v, fastpathCheckNilTrue, e)
+ case *map[interface{}]int64:
+ fastpathTV.EncMapIntfInt64V(*v, fastpathCheckNilTrue, e)
+
+ case map[interface{}]float32:
+ fastpathTV.EncMapIntfFloat32V(v, fastpathCheckNilTrue, e)
+ case *map[interface{}]float32:
+ fastpathTV.EncMapIntfFloat32V(*v, fastpathCheckNilTrue, e)
+
+ case map[interface{}]float64:
+ fastpathTV.EncMapIntfFloat64V(v, fastpathCheckNilTrue, e)
+ case *map[interface{}]float64:
+ fastpathTV.EncMapIntfFloat64V(*v, fastpathCheckNilTrue, e)
+
+ case map[interface{}]bool:
+ fastpathTV.EncMapIntfBoolV(v, fastpathCheckNilTrue, e)
+ case *map[interface{}]bool:
+ fastpathTV.EncMapIntfBoolV(*v, fastpathCheckNilTrue, e)
+
+ case map[string]interface{}:
+ fastpathTV.EncMapStringIntfV(v, fastpathCheckNilTrue, e)
+ case *map[string]interface{}:
+ fastpathTV.EncMapStringIntfV(*v, fastpathCheckNilTrue, e)
+
+ case map[string]string:
+ fastpathTV.EncMapStringStringV(v, fastpathCheckNilTrue, e)
+ case *map[string]string:
+ fastpathTV.EncMapStringStringV(*v, fastpathCheckNilTrue, e)
+
+ case map[string]uint:
+ fastpathTV.EncMapStringUintV(v, fastpathCheckNilTrue, e)
+ case *map[string]uint:
+ fastpathTV.EncMapStringUintV(*v, fastpathCheckNilTrue, e)
+
+ case map[string]uint8:
+ fastpathTV.EncMapStringUint8V(v, fastpathCheckNilTrue, e)
+ case *map[string]uint8:
+ fastpathTV.EncMapStringUint8V(*v, fastpathCheckNilTrue, e)
+
+ case map[string]uint16:
+ fastpathTV.EncMapStringUint16V(v, fastpathCheckNilTrue, e)
+ case *map[string]uint16:
+ fastpathTV.EncMapStringUint16V(*v, fastpathCheckNilTrue, e)
+
+ case map[string]uint32:
+ fastpathTV.EncMapStringUint32V(v, fastpathCheckNilTrue, e)
+ case *map[string]uint32:
+ fastpathTV.EncMapStringUint32V(*v, fastpathCheckNilTrue, e)
+
+ case map[string]uint64:
+ fastpathTV.EncMapStringUint64V(v, fastpathCheckNilTrue, e)
+ case *map[string]uint64:
+ fastpathTV.EncMapStringUint64V(*v, fastpathCheckNilTrue, e)
+
+ case map[string]uintptr:
+ fastpathTV.EncMapStringUintptrV(v, fastpathCheckNilTrue, e)
+ case *map[string]uintptr:
+ fastpathTV.EncMapStringUintptrV(*v, fastpathCheckNilTrue, e)
+
+ case map[string]int:
+ fastpathTV.EncMapStringIntV(v, fastpathCheckNilTrue, e)
+ case *map[string]int:
+ fastpathTV.EncMapStringIntV(*v, fastpathCheckNilTrue, e)
+
+ case map[string]int8:
+ fastpathTV.EncMapStringInt8V(v, fastpathCheckNilTrue, e)
+ case *map[string]int8:
+ fastpathTV.EncMapStringInt8V(*v, fastpathCheckNilTrue, e)
+
+ case map[string]int16:
+ fastpathTV.EncMapStringInt16V(v, fastpathCheckNilTrue, e)
+ case *map[string]int16:
+ fastpathTV.EncMapStringInt16V(*v, fastpathCheckNilTrue, e)
+
+ case map[string]int32:
+ fastpathTV.EncMapStringInt32V(v, fastpathCheckNilTrue, e)
+ case *map[string]int32:
+ fastpathTV.EncMapStringInt32V(*v, fastpathCheckNilTrue, e)
+
+ case map[string]int64:
+ fastpathTV.EncMapStringInt64V(v, fastpathCheckNilTrue, e)
+ case *map[string]int64:
+ fastpathTV.EncMapStringInt64V(*v, fastpathCheckNilTrue, e)
+
+ case map[string]float32:
+ fastpathTV.EncMapStringFloat32V(v, fastpathCheckNilTrue, e)
+ case *map[string]float32:
+ fastpathTV.EncMapStringFloat32V(*v, fastpathCheckNilTrue, e)
+
+ case map[string]float64:
+ fastpathTV.EncMapStringFloat64V(v, fastpathCheckNilTrue, e)
+ case *map[string]float64:
+ fastpathTV.EncMapStringFloat64V(*v, fastpathCheckNilTrue, e)
+
+ case map[string]bool:
+ fastpathTV.EncMapStringBoolV(v, fastpathCheckNilTrue, e)
+ case *map[string]bool:
+ fastpathTV.EncMapStringBoolV(*v, fastpathCheckNilTrue, e)
+
+ case map[float32]interface{}:
+ fastpathTV.EncMapFloat32IntfV(v, fastpathCheckNilTrue, e)
+ case *map[float32]interface{}:
+ fastpathTV.EncMapFloat32IntfV(*v, fastpathCheckNilTrue, e)
+
+ case map[float32]string:
+ fastpathTV.EncMapFloat32StringV(v, fastpathCheckNilTrue, e)
+ case *map[float32]string:
+ fastpathTV.EncMapFloat32StringV(*v, fastpathCheckNilTrue, e)
+
+ case map[float32]uint:
+ fastpathTV.EncMapFloat32UintV(v, fastpathCheckNilTrue, e)
+ case *map[float32]uint:
+ fastpathTV.EncMapFloat32UintV(*v, fastpathCheckNilTrue, e)
+
+ case map[float32]uint8:
+ fastpathTV.EncMapFloat32Uint8V(v, fastpathCheckNilTrue, e)
+ case *map[float32]uint8:
+ fastpathTV.EncMapFloat32Uint8V(*v, fastpathCheckNilTrue, e)
+
+ case map[float32]uint16:
+ fastpathTV.EncMapFloat32Uint16V(v, fastpathCheckNilTrue, e)
+ case *map[float32]uint16:
+ fastpathTV.EncMapFloat32Uint16V(*v, fastpathCheckNilTrue, e)
+
+ case map[float32]uint32:
+ fastpathTV.EncMapFloat32Uint32V(v, fastpathCheckNilTrue, e)
+ case *map[float32]uint32:
+ fastpathTV.EncMapFloat32Uint32V(*v, fastpathCheckNilTrue, e)
+
+ case map[float32]uint64:
+ fastpathTV.EncMapFloat32Uint64V(v, fastpathCheckNilTrue, e)
+ case *map[float32]uint64:
+ fastpathTV.EncMapFloat32Uint64V(*v, fastpathCheckNilTrue, e)
+
+ case map[float32]uintptr:
+ fastpathTV.EncMapFloat32UintptrV(v, fastpathCheckNilTrue, e)
+ case *map[float32]uintptr:
+ fastpathTV.EncMapFloat32UintptrV(*v, fastpathCheckNilTrue, e)
+
+ case map[float32]int:
+ fastpathTV.EncMapFloat32IntV(v, fastpathCheckNilTrue, e)
+ case *map[float32]int:
+ fastpathTV.EncMapFloat32IntV(*v, fastpathCheckNilTrue, e)
+
+ case map[float32]int8:
+ fastpathTV.EncMapFloat32Int8V(v, fastpathCheckNilTrue, e)
+ case *map[float32]int8:
+ fastpathTV.EncMapFloat32Int8V(*v, fastpathCheckNilTrue, e)
+
+ case map[float32]int16:
+ fastpathTV.EncMapFloat32Int16V(v, fastpathCheckNilTrue, e)
+ case *map[float32]int16:
+ fastpathTV.EncMapFloat32Int16V(*v, fastpathCheckNilTrue, e)
+
+ case map[float32]int32:
+ fastpathTV.EncMapFloat32Int32V(v, fastpathCheckNilTrue, e)
+ case *map[float32]int32:
+ fastpathTV.EncMapFloat32Int32V(*v, fastpathCheckNilTrue, e)
+
+ case map[float32]int64:
+ fastpathTV.EncMapFloat32Int64V(v, fastpathCheckNilTrue, e)
+ case *map[float32]int64:
+ fastpathTV.EncMapFloat32Int64V(*v, fastpathCheckNilTrue, e)
+
+ case map[float32]float32:
+ fastpathTV.EncMapFloat32Float32V(v, fastpathCheckNilTrue, e)
+ case *map[float32]float32:
+ fastpathTV.EncMapFloat32Float32V(*v, fastpathCheckNilTrue, e)
+
+ case map[float32]float64:
+ fastpathTV.EncMapFloat32Float64V(v, fastpathCheckNilTrue, e)
+ case *map[float32]float64:
+ fastpathTV.EncMapFloat32Float64V(*v, fastpathCheckNilTrue, e)
+
+ case map[float32]bool:
+ fastpathTV.EncMapFloat32BoolV(v, fastpathCheckNilTrue, e)
+ case *map[float32]bool:
+ fastpathTV.EncMapFloat32BoolV(*v, fastpathCheckNilTrue, e)
+
+ case map[float64]interface{}:
+ fastpathTV.EncMapFloat64IntfV(v, fastpathCheckNilTrue, e)
+ case *map[float64]interface{}:
+ fastpathTV.EncMapFloat64IntfV(*v, fastpathCheckNilTrue, e)
+
+ case map[float64]string:
+ fastpathTV.EncMapFloat64StringV(v, fastpathCheckNilTrue, e)
+ case *map[float64]string:
+ fastpathTV.EncMapFloat64StringV(*v, fastpathCheckNilTrue, e)
+
+ case map[float64]uint:
+ fastpathTV.EncMapFloat64UintV(v, fastpathCheckNilTrue, e)
+ case *map[float64]uint:
+ fastpathTV.EncMapFloat64UintV(*v, fastpathCheckNilTrue, e)
+
+ case map[float64]uint8:
+ fastpathTV.EncMapFloat64Uint8V(v, fastpathCheckNilTrue, e)
+ case *map[float64]uint8:
+ fastpathTV.EncMapFloat64Uint8V(*v, fastpathCheckNilTrue, e)
+
+ case map[float64]uint16:
+ fastpathTV.EncMapFloat64Uint16V(v, fastpathCheckNilTrue, e)
+ case *map[float64]uint16:
+ fastpathTV.EncMapFloat64Uint16V(*v, fastpathCheckNilTrue, e)
+
+ case map[float64]uint32:
+ fastpathTV.EncMapFloat64Uint32V(v, fastpathCheckNilTrue, e)
+ case *map[float64]uint32:
+ fastpathTV.EncMapFloat64Uint32V(*v, fastpathCheckNilTrue, e)
+
+ case map[float64]uint64:
+ fastpathTV.EncMapFloat64Uint64V(v, fastpathCheckNilTrue, e)
+ case *map[float64]uint64:
+ fastpathTV.EncMapFloat64Uint64V(*v, fastpathCheckNilTrue, e)
+
+ case map[float64]uintptr:
+ fastpathTV.EncMapFloat64UintptrV(v, fastpathCheckNilTrue, e)
+ case *map[float64]uintptr:
+ fastpathTV.EncMapFloat64UintptrV(*v, fastpathCheckNilTrue, e)
+
+ case map[float64]int:
+ fastpathTV.EncMapFloat64IntV(v, fastpathCheckNilTrue, e)
+ case *map[float64]int:
+ fastpathTV.EncMapFloat64IntV(*v, fastpathCheckNilTrue, e)
+
+ case map[float64]int8:
+ fastpathTV.EncMapFloat64Int8V(v, fastpathCheckNilTrue, e)
+ case *map[float64]int8:
+ fastpathTV.EncMapFloat64Int8V(*v, fastpathCheckNilTrue, e)
+
+ case map[float64]int16:
+ fastpathTV.EncMapFloat64Int16V(v, fastpathCheckNilTrue, e)
+ case *map[float64]int16:
+ fastpathTV.EncMapFloat64Int16V(*v, fastpathCheckNilTrue, e)
+
+ case map[float64]int32:
+ fastpathTV.EncMapFloat64Int32V(v, fastpathCheckNilTrue, e)
+ case *map[float64]int32:
+ fastpathTV.EncMapFloat64Int32V(*v, fastpathCheckNilTrue, e)
+
+ case map[float64]int64:
+ fastpathTV.EncMapFloat64Int64V(v, fastpathCheckNilTrue, e)
+ case *map[float64]int64:
+ fastpathTV.EncMapFloat64Int64V(*v, fastpathCheckNilTrue, e)
+
+ case map[float64]float32:
+ fastpathTV.EncMapFloat64Float32V(v, fastpathCheckNilTrue, e)
+ case *map[float64]float32:
+ fastpathTV.EncMapFloat64Float32V(*v, fastpathCheckNilTrue, e)
+
+ case map[float64]float64:
+ fastpathTV.EncMapFloat64Float64V(v, fastpathCheckNilTrue, e)
+ case *map[float64]float64:
+ fastpathTV.EncMapFloat64Float64V(*v, fastpathCheckNilTrue, e)
+
+ case map[float64]bool:
+ fastpathTV.EncMapFloat64BoolV(v, fastpathCheckNilTrue, e)
+ case *map[float64]bool:
+ fastpathTV.EncMapFloat64BoolV(*v, fastpathCheckNilTrue, e)
+
+ case map[uint]interface{}:
+ fastpathTV.EncMapUintIntfV(v, fastpathCheckNilTrue, e)
+ case *map[uint]interface{}:
+ fastpathTV.EncMapUintIntfV(*v, fastpathCheckNilTrue, e)
+
+ case map[uint]string:
+ fastpathTV.EncMapUintStringV(v, fastpathCheckNilTrue, e)
+ case *map[uint]string:
+ fastpathTV.EncMapUintStringV(*v, fastpathCheckNilTrue, e)
+
+ case map[uint]uint:
+ fastpathTV.EncMapUintUintV(v, fastpathCheckNilTrue, e)
+ case *map[uint]uint:
+ fastpathTV.EncMapUintUintV(*v, fastpathCheckNilTrue, e)
+
+ case map[uint]uint8:
+ fastpathTV.EncMapUintUint8V(v, fastpathCheckNilTrue, e)
+ case *map[uint]uint8:
+ fastpathTV.EncMapUintUint8V(*v, fastpathCheckNilTrue, e)
+
+ case map[uint]uint16:
+ fastpathTV.EncMapUintUint16V(v, fastpathCheckNilTrue, e)
+ case *map[uint]uint16:
+ fastpathTV.EncMapUintUint16V(*v, fastpathCheckNilTrue, e)
+
+ case map[uint]uint32:
+ fastpathTV.EncMapUintUint32V(v, fastpathCheckNilTrue, e)
+ case *map[uint]uint32:
+ fastpathTV.EncMapUintUint32V(*v, fastpathCheckNilTrue, e)
+
+ case map[uint]uint64:
+ fastpathTV.EncMapUintUint64V(v, fastpathCheckNilTrue, e)
+ case *map[uint]uint64:
+ fastpathTV.EncMapUintUint64V(*v, fastpathCheckNilTrue, e)
+
+ case map[uint]uintptr:
+ fastpathTV.EncMapUintUintptrV(v, fastpathCheckNilTrue, e)
+ case *map[uint]uintptr:
+ fastpathTV.EncMapUintUintptrV(*v, fastpathCheckNilTrue, e)
+
+ case map[uint]int:
+ fastpathTV.EncMapUintIntV(v, fastpathCheckNilTrue, e)
+ case *map[uint]int:
+ fastpathTV.EncMapUintIntV(*v, fastpathCheckNilTrue, e)
+
+ case map[uint]int8:
+ fastpathTV.EncMapUintInt8V(v, fastpathCheckNilTrue, e)
+ case *map[uint]int8:
+ fastpathTV.EncMapUintInt8V(*v, fastpathCheckNilTrue, e)
+
+ case map[uint]int16:
+ fastpathTV.EncMapUintInt16V(v, fastpathCheckNilTrue, e)
+ case *map[uint]int16:
+ fastpathTV.EncMapUintInt16V(*v, fastpathCheckNilTrue, e)
+
+ case map[uint]int32:
+ fastpathTV.EncMapUintInt32V(v, fastpathCheckNilTrue, e)
+ case *map[uint]int32:
+ fastpathTV.EncMapUintInt32V(*v, fastpathCheckNilTrue, e)
+
+ case map[uint]int64:
+ fastpathTV.EncMapUintInt64V(v, fastpathCheckNilTrue, e)
+ case *map[uint]int64:
+ fastpathTV.EncMapUintInt64V(*v, fastpathCheckNilTrue, e)
+
+ case map[uint]float32:
+ fastpathTV.EncMapUintFloat32V(v, fastpathCheckNilTrue, e)
+ case *map[uint]float32:
+ fastpathTV.EncMapUintFloat32V(*v, fastpathCheckNilTrue, e)
+
+ case map[uint]float64:
+ fastpathTV.EncMapUintFloat64V(v, fastpathCheckNilTrue, e)
+ case *map[uint]float64:
+ fastpathTV.EncMapUintFloat64V(*v, fastpathCheckNilTrue, e)
+
+ case map[uint]bool:
+ fastpathTV.EncMapUintBoolV(v, fastpathCheckNilTrue, e)
+ case *map[uint]bool:
+ fastpathTV.EncMapUintBoolV(*v, fastpathCheckNilTrue, e)
+
+ case map[uint8]interface{}:
+ fastpathTV.EncMapUint8IntfV(v, fastpathCheckNilTrue, e)
+ case *map[uint8]interface{}:
+ fastpathTV.EncMapUint8IntfV(*v, fastpathCheckNilTrue, e)
+
+ case map[uint8]string:
+ fastpathTV.EncMapUint8StringV(v, fastpathCheckNilTrue, e)
+ case *map[uint8]string:
+ fastpathTV.EncMapUint8StringV(*v, fastpathCheckNilTrue, e)
+
+ case map[uint8]uint:
+ fastpathTV.EncMapUint8UintV(v, fastpathCheckNilTrue, e)
+ case *map[uint8]uint:
+ fastpathTV.EncMapUint8UintV(*v, fastpathCheckNilTrue, e)
+
+ case map[uint8]uint8:
+ fastpathTV.EncMapUint8Uint8V(v, fastpathCheckNilTrue, e)
+ case *map[uint8]uint8:
+ fastpathTV.EncMapUint8Uint8V(*v, fastpathCheckNilTrue, e)
+
+ case map[uint8]uint16:
+ fastpathTV.EncMapUint8Uint16V(v, fastpathCheckNilTrue, e)
+ case *map[uint8]uint16:
+ fastpathTV.EncMapUint8Uint16V(*v, fastpathCheckNilTrue, e)
+
+ case map[uint8]uint32:
+ fastpathTV.EncMapUint8Uint32V(v, fastpathCheckNilTrue, e)
+ case *map[uint8]uint32:
+ fastpathTV.EncMapUint8Uint32V(*v, fastpathCheckNilTrue, e)
+
+ case map[uint8]uint64:
+ fastpathTV.EncMapUint8Uint64V(v, fastpathCheckNilTrue, e)
+ case *map[uint8]uint64:
+ fastpathTV.EncMapUint8Uint64V(*v, fastpathCheckNilTrue, e)
+
+ case map[uint8]uintptr:
+ fastpathTV.EncMapUint8UintptrV(v, fastpathCheckNilTrue, e)
+ case *map[uint8]uintptr:
+ fastpathTV.EncMapUint8UintptrV(*v, fastpathCheckNilTrue, e)
+
+ case map[uint8]int:
+ fastpathTV.EncMapUint8IntV(v, fastpathCheckNilTrue, e)
+ case *map[uint8]int:
+ fastpathTV.EncMapUint8IntV(*v, fastpathCheckNilTrue, e)
+
+ case map[uint8]int8:
+ fastpathTV.EncMapUint8Int8V(v, fastpathCheckNilTrue, e)
+ case *map[uint8]int8:
+ fastpathTV.EncMapUint8Int8V(*v, fastpathCheckNilTrue, e)
+
+ case map[uint8]int16:
+ fastpathTV.EncMapUint8Int16V(v, fastpathCheckNilTrue, e)
+ case *map[uint8]int16:
+ fastpathTV.EncMapUint8Int16V(*v, fastpathCheckNilTrue, e)
+
+ case map[uint8]int32:
+ fastpathTV.EncMapUint8Int32V(v, fastpathCheckNilTrue, e)
+ case *map[uint8]int32:
+ fastpathTV.EncMapUint8Int32V(*v, fastpathCheckNilTrue, e)
+
+ case map[uint8]int64:
+ fastpathTV.EncMapUint8Int64V(v, fastpathCheckNilTrue, e)
+ case *map[uint8]int64:
+ fastpathTV.EncMapUint8Int64V(*v, fastpathCheckNilTrue, e)
+
+ case map[uint8]float32:
+ fastpathTV.EncMapUint8Float32V(v, fastpathCheckNilTrue, e)
+ case *map[uint8]float32:
+ fastpathTV.EncMapUint8Float32V(*v, fastpathCheckNilTrue, e)
+
+ case map[uint8]float64:
+ fastpathTV.EncMapUint8Float64V(v, fastpathCheckNilTrue, e)
+ case *map[uint8]float64:
+ fastpathTV.EncMapUint8Float64V(*v, fastpathCheckNilTrue, e)
+
+ case map[uint8]bool:
+ fastpathTV.EncMapUint8BoolV(v, fastpathCheckNilTrue, e)
+ case *map[uint8]bool:
+ fastpathTV.EncMapUint8BoolV(*v, fastpathCheckNilTrue, e)
+
+ case map[uint16]interface{}:
+ fastpathTV.EncMapUint16IntfV(v, fastpathCheckNilTrue, e)
+ case *map[uint16]interface{}:
+ fastpathTV.EncMapUint16IntfV(*v, fastpathCheckNilTrue, e)
+
+ case map[uint16]string:
+ fastpathTV.EncMapUint16StringV(v, fastpathCheckNilTrue, e)
+ case *map[uint16]string:
+ fastpathTV.EncMapUint16StringV(*v, fastpathCheckNilTrue, e)
+
+ case map[uint16]uint:
+ fastpathTV.EncMapUint16UintV(v, fastpathCheckNilTrue, e)
+ case *map[uint16]uint:
+ fastpathTV.EncMapUint16UintV(*v, fastpathCheckNilTrue, e)
+
+ case map[uint16]uint8:
+ fastpathTV.EncMapUint16Uint8V(v, fastpathCheckNilTrue, e)
+ case *map[uint16]uint8:
+ fastpathTV.EncMapUint16Uint8V(*v, fastpathCheckNilTrue, e)
+
+ case map[uint16]uint16:
+ fastpathTV.EncMapUint16Uint16V(v, fastpathCheckNilTrue, e)
+ case *map[uint16]uint16:
+ fastpathTV.EncMapUint16Uint16V(*v, fastpathCheckNilTrue, e)
+
+ case map[uint16]uint32:
+ fastpathTV.EncMapUint16Uint32V(v, fastpathCheckNilTrue, e)
+ case *map[uint16]uint32:
+ fastpathTV.EncMapUint16Uint32V(*v, fastpathCheckNilTrue, e)
+
+ case map[uint16]uint64:
+ fastpathTV.EncMapUint16Uint64V(v, fastpathCheckNilTrue, e)
+ case *map[uint16]uint64:
+ fastpathTV.EncMapUint16Uint64V(*v, fastpathCheckNilTrue, e)
+
+ case map[uint16]uintptr:
+ fastpathTV.EncMapUint16UintptrV(v, fastpathCheckNilTrue, e)
+ case *map[uint16]uintptr:
+ fastpathTV.EncMapUint16UintptrV(*v, fastpathCheckNilTrue, e)
+
+ case map[uint16]int:
+ fastpathTV.EncMapUint16IntV(v, fastpathCheckNilTrue, e)
+ case *map[uint16]int:
+ fastpathTV.EncMapUint16IntV(*v, fastpathCheckNilTrue, e)
+
+ case map[uint16]int8:
+ fastpathTV.EncMapUint16Int8V(v, fastpathCheckNilTrue, e)
+ case *map[uint16]int8:
+ fastpathTV.EncMapUint16Int8V(*v, fastpathCheckNilTrue, e)
+
+ case map[uint16]int16:
+ fastpathTV.EncMapUint16Int16V(v, fastpathCheckNilTrue, e)
+ case *map[uint16]int16:
+ fastpathTV.EncMapUint16Int16V(*v, fastpathCheckNilTrue, e)
+
+ case map[uint16]int32:
+ fastpathTV.EncMapUint16Int32V(v, fastpathCheckNilTrue, e)
+ case *map[uint16]int32:
+ fastpathTV.EncMapUint16Int32V(*v, fastpathCheckNilTrue, e)
+
+ case map[uint16]int64:
+ fastpathTV.EncMapUint16Int64V(v, fastpathCheckNilTrue, e)
+ case *map[uint16]int64:
+ fastpathTV.EncMapUint16Int64V(*v, fastpathCheckNilTrue, e)
+
+ case map[uint16]float32:
+ fastpathTV.EncMapUint16Float32V(v, fastpathCheckNilTrue, e)
+ case *map[uint16]float32:
+ fastpathTV.EncMapUint16Float32V(*v, fastpathCheckNilTrue, e)
+
+ case map[uint16]float64:
+ fastpathTV.EncMapUint16Float64V(v, fastpathCheckNilTrue, e)
+ case *map[uint16]float64:
+ fastpathTV.EncMapUint16Float64V(*v, fastpathCheckNilTrue, e)
+
+ case map[uint16]bool:
+ fastpathTV.EncMapUint16BoolV(v, fastpathCheckNilTrue, e)
+ case *map[uint16]bool:
+ fastpathTV.EncMapUint16BoolV(*v, fastpathCheckNilTrue, e)
+
+ case map[uint32]interface{}:
+ fastpathTV.EncMapUint32IntfV(v, fastpathCheckNilTrue, e)
+ case *map[uint32]interface{}:
+ fastpathTV.EncMapUint32IntfV(*v, fastpathCheckNilTrue, e)
+
+ case map[uint32]string:
+ fastpathTV.EncMapUint32StringV(v, fastpathCheckNilTrue, e)
+ case *map[uint32]string:
+ fastpathTV.EncMapUint32StringV(*v, fastpathCheckNilTrue, e)
+
+ case map[uint32]uint:
+ fastpathTV.EncMapUint32UintV(v, fastpathCheckNilTrue, e)
+ case *map[uint32]uint:
+ fastpathTV.EncMapUint32UintV(*v, fastpathCheckNilTrue, e)
+
+ case map[uint32]uint8:
+ fastpathTV.EncMapUint32Uint8V(v, fastpathCheckNilTrue, e)
+ case *map[uint32]uint8:
+ fastpathTV.EncMapUint32Uint8V(*v, fastpathCheckNilTrue, e)
+
+ case map[uint32]uint16:
+ fastpathTV.EncMapUint32Uint16V(v, fastpathCheckNilTrue, e)
+ case *map[uint32]uint16:
+ fastpathTV.EncMapUint32Uint16V(*v, fastpathCheckNilTrue, e)
+
+ case map[uint32]uint32:
+ fastpathTV.EncMapUint32Uint32V(v, fastpathCheckNilTrue, e)
+ case *map[uint32]uint32:
+ fastpathTV.EncMapUint32Uint32V(*v, fastpathCheckNilTrue, e)
+
+ case map[uint32]uint64:
+ fastpathTV.EncMapUint32Uint64V(v, fastpathCheckNilTrue, e)
+ case *map[uint32]uint64:
+ fastpathTV.EncMapUint32Uint64V(*v, fastpathCheckNilTrue, e)
+
+ case map[uint32]uintptr:
+ fastpathTV.EncMapUint32UintptrV(v, fastpathCheckNilTrue, e)
+ case *map[uint32]uintptr:
+ fastpathTV.EncMapUint32UintptrV(*v, fastpathCheckNilTrue, e)
+
+ case map[uint32]int:
+ fastpathTV.EncMapUint32IntV(v, fastpathCheckNilTrue, e)
+ case *map[uint32]int:
+ fastpathTV.EncMapUint32IntV(*v, fastpathCheckNilTrue, e)
+
+ case map[uint32]int8:
+ fastpathTV.EncMapUint32Int8V(v, fastpathCheckNilTrue, e)
+ case *map[uint32]int8:
+ fastpathTV.EncMapUint32Int8V(*v, fastpathCheckNilTrue, e)
+
+ case map[uint32]int16:
+ fastpathTV.EncMapUint32Int16V(v, fastpathCheckNilTrue, e)
+ case *map[uint32]int16:
+ fastpathTV.EncMapUint32Int16V(*v, fastpathCheckNilTrue, e)
+
+ case map[uint32]int32:
+ fastpathTV.EncMapUint32Int32V(v, fastpathCheckNilTrue, e)
+ case *map[uint32]int32:
+ fastpathTV.EncMapUint32Int32V(*v, fastpathCheckNilTrue, e)
+
+ case map[uint32]int64:
+ fastpathTV.EncMapUint32Int64V(v, fastpathCheckNilTrue, e)
+ case *map[uint32]int64:
+ fastpathTV.EncMapUint32Int64V(*v, fastpathCheckNilTrue, e)
+
+ case map[uint32]float32:
+ fastpathTV.EncMapUint32Float32V(v, fastpathCheckNilTrue, e)
+ case *map[uint32]float32:
+ fastpathTV.EncMapUint32Float32V(*v, fastpathCheckNilTrue, e)
+
+ case map[uint32]float64:
+ fastpathTV.EncMapUint32Float64V(v, fastpathCheckNilTrue, e)
+ case *map[uint32]float64:
+ fastpathTV.EncMapUint32Float64V(*v, fastpathCheckNilTrue, e)
+
+ case map[uint32]bool:
+ fastpathTV.EncMapUint32BoolV(v, fastpathCheckNilTrue, e)
+ case *map[uint32]bool:
+ fastpathTV.EncMapUint32BoolV(*v, fastpathCheckNilTrue, e)
+
+ case map[uint64]interface{}:
+ fastpathTV.EncMapUint64IntfV(v, fastpathCheckNilTrue, e)
+ case *map[uint64]interface{}:
+ fastpathTV.EncMapUint64IntfV(*v, fastpathCheckNilTrue, e)
+
+ case map[uint64]string:
+ fastpathTV.EncMapUint64StringV(v, fastpathCheckNilTrue, e)
+ case *map[uint64]string:
+ fastpathTV.EncMapUint64StringV(*v, fastpathCheckNilTrue, e)
+
+ case map[uint64]uint:
+ fastpathTV.EncMapUint64UintV(v, fastpathCheckNilTrue, e)
+ case *map[uint64]uint:
+ fastpathTV.EncMapUint64UintV(*v, fastpathCheckNilTrue, e)
+
+ case map[uint64]uint8:
+ fastpathTV.EncMapUint64Uint8V(v, fastpathCheckNilTrue, e)
+ case *map[uint64]uint8:
+ fastpathTV.EncMapUint64Uint8V(*v, fastpathCheckNilTrue, e)
+
+ case map[uint64]uint16:
+ fastpathTV.EncMapUint64Uint16V(v, fastpathCheckNilTrue, e)
+ case *map[uint64]uint16:
+ fastpathTV.EncMapUint64Uint16V(*v, fastpathCheckNilTrue, e)
+
+ case map[uint64]uint32:
+ fastpathTV.EncMapUint64Uint32V(v, fastpathCheckNilTrue, e)
+ case *map[uint64]uint32:
+ fastpathTV.EncMapUint64Uint32V(*v, fastpathCheckNilTrue, e)
+
+ case map[uint64]uint64:
+ fastpathTV.EncMapUint64Uint64V(v, fastpathCheckNilTrue, e)
+ case *map[uint64]uint64:
+ fastpathTV.EncMapUint64Uint64V(*v, fastpathCheckNilTrue, e)
+
+ case map[uint64]uintptr:
+ fastpathTV.EncMapUint64UintptrV(v, fastpathCheckNilTrue, e)
+ case *map[uint64]uintptr:
+ fastpathTV.EncMapUint64UintptrV(*v, fastpathCheckNilTrue, e)
+
+ case map[uint64]int:
+ fastpathTV.EncMapUint64IntV(v, fastpathCheckNilTrue, e)
+ case *map[uint64]int:
+ fastpathTV.EncMapUint64IntV(*v, fastpathCheckNilTrue, e)
+
+ case map[uint64]int8:
+ fastpathTV.EncMapUint64Int8V(v, fastpathCheckNilTrue, e)
+ case *map[uint64]int8:
+ fastpathTV.EncMapUint64Int8V(*v, fastpathCheckNilTrue, e)
+
+ case map[uint64]int16:
+ fastpathTV.EncMapUint64Int16V(v, fastpathCheckNilTrue, e)
+ case *map[uint64]int16:
+ fastpathTV.EncMapUint64Int16V(*v, fastpathCheckNilTrue, e)
+
+ case map[uint64]int32:
+ fastpathTV.EncMapUint64Int32V(v, fastpathCheckNilTrue, e)
+ case *map[uint64]int32:
+ fastpathTV.EncMapUint64Int32V(*v, fastpathCheckNilTrue, e)
+
+ case map[uint64]int64:
+ fastpathTV.EncMapUint64Int64V(v, fastpathCheckNilTrue, e)
+ case *map[uint64]int64:
+ fastpathTV.EncMapUint64Int64V(*v, fastpathCheckNilTrue, e)
+
+ case map[uint64]float32:
+ fastpathTV.EncMapUint64Float32V(v, fastpathCheckNilTrue, e)
+ case *map[uint64]float32:
+ fastpathTV.EncMapUint64Float32V(*v, fastpathCheckNilTrue, e)
+
+ case map[uint64]float64:
+ fastpathTV.EncMapUint64Float64V(v, fastpathCheckNilTrue, e)
+ case *map[uint64]float64:
+ fastpathTV.EncMapUint64Float64V(*v, fastpathCheckNilTrue, e)
+
+ case map[uint64]bool:
+ fastpathTV.EncMapUint64BoolV(v, fastpathCheckNilTrue, e)
+ case *map[uint64]bool:
+ fastpathTV.EncMapUint64BoolV(*v, fastpathCheckNilTrue, e)
+
+ case map[uintptr]interface{}:
+ fastpathTV.EncMapUintptrIntfV(v, fastpathCheckNilTrue, e)
+ case *map[uintptr]interface{}:
+ fastpathTV.EncMapUintptrIntfV(*v, fastpathCheckNilTrue, e)
+
+ case map[uintptr]string:
+ fastpathTV.EncMapUintptrStringV(v, fastpathCheckNilTrue, e)
+ case *map[uintptr]string:
+ fastpathTV.EncMapUintptrStringV(*v, fastpathCheckNilTrue, e)
+
+ case map[uintptr]uint:
+ fastpathTV.EncMapUintptrUintV(v, fastpathCheckNilTrue, e)
+ case *map[uintptr]uint:
+ fastpathTV.EncMapUintptrUintV(*v, fastpathCheckNilTrue, e)
+
+ case map[uintptr]uint8:
+ fastpathTV.EncMapUintptrUint8V(v, fastpathCheckNilTrue, e)
+ case *map[uintptr]uint8:
+ fastpathTV.EncMapUintptrUint8V(*v, fastpathCheckNilTrue, e)
+
+ case map[uintptr]uint16:
+ fastpathTV.EncMapUintptrUint16V(v, fastpathCheckNilTrue, e)
+ case *map[uintptr]uint16:
+ fastpathTV.EncMapUintptrUint16V(*v, fastpathCheckNilTrue, e)
+
+ case map[uintptr]uint32:
+ fastpathTV.EncMapUintptrUint32V(v, fastpathCheckNilTrue, e)
+ case *map[uintptr]uint32:
+ fastpathTV.EncMapUintptrUint32V(*v, fastpathCheckNilTrue, e)
+
+ case map[uintptr]uint64:
+ fastpathTV.EncMapUintptrUint64V(v, fastpathCheckNilTrue, e)
+ case *map[uintptr]uint64:
+ fastpathTV.EncMapUintptrUint64V(*v, fastpathCheckNilTrue, e)
+
+ case map[uintptr]uintptr:
+ fastpathTV.EncMapUintptrUintptrV(v, fastpathCheckNilTrue, e)
+ case *map[uintptr]uintptr:
+ fastpathTV.EncMapUintptrUintptrV(*v, fastpathCheckNilTrue, e)
+
+ case map[uintptr]int:
+ fastpathTV.EncMapUintptrIntV(v, fastpathCheckNilTrue, e)
+ case *map[uintptr]int:
+ fastpathTV.EncMapUintptrIntV(*v, fastpathCheckNilTrue, e)
+
+ case map[uintptr]int8:
+ fastpathTV.EncMapUintptrInt8V(v, fastpathCheckNilTrue, e)
+ case *map[uintptr]int8:
+ fastpathTV.EncMapUintptrInt8V(*v, fastpathCheckNilTrue, e)
+
+ case map[uintptr]int16:
+ fastpathTV.EncMapUintptrInt16V(v, fastpathCheckNilTrue, e)
+ case *map[uintptr]int16:
+ fastpathTV.EncMapUintptrInt16V(*v, fastpathCheckNilTrue, e)
+
+ case map[uintptr]int32:
+ fastpathTV.EncMapUintptrInt32V(v, fastpathCheckNilTrue, e)
+ case *map[uintptr]int32:
+ fastpathTV.EncMapUintptrInt32V(*v, fastpathCheckNilTrue, e)
+
+ case map[uintptr]int64:
+ fastpathTV.EncMapUintptrInt64V(v, fastpathCheckNilTrue, e)
+ case *map[uintptr]int64:
+ fastpathTV.EncMapUintptrInt64V(*v, fastpathCheckNilTrue, e)
+
+ case map[uintptr]float32:
+ fastpathTV.EncMapUintptrFloat32V(v, fastpathCheckNilTrue, e)
+ case *map[uintptr]float32:
+ fastpathTV.EncMapUintptrFloat32V(*v, fastpathCheckNilTrue, e)
+
+ case map[uintptr]float64:
+ fastpathTV.EncMapUintptrFloat64V(v, fastpathCheckNilTrue, e)
+ case *map[uintptr]float64:
+ fastpathTV.EncMapUintptrFloat64V(*v, fastpathCheckNilTrue, e)
+
+ case map[uintptr]bool:
+ fastpathTV.EncMapUintptrBoolV(v, fastpathCheckNilTrue, e)
+ case *map[uintptr]bool:
+ fastpathTV.EncMapUintptrBoolV(*v, fastpathCheckNilTrue, e)
+
+ case map[int]interface{}:
+ fastpathTV.EncMapIntIntfV(v, fastpathCheckNilTrue, e)
+ case *map[int]interface{}:
+ fastpathTV.EncMapIntIntfV(*v, fastpathCheckNilTrue, e)
+
+ case map[int]string:
+ fastpathTV.EncMapIntStringV(v, fastpathCheckNilTrue, e)
+ case *map[int]string:
+ fastpathTV.EncMapIntStringV(*v, fastpathCheckNilTrue, e)
+
+ case map[int]uint:
+ fastpathTV.EncMapIntUintV(v, fastpathCheckNilTrue, e)
+ case *map[int]uint:
+ fastpathTV.EncMapIntUintV(*v, fastpathCheckNilTrue, e)
+
+ case map[int]uint8:
+ fastpathTV.EncMapIntUint8V(v, fastpathCheckNilTrue, e)
+ case *map[int]uint8:
+ fastpathTV.EncMapIntUint8V(*v, fastpathCheckNilTrue, e)
+
+ case map[int]uint16:
+ fastpathTV.EncMapIntUint16V(v, fastpathCheckNilTrue, e)
+ case *map[int]uint16:
+ fastpathTV.EncMapIntUint16V(*v, fastpathCheckNilTrue, e)
+
+ case map[int]uint32:
+ fastpathTV.EncMapIntUint32V(v, fastpathCheckNilTrue, e)
+ case *map[int]uint32:
+ fastpathTV.EncMapIntUint32V(*v, fastpathCheckNilTrue, e)
+
+ case map[int]uint64:
+ fastpathTV.EncMapIntUint64V(v, fastpathCheckNilTrue, e)
+ case *map[int]uint64:
+ fastpathTV.EncMapIntUint64V(*v, fastpathCheckNilTrue, e)
+
+ case map[int]uintptr:
+ fastpathTV.EncMapIntUintptrV(v, fastpathCheckNilTrue, e)
+ case *map[int]uintptr:
+ fastpathTV.EncMapIntUintptrV(*v, fastpathCheckNilTrue, e)
+
+ case map[int]int:
+ fastpathTV.EncMapIntIntV(v, fastpathCheckNilTrue, e)
+ case *map[int]int:
+ fastpathTV.EncMapIntIntV(*v, fastpathCheckNilTrue, e)
+
+ case map[int]int8:
+ fastpathTV.EncMapIntInt8V(v, fastpathCheckNilTrue, e)
+ case *map[int]int8:
+ fastpathTV.EncMapIntInt8V(*v, fastpathCheckNilTrue, e)
+
+ case map[int]int16:
+ fastpathTV.EncMapIntInt16V(v, fastpathCheckNilTrue, e)
+ case *map[int]int16:
+ fastpathTV.EncMapIntInt16V(*v, fastpathCheckNilTrue, e)
+
+ case map[int]int32:
+ fastpathTV.EncMapIntInt32V(v, fastpathCheckNilTrue, e)
+ case *map[int]int32:
+ fastpathTV.EncMapIntInt32V(*v, fastpathCheckNilTrue, e)
+
+ case map[int]int64:
+ fastpathTV.EncMapIntInt64V(v, fastpathCheckNilTrue, e)
+ case *map[int]int64:
+ fastpathTV.EncMapIntInt64V(*v, fastpathCheckNilTrue, e)
+
+ case map[int]float32:
+ fastpathTV.EncMapIntFloat32V(v, fastpathCheckNilTrue, e)
+ case *map[int]float32:
+ fastpathTV.EncMapIntFloat32V(*v, fastpathCheckNilTrue, e)
+
+ case map[int]float64:
+ fastpathTV.EncMapIntFloat64V(v, fastpathCheckNilTrue, e)
+ case *map[int]float64:
+ fastpathTV.EncMapIntFloat64V(*v, fastpathCheckNilTrue, e)
+
+ case map[int]bool:
+ fastpathTV.EncMapIntBoolV(v, fastpathCheckNilTrue, e)
+ case *map[int]bool:
+ fastpathTV.EncMapIntBoolV(*v, fastpathCheckNilTrue, e)
+
+ case map[int8]interface{}:
+ fastpathTV.EncMapInt8IntfV(v, fastpathCheckNilTrue, e)
+ case *map[int8]interface{}:
+ fastpathTV.EncMapInt8IntfV(*v, fastpathCheckNilTrue, e)
+
+ case map[int8]string:
+ fastpathTV.EncMapInt8StringV(v, fastpathCheckNilTrue, e)
+ case *map[int8]string:
+ fastpathTV.EncMapInt8StringV(*v, fastpathCheckNilTrue, e)
+
+ case map[int8]uint:
+ fastpathTV.EncMapInt8UintV(v, fastpathCheckNilTrue, e)
+ case *map[int8]uint:
+ fastpathTV.EncMapInt8UintV(*v, fastpathCheckNilTrue, e)
+
+ case map[int8]uint8:
+ fastpathTV.EncMapInt8Uint8V(v, fastpathCheckNilTrue, e)
+ case *map[int8]uint8:
+ fastpathTV.EncMapInt8Uint8V(*v, fastpathCheckNilTrue, e)
+
+ case map[int8]uint16:
+ fastpathTV.EncMapInt8Uint16V(v, fastpathCheckNilTrue, e)
+ case *map[int8]uint16:
+ fastpathTV.EncMapInt8Uint16V(*v, fastpathCheckNilTrue, e)
+
+ case map[int8]uint32:
+ fastpathTV.EncMapInt8Uint32V(v, fastpathCheckNilTrue, e)
+ case *map[int8]uint32:
+ fastpathTV.EncMapInt8Uint32V(*v, fastpathCheckNilTrue, e)
+
+ case map[int8]uint64:
+ fastpathTV.EncMapInt8Uint64V(v, fastpathCheckNilTrue, e)
+ case *map[int8]uint64:
+ fastpathTV.EncMapInt8Uint64V(*v, fastpathCheckNilTrue, e)
+
+ case map[int8]uintptr:
+ fastpathTV.EncMapInt8UintptrV(v, fastpathCheckNilTrue, e)
+ case *map[int8]uintptr:
+ fastpathTV.EncMapInt8UintptrV(*v, fastpathCheckNilTrue, e)
+
+ case map[int8]int:
+ fastpathTV.EncMapInt8IntV(v, fastpathCheckNilTrue, e)
+ case *map[int8]int:
+ fastpathTV.EncMapInt8IntV(*v, fastpathCheckNilTrue, e)
+
+ case map[int8]int8:
+ fastpathTV.EncMapInt8Int8V(v, fastpathCheckNilTrue, e)
+ case *map[int8]int8:
+ fastpathTV.EncMapInt8Int8V(*v, fastpathCheckNilTrue, e)
+
+ case map[int8]int16:
+ fastpathTV.EncMapInt8Int16V(v, fastpathCheckNilTrue, e)
+ case *map[int8]int16:
+ fastpathTV.EncMapInt8Int16V(*v, fastpathCheckNilTrue, e)
+
+ case map[int8]int32:
+ fastpathTV.EncMapInt8Int32V(v, fastpathCheckNilTrue, e)
+ case *map[int8]int32:
+ fastpathTV.EncMapInt8Int32V(*v, fastpathCheckNilTrue, e)
+
+ case map[int8]int64:
+ fastpathTV.EncMapInt8Int64V(v, fastpathCheckNilTrue, e)
+ case *map[int8]int64:
+ fastpathTV.EncMapInt8Int64V(*v, fastpathCheckNilTrue, e)
+
+ case map[int8]float32:
+ fastpathTV.EncMapInt8Float32V(v, fastpathCheckNilTrue, e)
+ case *map[int8]float32:
+ fastpathTV.EncMapInt8Float32V(*v, fastpathCheckNilTrue, e)
+
+ case map[int8]float64:
+ fastpathTV.EncMapInt8Float64V(v, fastpathCheckNilTrue, e)
+ case *map[int8]float64:
+ fastpathTV.EncMapInt8Float64V(*v, fastpathCheckNilTrue, e)
+
+ case map[int8]bool:
+ fastpathTV.EncMapInt8BoolV(v, fastpathCheckNilTrue, e)
+ case *map[int8]bool:
+ fastpathTV.EncMapInt8BoolV(*v, fastpathCheckNilTrue, e)
+
+ case map[int16]interface{}:
+ fastpathTV.EncMapInt16IntfV(v, fastpathCheckNilTrue, e)
+ case *map[int16]interface{}:
+ fastpathTV.EncMapInt16IntfV(*v, fastpathCheckNilTrue, e)
+
+ case map[int16]string:
+ fastpathTV.EncMapInt16StringV(v, fastpathCheckNilTrue, e)
+ case *map[int16]string:
+ fastpathTV.EncMapInt16StringV(*v, fastpathCheckNilTrue, e)
+
+ case map[int16]uint:
+ fastpathTV.EncMapInt16UintV(v, fastpathCheckNilTrue, e)
+ case *map[int16]uint:
+ fastpathTV.EncMapInt16UintV(*v, fastpathCheckNilTrue, e)
+
+ case map[int16]uint8:
+ fastpathTV.EncMapInt16Uint8V(v, fastpathCheckNilTrue, e)
+ case *map[int16]uint8:
+ fastpathTV.EncMapInt16Uint8V(*v, fastpathCheckNilTrue, e)
+
+ case map[int16]uint16:
+ fastpathTV.EncMapInt16Uint16V(v, fastpathCheckNilTrue, e)
+ case *map[int16]uint16:
+ fastpathTV.EncMapInt16Uint16V(*v, fastpathCheckNilTrue, e)
+
+ case map[int16]uint32:
+ fastpathTV.EncMapInt16Uint32V(v, fastpathCheckNilTrue, e)
+ case *map[int16]uint32:
+ fastpathTV.EncMapInt16Uint32V(*v, fastpathCheckNilTrue, e)
+
+ case map[int16]uint64:
+ fastpathTV.EncMapInt16Uint64V(v, fastpathCheckNilTrue, e)
+ case *map[int16]uint64:
+ fastpathTV.EncMapInt16Uint64V(*v, fastpathCheckNilTrue, e)
+
+ case map[int16]uintptr:
+ fastpathTV.EncMapInt16UintptrV(v, fastpathCheckNilTrue, e)
+ case *map[int16]uintptr:
+ fastpathTV.EncMapInt16UintptrV(*v, fastpathCheckNilTrue, e)
+
+ case map[int16]int:
+ fastpathTV.EncMapInt16IntV(v, fastpathCheckNilTrue, e)
+ case *map[int16]int:
+ fastpathTV.EncMapInt16IntV(*v, fastpathCheckNilTrue, e)
+
+ case map[int16]int8:
+ fastpathTV.EncMapInt16Int8V(v, fastpathCheckNilTrue, e)
+ case *map[int16]int8:
+ fastpathTV.EncMapInt16Int8V(*v, fastpathCheckNilTrue, e)
+
+ case map[int16]int16:
+ fastpathTV.EncMapInt16Int16V(v, fastpathCheckNilTrue, e)
+ case *map[int16]int16:
+ fastpathTV.EncMapInt16Int16V(*v, fastpathCheckNilTrue, e)
+
+ case map[int16]int32:
+ fastpathTV.EncMapInt16Int32V(v, fastpathCheckNilTrue, e)
+ case *map[int16]int32:
+ fastpathTV.EncMapInt16Int32V(*v, fastpathCheckNilTrue, e)
+
+ case map[int16]int64:
+ fastpathTV.EncMapInt16Int64V(v, fastpathCheckNilTrue, e)
+ case *map[int16]int64:
+ fastpathTV.EncMapInt16Int64V(*v, fastpathCheckNilTrue, e)
+
+ case map[int16]float32:
+ fastpathTV.EncMapInt16Float32V(v, fastpathCheckNilTrue, e)
+ case *map[int16]float32:
+ fastpathTV.EncMapInt16Float32V(*v, fastpathCheckNilTrue, e)
+
+ case map[int16]float64:
+ fastpathTV.EncMapInt16Float64V(v, fastpathCheckNilTrue, e)
+ case *map[int16]float64:
+ fastpathTV.EncMapInt16Float64V(*v, fastpathCheckNilTrue, e)
+
+ case map[int16]bool:
+ fastpathTV.EncMapInt16BoolV(v, fastpathCheckNilTrue, e)
+ case *map[int16]bool:
+ fastpathTV.EncMapInt16BoolV(*v, fastpathCheckNilTrue, e)
+
+ case map[int32]interface{}:
+ fastpathTV.EncMapInt32IntfV(v, fastpathCheckNilTrue, e)
+ case *map[int32]interface{}:
+ fastpathTV.EncMapInt32IntfV(*v, fastpathCheckNilTrue, e)
+
+ case map[int32]string:
+ fastpathTV.EncMapInt32StringV(v, fastpathCheckNilTrue, e)
+ case *map[int32]string:
+ fastpathTV.EncMapInt32StringV(*v, fastpathCheckNilTrue, e)
+
+ case map[int32]uint:
+ fastpathTV.EncMapInt32UintV(v, fastpathCheckNilTrue, e)
+ case *map[int32]uint:
+ fastpathTV.EncMapInt32UintV(*v, fastpathCheckNilTrue, e)
+
+ case map[int32]uint8:
+ fastpathTV.EncMapInt32Uint8V(v, fastpathCheckNilTrue, e)
+ case *map[int32]uint8:
+ fastpathTV.EncMapInt32Uint8V(*v, fastpathCheckNilTrue, e)
+
+ case map[int32]uint16:
+ fastpathTV.EncMapInt32Uint16V(v, fastpathCheckNilTrue, e)
+ case *map[int32]uint16:
+ fastpathTV.EncMapInt32Uint16V(*v, fastpathCheckNilTrue, e)
+
+ case map[int32]uint32:
+ fastpathTV.EncMapInt32Uint32V(v, fastpathCheckNilTrue, e)
+ case *map[int32]uint32:
+ fastpathTV.EncMapInt32Uint32V(*v, fastpathCheckNilTrue, e)
+
+ case map[int32]uint64:
+ fastpathTV.EncMapInt32Uint64V(v, fastpathCheckNilTrue, e)
+ case *map[int32]uint64:
+ fastpathTV.EncMapInt32Uint64V(*v, fastpathCheckNilTrue, e)
+
+ case map[int32]uintptr:
+ fastpathTV.EncMapInt32UintptrV(v, fastpathCheckNilTrue, e)
+ case *map[int32]uintptr:
+ fastpathTV.EncMapInt32UintptrV(*v, fastpathCheckNilTrue, e)
+
+ case map[int32]int:
+ fastpathTV.EncMapInt32IntV(v, fastpathCheckNilTrue, e)
+ case *map[int32]int:
+ fastpathTV.EncMapInt32IntV(*v, fastpathCheckNilTrue, e)
+
+ case map[int32]int8:
+ fastpathTV.EncMapInt32Int8V(v, fastpathCheckNilTrue, e)
+ case *map[int32]int8:
+ fastpathTV.EncMapInt32Int8V(*v, fastpathCheckNilTrue, e)
+
+ case map[int32]int16:
+ fastpathTV.EncMapInt32Int16V(v, fastpathCheckNilTrue, e)
+ case *map[int32]int16:
+ fastpathTV.EncMapInt32Int16V(*v, fastpathCheckNilTrue, e)
+
+ case map[int32]int32:
+ fastpathTV.EncMapInt32Int32V(v, fastpathCheckNilTrue, e)
+ case *map[int32]int32:
+ fastpathTV.EncMapInt32Int32V(*v, fastpathCheckNilTrue, e)
+
+ case map[int32]int64:
+ fastpathTV.EncMapInt32Int64V(v, fastpathCheckNilTrue, e)
+ case *map[int32]int64:
+ fastpathTV.EncMapInt32Int64V(*v, fastpathCheckNilTrue, e)
+
+ case map[int32]float32:
+ fastpathTV.EncMapInt32Float32V(v, fastpathCheckNilTrue, e)
+ case *map[int32]float32:
+ fastpathTV.EncMapInt32Float32V(*v, fastpathCheckNilTrue, e)
+
+ case map[int32]float64:
+ fastpathTV.EncMapInt32Float64V(v, fastpathCheckNilTrue, e)
+ case *map[int32]float64:
+ fastpathTV.EncMapInt32Float64V(*v, fastpathCheckNilTrue, e)
+
+ case map[int32]bool:
+ fastpathTV.EncMapInt32BoolV(v, fastpathCheckNilTrue, e)
+ case *map[int32]bool:
+ fastpathTV.EncMapInt32BoolV(*v, fastpathCheckNilTrue, e)
+
+ case map[int64]interface{}:
+ fastpathTV.EncMapInt64IntfV(v, fastpathCheckNilTrue, e)
+ case *map[int64]interface{}:
+ fastpathTV.EncMapInt64IntfV(*v, fastpathCheckNilTrue, e)
+
+ case map[int64]string:
+ fastpathTV.EncMapInt64StringV(v, fastpathCheckNilTrue, e)
+ case *map[int64]string:
+ fastpathTV.EncMapInt64StringV(*v, fastpathCheckNilTrue, e)
+
+ case map[int64]uint:
+ fastpathTV.EncMapInt64UintV(v, fastpathCheckNilTrue, e)
+ case *map[int64]uint:
+ fastpathTV.EncMapInt64UintV(*v, fastpathCheckNilTrue, e)
+
+ case map[int64]uint8:
+ fastpathTV.EncMapInt64Uint8V(v, fastpathCheckNilTrue, e)
+ case *map[int64]uint8:
+ fastpathTV.EncMapInt64Uint8V(*v, fastpathCheckNilTrue, e)
+
+ case map[int64]uint16:
+ fastpathTV.EncMapInt64Uint16V(v, fastpathCheckNilTrue, e)
+ case *map[int64]uint16:
+ fastpathTV.EncMapInt64Uint16V(*v, fastpathCheckNilTrue, e)
+
+ case map[int64]uint32:
+ fastpathTV.EncMapInt64Uint32V(v, fastpathCheckNilTrue, e)
+ case *map[int64]uint32:
+ fastpathTV.EncMapInt64Uint32V(*v, fastpathCheckNilTrue, e)
+
+ case map[int64]uint64:
+ fastpathTV.EncMapInt64Uint64V(v, fastpathCheckNilTrue, e)
+ case *map[int64]uint64:
+ fastpathTV.EncMapInt64Uint64V(*v, fastpathCheckNilTrue, e)
+
+ case map[int64]uintptr:
+ fastpathTV.EncMapInt64UintptrV(v, fastpathCheckNilTrue, e)
+ case *map[int64]uintptr:
+ fastpathTV.EncMapInt64UintptrV(*v, fastpathCheckNilTrue, e)
+
+ case map[int64]int:
+ fastpathTV.EncMapInt64IntV(v, fastpathCheckNilTrue, e)
+ case *map[int64]int:
+ fastpathTV.EncMapInt64IntV(*v, fastpathCheckNilTrue, e)
+
+ case map[int64]int8:
+ fastpathTV.EncMapInt64Int8V(v, fastpathCheckNilTrue, e)
+ case *map[int64]int8:
+ fastpathTV.EncMapInt64Int8V(*v, fastpathCheckNilTrue, e)
+
+ case map[int64]int16:
+ fastpathTV.EncMapInt64Int16V(v, fastpathCheckNilTrue, e)
+ case *map[int64]int16:
+ fastpathTV.EncMapInt64Int16V(*v, fastpathCheckNilTrue, e)
+
+ case map[int64]int32:
+ fastpathTV.EncMapInt64Int32V(v, fastpathCheckNilTrue, e)
+ case *map[int64]int32:
+ fastpathTV.EncMapInt64Int32V(*v, fastpathCheckNilTrue, e)
+
+ case map[int64]int64:
+ fastpathTV.EncMapInt64Int64V(v, fastpathCheckNilTrue, e)
+ case *map[int64]int64:
+ fastpathTV.EncMapInt64Int64V(*v, fastpathCheckNilTrue, e)
+
+ case map[int64]float32:
+ fastpathTV.EncMapInt64Float32V(v, fastpathCheckNilTrue, e)
+ case *map[int64]float32:
+ fastpathTV.EncMapInt64Float32V(*v, fastpathCheckNilTrue, e)
+
+ case map[int64]float64:
+ fastpathTV.EncMapInt64Float64V(v, fastpathCheckNilTrue, e)
+ case *map[int64]float64:
+ fastpathTV.EncMapInt64Float64V(*v, fastpathCheckNilTrue, e)
+
+ case map[int64]bool:
+ fastpathTV.EncMapInt64BoolV(v, fastpathCheckNilTrue, e)
+ case *map[int64]bool:
+ fastpathTV.EncMapInt64BoolV(*v, fastpathCheckNilTrue, e)
+
+ case map[bool]interface{}:
+ fastpathTV.EncMapBoolIntfV(v, fastpathCheckNilTrue, e)
+ case *map[bool]interface{}:
+ fastpathTV.EncMapBoolIntfV(*v, fastpathCheckNilTrue, e)
+
+ case map[bool]string:
+ fastpathTV.EncMapBoolStringV(v, fastpathCheckNilTrue, e)
+ case *map[bool]string:
+ fastpathTV.EncMapBoolStringV(*v, fastpathCheckNilTrue, e)
+
+ case map[bool]uint:
+ fastpathTV.EncMapBoolUintV(v, fastpathCheckNilTrue, e)
+ case *map[bool]uint:
+ fastpathTV.EncMapBoolUintV(*v, fastpathCheckNilTrue, e)
+
+ case map[bool]uint8:
+ fastpathTV.EncMapBoolUint8V(v, fastpathCheckNilTrue, e)
+ case *map[bool]uint8:
+ fastpathTV.EncMapBoolUint8V(*v, fastpathCheckNilTrue, e)
+
+ case map[bool]uint16:
+ fastpathTV.EncMapBoolUint16V(v, fastpathCheckNilTrue, e)
+ case *map[bool]uint16:
+ fastpathTV.EncMapBoolUint16V(*v, fastpathCheckNilTrue, e)
+
+ case map[bool]uint32:
+ fastpathTV.EncMapBoolUint32V(v, fastpathCheckNilTrue, e)
+ case *map[bool]uint32:
+ fastpathTV.EncMapBoolUint32V(*v, fastpathCheckNilTrue, e)
+
+ case map[bool]uint64:
+ fastpathTV.EncMapBoolUint64V(v, fastpathCheckNilTrue, e)
+ case *map[bool]uint64:
+ fastpathTV.EncMapBoolUint64V(*v, fastpathCheckNilTrue, e)
+
+ case map[bool]uintptr:
+ fastpathTV.EncMapBoolUintptrV(v, fastpathCheckNilTrue, e)
+ case *map[bool]uintptr:
+ fastpathTV.EncMapBoolUintptrV(*v, fastpathCheckNilTrue, e)
+
+ case map[bool]int:
+ fastpathTV.EncMapBoolIntV(v, fastpathCheckNilTrue, e)
+ case *map[bool]int:
+ fastpathTV.EncMapBoolIntV(*v, fastpathCheckNilTrue, e)
+
+ case map[bool]int8:
+ fastpathTV.EncMapBoolInt8V(v, fastpathCheckNilTrue, e)
+ case *map[bool]int8:
+ fastpathTV.EncMapBoolInt8V(*v, fastpathCheckNilTrue, e)
+
+ case map[bool]int16:
+ fastpathTV.EncMapBoolInt16V(v, fastpathCheckNilTrue, e)
+ case *map[bool]int16:
+ fastpathTV.EncMapBoolInt16V(*v, fastpathCheckNilTrue, e)
+
+ case map[bool]int32:
+ fastpathTV.EncMapBoolInt32V(v, fastpathCheckNilTrue, e)
+ case *map[bool]int32:
+ fastpathTV.EncMapBoolInt32V(*v, fastpathCheckNilTrue, e)
+
+ case map[bool]int64:
+ fastpathTV.EncMapBoolInt64V(v, fastpathCheckNilTrue, e)
+ case *map[bool]int64:
+ fastpathTV.EncMapBoolInt64V(*v, fastpathCheckNilTrue, e)
+
+ case map[bool]float32:
+ fastpathTV.EncMapBoolFloat32V(v, fastpathCheckNilTrue, e)
+ case *map[bool]float32:
+ fastpathTV.EncMapBoolFloat32V(*v, fastpathCheckNilTrue, e)
+
+ case map[bool]float64:
+ fastpathTV.EncMapBoolFloat64V(v, fastpathCheckNilTrue, e)
+ case *map[bool]float64:
+ fastpathTV.EncMapBoolFloat64V(*v, fastpathCheckNilTrue, e)
+
+ case map[bool]bool:
+ fastpathTV.EncMapBoolBoolV(v, fastpathCheckNilTrue, e)
+ case *map[bool]bool:
+ fastpathTV.EncMapBoolBoolV(*v, fastpathCheckNilTrue, e)
+
+ default:
+ _ = v // TODO: workaround https://github.com/golang/go/issues/12927 (remove after go 1.6 release)
return false
}
return true
@@ -1465,6122 +3113,6220 @@ func fastpathEncodeTypeSwitch(iv interface{}, e *Encoder) bool {
// -- -- fast path functions
-func (e *Encoder) fastpathEncSliceIntfR(f *codecFnInfo, rv reflect.Value) {
+func (f *encFnInfo) fastpathEncSliceIntfR(rv reflect.Value) {
if f.ti.mbs {
- fastpathTV.EncAsMapSliceIntfV(rv2i(rv).([]interface{}), e)
+ fastpathTV.EncAsMapSliceIntfV(rv.Interface().([]interface{}), fastpathCheckNilFalse, f.e)
} else {
- fastpathTV.EncSliceIntfV(rv2i(rv).([]interface{}), e)
+ fastpathTV.EncSliceIntfV(rv.Interface().([]interface{}), fastpathCheckNilFalse, f.e)
}
}
-func (_ fastpathT) EncSliceIntfV(v []interface{}, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncSliceIntfV(v []interface{}, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteArrayStart(len(v))
- if esep {
- for _, v2 := range v {
- ee.WriteArrayElem()
- e.encode(v2)
- }
- } else {
- for _, v2 := range v {
- e.encode(v2)
+ ee.EncodeArrayStart(len(v))
+ for _, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerArrayElem)
}
+ e.encode(v2)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerArrayEnd)
}
- ee.WriteArrayEnd()
}
-func (_ fastpathT) EncAsMapSliceIntfV(v []interface{}, e *Encoder) {
- ee, esep := e.e, e.hh.hasElemSeparators()
+
+func (_ fastpathT) EncAsMapSliceIntfV(v []interface{}, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
if len(v)%2 == 1 {
e.errorf("mapBySlice requires even slice length, but got %v", len(v))
return
}
- ee.WriteMapStart(len(v) / 2)
- if esep {
- for j, v2 := range v {
+ ee.EncodeMapStart(len(v) / 2)
+ for j, v2 := range v {
+ if cr != nil {
if j%2 == 0 {
- ee.WriteMapElemKey()
+ cr.sendContainerState(containerMapKey)
} else {
- ee.WriteMapElemValue()
+ cr.sendContainerState(containerMapValue)
}
- e.encode(v2)
- }
- } else {
- for _, v2 := range v {
- e.encode(v2)
}
+ e.encode(v2)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
- ee.WriteMapEnd()
}
-func (e *Encoder) fastpathEncSliceStringR(f *codecFnInfo, rv reflect.Value) {
+func (f *encFnInfo) fastpathEncSliceStringR(rv reflect.Value) {
if f.ti.mbs {
- fastpathTV.EncAsMapSliceStringV(rv2i(rv).([]string), e)
+ fastpathTV.EncAsMapSliceStringV(rv.Interface().([]string), fastpathCheckNilFalse, f.e)
} else {
- fastpathTV.EncSliceStringV(rv2i(rv).([]string), e)
+ fastpathTV.EncSliceStringV(rv.Interface().([]string), fastpathCheckNilFalse, f.e)
}
}
-func (_ fastpathT) EncSliceStringV(v []string, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncSliceStringV(v []string, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteArrayStart(len(v))
- if esep {
- for _, v2 := range v {
- ee.WriteArrayElem()
- ee.EncodeString(cUTF8, v2)
- }
- } else {
- for _, v2 := range v {
- ee.EncodeString(cUTF8, v2)
+ ee.EncodeArrayStart(len(v))
+ for _, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerArrayElem)
}
+ ee.EncodeString(c_UTF8, v2)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerArrayEnd)
}
- ee.WriteArrayEnd()
}
-func (_ fastpathT) EncAsMapSliceStringV(v []string, e *Encoder) {
- ee, esep := e.e, e.hh.hasElemSeparators()
+
+func (_ fastpathT) EncAsMapSliceStringV(v []string, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
if len(v)%2 == 1 {
e.errorf("mapBySlice requires even slice length, but got %v", len(v))
return
}
- ee.WriteMapStart(len(v) / 2)
- if esep {
- for j, v2 := range v {
+ ee.EncodeMapStart(len(v) / 2)
+ for j, v2 := range v {
+ if cr != nil {
if j%2 == 0 {
- ee.WriteMapElemKey()
+ cr.sendContainerState(containerMapKey)
} else {
- ee.WriteMapElemValue()
+ cr.sendContainerState(containerMapValue)
}
- ee.EncodeString(cUTF8, v2)
- }
- } else {
- for _, v2 := range v {
- ee.EncodeString(cUTF8, v2)
}
+ ee.EncodeString(c_UTF8, v2)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
- ee.WriteMapEnd()
}
-func (e *Encoder) fastpathEncSliceFloat32R(f *codecFnInfo, rv reflect.Value) {
+func (f *encFnInfo) fastpathEncSliceFloat32R(rv reflect.Value) {
if f.ti.mbs {
- fastpathTV.EncAsMapSliceFloat32V(rv2i(rv).([]float32), e)
+ fastpathTV.EncAsMapSliceFloat32V(rv.Interface().([]float32), fastpathCheckNilFalse, f.e)
} else {
- fastpathTV.EncSliceFloat32V(rv2i(rv).([]float32), e)
+ fastpathTV.EncSliceFloat32V(rv.Interface().([]float32), fastpathCheckNilFalse, f.e)
}
}
-func (_ fastpathT) EncSliceFloat32V(v []float32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncSliceFloat32V(v []float32, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteArrayStart(len(v))
- if esep {
- for _, v2 := range v {
- ee.WriteArrayElem()
- ee.EncodeFloat32(v2)
+ ee.EncodeArrayStart(len(v))
+ for _, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerArrayElem)
+ }
+ ee.EncodeFloat32(v2)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerArrayEnd)
+ }
+}
+
+func (_ fastpathT) EncAsMapSliceFloat32V(v []float32, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ if len(v)%2 == 1 {
+ e.errorf("mapBySlice requires even slice length, but got %v", len(v))
+ return
+ }
+ ee.EncodeMapStart(len(v) / 2)
+ for j, v2 := range v {
+ if cr != nil {
+ if j%2 == 0 {
+ cr.sendContainerState(containerMapKey)
+ } else {
+ cr.sendContainerState(containerMapValue)
+ }
+ }
+ ee.EncodeFloat32(v2)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncSliceFloat64R(rv reflect.Value) {
+ if f.ti.mbs {
+ fastpathTV.EncAsMapSliceFloat64V(rv.Interface().([]float64), fastpathCheckNilFalse, f.e)
+ } else {
+ fastpathTV.EncSliceFloat64V(rv.Interface().([]float64), fastpathCheckNilFalse, f.e)
+ }
+}
+func (_ fastpathT) EncSliceFloat64V(v []float64, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeArrayStart(len(v))
+ for _, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerArrayElem)
+ }
+ ee.EncodeFloat64(v2)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerArrayEnd)
+ }
+}
+
+func (_ fastpathT) EncAsMapSliceFloat64V(v []float64, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ if len(v)%2 == 1 {
+ e.errorf("mapBySlice requires even slice length, but got %v", len(v))
+ return
+ }
+ ee.EncodeMapStart(len(v) / 2)
+ for j, v2 := range v {
+ if cr != nil {
+ if j%2 == 0 {
+ cr.sendContainerState(containerMapKey)
+ } else {
+ cr.sendContainerState(containerMapValue)
+ }
+ }
+ ee.EncodeFloat64(v2)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncSliceUintR(rv reflect.Value) {
+ if f.ti.mbs {
+ fastpathTV.EncAsMapSliceUintV(rv.Interface().([]uint), fastpathCheckNilFalse, f.e)
+ } else {
+ fastpathTV.EncSliceUintV(rv.Interface().([]uint), fastpathCheckNilFalse, f.e)
+ }
+}
+func (_ fastpathT) EncSliceUintV(v []uint, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeArrayStart(len(v))
+ for _, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerArrayElem)
+ }
+ ee.EncodeUint(uint64(v2))
+ }
+ if cr != nil {
+ cr.sendContainerState(containerArrayEnd)
+ }
+}
+
+func (_ fastpathT) EncAsMapSliceUintV(v []uint, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ if len(v)%2 == 1 {
+ e.errorf("mapBySlice requires even slice length, but got %v", len(v))
+ return
+ }
+ ee.EncodeMapStart(len(v) / 2)
+ for j, v2 := range v {
+ if cr != nil {
+ if j%2 == 0 {
+ cr.sendContainerState(containerMapKey)
+ } else {
+ cr.sendContainerState(containerMapValue)
+ }
+ }
+ ee.EncodeUint(uint64(v2))
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncSliceUint16R(rv reflect.Value) {
+ if f.ti.mbs {
+ fastpathTV.EncAsMapSliceUint16V(rv.Interface().([]uint16), fastpathCheckNilFalse, f.e)
+ } else {
+ fastpathTV.EncSliceUint16V(rv.Interface().([]uint16), fastpathCheckNilFalse, f.e)
+ }
+}
+func (_ fastpathT) EncSliceUint16V(v []uint16, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeArrayStart(len(v))
+ for _, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerArrayElem)
+ }
+ ee.EncodeUint(uint64(v2))
+ }
+ if cr != nil {
+ cr.sendContainerState(containerArrayEnd)
+ }
+}
+
+func (_ fastpathT) EncAsMapSliceUint16V(v []uint16, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ if len(v)%2 == 1 {
+ e.errorf("mapBySlice requires even slice length, but got %v", len(v))
+ return
+ }
+ ee.EncodeMapStart(len(v) / 2)
+ for j, v2 := range v {
+ if cr != nil {
+ if j%2 == 0 {
+ cr.sendContainerState(containerMapKey)
+ } else {
+ cr.sendContainerState(containerMapValue)
+ }
+ }
+ ee.EncodeUint(uint64(v2))
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncSliceUint32R(rv reflect.Value) {
+ if f.ti.mbs {
+ fastpathTV.EncAsMapSliceUint32V(rv.Interface().([]uint32), fastpathCheckNilFalse, f.e)
+ } else {
+ fastpathTV.EncSliceUint32V(rv.Interface().([]uint32), fastpathCheckNilFalse, f.e)
+ }
+}
+func (_ fastpathT) EncSliceUint32V(v []uint32, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeArrayStart(len(v))
+ for _, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerArrayElem)
+ }
+ ee.EncodeUint(uint64(v2))
+ }
+ if cr != nil {
+ cr.sendContainerState(containerArrayEnd)
+ }
+}
+
+func (_ fastpathT) EncAsMapSliceUint32V(v []uint32, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ if len(v)%2 == 1 {
+ e.errorf("mapBySlice requires even slice length, but got %v", len(v))
+ return
+ }
+ ee.EncodeMapStart(len(v) / 2)
+ for j, v2 := range v {
+ if cr != nil {
+ if j%2 == 0 {
+ cr.sendContainerState(containerMapKey)
+ } else {
+ cr.sendContainerState(containerMapValue)
+ }
+ }
+ ee.EncodeUint(uint64(v2))
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncSliceUint64R(rv reflect.Value) {
+ if f.ti.mbs {
+ fastpathTV.EncAsMapSliceUint64V(rv.Interface().([]uint64), fastpathCheckNilFalse, f.e)
+ } else {
+ fastpathTV.EncSliceUint64V(rv.Interface().([]uint64), fastpathCheckNilFalse, f.e)
+ }
+}
+func (_ fastpathT) EncSliceUint64V(v []uint64, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeArrayStart(len(v))
+ for _, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerArrayElem)
+ }
+ ee.EncodeUint(uint64(v2))
+ }
+ if cr != nil {
+ cr.sendContainerState(containerArrayEnd)
+ }
+}
+
+func (_ fastpathT) EncAsMapSliceUint64V(v []uint64, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ if len(v)%2 == 1 {
+ e.errorf("mapBySlice requires even slice length, but got %v", len(v))
+ return
+ }
+ ee.EncodeMapStart(len(v) / 2)
+ for j, v2 := range v {
+ if cr != nil {
+ if j%2 == 0 {
+ cr.sendContainerState(containerMapKey)
+ } else {
+ cr.sendContainerState(containerMapValue)
+ }
+ }
+ ee.EncodeUint(uint64(v2))
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncSliceUintptrR(rv reflect.Value) {
+ if f.ti.mbs {
+ fastpathTV.EncAsMapSliceUintptrV(rv.Interface().([]uintptr), fastpathCheckNilFalse, f.e)
+ } else {
+ fastpathTV.EncSliceUintptrV(rv.Interface().([]uintptr), fastpathCheckNilFalse, f.e)
+ }
+}
+func (_ fastpathT) EncSliceUintptrV(v []uintptr, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeArrayStart(len(v))
+ for _, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerArrayElem)
+ }
+ e.encode(v2)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerArrayEnd)
+ }
+}
+
+func (_ fastpathT) EncAsMapSliceUintptrV(v []uintptr, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ if len(v)%2 == 1 {
+ e.errorf("mapBySlice requires even slice length, but got %v", len(v))
+ return
+ }
+ ee.EncodeMapStart(len(v) / 2)
+ for j, v2 := range v {
+ if cr != nil {
+ if j%2 == 0 {
+ cr.sendContainerState(containerMapKey)
+ } else {
+ cr.sendContainerState(containerMapValue)
+ }
+ }
+ e.encode(v2)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncSliceIntR(rv reflect.Value) {
+ if f.ti.mbs {
+ fastpathTV.EncAsMapSliceIntV(rv.Interface().([]int), fastpathCheckNilFalse, f.e)
+ } else {
+ fastpathTV.EncSliceIntV(rv.Interface().([]int), fastpathCheckNilFalse, f.e)
+ }
+}
+func (_ fastpathT) EncSliceIntV(v []int, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeArrayStart(len(v))
+ for _, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerArrayElem)
+ }
+ ee.EncodeInt(int64(v2))
+ }
+ if cr != nil {
+ cr.sendContainerState(containerArrayEnd)
+ }
+}
+
+func (_ fastpathT) EncAsMapSliceIntV(v []int, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ if len(v)%2 == 1 {
+ e.errorf("mapBySlice requires even slice length, but got %v", len(v))
+ return
+ }
+ ee.EncodeMapStart(len(v) / 2)
+ for j, v2 := range v {
+ if cr != nil {
+ if j%2 == 0 {
+ cr.sendContainerState(containerMapKey)
+ } else {
+ cr.sendContainerState(containerMapValue)
+ }
+ }
+ ee.EncodeInt(int64(v2))
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncSliceInt8R(rv reflect.Value) {
+ if f.ti.mbs {
+ fastpathTV.EncAsMapSliceInt8V(rv.Interface().([]int8), fastpathCheckNilFalse, f.e)
+ } else {
+ fastpathTV.EncSliceInt8V(rv.Interface().([]int8), fastpathCheckNilFalse, f.e)
+ }
+}
+func (_ fastpathT) EncSliceInt8V(v []int8, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeArrayStart(len(v))
+ for _, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerArrayElem)
+ }
+ ee.EncodeInt(int64(v2))
+ }
+ if cr != nil {
+ cr.sendContainerState(containerArrayEnd)
+ }
+}
+
+func (_ fastpathT) EncAsMapSliceInt8V(v []int8, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ if len(v)%2 == 1 {
+ e.errorf("mapBySlice requires even slice length, but got %v", len(v))
+ return
+ }
+ ee.EncodeMapStart(len(v) / 2)
+ for j, v2 := range v {
+ if cr != nil {
+ if j%2 == 0 {
+ cr.sendContainerState(containerMapKey)
+ } else {
+ cr.sendContainerState(containerMapValue)
+ }
+ }
+ ee.EncodeInt(int64(v2))
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncSliceInt16R(rv reflect.Value) {
+ if f.ti.mbs {
+ fastpathTV.EncAsMapSliceInt16V(rv.Interface().([]int16), fastpathCheckNilFalse, f.e)
+ } else {
+ fastpathTV.EncSliceInt16V(rv.Interface().([]int16), fastpathCheckNilFalse, f.e)
+ }
+}
+func (_ fastpathT) EncSliceInt16V(v []int16, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeArrayStart(len(v))
+ for _, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerArrayElem)
+ }
+ ee.EncodeInt(int64(v2))
+ }
+ if cr != nil {
+ cr.sendContainerState(containerArrayEnd)
+ }
+}
+
+func (_ fastpathT) EncAsMapSliceInt16V(v []int16, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ if len(v)%2 == 1 {
+ e.errorf("mapBySlice requires even slice length, but got %v", len(v))
+ return
+ }
+ ee.EncodeMapStart(len(v) / 2)
+ for j, v2 := range v {
+ if cr != nil {
+ if j%2 == 0 {
+ cr.sendContainerState(containerMapKey)
+ } else {
+ cr.sendContainerState(containerMapValue)
+ }
+ }
+ ee.EncodeInt(int64(v2))
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncSliceInt32R(rv reflect.Value) {
+ if f.ti.mbs {
+ fastpathTV.EncAsMapSliceInt32V(rv.Interface().([]int32), fastpathCheckNilFalse, f.e)
+ } else {
+ fastpathTV.EncSliceInt32V(rv.Interface().([]int32), fastpathCheckNilFalse, f.e)
+ }
+}
+func (_ fastpathT) EncSliceInt32V(v []int32, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeArrayStart(len(v))
+ for _, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerArrayElem)
+ }
+ ee.EncodeInt(int64(v2))
+ }
+ if cr != nil {
+ cr.sendContainerState(containerArrayEnd)
+ }
+}
+
+func (_ fastpathT) EncAsMapSliceInt32V(v []int32, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ if len(v)%2 == 1 {
+ e.errorf("mapBySlice requires even slice length, but got %v", len(v))
+ return
+ }
+ ee.EncodeMapStart(len(v) / 2)
+ for j, v2 := range v {
+ if cr != nil {
+ if j%2 == 0 {
+ cr.sendContainerState(containerMapKey)
+ } else {
+ cr.sendContainerState(containerMapValue)
+ }
+ }
+ ee.EncodeInt(int64(v2))
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncSliceInt64R(rv reflect.Value) {
+ if f.ti.mbs {
+ fastpathTV.EncAsMapSliceInt64V(rv.Interface().([]int64), fastpathCheckNilFalse, f.e)
+ } else {
+ fastpathTV.EncSliceInt64V(rv.Interface().([]int64), fastpathCheckNilFalse, f.e)
+ }
+}
+func (_ fastpathT) EncSliceInt64V(v []int64, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeArrayStart(len(v))
+ for _, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerArrayElem)
+ }
+ ee.EncodeInt(int64(v2))
+ }
+ if cr != nil {
+ cr.sendContainerState(containerArrayEnd)
+ }
+}
+
+func (_ fastpathT) EncAsMapSliceInt64V(v []int64, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ if len(v)%2 == 1 {
+ e.errorf("mapBySlice requires even slice length, but got %v", len(v))
+ return
+ }
+ ee.EncodeMapStart(len(v) / 2)
+ for j, v2 := range v {
+ if cr != nil {
+ if j%2 == 0 {
+ cr.sendContainerState(containerMapKey)
+ } else {
+ cr.sendContainerState(containerMapValue)
+ }
+ }
+ ee.EncodeInt(int64(v2))
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncSliceBoolR(rv reflect.Value) {
+ if f.ti.mbs {
+ fastpathTV.EncAsMapSliceBoolV(rv.Interface().([]bool), fastpathCheckNilFalse, f.e)
+ } else {
+ fastpathTV.EncSliceBoolV(rv.Interface().([]bool), fastpathCheckNilFalse, f.e)
+ }
+}
+func (_ fastpathT) EncSliceBoolV(v []bool, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeArrayStart(len(v))
+ for _, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerArrayElem)
+ }
+ ee.EncodeBool(v2)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerArrayEnd)
+ }
+}
+
+func (_ fastpathT) EncAsMapSliceBoolV(v []bool, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ if len(v)%2 == 1 {
+ e.errorf("mapBySlice requires even slice length, but got %v", len(v))
+ return
+ }
+ ee.EncodeMapStart(len(v) / 2)
+ for j, v2 := range v {
+ if cr != nil {
+ if j%2 == 0 {
+ cr.sendContainerState(containerMapKey)
+ } else {
+ cr.sendContainerState(containerMapValue)
+ }
+ }
+ ee.EncodeBool(v2)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapIntfIntfR(rv reflect.Value) {
+ fastpathTV.EncMapIntfIntfV(rv.Interface().(map[interface{}]interface{}), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapIntfIntfV(v map[interface{}]interface{}, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(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 int
+ var vp *bytesI
+ for k2, _ := range v {
+ l = len(mksv)
+ e2.MustEncode(k2)
+ vp = &v2[i]
+ vp.v = mksv[l:]
+ vp.i = k2
+ i++
+ }
+ sort.Sort(bytesISlice(v2))
+ for j := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.asis(v2[j].v)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[v2[j].i])
}
} else {
- for _, v2 := range v {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.encode(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v2)
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapIntfStringR(rv reflect.Value) {
+ fastpathTV.EncMapIntfStringV(rv.Interface().(map[interface{}]string), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapIntfStringV(v map[interface{}]string, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(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 int
+ var vp *bytesI
+ for k2, _ := range v {
+ l = len(mksv)
+ e2.MustEncode(k2)
+ vp = &v2[i]
+ vp.v = mksv[l:]
+ vp.i = k2
+ i++
+ }
+ sort.Sort(bytesISlice(v2))
+ for j := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.asis(v2[j].v)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[v2[j].i])
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.encode(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeString(c_UTF8, v2)
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapIntfUintR(rv reflect.Value) {
+ fastpathTV.EncMapIntfUintV(rv.Interface().(map[interface{}]uint), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapIntfUintV(v map[interface{}]uint, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(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 int
+ var vp *bytesI
+ for k2, _ := range v {
+ l = len(mksv)
+ e2.MustEncode(k2)
+ vp = &v2[i]
+ vp.v = mksv[l:]
+ vp.i = k2
+ i++
+ }
+ sort.Sort(bytesISlice(v2))
+ for j := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.asis(v2[j].v)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[v2[j].i])
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.encode(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapIntfUint8R(rv reflect.Value) {
+ fastpathTV.EncMapIntfUint8V(rv.Interface().(map[interface{}]uint8), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapIntfUint8V(v map[interface{}]uint8, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(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 int
+ var vp *bytesI
+ for k2, _ := range v {
+ l = len(mksv)
+ e2.MustEncode(k2)
+ vp = &v2[i]
+ vp.v = mksv[l:]
+ vp.i = k2
+ i++
+ }
+ sort.Sort(bytesISlice(v2))
+ for j := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.asis(v2[j].v)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[v2[j].i])
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.encode(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapIntfUint16R(rv reflect.Value) {
+ fastpathTV.EncMapIntfUint16V(rv.Interface().(map[interface{}]uint16), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapIntfUint16V(v map[interface{}]uint16, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(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 int
+ var vp *bytesI
+ for k2, _ := range v {
+ l = len(mksv)
+ e2.MustEncode(k2)
+ vp = &v2[i]
+ vp.v = mksv[l:]
+ vp.i = k2
+ i++
+ }
+ sort.Sort(bytesISlice(v2))
+ for j := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.asis(v2[j].v)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[v2[j].i])
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.encode(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapIntfUint32R(rv reflect.Value) {
+ fastpathTV.EncMapIntfUint32V(rv.Interface().(map[interface{}]uint32), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapIntfUint32V(v map[interface{}]uint32, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(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 int
+ var vp *bytesI
+ for k2, _ := range v {
+ l = len(mksv)
+ e2.MustEncode(k2)
+ vp = &v2[i]
+ vp.v = mksv[l:]
+ vp.i = k2
+ i++
+ }
+ sort.Sort(bytesISlice(v2))
+ for j := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.asis(v2[j].v)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[v2[j].i])
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.encode(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapIntfUint64R(rv reflect.Value) {
+ fastpathTV.EncMapIntfUint64V(rv.Interface().(map[interface{}]uint64), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapIntfUint64V(v map[interface{}]uint64, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(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 int
+ var vp *bytesI
+ for k2, _ := range v {
+ l = len(mksv)
+ e2.MustEncode(k2)
+ vp = &v2[i]
+ vp.v = mksv[l:]
+ vp.i = k2
+ i++
+ }
+ sort.Sort(bytesISlice(v2))
+ for j := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.asis(v2[j].v)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[v2[j].i])
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.encode(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapIntfUintptrR(rv reflect.Value) {
+ fastpathTV.EncMapIntfUintptrV(rv.Interface().(map[interface{}]uintptr), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapIntfUintptrV(v map[interface{}]uintptr, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(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 int
+ var vp *bytesI
+ for k2, _ := range v {
+ l = len(mksv)
+ e2.MustEncode(k2)
+ vp = &v2[i]
+ vp.v = mksv[l:]
+ vp.i = k2
+ i++
+ }
+ sort.Sort(bytesISlice(v2))
+ for j := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.asis(v2[j].v)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[v2[j].i])
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.encode(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v2)
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapIntfIntR(rv reflect.Value) {
+ fastpathTV.EncMapIntfIntV(rv.Interface().(map[interface{}]int), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapIntfIntV(v map[interface{}]int, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(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 int
+ var vp *bytesI
+ for k2, _ := range v {
+ l = len(mksv)
+ e2.MustEncode(k2)
+ vp = &v2[i]
+ vp.v = mksv[l:]
+ vp.i = k2
+ i++
+ }
+ sort.Sort(bytesISlice(v2))
+ for j := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.asis(v2[j].v)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[v2[j].i])
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.encode(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapIntfInt8R(rv reflect.Value) {
+ fastpathTV.EncMapIntfInt8V(rv.Interface().(map[interface{}]int8), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapIntfInt8V(v map[interface{}]int8, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(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 int
+ var vp *bytesI
+ for k2, _ := range v {
+ l = len(mksv)
+ e2.MustEncode(k2)
+ vp = &v2[i]
+ vp.v = mksv[l:]
+ vp.i = k2
+ i++
+ }
+ sort.Sort(bytesISlice(v2))
+ for j := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.asis(v2[j].v)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[v2[j].i])
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.encode(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapIntfInt16R(rv reflect.Value) {
+ fastpathTV.EncMapIntfInt16V(rv.Interface().(map[interface{}]int16), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapIntfInt16V(v map[interface{}]int16, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(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 int
+ var vp *bytesI
+ for k2, _ := range v {
+ l = len(mksv)
+ e2.MustEncode(k2)
+ vp = &v2[i]
+ vp.v = mksv[l:]
+ vp.i = k2
+ i++
+ }
+ sort.Sort(bytesISlice(v2))
+ for j := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.asis(v2[j].v)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[v2[j].i])
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.encode(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapIntfInt32R(rv reflect.Value) {
+ fastpathTV.EncMapIntfInt32V(rv.Interface().(map[interface{}]int32), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapIntfInt32V(v map[interface{}]int32, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(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 int
+ var vp *bytesI
+ for k2, _ := range v {
+ l = len(mksv)
+ e2.MustEncode(k2)
+ vp = &v2[i]
+ vp.v = mksv[l:]
+ vp.i = k2
+ i++
+ }
+ sort.Sort(bytesISlice(v2))
+ for j := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.asis(v2[j].v)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[v2[j].i])
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.encode(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapIntfInt64R(rv reflect.Value) {
+ fastpathTV.EncMapIntfInt64V(rv.Interface().(map[interface{}]int64), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapIntfInt64V(v map[interface{}]int64, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(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 int
+ var vp *bytesI
+ for k2, _ := range v {
+ l = len(mksv)
+ e2.MustEncode(k2)
+ vp = &v2[i]
+ vp.v = mksv[l:]
+ vp.i = k2
+ i++
+ }
+ sort.Sort(bytesISlice(v2))
+ for j := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.asis(v2[j].v)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[v2[j].i])
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.encode(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapIntfFloat32R(rv reflect.Value) {
+ fastpathTV.EncMapIntfFloat32V(rv.Interface().(map[interface{}]float32), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapIntfFloat32V(v map[interface{}]float32, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(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 int
+ var vp *bytesI
+ for k2, _ := range v {
+ l = len(mksv)
+ e2.MustEncode(k2)
+ vp = &v2[i]
+ vp.v = mksv[l:]
+ vp.i = k2
+ i++
+ }
+ sort.Sort(bytesISlice(v2))
+ for j := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.asis(v2[j].v)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[v2[j].i])
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.encode(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeFloat32(v2)
}
}
- ee.WriteArrayEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (_ fastpathT) EncAsMapSliceFloat32V(v []float32, e *Encoder) {
- ee, esep := e.e, e.hh.hasElemSeparators()
- if len(v)%2 == 1 {
- e.errorf("mapBySlice requires even slice length, but got %v", len(v))
+
+func (f *encFnInfo) fastpathEncMapIntfFloat64R(rv reflect.Value) {
+ fastpathTV.EncMapIntfFloat64V(rv.Interface().(map[interface{}]float64), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapIntfFloat64V(v map[interface{}]float64, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee.WriteMapStart(len(v) / 2)
- if esep {
- for j, v2 := range v {
- if j%2 == 0 {
- ee.WriteMapElemKey()
+ ee.EncodeMapStart(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 int
+ var vp *bytesI
+ for k2, _ := range v {
+ l = len(mksv)
+ e2.MustEncode(k2)
+ vp = &v2[i]
+ vp.v = mksv[l:]
+ vp.i = k2
+ i++
+ }
+ sort.Sort(bytesISlice(v2))
+ for j := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.asis(v2[j].v)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[v2[j].i])
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.encode(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeFloat64(v2)
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapIntfBoolR(rv reflect.Value) {
+ fastpathTV.EncMapIntfBoolV(rv.Interface().(map[interface{}]bool), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapIntfBoolV(v map[interface{}]bool, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(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 int
+ var vp *bytesI
+ for k2, _ := range v {
+ l = len(mksv)
+ e2.MustEncode(k2)
+ vp = &v2[i]
+ vp.v = mksv[l:]
+ vp.i = k2
+ i++
+ }
+ sort.Sort(bytesISlice(v2))
+ for j := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.asis(v2[j].v)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[v2[j].i])
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ e.encode(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeBool(v2)
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapStringIntfR(rv reflect.Value) {
+ fastpathTV.EncMapStringIntfV(rv.Interface().(map[string]interface{}), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapStringIntfV(v map[string]interface{}, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0
+ if e.h.Canonical {
+ v2 := make([]string, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = string(k)
+ i++
+ }
+ sort.Sort(stringSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ if asSymbols {
+ ee.EncodeSymbol(k2)
} else {
- ee.WriteMapElemValue()
+ ee.EncodeString(c_UTF8, k2)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[string(k2)])
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ if asSymbols {
+ ee.EncodeSymbol(k2)
+ } else {
+ ee.EncodeString(c_UTF8, k2)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v2)
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapStringStringR(rv reflect.Value) {
+ fastpathTV.EncMapStringStringV(rv.Interface().(map[string]string), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapStringStringV(v map[string]string, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0
+ if e.h.Canonical {
+ v2 := make([]string, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = string(k)
+ i++
+ }
+ sort.Sort(stringSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ if asSymbols {
+ ee.EncodeSymbol(k2)
+ } else {
+ ee.EncodeString(c_UTF8, k2)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeString(c_UTF8, v[string(k2)])
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ if asSymbols {
+ ee.EncodeSymbol(k2)
+ } else {
+ ee.EncodeString(c_UTF8, k2)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeString(c_UTF8, v2)
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapStringUintR(rv reflect.Value) {
+ fastpathTV.EncMapStringUintV(rv.Interface().(map[string]uint), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapStringUintV(v map[string]uint, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0
+ if e.h.Canonical {
+ v2 := make([]string, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = string(k)
+ i++
+ }
+ sort.Sort(stringSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ if asSymbols {
+ ee.EncodeSymbol(k2)
+ } else {
+ ee.EncodeString(c_UTF8, k2)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[string(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ if asSymbols {
+ ee.EncodeSymbol(k2)
+ } else {
+ ee.EncodeString(c_UTF8, k2)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapStringUint8R(rv reflect.Value) {
+ fastpathTV.EncMapStringUint8V(rv.Interface().(map[string]uint8), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapStringUint8V(v map[string]uint8, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0
+ if e.h.Canonical {
+ v2 := make([]string, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = string(k)
+ i++
+ }
+ sort.Sort(stringSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ if asSymbols {
+ ee.EncodeSymbol(k2)
+ } else {
+ ee.EncodeString(c_UTF8, k2)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[string(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ if asSymbols {
+ ee.EncodeSymbol(k2)
+ } else {
+ ee.EncodeString(c_UTF8, k2)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapStringUint16R(rv reflect.Value) {
+ fastpathTV.EncMapStringUint16V(rv.Interface().(map[string]uint16), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapStringUint16V(v map[string]uint16, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0
+ if e.h.Canonical {
+ v2 := make([]string, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = string(k)
+ i++
+ }
+ sort.Sort(stringSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ if asSymbols {
+ ee.EncodeSymbol(k2)
+ } else {
+ ee.EncodeString(c_UTF8, k2)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[string(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ if asSymbols {
+ ee.EncodeSymbol(k2)
+ } else {
+ ee.EncodeString(c_UTF8, k2)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapStringUint32R(rv reflect.Value) {
+ fastpathTV.EncMapStringUint32V(rv.Interface().(map[string]uint32), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapStringUint32V(v map[string]uint32, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0
+ if e.h.Canonical {
+ v2 := make([]string, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = string(k)
+ i++
+ }
+ sort.Sort(stringSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ if asSymbols {
+ ee.EncodeSymbol(k2)
+ } else {
+ ee.EncodeString(c_UTF8, k2)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[string(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ if asSymbols {
+ ee.EncodeSymbol(k2)
+ } else {
+ ee.EncodeString(c_UTF8, k2)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapStringUint64R(rv reflect.Value) {
+ fastpathTV.EncMapStringUint64V(rv.Interface().(map[string]uint64), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapStringUint64V(v map[string]uint64, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0
+ if e.h.Canonical {
+ v2 := make([]string, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = string(k)
+ i++
+ }
+ sort.Sort(stringSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ if asSymbols {
+ ee.EncodeSymbol(k2)
+ } else {
+ ee.EncodeString(c_UTF8, k2)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[string(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ if asSymbols {
+ ee.EncodeSymbol(k2)
+ } else {
+ ee.EncodeString(c_UTF8, k2)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapStringUintptrR(rv reflect.Value) {
+ fastpathTV.EncMapStringUintptrV(rv.Interface().(map[string]uintptr), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapStringUintptrV(v map[string]uintptr, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0
+ if e.h.Canonical {
+ v2 := make([]string, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = string(k)
+ i++
+ }
+ sort.Sort(stringSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ if asSymbols {
+ ee.EncodeSymbol(k2)
+ } else {
+ ee.EncodeString(c_UTF8, k2)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[string(k2)])
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ if asSymbols {
+ ee.EncodeSymbol(k2)
+ } else {
+ ee.EncodeString(c_UTF8, k2)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v2)
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapStringIntR(rv reflect.Value) {
+ fastpathTV.EncMapStringIntV(rv.Interface().(map[string]int), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapStringIntV(v map[string]int, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0
+ if e.h.Canonical {
+ v2 := make([]string, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = string(k)
+ i++
+ }
+ sort.Sort(stringSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ if asSymbols {
+ ee.EncodeSymbol(k2)
+ } else {
+ ee.EncodeString(c_UTF8, k2)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[string(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ if asSymbols {
+ ee.EncodeSymbol(k2)
+ } else {
+ ee.EncodeString(c_UTF8, k2)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapStringInt8R(rv reflect.Value) {
+ fastpathTV.EncMapStringInt8V(rv.Interface().(map[string]int8), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapStringInt8V(v map[string]int8, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0
+ if e.h.Canonical {
+ v2 := make([]string, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = string(k)
+ i++
+ }
+ sort.Sort(stringSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ if asSymbols {
+ ee.EncodeSymbol(k2)
+ } else {
+ ee.EncodeString(c_UTF8, k2)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[string(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ if asSymbols {
+ ee.EncodeSymbol(k2)
+ } else {
+ ee.EncodeString(c_UTF8, k2)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapStringInt16R(rv reflect.Value) {
+ fastpathTV.EncMapStringInt16V(rv.Interface().(map[string]int16), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapStringInt16V(v map[string]int16, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0
+ if e.h.Canonical {
+ v2 := make([]string, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = string(k)
+ i++
+ }
+ sort.Sort(stringSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ if asSymbols {
+ ee.EncodeSymbol(k2)
+ } else {
+ ee.EncodeString(c_UTF8, k2)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[string(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ if asSymbols {
+ ee.EncodeSymbol(k2)
+ } else {
+ ee.EncodeString(c_UTF8, k2)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapStringInt32R(rv reflect.Value) {
+ fastpathTV.EncMapStringInt32V(rv.Interface().(map[string]int32), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapStringInt32V(v map[string]int32, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0
+ if e.h.Canonical {
+ v2 := make([]string, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = string(k)
+ i++
+ }
+ sort.Sort(stringSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ if asSymbols {
+ ee.EncodeSymbol(k2)
+ } else {
+ ee.EncodeString(c_UTF8, k2)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[string(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ if asSymbols {
+ ee.EncodeSymbol(k2)
+ } else {
+ ee.EncodeString(c_UTF8, k2)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapStringInt64R(rv reflect.Value) {
+ fastpathTV.EncMapStringInt64V(rv.Interface().(map[string]int64), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapStringInt64V(v map[string]int64, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0
+ if e.h.Canonical {
+ v2 := make([]string, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = string(k)
+ i++
+ }
+ sort.Sort(stringSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ if asSymbols {
+ ee.EncodeSymbol(k2)
+ } else {
+ ee.EncodeString(c_UTF8, k2)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[string(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ if asSymbols {
+ ee.EncodeSymbol(k2)
+ } else {
+ ee.EncodeString(c_UTF8, k2)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapStringFloat32R(rv reflect.Value) {
+ fastpathTV.EncMapStringFloat32V(rv.Interface().(map[string]float32), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapStringFloat32V(v map[string]float32, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0
+ if e.h.Canonical {
+ v2 := make([]string, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = string(k)
+ i++
+ }
+ sort.Sort(stringSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ if asSymbols {
+ ee.EncodeSymbol(k2)
+ } else {
+ ee.EncodeString(c_UTF8, k2)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeFloat32(v[string(k2)])
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ if asSymbols {
+ ee.EncodeSymbol(k2)
+ } else {
+ ee.EncodeString(c_UTF8, k2)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
ee.EncodeFloat32(v2)
}
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapStringFloat64R(rv reflect.Value) {
+ fastpathTV.EncMapStringFloat64V(rv.Interface().(map[string]float64), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapStringFloat64V(v map[string]float64, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0
+ if e.h.Canonical {
+ v2 := make([]string, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = string(k)
+ i++
+ }
+ sort.Sort(stringSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ if asSymbols {
+ ee.EncodeSymbol(k2)
+ } else {
+ ee.EncodeString(c_UTF8, k2)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeFloat64(v[string(k2)])
+ }
} else {
- for _, v2 := range v {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ if asSymbols {
+ ee.EncodeSymbol(k2)
+ } else {
+ ee.EncodeString(c_UTF8, k2)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeFloat64(v2)
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapStringBoolR(rv reflect.Value) {
+ fastpathTV.EncMapStringBoolV(rv.Interface().(map[string]bool), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapStringBoolV(v map[string]bool, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0
+ if e.h.Canonical {
+ v2 := make([]string, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = string(k)
+ i++
+ }
+ sort.Sort(stringSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ if asSymbols {
+ ee.EncodeSymbol(k2)
+ } else {
+ ee.EncodeString(c_UTF8, k2)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeBool(v[string(k2)])
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ if asSymbols {
+ ee.EncodeSymbol(k2)
+ } else {
+ ee.EncodeString(c_UTF8, k2)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeBool(v2)
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapFloat32IntfR(rv reflect.Value) {
+ fastpathTV.EncMapFloat32IntfV(rv.Interface().(map[float32]interface{}), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapFloat32IntfV(v map[float32]interface{}, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]float64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = float64(k)
+ i++
+ }
+ sort.Sort(floatSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat32(float32(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[float32(k2)])
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat32(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v2)
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapFloat32StringR(rv reflect.Value) {
+ fastpathTV.EncMapFloat32StringV(rv.Interface().(map[float32]string), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapFloat32StringV(v map[float32]string, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]float64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = float64(k)
+ i++
+ }
+ sort.Sort(floatSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat32(float32(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeString(c_UTF8, v[float32(k2)])
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat32(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeString(c_UTF8, v2)
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapFloat32UintR(rv reflect.Value) {
+ fastpathTV.EncMapFloat32UintV(rv.Interface().(map[float32]uint), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapFloat32UintV(v map[float32]uint, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]float64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = float64(k)
+ i++
+ }
+ sort.Sort(floatSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat32(float32(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[float32(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat32(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapFloat32Uint8R(rv reflect.Value) {
+ fastpathTV.EncMapFloat32Uint8V(rv.Interface().(map[float32]uint8), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapFloat32Uint8V(v map[float32]uint8, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]float64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = float64(k)
+ i++
+ }
+ sort.Sort(floatSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat32(float32(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[float32(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat32(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapFloat32Uint16R(rv reflect.Value) {
+ fastpathTV.EncMapFloat32Uint16V(rv.Interface().(map[float32]uint16), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapFloat32Uint16V(v map[float32]uint16, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]float64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = float64(k)
+ i++
+ }
+ sort.Sort(floatSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat32(float32(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[float32(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat32(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapFloat32Uint32R(rv reflect.Value) {
+ fastpathTV.EncMapFloat32Uint32V(rv.Interface().(map[float32]uint32), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapFloat32Uint32V(v map[float32]uint32, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]float64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = float64(k)
+ i++
+ }
+ sort.Sort(floatSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat32(float32(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[float32(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat32(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapFloat32Uint64R(rv reflect.Value) {
+ fastpathTV.EncMapFloat32Uint64V(rv.Interface().(map[float32]uint64), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapFloat32Uint64V(v map[float32]uint64, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]float64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = float64(k)
+ i++
+ }
+ sort.Sort(floatSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat32(float32(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[float32(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat32(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapFloat32UintptrR(rv reflect.Value) {
+ fastpathTV.EncMapFloat32UintptrV(rv.Interface().(map[float32]uintptr), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapFloat32UintptrV(v map[float32]uintptr, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]float64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = float64(k)
+ i++
+ }
+ sort.Sort(floatSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat32(float32(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[float32(k2)])
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat32(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v2)
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapFloat32IntR(rv reflect.Value) {
+ fastpathTV.EncMapFloat32IntV(rv.Interface().(map[float32]int), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapFloat32IntV(v map[float32]int, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]float64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = float64(k)
+ i++
+ }
+ sort.Sort(floatSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat32(float32(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[float32(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat32(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapFloat32Int8R(rv reflect.Value) {
+ fastpathTV.EncMapFloat32Int8V(rv.Interface().(map[float32]int8), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapFloat32Int8V(v map[float32]int8, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]float64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = float64(k)
+ i++
+ }
+ sort.Sort(floatSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat32(float32(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[float32(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat32(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapFloat32Int16R(rv reflect.Value) {
+ fastpathTV.EncMapFloat32Int16V(rv.Interface().(map[float32]int16), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapFloat32Int16V(v map[float32]int16, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]float64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = float64(k)
+ i++
+ }
+ sort.Sort(floatSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat32(float32(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[float32(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat32(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapFloat32Int32R(rv reflect.Value) {
+ fastpathTV.EncMapFloat32Int32V(rv.Interface().(map[float32]int32), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapFloat32Int32V(v map[float32]int32, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]float64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = float64(k)
+ i++
+ }
+ sort.Sort(floatSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat32(float32(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[float32(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat32(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapFloat32Int64R(rv reflect.Value) {
+ fastpathTV.EncMapFloat32Int64V(rv.Interface().(map[float32]int64), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapFloat32Int64V(v map[float32]int64, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]float64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = float64(k)
+ i++
+ }
+ sort.Sort(floatSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat32(float32(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[float32(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat32(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapFloat32Float32R(rv reflect.Value) {
+ fastpathTV.EncMapFloat32Float32V(rv.Interface().(map[float32]float32), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapFloat32Float32V(v map[float32]float32, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]float64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = float64(k)
+ i++
+ }
+ sort.Sort(floatSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat32(float32(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeFloat32(v[float32(k2)])
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat32(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeFloat32(v2)
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncSliceFloat64R(f *codecFnInfo, rv reflect.Value) {
- if f.ti.mbs {
- fastpathTV.EncAsMapSliceFloat64V(rv2i(rv).([]float64), e)
- } else {
- fastpathTV.EncSliceFloat64V(rv2i(rv).([]float64), e)
- }
+func (f *encFnInfo) fastpathEncMapFloat32Float64R(rv reflect.Value) {
+ fastpathTV.EncMapFloat32Float64V(rv.Interface().(map[float32]float64), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncSliceFloat64V(v []float64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapFloat32Float64V(v map[float32]float64, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteArrayStart(len(v))
- if esep {
- for _, v2 := range v {
- ee.WriteArrayElem()
- ee.EncodeFloat64(v2)
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]float64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = float64(k)
+ i++
+ }
+ sort.Sort(floatSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat32(float32(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeFloat64(v[float32(k2)])
}
} else {
- for _, v2 := range v {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat32(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeFloat64(v2)
}
}
- ee.WriteArrayEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (_ fastpathT) EncAsMapSliceFloat64V(v []float64, e *Encoder) {
- ee, esep := e.e, e.hh.hasElemSeparators()
- if len(v)%2 == 1 {
- e.errorf("mapBySlice requires even slice length, but got %v", len(v))
+
+func (f *encFnInfo) fastpathEncMapFloat32BoolR(rv reflect.Value) {
+ fastpathTV.EncMapFloat32BoolV(rv.Interface().(map[float32]bool), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapFloat32BoolV(v map[float32]bool, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee.WriteMapStart(len(v) / 2)
- if esep {
- for j, v2 := range v {
- if j%2 == 0 {
- ee.WriteMapElemKey()
- } else {
- ee.WriteMapElemValue()
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]float64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = float64(k)
+ i++
+ }
+ sort.Sort(floatSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat32(float32(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeBool(v[float32(k2)])
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat32(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeBool(v2)
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapFloat64IntfR(rv reflect.Value) {
+ fastpathTV.EncMapFloat64IntfV(rv.Interface().(map[float64]interface{}), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapFloat64IntfV(v map[float64]interface{}, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]float64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = float64(k)
+ i++
+ }
+ sort.Sort(floatSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat64(float64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[float64(k2)])
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat64(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v2)
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapFloat64StringR(rv reflect.Value) {
+ fastpathTV.EncMapFloat64StringV(rv.Interface().(map[float64]string), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapFloat64StringV(v map[float64]string, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]float64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = float64(k)
+ i++
+ }
+ sort.Sort(floatSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat64(float64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeString(c_UTF8, v[float64(k2)])
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat64(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeString(c_UTF8, v2)
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapFloat64UintR(rv reflect.Value) {
+ fastpathTV.EncMapFloat64UintV(rv.Interface().(map[float64]uint), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapFloat64UintV(v map[float64]uint, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]float64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = float64(k)
+ i++
+ }
+ sort.Sort(floatSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat64(float64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[float64(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat64(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapFloat64Uint8R(rv reflect.Value) {
+ fastpathTV.EncMapFloat64Uint8V(rv.Interface().(map[float64]uint8), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapFloat64Uint8V(v map[float64]uint8, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]float64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = float64(k)
+ i++
+ }
+ sort.Sort(floatSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat64(float64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[float64(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat64(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapFloat64Uint16R(rv reflect.Value) {
+ fastpathTV.EncMapFloat64Uint16V(rv.Interface().(map[float64]uint16), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapFloat64Uint16V(v map[float64]uint16, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]float64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = float64(k)
+ i++
+ }
+ sort.Sort(floatSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat64(float64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[float64(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat64(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapFloat64Uint32R(rv reflect.Value) {
+ fastpathTV.EncMapFloat64Uint32V(rv.Interface().(map[float64]uint32), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapFloat64Uint32V(v map[float64]uint32, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]float64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = float64(k)
+ i++
+ }
+ sort.Sort(floatSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat64(float64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[float64(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat64(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapFloat64Uint64R(rv reflect.Value) {
+ fastpathTV.EncMapFloat64Uint64V(rv.Interface().(map[float64]uint64), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapFloat64Uint64V(v map[float64]uint64, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]float64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = float64(k)
+ i++
+ }
+ sort.Sort(floatSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat64(float64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[float64(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat64(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapFloat64UintptrR(rv reflect.Value) {
+ fastpathTV.EncMapFloat64UintptrV(rv.Interface().(map[float64]uintptr), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapFloat64UintptrV(v map[float64]uintptr, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]float64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = float64(k)
+ i++
+ }
+ sort.Sort(floatSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat64(float64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[float64(k2)])
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat64(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v2)
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapFloat64IntR(rv reflect.Value) {
+ fastpathTV.EncMapFloat64IntV(rv.Interface().(map[float64]int), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapFloat64IntV(v map[float64]int, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]float64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = float64(k)
+ i++
+ }
+ sort.Sort(floatSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat64(float64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[float64(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat64(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapFloat64Int8R(rv reflect.Value) {
+ fastpathTV.EncMapFloat64Int8V(rv.Interface().(map[float64]int8), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapFloat64Int8V(v map[float64]int8, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]float64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = float64(k)
+ i++
+ }
+ sort.Sort(floatSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat64(float64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[float64(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat64(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapFloat64Int16R(rv reflect.Value) {
+ fastpathTV.EncMapFloat64Int16V(rv.Interface().(map[float64]int16), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapFloat64Int16V(v map[float64]int16, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]float64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = float64(k)
+ i++
+ }
+ sort.Sort(floatSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat64(float64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[float64(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat64(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapFloat64Int32R(rv reflect.Value) {
+ fastpathTV.EncMapFloat64Int32V(rv.Interface().(map[float64]int32), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapFloat64Int32V(v map[float64]int32, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]float64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = float64(k)
+ i++
+ }
+ sort.Sort(floatSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat64(float64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[float64(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat64(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapFloat64Int64R(rv reflect.Value) {
+ fastpathTV.EncMapFloat64Int64V(rv.Interface().(map[float64]int64), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapFloat64Int64V(v map[float64]int64, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]float64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = float64(k)
+ i++
+ }
+ sort.Sort(floatSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat64(float64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[float64(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat64(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapFloat64Float32R(rv reflect.Value) {
+ fastpathTV.EncMapFloat64Float32V(rv.Interface().(map[float64]float32), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapFloat64Float32V(v map[float64]float32, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]float64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = float64(k)
+ i++
+ }
+ sort.Sort(floatSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat64(float64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeFloat32(v[float64(k2)])
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat64(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeFloat32(v2)
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapFloat64Float64R(rv reflect.Value) {
+ fastpathTV.EncMapFloat64Float64V(rv.Interface().(map[float64]float64), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapFloat64Float64V(v map[float64]float64, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]float64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = float64(k)
+ i++
+ }
+ sort.Sort(floatSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat64(float64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeFloat64(v[float64(k2)])
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat64(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
ee.EncodeFloat64(v2)
}
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapFloat64BoolR(rv reflect.Value) {
+ fastpathTV.EncMapFloat64BoolV(rv.Interface().(map[float64]bool), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapFloat64BoolV(v map[float64]bool, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]float64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = float64(k)
+ i++
+ }
+ sort.Sort(floatSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat64(float64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeBool(v[float64(k2)])
+ }
} else {
- for _, v2 := range v {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeFloat64(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeBool(v2)
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapUintIntfR(rv reflect.Value) {
+ fastpathTV.EncMapUintIntfV(rv.Interface().(map[uint]interface{}), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUintIntfV(v map[uint]interface{}, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[uint(k2)])
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v2)
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapUintStringR(rv reflect.Value) {
+ fastpathTV.EncMapUintStringV(rv.Interface().(map[uint]string), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUintStringV(v map[uint]string, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeString(c_UTF8, v[uint(k2)])
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeString(c_UTF8, v2)
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapUintUintR(rv reflect.Value) {
+ fastpathTV.EncMapUintUintV(rv.Interface().(map[uint]uint), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUintUintV(v map[uint]uint, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[uint(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapUintUint8R(rv reflect.Value) {
+ fastpathTV.EncMapUintUint8V(rv.Interface().(map[uint]uint8), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUintUint8V(v map[uint]uint8, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[uint(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapUintUint16R(rv reflect.Value) {
+ fastpathTV.EncMapUintUint16V(rv.Interface().(map[uint]uint16), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUintUint16V(v map[uint]uint16, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[uint(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapUintUint32R(rv reflect.Value) {
+ fastpathTV.EncMapUintUint32V(rv.Interface().(map[uint]uint32), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUintUint32V(v map[uint]uint32, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[uint(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapUintUint64R(rv reflect.Value) {
+ fastpathTV.EncMapUintUint64V(rv.Interface().(map[uint]uint64), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUintUint64V(v map[uint]uint64, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[uint(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapUintUintptrR(rv reflect.Value) {
+ fastpathTV.EncMapUintUintptrV(rv.Interface().(map[uint]uintptr), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUintUintptrV(v map[uint]uintptr, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[uint(k2)])
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v2)
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapUintIntR(rv reflect.Value) {
+ fastpathTV.EncMapUintIntV(rv.Interface().(map[uint]int), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUintIntV(v map[uint]int, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[uint(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapUintInt8R(rv reflect.Value) {
+ fastpathTV.EncMapUintInt8V(rv.Interface().(map[uint]int8), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUintInt8V(v map[uint]int8, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[uint(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapUintInt16R(rv reflect.Value) {
+ fastpathTV.EncMapUintInt16V(rv.Interface().(map[uint]int16), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUintInt16V(v map[uint]int16, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[uint(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapUintInt32R(rv reflect.Value) {
+ fastpathTV.EncMapUintInt32V(rv.Interface().(map[uint]int32), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUintInt32V(v map[uint]int32, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[uint(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapUintInt64R(rv reflect.Value) {
+ fastpathTV.EncMapUintInt64V(rv.Interface().(map[uint]int64), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUintInt64V(v map[uint]int64, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[uint(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapUintFloat32R(rv reflect.Value) {
+ fastpathTV.EncMapUintFloat32V(rv.Interface().(map[uint]float32), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUintFloat32V(v map[uint]float32, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeFloat32(v[uint(k2)])
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeFloat32(v2)
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapUintFloat64R(rv reflect.Value) {
+ fastpathTV.EncMapUintFloat64V(rv.Interface().(map[uint]float64), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUintFloat64V(v map[uint]float64, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeFloat64(v[uint(k2)])
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeFloat64(v2)
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncSliceUintR(f *codecFnInfo, rv reflect.Value) {
- if f.ti.mbs {
- fastpathTV.EncAsMapSliceUintV(rv2i(rv).([]uint), e)
- } else {
- fastpathTV.EncSliceUintV(rv2i(rv).([]uint), e)
- }
+func (f *encFnInfo) fastpathEncMapUintBoolR(rv reflect.Value) {
+ fastpathTV.EncMapUintBoolV(rv.Interface().(map[uint]bool), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncSliceUintV(v []uint, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapUintBoolV(v map[uint]bool, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteArrayStart(len(v))
- if esep {
- for _, v2 := range v {
- ee.WriteArrayElem()
- ee.EncodeUint(uint64(v2))
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
}
- } else {
- for _, v2 := range v {
- ee.EncodeUint(uint64(v2))
- }
- }
- ee.WriteArrayEnd()
-}
-func (_ fastpathT) EncAsMapSliceUintV(v []uint, e *Encoder) {
- ee, esep := e.e, e.hh.hasElemSeparators()
- if len(v)%2 == 1 {
- e.errorf("mapBySlice requires even slice length, but got %v", len(v))
- return
- }
- ee.WriteMapStart(len(v) / 2)
- if esep {
- for j, v2 := range v {
- if j%2 == 0 {
- ee.WriteMapElemKey()
- } else {
- ee.WriteMapElemValue()
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for _, v2 := range v {
- ee.EncodeUint(uint64(v2))
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncSliceUint8R(f *codecFnInfo, rv reflect.Value) {
- if f.ti.mbs {
- fastpathTV.EncAsMapSliceUint8V(rv2i(rv).([]uint8), e)
- } else {
- fastpathTV.EncSliceUint8V(rv2i(rv).([]uint8), e)
- }
-}
-func (_ fastpathT) EncSliceUint8V(v []uint8, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteArrayStart(len(v))
- if esep {
- for _, v2 := range v {
- ee.WriteArrayElem()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for _, v2 := range v {
- ee.EncodeUint(uint64(v2))
- }
- }
- ee.WriteArrayEnd()
-}
-func (_ fastpathT) EncAsMapSliceUint8V(v []uint8, e *Encoder) {
- ee, esep := e.e, e.hh.hasElemSeparators()
- if len(v)%2 == 1 {
- e.errorf("mapBySlice requires even slice length, but got %v", len(v))
- return
- }
- ee.WriteMapStart(len(v) / 2)
- if esep {
- for j, v2 := range v {
- if j%2 == 0 {
- ee.WriteMapElemKey()
- } else {
- ee.WriteMapElemValue()
+ ee.EncodeUint(uint64(uint(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
- ee.EncodeUint(uint64(v2))
+ ee.EncodeBool(v[uint(k2)])
}
} else {
- for _, v2 := range v {
- ee.EncodeUint(uint64(v2))
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncSliceUint16R(f *codecFnInfo, rv reflect.Value) {
- if f.ti.mbs {
- fastpathTV.EncAsMapSliceUint16V(rv2i(rv).([]uint16), e)
- } else {
- 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))
- if esep {
- for _, v2 := range v {
- ee.WriteArrayElem()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for _, v2 := range v {
- ee.EncodeUint(uint64(v2))
- }
- }
- ee.WriteArrayEnd()
-}
-func (_ fastpathT) EncAsMapSliceUint16V(v []uint16, e *Encoder) {
- ee, esep := e.e, e.hh.hasElemSeparators()
- if len(v)%2 == 1 {
- e.errorf("mapBySlice requires even slice length, but got %v", len(v))
- return
- }
- ee.WriteMapStart(len(v) / 2)
- if esep {
- for j, v2 := range v {
- if j%2 == 0 {
- ee.WriteMapElemKey()
- } else {
- ee.WriteMapElemValue()
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for _, v2 := range v {
- ee.EncodeUint(uint64(v2))
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncSliceUint32R(f *codecFnInfo, rv reflect.Value) {
- if f.ti.mbs {
- fastpathTV.EncAsMapSliceUint32V(rv2i(rv).([]uint32), e)
- } else {
- fastpathTV.EncSliceUint32V(rv2i(rv).([]uint32), e)
- }
-}
-func (_ fastpathT) EncSliceUint32V(v []uint32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteArrayStart(len(v))
- if esep {
- for _, v2 := range v {
- ee.WriteArrayElem()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for _, v2 := range v {
- ee.EncodeUint(uint64(v2))
- }
- }
- ee.WriteArrayEnd()
-}
-func (_ fastpathT) EncAsMapSliceUint32V(v []uint32, e *Encoder) {
- ee, esep := e.e, e.hh.hasElemSeparators()
- if len(v)%2 == 1 {
- e.errorf("mapBySlice requires even slice length, but got %v", len(v))
- return
- }
- ee.WriteMapStart(len(v) / 2)
- if esep {
- for j, v2 := range v {
- if j%2 == 0 {
- ee.WriteMapElemKey()
- } else {
- ee.WriteMapElemValue()
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for _, v2 := range v {
- ee.EncodeUint(uint64(v2))
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncSliceUint64R(f *codecFnInfo, rv reflect.Value) {
- if f.ti.mbs {
- fastpathTV.EncAsMapSliceUint64V(rv2i(rv).([]uint64), e)
- } else {
- fastpathTV.EncSliceUint64V(rv2i(rv).([]uint64), e)
- }
-}
-func (_ fastpathT) EncSliceUint64V(v []uint64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteArrayStart(len(v))
- if esep {
- for _, v2 := range v {
- ee.WriteArrayElem()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for _, v2 := range v {
- ee.EncodeUint(uint64(v2))
- }
- }
- ee.WriteArrayEnd()
-}
-func (_ fastpathT) EncAsMapSliceUint64V(v []uint64, e *Encoder) {
- ee, esep := e.e, e.hh.hasElemSeparators()
- if len(v)%2 == 1 {
- e.errorf("mapBySlice requires even slice length, but got %v", len(v))
- return
- }
- ee.WriteMapStart(len(v) / 2)
- if esep {
- for j, v2 := range v {
- if j%2 == 0 {
- ee.WriteMapElemKey()
- } else {
- ee.WriteMapElemValue()
- }
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for _, v2 := range v {
- ee.EncodeUint(uint64(v2))
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncSliceUintptrR(f *codecFnInfo, rv reflect.Value) {
- if f.ti.mbs {
- fastpathTV.EncAsMapSliceUintptrV(rv2i(rv).([]uintptr), e)
- } else {
- fastpathTV.EncSliceUintptrV(rv2i(rv).([]uintptr), e)
- }
-}
-func (_ fastpathT) EncSliceUintptrV(v []uintptr, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteArrayStart(len(v))
- if esep {
- for _, v2 := range v {
- ee.WriteArrayElem()
- e.encode(v2)
- }
- } else {
- for _, v2 := range v {
- e.encode(v2)
- }
- }
- ee.WriteArrayEnd()
-}
-func (_ fastpathT) EncAsMapSliceUintptrV(v []uintptr, e *Encoder) {
- ee, esep := e.e, e.hh.hasElemSeparators()
- if len(v)%2 == 1 {
- e.errorf("mapBySlice requires even slice length, but got %v", len(v))
- return
- }
- ee.WriteMapStart(len(v) / 2)
- if esep {
- for j, v2 := range v {
- if j%2 == 0 {
- ee.WriteMapElemKey()
- } else {
- ee.WriteMapElemValue()
- }
- e.encode(v2)
- }
- } else {
- for _, v2 := range v {
- 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))
- if esep {
- for _, v2 := range v {
- ee.WriteArrayElem()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for _, v2 := range v {
- 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("mapBySlice requires even slice length, but got %v", len(v))
- return
- }
- ee.WriteMapStart(len(v) / 2)
- if esep {
- for j, v2 := range v {
- if j%2 == 0 {
- ee.WriteMapElemKey()
- } else {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v2))
- }
- } else {
- for _, v2 := range v {
- ee.EncodeInt(int64(v2))
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncSliceInt8R(f *codecFnInfo, rv reflect.Value) {
- if f.ti.mbs {
- fastpathTV.EncAsMapSliceInt8V(rv2i(rv).([]int8), e)
- } else {
- fastpathTV.EncSliceInt8V(rv2i(rv).([]int8), e)
- }
-}
-func (_ fastpathT) EncSliceInt8V(v []int8, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteArrayStart(len(v))
- if esep {
- for _, v2 := range v {
- ee.WriteArrayElem()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for _, v2 := range v {
- ee.EncodeInt(int64(v2))
- }
- }
- ee.WriteArrayEnd()
-}
-func (_ fastpathT) EncAsMapSliceInt8V(v []int8, e *Encoder) {
- ee, esep := e.e, e.hh.hasElemSeparators()
- if len(v)%2 == 1 {
- e.errorf("mapBySlice requires even slice length, but got %v", len(v))
- return
- }
- ee.WriteMapStart(len(v) / 2)
- if esep {
- for j, v2 := range v {
- if j%2 == 0 {
- ee.WriteMapElemKey()
- } else {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v2))
- }
- } else {
- for _, v2 := range v {
- ee.EncodeInt(int64(v2))
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncSliceInt16R(f *codecFnInfo, rv reflect.Value) {
- if f.ti.mbs {
- fastpathTV.EncAsMapSliceInt16V(rv2i(rv).([]int16), e)
- } else {
- fastpathTV.EncSliceInt16V(rv2i(rv).([]int16), e)
- }
-}
-func (_ fastpathT) EncSliceInt16V(v []int16, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteArrayStart(len(v))
- if esep {
- for _, v2 := range v {
- ee.WriteArrayElem()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for _, v2 := range v {
- ee.EncodeInt(int64(v2))
- }
- }
- ee.WriteArrayEnd()
-}
-func (_ fastpathT) EncAsMapSliceInt16V(v []int16, e *Encoder) {
- ee, esep := e.e, e.hh.hasElemSeparators()
- if len(v)%2 == 1 {
- e.errorf("mapBySlice requires even slice length, but got %v", len(v))
- return
- }
- ee.WriteMapStart(len(v) / 2)
- if esep {
- for j, v2 := range v {
- if j%2 == 0 {
- ee.WriteMapElemKey()
- } else {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v2))
- }
- } else {
- for _, v2 := range v {
- ee.EncodeInt(int64(v2))
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncSliceInt32R(f *codecFnInfo, rv reflect.Value) {
- if f.ti.mbs {
- fastpathTV.EncAsMapSliceInt32V(rv2i(rv).([]int32), e)
- } else {
- fastpathTV.EncSliceInt32V(rv2i(rv).([]int32), e)
- }
-}
-func (_ fastpathT) EncSliceInt32V(v []int32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteArrayStart(len(v))
- if esep {
- for _, v2 := range v {
- ee.WriteArrayElem()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for _, v2 := range v {
- ee.EncodeInt(int64(v2))
- }
- }
- ee.WriteArrayEnd()
-}
-func (_ fastpathT) EncAsMapSliceInt32V(v []int32, e *Encoder) {
- ee, esep := e.e, e.hh.hasElemSeparators()
- if len(v)%2 == 1 {
- e.errorf("mapBySlice requires even slice length, but got %v", len(v))
- return
- }
- ee.WriteMapStart(len(v) / 2)
- if esep {
- for j, v2 := range v {
- if j%2 == 0 {
- ee.WriteMapElemKey()
- } else {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v2))
- }
- } else {
- for _, v2 := range v {
- ee.EncodeInt(int64(v2))
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncSliceInt64R(f *codecFnInfo, rv reflect.Value) {
- if f.ti.mbs {
- fastpathTV.EncAsMapSliceInt64V(rv2i(rv).([]int64), e)
- } else {
- fastpathTV.EncSliceInt64V(rv2i(rv).([]int64), e)
- }
-}
-func (_ fastpathT) EncSliceInt64V(v []int64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteArrayStart(len(v))
- if esep {
- for _, v2 := range v {
- ee.WriteArrayElem()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for _, v2 := range v {
- ee.EncodeInt(int64(v2))
- }
- }
- ee.WriteArrayEnd()
-}
-func (_ fastpathT) EncAsMapSliceInt64V(v []int64, e *Encoder) {
- ee, esep := e.e, e.hh.hasElemSeparators()
- if len(v)%2 == 1 {
- e.errorf("mapBySlice requires even slice length, but got %v", len(v))
- return
- }
- ee.WriteMapStart(len(v) / 2)
- if esep {
- for j, v2 := range v {
- if j%2 == 0 {
- ee.WriteMapElemKey()
- } else {
- ee.WriteMapElemValue()
- }
- ee.EncodeInt(int64(v2))
- }
- } else {
- for _, v2 := range v {
- ee.EncodeInt(int64(v2))
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncSliceBoolR(f *codecFnInfo, rv reflect.Value) {
- if f.ti.mbs {
- fastpathTV.EncAsMapSliceBoolV(rv2i(rv).([]bool), e)
- } else {
- fastpathTV.EncSliceBoolV(rv2i(rv).([]bool), e)
- }
-}
-func (_ fastpathT) EncSliceBoolV(v []bool, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteArrayStart(len(v))
- if esep {
- for _, v2 := range v {
- ee.WriteArrayElem()
- ee.EncodeBool(v2)
- }
- } else {
- for _, v2 := range v {
ee.EncodeBool(v2)
}
}
- ee.WriteArrayEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (_ fastpathT) EncAsMapSliceBoolV(v []bool, e *Encoder) {
- ee, esep := e.e, e.hh.hasElemSeparators()
- if len(v)%2 == 1 {
- e.errorf("mapBySlice requires even slice length, but got %v", len(v))
+
+func (f *encFnInfo) fastpathEncMapUint8IntfR(rv reflect.Value) {
+ fastpathTV.EncMapUint8IntfV(rv.Interface().(map[uint8]interface{}), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUint8IntfV(v map[uint8]interface{}, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee.WriteMapStart(len(v) / 2)
- if esep {
- for j, v2 := range v {
- if j%2 == 0 {
- ee.WriteMapElemKey()
- } else {
- ee.WriteMapElemValue()
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint8(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[uint8(k2)])
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v2)
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapUint8StringR(rv reflect.Value) {
+ fastpathTV.EncMapUint8StringV(rv.Interface().(map[uint8]string), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUint8StringV(v map[uint8]string, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint8(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeString(c_UTF8, v[uint8(k2)])
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeString(c_UTF8, v2)
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapUint8UintR(rv reflect.Value) {
+ fastpathTV.EncMapUint8UintV(rv.Interface().(map[uint8]uint), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUint8UintV(v map[uint8]uint, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint8(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[uint8(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapUint8Uint8R(rv reflect.Value) {
+ fastpathTV.EncMapUint8Uint8V(rv.Interface().(map[uint8]uint8), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUint8Uint8V(v map[uint8]uint8, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint8(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[uint8(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapUint8Uint16R(rv reflect.Value) {
+ fastpathTV.EncMapUint8Uint16V(rv.Interface().(map[uint8]uint16), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUint8Uint16V(v map[uint8]uint16, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint8(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[uint8(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapUint8Uint32R(rv reflect.Value) {
+ fastpathTV.EncMapUint8Uint32V(rv.Interface().(map[uint8]uint32), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUint8Uint32V(v map[uint8]uint32, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint8(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[uint8(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapUint8Uint64R(rv reflect.Value) {
+ fastpathTV.EncMapUint8Uint64V(rv.Interface().(map[uint8]uint64), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUint8Uint64V(v map[uint8]uint64, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint8(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[uint8(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapUint8UintptrR(rv reflect.Value) {
+ fastpathTV.EncMapUint8UintptrV(rv.Interface().(map[uint8]uintptr), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUint8UintptrV(v map[uint8]uintptr, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint8(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[uint8(k2)])
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v2)
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapUint8IntR(rv reflect.Value) {
+ fastpathTV.EncMapUint8IntV(rv.Interface().(map[uint8]int), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUint8IntV(v map[uint8]int, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint8(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[uint8(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapUint8Int8R(rv reflect.Value) {
+ fastpathTV.EncMapUint8Int8V(rv.Interface().(map[uint8]int8), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUint8Int8V(v map[uint8]int8, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint8(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[uint8(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapUint8Int16R(rv reflect.Value) {
+ fastpathTV.EncMapUint8Int16V(rv.Interface().(map[uint8]int16), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUint8Int16V(v map[uint8]int16, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint8(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[uint8(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapUint8Int32R(rv reflect.Value) {
+ fastpathTV.EncMapUint8Int32V(rv.Interface().(map[uint8]int32), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUint8Int32V(v map[uint8]int32, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint8(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[uint8(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapUint8Int64R(rv reflect.Value) {
+ fastpathTV.EncMapUint8Int64V(rv.Interface().(map[uint8]int64), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUint8Int64V(v map[uint8]int64, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint8(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[uint8(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapUint8Float32R(rv reflect.Value) {
+ fastpathTV.EncMapUint8Float32V(rv.Interface().(map[uint8]float32), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUint8Float32V(v map[uint8]float32, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint8(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeFloat32(v[uint8(k2)])
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeFloat32(v2)
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapUint8Float64R(rv reflect.Value) {
+ fastpathTV.EncMapUint8Float64V(rv.Interface().(map[uint8]float64), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUint8Float64V(v map[uint8]float64, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint8(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeFloat64(v[uint8(k2)])
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeFloat64(v2)
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapUint8BoolR(rv reflect.Value) {
+ fastpathTV.EncMapUint8BoolV(rv.Interface().(map[uint8]bool), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUint8BoolV(v map[uint8]bool, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint8(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeBool(v[uint8(k2)])
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
ee.EncodeBool(v2)
}
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapUint16IntfR(rv reflect.Value) {
+ fastpathTV.EncMapUint16IntfV(rv.Interface().(map[uint16]interface{}), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUint16IntfV(v map[uint16]interface{}, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint16(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[uint16(k2)])
+ }
} else {
- for _, v2 := range v {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v2)
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapUint16StringR(rv reflect.Value) {
+ fastpathTV.EncMapUint16StringV(rv.Interface().(map[uint16]string), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUint16StringV(v map[uint16]string, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint16(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeString(c_UTF8, v[uint16(k2)])
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeString(c_UTF8, v2)
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapUint16UintR(rv reflect.Value) {
+ fastpathTV.EncMapUint16UintV(rv.Interface().(map[uint16]uint), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUint16UintV(v map[uint16]uint, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint16(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[uint16(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapUint16Uint8R(rv reflect.Value) {
+ fastpathTV.EncMapUint16Uint8V(rv.Interface().(map[uint16]uint8), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUint16Uint8V(v map[uint16]uint8, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint16(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[uint16(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapUint16Uint16R(rv reflect.Value) {
+ fastpathTV.EncMapUint16Uint16V(rv.Interface().(map[uint16]uint16), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUint16Uint16V(v map[uint16]uint16, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint16(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[uint16(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapUint16Uint32R(rv reflect.Value) {
+ fastpathTV.EncMapUint16Uint32V(rv.Interface().(map[uint16]uint32), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUint16Uint32V(v map[uint16]uint32, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint16(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[uint16(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapUint16Uint64R(rv reflect.Value) {
+ fastpathTV.EncMapUint16Uint64V(rv.Interface().(map[uint16]uint64), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUint16Uint64V(v map[uint16]uint64, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint16(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v[uint16(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeUint(uint64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapUint16UintptrR(rv reflect.Value) {
+ fastpathTV.EncMapUint16UintptrV(rv.Interface().(map[uint16]uintptr), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUint16UintptrV(v map[uint16]uintptr, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint16(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v[uint16(k2)])
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ e.encode(v2)
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapUint16IntR(rv reflect.Value) {
+ fastpathTV.EncMapUint16IntV(rv.Interface().(map[uint16]int), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUint16IntV(v map[uint16]int, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint16(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[uint16(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapUint16Int8R(rv reflect.Value) {
+ fastpathTV.EncMapUint16Int8V(rv.Interface().(map[uint16]int8), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUint16Int8V(v map[uint16]int8, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint16(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[uint16(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapUint16Int16R(rv reflect.Value) {
+ fastpathTV.EncMapUint16Int16V(rv.Interface().(map[uint16]int16), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUint16Int16V(v map[uint16]int16, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint16(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[uint16(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapUint16Int32R(rv reflect.Value) {
+ fastpathTV.EncMapUint16Int32V(rv.Interface().(map[uint16]int32), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUint16Int32V(v map[uint16]int32, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint16(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[uint16(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapUint16Int64R(rv reflect.Value) {
+ fastpathTV.EncMapUint16Int64V(rv.Interface().(map[uint16]int64), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUint16Int64V(v map[uint16]int64, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint16(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v[uint16(k2)]))
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeInt(int64(v2))
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapUint16Float32R(rv reflect.Value) {
+ fastpathTV.EncMapUint16Float32V(rv.Interface().(map[uint16]float32), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUint16Float32V(v map[uint16]float32, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint16(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeFloat32(v[uint16(k2)])
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeFloat32(v2)
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapUint16Float64R(rv reflect.Value) {
+ fastpathTV.EncMapUint16Float64V(rv.Interface().(map[uint16]float64), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUint16Float64V(v map[uint16]float64, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint16(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeFloat64(v[uint16(k2)])
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeFloat64(v2)
+ }
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
+}
+
+func (f *encFnInfo) fastpathEncMapUint16BoolR(rv reflect.Value) {
+ fastpathTV.EncMapUint16BoolV(rv.Interface().(map[uint16]bool), fastpathCheckNilFalse, f.e)
+}
+func (_ fastpathT) EncMapUint16BoolV(v map[uint16]bool, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ if e.h.Canonical {
+ v2 := make([]uint64, len(v))
+ var i int
+ for k, _ := range v {
+ v2[i] = uint64(k)
+ i++
+ }
+ sort.Sort(uintSlice(v2))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(uint16(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ ee.EncodeBool(v[uint16(k2)])
+ }
+ } else {
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
ee.EncodeBool(v2)
}
}
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapIntfIntfR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapIntfIntfV(rv2i(rv).(map[interface{}]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))
- 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 int
- var vp *bytesI
- for k2, _ := range v {
- l = len(mksv)
- e2.MustEncode(k2)
- vp = &v2[i]
- vp.v = mksv[l:]
- vp.i = k2
- i++
- }
- sort.Sort(bytesISlice(v2))
- if esep {
- for j := range v2 {
- ee.WriteMapElemKey()
- e.asis(v2[j].v)
- ee.WriteMapElemValue()
- e.encode(v[v2[j].i])
- }
- } else {
- for j := range v2 {
- e.asis(v2[j].v)
- e.encode(v[v2[j].i])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- e.encode(k2)
- ee.WriteMapElemValue()
- e.encode(v2)
- }
- } else {
- for k2, v2 := range v {
- e.encode(k2)
- e.encode(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapIntfStringR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapIntfStringV(rv2i(rv).(map[interface{}]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))
- 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 int
- var vp *bytesI
- for k2, _ := range v {
- l = len(mksv)
- e2.MustEncode(k2)
- vp = &v2[i]
- vp.v = mksv[l:]
- vp.i = k2
- i++
- }
- sort.Sort(bytesISlice(v2))
- if esep {
- for j := range v2 {
- ee.WriteMapElemKey()
- e.asis(v2[j].v)
- ee.WriteMapElemValue()
- e.encode(v[v2[j].i])
- }
- } else {
- for j := range v2 {
- e.asis(v2[j].v)
- e.encode(v[v2[j].i])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- e.encode(k2)
- ee.WriteMapElemValue()
- ee.EncodeString(cUTF8, v2)
- }
- } else {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeString(cUTF8, v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapIntfUintR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapIntfUintV(rv2i(rv).(map[interface{}]uint), 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))
- 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 int
- var vp *bytesI
- for k2, _ := range v {
- l = len(mksv)
- e2.MustEncode(k2)
- vp = &v2[i]
- vp.v = mksv[l:]
- vp.i = k2
- i++
- }
- sort.Sort(bytesISlice(v2))
- if esep {
- for j := range v2 {
- ee.WriteMapElemKey()
- e.asis(v2[j].v)
- ee.WriteMapElemValue()
- e.encode(v[v2[j].i])
- }
- } else {
- for j := range v2 {
- e.asis(v2[j].v)
- e.encode(v[v2[j].i])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- e.encode(k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapIntfUint8R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapIntfUint8V(rv2i(rv).(map[interface{}]uint8), 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))
- 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 int
- var vp *bytesI
- for k2, _ := range v {
- l = len(mksv)
- e2.MustEncode(k2)
- vp = &v2[i]
- vp.v = mksv[l:]
- vp.i = k2
- i++
- }
- sort.Sort(bytesISlice(v2))
- if esep {
- for j := range v2 {
- ee.WriteMapElemKey()
- e.asis(v2[j].v)
- ee.WriteMapElemValue()
- e.encode(v[v2[j].i])
- }
- } else {
- for j := range v2 {
- e.asis(v2[j].v)
- e.encode(v[v2[j].i])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- e.encode(k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapIntfUint16R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapIntfUint16V(rv2i(rv).(map[interface{}]uint16), 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))
- 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 int
- var vp *bytesI
- for k2, _ := range v {
- l = len(mksv)
- e2.MustEncode(k2)
- vp = &v2[i]
- vp.v = mksv[l:]
- vp.i = k2
- i++
- }
- sort.Sort(bytesISlice(v2))
- if esep {
- for j := range v2 {
- ee.WriteMapElemKey()
- e.asis(v2[j].v)
- ee.WriteMapElemValue()
- e.encode(v[v2[j].i])
- }
- } else {
- for j := range v2 {
- e.asis(v2[j].v)
- e.encode(v[v2[j].i])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- e.encode(k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapIntfUint32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapIntfUint32V(rv2i(rv).(map[interface{}]uint32), 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))
- 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 int
- var vp *bytesI
- for k2, _ := range v {
- l = len(mksv)
- e2.MustEncode(k2)
- vp = &v2[i]
- vp.v = mksv[l:]
- vp.i = k2
- i++
- }
- sort.Sort(bytesISlice(v2))
- if esep {
- for j := range v2 {
- ee.WriteMapElemKey()
- e.asis(v2[j].v)
- ee.WriteMapElemValue()
- e.encode(v[v2[j].i])
- }
- } else {
- for j := range v2 {
- e.asis(v2[j].v)
- e.encode(v[v2[j].i])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- e.encode(k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapIntfUint64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapIntfUint64V(rv2i(rv).(map[interface{}]uint64), 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))
- 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 int
- var vp *bytesI
- for k2, _ := range v {
- l = len(mksv)
- e2.MustEncode(k2)
- vp = &v2[i]
- vp.v = mksv[l:]
- vp.i = k2
- i++
- }
- sort.Sort(bytesISlice(v2))
- if esep {
- for j := range v2 {
- ee.WriteMapElemKey()
- e.asis(v2[j].v)
- ee.WriteMapElemValue()
- e.encode(v[v2[j].i])
- }
- } else {
- for j := range v2 {
- e.asis(v2[j].v)
- e.encode(v[v2[j].i])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- e.encode(k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapIntfUintptrR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapIntfUintptrV(rv2i(rv).(map[interface{}]uintptr), 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))
- 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 int
- var vp *bytesI
- for k2, _ := range v {
- l = len(mksv)
- e2.MustEncode(k2)
- vp = &v2[i]
- vp.v = mksv[l:]
- vp.i = k2
- i++
- }
- sort.Sort(bytesISlice(v2))
- if esep {
- for j := range v2 {
- ee.WriteMapElemKey()
- e.asis(v2[j].v)
- ee.WriteMapElemValue()
- e.encode(v[v2[j].i])
- }
- } else {
- for j := range v2 {
- e.asis(v2[j].v)
- e.encode(v[v2[j].i])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- e.encode(k2)
- ee.WriteMapElemValue()
- e.encode(v2)
- }
- } else {
- for k2, v2 := range v {
- e.encode(k2)
- e.encode(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapIntfIntR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapIntfIntV(rv2i(rv).(map[interface{}]int), 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))
- 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 int
- var vp *bytesI
- for k2, _ := range v {
- l = len(mksv)
- e2.MustEncode(k2)
- vp = &v2[i]
- vp.v = mksv[l:]
- vp.i = k2
- i++
- }
- sort.Sort(bytesISlice(v2))
- if esep {
- for j := range v2 {
- ee.WriteMapElemKey()
- e.asis(v2[j].v)
- ee.WriteMapElemValue()
- e.encode(v[v2[j].i])
- }
- } else {
- for j := range v2 {
- e.asis(v2[j].v)
- e.encode(v[v2[j].i])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- e.encode(k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapIntfInt8R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapIntfInt8V(rv2i(rv).(map[interface{}]int8), 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))
- 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 int
- var vp *bytesI
- for k2, _ := range v {
- l = len(mksv)
- e2.MustEncode(k2)
- vp = &v2[i]
- vp.v = mksv[l:]
- vp.i = k2
- i++
- }
- sort.Sort(bytesISlice(v2))
- if esep {
- for j := range v2 {
- ee.WriteMapElemKey()
- e.asis(v2[j].v)
- ee.WriteMapElemValue()
- e.encode(v[v2[j].i])
- }
- } else {
- for j := range v2 {
- e.asis(v2[j].v)
- e.encode(v[v2[j].i])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- e.encode(k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapIntfInt16R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapIntfInt16V(rv2i(rv).(map[interface{}]int16), 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))
- 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 int
- var vp *bytesI
- for k2, _ := range v {
- l = len(mksv)
- e2.MustEncode(k2)
- vp = &v2[i]
- vp.v = mksv[l:]
- vp.i = k2
- i++
- }
- sort.Sort(bytesISlice(v2))
- if esep {
- for j := range v2 {
- ee.WriteMapElemKey()
- e.asis(v2[j].v)
- ee.WriteMapElemValue()
- e.encode(v[v2[j].i])
- }
- } else {
- for j := range v2 {
- e.asis(v2[j].v)
- e.encode(v[v2[j].i])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- e.encode(k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapIntfInt32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapIntfInt32V(rv2i(rv).(map[interface{}]int32), 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))
- 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 int
- var vp *bytesI
- for k2, _ := range v {
- l = len(mksv)
- e2.MustEncode(k2)
- vp = &v2[i]
- vp.v = mksv[l:]
- vp.i = k2
- i++
- }
- sort.Sort(bytesISlice(v2))
- if esep {
- for j := range v2 {
- ee.WriteMapElemKey()
- e.asis(v2[j].v)
- ee.WriteMapElemValue()
- e.encode(v[v2[j].i])
- }
- } else {
- for j := range v2 {
- e.asis(v2[j].v)
- e.encode(v[v2[j].i])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- e.encode(k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapIntfInt64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapIntfInt64V(rv2i(rv).(map[interface{}]int64), 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))
- 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 int
- var vp *bytesI
- for k2, _ := range v {
- l = len(mksv)
- e2.MustEncode(k2)
- vp = &v2[i]
- vp.v = mksv[l:]
- vp.i = k2
- i++
- }
- sort.Sort(bytesISlice(v2))
- if esep {
- for j := range v2 {
- ee.WriteMapElemKey()
- e.asis(v2[j].v)
- ee.WriteMapElemValue()
- e.encode(v[v2[j].i])
- }
- } else {
- for j := range v2 {
- e.asis(v2[j].v)
- e.encode(v[v2[j].i])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- e.encode(k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapIntfFloat32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapIntfFloat32V(rv2i(rv).(map[interface{}]float32), 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))
- 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 int
- var vp *bytesI
- for k2, _ := range v {
- l = len(mksv)
- e2.MustEncode(k2)
- vp = &v2[i]
- vp.v = mksv[l:]
- vp.i = k2
- i++
- }
- sort.Sort(bytesISlice(v2))
- if esep {
- for j := range v2 {
- ee.WriteMapElemKey()
- e.asis(v2[j].v)
- ee.WriteMapElemValue()
- e.encode(v[v2[j].i])
- }
- } else {
- for j := range v2 {
- e.asis(v2[j].v)
- e.encode(v[v2[j].i])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- e.encode(k2)
- ee.WriteMapElemValue()
- ee.EncodeFloat32(v2)
- }
- } else {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeFloat32(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapIntfFloat64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapIntfFloat64V(rv2i(rv).(map[interface{}]float64), 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))
- 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 int
- var vp *bytesI
- for k2, _ := range v {
- l = len(mksv)
- e2.MustEncode(k2)
- vp = &v2[i]
- vp.v = mksv[l:]
- vp.i = k2
- i++
- }
- sort.Sort(bytesISlice(v2))
- if esep {
- for j := range v2 {
- ee.WriteMapElemKey()
- e.asis(v2[j].v)
- ee.WriteMapElemValue()
- e.encode(v[v2[j].i])
- }
- } else {
- for j := range v2 {
- e.asis(v2[j].v)
- e.encode(v[v2[j].i])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- e.encode(k2)
- ee.WriteMapElemValue()
- ee.EncodeFloat64(v2)
- }
- } else {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeFloat64(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapIntfBoolR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapIntfBoolV(rv2i(rv).(map[interface{}]bool), 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))
- 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 int
- var vp *bytesI
- for k2, _ := range v {
- l = len(mksv)
- e2.MustEncode(k2)
- vp = &v2[i]
- vp.v = mksv[l:]
- vp.i = k2
- i++
- }
- sort.Sort(bytesISlice(v2))
- if esep {
- for j := range v2 {
- ee.WriteMapElemKey()
- e.asis(v2[j].v)
- ee.WriteMapElemValue()
- e.encode(v[v2[j].i])
- }
- } else {
- for j := range v2 {
- e.asis(v2[j].v)
- e.encode(v[v2[j].i])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- e.encode(k2)
- ee.WriteMapElemValue()
- ee.EncodeBool(v2)
- }
- } else {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeBool(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapStringIntfR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapStringIntfV(rv2i(rv).(map[string]interface{}), 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))
- if e.h.Canonical {
- v2 := make([]string, len(v))
- var i int
- for k, _ := range v {
- v2[i] = string(k)
- i++
- }
- sort.Sort(stringSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeString(cUTF8, k2)
- ee.WriteMapElemValue()
- e.encode(v[string(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeString(cUTF8, k2)
- e.encode(v[string(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeString(cUTF8, k2)
- ee.WriteMapElemValue()
- e.encode(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeString(cUTF8, k2)
- e.encode(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapStringStringR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapStringStringV(rv2i(rv).(map[string]string), 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))
- if e.h.Canonical {
- v2 := make([]string, len(v))
- var i int
- for k, _ := range v {
- v2[i] = string(k)
- i++
- }
- sort.Sort(stringSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeString(cUTF8, k2)
- ee.WriteMapElemValue()
- ee.EncodeString(cUTF8, v[string(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeString(cUTF8, k2)
- ee.EncodeString(cUTF8, v[string(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeString(cUTF8, k2)
- ee.WriteMapElemValue()
- ee.EncodeString(cUTF8, v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeString(cUTF8, k2)
- ee.EncodeString(cUTF8, v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapStringUintR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapStringUintV(rv2i(rv).(map[string]uint), 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))
- if e.h.Canonical {
- v2 := make([]string, len(v))
- var i int
- for k, _ := range v {
- v2[i] = string(k)
- i++
- }
- sort.Sort(stringSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeString(cUTF8, k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[string(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeString(cUTF8, k2)
- ee.EncodeUint(uint64(v[string(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeString(cUTF8, k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeString(cUTF8, k2)
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapStringUint8R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapStringUint8V(rv2i(rv).(map[string]uint8), 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))
- if e.h.Canonical {
- v2 := make([]string, len(v))
- var i int
- for k, _ := range v {
- v2[i] = string(k)
- i++
- }
- sort.Sort(stringSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeString(cUTF8, k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[string(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeString(cUTF8, k2)
- ee.EncodeUint(uint64(v[string(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeString(cUTF8, k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeString(cUTF8, k2)
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapStringUint16R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapStringUint16V(rv2i(rv).(map[string]uint16), 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))
- if e.h.Canonical {
- v2 := make([]string, len(v))
- var i int
- for k, _ := range v {
- v2[i] = string(k)
- i++
- }
- sort.Sort(stringSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeString(cUTF8, k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[string(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeString(cUTF8, k2)
- ee.EncodeUint(uint64(v[string(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeString(cUTF8, k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeString(cUTF8, k2)
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapStringUint32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapStringUint32V(rv2i(rv).(map[string]uint32), 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))
- if e.h.Canonical {
- v2 := make([]string, len(v))
- var i int
- for k, _ := range v {
- v2[i] = string(k)
- i++
- }
- sort.Sort(stringSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeString(cUTF8, k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[string(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeString(cUTF8, k2)
- ee.EncodeUint(uint64(v[string(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeString(cUTF8, k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeString(cUTF8, k2)
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapStringUint64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapStringUint64V(rv2i(rv).(map[string]uint64), 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))
- if e.h.Canonical {
- v2 := make([]string, len(v))
- var i int
- for k, _ := range v {
- v2[i] = string(k)
- i++
- }
- sort.Sort(stringSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeString(cUTF8, k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[string(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeString(cUTF8, k2)
- ee.EncodeUint(uint64(v[string(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeString(cUTF8, k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeString(cUTF8, k2)
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapStringUintptrR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapStringUintptrV(rv2i(rv).(map[string]uintptr), 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))
- if e.h.Canonical {
- v2 := make([]string, len(v))
- var i int
- for k, _ := range v {
- v2[i] = string(k)
- i++
- }
- sort.Sort(stringSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeString(cUTF8, k2)
- ee.WriteMapElemValue()
- e.encode(v[string(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeString(cUTF8, k2)
- e.encode(v[string(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeString(cUTF8, k2)
- ee.WriteMapElemValue()
- e.encode(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeString(cUTF8, k2)
- e.encode(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapStringIntR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapStringIntV(rv2i(rv).(map[string]int), 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))
- if e.h.Canonical {
- v2 := make([]string, len(v))
- var i int
- for k, _ := range v {
- v2[i] = string(k)
- i++
- }
- sort.Sort(stringSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeString(cUTF8, k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[string(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeString(cUTF8, k2)
- ee.EncodeInt(int64(v[string(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeString(cUTF8, k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeString(cUTF8, k2)
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapStringInt8R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapStringInt8V(rv2i(rv).(map[string]int8), 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))
- if e.h.Canonical {
- v2 := make([]string, len(v))
- var i int
- for k, _ := range v {
- v2[i] = string(k)
- i++
- }
- sort.Sort(stringSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeString(cUTF8, k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[string(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeString(cUTF8, k2)
- ee.EncodeInt(int64(v[string(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeString(cUTF8, k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeString(cUTF8, k2)
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapStringInt16R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapStringInt16V(rv2i(rv).(map[string]int16), 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))
- if e.h.Canonical {
- v2 := make([]string, len(v))
- var i int
- for k, _ := range v {
- v2[i] = string(k)
- i++
- }
- sort.Sort(stringSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeString(cUTF8, k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[string(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeString(cUTF8, k2)
- ee.EncodeInt(int64(v[string(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeString(cUTF8, k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeString(cUTF8, k2)
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapStringInt32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapStringInt32V(rv2i(rv).(map[string]int32), 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))
- if e.h.Canonical {
- v2 := make([]string, len(v))
- var i int
- for k, _ := range v {
- v2[i] = string(k)
- i++
- }
- sort.Sort(stringSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeString(cUTF8, k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[string(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeString(cUTF8, k2)
- ee.EncodeInt(int64(v[string(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeString(cUTF8, k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeString(cUTF8, k2)
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapStringInt64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapStringInt64V(rv2i(rv).(map[string]int64), 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))
- if e.h.Canonical {
- v2 := make([]string, len(v))
- var i int
- for k, _ := range v {
- v2[i] = string(k)
- i++
- }
- sort.Sort(stringSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeString(cUTF8, k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[string(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeString(cUTF8, k2)
- ee.EncodeInt(int64(v[string(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeString(cUTF8, k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeString(cUTF8, k2)
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapStringFloat32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapStringFloat32V(rv2i(rv).(map[string]float32), 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))
- if e.h.Canonical {
- v2 := make([]string, len(v))
- var i int
- for k, _ := range v {
- v2[i] = string(k)
- i++
- }
- sort.Sort(stringSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeString(cUTF8, k2)
- ee.WriteMapElemValue()
- ee.EncodeFloat32(v[string(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeString(cUTF8, k2)
- ee.EncodeFloat32(v[string(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeString(cUTF8, k2)
- ee.WriteMapElemValue()
- ee.EncodeFloat32(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeString(cUTF8, k2)
- ee.EncodeFloat32(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapStringFloat64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapStringFloat64V(rv2i(rv).(map[string]float64), 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))
- if e.h.Canonical {
- v2 := make([]string, len(v))
- var i int
- for k, _ := range v {
- v2[i] = string(k)
- i++
- }
- sort.Sort(stringSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeString(cUTF8, k2)
- ee.WriteMapElemValue()
- ee.EncodeFloat64(v[string(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeString(cUTF8, k2)
- ee.EncodeFloat64(v[string(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeString(cUTF8, k2)
- ee.WriteMapElemValue()
- ee.EncodeFloat64(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeString(cUTF8, k2)
- ee.EncodeFloat64(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapStringBoolR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapStringBoolV(rv2i(rv).(map[string]bool), 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))
- if e.h.Canonical {
- v2 := make([]string, len(v))
- var i int
- for k, _ := range v {
- v2[i] = string(k)
- i++
- }
- sort.Sort(stringSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeString(cUTF8, k2)
- ee.WriteMapElemValue()
- ee.EncodeBool(v[string(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeString(cUTF8, k2)
- ee.EncodeBool(v[string(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeString(cUTF8, k2)
- ee.WriteMapElemValue()
- ee.EncodeBool(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeString(cUTF8, k2)
- ee.EncodeBool(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapFloat32IntfR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapFloat32IntfV(rv2i(rv).(map[float32]interface{}), 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))
- if e.h.Canonical {
- v2 := make([]float64, len(v))
- var i int
- for k, _ := range v {
- v2[i] = float64(k)
- i++
- }
- sort.Sort(floatSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeFloat32(float32(k2))
- ee.WriteMapElemValue()
- e.encode(v[float32(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeFloat32(float32(k2))
- e.encode(v[float32(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeFloat32(k2)
- ee.WriteMapElemValue()
- e.encode(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeFloat32(k2)
- e.encode(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapFloat32StringR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapFloat32StringV(rv2i(rv).(map[float32]string), 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))
- if e.h.Canonical {
- v2 := make([]float64, len(v))
- var i int
- for k, _ := range v {
- v2[i] = float64(k)
- i++
- }
- sort.Sort(floatSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeFloat32(float32(k2))
- ee.WriteMapElemValue()
- ee.EncodeString(cUTF8, v[float32(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeFloat32(float32(k2))
- ee.EncodeString(cUTF8, v[float32(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeFloat32(k2)
- ee.WriteMapElemValue()
- ee.EncodeString(cUTF8, v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeFloat32(k2)
- ee.EncodeString(cUTF8, v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapFloat32UintR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapFloat32UintV(rv2i(rv).(map[float32]uint), 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))
- if e.h.Canonical {
- v2 := make([]float64, len(v))
- var i int
- for k, _ := range v {
- v2[i] = float64(k)
- i++
- }
- sort.Sort(floatSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeFloat32(float32(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[float32(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeFloat32(float32(k2))
- ee.EncodeUint(uint64(v[float32(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeFloat32(k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeFloat32(k2)
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapFloat32Uint8R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapFloat32Uint8V(rv2i(rv).(map[float32]uint8), 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))
- if e.h.Canonical {
- v2 := make([]float64, len(v))
- var i int
- for k, _ := range v {
- v2[i] = float64(k)
- i++
- }
- sort.Sort(floatSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeFloat32(float32(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[float32(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeFloat32(float32(k2))
- ee.EncodeUint(uint64(v[float32(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeFloat32(k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeFloat32(k2)
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapFloat32Uint16R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapFloat32Uint16V(rv2i(rv).(map[float32]uint16), 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))
- if e.h.Canonical {
- v2 := make([]float64, len(v))
- var i int
- for k, _ := range v {
- v2[i] = float64(k)
- i++
- }
- sort.Sort(floatSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeFloat32(float32(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[float32(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeFloat32(float32(k2))
- ee.EncodeUint(uint64(v[float32(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeFloat32(k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeFloat32(k2)
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapFloat32Uint32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapFloat32Uint32V(rv2i(rv).(map[float32]uint32), 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))
- if e.h.Canonical {
- v2 := make([]float64, len(v))
- var i int
- for k, _ := range v {
- v2[i] = float64(k)
- i++
- }
- sort.Sort(floatSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeFloat32(float32(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[float32(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeFloat32(float32(k2))
- ee.EncodeUint(uint64(v[float32(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeFloat32(k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeFloat32(k2)
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapFloat32Uint64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapFloat32Uint64V(rv2i(rv).(map[float32]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))
- if e.h.Canonical {
- v2 := make([]float64, len(v))
- var i int
- for k, _ := range v {
- v2[i] = float64(k)
- i++
- }
- sort.Sort(floatSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeFloat32(float32(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[float32(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeFloat32(float32(k2))
- ee.EncodeUint(uint64(v[float32(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeFloat32(k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeFloat32(k2)
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapFloat32UintptrR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapFloat32UintptrV(rv2i(rv).(map[float32]uintptr), 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))
- if e.h.Canonical {
- v2 := make([]float64, len(v))
- var i int
- for k, _ := range v {
- v2[i] = float64(k)
- i++
- }
- sort.Sort(floatSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeFloat32(float32(k2))
- ee.WriteMapElemValue()
- e.encode(v[float32(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeFloat32(float32(k2))
- e.encode(v[float32(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeFloat32(k2)
- ee.WriteMapElemValue()
- e.encode(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeFloat32(k2)
- e.encode(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapFloat32IntR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapFloat32IntV(rv2i(rv).(map[float32]int), 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))
- if e.h.Canonical {
- v2 := make([]float64, len(v))
- var i int
- for k, _ := range v {
- v2[i] = float64(k)
- i++
- }
- sort.Sort(floatSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeFloat32(float32(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[float32(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeFloat32(float32(k2))
- ee.EncodeInt(int64(v[float32(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeFloat32(k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeFloat32(k2)
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapFloat32Int8R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapFloat32Int8V(rv2i(rv).(map[float32]int8), 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))
- if e.h.Canonical {
- v2 := make([]float64, len(v))
- var i int
- for k, _ := range v {
- v2[i] = float64(k)
- i++
- }
- sort.Sort(floatSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeFloat32(float32(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[float32(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeFloat32(float32(k2))
- ee.EncodeInt(int64(v[float32(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeFloat32(k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeFloat32(k2)
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapFloat32Int16R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapFloat32Int16V(rv2i(rv).(map[float32]int16), 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))
- if e.h.Canonical {
- v2 := make([]float64, len(v))
- var i int
- for k, _ := range v {
- v2[i] = float64(k)
- i++
- }
- sort.Sort(floatSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeFloat32(float32(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[float32(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeFloat32(float32(k2))
- ee.EncodeInt(int64(v[float32(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeFloat32(k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeFloat32(k2)
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapFloat32Int32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapFloat32Int32V(rv2i(rv).(map[float32]int32), 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))
- if e.h.Canonical {
- v2 := make([]float64, len(v))
- var i int
- for k, _ := range v {
- v2[i] = float64(k)
- i++
- }
- sort.Sort(floatSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeFloat32(float32(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[float32(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeFloat32(float32(k2))
- ee.EncodeInt(int64(v[float32(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeFloat32(k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeFloat32(k2)
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapFloat32Int64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapFloat32Int64V(rv2i(rv).(map[float32]int64), 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))
- if e.h.Canonical {
- v2 := make([]float64, len(v))
- var i int
- for k, _ := range v {
- v2[i] = float64(k)
- i++
- }
- sort.Sort(floatSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeFloat32(float32(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[float32(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeFloat32(float32(k2))
- ee.EncodeInt(int64(v[float32(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeFloat32(k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeFloat32(k2)
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapFloat32Float32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapFloat32Float32V(rv2i(rv).(map[float32]float32), 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))
- if e.h.Canonical {
- v2 := make([]float64, len(v))
- var i int
- for k, _ := range v {
- v2[i] = float64(k)
- i++
- }
- sort.Sort(floatSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeFloat32(float32(k2))
- ee.WriteMapElemValue()
- ee.EncodeFloat32(v[float32(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeFloat32(float32(k2))
- ee.EncodeFloat32(v[float32(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeFloat32(k2)
- ee.WriteMapElemValue()
- ee.EncodeFloat32(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeFloat32(k2)
- ee.EncodeFloat32(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapFloat32Float64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapFloat32Float64V(rv2i(rv).(map[float32]float64), 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))
- if e.h.Canonical {
- v2 := make([]float64, len(v))
- var i int
- for k, _ := range v {
- v2[i] = float64(k)
- i++
- }
- sort.Sort(floatSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeFloat32(float32(k2))
- ee.WriteMapElemValue()
- ee.EncodeFloat64(v[float32(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeFloat32(float32(k2))
- ee.EncodeFloat64(v[float32(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeFloat32(k2)
- ee.WriteMapElemValue()
- ee.EncodeFloat64(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeFloat32(k2)
- ee.EncodeFloat64(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapFloat32BoolR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapFloat32BoolV(rv2i(rv).(map[float32]bool), 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))
- if e.h.Canonical {
- v2 := make([]float64, len(v))
- var i int
- for k, _ := range v {
- v2[i] = float64(k)
- i++
- }
- sort.Sort(floatSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeFloat32(float32(k2))
- ee.WriteMapElemValue()
- ee.EncodeBool(v[float32(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeFloat32(float32(k2))
- ee.EncodeBool(v[float32(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeFloat32(k2)
- ee.WriteMapElemValue()
- ee.EncodeBool(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeFloat32(k2)
- ee.EncodeBool(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapFloat64IntfR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapFloat64IntfV(rv2i(rv).(map[float64]interface{}), 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))
- if e.h.Canonical {
- v2 := make([]float64, len(v))
- var i int
- for k, _ := range v {
- v2[i] = float64(k)
- i++
- }
- sort.Sort(floatSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeFloat64(float64(k2))
- ee.WriteMapElemValue()
- e.encode(v[float64(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeFloat64(float64(k2))
- e.encode(v[float64(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeFloat64(k2)
- ee.WriteMapElemValue()
- e.encode(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeFloat64(k2)
- e.encode(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapFloat64StringR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapFloat64StringV(rv2i(rv).(map[float64]string), 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))
- if e.h.Canonical {
- v2 := make([]float64, len(v))
- var i int
- for k, _ := range v {
- v2[i] = float64(k)
- i++
- }
- sort.Sort(floatSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeFloat64(float64(k2))
- ee.WriteMapElemValue()
- ee.EncodeString(cUTF8, v[float64(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeFloat64(float64(k2))
- ee.EncodeString(cUTF8, v[float64(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeFloat64(k2)
- ee.WriteMapElemValue()
- ee.EncodeString(cUTF8, v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeFloat64(k2)
- ee.EncodeString(cUTF8, v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapFloat64UintR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapFloat64UintV(rv2i(rv).(map[float64]uint), 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))
- if e.h.Canonical {
- v2 := make([]float64, len(v))
- var i int
- for k, _ := range v {
- v2[i] = float64(k)
- i++
- }
- sort.Sort(floatSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeFloat64(float64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[float64(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeFloat64(float64(k2))
- ee.EncodeUint(uint64(v[float64(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeFloat64(k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeFloat64(k2)
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapFloat64Uint8R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapFloat64Uint8V(rv2i(rv).(map[float64]uint8), 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))
- if e.h.Canonical {
- v2 := make([]float64, len(v))
- var i int
- for k, _ := range v {
- v2[i] = float64(k)
- i++
- }
- sort.Sort(floatSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeFloat64(float64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[float64(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeFloat64(float64(k2))
- ee.EncodeUint(uint64(v[float64(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeFloat64(k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeFloat64(k2)
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapFloat64Uint16R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapFloat64Uint16V(rv2i(rv).(map[float64]uint16), 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))
- if e.h.Canonical {
- v2 := make([]float64, len(v))
- var i int
- for k, _ := range v {
- v2[i] = float64(k)
- i++
- }
- sort.Sort(floatSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeFloat64(float64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[float64(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeFloat64(float64(k2))
- ee.EncodeUint(uint64(v[float64(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeFloat64(k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeFloat64(k2)
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapFloat64Uint32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapFloat64Uint32V(rv2i(rv).(map[float64]uint32), 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))
- if e.h.Canonical {
- v2 := make([]float64, len(v))
- var i int
- for k, _ := range v {
- v2[i] = float64(k)
- i++
- }
- sort.Sort(floatSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeFloat64(float64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[float64(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeFloat64(float64(k2))
- ee.EncodeUint(uint64(v[float64(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeFloat64(k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeFloat64(k2)
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapFloat64Uint64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapFloat64Uint64V(rv2i(rv).(map[float64]uint64), 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))
- if e.h.Canonical {
- v2 := make([]float64, len(v))
- var i int
- for k, _ := range v {
- v2[i] = float64(k)
- i++
- }
- sort.Sort(floatSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeFloat64(float64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[float64(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeFloat64(float64(k2))
- ee.EncodeUint(uint64(v[float64(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeFloat64(k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeFloat64(k2)
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapFloat64UintptrR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapFloat64UintptrV(rv2i(rv).(map[float64]uintptr), 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))
- if e.h.Canonical {
- v2 := make([]float64, len(v))
- var i int
- for k, _ := range v {
- v2[i] = float64(k)
- i++
- }
- sort.Sort(floatSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeFloat64(float64(k2))
- ee.WriteMapElemValue()
- e.encode(v[float64(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeFloat64(float64(k2))
- e.encode(v[float64(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeFloat64(k2)
- ee.WriteMapElemValue()
- e.encode(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeFloat64(k2)
- e.encode(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapFloat64IntR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapFloat64IntV(rv2i(rv).(map[float64]int), 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))
- if e.h.Canonical {
- v2 := make([]float64, len(v))
- var i int
- for k, _ := range v {
- v2[i] = float64(k)
- i++
- }
- sort.Sort(floatSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeFloat64(float64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[float64(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeFloat64(float64(k2))
- ee.EncodeInt(int64(v[float64(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeFloat64(k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeFloat64(k2)
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapFloat64Int8R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapFloat64Int8V(rv2i(rv).(map[float64]int8), 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))
- if e.h.Canonical {
- v2 := make([]float64, len(v))
- var i int
- for k, _ := range v {
- v2[i] = float64(k)
- i++
- }
- sort.Sort(floatSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeFloat64(float64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[float64(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeFloat64(float64(k2))
- ee.EncodeInt(int64(v[float64(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeFloat64(k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeFloat64(k2)
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapFloat64Int16R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapFloat64Int16V(rv2i(rv).(map[float64]int16), 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))
- if e.h.Canonical {
- v2 := make([]float64, len(v))
- var i int
- for k, _ := range v {
- v2[i] = float64(k)
- i++
- }
- sort.Sort(floatSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeFloat64(float64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[float64(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeFloat64(float64(k2))
- ee.EncodeInt(int64(v[float64(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeFloat64(k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeFloat64(k2)
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapFloat64Int32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapFloat64Int32V(rv2i(rv).(map[float64]int32), 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))
- if e.h.Canonical {
- v2 := make([]float64, len(v))
- var i int
- for k, _ := range v {
- v2[i] = float64(k)
- i++
- }
- sort.Sort(floatSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeFloat64(float64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[float64(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeFloat64(float64(k2))
- ee.EncodeInt(int64(v[float64(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeFloat64(k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeFloat64(k2)
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapFloat64Int64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapFloat64Int64V(rv2i(rv).(map[float64]int64), 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))
- if e.h.Canonical {
- v2 := make([]float64, len(v))
- var i int
- for k, _ := range v {
- v2[i] = float64(k)
- i++
- }
- sort.Sort(floatSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeFloat64(float64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[float64(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeFloat64(float64(k2))
- ee.EncodeInt(int64(v[float64(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeFloat64(k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeFloat64(k2)
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapFloat64Float32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapFloat64Float32V(rv2i(rv).(map[float64]float32), 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))
- if e.h.Canonical {
- v2 := make([]float64, len(v))
- var i int
- for k, _ := range v {
- v2[i] = float64(k)
- i++
- }
- sort.Sort(floatSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeFloat64(float64(k2))
- ee.WriteMapElemValue()
- ee.EncodeFloat32(v[float64(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeFloat64(float64(k2))
- ee.EncodeFloat32(v[float64(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeFloat64(k2)
- ee.WriteMapElemValue()
- ee.EncodeFloat32(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeFloat64(k2)
- ee.EncodeFloat32(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapFloat64Float64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapFloat64Float64V(rv2i(rv).(map[float64]float64), 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))
- if e.h.Canonical {
- v2 := make([]float64, len(v))
- var i int
- for k, _ := range v {
- v2[i] = float64(k)
- i++
- }
- sort.Sort(floatSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeFloat64(float64(k2))
- ee.WriteMapElemValue()
- ee.EncodeFloat64(v[float64(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeFloat64(float64(k2))
- ee.EncodeFloat64(v[float64(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeFloat64(k2)
- ee.WriteMapElemValue()
- ee.EncodeFloat64(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeFloat64(k2)
- ee.EncodeFloat64(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapFloat64BoolR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapFloat64BoolV(rv2i(rv).(map[float64]bool), 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))
- if e.h.Canonical {
- v2 := make([]float64, len(v))
- var i int
- for k, _ := range v {
- v2[i] = float64(k)
- i++
- }
- sort.Sort(floatSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeFloat64(float64(k2))
- ee.WriteMapElemValue()
- ee.EncodeBool(v[float64(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeFloat64(float64(k2))
- ee.EncodeBool(v[float64(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeFloat64(k2)
- ee.WriteMapElemValue()
- ee.EncodeBool(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeFloat64(k2)
- ee.EncodeBool(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUintIntfR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUintIntfV(rv2i(rv).(map[uint]interface{}), 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))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i int
- for k, _ := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint(k2)))
- ee.WriteMapElemValue()
- e.encode(v[uint(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint(k2)))
- e.encode(v[uint(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- e.encode(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- e.encode(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUintStringR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUintStringV(rv2i(rv).(map[uint]string), 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))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i int
- for k, _ := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint(k2)))
- ee.WriteMapElemValue()
- ee.EncodeString(cUTF8, v[uint(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint(k2)))
- ee.EncodeString(cUTF8, v[uint(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeString(cUTF8, v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeString(cUTF8, v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-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 int
- for k, _ := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[uint(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint(k2)))
- ee.EncodeUint(uint64(v[uint(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) 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 int
- for k, _ := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[uint(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint(k2)))
- ee.EncodeUint(uint64(v[uint(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) 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 int
- for k, _ := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[uint(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint(k2)))
- ee.EncodeUint(uint64(v[uint(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) 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 int
- for k, _ := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[uint(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint(k2)))
- ee.EncodeUint(uint64(v[uint(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) 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 int
- for k, _ := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[uint(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint(k2)))
- ee.EncodeUint(uint64(v[uint(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) 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 int
- for k, _ := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint(k2)))
- ee.WriteMapElemValue()
- e.encode(v[uint(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint(k2)))
- e.encode(v[uint(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- e.encode(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- e.encode(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) 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 int
- for k, _ := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[uint(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint(k2)))
- ee.EncodeInt(int64(v[uint(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) 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 int
- for k, _ := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[uint(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint(k2)))
- ee.EncodeInt(int64(v[uint(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) 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 int
- for k, _ := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[uint(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint(k2)))
- ee.EncodeInt(int64(v[uint(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) 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 int
- for k, _ := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[uint(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint(k2)))
- ee.EncodeInt(int64(v[uint(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) 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 int
- for k, _ := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[uint(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint(k2)))
- ee.EncodeInt(int64(v[uint(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) 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 int
- for k, _ := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint(k2)))
- ee.WriteMapElemValue()
- ee.EncodeFloat32(v[uint(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint(k2)))
- ee.EncodeFloat32(v[uint(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeFloat32(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeFloat32(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) 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 int
- for k, _ := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint(k2)))
- ee.WriteMapElemValue()
- ee.EncodeFloat64(v[uint(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint(k2)))
- ee.EncodeFloat64(v[uint(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeFloat64(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeFloat64(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) 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 int
- for k, _ := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint(k2)))
- ee.WriteMapElemValue()
- ee.EncodeBool(v[uint(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint(k2)))
- ee.EncodeBool(v[uint(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeBool(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeBool(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) 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 int
- for k, _ := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint8(k2)))
- ee.WriteMapElemValue()
- e.encode(v[uint8(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint8(k2)))
- e.encode(v[uint8(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- e.encode(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- e.encode(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) 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 int
- for k, _ := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint8(k2)))
- ee.WriteMapElemValue()
- ee.EncodeString(cUTF8, v[uint8(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint8(k2)))
- ee.EncodeString(cUTF8, v[uint8(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeString(cUTF8, v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeString(cUTF8, v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint8UintR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint8UintV(rv2i(rv).(map[uint8]uint), e)
-}
-func (_ fastpathT) EncMapUint8UintV(v map[uint8]uint, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i int
- for k, _ := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint8(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[uint8(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint8(k2)))
- ee.EncodeUint(uint64(v[uint8(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint8Uint8R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint8Uint8V(rv2i(rv).(map[uint8]uint8), e)
-}
-func (_ fastpathT) EncMapUint8Uint8V(v map[uint8]uint8, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i int
- for k, _ := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint8(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[uint8(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint8(k2)))
- ee.EncodeUint(uint64(v[uint8(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint8Uint16R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint8Uint16V(rv2i(rv).(map[uint8]uint16), e)
-}
-func (_ fastpathT) EncMapUint8Uint16V(v map[uint8]uint16, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i int
- for k, _ := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint8(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[uint8(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint8(k2)))
- ee.EncodeUint(uint64(v[uint8(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint8Uint32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint8Uint32V(rv2i(rv).(map[uint8]uint32), e)
-}
-func (_ fastpathT) EncMapUint8Uint32V(v map[uint8]uint32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i int
- for k, _ := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint8(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[uint8(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint8(k2)))
- ee.EncodeUint(uint64(v[uint8(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint8Uint64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint8Uint64V(rv2i(rv).(map[uint8]uint64), e)
-}
-func (_ fastpathT) EncMapUint8Uint64V(v map[uint8]uint64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i int
- for k, _ := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint8(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[uint8(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint8(k2)))
- ee.EncodeUint(uint64(v[uint8(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint8UintptrR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint8UintptrV(rv2i(rv).(map[uint8]uintptr), e)
-}
-func (_ fastpathT) EncMapUint8UintptrV(v map[uint8]uintptr, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i int
- for k, _ := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint8(k2)))
- ee.WriteMapElemValue()
- e.encode(v[uint8(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint8(k2)))
- e.encode(v[uint8(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- e.encode(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- e.encode(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint8IntR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint8IntV(rv2i(rv).(map[uint8]int), e)
-}
-func (_ fastpathT) EncMapUint8IntV(v map[uint8]int, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i int
- for k, _ := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint8(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[uint8(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint8(k2)))
- ee.EncodeInt(int64(v[uint8(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint8Int8R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint8Int8V(rv2i(rv).(map[uint8]int8), e)
-}
-func (_ fastpathT) EncMapUint8Int8V(v map[uint8]int8, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i int
- for k, _ := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint8(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[uint8(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint8(k2)))
- ee.EncodeInt(int64(v[uint8(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint8Int16R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint8Int16V(rv2i(rv).(map[uint8]int16), e)
-}
-func (_ fastpathT) EncMapUint8Int16V(v map[uint8]int16, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i int
- for k, _ := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint8(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[uint8(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint8(k2)))
- ee.EncodeInt(int64(v[uint8(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint8Int32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint8Int32V(rv2i(rv).(map[uint8]int32), e)
-}
-func (_ fastpathT) EncMapUint8Int32V(v map[uint8]int32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i int
- for k, _ := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint8(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[uint8(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint8(k2)))
- ee.EncodeInt(int64(v[uint8(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint8Int64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint8Int64V(rv2i(rv).(map[uint8]int64), e)
-}
-func (_ fastpathT) EncMapUint8Int64V(v map[uint8]int64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i int
- for k, _ := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint8(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[uint8(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint8(k2)))
- ee.EncodeInt(int64(v[uint8(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint8Float32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint8Float32V(rv2i(rv).(map[uint8]float32), e)
-}
-func (_ fastpathT) EncMapUint8Float32V(v map[uint8]float32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i int
- for k, _ := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint8(k2)))
- ee.WriteMapElemValue()
- ee.EncodeFloat32(v[uint8(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint8(k2)))
- ee.EncodeFloat32(v[uint8(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeFloat32(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeFloat32(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint8Float64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint8Float64V(rv2i(rv).(map[uint8]float64), e)
-}
-func (_ fastpathT) EncMapUint8Float64V(v map[uint8]float64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i int
- for k, _ := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint8(k2)))
- ee.WriteMapElemValue()
- ee.EncodeFloat64(v[uint8(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint8(k2)))
- ee.EncodeFloat64(v[uint8(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeFloat64(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeFloat64(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint8BoolR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint8BoolV(rv2i(rv).(map[uint8]bool), e)
-}
-func (_ fastpathT) EncMapUint8BoolV(v map[uint8]bool, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i int
- for k, _ := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint8(k2)))
- ee.WriteMapElemValue()
- ee.EncodeBool(v[uint8(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint8(k2)))
- ee.EncodeBool(v[uint8(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeBool(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeBool(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint16IntfR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint16IntfV(rv2i(rv).(map[uint16]interface{}), e)
-}
-func (_ fastpathT) EncMapUint16IntfV(v map[uint16]interface{}, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i int
- for k, _ := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint16(k2)))
- ee.WriteMapElemValue()
- e.encode(v[uint16(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint16(k2)))
- e.encode(v[uint16(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- e.encode(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- e.encode(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint16StringR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint16StringV(rv2i(rv).(map[uint16]string), e)
-}
-func (_ fastpathT) EncMapUint16StringV(v map[uint16]string, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i int
- for k, _ := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint16(k2)))
- ee.WriteMapElemValue()
- ee.EncodeString(cUTF8, v[uint16(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint16(k2)))
- ee.EncodeString(cUTF8, v[uint16(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeString(cUTF8, v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeString(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 int
- for k, _ := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint16(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[uint16(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint16(k2)))
- ee.EncodeUint(uint64(v[uint16(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint16Uint8R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint16Uint8V(rv2i(rv).(map[uint16]uint8), e)
-}
-func (_ fastpathT) EncMapUint16Uint8V(v map[uint16]uint8, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i int
- for k, _ := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint16(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[uint16(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint16(k2)))
- ee.EncodeUint(uint64(v[uint16(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint16Uint16R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint16Uint16V(rv2i(rv).(map[uint16]uint16), e)
-}
-func (_ fastpathT) EncMapUint16Uint16V(v map[uint16]uint16, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i int
- for k, _ := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint16(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[uint16(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint16(k2)))
- ee.EncodeUint(uint64(v[uint16(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint16Uint32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint16Uint32V(rv2i(rv).(map[uint16]uint32), e)
-}
-func (_ fastpathT) EncMapUint16Uint32V(v map[uint16]uint32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i int
- for k, _ := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint16(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[uint16(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint16(k2)))
- ee.EncodeUint(uint64(v[uint16(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint16Uint64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint16Uint64V(rv2i(rv).(map[uint16]uint64), e)
-}
-func (_ fastpathT) EncMapUint16Uint64V(v map[uint16]uint64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i int
- for k, _ := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint16(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[uint16(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint16(k2)))
- ee.EncodeUint(uint64(v[uint16(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint16UintptrR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint16UintptrV(rv2i(rv).(map[uint16]uintptr), e)
-}
-func (_ fastpathT) EncMapUint16UintptrV(v map[uint16]uintptr, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i int
- for k, _ := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint16(k2)))
- ee.WriteMapElemValue()
- e.encode(v[uint16(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint16(k2)))
- e.encode(v[uint16(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- e.encode(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- e.encode(v2)
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint16IntR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint16IntV(rv2i(rv).(map[uint16]int), e)
-}
-func (_ fastpathT) EncMapUint16IntV(v map[uint16]int, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i int
- for k, _ := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint16(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[uint16(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint16(k2)))
- ee.EncodeInt(int64(v[uint16(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
- }
- }
- }
- ee.WriteMapEnd()
-}
-
-func (e *Encoder) fastpathEncMapUint16Int8R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint16Int8V(rv2i(rv).(map[uint16]int8), e)
-}
-func (_ fastpathT) EncMapUint16Int8V(v map[uint16]int8, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
- return
- }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
- if e.h.Canonical {
- v2 := make([]uint64, len(v))
- var i int
- for k, _ := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint16(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[uint16(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint16(k2)))
- ee.EncodeInt(int64(v[uint16(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
- }
- }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
- ee.WriteMapEnd()
}
-func (e *Encoder) fastpathEncMapUint16Int16R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint16Int16V(rv2i(rv).(map[uint16]int16), e)
+func (f *encFnInfo) fastpathEncMapUint32IntfR(rv reflect.Value) {
+ fastpathTV.EncMapUint32IntfV(rv.Interface().(map[uint32]interface{}), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapUint16Int16V(v map[uint16]int16, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapUint32IntfV(v map[uint32]interface{}, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]uint64, len(v))
var i int
@@ -7589,96 +9335,44 @@ func (_ fastpathT) EncMapUint16Int16V(v map[uint16]int16, e *Encoder) {
i++
}
sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint16(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[uint16(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint16(k2)))
- ee.EncodeInt(int64(v[uint16(k2)]))
+ ee.EncodeUint(uint64(uint32(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ e.encode(v[uint32(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ e.encode(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 int
- for k, _ := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint16(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[uint16(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint16(k2)))
- ee.EncodeInt(int64(v[uint16(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
- }
- }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
- ee.WriteMapEnd()
}
-func (e *Encoder) fastpathEncMapUint16Int64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint16Int64V(rv2i(rv).(map[uint16]int64), e)
+func (f *encFnInfo) fastpathEncMapUint32StringR(rv reflect.Value) {
+ fastpathTV.EncMapUint32StringV(rv.Interface().(map[uint32]string), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapUint16Int64V(v map[uint16]int64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapUint32StringV(v map[uint32]string, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]uint64, len(v))
var i int
@@ -7687,96 +9381,44 @@ func (_ fastpathT) EncMapUint16Int64V(v map[uint16]int64, e *Encoder) {
i++
}
sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint16(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[uint16(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint16(k2)))
- ee.EncodeInt(int64(v[uint16(k2)]))
+ ee.EncodeUint(uint64(uint32(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeString(c_UTF8, v[uint32(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeString(c_UTF8, 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 int
- for k, _ := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint16(k2)))
- ee.WriteMapElemValue()
- ee.EncodeFloat32(v[uint16(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint16(k2)))
- ee.EncodeFloat32(v[uint16(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeFloat32(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeFloat32(v2)
- }
- }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
- ee.WriteMapEnd()
}
-func (e *Encoder) fastpathEncMapUint16Float64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint16Float64V(rv2i(rv).(map[uint16]float64), e)
+func (f *encFnInfo) fastpathEncMapUint32UintR(rv reflect.Value) {
+ fastpathTV.EncMapUint32UintV(rv.Interface().(map[uint32]uint), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapUint16Float64V(v map[uint16]float64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapUint32UintV(v map[uint32]uint, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]uint64, len(v))
var i int
@@ -7785,96 +9427,44 @@ func (_ fastpathT) EncMapUint16Float64V(v map[uint16]float64, e *Encoder) {
i++
}
sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint16(k2)))
- ee.WriteMapElemValue()
- ee.EncodeFloat64(v[uint16(k2)])
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint16(k2)))
- ee.EncodeFloat64(v[uint16(k2)])
+ ee.EncodeUint(uint64(uint32(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v[uint32(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeFloat64(v2)
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeFloat64(v2)
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(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 int
- for k, _ := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint16(k2)))
- ee.WriteMapElemValue()
- ee.EncodeBool(v[uint16(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint16(k2)))
- ee.EncodeBool(v[uint16(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeBool(v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeBool(v2)
- }
- }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
- ee.WriteMapEnd()
}
-func (e *Encoder) fastpathEncMapUint32IntfR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint32IntfV(rv2i(rv).(map[uint32]interface{}), e)
+func (f *encFnInfo) fastpathEncMapUint32Uint8R(rv reflect.Value) {
+ fastpathTV.EncMapUint32Uint8V(rv.Interface().(map[uint32]uint8), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapUint32IntfV(v map[uint32]interface{}, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapUint32Uint8V(v map[uint32]uint8, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]uint64, len(v))
var i int
@@ -7883,96 +9473,44 @@ func (_ fastpathT) EncMapUint32IntfV(v map[uint32]interface{}, e *Encoder) {
i++
}
sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint32(k2)))
- ee.WriteMapElemValue()
- e.encode(v[uint32(k2)])
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint32(k2)))
- e.encode(v[uint32(k2)])
+ ee.EncodeUint(uint64(uint32(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v[uint32(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- e.encode(v2)
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- e.encode(v2)
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(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 int
- for k, _ := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint32(k2)))
- ee.WriteMapElemValue()
- ee.EncodeString(cUTF8, v[uint32(k2)])
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint32(k2)))
- ee.EncodeString(cUTF8, v[uint32(k2)])
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeString(cUTF8, v2)
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeString(cUTF8, v2)
- }
- }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
- ee.WriteMapEnd()
}
-func (e *Encoder) fastpathEncMapUint32UintR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint32UintV(rv2i(rv).(map[uint32]uint), e)
+func (f *encFnInfo) fastpathEncMapUint32Uint16R(rv reflect.Value) {
+ fastpathTV.EncMapUint32Uint16V(rv.Interface().(map[uint32]uint16), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapUint32UintV(v map[uint32]uint, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapUint32Uint16V(v map[uint32]uint16, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]uint64, len(v))
var i int
@@ -7981,96 +9519,44 @@ func (_ fastpathT) EncMapUint32UintV(v map[uint32]uint, e *Encoder) {
i++
}
sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint32(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[uint32(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint32(k2)))
- ee.EncodeUint(uint64(v[uint32(k2)]))
+ ee.EncodeUint(uint64(uint32(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v[uint32(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ 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 int
- for k, _ := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint32(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[uint32(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint32(k2)))
- ee.EncodeUint(uint64(v[uint32(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
- }
- }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
- ee.WriteMapEnd()
}
-func (e *Encoder) fastpathEncMapUint32Uint16R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint32Uint16V(rv2i(rv).(map[uint32]uint16), e)
+func (f *encFnInfo) fastpathEncMapUint32Uint32R(rv reflect.Value) {
+ fastpathTV.EncMapUint32Uint32V(rv.Interface().(map[uint32]uint32), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapUint32Uint16V(v map[uint32]uint16, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapUint32Uint32V(v map[uint32]uint32, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]uint64, len(v))
var i int
@@ -8079,96 +9565,44 @@ func (_ fastpathT) EncMapUint32Uint16V(v map[uint32]uint16, e *Encoder) {
i++
}
sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint32(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[uint32(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint32(k2)))
- ee.EncodeUint(uint64(v[uint32(k2)]))
+ ee.EncodeUint(uint64(uint32(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v[uint32(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ 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 int
- for k, _ := range v {
- v2[i] = uint64(k)
- i++
- }
- sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint32(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[uint32(k2)]))
- }
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint32(k2)))
- ee.EncodeUint(uint64(v[uint32(k2)]))
- }
- }
- } else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
- }
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
- }
- }
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
}
- ee.WriteMapEnd()
}
-func (e *Encoder) fastpathEncMapUint32Uint64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint32Uint64V(rv2i(rv).(map[uint32]uint64), e)
+func (f *encFnInfo) fastpathEncMapUint32Uint64R(rv reflect.Value) {
+ fastpathTV.EncMapUint32Uint64V(rv.Interface().(map[uint32]uint64), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapUint32Uint64V(v map[uint32]uint64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapUint32Uint64V(v map[uint32]uint64, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]uint64, len(v))
var i int
@@ -8177,47 +9611,44 @@ func (_ fastpathT) EncMapUint32Uint64V(v map[uint32]uint64, e *Encoder) {
i++
}
sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint32(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[uint32(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint32(k2)))
- ee.EncodeUint(uint64(v[uint32(k2)]))
+ ee.EncodeUint(uint64(uint32(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v[uint32(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapUint32UintptrR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint32UintptrV(rv2i(rv).(map[uint32]uintptr), e)
+func (f *encFnInfo) fastpathEncMapUint32UintptrR(rv reflect.Value) {
+ fastpathTV.EncMapUint32UintptrV(rv.Interface().(map[uint32]uintptr), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapUint32UintptrV(v map[uint32]uintptr, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapUint32UintptrV(v map[uint32]uintptr, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]uint64, len(v))
var i int
@@ -8226,47 +9657,44 @@ func (_ fastpathT) EncMapUint32UintptrV(v map[uint32]uintptr, e *Encoder) {
i++
}
sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint32(k2)))
- ee.WriteMapElemValue()
- e.encode(v[uint32(k2)])
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint32(k2)))
- e.encode(v[uint32(k2)])
+ ee.EncodeUint(uint64(uint32(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ e.encode(v[uint32(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- e.encode(v2)
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- e.encode(v2)
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ e.encode(v2)
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapUint32IntR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint32IntV(rv2i(rv).(map[uint32]int), e)
+func (f *encFnInfo) fastpathEncMapUint32IntR(rv reflect.Value) {
+ fastpathTV.EncMapUint32IntV(rv.Interface().(map[uint32]int), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapUint32IntV(v map[uint32]int, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapUint32IntV(v map[uint32]int, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]uint64, len(v))
var i int
@@ -8275,47 +9703,44 @@ func (_ fastpathT) EncMapUint32IntV(v map[uint32]int, e *Encoder) {
i++
}
sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint32(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[uint32(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint32(k2)))
- ee.EncodeInt(int64(v[uint32(k2)]))
+ ee.EncodeUint(uint64(uint32(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v[uint32(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapUint32Int8R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint32Int8V(rv2i(rv).(map[uint32]int8), e)
+func (f *encFnInfo) fastpathEncMapUint32Int8R(rv reflect.Value) {
+ fastpathTV.EncMapUint32Int8V(rv.Interface().(map[uint32]int8), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapUint32Int8V(v map[uint32]int8, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapUint32Int8V(v map[uint32]int8, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]uint64, len(v))
var i int
@@ -8324,47 +9749,44 @@ func (_ fastpathT) EncMapUint32Int8V(v map[uint32]int8, e *Encoder) {
i++
}
sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint32(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[uint32(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint32(k2)))
- ee.EncodeInt(int64(v[uint32(k2)]))
+ ee.EncodeUint(uint64(uint32(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v[uint32(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapUint32Int16R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint32Int16V(rv2i(rv).(map[uint32]int16), e)
+func (f *encFnInfo) fastpathEncMapUint32Int16R(rv reflect.Value) {
+ fastpathTV.EncMapUint32Int16V(rv.Interface().(map[uint32]int16), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapUint32Int16V(v map[uint32]int16, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapUint32Int16V(v map[uint32]int16, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]uint64, len(v))
var i int
@@ -8373,47 +9795,44 @@ func (_ fastpathT) EncMapUint32Int16V(v map[uint32]int16, e *Encoder) {
i++
}
sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint32(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[uint32(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint32(k2)))
- ee.EncodeInt(int64(v[uint32(k2)]))
+ ee.EncodeUint(uint64(uint32(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v[uint32(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapUint32Int32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint32Int32V(rv2i(rv).(map[uint32]int32), e)
+func (f *encFnInfo) fastpathEncMapUint32Int32R(rv reflect.Value) {
+ fastpathTV.EncMapUint32Int32V(rv.Interface().(map[uint32]int32), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapUint32Int32V(v map[uint32]int32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapUint32Int32V(v map[uint32]int32, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]uint64, len(v))
var i int
@@ -8422,47 +9841,44 @@ func (_ fastpathT) EncMapUint32Int32V(v map[uint32]int32, e *Encoder) {
i++
}
sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint32(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[uint32(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint32(k2)))
- ee.EncodeInt(int64(v[uint32(k2)]))
+ ee.EncodeUint(uint64(uint32(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v[uint32(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapUint32Int64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint32Int64V(rv2i(rv).(map[uint32]int64), e)
+func (f *encFnInfo) fastpathEncMapUint32Int64R(rv reflect.Value) {
+ fastpathTV.EncMapUint32Int64V(rv.Interface().(map[uint32]int64), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapUint32Int64V(v map[uint32]int64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapUint32Int64V(v map[uint32]int64, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]uint64, len(v))
var i int
@@ -8471,47 +9887,44 @@ func (_ fastpathT) EncMapUint32Int64V(v map[uint32]int64, e *Encoder) {
i++
}
sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint32(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[uint32(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint32(k2)))
- ee.EncodeInt(int64(v[uint32(k2)]))
+ ee.EncodeUint(uint64(uint32(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v[uint32(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapUint32Float32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint32Float32V(rv2i(rv).(map[uint32]float32), e)
+func (f *encFnInfo) fastpathEncMapUint32Float32R(rv reflect.Value) {
+ fastpathTV.EncMapUint32Float32V(rv.Interface().(map[uint32]float32), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapUint32Float32V(v map[uint32]float32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapUint32Float32V(v map[uint32]float32, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]uint64, len(v))
var i int
@@ -8520,47 +9933,44 @@ func (_ fastpathT) EncMapUint32Float32V(v map[uint32]float32, e *Encoder) {
i++
}
sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint32(k2)))
- ee.WriteMapElemValue()
- ee.EncodeFloat32(v[uint32(k2)])
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint32(k2)))
- ee.EncodeFloat32(v[uint32(k2)])
+ ee.EncodeUint(uint64(uint32(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeFloat32(v[uint32(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeFloat32(v2)
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeFloat32(v2)
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeFloat32(v2)
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapUint32Float64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint32Float64V(rv2i(rv).(map[uint32]float64), e)
+func (f *encFnInfo) fastpathEncMapUint32Float64R(rv reflect.Value) {
+ fastpathTV.EncMapUint32Float64V(rv.Interface().(map[uint32]float64), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapUint32Float64V(v map[uint32]float64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapUint32Float64V(v map[uint32]float64, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]uint64, len(v))
var i int
@@ -8569,47 +9979,44 @@ func (_ fastpathT) EncMapUint32Float64V(v map[uint32]float64, e *Encoder) {
i++
}
sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint32(k2)))
- ee.WriteMapElemValue()
- ee.EncodeFloat64(v[uint32(k2)])
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint32(k2)))
- ee.EncodeFloat64(v[uint32(k2)])
+ ee.EncodeUint(uint64(uint32(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeFloat64(v[uint32(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeFloat64(v2)
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeFloat64(v2)
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeFloat64(v2)
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapUint32BoolR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint32BoolV(rv2i(rv).(map[uint32]bool), e)
+func (f *encFnInfo) fastpathEncMapUint32BoolR(rv reflect.Value) {
+ fastpathTV.EncMapUint32BoolV(rv.Interface().(map[uint32]bool), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapUint32BoolV(v map[uint32]bool, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapUint32BoolV(v map[uint32]bool, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]uint64, len(v))
var i int
@@ -8618,47 +10025,44 @@ func (_ fastpathT) EncMapUint32BoolV(v map[uint32]bool, e *Encoder) {
i++
}
sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint32(k2)))
- ee.WriteMapElemValue()
- ee.EncodeBool(v[uint32(k2)])
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint32(k2)))
- ee.EncodeBool(v[uint32(k2)])
+ ee.EncodeUint(uint64(uint32(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeBool(v[uint32(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeBool(v2)
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeBool(v2)
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeBool(v2)
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapUint64IntfR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint64IntfV(rv2i(rv).(map[uint64]interface{}), e)
+func (f *encFnInfo) fastpathEncMapUint64IntfR(rv reflect.Value) {
+ fastpathTV.EncMapUint64IntfV(rv.Interface().(map[uint64]interface{}), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapUint64IntfV(v map[uint64]interface{}, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapUint64IntfV(v map[uint64]interface{}, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]uint64, len(v))
var i int
@@ -8667,47 +10071,44 @@ func (_ fastpathT) EncMapUint64IntfV(v map[uint64]interface{}, e *Encoder) {
i++
}
sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint64(k2)))
- ee.WriteMapElemValue()
- e.encode(v[uint64(k2)])
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint64(k2)))
- e.encode(v[uint64(k2)])
+ ee.EncodeUint(uint64(uint64(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ e.encode(v[uint64(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- e.encode(v2)
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- e.encode(v2)
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ e.encode(v2)
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapUint64StringR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint64StringV(rv2i(rv).(map[uint64]string), e)
+func (f *encFnInfo) fastpathEncMapUint64StringR(rv reflect.Value) {
+ fastpathTV.EncMapUint64StringV(rv.Interface().(map[uint64]string), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapUint64StringV(v map[uint64]string, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapUint64StringV(v map[uint64]string, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]uint64, len(v))
var i int
@@ -8716,47 +10117,44 @@ func (_ fastpathT) EncMapUint64StringV(v map[uint64]string, e *Encoder) {
i++
}
sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint64(k2)))
- ee.WriteMapElemValue()
- ee.EncodeString(cUTF8, v[uint64(k2)])
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint64(k2)))
- ee.EncodeString(cUTF8, v[uint64(k2)])
+ ee.EncodeUint(uint64(uint64(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeString(c_UTF8, v[uint64(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeString(cUTF8, v2)
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeString(cUTF8, v2)
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeString(c_UTF8, v2)
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapUint64UintR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint64UintV(rv2i(rv).(map[uint64]uint), e)
+func (f *encFnInfo) fastpathEncMapUint64UintR(rv reflect.Value) {
+ fastpathTV.EncMapUint64UintV(rv.Interface().(map[uint64]uint), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapUint64UintV(v map[uint64]uint, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapUint64UintV(v map[uint64]uint, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]uint64, len(v))
var i int
@@ -8765,47 +10163,44 @@ func (_ fastpathT) EncMapUint64UintV(v map[uint64]uint, e *Encoder) {
i++
}
sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint64(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[uint64(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint64(k2)))
- ee.EncodeUint(uint64(v[uint64(k2)]))
+ ee.EncodeUint(uint64(uint64(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v[uint64(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapUint64Uint8R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint64Uint8V(rv2i(rv).(map[uint64]uint8), e)
+func (f *encFnInfo) fastpathEncMapUint64Uint8R(rv reflect.Value) {
+ fastpathTV.EncMapUint64Uint8V(rv.Interface().(map[uint64]uint8), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapUint64Uint8V(v map[uint64]uint8, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapUint64Uint8V(v map[uint64]uint8, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]uint64, len(v))
var i int
@@ -8814,47 +10209,44 @@ func (_ fastpathT) EncMapUint64Uint8V(v map[uint64]uint8, e *Encoder) {
i++
}
sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint64(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[uint64(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint64(k2)))
- ee.EncodeUint(uint64(v[uint64(k2)]))
+ ee.EncodeUint(uint64(uint64(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v[uint64(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapUint64Uint16R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint64Uint16V(rv2i(rv).(map[uint64]uint16), e)
+func (f *encFnInfo) fastpathEncMapUint64Uint16R(rv reflect.Value) {
+ fastpathTV.EncMapUint64Uint16V(rv.Interface().(map[uint64]uint16), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapUint64Uint16V(v map[uint64]uint16, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapUint64Uint16V(v map[uint64]uint16, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]uint64, len(v))
var i int
@@ -8863,47 +10255,44 @@ func (_ fastpathT) EncMapUint64Uint16V(v map[uint64]uint16, e *Encoder) {
i++
}
sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint64(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[uint64(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint64(k2)))
- ee.EncodeUint(uint64(v[uint64(k2)]))
+ ee.EncodeUint(uint64(uint64(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v[uint64(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapUint64Uint32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint64Uint32V(rv2i(rv).(map[uint64]uint32), e)
+func (f *encFnInfo) fastpathEncMapUint64Uint32R(rv reflect.Value) {
+ fastpathTV.EncMapUint64Uint32V(rv.Interface().(map[uint64]uint32), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapUint64Uint32V(v map[uint64]uint32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapUint64Uint32V(v map[uint64]uint32, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]uint64, len(v))
var i int
@@ -8912,47 +10301,44 @@ func (_ fastpathT) EncMapUint64Uint32V(v map[uint64]uint32, e *Encoder) {
i++
}
sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint64(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[uint64(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint64(k2)))
- ee.EncodeUint(uint64(v[uint64(k2)]))
+ ee.EncodeUint(uint64(uint64(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v[uint64(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapUint64Uint64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint64Uint64V(rv2i(rv).(map[uint64]uint64), e)
+func (f *encFnInfo) fastpathEncMapUint64Uint64R(rv reflect.Value) {
+ fastpathTV.EncMapUint64Uint64V(rv.Interface().(map[uint64]uint64), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapUint64Uint64V(v map[uint64]uint64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapUint64Uint64V(v map[uint64]uint64, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]uint64, len(v))
var i int
@@ -8961,47 +10347,44 @@ func (_ fastpathT) EncMapUint64Uint64V(v map[uint64]uint64, e *Encoder) {
i++
}
sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint64(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[uint64(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint64(k2)))
- ee.EncodeUint(uint64(v[uint64(k2)]))
+ ee.EncodeUint(uint64(uint64(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v[uint64(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeUint(uint64(v2))
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapUint64UintptrR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint64UintptrV(rv2i(rv).(map[uint64]uintptr), e)
+func (f *encFnInfo) fastpathEncMapUint64UintptrR(rv reflect.Value) {
+ fastpathTV.EncMapUint64UintptrV(rv.Interface().(map[uint64]uintptr), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapUint64UintptrV(v map[uint64]uintptr, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapUint64UintptrV(v map[uint64]uintptr, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]uint64, len(v))
var i int
@@ -9010,47 +10393,44 @@ func (_ fastpathT) EncMapUint64UintptrV(v map[uint64]uintptr, e *Encoder) {
i++
}
sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint64(k2)))
- ee.WriteMapElemValue()
- e.encode(v[uint64(k2)])
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint64(k2)))
- e.encode(v[uint64(k2)])
+ ee.EncodeUint(uint64(uint64(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ e.encode(v[uint64(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- e.encode(v2)
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- e.encode(v2)
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ e.encode(v2)
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapUint64IntR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint64IntV(rv2i(rv).(map[uint64]int), e)
+func (f *encFnInfo) fastpathEncMapUint64IntR(rv reflect.Value) {
+ fastpathTV.EncMapUint64IntV(rv.Interface().(map[uint64]int), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapUint64IntV(v map[uint64]int, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapUint64IntV(v map[uint64]int, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]uint64, len(v))
var i int
@@ -9059,47 +10439,44 @@ func (_ fastpathT) EncMapUint64IntV(v map[uint64]int, e *Encoder) {
i++
}
sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint64(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[uint64(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint64(k2)))
- ee.EncodeInt(int64(v[uint64(k2)]))
+ ee.EncodeUint(uint64(uint64(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v[uint64(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapUint64Int8R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint64Int8V(rv2i(rv).(map[uint64]int8), e)
+func (f *encFnInfo) fastpathEncMapUint64Int8R(rv reflect.Value) {
+ fastpathTV.EncMapUint64Int8V(rv.Interface().(map[uint64]int8), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapUint64Int8V(v map[uint64]int8, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapUint64Int8V(v map[uint64]int8, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]uint64, len(v))
var i int
@@ -9108,47 +10485,44 @@ func (_ fastpathT) EncMapUint64Int8V(v map[uint64]int8, e *Encoder) {
i++
}
sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint64(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[uint64(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint64(k2)))
- ee.EncodeInt(int64(v[uint64(k2)]))
+ ee.EncodeUint(uint64(uint64(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v[uint64(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapUint64Int16R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint64Int16V(rv2i(rv).(map[uint64]int16), e)
+func (f *encFnInfo) fastpathEncMapUint64Int16R(rv reflect.Value) {
+ fastpathTV.EncMapUint64Int16V(rv.Interface().(map[uint64]int16), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapUint64Int16V(v map[uint64]int16, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapUint64Int16V(v map[uint64]int16, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]uint64, len(v))
var i int
@@ -9157,47 +10531,44 @@ func (_ fastpathT) EncMapUint64Int16V(v map[uint64]int16, e *Encoder) {
i++
}
sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint64(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[uint64(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint64(k2)))
- ee.EncodeInt(int64(v[uint64(k2)]))
+ ee.EncodeUint(uint64(uint64(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v[uint64(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapUint64Int32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint64Int32V(rv2i(rv).(map[uint64]int32), e)
+func (f *encFnInfo) fastpathEncMapUint64Int32R(rv reflect.Value) {
+ fastpathTV.EncMapUint64Int32V(rv.Interface().(map[uint64]int32), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapUint64Int32V(v map[uint64]int32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapUint64Int32V(v map[uint64]int32, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]uint64, len(v))
var i int
@@ -9206,47 +10577,44 @@ func (_ fastpathT) EncMapUint64Int32V(v map[uint64]int32, e *Encoder) {
i++
}
sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint64(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[uint64(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint64(k2)))
- ee.EncodeInt(int64(v[uint64(k2)]))
+ ee.EncodeUint(uint64(uint64(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v[uint64(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapUint64Int64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint64Int64V(rv2i(rv).(map[uint64]int64), e)
+func (f *encFnInfo) fastpathEncMapUint64Int64R(rv reflect.Value) {
+ fastpathTV.EncMapUint64Int64V(rv.Interface().(map[uint64]int64), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapUint64Int64V(v map[uint64]int64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapUint64Int64V(v map[uint64]int64, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]uint64, len(v))
var i int
@@ -9255,47 +10623,44 @@ func (_ fastpathT) EncMapUint64Int64V(v map[uint64]int64, e *Encoder) {
i++
}
sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint64(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[uint64(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint64(k2)))
- ee.EncodeInt(int64(v[uint64(k2)]))
+ ee.EncodeUint(uint64(uint64(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v[uint64(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeInt(int64(v2))
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapUint64Float32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint64Float32V(rv2i(rv).(map[uint64]float32), e)
+func (f *encFnInfo) fastpathEncMapUint64Float32R(rv reflect.Value) {
+ fastpathTV.EncMapUint64Float32V(rv.Interface().(map[uint64]float32), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapUint64Float32V(v map[uint64]float32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapUint64Float32V(v map[uint64]float32, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]uint64, len(v))
var i int
@@ -9304,47 +10669,44 @@ func (_ fastpathT) EncMapUint64Float32V(v map[uint64]float32, e *Encoder) {
i++
}
sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint64(k2)))
- ee.WriteMapElemValue()
- ee.EncodeFloat32(v[uint64(k2)])
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint64(k2)))
- ee.EncodeFloat32(v[uint64(k2)])
+ ee.EncodeUint(uint64(uint64(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeFloat32(v[uint64(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeFloat32(v2)
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeFloat32(v2)
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeFloat32(v2)
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapUint64Float64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint64Float64V(rv2i(rv).(map[uint64]float64), e)
+func (f *encFnInfo) fastpathEncMapUint64Float64R(rv reflect.Value) {
+ fastpathTV.EncMapUint64Float64V(rv.Interface().(map[uint64]float64), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapUint64Float64V(v map[uint64]float64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapUint64Float64V(v map[uint64]float64, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]uint64, len(v))
var i int
@@ -9353,47 +10715,44 @@ func (_ fastpathT) EncMapUint64Float64V(v map[uint64]float64, e *Encoder) {
i++
}
sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint64(k2)))
- ee.WriteMapElemValue()
- ee.EncodeFloat64(v[uint64(k2)])
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint64(k2)))
- ee.EncodeFloat64(v[uint64(k2)])
+ ee.EncodeUint(uint64(uint64(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeFloat64(v[uint64(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeFloat64(v2)
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeFloat64(v2)
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeFloat64(v2)
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapUint64BoolR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUint64BoolV(rv2i(rv).(map[uint64]bool), e)
+func (f *encFnInfo) fastpathEncMapUint64BoolR(rv reflect.Value) {
+ fastpathTV.EncMapUint64BoolV(rv.Interface().(map[uint64]bool), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapUint64BoolV(v map[uint64]bool, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapUint64BoolV(v map[uint64]bool, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]uint64, len(v))
var i int
@@ -9402,47 +10761,44 @@ func (_ fastpathT) EncMapUint64BoolV(v map[uint64]bool, e *Encoder) {
i++
}
sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(uint64(k2)))
- ee.WriteMapElemValue()
- ee.EncodeBool(v[uint64(k2)])
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeUint(uint64(uint64(k2)))
- ee.EncodeBool(v[uint64(k2)])
+ ee.EncodeUint(uint64(uint64(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeBool(v[uint64(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeUint(uint64(k2))
- ee.WriteMapElemValue()
- ee.EncodeBool(v2)
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeUint(uint64(k2))
- ee.EncodeBool(v2)
+ ee.EncodeUint(uint64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeBool(v2)
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapUintptrIntfR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUintptrIntfV(rv2i(rv).(map[uintptr]interface{}), e)
+func (f *encFnInfo) fastpathEncMapUintptrIntfR(rv reflect.Value) {
+ fastpathTV.EncMapUintptrIntfV(rv.Interface().(map[uintptr]interface{}), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapUintptrIntfV(v map[uintptr]interface{}, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapUintptrIntfV(v map[uintptr]interface{}, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]uint64, len(v))
var i int
@@ -9451,47 +10807,44 @@ func (_ fastpathT) EncMapUintptrIntfV(v map[uintptr]interface{}, e *Encoder) {
i++
}
sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- e.encode(uintptr(k2))
- ee.WriteMapElemValue()
- e.encode(v[uintptr(k2)])
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- e.encode(uintptr(k2))
- e.encode(v[uintptr(k2)])
+ e.encode(uintptr(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ e.encode(v[uintptr(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- e.encode(k2)
- ee.WriteMapElemValue()
- e.encode(v2)
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- e.encode(k2)
- e.encode(v2)
+ e.encode(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ e.encode(v2)
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapUintptrStringR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUintptrStringV(rv2i(rv).(map[uintptr]string), e)
+func (f *encFnInfo) fastpathEncMapUintptrStringR(rv reflect.Value) {
+ fastpathTV.EncMapUintptrStringV(rv.Interface().(map[uintptr]string), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapUintptrStringV(v map[uintptr]string, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapUintptrStringV(v map[uintptr]string, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]uint64, len(v))
var i int
@@ -9500,47 +10853,44 @@ func (_ fastpathT) EncMapUintptrStringV(v map[uintptr]string, e *Encoder) {
i++
}
sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- e.encode(uintptr(k2))
- ee.WriteMapElemValue()
- ee.EncodeString(cUTF8, v[uintptr(k2)])
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- e.encode(uintptr(k2))
- ee.EncodeString(cUTF8, v[uintptr(k2)])
+ e.encode(uintptr(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeString(c_UTF8, v[uintptr(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- e.encode(k2)
- ee.WriteMapElemValue()
- ee.EncodeString(cUTF8, v2)
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeString(cUTF8, v2)
+ e.encode(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeString(c_UTF8, v2)
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapUintptrUintR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUintptrUintV(rv2i(rv).(map[uintptr]uint), e)
+func (f *encFnInfo) fastpathEncMapUintptrUintR(rv reflect.Value) {
+ fastpathTV.EncMapUintptrUintV(rv.Interface().(map[uintptr]uint), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapUintptrUintV(v map[uintptr]uint, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapUintptrUintV(v map[uintptr]uint, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]uint64, len(v))
var i int
@@ -9549,47 +10899,44 @@ func (_ fastpathT) EncMapUintptrUintV(v map[uintptr]uint, e *Encoder) {
i++
}
sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- e.encode(uintptr(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[uintptr(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- e.encode(uintptr(k2))
- ee.EncodeUint(uint64(v[uintptr(k2)]))
+ e.encode(uintptr(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v[uintptr(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- e.encode(k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeUint(uint64(v2))
+ e.encode(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapUintptrUint8R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUintptrUint8V(rv2i(rv).(map[uintptr]uint8), e)
+func (f *encFnInfo) fastpathEncMapUintptrUint8R(rv reflect.Value) {
+ fastpathTV.EncMapUintptrUint8V(rv.Interface().(map[uintptr]uint8), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapUintptrUint8V(v map[uintptr]uint8, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapUintptrUint8V(v map[uintptr]uint8, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]uint64, len(v))
var i int
@@ -9598,47 +10945,44 @@ func (_ fastpathT) EncMapUintptrUint8V(v map[uintptr]uint8, e *Encoder) {
i++
}
sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- e.encode(uintptr(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[uintptr(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- e.encode(uintptr(k2))
- ee.EncodeUint(uint64(v[uintptr(k2)]))
+ e.encode(uintptr(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v[uintptr(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- e.encode(k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeUint(uint64(v2))
+ e.encode(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapUintptrUint16R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUintptrUint16V(rv2i(rv).(map[uintptr]uint16), e)
+func (f *encFnInfo) fastpathEncMapUintptrUint16R(rv reflect.Value) {
+ fastpathTV.EncMapUintptrUint16V(rv.Interface().(map[uintptr]uint16), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapUintptrUint16V(v map[uintptr]uint16, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapUintptrUint16V(v map[uintptr]uint16, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]uint64, len(v))
var i int
@@ -9647,47 +10991,44 @@ func (_ fastpathT) EncMapUintptrUint16V(v map[uintptr]uint16, e *Encoder) {
i++
}
sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- e.encode(uintptr(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[uintptr(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- e.encode(uintptr(k2))
- ee.EncodeUint(uint64(v[uintptr(k2)]))
+ e.encode(uintptr(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v[uintptr(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- e.encode(k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeUint(uint64(v2))
+ e.encode(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapUintptrUint32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUintptrUint32V(rv2i(rv).(map[uintptr]uint32), e)
+func (f *encFnInfo) fastpathEncMapUintptrUint32R(rv reflect.Value) {
+ fastpathTV.EncMapUintptrUint32V(rv.Interface().(map[uintptr]uint32), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapUintptrUint32V(v map[uintptr]uint32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapUintptrUint32V(v map[uintptr]uint32, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]uint64, len(v))
var i int
@@ -9696,47 +11037,44 @@ func (_ fastpathT) EncMapUintptrUint32V(v map[uintptr]uint32, e *Encoder) {
i++
}
sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- e.encode(uintptr(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[uintptr(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- e.encode(uintptr(k2))
- ee.EncodeUint(uint64(v[uintptr(k2)]))
+ e.encode(uintptr(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v[uintptr(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- e.encode(k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeUint(uint64(v2))
+ e.encode(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapUintptrUint64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUintptrUint64V(rv2i(rv).(map[uintptr]uint64), e)
+func (f *encFnInfo) fastpathEncMapUintptrUint64R(rv reflect.Value) {
+ fastpathTV.EncMapUintptrUint64V(rv.Interface().(map[uintptr]uint64), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapUintptrUint64V(v map[uintptr]uint64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapUintptrUint64V(v map[uintptr]uint64, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]uint64, len(v))
var i int
@@ -9745,47 +11083,44 @@ func (_ fastpathT) EncMapUintptrUint64V(v map[uintptr]uint64, e *Encoder) {
i++
}
sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- e.encode(uintptr(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[uintptr(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- e.encode(uintptr(k2))
- ee.EncodeUint(uint64(v[uintptr(k2)]))
+ e.encode(uintptr(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v[uintptr(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- e.encode(k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeUint(uint64(v2))
+ e.encode(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapUintptrUintptrR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUintptrUintptrV(rv2i(rv).(map[uintptr]uintptr), e)
+func (f *encFnInfo) fastpathEncMapUintptrUintptrR(rv reflect.Value) {
+ fastpathTV.EncMapUintptrUintptrV(rv.Interface().(map[uintptr]uintptr), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapUintptrUintptrV(v map[uintptr]uintptr, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapUintptrUintptrV(v map[uintptr]uintptr, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]uint64, len(v))
var i int
@@ -9794,47 +11129,44 @@ func (_ fastpathT) EncMapUintptrUintptrV(v map[uintptr]uintptr, e *Encoder) {
i++
}
sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- e.encode(uintptr(k2))
- ee.WriteMapElemValue()
- e.encode(v[uintptr(k2)])
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- e.encode(uintptr(k2))
- e.encode(v[uintptr(k2)])
+ e.encode(uintptr(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ e.encode(v[uintptr(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- e.encode(k2)
- ee.WriteMapElemValue()
- e.encode(v2)
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- e.encode(k2)
- e.encode(v2)
+ e.encode(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ e.encode(v2)
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapUintptrIntR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUintptrIntV(rv2i(rv).(map[uintptr]int), e)
+func (f *encFnInfo) fastpathEncMapUintptrIntR(rv reflect.Value) {
+ fastpathTV.EncMapUintptrIntV(rv.Interface().(map[uintptr]int), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapUintptrIntV(v map[uintptr]int, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapUintptrIntV(v map[uintptr]int, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]uint64, len(v))
var i int
@@ -9843,47 +11175,44 @@ func (_ fastpathT) EncMapUintptrIntV(v map[uintptr]int, e *Encoder) {
i++
}
sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- e.encode(uintptr(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[uintptr(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- e.encode(uintptr(k2))
- ee.EncodeInt(int64(v[uintptr(k2)]))
+ e.encode(uintptr(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v[uintptr(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- e.encode(k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeInt(int64(v2))
+ e.encode(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapUintptrInt8R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUintptrInt8V(rv2i(rv).(map[uintptr]int8), e)
+func (f *encFnInfo) fastpathEncMapUintptrInt8R(rv reflect.Value) {
+ fastpathTV.EncMapUintptrInt8V(rv.Interface().(map[uintptr]int8), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapUintptrInt8V(v map[uintptr]int8, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapUintptrInt8V(v map[uintptr]int8, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]uint64, len(v))
var i int
@@ -9892,47 +11221,44 @@ func (_ fastpathT) EncMapUintptrInt8V(v map[uintptr]int8, e *Encoder) {
i++
}
sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- e.encode(uintptr(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[uintptr(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- e.encode(uintptr(k2))
- ee.EncodeInt(int64(v[uintptr(k2)]))
+ e.encode(uintptr(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v[uintptr(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- e.encode(k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeInt(int64(v2))
+ e.encode(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapUintptrInt16R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUintptrInt16V(rv2i(rv).(map[uintptr]int16), e)
+func (f *encFnInfo) fastpathEncMapUintptrInt16R(rv reflect.Value) {
+ fastpathTV.EncMapUintptrInt16V(rv.Interface().(map[uintptr]int16), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapUintptrInt16V(v map[uintptr]int16, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapUintptrInt16V(v map[uintptr]int16, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]uint64, len(v))
var i int
@@ -9941,47 +11267,44 @@ func (_ fastpathT) EncMapUintptrInt16V(v map[uintptr]int16, e *Encoder) {
i++
}
sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- e.encode(uintptr(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[uintptr(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- e.encode(uintptr(k2))
- ee.EncodeInt(int64(v[uintptr(k2)]))
+ e.encode(uintptr(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v[uintptr(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- e.encode(k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeInt(int64(v2))
+ e.encode(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapUintptrInt32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUintptrInt32V(rv2i(rv).(map[uintptr]int32), e)
+func (f *encFnInfo) fastpathEncMapUintptrInt32R(rv reflect.Value) {
+ fastpathTV.EncMapUintptrInt32V(rv.Interface().(map[uintptr]int32), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapUintptrInt32V(v map[uintptr]int32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapUintptrInt32V(v map[uintptr]int32, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]uint64, len(v))
var i int
@@ -9990,47 +11313,44 @@ func (_ fastpathT) EncMapUintptrInt32V(v map[uintptr]int32, e *Encoder) {
i++
}
sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- e.encode(uintptr(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[uintptr(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- e.encode(uintptr(k2))
- ee.EncodeInt(int64(v[uintptr(k2)]))
+ e.encode(uintptr(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v[uintptr(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- e.encode(k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeInt(int64(v2))
+ e.encode(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapUintptrInt64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUintptrInt64V(rv2i(rv).(map[uintptr]int64), e)
+func (f *encFnInfo) fastpathEncMapUintptrInt64R(rv reflect.Value) {
+ fastpathTV.EncMapUintptrInt64V(rv.Interface().(map[uintptr]int64), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapUintptrInt64V(v map[uintptr]int64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapUintptrInt64V(v map[uintptr]int64, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]uint64, len(v))
var i int
@@ -10039,47 +11359,44 @@ func (_ fastpathT) EncMapUintptrInt64V(v map[uintptr]int64, e *Encoder) {
i++
}
sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- e.encode(uintptr(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[uintptr(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- e.encode(uintptr(k2))
- ee.EncodeInt(int64(v[uintptr(k2)]))
+ e.encode(uintptr(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v[uintptr(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- e.encode(k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeInt(int64(v2))
+ e.encode(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapUintptrFloat32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUintptrFloat32V(rv2i(rv).(map[uintptr]float32), e)
+func (f *encFnInfo) fastpathEncMapUintptrFloat32R(rv reflect.Value) {
+ fastpathTV.EncMapUintptrFloat32V(rv.Interface().(map[uintptr]float32), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapUintptrFloat32V(v map[uintptr]float32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapUintptrFloat32V(v map[uintptr]float32, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]uint64, len(v))
var i int
@@ -10088,47 +11405,44 @@ func (_ fastpathT) EncMapUintptrFloat32V(v map[uintptr]float32, e *Encoder) {
i++
}
sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- e.encode(uintptr(k2))
- ee.WriteMapElemValue()
- ee.EncodeFloat32(v[uintptr(k2)])
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- e.encode(uintptr(k2))
- ee.EncodeFloat32(v[uintptr(k2)])
+ e.encode(uintptr(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeFloat32(v[uintptr(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- e.encode(k2)
- ee.WriteMapElemValue()
- ee.EncodeFloat32(v2)
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeFloat32(v2)
+ e.encode(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeFloat32(v2)
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapUintptrFloat64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUintptrFloat64V(rv2i(rv).(map[uintptr]float64), e)
+func (f *encFnInfo) fastpathEncMapUintptrFloat64R(rv reflect.Value) {
+ fastpathTV.EncMapUintptrFloat64V(rv.Interface().(map[uintptr]float64), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapUintptrFloat64V(v map[uintptr]float64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapUintptrFloat64V(v map[uintptr]float64, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]uint64, len(v))
var i int
@@ -10137,47 +11451,44 @@ func (_ fastpathT) EncMapUintptrFloat64V(v map[uintptr]float64, e *Encoder) {
i++
}
sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- e.encode(uintptr(k2))
- ee.WriteMapElemValue()
- ee.EncodeFloat64(v[uintptr(k2)])
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- e.encode(uintptr(k2))
- ee.EncodeFloat64(v[uintptr(k2)])
+ e.encode(uintptr(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeFloat64(v[uintptr(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- e.encode(k2)
- ee.WriteMapElemValue()
- ee.EncodeFloat64(v2)
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeFloat64(v2)
+ e.encode(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeFloat64(v2)
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapUintptrBoolR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapUintptrBoolV(rv2i(rv).(map[uintptr]bool), e)
+func (f *encFnInfo) fastpathEncMapUintptrBoolR(rv reflect.Value) {
+ fastpathTV.EncMapUintptrBoolV(rv.Interface().(map[uintptr]bool), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapUintptrBoolV(v map[uintptr]bool, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapUintptrBoolV(v map[uintptr]bool, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]uint64, len(v))
var i int
@@ -10186,47 +11497,44 @@ func (_ fastpathT) EncMapUintptrBoolV(v map[uintptr]bool, e *Encoder) {
i++
}
sort.Sort(uintSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- e.encode(uintptr(k2))
- ee.WriteMapElemValue()
- ee.EncodeBool(v[uintptr(k2)])
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- e.encode(uintptr(k2))
- ee.EncodeBool(v[uintptr(k2)])
+ e.encode(uintptr(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeBool(v[uintptr(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- e.encode(k2)
- ee.WriteMapElemValue()
- ee.EncodeBool(v2)
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- e.encode(k2)
- ee.EncodeBool(v2)
+ e.encode(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeBool(v2)
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapIntIntfR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapIntIntfV(rv2i(rv).(map[int]interface{}), e)
+func (f *encFnInfo) fastpathEncMapIntIntfR(rv reflect.Value) {
+ fastpathTV.EncMapIntIntfV(rv.Interface().(map[int]interface{}), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapIntIntfV(v map[int]interface{}, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapIntIntfV(v map[int]interface{}, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -10235,47 +11543,44 @@ func (_ fastpathT) EncMapIntIntfV(v map[int]interface{}, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int(k2)))
- ee.WriteMapElemValue()
- e.encode(v[int(k2)])
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int(k2)))
- e.encode(v[int(k2)])
+ ee.EncodeInt(int64(int(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ e.encode(v[int(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- e.encode(v2)
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- e.encode(v2)
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ e.encode(v2)
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapIntStringR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapIntStringV(rv2i(rv).(map[int]string), e)
+func (f *encFnInfo) fastpathEncMapIntStringR(rv reflect.Value) {
+ fastpathTV.EncMapIntStringV(rv.Interface().(map[int]string), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapIntStringV(v map[int]string, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapIntStringV(v map[int]string, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -10284,47 +11589,44 @@ func (_ fastpathT) EncMapIntStringV(v map[int]string, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int(k2)))
- ee.WriteMapElemValue()
- ee.EncodeString(cUTF8, v[int(k2)])
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int(k2)))
- ee.EncodeString(cUTF8, v[int(k2)])
+ ee.EncodeInt(int64(int(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeString(c_UTF8, v[int(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeString(cUTF8, v2)
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeString(cUTF8, v2)
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeString(c_UTF8, v2)
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapIntUintR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapIntUintV(rv2i(rv).(map[int]uint), e)
+func (f *encFnInfo) fastpathEncMapIntUintR(rv reflect.Value) {
+ fastpathTV.EncMapIntUintV(rv.Interface().(map[int]uint), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapIntUintV(v map[int]uint, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapIntUintV(v map[int]uint, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -10333,47 +11635,44 @@ func (_ fastpathT) EncMapIntUintV(v map[int]uint, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[int(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int(k2)))
- ee.EncodeUint(uint64(v[int(k2)]))
+ ee.EncodeInt(int64(int(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v[int(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapIntUint8R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapIntUint8V(rv2i(rv).(map[int]uint8), e)
+func (f *encFnInfo) fastpathEncMapIntUint8R(rv reflect.Value) {
+ fastpathTV.EncMapIntUint8V(rv.Interface().(map[int]uint8), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapIntUint8V(v map[int]uint8, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapIntUint8V(v map[int]uint8, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -10382,47 +11681,44 @@ func (_ fastpathT) EncMapIntUint8V(v map[int]uint8, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[int(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int(k2)))
- ee.EncodeUint(uint64(v[int(k2)]))
+ ee.EncodeInt(int64(int(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v[int(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapIntUint16R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapIntUint16V(rv2i(rv).(map[int]uint16), e)
+func (f *encFnInfo) fastpathEncMapIntUint16R(rv reflect.Value) {
+ fastpathTV.EncMapIntUint16V(rv.Interface().(map[int]uint16), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapIntUint16V(v map[int]uint16, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapIntUint16V(v map[int]uint16, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -10431,47 +11727,44 @@ func (_ fastpathT) EncMapIntUint16V(v map[int]uint16, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[int(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int(k2)))
- ee.EncodeUint(uint64(v[int(k2)]))
+ ee.EncodeInt(int64(int(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v[int(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapIntUint32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapIntUint32V(rv2i(rv).(map[int]uint32), e)
+func (f *encFnInfo) fastpathEncMapIntUint32R(rv reflect.Value) {
+ fastpathTV.EncMapIntUint32V(rv.Interface().(map[int]uint32), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapIntUint32V(v map[int]uint32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapIntUint32V(v map[int]uint32, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -10480,47 +11773,44 @@ func (_ fastpathT) EncMapIntUint32V(v map[int]uint32, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[int(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int(k2)))
- ee.EncodeUint(uint64(v[int(k2)]))
+ ee.EncodeInt(int64(int(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v[int(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapIntUint64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapIntUint64V(rv2i(rv).(map[int]uint64), e)
+func (f *encFnInfo) fastpathEncMapIntUint64R(rv reflect.Value) {
+ fastpathTV.EncMapIntUint64V(rv.Interface().(map[int]uint64), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapIntUint64V(v map[int]uint64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapIntUint64V(v map[int]uint64, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -10529,47 +11819,44 @@ func (_ fastpathT) EncMapIntUint64V(v map[int]uint64, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[int(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int(k2)))
- ee.EncodeUint(uint64(v[int(k2)]))
+ ee.EncodeInt(int64(int(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v[int(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapIntUintptrR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapIntUintptrV(rv2i(rv).(map[int]uintptr), e)
+func (f *encFnInfo) fastpathEncMapIntUintptrR(rv reflect.Value) {
+ fastpathTV.EncMapIntUintptrV(rv.Interface().(map[int]uintptr), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapIntUintptrV(v map[int]uintptr, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapIntUintptrV(v map[int]uintptr, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -10578,47 +11865,44 @@ func (_ fastpathT) EncMapIntUintptrV(v map[int]uintptr, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int(k2)))
- ee.WriteMapElemValue()
- e.encode(v[int(k2)])
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int(k2)))
- e.encode(v[int(k2)])
+ ee.EncodeInt(int64(int(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ e.encode(v[int(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- e.encode(v2)
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- e.encode(v2)
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ e.encode(v2)
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapIntIntR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapIntIntV(rv2i(rv).(map[int]int), e)
+func (f *encFnInfo) fastpathEncMapIntIntR(rv reflect.Value) {
+ fastpathTV.EncMapIntIntV(rv.Interface().(map[int]int), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapIntIntV(v map[int]int, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapIntIntV(v map[int]int, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -10627,47 +11911,44 @@ func (_ fastpathT) EncMapIntIntV(v map[int]int, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[int(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int(k2)))
- ee.EncodeInt(int64(v[int(k2)]))
+ ee.EncodeInt(int64(int(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v[int(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapIntInt8R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapIntInt8V(rv2i(rv).(map[int]int8), e)
+func (f *encFnInfo) fastpathEncMapIntInt8R(rv reflect.Value) {
+ fastpathTV.EncMapIntInt8V(rv.Interface().(map[int]int8), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapIntInt8V(v map[int]int8, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapIntInt8V(v map[int]int8, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -10676,47 +11957,44 @@ func (_ fastpathT) EncMapIntInt8V(v map[int]int8, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[int(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int(k2)))
- ee.EncodeInt(int64(v[int(k2)]))
+ ee.EncodeInt(int64(int(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v[int(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapIntInt16R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapIntInt16V(rv2i(rv).(map[int]int16), e)
+func (f *encFnInfo) fastpathEncMapIntInt16R(rv reflect.Value) {
+ fastpathTV.EncMapIntInt16V(rv.Interface().(map[int]int16), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapIntInt16V(v map[int]int16, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapIntInt16V(v map[int]int16, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -10725,47 +12003,44 @@ func (_ fastpathT) EncMapIntInt16V(v map[int]int16, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[int(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int(k2)))
- ee.EncodeInt(int64(v[int(k2)]))
+ ee.EncodeInt(int64(int(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v[int(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapIntInt32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapIntInt32V(rv2i(rv).(map[int]int32), e)
+func (f *encFnInfo) fastpathEncMapIntInt32R(rv reflect.Value) {
+ fastpathTV.EncMapIntInt32V(rv.Interface().(map[int]int32), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapIntInt32V(v map[int]int32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapIntInt32V(v map[int]int32, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -10774,47 +12049,44 @@ func (_ fastpathT) EncMapIntInt32V(v map[int]int32, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[int(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int(k2)))
- ee.EncodeInt(int64(v[int(k2)]))
+ ee.EncodeInt(int64(int(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v[int(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapIntInt64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapIntInt64V(rv2i(rv).(map[int]int64), e)
+func (f *encFnInfo) fastpathEncMapIntInt64R(rv reflect.Value) {
+ fastpathTV.EncMapIntInt64V(rv.Interface().(map[int]int64), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapIntInt64V(v map[int]int64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapIntInt64V(v map[int]int64, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -10823,47 +12095,44 @@ func (_ fastpathT) EncMapIntInt64V(v map[int]int64, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[int(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int(k2)))
- ee.EncodeInt(int64(v[int(k2)]))
+ ee.EncodeInt(int64(int(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v[int(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapIntFloat32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapIntFloat32V(rv2i(rv).(map[int]float32), e)
+func (f *encFnInfo) fastpathEncMapIntFloat32R(rv reflect.Value) {
+ fastpathTV.EncMapIntFloat32V(rv.Interface().(map[int]float32), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapIntFloat32V(v map[int]float32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapIntFloat32V(v map[int]float32, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -10872,47 +12141,44 @@ func (_ fastpathT) EncMapIntFloat32V(v map[int]float32, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int(k2)))
- ee.WriteMapElemValue()
- ee.EncodeFloat32(v[int(k2)])
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int(k2)))
- ee.EncodeFloat32(v[int(k2)])
+ ee.EncodeInt(int64(int(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeFloat32(v[int(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeFloat32(v2)
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeFloat32(v2)
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeFloat32(v2)
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapIntFloat64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapIntFloat64V(rv2i(rv).(map[int]float64), e)
+func (f *encFnInfo) fastpathEncMapIntFloat64R(rv reflect.Value) {
+ fastpathTV.EncMapIntFloat64V(rv.Interface().(map[int]float64), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapIntFloat64V(v map[int]float64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapIntFloat64V(v map[int]float64, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -10921,47 +12187,44 @@ func (_ fastpathT) EncMapIntFloat64V(v map[int]float64, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int(k2)))
- ee.WriteMapElemValue()
- ee.EncodeFloat64(v[int(k2)])
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int(k2)))
- ee.EncodeFloat64(v[int(k2)])
+ ee.EncodeInt(int64(int(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeFloat64(v[int(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeFloat64(v2)
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeFloat64(v2)
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeFloat64(v2)
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapIntBoolR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapIntBoolV(rv2i(rv).(map[int]bool), e)
+func (f *encFnInfo) fastpathEncMapIntBoolR(rv reflect.Value) {
+ fastpathTV.EncMapIntBoolV(rv.Interface().(map[int]bool), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapIntBoolV(v map[int]bool, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapIntBoolV(v map[int]bool, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -10970,47 +12233,44 @@ func (_ fastpathT) EncMapIntBoolV(v map[int]bool, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int(k2)))
- ee.WriteMapElemValue()
- ee.EncodeBool(v[int(k2)])
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int(k2)))
- ee.EncodeBool(v[int(k2)])
+ ee.EncodeInt(int64(int(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeBool(v[int(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeBool(v2)
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeBool(v2)
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeBool(v2)
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapInt8IntfR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt8IntfV(rv2i(rv).(map[int8]interface{}), e)
+func (f *encFnInfo) fastpathEncMapInt8IntfR(rv reflect.Value) {
+ fastpathTV.EncMapInt8IntfV(rv.Interface().(map[int8]interface{}), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapInt8IntfV(v map[int8]interface{}, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapInt8IntfV(v map[int8]interface{}, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -11019,47 +12279,44 @@ func (_ fastpathT) EncMapInt8IntfV(v map[int8]interface{}, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int8(k2)))
- ee.WriteMapElemValue()
- e.encode(v[int8(k2)])
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int8(k2)))
- e.encode(v[int8(k2)])
+ ee.EncodeInt(int64(int8(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ e.encode(v[int8(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- e.encode(v2)
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- e.encode(v2)
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ e.encode(v2)
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapInt8StringR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt8StringV(rv2i(rv).(map[int8]string), e)
+func (f *encFnInfo) fastpathEncMapInt8StringR(rv reflect.Value) {
+ fastpathTV.EncMapInt8StringV(rv.Interface().(map[int8]string), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapInt8StringV(v map[int8]string, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapInt8StringV(v map[int8]string, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -11068,47 +12325,44 @@ func (_ fastpathT) EncMapInt8StringV(v map[int8]string, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int8(k2)))
- ee.WriteMapElemValue()
- ee.EncodeString(cUTF8, v[int8(k2)])
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int8(k2)))
- ee.EncodeString(cUTF8, v[int8(k2)])
+ ee.EncodeInt(int64(int8(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeString(c_UTF8, v[int8(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeString(cUTF8, v2)
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeString(cUTF8, v2)
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeString(c_UTF8, v2)
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapInt8UintR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt8UintV(rv2i(rv).(map[int8]uint), e)
+func (f *encFnInfo) fastpathEncMapInt8UintR(rv reflect.Value) {
+ fastpathTV.EncMapInt8UintV(rv.Interface().(map[int8]uint), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapInt8UintV(v map[int8]uint, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapInt8UintV(v map[int8]uint, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -11117,47 +12371,44 @@ func (_ fastpathT) EncMapInt8UintV(v map[int8]uint, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int8(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[int8(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int8(k2)))
- ee.EncodeUint(uint64(v[int8(k2)]))
+ ee.EncodeInt(int64(int8(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v[int8(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapInt8Uint8R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt8Uint8V(rv2i(rv).(map[int8]uint8), e)
+func (f *encFnInfo) fastpathEncMapInt8Uint8R(rv reflect.Value) {
+ fastpathTV.EncMapInt8Uint8V(rv.Interface().(map[int8]uint8), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapInt8Uint8V(v map[int8]uint8, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapInt8Uint8V(v map[int8]uint8, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -11166,47 +12417,44 @@ func (_ fastpathT) EncMapInt8Uint8V(v map[int8]uint8, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int8(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[int8(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int8(k2)))
- ee.EncodeUint(uint64(v[int8(k2)]))
+ ee.EncodeInt(int64(int8(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v[int8(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapInt8Uint16R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt8Uint16V(rv2i(rv).(map[int8]uint16), e)
+func (f *encFnInfo) fastpathEncMapInt8Uint16R(rv reflect.Value) {
+ fastpathTV.EncMapInt8Uint16V(rv.Interface().(map[int8]uint16), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapInt8Uint16V(v map[int8]uint16, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapInt8Uint16V(v map[int8]uint16, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -11215,47 +12463,44 @@ func (_ fastpathT) EncMapInt8Uint16V(v map[int8]uint16, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int8(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[int8(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int8(k2)))
- ee.EncodeUint(uint64(v[int8(k2)]))
+ ee.EncodeInt(int64(int8(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v[int8(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapInt8Uint32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt8Uint32V(rv2i(rv).(map[int8]uint32), e)
+func (f *encFnInfo) fastpathEncMapInt8Uint32R(rv reflect.Value) {
+ fastpathTV.EncMapInt8Uint32V(rv.Interface().(map[int8]uint32), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapInt8Uint32V(v map[int8]uint32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapInt8Uint32V(v map[int8]uint32, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -11264,47 +12509,44 @@ func (_ fastpathT) EncMapInt8Uint32V(v map[int8]uint32, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int8(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[int8(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int8(k2)))
- ee.EncodeUint(uint64(v[int8(k2)]))
+ ee.EncodeInt(int64(int8(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v[int8(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapInt8Uint64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt8Uint64V(rv2i(rv).(map[int8]uint64), e)
+func (f *encFnInfo) fastpathEncMapInt8Uint64R(rv reflect.Value) {
+ fastpathTV.EncMapInt8Uint64V(rv.Interface().(map[int8]uint64), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapInt8Uint64V(v map[int8]uint64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapInt8Uint64V(v map[int8]uint64, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -11313,47 +12555,44 @@ func (_ fastpathT) EncMapInt8Uint64V(v map[int8]uint64, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int8(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[int8(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int8(k2)))
- ee.EncodeUint(uint64(v[int8(k2)]))
+ ee.EncodeInt(int64(int8(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v[int8(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapInt8UintptrR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt8UintptrV(rv2i(rv).(map[int8]uintptr), e)
+func (f *encFnInfo) fastpathEncMapInt8UintptrR(rv reflect.Value) {
+ fastpathTV.EncMapInt8UintptrV(rv.Interface().(map[int8]uintptr), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapInt8UintptrV(v map[int8]uintptr, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapInt8UintptrV(v map[int8]uintptr, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -11362,47 +12601,44 @@ func (_ fastpathT) EncMapInt8UintptrV(v map[int8]uintptr, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int8(k2)))
- ee.WriteMapElemValue()
- e.encode(v[int8(k2)])
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int8(k2)))
- e.encode(v[int8(k2)])
+ ee.EncodeInt(int64(int8(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ e.encode(v[int8(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- e.encode(v2)
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- e.encode(v2)
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ e.encode(v2)
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapInt8IntR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt8IntV(rv2i(rv).(map[int8]int), e)
+func (f *encFnInfo) fastpathEncMapInt8IntR(rv reflect.Value) {
+ fastpathTV.EncMapInt8IntV(rv.Interface().(map[int8]int), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapInt8IntV(v map[int8]int, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapInt8IntV(v map[int8]int, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -11411,47 +12647,44 @@ func (_ fastpathT) EncMapInt8IntV(v map[int8]int, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int8(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[int8(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int8(k2)))
- ee.EncodeInt(int64(v[int8(k2)]))
+ ee.EncodeInt(int64(int8(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v[int8(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapInt8Int8R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt8Int8V(rv2i(rv).(map[int8]int8), e)
+func (f *encFnInfo) fastpathEncMapInt8Int8R(rv reflect.Value) {
+ fastpathTV.EncMapInt8Int8V(rv.Interface().(map[int8]int8), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapInt8Int8V(v map[int8]int8, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapInt8Int8V(v map[int8]int8, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -11460,47 +12693,44 @@ func (_ fastpathT) EncMapInt8Int8V(v map[int8]int8, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int8(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[int8(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int8(k2)))
- ee.EncodeInt(int64(v[int8(k2)]))
+ ee.EncodeInt(int64(int8(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v[int8(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapInt8Int16R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt8Int16V(rv2i(rv).(map[int8]int16), e)
+func (f *encFnInfo) fastpathEncMapInt8Int16R(rv reflect.Value) {
+ fastpathTV.EncMapInt8Int16V(rv.Interface().(map[int8]int16), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapInt8Int16V(v map[int8]int16, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapInt8Int16V(v map[int8]int16, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -11509,47 +12739,44 @@ func (_ fastpathT) EncMapInt8Int16V(v map[int8]int16, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int8(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[int8(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int8(k2)))
- ee.EncodeInt(int64(v[int8(k2)]))
+ ee.EncodeInt(int64(int8(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v[int8(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapInt8Int32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt8Int32V(rv2i(rv).(map[int8]int32), e)
+func (f *encFnInfo) fastpathEncMapInt8Int32R(rv reflect.Value) {
+ fastpathTV.EncMapInt8Int32V(rv.Interface().(map[int8]int32), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapInt8Int32V(v map[int8]int32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapInt8Int32V(v map[int8]int32, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -11558,47 +12785,44 @@ func (_ fastpathT) EncMapInt8Int32V(v map[int8]int32, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int8(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[int8(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int8(k2)))
- ee.EncodeInt(int64(v[int8(k2)]))
+ ee.EncodeInt(int64(int8(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v[int8(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapInt8Int64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt8Int64V(rv2i(rv).(map[int8]int64), e)
+func (f *encFnInfo) fastpathEncMapInt8Int64R(rv reflect.Value) {
+ fastpathTV.EncMapInt8Int64V(rv.Interface().(map[int8]int64), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapInt8Int64V(v map[int8]int64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapInt8Int64V(v map[int8]int64, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -11607,47 +12831,44 @@ func (_ fastpathT) EncMapInt8Int64V(v map[int8]int64, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int8(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[int8(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int8(k2)))
- ee.EncodeInt(int64(v[int8(k2)]))
+ ee.EncodeInt(int64(int8(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v[int8(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapInt8Float32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt8Float32V(rv2i(rv).(map[int8]float32), e)
+func (f *encFnInfo) fastpathEncMapInt8Float32R(rv reflect.Value) {
+ fastpathTV.EncMapInt8Float32V(rv.Interface().(map[int8]float32), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapInt8Float32V(v map[int8]float32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapInt8Float32V(v map[int8]float32, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -11656,47 +12877,44 @@ func (_ fastpathT) EncMapInt8Float32V(v map[int8]float32, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int8(k2)))
- ee.WriteMapElemValue()
- ee.EncodeFloat32(v[int8(k2)])
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int8(k2)))
- ee.EncodeFloat32(v[int8(k2)])
+ ee.EncodeInt(int64(int8(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeFloat32(v[int8(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeFloat32(v2)
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeFloat32(v2)
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeFloat32(v2)
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapInt8Float64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt8Float64V(rv2i(rv).(map[int8]float64), e)
+func (f *encFnInfo) fastpathEncMapInt8Float64R(rv reflect.Value) {
+ fastpathTV.EncMapInt8Float64V(rv.Interface().(map[int8]float64), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapInt8Float64V(v map[int8]float64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapInt8Float64V(v map[int8]float64, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -11705,47 +12923,44 @@ func (_ fastpathT) EncMapInt8Float64V(v map[int8]float64, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int8(k2)))
- ee.WriteMapElemValue()
- ee.EncodeFloat64(v[int8(k2)])
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int8(k2)))
- ee.EncodeFloat64(v[int8(k2)])
+ ee.EncodeInt(int64(int8(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeFloat64(v[int8(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeFloat64(v2)
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeFloat64(v2)
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeFloat64(v2)
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapInt8BoolR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt8BoolV(rv2i(rv).(map[int8]bool), e)
+func (f *encFnInfo) fastpathEncMapInt8BoolR(rv reflect.Value) {
+ fastpathTV.EncMapInt8BoolV(rv.Interface().(map[int8]bool), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapInt8BoolV(v map[int8]bool, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapInt8BoolV(v map[int8]bool, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -11754,47 +12969,44 @@ func (_ fastpathT) EncMapInt8BoolV(v map[int8]bool, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int8(k2)))
- ee.WriteMapElemValue()
- ee.EncodeBool(v[int8(k2)])
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int8(k2)))
- ee.EncodeBool(v[int8(k2)])
+ ee.EncodeInt(int64(int8(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeBool(v[int8(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeBool(v2)
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeBool(v2)
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeBool(v2)
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapInt16IntfR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt16IntfV(rv2i(rv).(map[int16]interface{}), e)
+func (f *encFnInfo) fastpathEncMapInt16IntfR(rv reflect.Value) {
+ fastpathTV.EncMapInt16IntfV(rv.Interface().(map[int16]interface{}), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapInt16IntfV(v map[int16]interface{}, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapInt16IntfV(v map[int16]interface{}, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -11803,47 +13015,44 @@ func (_ fastpathT) EncMapInt16IntfV(v map[int16]interface{}, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int16(k2)))
- ee.WriteMapElemValue()
- e.encode(v[int16(k2)])
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int16(k2)))
- e.encode(v[int16(k2)])
+ ee.EncodeInt(int64(int16(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ e.encode(v[int16(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- e.encode(v2)
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- e.encode(v2)
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ e.encode(v2)
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapInt16StringR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt16StringV(rv2i(rv).(map[int16]string), e)
+func (f *encFnInfo) fastpathEncMapInt16StringR(rv reflect.Value) {
+ fastpathTV.EncMapInt16StringV(rv.Interface().(map[int16]string), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapInt16StringV(v map[int16]string, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapInt16StringV(v map[int16]string, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -11852,47 +13061,44 @@ func (_ fastpathT) EncMapInt16StringV(v map[int16]string, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int16(k2)))
- ee.WriteMapElemValue()
- ee.EncodeString(cUTF8, v[int16(k2)])
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int16(k2)))
- ee.EncodeString(cUTF8, v[int16(k2)])
+ ee.EncodeInt(int64(int16(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeString(c_UTF8, v[int16(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeString(cUTF8, v2)
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeString(cUTF8, v2)
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeString(c_UTF8, v2)
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapInt16UintR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt16UintV(rv2i(rv).(map[int16]uint), e)
+func (f *encFnInfo) fastpathEncMapInt16UintR(rv reflect.Value) {
+ fastpathTV.EncMapInt16UintV(rv.Interface().(map[int16]uint), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapInt16UintV(v map[int16]uint, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapInt16UintV(v map[int16]uint, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -11901,47 +13107,44 @@ func (_ fastpathT) EncMapInt16UintV(v map[int16]uint, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int16(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[int16(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int16(k2)))
- ee.EncodeUint(uint64(v[int16(k2)]))
+ ee.EncodeInt(int64(int16(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v[int16(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapInt16Uint8R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt16Uint8V(rv2i(rv).(map[int16]uint8), e)
+func (f *encFnInfo) fastpathEncMapInt16Uint8R(rv reflect.Value) {
+ fastpathTV.EncMapInt16Uint8V(rv.Interface().(map[int16]uint8), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapInt16Uint8V(v map[int16]uint8, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapInt16Uint8V(v map[int16]uint8, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -11950,47 +13153,44 @@ func (_ fastpathT) EncMapInt16Uint8V(v map[int16]uint8, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int16(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[int16(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int16(k2)))
- ee.EncodeUint(uint64(v[int16(k2)]))
+ ee.EncodeInt(int64(int16(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v[int16(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapInt16Uint16R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt16Uint16V(rv2i(rv).(map[int16]uint16), e)
+func (f *encFnInfo) fastpathEncMapInt16Uint16R(rv reflect.Value) {
+ fastpathTV.EncMapInt16Uint16V(rv.Interface().(map[int16]uint16), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapInt16Uint16V(v map[int16]uint16, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapInt16Uint16V(v map[int16]uint16, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -11999,47 +13199,44 @@ func (_ fastpathT) EncMapInt16Uint16V(v map[int16]uint16, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int16(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[int16(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int16(k2)))
- ee.EncodeUint(uint64(v[int16(k2)]))
+ ee.EncodeInt(int64(int16(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v[int16(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapInt16Uint32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt16Uint32V(rv2i(rv).(map[int16]uint32), e)
+func (f *encFnInfo) fastpathEncMapInt16Uint32R(rv reflect.Value) {
+ fastpathTV.EncMapInt16Uint32V(rv.Interface().(map[int16]uint32), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapInt16Uint32V(v map[int16]uint32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapInt16Uint32V(v map[int16]uint32, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -12048,47 +13245,44 @@ func (_ fastpathT) EncMapInt16Uint32V(v map[int16]uint32, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int16(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[int16(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int16(k2)))
- ee.EncodeUint(uint64(v[int16(k2)]))
+ ee.EncodeInt(int64(int16(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v[int16(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapInt16Uint64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt16Uint64V(rv2i(rv).(map[int16]uint64), e)
+func (f *encFnInfo) fastpathEncMapInt16Uint64R(rv reflect.Value) {
+ fastpathTV.EncMapInt16Uint64V(rv.Interface().(map[int16]uint64), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapInt16Uint64V(v map[int16]uint64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapInt16Uint64V(v map[int16]uint64, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -12097,47 +13291,44 @@ func (_ fastpathT) EncMapInt16Uint64V(v map[int16]uint64, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int16(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[int16(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int16(k2)))
- ee.EncodeUint(uint64(v[int16(k2)]))
+ ee.EncodeInt(int64(int16(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v[int16(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapInt16UintptrR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt16UintptrV(rv2i(rv).(map[int16]uintptr), e)
+func (f *encFnInfo) fastpathEncMapInt16UintptrR(rv reflect.Value) {
+ fastpathTV.EncMapInt16UintptrV(rv.Interface().(map[int16]uintptr), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapInt16UintptrV(v map[int16]uintptr, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapInt16UintptrV(v map[int16]uintptr, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -12146,47 +13337,44 @@ func (_ fastpathT) EncMapInt16UintptrV(v map[int16]uintptr, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int16(k2)))
- ee.WriteMapElemValue()
- e.encode(v[int16(k2)])
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int16(k2)))
- e.encode(v[int16(k2)])
+ ee.EncodeInt(int64(int16(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ e.encode(v[int16(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- e.encode(v2)
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- e.encode(v2)
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ e.encode(v2)
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapInt16IntR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt16IntV(rv2i(rv).(map[int16]int), e)
+func (f *encFnInfo) fastpathEncMapInt16IntR(rv reflect.Value) {
+ fastpathTV.EncMapInt16IntV(rv.Interface().(map[int16]int), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapInt16IntV(v map[int16]int, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapInt16IntV(v map[int16]int, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -12195,47 +13383,44 @@ func (_ fastpathT) EncMapInt16IntV(v map[int16]int, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int16(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[int16(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int16(k2)))
- ee.EncodeInt(int64(v[int16(k2)]))
+ ee.EncodeInt(int64(int16(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v[int16(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapInt16Int8R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt16Int8V(rv2i(rv).(map[int16]int8), e)
+func (f *encFnInfo) fastpathEncMapInt16Int8R(rv reflect.Value) {
+ fastpathTV.EncMapInt16Int8V(rv.Interface().(map[int16]int8), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapInt16Int8V(v map[int16]int8, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapInt16Int8V(v map[int16]int8, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -12244,47 +13429,44 @@ func (_ fastpathT) EncMapInt16Int8V(v map[int16]int8, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int16(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[int16(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int16(k2)))
- ee.EncodeInt(int64(v[int16(k2)]))
+ ee.EncodeInt(int64(int16(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v[int16(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapInt16Int16R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt16Int16V(rv2i(rv).(map[int16]int16), e)
+func (f *encFnInfo) fastpathEncMapInt16Int16R(rv reflect.Value) {
+ fastpathTV.EncMapInt16Int16V(rv.Interface().(map[int16]int16), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapInt16Int16V(v map[int16]int16, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapInt16Int16V(v map[int16]int16, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -12293,47 +13475,44 @@ func (_ fastpathT) EncMapInt16Int16V(v map[int16]int16, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int16(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[int16(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int16(k2)))
- ee.EncodeInt(int64(v[int16(k2)]))
+ ee.EncodeInt(int64(int16(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v[int16(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapInt16Int32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt16Int32V(rv2i(rv).(map[int16]int32), e)
+func (f *encFnInfo) fastpathEncMapInt16Int32R(rv reflect.Value) {
+ fastpathTV.EncMapInt16Int32V(rv.Interface().(map[int16]int32), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapInt16Int32V(v map[int16]int32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapInt16Int32V(v map[int16]int32, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -12342,47 +13521,44 @@ func (_ fastpathT) EncMapInt16Int32V(v map[int16]int32, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int16(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[int16(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int16(k2)))
- ee.EncodeInt(int64(v[int16(k2)]))
+ ee.EncodeInt(int64(int16(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v[int16(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapInt16Int64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt16Int64V(rv2i(rv).(map[int16]int64), e)
+func (f *encFnInfo) fastpathEncMapInt16Int64R(rv reflect.Value) {
+ fastpathTV.EncMapInt16Int64V(rv.Interface().(map[int16]int64), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapInt16Int64V(v map[int16]int64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapInt16Int64V(v map[int16]int64, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -12391,47 +13567,44 @@ func (_ fastpathT) EncMapInt16Int64V(v map[int16]int64, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int16(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[int16(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int16(k2)))
- ee.EncodeInt(int64(v[int16(k2)]))
+ ee.EncodeInt(int64(int16(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v[int16(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapInt16Float32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt16Float32V(rv2i(rv).(map[int16]float32), e)
+func (f *encFnInfo) fastpathEncMapInt16Float32R(rv reflect.Value) {
+ fastpathTV.EncMapInt16Float32V(rv.Interface().(map[int16]float32), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapInt16Float32V(v map[int16]float32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapInt16Float32V(v map[int16]float32, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -12440,47 +13613,44 @@ func (_ fastpathT) EncMapInt16Float32V(v map[int16]float32, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int16(k2)))
- ee.WriteMapElemValue()
- ee.EncodeFloat32(v[int16(k2)])
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int16(k2)))
- ee.EncodeFloat32(v[int16(k2)])
+ ee.EncodeInt(int64(int16(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeFloat32(v[int16(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeFloat32(v2)
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeFloat32(v2)
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeFloat32(v2)
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapInt16Float64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt16Float64V(rv2i(rv).(map[int16]float64), e)
+func (f *encFnInfo) fastpathEncMapInt16Float64R(rv reflect.Value) {
+ fastpathTV.EncMapInt16Float64V(rv.Interface().(map[int16]float64), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapInt16Float64V(v map[int16]float64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapInt16Float64V(v map[int16]float64, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -12489,47 +13659,44 @@ func (_ fastpathT) EncMapInt16Float64V(v map[int16]float64, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int16(k2)))
- ee.WriteMapElemValue()
- ee.EncodeFloat64(v[int16(k2)])
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int16(k2)))
- ee.EncodeFloat64(v[int16(k2)])
+ ee.EncodeInt(int64(int16(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeFloat64(v[int16(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeFloat64(v2)
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeFloat64(v2)
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeFloat64(v2)
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapInt16BoolR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt16BoolV(rv2i(rv).(map[int16]bool), e)
+func (f *encFnInfo) fastpathEncMapInt16BoolR(rv reflect.Value) {
+ fastpathTV.EncMapInt16BoolV(rv.Interface().(map[int16]bool), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapInt16BoolV(v map[int16]bool, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapInt16BoolV(v map[int16]bool, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -12538,47 +13705,44 @@ func (_ fastpathT) EncMapInt16BoolV(v map[int16]bool, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int16(k2)))
- ee.WriteMapElemValue()
- ee.EncodeBool(v[int16(k2)])
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int16(k2)))
- ee.EncodeBool(v[int16(k2)])
+ ee.EncodeInt(int64(int16(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeBool(v[int16(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeBool(v2)
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeBool(v2)
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeBool(v2)
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapInt32IntfR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt32IntfV(rv2i(rv).(map[int32]interface{}), e)
+func (f *encFnInfo) fastpathEncMapInt32IntfR(rv reflect.Value) {
+ fastpathTV.EncMapInt32IntfV(rv.Interface().(map[int32]interface{}), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapInt32IntfV(v map[int32]interface{}, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapInt32IntfV(v map[int32]interface{}, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -12587,47 +13751,44 @@ func (_ fastpathT) EncMapInt32IntfV(v map[int32]interface{}, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int32(k2)))
- ee.WriteMapElemValue()
- e.encode(v[int32(k2)])
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int32(k2)))
- e.encode(v[int32(k2)])
+ ee.EncodeInt(int64(int32(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ e.encode(v[int32(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- e.encode(v2)
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- e.encode(v2)
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ e.encode(v2)
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapInt32StringR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt32StringV(rv2i(rv).(map[int32]string), e)
+func (f *encFnInfo) fastpathEncMapInt32StringR(rv reflect.Value) {
+ fastpathTV.EncMapInt32StringV(rv.Interface().(map[int32]string), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapInt32StringV(v map[int32]string, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapInt32StringV(v map[int32]string, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -12636,47 +13797,44 @@ func (_ fastpathT) EncMapInt32StringV(v map[int32]string, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int32(k2)))
- ee.WriteMapElemValue()
- ee.EncodeString(cUTF8, v[int32(k2)])
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int32(k2)))
- ee.EncodeString(cUTF8, v[int32(k2)])
+ ee.EncodeInt(int64(int32(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeString(c_UTF8, v[int32(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeString(cUTF8, v2)
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeString(cUTF8, v2)
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeString(c_UTF8, v2)
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapInt32UintR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt32UintV(rv2i(rv).(map[int32]uint), e)
+func (f *encFnInfo) fastpathEncMapInt32UintR(rv reflect.Value) {
+ fastpathTV.EncMapInt32UintV(rv.Interface().(map[int32]uint), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapInt32UintV(v map[int32]uint, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapInt32UintV(v map[int32]uint, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -12685,47 +13843,44 @@ func (_ fastpathT) EncMapInt32UintV(v map[int32]uint, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int32(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[int32(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int32(k2)))
- ee.EncodeUint(uint64(v[int32(k2)]))
+ ee.EncodeInt(int64(int32(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v[int32(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapInt32Uint8R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt32Uint8V(rv2i(rv).(map[int32]uint8), e)
+func (f *encFnInfo) fastpathEncMapInt32Uint8R(rv reflect.Value) {
+ fastpathTV.EncMapInt32Uint8V(rv.Interface().(map[int32]uint8), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapInt32Uint8V(v map[int32]uint8, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapInt32Uint8V(v map[int32]uint8, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -12734,47 +13889,44 @@ func (_ fastpathT) EncMapInt32Uint8V(v map[int32]uint8, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int32(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[int32(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int32(k2)))
- ee.EncodeUint(uint64(v[int32(k2)]))
+ ee.EncodeInt(int64(int32(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v[int32(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapInt32Uint16R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt32Uint16V(rv2i(rv).(map[int32]uint16), e)
+func (f *encFnInfo) fastpathEncMapInt32Uint16R(rv reflect.Value) {
+ fastpathTV.EncMapInt32Uint16V(rv.Interface().(map[int32]uint16), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapInt32Uint16V(v map[int32]uint16, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapInt32Uint16V(v map[int32]uint16, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -12783,47 +13935,44 @@ func (_ fastpathT) EncMapInt32Uint16V(v map[int32]uint16, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int32(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[int32(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int32(k2)))
- ee.EncodeUint(uint64(v[int32(k2)]))
+ ee.EncodeInt(int64(int32(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v[int32(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapInt32Uint32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt32Uint32V(rv2i(rv).(map[int32]uint32), e)
+func (f *encFnInfo) fastpathEncMapInt32Uint32R(rv reflect.Value) {
+ fastpathTV.EncMapInt32Uint32V(rv.Interface().(map[int32]uint32), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapInt32Uint32V(v map[int32]uint32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapInt32Uint32V(v map[int32]uint32, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -12832,47 +13981,44 @@ func (_ fastpathT) EncMapInt32Uint32V(v map[int32]uint32, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int32(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[int32(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int32(k2)))
- ee.EncodeUint(uint64(v[int32(k2)]))
+ ee.EncodeInt(int64(int32(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v[int32(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapInt32Uint64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt32Uint64V(rv2i(rv).(map[int32]uint64), e)
+func (f *encFnInfo) fastpathEncMapInt32Uint64R(rv reflect.Value) {
+ fastpathTV.EncMapInt32Uint64V(rv.Interface().(map[int32]uint64), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapInt32Uint64V(v map[int32]uint64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapInt32Uint64V(v map[int32]uint64, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -12881,47 +14027,44 @@ func (_ fastpathT) EncMapInt32Uint64V(v map[int32]uint64, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int32(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[int32(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int32(k2)))
- ee.EncodeUint(uint64(v[int32(k2)]))
+ ee.EncodeInt(int64(int32(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v[int32(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapInt32UintptrR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt32UintptrV(rv2i(rv).(map[int32]uintptr), e)
+func (f *encFnInfo) fastpathEncMapInt32UintptrR(rv reflect.Value) {
+ fastpathTV.EncMapInt32UintptrV(rv.Interface().(map[int32]uintptr), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapInt32UintptrV(v map[int32]uintptr, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapInt32UintptrV(v map[int32]uintptr, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -12930,47 +14073,44 @@ func (_ fastpathT) EncMapInt32UintptrV(v map[int32]uintptr, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int32(k2)))
- ee.WriteMapElemValue()
- e.encode(v[int32(k2)])
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int32(k2)))
- e.encode(v[int32(k2)])
+ ee.EncodeInt(int64(int32(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ e.encode(v[int32(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- e.encode(v2)
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- e.encode(v2)
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ e.encode(v2)
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapInt32IntR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt32IntV(rv2i(rv).(map[int32]int), e)
+func (f *encFnInfo) fastpathEncMapInt32IntR(rv reflect.Value) {
+ fastpathTV.EncMapInt32IntV(rv.Interface().(map[int32]int), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapInt32IntV(v map[int32]int, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapInt32IntV(v map[int32]int, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -12979,47 +14119,44 @@ func (_ fastpathT) EncMapInt32IntV(v map[int32]int, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int32(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[int32(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int32(k2)))
- ee.EncodeInt(int64(v[int32(k2)]))
+ ee.EncodeInt(int64(int32(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v[int32(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapInt32Int8R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt32Int8V(rv2i(rv).(map[int32]int8), e)
+func (f *encFnInfo) fastpathEncMapInt32Int8R(rv reflect.Value) {
+ fastpathTV.EncMapInt32Int8V(rv.Interface().(map[int32]int8), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapInt32Int8V(v map[int32]int8, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapInt32Int8V(v map[int32]int8, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -13028,47 +14165,44 @@ func (_ fastpathT) EncMapInt32Int8V(v map[int32]int8, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int32(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[int32(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int32(k2)))
- ee.EncodeInt(int64(v[int32(k2)]))
+ ee.EncodeInt(int64(int32(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v[int32(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapInt32Int16R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt32Int16V(rv2i(rv).(map[int32]int16), e)
+func (f *encFnInfo) fastpathEncMapInt32Int16R(rv reflect.Value) {
+ fastpathTV.EncMapInt32Int16V(rv.Interface().(map[int32]int16), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapInt32Int16V(v map[int32]int16, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapInt32Int16V(v map[int32]int16, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -13077,47 +14211,44 @@ func (_ fastpathT) EncMapInt32Int16V(v map[int32]int16, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int32(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[int32(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int32(k2)))
- ee.EncodeInt(int64(v[int32(k2)]))
+ ee.EncodeInt(int64(int32(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v[int32(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapInt32Int32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt32Int32V(rv2i(rv).(map[int32]int32), e)
+func (f *encFnInfo) fastpathEncMapInt32Int32R(rv reflect.Value) {
+ fastpathTV.EncMapInt32Int32V(rv.Interface().(map[int32]int32), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapInt32Int32V(v map[int32]int32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapInt32Int32V(v map[int32]int32, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -13126,47 +14257,44 @@ func (_ fastpathT) EncMapInt32Int32V(v map[int32]int32, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int32(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[int32(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int32(k2)))
- ee.EncodeInt(int64(v[int32(k2)]))
+ ee.EncodeInt(int64(int32(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v[int32(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapInt32Int64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt32Int64V(rv2i(rv).(map[int32]int64), e)
+func (f *encFnInfo) fastpathEncMapInt32Int64R(rv reflect.Value) {
+ fastpathTV.EncMapInt32Int64V(rv.Interface().(map[int32]int64), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapInt32Int64V(v map[int32]int64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapInt32Int64V(v map[int32]int64, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -13175,47 +14303,44 @@ func (_ fastpathT) EncMapInt32Int64V(v map[int32]int64, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int32(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[int32(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int32(k2)))
- ee.EncodeInt(int64(v[int32(k2)]))
+ ee.EncodeInt(int64(int32(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v[int32(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapInt32Float32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt32Float32V(rv2i(rv).(map[int32]float32), e)
+func (f *encFnInfo) fastpathEncMapInt32Float32R(rv reflect.Value) {
+ fastpathTV.EncMapInt32Float32V(rv.Interface().(map[int32]float32), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapInt32Float32V(v map[int32]float32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapInt32Float32V(v map[int32]float32, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -13224,47 +14349,44 @@ func (_ fastpathT) EncMapInt32Float32V(v map[int32]float32, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int32(k2)))
- ee.WriteMapElemValue()
- ee.EncodeFloat32(v[int32(k2)])
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int32(k2)))
- ee.EncodeFloat32(v[int32(k2)])
+ ee.EncodeInt(int64(int32(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeFloat32(v[int32(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeFloat32(v2)
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeFloat32(v2)
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeFloat32(v2)
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapInt32Float64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt32Float64V(rv2i(rv).(map[int32]float64), e)
+func (f *encFnInfo) fastpathEncMapInt32Float64R(rv reflect.Value) {
+ fastpathTV.EncMapInt32Float64V(rv.Interface().(map[int32]float64), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapInt32Float64V(v map[int32]float64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapInt32Float64V(v map[int32]float64, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -13273,47 +14395,44 @@ func (_ fastpathT) EncMapInt32Float64V(v map[int32]float64, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int32(k2)))
- ee.WriteMapElemValue()
- ee.EncodeFloat64(v[int32(k2)])
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int32(k2)))
- ee.EncodeFloat64(v[int32(k2)])
+ ee.EncodeInt(int64(int32(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeFloat64(v[int32(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeFloat64(v2)
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeFloat64(v2)
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeFloat64(v2)
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapInt32BoolR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt32BoolV(rv2i(rv).(map[int32]bool), e)
+func (f *encFnInfo) fastpathEncMapInt32BoolR(rv reflect.Value) {
+ fastpathTV.EncMapInt32BoolV(rv.Interface().(map[int32]bool), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapInt32BoolV(v map[int32]bool, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapInt32BoolV(v map[int32]bool, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -13322,47 +14441,44 @@ func (_ fastpathT) EncMapInt32BoolV(v map[int32]bool, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int32(k2)))
- ee.WriteMapElemValue()
- ee.EncodeBool(v[int32(k2)])
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int32(k2)))
- ee.EncodeBool(v[int32(k2)])
+ ee.EncodeInt(int64(int32(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeBool(v[int32(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeBool(v2)
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeBool(v2)
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeBool(v2)
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapInt64IntfR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt64IntfV(rv2i(rv).(map[int64]interface{}), e)
+func (f *encFnInfo) fastpathEncMapInt64IntfR(rv reflect.Value) {
+ fastpathTV.EncMapInt64IntfV(rv.Interface().(map[int64]interface{}), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapInt64IntfV(v map[int64]interface{}, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapInt64IntfV(v map[int64]interface{}, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -13371,47 +14487,44 @@ func (_ fastpathT) EncMapInt64IntfV(v map[int64]interface{}, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int64(k2)))
- ee.WriteMapElemValue()
- e.encode(v[int64(k2)])
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int64(k2)))
- e.encode(v[int64(k2)])
+ ee.EncodeInt(int64(int64(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ e.encode(v[int64(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- e.encode(v2)
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- e.encode(v2)
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ e.encode(v2)
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapInt64StringR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt64StringV(rv2i(rv).(map[int64]string), e)
+func (f *encFnInfo) fastpathEncMapInt64StringR(rv reflect.Value) {
+ fastpathTV.EncMapInt64StringV(rv.Interface().(map[int64]string), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapInt64StringV(v map[int64]string, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapInt64StringV(v map[int64]string, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -13420,47 +14533,44 @@ func (_ fastpathT) EncMapInt64StringV(v map[int64]string, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int64(k2)))
- ee.WriteMapElemValue()
- ee.EncodeString(cUTF8, v[int64(k2)])
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int64(k2)))
- ee.EncodeString(cUTF8, v[int64(k2)])
+ ee.EncodeInt(int64(int64(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeString(c_UTF8, v[int64(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeString(cUTF8, v2)
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeString(cUTF8, v2)
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeString(c_UTF8, v2)
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapInt64UintR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt64UintV(rv2i(rv).(map[int64]uint), e)
+func (f *encFnInfo) fastpathEncMapInt64UintR(rv reflect.Value) {
+ fastpathTV.EncMapInt64UintV(rv.Interface().(map[int64]uint), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapInt64UintV(v map[int64]uint, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapInt64UintV(v map[int64]uint, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -13469,47 +14579,44 @@ func (_ fastpathT) EncMapInt64UintV(v map[int64]uint, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int64(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[int64(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int64(k2)))
- ee.EncodeUint(uint64(v[int64(k2)]))
+ ee.EncodeInt(int64(int64(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v[int64(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapInt64Uint8R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt64Uint8V(rv2i(rv).(map[int64]uint8), e)
+func (f *encFnInfo) fastpathEncMapInt64Uint8R(rv reflect.Value) {
+ fastpathTV.EncMapInt64Uint8V(rv.Interface().(map[int64]uint8), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapInt64Uint8V(v map[int64]uint8, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapInt64Uint8V(v map[int64]uint8, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -13518,47 +14625,44 @@ func (_ fastpathT) EncMapInt64Uint8V(v map[int64]uint8, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int64(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[int64(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int64(k2)))
- ee.EncodeUint(uint64(v[int64(k2)]))
+ ee.EncodeInt(int64(int64(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v[int64(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapInt64Uint16R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt64Uint16V(rv2i(rv).(map[int64]uint16), e)
+func (f *encFnInfo) fastpathEncMapInt64Uint16R(rv reflect.Value) {
+ fastpathTV.EncMapInt64Uint16V(rv.Interface().(map[int64]uint16), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapInt64Uint16V(v map[int64]uint16, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapInt64Uint16V(v map[int64]uint16, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -13567,47 +14671,44 @@ func (_ fastpathT) EncMapInt64Uint16V(v map[int64]uint16, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int64(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[int64(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int64(k2)))
- ee.EncodeUint(uint64(v[int64(k2)]))
+ ee.EncodeInt(int64(int64(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v[int64(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapInt64Uint32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt64Uint32V(rv2i(rv).(map[int64]uint32), e)
+func (f *encFnInfo) fastpathEncMapInt64Uint32R(rv reflect.Value) {
+ fastpathTV.EncMapInt64Uint32V(rv.Interface().(map[int64]uint32), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapInt64Uint32V(v map[int64]uint32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapInt64Uint32V(v map[int64]uint32, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -13616,47 +14717,44 @@ func (_ fastpathT) EncMapInt64Uint32V(v map[int64]uint32, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int64(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[int64(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int64(k2)))
- ee.EncodeUint(uint64(v[int64(k2)]))
+ ee.EncodeInt(int64(int64(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v[int64(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapInt64Uint64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt64Uint64V(rv2i(rv).(map[int64]uint64), e)
+func (f *encFnInfo) fastpathEncMapInt64Uint64R(rv reflect.Value) {
+ fastpathTV.EncMapInt64Uint64V(rv.Interface().(map[int64]uint64), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapInt64Uint64V(v map[int64]uint64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapInt64Uint64V(v map[int64]uint64, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -13665,47 +14763,44 @@ func (_ fastpathT) EncMapInt64Uint64V(v map[int64]uint64, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int64(k2)))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[int64(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int64(k2)))
- ee.EncodeUint(uint64(v[int64(k2)]))
+ ee.EncodeInt(int64(int64(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v[int64(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeUint(uint64(v2))
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapInt64UintptrR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt64UintptrV(rv2i(rv).(map[int64]uintptr), e)
+func (f *encFnInfo) fastpathEncMapInt64UintptrR(rv reflect.Value) {
+ fastpathTV.EncMapInt64UintptrV(rv.Interface().(map[int64]uintptr), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapInt64UintptrV(v map[int64]uintptr, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapInt64UintptrV(v map[int64]uintptr, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -13714,47 +14809,44 @@ func (_ fastpathT) EncMapInt64UintptrV(v map[int64]uintptr, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int64(k2)))
- ee.WriteMapElemValue()
- e.encode(v[int64(k2)])
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int64(k2)))
- e.encode(v[int64(k2)])
+ ee.EncodeInt(int64(int64(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ e.encode(v[int64(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- e.encode(v2)
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- e.encode(v2)
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ e.encode(v2)
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapInt64IntR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt64IntV(rv2i(rv).(map[int64]int), e)
+func (f *encFnInfo) fastpathEncMapInt64IntR(rv reflect.Value) {
+ fastpathTV.EncMapInt64IntV(rv.Interface().(map[int64]int), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapInt64IntV(v map[int64]int, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapInt64IntV(v map[int64]int, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -13763,47 +14855,44 @@ func (_ fastpathT) EncMapInt64IntV(v map[int64]int, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int64(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[int64(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int64(k2)))
- ee.EncodeInt(int64(v[int64(k2)]))
+ ee.EncodeInt(int64(int64(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v[int64(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapInt64Int8R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt64Int8V(rv2i(rv).(map[int64]int8), e)
+func (f *encFnInfo) fastpathEncMapInt64Int8R(rv reflect.Value) {
+ fastpathTV.EncMapInt64Int8V(rv.Interface().(map[int64]int8), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapInt64Int8V(v map[int64]int8, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapInt64Int8V(v map[int64]int8, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -13812,47 +14901,44 @@ func (_ fastpathT) EncMapInt64Int8V(v map[int64]int8, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int64(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[int64(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int64(k2)))
- ee.EncodeInt(int64(v[int64(k2)]))
+ ee.EncodeInt(int64(int64(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v[int64(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapInt64Int16R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt64Int16V(rv2i(rv).(map[int64]int16), e)
+func (f *encFnInfo) fastpathEncMapInt64Int16R(rv reflect.Value) {
+ fastpathTV.EncMapInt64Int16V(rv.Interface().(map[int64]int16), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapInt64Int16V(v map[int64]int16, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapInt64Int16V(v map[int64]int16, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -13861,47 +14947,44 @@ func (_ fastpathT) EncMapInt64Int16V(v map[int64]int16, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int64(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[int64(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int64(k2)))
- ee.EncodeInt(int64(v[int64(k2)]))
+ ee.EncodeInt(int64(int64(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v[int64(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapInt64Int32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt64Int32V(rv2i(rv).(map[int64]int32), e)
+func (f *encFnInfo) fastpathEncMapInt64Int32R(rv reflect.Value) {
+ fastpathTV.EncMapInt64Int32V(rv.Interface().(map[int64]int32), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapInt64Int32V(v map[int64]int32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapInt64Int32V(v map[int64]int32, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -13910,47 +14993,44 @@ func (_ fastpathT) EncMapInt64Int32V(v map[int64]int32, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int64(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[int64(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int64(k2)))
- ee.EncodeInt(int64(v[int64(k2)]))
+ ee.EncodeInt(int64(int64(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v[int64(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapInt64Int64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt64Int64V(rv2i(rv).(map[int64]int64), e)
+func (f *encFnInfo) fastpathEncMapInt64Int64R(rv reflect.Value) {
+ fastpathTV.EncMapInt64Int64V(rv.Interface().(map[int64]int64), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapInt64Int64V(v map[int64]int64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapInt64Int64V(v map[int64]int64, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -13959,47 +15039,44 @@ func (_ fastpathT) EncMapInt64Int64V(v map[int64]int64, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int64(k2)))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[int64(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int64(k2)))
- ee.EncodeInt(int64(v[int64(k2)]))
+ ee.EncodeInt(int64(int64(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v[int64(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeInt(int64(v2))
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapInt64Float32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt64Float32V(rv2i(rv).(map[int64]float32), e)
+func (f *encFnInfo) fastpathEncMapInt64Float32R(rv reflect.Value) {
+ fastpathTV.EncMapInt64Float32V(rv.Interface().(map[int64]float32), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapInt64Float32V(v map[int64]float32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapInt64Float32V(v map[int64]float32, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -14008,47 +15085,44 @@ func (_ fastpathT) EncMapInt64Float32V(v map[int64]float32, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int64(k2)))
- ee.WriteMapElemValue()
- ee.EncodeFloat32(v[int64(k2)])
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int64(k2)))
- ee.EncodeFloat32(v[int64(k2)])
+ ee.EncodeInt(int64(int64(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeFloat32(v[int64(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeFloat32(v2)
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeFloat32(v2)
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeFloat32(v2)
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapInt64Float64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt64Float64V(rv2i(rv).(map[int64]float64), e)
+func (f *encFnInfo) fastpathEncMapInt64Float64R(rv reflect.Value) {
+ fastpathTV.EncMapInt64Float64V(rv.Interface().(map[int64]float64), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapInt64Float64V(v map[int64]float64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapInt64Float64V(v map[int64]float64, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -14057,47 +15131,44 @@ func (_ fastpathT) EncMapInt64Float64V(v map[int64]float64, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int64(k2)))
- ee.WriteMapElemValue()
- ee.EncodeFloat64(v[int64(k2)])
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int64(k2)))
- ee.EncodeFloat64(v[int64(k2)])
+ ee.EncodeInt(int64(int64(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeFloat64(v[int64(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeFloat64(v2)
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeFloat64(v2)
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeFloat64(v2)
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapInt64BoolR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapInt64BoolV(rv2i(rv).(map[int64]bool), e)
+func (f *encFnInfo) fastpathEncMapInt64BoolR(rv reflect.Value) {
+ fastpathTV.EncMapInt64BoolV(rv.Interface().(map[int64]bool), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapInt64BoolV(v map[int64]bool, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapInt64BoolV(v map[int64]bool, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]int64, len(v))
var i int
@@ -14106,47 +15177,44 @@ func (_ fastpathT) EncMapInt64BoolV(v map[int64]bool, e *Encoder) {
i++
}
sort.Sort(intSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(int64(k2)))
- ee.WriteMapElemValue()
- ee.EncodeBool(v[int64(k2)])
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeInt(int64(int64(k2)))
- ee.EncodeBool(v[int64(k2)])
+ ee.EncodeInt(int64(int64(k2)))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeBool(v[int64(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeInt(int64(k2))
- ee.WriteMapElemValue()
- ee.EncodeBool(v2)
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeInt(int64(k2))
- ee.EncodeBool(v2)
+ ee.EncodeInt(int64(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeBool(v2)
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapBoolIntfR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapBoolIntfV(rv2i(rv).(map[bool]interface{}), e)
+func (f *encFnInfo) fastpathEncMapBoolIntfR(rv reflect.Value) {
+ fastpathTV.EncMapBoolIntfV(rv.Interface().(map[bool]interface{}), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapBoolIntfV(v map[bool]interface{}, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapBoolIntfV(v map[bool]interface{}, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]bool, len(v))
var i int
@@ -14155,47 +15223,44 @@ func (_ fastpathT) EncMapBoolIntfV(v map[bool]interface{}, e *Encoder) {
i++
}
sort.Sort(boolSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeBool(bool(k2))
- ee.WriteMapElemValue()
- e.encode(v[bool(k2)])
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeBool(bool(k2))
- e.encode(v[bool(k2)])
+ ee.EncodeBool(bool(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ e.encode(v[bool(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeBool(k2)
- ee.WriteMapElemValue()
- e.encode(v2)
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeBool(k2)
- e.encode(v2)
+ ee.EncodeBool(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ e.encode(v2)
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapBoolStringR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapBoolStringV(rv2i(rv).(map[bool]string), e)
+func (f *encFnInfo) fastpathEncMapBoolStringR(rv reflect.Value) {
+ fastpathTV.EncMapBoolStringV(rv.Interface().(map[bool]string), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapBoolStringV(v map[bool]string, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapBoolStringV(v map[bool]string, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]bool, len(v))
var i int
@@ -14204,47 +15269,44 @@ func (_ fastpathT) EncMapBoolStringV(v map[bool]string, e *Encoder) {
i++
}
sort.Sort(boolSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeBool(bool(k2))
- ee.WriteMapElemValue()
- ee.EncodeString(cUTF8, v[bool(k2)])
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeBool(bool(k2))
- ee.EncodeString(cUTF8, v[bool(k2)])
+ ee.EncodeBool(bool(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeString(c_UTF8, v[bool(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeBool(k2)
- ee.WriteMapElemValue()
- ee.EncodeString(cUTF8, v2)
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeBool(k2)
- ee.EncodeString(cUTF8, v2)
+ ee.EncodeBool(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeString(c_UTF8, v2)
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapBoolUintR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapBoolUintV(rv2i(rv).(map[bool]uint), e)
+func (f *encFnInfo) fastpathEncMapBoolUintR(rv reflect.Value) {
+ fastpathTV.EncMapBoolUintV(rv.Interface().(map[bool]uint), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapBoolUintV(v map[bool]uint, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapBoolUintV(v map[bool]uint, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]bool, len(v))
var i int
@@ -14253,47 +15315,44 @@ func (_ fastpathT) EncMapBoolUintV(v map[bool]uint, e *Encoder) {
i++
}
sort.Sort(boolSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeBool(bool(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[bool(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeBool(bool(k2))
- ee.EncodeUint(uint64(v[bool(k2)]))
+ ee.EncodeBool(bool(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v[bool(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeBool(k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeBool(k2)
- ee.EncodeUint(uint64(v2))
+ ee.EncodeBool(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapBoolUint8R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapBoolUint8V(rv2i(rv).(map[bool]uint8), e)
+func (f *encFnInfo) fastpathEncMapBoolUint8R(rv reflect.Value) {
+ fastpathTV.EncMapBoolUint8V(rv.Interface().(map[bool]uint8), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapBoolUint8V(v map[bool]uint8, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapBoolUint8V(v map[bool]uint8, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]bool, len(v))
var i int
@@ -14302,47 +15361,44 @@ func (_ fastpathT) EncMapBoolUint8V(v map[bool]uint8, e *Encoder) {
i++
}
sort.Sort(boolSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeBool(bool(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[bool(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeBool(bool(k2))
- ee.EncodeUint(uint64(v[bool(k2)]))
+ ee.EncodeBool(bool(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v[bool(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeBool(k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeBool(k2)
- ee.EncodeUint(uint64(v2))
+ ee.EncodeBool(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapBoolUint16R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapBoolUint16V(rv2i(rv).(map[bool]uint16), e)
+func (f *encFnInfo) fastpathEncMapBoolUint16R(rv reflect.Value) {
+ fastpathTV.EncMapBoolUint16V(rv.Interface().(map[bool]uint16), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapBoolUint16V(v map[bool]uint16, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapBoolUint16V(v map[bool]uint16, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]bool, len(v))
var i int
@@ -14351,47 +15407,44 @@ func (_ fastpathT) EncMapBoolUint16V(v map[bool]uint16, e *Encoder) {
i++
}
sort.Sort(boolSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeBool(bool(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[bool(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeBool(bool(k2))
- ee.EncodeUint(uint64(v[bool(k2)]))
+ ee.EncodeBool(bool(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v[bool(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeBool(k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeBool(k2)
- ee.EncodeUint(uint64(v2))
+ ee.EncodeBool(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapBoolUint32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapBoolUint32V(rv2i(rv).(map[bool]uint32), e)
+func (f *encFnInfo) fastpathEncMapBoolUint32R(rv reflect.Value) {
+ fastpathTV.EncMapBoolUint32V(rv.Interface().(map[bool]uint32), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapBoolUint32V(v map[bool]uint32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapBoolUint32V(v map[bool]uint32, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]bool, len(v))
var i int
@@ -14400,47 +15453,44 @@ func (_ fastpathT) EncMapBoolUint32V(v map[bool]uint32, e *Encoder) {
i++
}
sort.Sort(boolSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeBool(bool(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[bool(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeBool(bool(k2))
- ee.EncodeUint(uint64(v[bool(k2)]))
+ ee.EncodeBool(bool(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v[bool(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeBool(k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeBool(k2)
- ee.EncodeUint(uint64(v2))
+ ee.EncodeBool(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapBoolUint64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapBoolUint64V(rv2i(rv).(map[bool]uint64), e)
+func (f *encFnInfo) fastpathEncMapBoolUint64R(rv reflect.Value) {
+ fastpathTV.EncMapBoolUint64V(rv.Interface().(map[bool]uint64), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapBoolUint64V(v map[bool]uint64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapBoolUint64V(v map[bool]uint64, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]bool, len(v))
var i int
@@ -14449,47 +15499,44 @@ func (_ fastpathT) EncMapBoolUint64V(v map[bool]uint64, e *Encoder) {
i++
}
sort.Sort(boolSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeBool(bool(k2))
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v[bool(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeBool(bool(k2))
- ee.EncodeUint(uint64(v[bool(k2)]))
+ ee.EncodeBool(bool(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v[bool(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeBool(k2)
- ee.WriteMapElemValue()
- ee.EncodeUint(uint64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeBool(k2)
- ee.EncodeUint(uint64(v2))
+ ee.EncodeBool(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeUint(uint64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapBoolUintptrR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapBoolUintptrV(rv2i(rv).(map[bool]uintptr), e)
+func (f *encFnInfo) fastpathEncMapBoolUintptrR(rv reflect.Value) {
+ fastpathTV.EncMapBoolUintptrV(rv.Interface().(map[bool]uintptr), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapBoolUintptrV(v map[bool]uintptr, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapBoolUintptrV(v map[bool]uintptr, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]bool, len(v))
var i int
@@ -14498,47 +15545,44 @@ func (_ fastpathT) EncMapBoolUintptrV(v map[bool]uintptr, e *Encoder) {
i++
}
sort.Sort(boolSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeBool(bool(k2))
- ee.WriteMapElemValue()
- e.encode(v[bool(k2)])
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeBool(bool(k2))
- e.encode(v[bool(k2)])
+ ee.EncodeBool(bool(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ e.encode(v[bool(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeBool(k2)
- ee.WriteMapElemValue()
- e.encode(v2)
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeBool(k2)
- e.encode(v2)
+ ee.EncodeBool(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ e.encode(v2)
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapBoolIntR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapBoolIntV(rv2i(rv).(map[bool]int), e)
+func (f *encFnInfo) fastpathEncMapBoolIntR(rv reflect.Value) {
+ fastpathTV.EncMapBoolIntV(rv.Interface().(map[bool]int), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapBoolIntV(v map[bool]int, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapBoolIntV(v map[bool]int, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]bool, len(v))
var i int
@@ -14547,47 +15591,44 @@ func (_ fastpathT) EncMapBoolIntV(v map[bool]int, e *Encoder) {
i++
}
sort.Sort(boolSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeBool(bool(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[bool(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeBool(bool(k2))
- ee.EncodeInt(int64(v[bool(k2)]))
+ ee.EncodeBool(bool(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v[bool(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeBool(k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeBool(k2)
- ee.EncodeInt(int64(v2))
+ ee.EncodeBool(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapBoolInt8R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapBoolInt8V(rv2i(rv).(map[bool]int8), e)
+func (f *encFnInfo) fastpathEncMapBoolInt8R(rv reflect.Value) {
+ fastpathTV.EncMapBoolInt8V(rv.Interface().(map[bool]int8), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapBoolInt8V(v map[bool]int8, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapBoolInt8V(v map[bool]int8, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]bool, len(v))
var i int
@@ -14596,47 +15637,44 @@ func (_ fastpathT) EncMapBoolInt8V(v map[bool]int8, e *Encoder) {
i++
}
sort.Sort(boolSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeBool(bool(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[bool(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeBool(bool(k2))
- ee.EncodeInt(int64(v[bool(k2)]))
+ ee.EncodeBool(bool(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v[bool(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeBool(k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeBool(k2)
- ee.EncodeInt(int64(v2))
+ ee.EncodeBool(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapBoolInt16R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapBoolInt16V(rv2i(rv).(map[bool]int16), e)
+func (f *encFnInfo) fastpathEncMapBoolInt16R(rv reflect.Value) {
+ fastpathTV.EncMapBoolInt16V(rv.Interface().(map[bool]int16), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapBoolInt16V(v map[bool]int16, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapBoolInt16V(v map[bool]int16, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]bool, len(v))
var i int
@@ -14645,47 +15683,44 @@ func (_ fastpathT) EncMapBoolInt16V(v map[bool]int16, e *Encoder) {
i++
}
sort.Sort(boolSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeBool(bool(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[bool(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeBool(bool(k2))
- ee.EncodeInt(int64(v[bool(k2)]))
+ ee.EncodeBool(bool(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v[bool(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeBool(k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeBool(k2)
- ee.EncodeInt(int64(v2))
+ ee.EncodeBool(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapBoolInt32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapBoolInt32V(rv2i(rv).(map[bool]int32), e)
+func (f *encFnInfo) fastpathEncMapBoolInt32R(rv reflect.Value) {
+ fastpathTV.EncMapBoolInt32V(rv.Interface().(map[bool]int32), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapBoolInt32V(v map[bool]int32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapBoolInt32V(v map[bool]int32, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]bool, len(v))
var i int
@@ -14694,47 +15729,44 @@ func (_ fastpathT) EncMapBoolInt32V(v map[bool]int32, e *Encoder) {
i++
}
sort.Sort(boolSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeBool(bool(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[bool(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeBool(bool(k2))
- ee.EncodeInt(int64(v[bool(k2)]))
+ ee.EncodeBool(bool(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v[bool(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeBool(k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeBool(k2)
- ee.EncodeInt(int64(v2))
+ ee.EncodeBool(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapBoolInt64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapBoolInt64V(rv2i(rv).(map[bool]int64), e)
+func (f *encFnInfo) fastpathEncMapBoolInt64R(rv reflect.Value) {
+ fastpathTV.EncMapBoolInt64V(rv.Interface().(map[bool]int64), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapBoolInt64V(v map[bool]int64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapBoolInt64V(v map[bool]int64, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]bool, len(v))
var i int
@@ -14743,47 +15775,44 @@ func (_ fastpathT) EncMapBoolInt64V(v map[bool]int64, e *Encoder) {
i++
}
sort.Sort(boolSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeBool(bool(k2))
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v[bool(k2)]))
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeBool(bool(k2))
- ee.EncodeInt(int64(v[bool(k2)]))
+ ee.EncodeBool(bool(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v[bool(k2)]))
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeBool(k2)
- ee.WriteMapElemValue()
- ee.EncodeInt(int64(v2))
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeBool(k2)
- ee.EncodeInt(int64(v2))
+ ee.EncodeBool(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeInt(int64(v2))
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapBoolFloat32R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapBoolFloat32V(rv2i(rv).(map[bool]float32), e)
+func (f *encFnInfo) fastpathEncMapBoolFloat32R(rv reflect.Value) {
+ fastpathTV.EncMapBoolFloat32V(rv.Interface().(map[bool]float32), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapBoolFloat32V(v map[bool]float32, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapBoolFloat32V(v map[bool]float32, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]bool, len(v))
var i int
@@ -14792,47 +15821,44 @@ func (_ fastpathT) EncMapBoolFloat32V(v map[bool]float32, e *Encoder) {
i++
}
sort.Sort(boolSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeBool(bool(k2))
- ee.WriteMapElemValue()
- ee.EncodeFloat32(v[bool(k2)])
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeBool(bool(k2))
- ee.EncodeFloat32(v[bool(k2)])
+ ee.EncodeBool(bool(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeFloat32(v[bool(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeBool(k2)
- ee.WriteMapElemValue()
- ee.EncodeFloat32(v2)
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeBool(k2)
- ee.EncodeFloat32(v2)
+ ee.EncodeBool(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeFloat32(v2)
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapBoolFloat64R(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapBoolFloat64V(rv2i(rv).(map[bool]float64), e)
+func (f *encFnInfo) fastpathEncMapBoolFloat64R(rv reflect.Value) {
+ fastpathTV.EncMapBoolFloat64V(rv.Interface().(map[bool]float64), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapBoolFloat64V(v map[bool]float64, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapBoolFloat64V(v map[bool]float64, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]bool, len(v))
var i int
@@ -14841,47 +15867,44 @@ func (_ fastpathT) EncMapBoolFloat64V(v map[bool]float64, e *Encoder) {
i++
}
sort.Sort(boolSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeBool(bool(k2))
- ee.WriteMapElemValue()
- ee.EncodeFloat64(v[bool(k2)])
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeBool(bool(k2))
- ee.EncodeFloat64(v[bool(k2)])
+ ee.EncodeBool(bool(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeFloat64(v[bool(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeBool(k2)
- ee.WriteMapElemValue()
- ee.EncodeFloat64(v2)
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeBool(k2)
- ee.EncodeFloat64(v2)
+ ee.EncodeBool(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeFloat64(v2)
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
-func (e *Encoder) fastpathEncMapBoolBoolR(f *codecFnInfo, rv reflect.Value) {
- fastpathTV.EncMapBoolBoolV(rv2i(rv).(map[bool]bool), e)
+func (f *encFnInfo) fastpathEncMapBoolBoolR(rv reflect.Value) {
+ fastpathTV.EncMapBoolBoolV(rv.Interface().(map[bool]bool), fastpathCheckNilFalse, f.e)
}
-func (_ fastpathT) EncMapBoolBoolV(v map[bool]bool, e *Encoder) {
- if v == nil {
- e.e.EncodeNil()
+func (_ fastpathT) EncMapBoolBoolV(v map[bool]bool, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
return
}
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteMapStart(len(v))
+ ee.EncodeMapStart(len(v))
if e.h.Canonical {
v2 := make([]bool, len(v))
var i int
@@ -14890,2830 +15913,2209 @@ func (_ fastpathT) EncMapBoolBoolV(v map[bool]bool, e *Encoder) {
i++
}
sort.Sort(boolSlice(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- ee.EncodeBool(bool(k2))
- ee.WriteMapElemValue()
- ee.EncodeBool(v[bool(k2)])
+ for _, k2 := range v2 {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for _, k2 := range v2 {
- ee.EncodeBool(bool(k2))
- ee.EncodeBool(v[bool(k2)])
+ ee.EncodeBool(bool(k2))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeBool(v[bool(k2)])
}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- ee.EncodeBool(k2)
- ee.WriteMapElemValue()
- ee.EncodeBool(v2)
+ for k2, v2 := range v {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
}
- } else {
- for k2, v2 := range v {
- ee.EncodeBool(k2)
- ee.EncodeBool(v2)
+ ee.EncodeBool(k2)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
}
+ ee.EncodeBool(v2)
}
}
- ee.WriteMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
}
// -- 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)
- }
+ fastpathTV.DecSliceIntfV(v, fastpathCheckNilFalse, false, d)
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 {
+ v2, changed2 := fastpathTV.DecSliceIntfV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
*v = v2
}
case map[interface{}]interface{}:
- fastpathTV.DecMapIntfIntfV(v, false, d)
+ fastpathTV.DecMapIntfIntfV(v, fastpathCheckNilFalse, false, d)
case *map[interface{}]interface{}:
- var v2 map[interface{}]interface{}
- v2, changed = fastpathTV.DecMapIntfIntfV(*v, true, d)
- if changed {
+ v2, changed2 := fastpathTV.DecMapIntfIntfV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
*v = v2
}
+
case map[interface{}]string:
- fastpathTV.DecMapIntfStringV(v, false, d)
+ fastpathTV.DecMapIntfStringV(v, fastpathCheckNilFalse, false, d)
case *map[interface{}]string:
- var v2 map[interface{}]string
- v2, changed = fastpathTV.DecMapIntfStringV(*v, true, d)
- if changed {
+ v2, changed2 := fastpathTV.DecMapIntfStringV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
*v = v2
}
+
case map[interface{}]uint:
- fastpathTV.DecMapIntfUintV(v, false, d)
+ fastpathTV.DecMapIntfUintV(v, fastpathCheckNilFalse, false, d)
case *map[interface{}]uint:
- var v2 map[interface{}]uint
- v2, changed = fastpathTV.DecMapIntfUintV(*v, true, d)
- if changed {
+ v2, changed2 := fastpathTV.DecMapIntfUintV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
*v = v2
}
+
case map[interface{}]uint8:
- fastpathTV.DecMapIntfUint8V(v, false, d)
+ fastpathTV.DecMapIntfUint8V(v, fastpathCheckNilFalse, false, d)
case *map[interface{}]uint8:
- var v2 map[interface{}]uint8
- v2, changed = fastpathTV.DecMapIntfUint8V(*v, true, d)
- if changed {
+ v2, changed2 := fastpathTV.DecMapIntfUint8V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
*v = v2
}
+
case map[interface{}]uint16:
- fastpathTV.DecMapIntfUint16V(v, false, d)
+ fastpathTV.DecMapIntfUint16V(v, fastpathCheckNilFalse, false, d)
case *map[interface{}]uint16:
- var v2 map[interface{}]uint16
- v2, changed = fastpathTV.DecMapIntfUint16V(*v, true, d)
- if changed {
+ v2, changed2 := fastpathTV.DecMapIntfUint16V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
*v = v2
}
+
case map[interface{}]uint32:
- fastpathTV.DecMapIntfUint32V(v, false, d)
+ fastpathTV.DecMapIntfUint32V(v, fastpathCheckNilFalse, false, d)
case *map[interface{}]uint32:
- var v2 map[interface{}]uint32
- v2, changed = fastpathTV.DecMapIntfUint32V(*v, true, d)
- if changed {
+ v2, changed2 := fastpathTV.DecMapIntfUint32V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
*v = v2
}
+
case map[interface{}]uint64:
- fastpathTV.DecMapIntfUint64V(v, false, d)
+ fastpathTV.DecMapIntfUint64V(v, fastpathCheckNilFalse, false, d)
case *map[interface{}]uint64:
- var v2 map[interface{}]uint64
- v2, changed = fastpathTV.DecMapIntfUint64V(*v, true, d)
- if changed {
+ v2, changed2 := fastpathTV.DecMapIntfUint64V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
*v = v2
}
+
case map[interface{}]uintptr:
- fastpathTV.DecMapIntfUintptrV(v, false, d)
+ fastpathTV.DecMapIntfUintptrV(v, fastpathCheckNilFalse, false, d)
case *map[interface{}]uintptr:
- var v2 map[interface{}]uintptr
- v2, changed = fastpathTV.DecMapIntfUintptrV(*v, true, d)
- if changed {
+ v2, changed2 := fastpathTV.DecMapIntfUintptrV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
*v = v2
}
+
case map[interface{}]int:
- fastpathTV.DecMapIntfIntV(v, false, d)
+ fastpathTV.DecMapIntfIntV(v, fastpathCheckNilFalse, false, d)
case *map[interface{}]int:
- var v2 map[interface{}]int
- v2, changed = fastpathTV.DecMapIntfIntV(*v, true, d)
- if changed {
+ v2, changed2 := fastpathTV.DecMapIntfIntV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
*v = v2
}
+
case map[interface{}]int8:
- fastpathTV.DecMapIntfInt8V(v, false, d)
+ fastpathTV.DecMapIntfInt8V(v, fastpathCheckNilFalse, false, d)
case *map[interface{}]int8:
- var v2 map[interface{}]int8
- v2, changed = fastpathTV.DecMapIntfInt8V(*v, true, d)
- if changed {
+ v2, changed2 := fastpathTV.DecMapIntfInt8V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
*v = v2
}
+
case map[interface{}]int16:
- fastpathTV.DecMapIntfInt16V(v, false, d)
+ fastpathTV.DecMapIntfInt16V(v, fastpathCheckNilFalse, false, d)
case *map[interface{}]int16:
- var v2 map[interface{}]int16
- v2, changed = fastpathTV.DecMapIntfInt16V(*v, true, d)
- if changed {
+ v2, changed2 := fastpathTV.DecMapIntfInt16V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
*v = v2
}
+
case map[interface{}]int32:
- fastpathTV.DecMapIntfInt32V(v, false, d)
+ fastpathTV.DecMapIntfInt32V(v, fastpathCheckNilFalse, false, d)
case *map[interface{}]int32:
- var v2 map[interface{}]int32
- v2, changed = fastpathTV.DecMapIntfInt32V(*v, true, d)
- if changed {
+ v2, changed2 := fastpathTV.DecMapIntfInt32V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
*v = v2
}
+
case map[interface{}]int64:
- fastpathTV.DecMapIntfInt64V(v, false, d)
+ fastpathTV.DecMapIntfInt64V(v, fastpathCheckNilFalse, false, d)
case *map[interface{}]int64:
- var v2 map[interface{}]int64
- v2, changed = fastpathTV.DecMapIntfInt64V(*v, true, d)
- if changed {
+ v2, changed2 := fastpathTV.DecMapIntfInt64V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
*v = v2
}
+
case map[interface{}]float32:
- fastpathTV.DecMapIntfFloat32V(v, false, d)
+ fastpathTV.DecMapIntfFloat32V(v, fastpathCheckNilFalse, false, d)
case *map[interface{}]float32:
- var v2 map[interface{}]float32
- v2, changed = fastpathTV.DecMapIntfFloat32V(*v, true, d)
- if changed {
+ v2, changed2 := fastpathTV.DecMapIntfFloat32V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
*v = v2
}
+
case map[interface{}]float64:
- fastpathTV.DecMapIntfFloat64V(v, false, d)
+ fastpathTV.DecMapIntfFloat64V(v, fastpathCheckNilFalse, false, d)
case *map[interface{}]float64:
- var v2 map[interface{}]float64
- v2, changed = fastpathTV.DecMapIntfFloat64V(*v, true, d)
- if changed {
+ v2, changed2 := fastpathTV.DecMapIntfFloat64V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
*v = v2
}
+
case map[interface{}]bool:
- fastpathTV.DecMapIntfBoolV(v, false, d)
+ fastpathTV.DecMapIntfBoolV(v, fastpathCheckNilFalse, false, d)
case *map[interface{}]bool:
- var v2 map[interface{}]bool
- v2, changed = fastpathTV.DecMapIntfBoolV(*v, true, d)
- if changed {
+ v2, changed2 := fastpathTV.DecMapIntfBoolV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
*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:
+ fastpathTV.DecSliceStringV(v, fastpathCheckNilFalse, false, d)
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
+ v2, changed2 := fastpathTV.DecSliceStringV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
- 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{}:
+ fastpathTV.DecMapStringIntfV(v, fastpathCheckNilFalse, false, d)
case *map[string]interface{}:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapStringIntfV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[string]string:
+ fastpathTV.DecMapStringStringV(v, fastpathCheckNilFalse, false, d)
case *map[string]string:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapStringStringV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[string]uint:
+ fastpathTV.DecMapStringUintV(v, fastpathCheckNilFalse, false, d)
case *map[string]uint:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapStringUintV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[string]uint8:
+ fastpathTV.DecMapStringUint8V(v, fastpathCheckNilFalse, false, d)
case *map[string]uint8:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapStringUint8V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[string]uint16:
+ fastpathTV.DecMapStringUint16V(v, fastpathCheckNilFalse, false, d)
case *map[string]uint16:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapStringUint16V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[string]uint32:
+ fastpathTV.DecMapStringUint32V(v, fastpathCheckNilFalse, false, d)
case *map[string]uint32:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapStringUint32V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[string]uint64:
+ fastpathTV.DecMapStringUint64V(v, fastpathCheckNilFalse, false, d)
case *map[string]uint64:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapStringUint64V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[string]uintptr:
+ fastpathTV.DecMapStringUintptrV(v, fastpathCheckNilFalse, false, d)
case *map[string]uintptr:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapStringUintptrV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[string]int:
+ fastpathTV.DecMapStringIntV(v, fastpathCheckNilFalse, false, d)
case *map[string]int:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapStringIntV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[string]int8:
+ fastpathTV.DecMapStringInt8V(v, fastpathCheckNilFalse, false, d)
case *map[string]int8:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapStringInt8V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[string]int16:
+ fastpathTV.DecMapStringInt16V(v, fastpathCheckNilFalse, false, d)
case *map[string]int16:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapStringInt16V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[string]int32:
+ fastpathTV.DecMapStringInt32V(v, fastpathCheckNilFalse, false, d)
case *map[string]int32:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapStringInt32V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[string]int64:
+ fastpathTV.DecMapStringInt64V(v, fastpathCheckNilFalse, false, d)
case *map[string]int64:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapStringInt64V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[string]float32:
+ fastpathTV.DecMapStringFloat32V(v, fastpathCheckNilFalse, false, d)
case *map[string]float32:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapStringFloat32V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[string]float64:
+ fastpathTV.DecMapStringFloat64V(v, fastpathCheckNilFalse, false, d)
case *map[string]float64:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapStringFloat64V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[string]bool:
+ fastpathTV.DecMapStringBoolV(v, fastpathCheckNilFalse, false, d)
case *map[string]bool:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapStringBoolV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case []float32:
+ fastpathTV.DecSliceFloat32V(v, fastpathCheckNilFalse, false, d)
+ case *[]float32:
+ v2, changed2 := fastpathTV.DecSliceFloat32V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[float32]interface{}:
+ fastpathTV.DecMapFloat32IntfV(v, fastpathCheckNilFalse, false, d)
case *map[float32]interface{}:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapFloat32IntfV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[float32]string:
+ fastpathTV.DecMapFloat32StringV(v, fastpathCheckNilFalse, false, d)
case *map[float32]string:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapFloat32StringV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[float32]uint:
+ fastpathTV.DecMapFloat32UintV(v, fastpathCheckNilFalse, false, d)
case *map[float32]uint:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapFloat32UintV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[float32]uint8:
+ fastpathTV.DecMapFloat32Uint8V(v, fastpathCheckNilFalse, false, d)
case *map[float32]uint8:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapFloat32Uint8V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[float32]uint16:
+ fastpathTV.DecMapFloat32Uint16V(v, fastpathCheckNilFalse, false, d)
case *map[float32]uint16:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapFloat32Uint16V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[float32]uint32:
+ fastpathTV.DecMapFloat32Uint32V(v, fastpathCheckNilFalse, false, d)
case *map[float32]uint32:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapFloat32Uint32V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[float32]uint64:
+ fastpathTV.DecMapFloat32Uint64V(v, fastpathCheckNilFalse, false, d)
case *map[float32]uint64:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapFloat32Uint64V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[float32]uintptr:
+ fastpathTV.DecMapFloat32UintptrV(v, fastpathCheckNilFalse, false, d)
case *map[float32]uintptr:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapFloat32UintptrV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[float32]int:
+ fastpathTV.DecMapFloat32IntV(v, fastpathCheckNilFalse, false, d)
case *map[float32]int:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapFloat32IntV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[float32]int8:
+ fastpathTV.DecMapFloat32Int8V(v, fastpathCheckNilFalse, false, d)
case *map[float32]int8:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapFloat32Int8V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[float32]int16:
+ fastpathTV.DecMapFloat32Int16V(v, fastpathCheckNilFalse, false, d)
case *map[float32]int16:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapFloat32Int16V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[float32]int32:
+ fastpathTV.DecMapFloat32Int32V(v, fastpathCheckNilFalse, false, d)
case *map[float32]int32:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapFloat32Int32V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[float32]int64:
+ fastpathTV.DecMapFloat32Int64V(v, fastpathCheckNilFalse, false, d)
case *map[float32]int64:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapFloat32Int64V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[float32]float32:
+ fastpathTV.DecMapFloat32Float32V(v, fastpathCheckNilFalse, false, d)
case *map[float32]float32:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapFloat32Float32V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[float32]float64:
+ fastpathTV.DecMapFloat32Float64V(v, fastpathCheckNilFalse, false, d)
case *map[float32]float64:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapFloat32Float64V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[float32]bool:
+ fastpathTV.DecMapFloat32BoolV(v, fastpathCheckNilFalse, false, d)
case *map[float32]bool:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapFloat32BoolV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case []float64:
+ fastpathTV.DecSliceFloat64V(v, fastpathCheckNilFalse, false, d)
+ case *[]float64:
+ v2, changed2 := fastpathTV.DecSliceFloat64V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[float64]interface{}:
+ fastpathTV.DecMapFloat64IntfV(v, fastpathCheckNilFalse, false, d)
case *map[float64]interface{}:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapFloat64IntfV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[float64]string:
+ fastpathTV.DecMapFloat64StringV(v, fastpathCheckNilFalse, false, d)
case *map[float64]string:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapFloat64StringV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[float64]uint:
+ fastpathTV.DecMapFloat64UintV(v, fastpathCheckNilFalse, false, d)
case *map[float64]uint:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapFloat64UintV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[float64]uint8:
+ fastpathTV.DecMapFloat64Uint8V(v, fastpathCheckNilFalse, false, d)
case *map[float64]uint8:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapFloat64Uint8V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[float64]uint16:
+ fastpathTV.DecMapFloat64Uint16V(v, fastpathCheckNilFalse, false, d)
case *map[float64]uint16:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapFloat64Uint16V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[float64]uint32:
+ fastpathTV.DecMapFloat64Uint32V(v, fastpathCheckNilFalse, false, d)
case *map[float64]uint32:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapFloat64Uint32V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[float64]uint64:
+ fastpathTV.DecMapFloat64Uint64V(v, fastpathCheckNilFalse, false, d)
case *map[float64]uint64:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapFloat64Uint64V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[float64]uintptr:
+ fastpathTV.DecMapFloat64UintptrV(v, fastpathCheckNilFalse, false, d)
case *map[float64]uintptr:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapFloat64UintptrV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[float64]int:
+ fastpathTV.DecMapFloat64IntV(v, fastpathCheckNilFalse, false, d)
case *map[float64]int:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapFloat64IntV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[float64]int8:
+ fastpathTV.DecMapFloat64Int8V(v, fastpathCheckNilFalse, false, d)
case *map[float64]int8:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapFloat64Int8V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[float64]int16:
+ fastpathTV.DecMapFloat64Int16V(v, fastpathCheckNilFalse, false, d)
case *map[float64]int16:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapFloat64Int16V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[float64]int32:
+ fastpathTV.DecMapFloat64Int32V(v, fastpathCheckNilFalse, false, d)
case *map[float64]int32:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapFloat64Int32V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[float64]int64:
+ fastpathTV.DecMapFloat64Int64V(v, fastpathCheckNilFalse, false, d)
case *map[float64]int64:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapFloat64Int64V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[float64]float32:
+ fastpathTV.DecMapFloat64Float32V(v, fastpathCheckNilFalse, false, d)
case *map[float64]float32:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapFloat64Float32V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[float64]float64:
+ fastpathTV.DecMapFloat64Float64V(v, fastpathCheckNilFalse, false, d)
case *map[float64]float64:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapFloat64Float64V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[float64]bool:
+ fastpathTV.DecMapFloat64BoolV(v, fastpathCheckNilFalse, false, d)
case *map[float64]bool:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapFloat64BoolV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case []uint:
+ fastpathTV.DecSliceUintV(v, fastpathCheckNilFalse, false, d)
+ case *[]uint:
+ v2, changed2 := fastpathTV.DecSliceUintV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint]interface{}:
+ fastpathTV.DecMapUintIntfV(v, fastpathCheckNilFalse, false, d)
case *map[uint]interface{}:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUintIntfV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint]string:
+ fastpathTV.DecMapUintStringV(v, fastpathCheckNilFalse, false, d)
case *map[uint]string:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUintStringV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint]uint:
+ fastpathTV.DecMapUintUintV(v, fastpathCheckNilFalse, false, d)
case *map[uint]uint:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUintUintV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint]uint8:
+ fastpathTV.DecMapUintUint8V(v, fastpathCheckNilFalse, false, d)
case *map[uint]uint8:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUintUint8V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint]uint16:
+ fastpathTV.DecMapUintUint16V(v, fastpathCheckNilFalse, false, d)
case *map[uint]uint16:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUintUint16V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint]uint32:
+ fastpathTV.DecMapUintUint32V(v, fastpathCheckNilFalse, false, d)
case *map[uint]uint32:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUintUint32V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint]uint64:
+ fastpathTV.DecMapUintUint64V(v, fastpathCheckNilFalse, false, d)
case *map[uint]uint64:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUintUint64V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint]uintptr:
+ fastpathTV.DecMapUintUintptrV(v, fastpathCheckNilFalse, false, d)
case *map[uint]uintptr:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUintUintptrV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint]int:
+ fastpathTV.DecMapUintIntV(v, fastpathCheckNilFalse, false, d)
case *map[uint]int:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUintIntV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint]int8:
+ fastpathTV.DecMapUintInt8V(v, fastpathCheckNilFalse, false, d)
case *map[uint]int8:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUintInt8V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint]int16:
+ fastpathTV.DecMapUintInt16V(v, fastpathCheckNilFalse, false, d)
case *map[uint]int16:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUintInt16V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint]int32:
+ fastpathTV.DecMapUintInt32V(v, fastpathCheckNilFalse, false, d)
case *map[uint]int32:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUintInt32V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint]int64:
+ fastpathTV.DecMapUintInt64V(v, fastpathCheckNilFalse, false, d)
case *map[uint]int64:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUintInt64V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint]float32:
+ fastpathTV.DecMapUintFloat32V(v, fastpathCheckNilFalse, false, d)
case *map[uint]float32:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUintFloat32V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint]float64:
+ fastpathTV.DecMapUintFloat64V(v, fastpathCheckNilFalse, false, d)
case *map[uint]float64:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUintFloat64V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint]bool:
+ fastpathTV.DecMapUintBoolV(v, fastpathCheckNilFalse, false, d)
case *map[uint]bool:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUintBoolV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint8]interface{}:
+ fastpathTV.DecMapUint8IntfV(v, fastpathCheckNilFalse, false, d)
case *map[uint8]interface{}:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUint8IntfV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint8]string:
+ fastpathTV.DecMapUint8StringV(v, fastpathCheckNilFalse, false, d)
case *map[uint8]string:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUint8StringV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint8]uint:
+ fastpathTV.DecMapUint8UintV(v, fastpathCheckNilFalse, false, d)
case *map[uint8]uint:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUint8UintV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint8]uint8:
+ fastpathTV.DecMapUint8Uint8V(v, fastpathCheckNilFalse, false, d)
case *map[uint8]uint8:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUint8Uint8V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint8]uint16:
+ fastpathTV.DecMapUint8Uint16V(v, fastpathCheckNilFalse, false, d)
case *map[uint8]uint16:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUint8Uint16V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint8]uint32:
+ fastpathTV.DecMapUint8Uint32V(v, fastpathCheckNilFalse, false, d)
case *map[uint8]uint32:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUint8Uint32V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint8]uint64:
+ fastpathTV.DecMapUint8Uint64V(v, fastpathCheckNilFalse, false, d)
case *map[uint8]uint64:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUint8Uint64V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint8]uintptr:
+ fastpathTV.DecMapUint8UintptrV(v, fastpathCheckNilFalse, false, d)
case *map[uint8]uintptr:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUint8UintptrV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint8]int:
+ fastpathTV.DecMapUint8IntV(v, fastpathCheckNilFalse, false, d)
case *map[uint8]int:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUint8IntV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint8]int8:
+ fastpathTV.DecMapUint8Int8V(v, fastpathCheckNilFalse, false, d)
case *map[uint8]int8:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUint8Int8V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint8]int16:
+ fastpathTV.DecMapUint8Int16V(v, fastpathCheckNilFalse, false, d)
case *map[uint8]int16:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUint8Int16V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint8]int32:
+ fastpathTV.DecMapUint8Int32V(v, fastpathCheckNilFalse, false, d)
case *map[uint8]int32:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUint8Int32V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint8]int64:
+ fastpathTV.DecMapUint8Int64V(v, fastpathCheckNilFalse, false, d)
case *map[uint8]int64:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUint8Int64V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint8]float32:
+ fastpathTV.DecMapUint8Float32V(v, fastpathCheckNilFalse, false, d)
case *map[uint8]float32:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUint8Float32V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint8]float64:
+ fastpathTV.DecMapUint8Float64V(v, fastpathCheckNilFalse, false, d)
case *map[uint8]float64:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUint8Float64V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint8]bool:
+ fastpathTV.DecMapUint8BoolV(v, fastpathCheckNilFalse, false, d)
case *map[uint8]bool:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUint8BoolV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case []uint16:
+ fastpathTV.DecSliceUint16V(v, fastpathCheckNilFalse, false, d)
+ case *[]uint16:
+ v2, changed2 := fastpathTV.DecSliceUint16V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint16]interface{}:
+ fastpathTV.DecMapUint16IntfV(v, fastpathCheckNilFalse, false, d)
case *map[uint16]interface{}:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUint16IntfV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint16]string:
+ fastpathTV.DecMapUint16StringV(v, fastpathCheckNilFalse, false, d)
case *map[uint16]string:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUint16StringV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint16]uint:
+ fastpathTV.DecMapUint16UintV(v, fastpathCheckNilFalse, false, d)
case *map[uint16]uint:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUint16UintV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint16]uint8:
+ fastpathTV.DecMapUint16Uint8V(v, fastpathCheckNilFalse, false, d)
case *map[uint16]uint8:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUint16Uint8V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint16]uint16:
+ fastpathTV.DecMapUint16Uint16V(v, fastpathCheckNilFalse, false, d)
case *map[uint16]uint16:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUint16Uint16V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint16]uint32:
+ fastpathTV.DecMapUint16Uint32V(v, fastpathCheckNilFalse, false, d)
case *map[uint16]uint32:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUint16Uint32V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint16]uint64:
+ fastpathTV.DecMapUint16Uint64V(v, fastpathCheckNilFalse, false, d)
case *map[uint16]uint64:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUint16Uint64V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint16]uintptr:
+ fastpathTV.DecMapUint16UintptrV(v, fastpathCheckNilFalse, false, d)
case *map[uint16]uintptr:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUint16UintptrV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint16]int:
+ fastpathTV.DecMapUint16IntV(v, fastpathCheckNilFalse, false, d)
case *map[uint16]int:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUint16IntV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint16]int8:
+ fastpathTV.DecMapUint16Int8V(v, fastpathCheckNilFalse, false, d)
case *map[uint16]int8:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUint16Int8V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint16]int16:
+ fastpathTV.DecMapUint16Int16V(v, fastpathCheckNilFalse, false, d)
case *map[uint16]int16:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUint16Int16V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint16]int32:
+ fastpathTV.DecMapUint16Int32V(v, fastpathCheckNilFalse, false, d)
case *map[uint16]int32:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUint16Int32V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint16]int64:
+ fastpathTV.DecMapUint16Int64V(v, fastpathCheckNilFalse, false, d)
case *map[uint16]int64:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUint16Int64V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint16]float32:
+ fastpathTV.DecMapUint16Float32V(v, fastpathCheckNilFalse, false, d)
case *map[uint16]float32:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUint16Float32V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint16]float64:
+ fastpathTV.DecMapUint16Float64V(v, fastpathCheckNilFalse, false, d)
case *map[uint16]float64:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUint16Float64V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint16]bool:
+ fastpathTV.DecMapUint16BoolV(v, fastpathCheckNilFalse, false, d)
case *map[uint16]bool:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUint16BoolV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case []uint32:
+ fastpathTV.DecSliceUint32V(v, fastpathCheckNilFalse, false, d)
+ case *[]uint32:
+ v2, changed2 := fastpathTV.DecSliceUint32V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint32]interface{}:
+ fastpathTV.DecMapUint32IntfV(v, fastpathCheckNilFalse, false, d)
case *map[uint32]interface{}:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUint32IntfV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint32]string:
+ fastpathTV.DecMapUint32StringV(v, fastpathCheckNilFalse, false, d)
case *map[uint32]string:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUint32StringV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint32]uint:
+ fastpathTV.DecMapUint32UintV(v, fastpathCheckNilFalse, false, d)
case *map[uint32]uint:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUint32UintV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint32]uint8:
+ fastpathTV.DecMapUint32Uint8V(v, fastpathCheckNilFalse, false, d)
case *map[uint32]uint8:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUint32Uint8V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint32]uint16:
+ fastpathTV.DecMapUint32Uint16V(v, fastpathCheckNilFalse, false, d)
case *map[uint32]uint16:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUint32Uint16V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint32]uint32:
+ fastpathTV.DecMapUint32Uint32V(v, fastpathCheckNilFalse, false, d)
case *map[uint32]uint32:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUint32Uint32V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint32]uint64:
+ fastpathTV.DecMapUint32Uint64V(v, fastpathCheckNilFalse, false, d)
case *map[uint32]uint64:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUint32Uint64V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint32]uintptr:
+ fastpathTV.DecMapUint32UintptrV(v, fastpathCheckNilFalse, false, d)
case *map[uint32]uintptr:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUint32UintptrV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint32]int:
+ fastpathTV.DecMapUint32IntV(v, fastpathCheckNilFalse, false, d)
case *map[uint32]int:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUint32IntV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint32]int8:
+ fastpathTV.DecMapUint32Int8V(v, fastpathCheckNilFalse, false, d)
case *map[uint32]int8:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUint32Int8V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint32]int16:
+ fastpathTV.DecMapUint32Int16V(v, fastpathCheckNilFalse, false, d)
case *map[uint32]int16:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUint32Int16V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint32]int32:
+ fastpathTV.DecMapUint32Int32V(v, fastpathCheckNilFalse, false, d)
case *map[uint32]int32:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUint32Int32V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint32]int64:
+ fastpathTV.DecMapUint32Int64V(v, fastpathCheckNilFalse, false, d)
case *map[uint32]int64:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUint32Int64V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint32]float32:
+ fastpathTV.DecMapUint32Float32V(v, fastpathCheckNilFalse, false, d)
case *map[uint32]float32:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUint32Float32V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint32]float64:
+ fastpathTV.DecMapUint32Float64V(v, fastpathCheckNilFalse, false, d)
case *map[uint32]float64:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUint32Float64V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint32]bool:
+ fastpathTV.DecMapUint32BoolV(v, fastpathCheckNilFalse, false, d)
case *map[uint32]bool:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUint32BoolV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case []uint64:
+ fastpathTV.DecSliceUint64V(v, fastpathCheckNilFalse, false, d)
+ case *[]uint64:
+ v2, changed2 := fastpathTV.DecSliceUint64V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint64]interface{}:
+ fastpathTV.DecMapUint64IntfV(v, fastpathCheckNilFalse, false, d)
case *map[uint64]interface{}:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUint64IntfV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint64]string:
+ fastpathTV.DecMapUint64StringV(v, fastpathCheckNilFalse, false, d)
case *map[uint64]string:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUint64StringV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint64]uint:
+ fastpathTV.DecMapUint64UintV(v, fastpathCheckNilFalse, false, d)
case *map[uint64]uint:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUint64UintV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint64]uint8:
+ fastpathTV.DecMapUint64Uint8V(v, fastpathCheckNilFalse, false, d)
case *map[uint64]uint8:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUint64Uint8V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint64]uint16:
+ fastpathTV.DecMapUint64Uint16V(v, fastpathCheckNilFalse, false, d)
case *map[uint64]uint16:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUint64Uint16V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint64]uint32:
+ fastpathTV.DecMapUint64Uint32V(v, fastpathCheckNilFalse, false, d)
case *map[uint64]uint32:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUint64Uint32V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint64]uint64:
+ fastpathTV.DecMapUint64Uint64V(v, fastpathCheckNilFalse, false, d)
case *map[uint64]uint64:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUint64Uint64V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint64]uintptr:
+ fastpathTV.DecMapUint64UintptrV(v, fastpathCheckNilFalse, false, d)
case *map[uint64]uintptr:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUint64UintptrV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint64]int:
+ fastpathTV.DecMapUint64IntV(v, fastpathCheckNilFalse, false, d)
case *map[uint64]int:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUint64IntV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint64]int8:
+ fastpathTV.DecMapUint64Int8V(v, fastpathCheckNilFalse, false, d)
case *map[uint64]int8:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUint64Int8V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint64]int16:
+ fastpathTV.DecMapUint64Int16V(v, fastpathCheckNilFalse, false, d)
case *map[uint64]int16:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUint64Int16V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint64]int32:
+ fastpathTV.DecMapUint64Int32V(v, fastpathCheckNilFalse, false, d)
case *map[uint64]int32:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUint64Int32V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint64]int64:
+ fastpathTV.DecMapUint64Int64V(v, fastpathCheckNilFalse, false, d)
case *map[uint64]int64:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUint64Int64V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint64]float32:
+ fastpathTV.DecMapUint64Float32V(v, fastpathCheckNilFalse, false, d)
case *map[uint64]float32:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUint64Float32V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint64]float64:
+ fastpathTV.DecMapUint64Float64V(v, fastpathCheckNilFalse, false, d)
case *map[uint64]float64:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUint64Float64V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uint64]bool:
+ fastpathTV.DecMapUint64BoolV(v, fastpathCheckNilFalse, false, d)
case *map[uint64]bool:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUint64BoolV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case []uintptr:
+ fastpathTV.DecSliceUintptrV(v, fastpathCheckNilFalse, false, d)
+ case *[]uintptr:
+ v2, changed2 := fastpathTV.DecSliceUintptrV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uintptr]interface{}:
+ fastpathTV.DecMapUintptrIntfV(v, fastpathCheckNilFalse, false, d)
case *map[uintptr]interface{}:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUintptrIntfV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uintptr]string:
+ fastpathTV.DecMapUintptrStringV(v, fastpathCheckNilFalse, false, d)
case *map[uintptr]string:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUintptrStringV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uintptr]uint:
+ fastpathTV.DecMapUintptrUintV(v, fastpathCheckNilFalse, false, d)
case *map[uintptr]uint:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUintptrUintV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uintptr]uint8:
+ fastpathTV.DecMapUintptrUint8V(v, fastpathCheckNilFalse, false, d)
case *map[uintptr]uint8:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUintptrUint8V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uintptr]uint16:
+ fastpathTV.DecMapUintptrUint16V(v, fastpathCheckNilFalse, false, d)
case *map[uintptr]uint16:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUintptrUint16V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uintptr]uint32:
+ fastpathTV.DecMapUintptrUint32V(v, fastpathCheckNilFalse, false, d)
case *map[uintptr]uint32:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUintptrUint32V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uintptr]uint64:
+ fastpathTV.DecMapUintptrUint64V(v, fastpathCheckNilFalse, false, d)
case *map[uintptr]uint64:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUintptrUint64V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uintptr]uintptr:
+ fastpathTV.DecMapUintptrUintptrV(v, fastpathCheckNilFalse, false, d)
case *map[uintptr]uintptr:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUintptrUintptrV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uintptr]int:
+ fastpathTV.DecMapUintptrIntV(v, fastpathCheckNilFalse, false, d)
case *map[uintptr]int:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUintptrIntV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uintptr]int8:
+ fastpathTV.DecMapUintptrInt8V(v, fastpathCheckNilFalse, false, d)
case *map[uintptr]int8:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUintptrInt8V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uintptr]int16:
+ fastpathTV.DecMapUintptrInt16V(v, fastpathCheckNilFalse, false, d)
case *map[uintptr]int16:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUintptrInt16V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uintptr]int32:
+ fastpathTV.DecMapUintptrInt32V(v, fastpathCheckNilFalse, false, d)
case *map[uintptr]int32:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUintptrInt32V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uintptr]int64:
+ fastpathTV.DecMapUintptrInt64V(v, fastpathCheckNilFalse, false, d)
case *map[uintptr]int64:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUintptrInt64V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uintptr]float32:
+ fastpathTV.DecMapUintptrFloat32V(v, fastpathCheckNilFalse, false, d)
case *map[uintptr]float32:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUintptrFloat32V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uintptr]float64:
+ fastpathTV.DecMapUintptrFloat64V(v, fastpathCheckNilFalse, false, d)
case *map[uintptr]float64:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUintptrFloat64V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[uintptr]bool:
+ fastpathTV.DecMapUintptrBoolV(v, fastpathCheckNilFalse, false, d)
case *map[uintptr]bool:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapUintptrBoolV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case []int:
+ fastpathTV.DecSliceIntV(v, fastpathCheckNilFalse, false, d)
+ case *[]int:
+ v2, changed2 := fastpathTV.DecSliceIntV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int]interface{}:
+ fastpathTV.DecMapIntIntfV(v, fastpathCheckNilFalse, false, d)
case *map[int]interface{}:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapIntIntfV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int]string:
+ fastpathTV.DecMapIntStringV(v, fastpathCheckNilFalse, false, d)
case *map[int]string:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapIntStringV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int]uint:
+ fastpathTV.DecMapIntUintV(v, fastpathCheckNilFalse, false, d)
case *map[int]uint:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapIntUintV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int]uint8:
+ fastpathTV.DecMapIntUint8V(v, fastpathCheckNilFalse, false, d)
case *map[int]uint8:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapIntUint8V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int]uint16:
+ fastpathTV.DecMapIntUint16V(v, fastpathCheckNilFalse, false, d)
case *map[int]uint16:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapIntUint16V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int]uint32:
+ fastpathTV.DecMapIntUint32V(v, fastpathCheckNilFalse, false, d)
case *map[int]uint32:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapIntUint32V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int]uint64:
+ fastpathTV.DecMapIntUint64V(v, fastpathCheckNilFalse, false, d)
case *map[int]uint64:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapIntUint64V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int]uintptr:
+ fastpathTV.DecMapIntUintptrV(v, fastpathCheckNilFalse, false, d)
case *map[int]uintptr:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapIntUintptrV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int]int:
+ fastpathTV.DecMapIntIntV(v, fastpathCheckNilFalse, false, d)
case *map[int]int:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapIntIntV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int]int8:
+ fastpathTV.DecMapIntInt8V(v, fastpathCheckNilFalse, false, d)
case *map[int]int8:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapIntInt8V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int]int16:
+ fastpathTV.DecMapIntInt16V(v, fastpathCheckNilFalse, false, d)
case *map[int]int16:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapIntInt16V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int]int32:
+ fastpathTV.DecMapIntInt32V(v, fastpathCheckNilFalse, false, d)
case *map[int]int32:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapIntInt32V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int]int64:
+ fastpathTV.DecMapIntInt64V(v, fastpathCheckNilFalse, false, d)
case *map[int]int64:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapIntInt64V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int]float32:
+ fastpathTV.DecMapIntFloat32V(v, fastpathCheckNilFalse, false, d)
case *map[int]float32:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapIntFloat32V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int]float64:
+ fastpathTV.DecMapIntFloat64V(v, fastpathCheckNilFalse, false, d)
case *map[int]float64:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapIntFloat64V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int]bool:
+ fastpathTV.DecMapIntBoolV(v, fastpathCheckNilFalse, false, d)
case *map[int]bool:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapIntBoolV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case []int8:
+ fastpathTV.DecSliceInt8V(v, fastpathCheckNilFalse, false, d)
+ case *[]int8:
+ v2, changed2 := fastpathTV.DecSliceInt8V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int8]interface{}:
+ fastpathTV.DecMapInt8IntfV(v, fastpathCheckNilFalse, false, d)
case *map[int8]interface{}:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapInt8IntfV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int8]string:
+ fastpathTV.DecMapInt8StringV(v, fastpathCheckNilFalse, false, d)
case *map[int8]string:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapInt8StringV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int8]uint:
+ fastpathTV.DecMapInt8UintV(v, fastpathCheckNilFalse, false, d)
case *map[int8]uint:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapInt8UintV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int8]uint8:
+ fastpathTV.DecMapInt8Uint8V(v, fastpathCheckNilFalse, false, d)
case *map[int8]uint8:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapInt8Uint8V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int8]uint16:
+ fastpathTV.DecMapInt8Uint16V(v, fastpathCheckNilFalse, false, d)
case *map[int8]uint16:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapInt8Uint16V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int8]uint32:
+ fastpathTV.DecMapInt8Uint32V(v, fastpathCheckNilFalse, false, d)
case *map[int8]uint32:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapInt8Uint32V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int8]uint64:
+ fastpathTV.DecMapInt8Uint64V(v, fastpathCheckNilFalse, false, d)
case *map[int8]uint64:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapInt8Uint64V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int8]uintptr:
+ fastpathTV.DecMapInt8UintptrV(v, fastpathCheckNilFalse, false, d)
case *map[int8]uintptr:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapInt8UintptrV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int8]int:
+ fastpathTV.DecMapInt8IntV(v, fastpathCheckNilFalse, false, d)
case *map[int8]int:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapInt8IntV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int8]int8:
+ fastpathTV.DecMapInt8Int8V(v, fastpathCheckNilFalse, false, d)
case *map[int8]int8:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapInt8Int8V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int8]int16:
+ fastpathTV.DecMapInt8Int16V(v, fastpathCheckNilFalse, false, d)
case *map[int8]int16:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapInt8Int16V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int8]int32:
+ fastpathTV.DecMapInt8Int32V(v, fastpathCheckNilFalse, false, d)
case *map[int8]int32:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapInt8Int32V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int8]int64:
+ fastpathTV.DecMapInt8Int64V(v, fastpathCheckNilFalse, false, d)
case *map[int8]int64:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapInt8Int64V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int8]float32:
+ fastpathTV.DecMapInt8Float32V(v, fastpathCheckNilFalse, false, d)
case *map[int8]float32:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapInt8Float32V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int8]float64:
+ fastpathTV.DecMapInt8Float64V(v, fastpathCheckNilFalse, false, d)
case *map[int8]float64:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapInt8Float64V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int8]bool:
+ fastpathTV.DecMapInt8BoolV(v, fastpathCheckNilFalse, false, d)
case *map[int8]bool:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapInt8BoolV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case []int16:
+ fastpathTV.DecSliceInt16V(v, fastpathCheckNilFalse, false, d)
+ case *[]int16:
+ v2, changed2 := fastpathTV.DecSliceInt16V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int16]interface{}:
+ fastpathTV.DecMapInt16IntfV(v, fastpathCheckNilFalse, false, d)
case *map[int16]interface{}:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapInt16IntfV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int16]string:
+ fastpathTV.DecMapInt16StringV(v, fastpathCheckNilFalse, false, d)
case *map[int16]string:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapInt16StringV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int16]uint:
+ fastpathTV.DecMapInt16UintV(v, fastpathCheckNilFalse, false, d)
case *map[int16]uint:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapInt16UintV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int16]uint8:
+ fastpathTV.DecMapInt16Uint8V(v, fastpathCheckNilFalse, false, d)
case *map[int16]uint8:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapInt16Uint8V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int16]uint16:
+ fastpathTV.DecMapInt16Uint16V(v, fastpathCheckNilFalse, false, d)
case *map[int16]uint16:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapInt16Uint16V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int16]uint32:
+ fastpathTV.DecMapInt16Uint32V(v, fastpathCheckNilFalse, false, d)
case *map[int16]uint32:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapInt16Uint32V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int16]uint64:
+ fastpathTV.DecMapInt16Uint64V(v, fastpathCheckNilFalse, false, d)
case *map[int16]uint64:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapInt16Uint64V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int16]uintptr:
+ fastpathTV.DecMapInt16UintptrV(v, fastpathCheckNilFalse, false, d)
case *map[int16]uintptr:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapInt16UintptrV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int16]int:
+ fastpathTV.DecMapInt16IntV(v, fastpathCheckNilFalse, false, d)
case *map[int16]int:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapInt16IntV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int16]int8:
+ fastpathTV.DecMapInt16Int8V(v, fastpathCheckNilFalse, false, d)
case *map[int16]int8:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapInt16Int8V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int16]int16:
+ fastpathTV.DecMapInt16Int16V(v, fastpathCheckNilFalse, false, d)
case *map[int16]int16:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapInt16Int16V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int16]int32:
+ fastpathTV.DecMapInt16Int32V(v, fastpathCheckNilFalse, false, d)
case *map[int16]int32:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapInt16Int32V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int16]int64:
+ fastpathTV.DecMapInt16Int64V(v, fastpathCheckNilFalse, false, d)
case *map[int16]int64:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapInt16Int64V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int16]float32:
+ fastpathTV.DecMapInt16Float32V(v, fastpathCheckNilFalse, false, d)
case *map[int16]float32:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapInt16Float32V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int16]float64:
+ fastpathTV.DecMapInt16Float64V(v, fastpathCheckNilFalse, false, d)
case *map[int16]float64:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapInt16Float64V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int16]bool:
+ fastpathTV.DecMapInt16BoolV(v, fastpathCheckNilFalse, false, d)
case *map[int16]bool:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapInt16BoolV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case []int32:
+ fastpathTV.DecSliceInt32V(v, fastpathCheckNilFalse, false, d)
+ case *[]int32:
+ v2, changed2 := fastpathTV.DecSliceInt32V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int32]interface{}:
+ fastpathTV.DecMapInt32IntfV(v, fastpathCheckNilFalse, false, d)
case *map[int32]interface{}:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapInt32IntfV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int32]string:
+ fastpathTV.DecMapInt32StringV(v, fastpathCheckNilFalse, false, d)
case *map[int32]string:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapInt32StringV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int32]uint:
+ fastpathTV.DecMapInt32UintV(v, fastpathCheckNilFalse, false, d)
case *map[int32]uint:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapInt32UintV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int32]uint8:
+ fastpathTV.DecMapInt32Uint8V(v, fastpathCheckNilFalse, false, d)
case *map[int32]uint8:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapInt32Uint8V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int32]uint16:
+ fastpathTV.DecMapInt32Uint16V(v, fastpathCheckNilFalse, false, d)
case *map[int32]uint16:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapInt32Uint16V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int32]uint32:
+ fastpathTV.DecMapInt32Uint32V(v, fastpathCheckNilFalse, false, d)
case *map[int32]uint32:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapInt32Uint32V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int32]uint64:
+ fastpathTV.DecMapInt32Uint64V(v, fastpathCheckNilFalse, false, d)
case *map[int32]uint64:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapInt32Uint64V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int32]uintptr:
+ fastpathTV.DecMapInt32UintptrV(v, fastpathCheckNilFalse, false, d)
case *map[int32]uintptr:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapInt32UintptrV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int32]int:
+ fastpathTV.DecMapInt32IntV(v, fastpathCheckNilFalse, false, d)
case *map[int32]int:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapInt32IntV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int32]int8:
+ fastpathTV.DecMapInt32Int8V(v, fastpathCheckNilFalse, false, d)
case *map[int32]int8:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapInt32Int8V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int32]int16:
+ fastpathTV.DecMapInt32Int16V(v, fastpathCheckNilFalse, false, d)
case *map[int32]int16:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapInt32Int16V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int32]int32:
+ fastpathTV.DecMapInt32Int32V(v, fastpathCheckNilFalse, false, d)
case *map[int32]int32:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapInt32Int32V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int32]int64:
+ fastpathTV.DecMapInt32Int64V(v, fastpathCheckNilFalse, false, d)
case *map[int32]int64:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapInt32Int64V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int32]float32:
+ fastpathTV.DecMapInt32Float32V(v, fastpathCheckNilFalse, false, d)
case *map[int32]float32:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapInt32Float32V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int32]float64:
+ fastpathTV.DecMapInt32Float64V(v, fastpathCheckNilFalse, false, d)
case *map[int32]float64:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapInt32Float64V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int32]bool:
+ fastpathTV.DecMapInt32BoolV(v, fastpathCheckNilFalse, false, d)
case *map[int32]bool:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapInt32BoolV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case []int64:
+ fastpathTV.DecSliceInt64V(v, fastpathCheckNilFalse, false, d)
+ case *[]int64:
+ v2, changed2 := fastpathTV.DecSliceInt64V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int64]interface{}:
+ fastpathTV.DecMapInt64IntfV(v, fastpathCheckNilFalse, false, d)
case *map[int64]interface{}:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapInt64IntfV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int64]string:
+ fastpathTV.DecMapInt64StringV(v, fastpathCheckNilFalse, false, d)
case *map[int64]string:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapInt64StringV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int64]uint:
+ fastpathTV.DecMapInt64UintV(v, fastpathCheckNilFalse, false, d)
case *map[int64]uint:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapInt64UintV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int64]uint8:
+ fastpathTV.DecMapInt64Uint8V(v, fastpathCheckNilFalse, false, d)
case *map[int64]uint8:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapInt64Uint8V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int64]uint16:
+ fastpathTV.DecMapInt64Uint16V(v, fastpathCheckNilFalse, false, d)
case *map[int64]uint16:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapInt64Uint16V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int64]uint32:
+ fastpathTV.DecMapInt64Uint32V(v, fastpathCheckNilFalse, false, d)
case *map[int64]uint32:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapInt64Uint32V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int64]uint64:
+ fastpathTV.DecMapInt64Uint64V(v, fastpathCheckNilFalse, false, d)
case *map[int64]uint64:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapInt64Uint64V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int64]uintptr:
+ fastpathTV.DecMapInt64UintptrV(v, fastpathCheckNilFalse, false, d)
case *map[int64]uintptr:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapInt64UintptrV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int64]int:
+ fastpathTV.DecMapInt64IntV(v, fastpathCheckNilFalse, false, d)
case *map[int64]int:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapInt64IntV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int64]int8:
+ fastpathTV.DecMapInt64Int8V(v, fastpathCheckNilFalse, false, d)
case *map[int64]int8:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapInt64Int8V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int64]int16:
+ fastpathTV.DecMapInt64Int16V(v, fastpathCheckNilFalse, false, d)
case *map[int64]int16:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapInt64Int16V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int64]int32:
+ fastpathTV.DecMapInt64Int32V(v, fastpathCheckNilFalse, false, d)
case *map[int64]int32:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapInt64Int32V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int64]int64:
+ fastpathTV.DecMapInt64Int64V(v, fastpathCheckNilFalse, false, d)
case *map[int64]int64:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapInt64Int64V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int64]float32:
+ fastpathTV.DecMapInt64Float32V(v, fastpathCheckNilFalse, false, d)
case *map[int64]float32:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapInt64Float32V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int64]float64:
+ fastpathTV.DecMapInt64Float64V(v, fastpathCheckNilFalse, false, d)
case *map[int64]float64:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapInt64Float64V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[int64]bool:
+ fastpathTV.DecMapInt64BoolV(v, fastpathCheckNilFalse, false, d)
case *map[int64]bool:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapInt64BoolV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case []bool:
+ fastpathTV.DecSliceBoolV(v, fastpathCheckNilFalse, false, d)
+ case *[]bool:
+ v2, changed2 := fastpathTV.DecSliceBoolV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[bool]interface{}:
+ fastpathTV.DecMapBoolIntfV(v, fastpathCheckNilFalse, false, d)
case *map[bool]interface{}:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapBoolIntfV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[bool]string:
+ fastpathTV.DecMapBoolStringV(v, fastpathCheckNilFalse, false, d)
case *map[bool]string:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapBoolStringV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[bool]uint:
+ fastpathTV.DecMapBoolUintV(v, fastpathCheckNilFalse, false, d)
case *map[bool]uint:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapBoolUintV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[bool]uint8:
+ fastpathTV.DecMapBoolUint8V(v, fastpathCheckNilFalse, false, d)
case *map[bool]uint8:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapBoolUint8V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[bool]uint16:
+ fastpathTV.DecMapBoolUint16V(v, fastpathCheckNilFalse, false, d)
case *map[bool]uint16:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapBoolUint16V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[bool]uint32:
+ fastpathTV.DecMapBoolUint32V(v, fastpathCheckNilFalse, false, d)
case *map[bool]uint32:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapBoolUint32V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[bool]uint64:
+ fastpathTV.DecMapBoolUint64V(v, fastpathCheckNilFalse, false, d)
case *map[bool]uint64:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapBoolUint64V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[bool]uintptr:
+ fastpathTV.DecMapBoolUintptrV(v, fastpathCheckNilFalse, false, d)
case *map[bool]uintptr:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapBoolUintptrV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[bool]int:
+ fastpathTV.DecMapBoolIntV(v, fastpathCheckNilFalse, false, d)
case *map[bool]int:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapBoolIntV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[bool]int8:
+ fastpathTV.DecMapBoolInt8V(v, fastpathCheckNilFalse, false, d)
case *map[bool]int8:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapBoolInt8V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[bool]int16:
+ fastpathTV.DecMapBoolInt16V(v, fastpathCheckNilFalse, false, d)
case *map[bool]int16:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapBoolInt16V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[bool]int32:
+ fastpathTV.DecMapBoolInt32V(v, fastpathCheckNilFalse, false, d)
case *map[bool]int32:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapBoolInt32V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[bool]int64:
+ fastpathTV.DecMapBoolInt64V(v, fastpathCheckNilFalse, false, d)
case *map[bool]int64:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapBoolInt64V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[bool]float32:
+ fastpathTV.DecMapBoolFloat32V(v, fastpathCheckNilFalse, false, d)
case *map[bool]float32:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapBoolFloat32V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[bool]float64:
+ fastpathTV.DecMapBoolFloat64V(v, fastpathCheckNilFalse, false, d)
case *map[bool]float64:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapBoolFloat64V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
+ case map[bool]bool:
+ fastpathTV.DecMapBoolBoolV(v, fastpathCheckNilFalse, false, d)
case *map[bool]bool:
- *v = nil
+ v2, changed2 := fastpathTV.DecMapBoolBoolV(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+
default:
- _ = v // workaround https://github.com/golang/go/issues/12927 seen in go1.4
+ _ = v // TODO: workaround https://github.com/golang/go/issues/12927 (remove after go 1.6 release)
return false
}
return true
@@ -17721,29 +18123,36 @@ func fastpathDecodeSetZeroTypeSwitch(iv interface{}) bool {
// -- -- 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)
+func (f *decFnInfo) fastpathDecSliceIntfR(rv reflect.Value) {
+ array := f.seq == seqTypeArray
+ if !array && rv.CanAddr() {
+ vp := rv.Addr().Interface().(*[]interface{})
+ v, changed := fastpathTV.DecSliceIntfV(*vp, fastpathCheckNilFalse, !array, f.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)
- }
+ v := rv.Interface().([]interface{})
+ fastpathTV.DecSliceIntfV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecSliceIntfX(vp *[]interface{}, d *Decoder) {
- v, changed := f.DecSliceIntfV(*vp, true, d)
+
+func (f fastpathT) DecSliceIntfX(vp *[]interface{}, checkNil bool, d *Decoder) {
+ v, changed := f.DecSliceIntfV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecSliceIntfV(v []interface{}, canChange bool, d *Decoder) (_ []interface{}, changed bool) {
+func (_ fastpathT) DecSliceIntfV(v []interface{}, checkNil bool, canChange bool, d *Decoder) (_ []interface{}, changed bool) {
dd := d.d
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
slh, containerLenS := d.decSliceHelperStart()
if containerLenS == 0 {
if canChange {
@@ -17757,59 +18166,90 @@ func (_ fastpathT) DecSliceIntfV(v []interface{}, canChange bool, d *Decoder) (_
slh.End()
return v, changed
}
- hasLen := containerLenS > 0
- var xlen int
- if hasLen && canChange {
+
+ if containerLenS > 0 {
+ x2read := containerLenS
+ var xtrunc bool
if containerLenS > cap(v) {
- xlen = decInferLen(containerLenS, d.h.MaxInitLen, 16)
- if xlen <= cap(v) {
- v = v[:xlen]
- } else {
- v = make([]interface{}, xlen)
- }
- changed = true
- } else if containerLenS != len(v) {
- v = v[:containerLenS]
- changed = true
- }
- }
- j := 0
- for ; (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{}, 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)
+ var xlen int
+ xlen, xtrunc = decInferLen(containerLenS, d.h.MaxInitLen, 16)
+ if xtrunc {
+ if xlen <= cap(v) {
+ v = v[:xlen]
+ } else {
+ v = make([]interface{}, xlen)
+ }
+ } else {
+ v = make([]interface{}, xlen)
+ }
changed = true
} else {
- d.arrayCannotExpand(len(v), j+1)
- decodeIntoBlank = true
+ d.arrayCannotExpand(len(v), containerLenS)
+ }
+ x2read = len(v)
+ } else if containerLenS != len(v) {
+ if canChange {
+ v = v[:containerLenS]
+ changed = true
}
}
- slh.ElemContainerState(j)
- if decodeIntoBlank {
- d.swallow()
- } else if dd.TryDecodeAsNil() {
- v[j] = nil
- } else {
+ j := 0
+ for ; j < x2read; j++ {
+ slh.ElemContainerState(j)
d.decode(&v[j])
}
- }
- if canChange {
- if j < len(v) {
- v = v[:j]
+ if xtrunc {
+ for ; j < containerLenS; j++ {
+ v = append(v, nil)
+ slh.ElemContainerState(j)
+ d.decode(&v[j])
+ }
+ } else if !canChange {
+ for ; j < containerLenS; j++ {
+ slh.ElemContainerState(j)
+ d.swallow()
+ }
+ }
+ } else {
+ breakFound := dd.CheckBreak()
+ if breakFound {
+ if canChange {
+ if v == nil {
+ v = []interface{}{}
+ } else if len(v) != 0 {
+ v = v[:0]
+ }
+ changed = true
+ }
+ slh.End()
+ return v, changed
+ }
+ if cap(v) == 0 {
+ v = make([]interface{}, 1, 4)
changed = true
- } else if j == 0 && v == nil {
- v = make([]interface{}, 0)
+ }
+ j := 0
+ for ; !breakFound; j++ {
+ if j >= len(v) {
+ if canChange {
+ v = append(v, nil)
+ changed = true
+ } else {
+ d.arrayCannotExpand(len(v), j+1)
+ }
+ }
+ slh.ElemContainerState(j)
+ if j < len(v) {
+ d.decode(&v[j])
+
+ } else {
+ d.swallow()
+ }
+ breakFound = dd.CheckBreak()
+ }
+ if canChange && j < len(v) {
+ v = v[:j]
changed = true
}
}
@@ -17817,29 +18257,36 @@ func (_ fastpathT) DecSliceIntfV(v []interface{}, canChange bool, d *Decoder) (_
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)
+func (f *decFnInfo) fastpathDecSliceStringR(rv reflect.Value) {
+ array := f.seq == seqTypeArray
+ if !array && rv.CanAddr() {
+ vp := rv.Addr().Interface().(*[]string)
+ v, changed := fastpathTV.DecSliceStringV(*vp, fastpathCheckNilFalse, !array, f.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)
- }
+ v := rv.Interface().([]string)
+ fastpathTV.DecSliceStringV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecSliceStringX(vp *[]string, d *Decoder) {
- v, changed := f.DecSliceStringV(*vp, true, d)
+
+func (f fastpathT) DecSliceStringX(vp *[]string, checkNil bool, d *Decoder) {
+ v, changed := f.DecSliceStringV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecSliceStringV(v []string, canChange bool, d *Decoder) (_ []string, changed bool) {
+func (_ fastpathT) DecSliceStringV(v []string, checkNil bool, canChange bool, d *Decoder) (_ []string, changed bool) {
dd := d.d
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
slh, containerLenS := d.decSliceHelperStart()
if containerLenS == 0 {
if canChange {
@@ -17853,59 +18300,89 @@ func (_ fastpathT) DecSliceStringV(v []string, canChange bool, d *Decoder) (_ []
slh.End()
return v, changed
}
- hasLen := containerLenS > 0
- var xlen int
- if hasLen && canChange {
+
+ if containerLenS > 0 {
+ x2read := containerLenS
+ var xtrunc bool
if containerLenS > cap(v) {
- xlen = decInferLen(containerLenS, d.h.MaxInitLen, 16)
- if xlen <= cap(v) {
- v = v[:xlen]
- } else {
- v = make([]string, xlen)
- }
- changed = true
- } else if containerLenS != len(v) {
- v = v[:containerLenS]
- changed = true
- }
- }
- j := 0
- for ; (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, xlen)
- changed = true
- }
- // if indefinite, etc, then expand the slice if necessary
- var decodeIntoBlank bool
- if j >= len(v) {
if canChange {
- v = append(v, "")
+ var xlen int
+ xlen, xtrunc = decInferLen(containerLenS, d.h.MaxInitLen, 16)
+ if xtrunc {
+ if xlen <= cap(v) {
+ v = v[:xlen]
+ } else {
+ v = make([]string, xlen)
+ }
+ } else {
+ v = make([]string, xlen)
+ }
changed = true
} else {
- d.arrayCannotExpand(len(v), j+1)
- decodeIntoBlank = true
+ d.arrayCannotExpand(len(v), containerLenS)
+ }
+ x2read = len(v)
+ } else if containerLenS != len(v) {
+ if canChange {
+ v = v[:containerLenS]
+ changed = true
}
}
- slh.ElemContainerState(j)
- if decodeIntoBlank {
- d.swallow()
- } else if dd.TryDecodeAsNil() {
- v[j] = ""
- } else {
+ j := 0
+ for ; j < x2read; j++ {
+ slh.ElemContainerState(j)
v[j] = dd.DecodeString()
}
- }
- if canChange {
- if j < len(v) {
- v = v[:j]
+ if xtrunc {
+ for ; j < containerLenS; j++ {
+ v = append(v, "")
+ slh.ElemContainerState(j)
+ v[j] = dd.DecodeString()
+ }
+ } else if !canChange {
+ for ; j < containerLenS; j++ {
+ slh.ElemContainerState(j)
+ d.swallow()
+ }
+ }
+ } else {
+ breakFound := dd.CheckBreak()
+ if breakFound {
+ if canChange {
+ if v == nil {
+ v = []string{}
+ } else if len(v) != 0 {
+ v = v[:0]
+ }
+ changed = true
+ }
+ slh.End()
+ return v, changed
+ }
+ if cap(v) == 0 {
+ v = make([]string, 1, 4)
changed = true
- } else if j == 0 && v == nil {
- v = make([]string, 0)
+ }
+ j := 0
+ for ; !breakFound; j++ {
+ if j >= len(v) {
+ if canChange {
+ v = append(v, "")
+ changed = true
+ } else {
+ d.arrayCannotExpand(len(v), j+1)
+ }
+ }
+ slh.ElemContainerState(j)
+ if j < len(v) {
+ v[j] = dd.DecodeString()
+ } else {
+ d.swallow()
+ }
+ breakFound = dd.CheckBreak()
+ }
+ if canChange && j < len(v) {
+ v = v[:j]
changed = true
}
}
@@ -17913,29 +18390,36 @@ func (_ fastpathT) DecSliceStringV(v []string, canChange bool, d *Decoder) (_ []
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)
+func (f *decFnInfo) fastpathDecSliceFloat32R(rv reflect.Value) {
+ array := f.seq == seqTypeArray
+ if !array && rv.CanAddr() {
+ vp := rv.Addr().Interface().(*[]float32)
+ v, changed := fastpathTV.DecSliceFloat32V(*vp, fastpathCheckNilFalse, !array, f.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)
- }
+ v := rv.Interface().([]float32)
+ fastpathTV.DecSliceFloat32V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecSliceFloat32X(vp *[]float32, d *Decoder) {
- v, changed := f.DecSliceFloat32V(*vp, true, d)
+
+func (f fastpathT) DecSliceFloat32X(vp *[]float32, checkNil bool, d *Decoder) {
+ v, changed := f.DecSliceFloat32V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecSliceFloat32V(v []float32, canChange bool, d *Decoder) (_ []float32, changed bool) {
+func (_ fastpathT) DecSliceFloat32V(v []float32, checkNil bool, canChange bool, d *Decoder) (_ []float32, changed bool) {
dd := d.d
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
slh, containerLenS := d.decSliceHelperStart()
if containerLenS == 0 {
if canChange {
@@ -17949,59 +18433,89 @@ func (_ fastpathT) DecSliceFloat32V(v []float32, canChange bool, d *Decoder) (_
slh.End()
return v, changed
}
- hasLen := containerLenS > 0
- var xlen int
- if hasLen && canChange {
+
+ if containerLenS > 0 {
+ x2read := containerLenS
+ var xtrunc bool
if containerLenS > cap(v) {
- xlen = decInferLen(containerLenS, d.h.MaxInitLen, 4)
- if xlen <= cap(v) {
- v = v[:xlen]
- } else {
- v = make([]float32, xlen)
- }
- changed = true
- } else if containerLenS != len(v) {
- v = v[:containerLenS]
- changed = true
- }
- }
- j := 0
- for ; (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, 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)
+ var xlen int
+ xlen, xtrunc = decInferLen(containerLenS, d.h.MaxInitLen, 4)
+ if xtrunc {
+ if xlen <= cap(v) {
+ v = v[:xlen]
+ } else {
+ v = make([]float32, xlen)
+ }
+ } else {
+ v = make([]float32, xlen)
+ }
changed = true
} else {
- d.arrayCannotExpand(len(v), j+1)
- decodeIntoBlank = true
+ d.arrayCannotExpand(len(v), containerLenS)
+ }
+ x2read = len(v)
+ } else if containerLenS != len(v) {
+ if canChange {
+ v = v[:containerLenS]
+ changed = true
}
}
- slh.ElemContainerState(j)
- if decodeIntoBlank {
- d.swallow()
- } else if dd.TryDecodeAsNil() {
- v[j] = 0
- } else {
- v[j] = float32(chkOvf.Float32V(dd.DecodeFloat64()))
+ j := 0
+ for ; j < x2read; j++ {
+ slh.ElemContainerState(j)
+ v[j] = float32(dd.DecodeFloat(true))
}
- }
- if canChange {
- if j < len(v) {
- v = v[:j]
+ if xtrunc {
+ for ; j < containerLenS; j++ {
+ v = append(v, 0)
+ slh.ElemContainerState(j)
+ v[j] = float32(dd.DecodeFloat(true))
+ }
+ } else if !canChange {
+ for ; j < containerLenS; j++ {
+ slh.ElemContainerState(j)
+ d.swallow()
+ }
+ }
+ } else {
+ breakFound := dd.CheckBreak()
+ if breakFound {
+ if canChange {
+ if v == nil {
+ v = []float32{}
+ } else if len(v) != 0 {
+ v = v[:0]
+ }
+ changed = true
+ }
+ slh.End()
+ return v, changed
+ }
+ if cap(v) == 0 {
+ v = make([]float32, 1, 4)
changed = true
- } else if j == 0 && v == nil {
- v = make([]float32, 0)
+ }
+ j := 0
+ for ; !breakFound; j++ {
+ if j >= len(v) {
+ if canChange {
+ v = append(v, 0)
+ changed = true
+ } else {
+ d.arrayCannotExpand(len(v), j+1)
+ }
+ }
+ slh.ElemContainerState(j)
+ if j < len(v) {
+ v[j] = float32(dd.DecodeFloat(true))
+ } else {
+ d.swallow()
+ }
+ breakFound = dd.CheckBreak()
+ }
+ if canChange && j < len(v) {
+ v = v[:j]
changed = true
}
}
@@ -18009,29 +18523,36 @@ func (_ fastpathT) DecSliceFloat32V(v []float32, canChange bool, d *Decoder) (_
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)
+func (f *decFnInfo) fastpathDecSliceFloat64R(rv reflect.Value) {
+ array := f.seq == seqTypeArray
+ if !array && rv.CanAddr() {
+ vp := rv.Addr().Interface().(*[]float64)
+ v, changed := fastpathTV.DecSliceFloat64V(*vp, fastpathCheckNilFalse, !array, f.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)
- }
+ v := rv.Interface().([]float64)
+ fastpathTV.DecSliceFloat64V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecSliceFloat64X(vp *[]float64, d *Decoder) {
- v, changed := f.DecSliceFloat64V(*vp, true, d)
+
+func (f fastpathT) DecSliceFloat64X(vp *[]float64, checkNil bool, d *Decoder) {
+ v, changed := f.DecSliceFloat64V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecSliceFloat64V(v []float64, canChange bool, d *Decoder) (_ []float64, changed bool) {
+func (_ fastpathT) DecSliceFloat64V(v []float64, checkNil bool, canChange bool, d *Decoder) (_ []float64, changed bool) {
dd := d.d
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
slh, containerLenS := d.decSliceHelperStart()
if containerLenS == 0 {
if canChange {
@@ -18045,59 +18566,89 @@ func (_ fastpathT) DecSliceFloat64V(v []float64, canChange bool, d *Decoder) (_
slh.End()
return v, changed
}
- hasLen := containerLenS > 0
- var xlen int
- if hasLen && canChange {
+
+ if containerLenS > 0 {
+ x2read := containerLenS
+ var xtrunc bool
if containerLenS > cap(v) {
- xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8)
- if xlen <= cap(v) {
- v = v[:xlen]
- } else {
- v = make([]float64, xlen)
- }
- changed = true
- } else if containerLenS != len(v) {
- v = v[:containerLenS]
- changed = true
- }
- }
- j := 0
- for ; (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, 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)
+ var xlen int
+ xlen, xtrunc = decInferLen(containerLenS, d.h.MaxInitLen, 8)
+ if xtrunc {
+ if xlen <= cap(v) {
+ v = v[:xlen]
+ } else {
+ v = make([]float64, xlen)
+ }
+ } else {
+ v = make([]float64, xlen)
+ }
changed = true
} else {
- d.arrayCannotExpand(len(v), j+1)
- decodeIntoBlank = true
+ d.arrayCannotExpand(len(v), containerLenS)
+ }
+ x2read = len(v)
+ } else if containerLenS != len(v) {
+ if canChange {
+ v = v[:containerLenS]
+ changed = true
}
}
- slh.ElemContainerState(j)
- if decodeIntoBlank {
- d.swallow()
- } else if dd.TryDecodeAsNil() {
- v[j] = 0
- } else {
- v[j] = dd.DecodeFloat64()
+ j := 0
+ for ; j < x2read; j++ {
+ slh.ElemContainerState(j)
+ v[j] = dd.DecodeFloat(false)
}
- }
- if canChange {
- if j < len(v) {
- v = v[:j]
+ if xtrunc {
+ for ; j < containerLenS; j++ {
+ v = append(v, 0)
+ slh.ElemContainerState(j)
+ v[j] = dd.DecodeFloat(false)
+ }
+ } else if !canChange {
+ for ; j < containerLenS; j++ {
+ slh.ElemContainerState(j)
+ d.swallow()
+ }
+ }
+ } else {
+ breakFound := dd.CheckBreak()
+ if breakFound {
+ if canChange {
+ if v == nil {
+ v = []float64{}
+ } else if len(v) != 0 {
+ v = v[:0]
+ }
+ changed = true
+ }
+ slh.End()
+ return v, changed
+ }
+ if cap(v) == 0 {
+ v = make([]float64, 1, 4)
changed = true
- } else if j == 0 && v == nil {
- v = make([]float64, 0)
+ }
+ j := 0
+ for ; !breakFound; j++ {
+ if j >= len(v) {
+ if canChange {
+ v = append(v, 0)
+ changed = true
+ } else {
+ d.arrayCannotExpand(len(v), j+1)
+ }
+ }
+ slh.ElemContainerState(j)
+ if j < len(v) {
+ v[j] = dd.DecodeFloat(false)
+ } else {
+ d.swallow()
+ }
+ breakFound = dd.CheckBreak()
+ }
+ if canChange && j < len(v) {
+ v = v[:j]
changed = true
}
}
@@ -18105,29 +18656,36 @@ func (_ fastpathT) DecSliceFloat64V(v []float64, canChange bool, d *Decoder) (_
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)
+func (f *decFnInfo) fastpathDecSliceUintR(rv reflect.Value) {
+ array := f.seq == seqTypeArray
+ if !array && rv.CanAddr() {
+ vp := rv.Addr().Interface().(*[]uint)
+ v, changed := fastpathTV.DecSliceUintV(*vp, fastpathCheckNilFalse, !array, f.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)
- }
+ v := rv.Interface().([]uint)
+ fastpathTV.DecSliceUintV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecSliceUintX(vp *[]uint, d *Decoder) {
- v, changed := f.DecSliceUintV(*vp, true, d)
+
+func (f fastpathT) DecSliceUintX(vp *[]uint, checkNil bool, d *Decoder) {
+ v, changed := f.DecSliceUintV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecSliceUintV(v []uint, canChange bool, d *Decoder) (_ []uint, changed bool) {
+func (_ fastpathT) DecSliceUintV(v []uint, checkNil bool, canChange bool, d *Decoder) (_ []uint, changed bool) {
dd := d.d
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
slh, containerLenS := d.decSliceHelperStart()
if containerLenS == 0 {
if canChange {
@@ -18141,59 +18699,89 @@ func (_ fastpathT) DecSliceUintV(v []uint, canChange bool, d *Decoder) (_ []uint
slh.End()
return v, changed
}
- hasLen := containerLenS > 0
- var xlen int
- if hasLen && canChange {
+
+ if containerLenS > 0 {
+ x2read := containerLenS
+ var xtrunc bool
if containerLenS > cap(v) {
- xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8)
- if xlen <= cap(v) {
- v = v[:xlen]
- } else {
- v = make([]uint, xlen)
- }
- changed = true
- } else if containerLenS != len(v) {
- v = v[:containerLenS]
- changed = true
- }
- }
- j := 0
- for ; (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, 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)
+ var xlen int
+ xlen, xtrunc = decInferLen(containerLenS, d.h.MaxInitLen, 8)
+ if xtrunc {
+ if xlen <= cap(v) {
+ v = v[:xlen]
+ } else {
+ v = make([]uint, xlen)
+ }
+ } else {
+ v = make([]uint, xlen)
+ }
changed = true
} else {
- d.arrayCannotExpand(len(v), j+1)
- decodeIntoBlank = true
+ d.arrayCannotExpand(len(v), containerLenS)
+ }
+ x2read = len(v)
+ } else if containerLenS != len(v) {
+ if canChange {
+ v = v[:containerLenS]
+ changed = true
}
}
- slh.ElemContainerState(j)
- if decodeIntoBlank {
- d.swallow()
- } else if dd.TryDecodeAsNil() {
- v[j] = 0
- } else {
- v[j] = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
+ j := 0
+ for ; j < x2read; j++ {
+ slh.ElemContainerState(j)
+ v[j] = uint(dd.DecodeUint(uintBitsize))
}
- }
- if canChange {
- if j < len(v) {
- v = v[:j]
+ if xtrunc {
+ for ; j < containerLenS; j++ {
+ v = append(v, 0)
+ slh.ElemContainerState(j)
+ v[j] = uint(dd.DecodeUint(uintBitsize))
+ }
+ } else if !canChange {
+ for ; j < containerLenS; j++ {
+ slh.ElemContainerState(j)
+ d.swallow()
+ }
+ }
+ } else {
+ breakFound := dd.CheckBreak()
+ if breakFound {
+ if canChange {
+ if v == nil {
+ v = []uint{}
+ } else if len(v) != 0 {
+ v = v[:0]
+ }
+ changed = true
+ }
+ slh.End()
+ return v, changed
+ }
+ if cap(v) == 0 {
+ v = make([]uint, 1, 4)
changed = true
- } else if j == 0 && v == nil {
- v = make([]uint, 0)
+ }
+ j := 0
+ for ; !breakFound; j++ {
+ if j >= len(v) {
+ if canChange {
+ v = append(v, 0)
+ changed = true
+ } else {
+ d.arrayCannotExpand(len(v), j+1)
+ }
+ }
+ slh.ElemContainerState(j)
+ if j < len(v) {
+ v[j] = uint(dd.DecodeUint(uintBitsize))
+ } else {
+ d.swallow()
+ }
+ breakFound = dd.CheckBreak()
+ }
+ if canChange && j < len(v) {
+ v = v[:j]
changed = true
}
}
@@ -18201,125 +18789,36 @@ func (_ fastpathT) DecSliceUintV(v []uint, canChange bool, d *Decoder) (_ []uint
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)
+func (f *decFnInfo) fastpathDecSliceUint16R(rv reflect.Value) {
+ array := f.seq == seqTypeArray
+ if !array && rv.CanAddr() {
+ vp := rv.Addr().Interface().(*[]uint16)
+ v, changed := fastpathTV.DecSliceUint16V(*vp, fastpathCheckNilFalse, !array, f.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)
- }
+ v := rv.Interface().([]uint16)
+ fastpathTV.DecSliceUint16V(v, fastpathCheckNilFalse, false, f.d)
}
}
-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
- }
- 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[:xlen]
- } else {
- v = make([]uint8, xlen)
- }
- changed = true
- } else if containerLenS != len(v) {
- v = v[:containerLenS]
- changed = true
- }
- }
- j := 0
- for ; (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, 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[j] = 0
- } else {
- v[j] = uint8(chkOvf.UintV(dd.DecodeUint64(), 8))
- }
- }
- if canChange {
- if j < len(v) {
- v = v[:j]
- changed = true
- } else if j == 0 && v == nil {
- v = make([]uint8, 0)
- changed = true
- }
- }
- slh.End()
- 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)
+func (f fastpathT) DecSliceUint16X(vp *[]uint16, checkNil bool, d *Decoder) {
+ v, changed := f.DecSliceUint16V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecSliceUint16V(v []uint16, canChange bool, d *Decoder) (_ []uint16, changed bool) {
+func (_ fastpathT) DecSliceUint16V(v []uint16, checkNil bool, canChange bool, d *Decoder) (_ []uint16, changed bool) {
dd := d.d
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
slh, containerLenS := d.decSliceHelperStart()
if containerLenS == 0 {
if canChange {
@@ -18333,59 +18832,89 @@ func (_ fastpathT) DecSliceUint16V(v []uint16, canChange bool, d *Decoder) (_ []
slh.End()
return v, changed
}
- hasLen := containerLenS > 0
- var xlen int
- if hasLen && canChange {
+
+ if containerLenS > 0 {
+ x2read := containerLenS
+ var xtrunc bool
if containerLenS > cap(v) {
- xlen = decInferLen(containerLenS, d.h.MaxInitLen, 2)
- if xlen <= cap(v) {
- v = v[:xlen]
- } else {
- v = make([]uint16, xlen)
- }
- changed = true
- } else if containerLenS != len(v) {
- v = v[:containerLenS]
- changed = true
- }
- }
- j := 0
- for ; (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, 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)
+ var xlen int
+ xlen, xtrunc = decInferLen(containerLenS, d.h.MaxInitLen, 2)
+ if xtrunc {
+ if xlen <= cap(v) {
+ v = v[:xlen]
+ } else {
+ v = make([]uint16, xlen)
+ }
+ } else {
+ v = make([]uint16, xlen)
+ }
changed = true
} else {
- d.arrayCannotExpand(len(v), j+1)
- decodeIntoBlank = true
+ d.arrayCannotExpand(len(v), containerLenS)
+ }
+ x2read = len(v)
+ } else if containerLenS != len(v) {
+ if canChange {
+ v = v[:containerLenS]
+ changed = true
}
}
- slh.ElemContainerState(j)
- if decodeIntoBlank {
- d.swallow()
- } else if dd.TryDecodeAsNil() {
- v[j] = 0
- } else {
- v[j] = uint16(chkOvf.UintV(dd.DecodeUint64(), 16))
+ j := 0
+ for ; j < x2read; j++ {
+ slh.ElemContainerState(j)
+ v[j] = uint16(dd.DecodeUint(16))
}
- }
- if canChange {
- if j < len(v) {
- v = v[:j]
+ if xtrunc {
+ for ; j < containerLenS; j++ {
+ v = append(v, 0)
+ slh.ElemContainerState(j)
+ v[j] = uint16(dd.DecodeUint(16))
+ }
+ } else if !canChange {
+ for ; j < containerLenS; j++ {
+ slh.ElemContainerState(j)
+ d.swallow()
+ }
+ }
+ } else {
+ breakFound := dd.CheckBreak()
+ if breakFound {
+ if canChange {
+ if v == nil {
+ v = []uint16{}
+ } else if len(v) != 0 {
+ v = v[:0]
+ }
+ changed = true
+ }
+ slh.End()
+ return v, changed
+ }
+ if cap(v) == 0 {
+ v = make([]uint16, 1, 4)
changed = true
- } else if j == 0 && v == nil {
- v = make([]uint16, 0)
+ }
+ j := 0
+ for ; !breakFound; j++ {
+ if j >= len(v) {
+ if canChange {
+ v = append(v, 0)
+ changed = true
+ } else {
+ d.arrayCannotExpand(len(v), j+1)
+ }
+ }
+ slh.ElemContainerState(j)
+ if j < len(v) {
+ v[j] = uint16(dd.DecodeUint(16))
+ } else {
+ d.swallow()
+ }
+ breakFound = dd.CheckBreak()
+ }
+ if canChange && j < len(v) {
+ v = v[:j]
changed = true
}
}
@@ -18393,29 +18922,36 @@ func (_ fastpathT) DecSliceUint16V(v []uint16, canChange bool, d *Decoder) (_ []
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)
+func (f *decFnInfo) fastpathDecSliceUint32R(rv reflect.Value) {
+ array := f.seq == seqTypeArray
+ if !array && rv.CanAddr() {
+ vp := rv.Addr().Interface().(*[]uint32)
+ v, changed := fastpathTV.DecSliceUint32V(*vp, fastpathCheckNilFalse, !array, f.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)
- }
+ v := rv.Interface().([]uint32)
+ fastpathTV.DecSliceUint32V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecSliceUint32X(vp *[]uint32, d *Decoder) {
- v, changed := f.DecSliceUint32V(*vp, true, d)
+
+func (f fastpathT) DecSliceUint32X(vp *[]uint32, checkNil bool, d *Decoder) {
+ v, changed := f.DecSliceUint32V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecSliceUint32V(v []uint32, canChange bool, d *Decoder) (_ []uint32, changed bool) {
+func (_ fastpathT) DecSliceUint32V(v []uint32, checkNil bool, canChange bool, d *Decoder) (_ []uint32, changed bool) {
dd := d.d
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
slh, containerLenS := d.decSliceHelperStart()
if containerLenS == 0 {
if canChange {
@@ -18429,59 +18965,89 @@ func (_ fastpathT) DecSliceUint32V(v []uint32, canChange bool, d *Decoder) (_ []
slh.End()
return v, changed
}
- hasLen := containerLenS > 0
- var xlen int
- if hasLen && canChange {
+
+ if containerLenS > 0 {
+ x2read := containerLenS
+ var xtrunc bool
if containerLenS > cap(v) {
- xlen = decInferLen(containerLenS, d.h.MaxInitLen, 4)
- if xlen <= cap(v) {
- v = v[:xlen]
- } else {
- v = make([]uint32, xlen)
- }
- changed = true
- } else if containerLenS != len(v) {
- v = v[:containerLenS]
- changed = true
- }
- }
- j := 0
- for ; (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, 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)
+ var xlen int
+ xlen, xtrunc = decInferLen(containerLenS, d.h.MaxInitLen, 4)
+ if xtrunc {
+ if xlen <= cap(v) {
+ v = v[:xlen]
+ } else {
+ v = make([]uint32, xlen)
+ }
+ } else {
+ v = make([]uint32, xlen)
+ }
changed = true
} else {
- d.arrayCannotExpand(len(v), j+1)
- decodeIntoBlank = true
+ d.arrayCannotExpand(len(v), containerLenS)
+ }
+ x2read = len(v)
+ } else if containerLenS != len(v) {
+ if canChange {
+ v = v[:containerLenS]
+ changed = true
}
}
- slh.ElemContainerState(j)
- if decodeIntoBlank {
- d.swallow()
- } else if dd.TryDecodeAsNil() {
- v[j] = 0
- } else {
- v[j] = uint32(chkOvf.UintV(dd.DecodeUint64(), 32))
+ j := 0
+ for ; j < x2read; j++ {
+ slh.ElemContainerState(j)
+ v[j] = uint32(dd.DecodeUint(32))
}
- }
- if canChange {
- if j < len(v) {
- v = v[:j]
+ if xtrunc {
+ for ; j < containerLenS; j++ {
+ v = append(v, 0)
+ slh.ElemContainerState(j)
+ v[j] = uint32(dd.DecodeUint(32))
+ }
+ } else if !canChange {
+ for ; j < containerLenS; j++ {
+ slh.ElemContainerState(j)
+ d.swallow()
+ }
+ }
+ } else {
+ breakFound := dd.CheckBreak()
+ if breakFound {
+ if canChange {
+ if v == nil {
+ v = []uint32{}
+ } else if len(v) != 0 {
+ v = v[:0]
+ }
+ changed = true
+ }
+ slh.End()
+ return v, changed
+ }
+ if cap(v) == 0 {
+ v = make([]uint32, 1, 4)
changed = true
- } else if j == 0 && v == nil {
- v = make([]uint32, 0)
+ }
+ j := 0
+ for ; !breakFound; j++ {
+ if j >= len(v) {
+ if canChange {
+ v = append(v, 0)
+ changed = true
+ } else {
+ d.arrayCannotExpand(len(v), j+1)
+ }
+ }
+ slh.ElemContainerState(j)
+ if j < len(v) {
+ v[j] = uint32(dd.DecodeUint(32))
+ } else {
+ d.swallow()
+ }
+ breakFound = dd.CheckBreak()
+ }
+ if canChange && j < len(v) {
+ v = v[:j]
changed = true
}
}
@@ -18489,29 +19055,36 @@ func (_ fastpathT) DecSliceUint32V(v []uint32, canChange bool, d *Decoder) (_ []
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)
+func (f *decFnInfo) fastpathDecSliceUint64R(rv reflect.Value) {
+ array := f.seq == seqTypeArray
+ if !array && rv.CanAddr() {
+ vp := rv.Addr().Interface().(*[]uint64)
+ v, changed := fastpathTV.DecSliceUint64V(*vp, fastpathCheckNilFalse, !array, f.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)
- }
+ v := rv.Interface().([]uint64)
+ fastpathTV.DecSliceUint64V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecSliceUint64X(vp *[]uint64, d *Decoder) {
- v, changed := f.DecSliceUint64V(*vp, true, d)
+
+func (f fastpathT) DecSliceUint64X(vp *[]uint64, checkNil bool, d *Decoder) {
+ v, changed := f.DecSliceUint64V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecSliceUint64V(v []uint64, canChange bool, d *Decoder) (_ []uint64, changed bool) {
+func (_ fastpathT) DecSliceUint64V(v []uint64, checkNil bool, canChange bool, d *Decoder) (_ []uint64, changed bool) {
dd := d.d
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
slh, containerLenS := d.decSliceHelperStart()
if containerLenS == 0 {
if canChange {
@@ -18525,59 +19098,89 @@ func (_ fastpathT) DecSliceUint64V(v []uint64, canChange bool, d *Decoder) (_ []
slh.End()
return v, changed
}
- hasLen := containerLenS > 0
- var xlen int
- if hasLen && canChange {
+
+ if containerLenS > 0 {
+ x2read := containerLenS
+ var xtrunc bool
if containerLenS > cap(v) {
- xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8)
- if xlen <= cap(v) {
- v = v[:xlen]
- } else {
- v = make([]uint64, xlen)
- }
- changed = true
- } else if containerLenS != len(v) {
- v = v[:containerLenS]
- changed = true
- }
- }
- j := 0
- for ; (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, 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)
+ var xlen int
+ xlen, xtrunc = decInferLen(containerLenS, d.h.MaxInitLen, 8)
+ if xtrunc {
+ if xlen <= cap(v) {
+ v = v[:xlen]
+ } else {
+ v = make([]uint64, xlen)
+ }
+ } else {
+ v = make([]uint64, xlen)
+ }
changed = true
} else {
- d.arrayCannotExpand(len(v), j+1)
- decodeIntoBlank = true
+ d.arrayCannotExpand(len(v), containerLenS)
+ }
+ x2read = len(v)
+ } else if containerLenS != len(v) {
+ if canChange {
+ v = v[:containerLenS]
+ changed = true
}
}
- slh.ElemContainerState(j)
- if decodeIntoBlank {
- d.swallow()
- } else if dd.TryDecodeAsNil() {
- v[j] = 0
- } else {
- v[j] = dd.DecodeUint64()
+ j := 0
+ for ; j < x2read; j++ {
+ slh.ElemContainerState(j)
+ v[j] = dd.DecodeUint(64)
}
- }
- if canChange {
- if j < len(v) {
- v = v[:j]
+ if xtrunc {
+ for ; j < containerLenS; j++ {
+ v = append(v, 0)
+ slh.ElemContainerState(j)
+ v[j] = dd.DecodeUint(64)
+ }
+ } else if !canChange {
+ for ; j < containerLenS; j++ {
+ slh.ElemContainerState(j)
+ d.swallow()
+ }
+ }
+ } else {
+ breakFound := dd.CheckBreak()
+ if breakFound {
+ if canChange {
+ if v == nil {
+ v = []uint64{}
+ } else if len(v) != 0 {
+ v = v[:0]
+ }
+ changed = true
+ }
+ slh.End()
+ return v, changed
+ }
+ if cap(v) == 0 {
+ v = make([]uint64, 1, 4)
changed = true
- } else if j == 0 && v == nil {
- v = make([]uint64, 0)
+ }
+ j := 0
+ for ; !breakFound; j++ {
+ if j >= len(v) {
+ if canChange {
+ v = append(v, 0)
+ changed = true
+ } else {
+ d.arrayCannotExpand(len(v), j+1)
+ }
+ }
+ slh.ElemContainerState(j)
+ if j < len(v) {
+ v[j] = dd.DecodeUint(64)
+ } else {
+ d.swallow()
+ }
+ breakFound = dd.CheckBreak()
+ }
+ if canChange && j < len(v) {
+ v = v[:j]
changed = true
}
}
@@ -18585,29 +19188,36 @@ func (_ fastpathT) DecSliceUint64V(v []uint64, canChange bool, d *Decoder) (_ []
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)
+func (f *decFnInfo) fastpathDecSliceUintptrR(rv reflect.Value) {
+ array := f.seq == seqTypeArray
+ if !array && rv.CanAddr() {
+ vp := rv.Addr().Interface().(*[]uintptr)
+ v, changed := fastpathTV.DecSliceUintptrV(*vp, fastpathCheckNilFalse, !array, f.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)
- }
+ v := rv.Interface().([]uintptr)
+ fastpathTV.DecSliceUintptrV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecSliceUintptrX(vp *[]uintptr, d *Decoder) {
- v, changed := f.DecSliceUintptrV(*vp, true, d)
+
+func (f fastpathT) DecSliceUintptrX(vp *[]uintptr, checkNil bool, d *Decoder) {
+ v, changed := f.DecSliceUintptrV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecSliceUintptrV(v []uintptr, canChange bool, d *Decoder) (_ []uintptr, changed bool) {
+func (_ fastpathT) DecSliceUintptrV(v []uintptr, checkNil bool, canChange bool, d *Decoder) (_ []uintptr, changed bool) {
dd := d.d
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
slh, containerLenS := d.decSliceHelperStart()
if containerLenS == 0 {
if canChange {
@@ -18621,59 +19231,89 @@ func (_ fastpathT) DecSliceUintptrV(v []uintptr, canChange bool, d *Decoder) (_
slh.End()
return v, changed
}
- hasLen := containerLenS > 0
- var xlen int
- if hasLen && canChange {
+
+ if containerLenS > 0 {
+ x2read := containerLenS
+ var xtrunc bool
if containerLenS > cap(v) {
- xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8)
- if xlen <= cap(v) {
- v = v[:xlen]
- } else {
- v = make([]uintptr, xlen)
- }
- changed = true
- } else if containerLenS != len(v) {
- v = v[:containerLenS]
- changed = true
- }
- }
- j := 0
- for ; (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, 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)
+ var xlen int
+ xlen, xtrunc = decInferLen(containerLenS, d.h.MaxInitLen, 8)
+ if xtrunc {
+ if xlen <= cap(v) {
+ v = v[:xlen]
+ } else {
+ v = make([]uintptr, xlen)
+ }
+ } else {
+ v = make([]uintptr, xlen)
+ }
changed = true
} else {
- d.arrayCannotExpand(len(v), j+1)
- decodeIntoBlank = true
+ d.arrayCannotExpand(len(v), containerLenS)
+ }
+ x2read = len(v)
+ } else if containerLenS != len(v) {
+ if canChange {
+ v = v[:containerLenS]
+ changed = true
}
}
- slh.ElemContainerState(j)
- if decodeIntoBlank {
- d.swallow()
- } else if dd.TryDecodeAsNil() {
- v[j] = 0
- } else {
- v[j] = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
+ j := 0
+ for ; j < x2read; j++ {
+ slh.ElemContainerState(j)
+ v[j] = uintptr(dd.DecodeUint(uintBitsize))
}
- }
- if canChange {
- if j < len(v) {
- v = v[:j]
+ if xtrunc {
+ for ; j < containerLenS; j++ {
+ v = append(v, 0)
+ slh.ElemContainerState(j)
+ v[j] = uintptr(dd.DecodeUint(uintBitsize))
+ }
+ } else if !canChange {
+ for ; j < containerLenS; j++ {
+ slh.ElemContainerState(j)
+ d.swallow()
+ }
+ }
+ } else {
+ breakFound := dd.CheckBreak()
+ if breakFound {
+ if canChange {
+ if v == nil {
+ v = []uintptr{}
+ } else if len(v) != 0 {
+ v = v[:0]
+ }
+ changed = true
+ }
+ slh.End()
+ return v, changed
+ }
+ if cap(v) == 0 {
+ v = make([]uintptr, 1, 4)
changed = true
- } else if j == 0 && v == nil {
- v = make([]uintptr, 0)
+ }
+ j := 0
+ for ; !breakFound; j++ {
+ if j >= len(v) {
+ if canChange {
+ v = append(v, 0)
+ changed = true
+ } else {
+ d.arrayCannotExpand(len(v), j+1)
+ }
+ }
+ slh.ElemContainerState(j)
+ if j < len(v) {
+ v[j] = uintptr(dd.DecodeUint(uintBitsize))
+ } else {
+ d.swallow()
+ }
+ breakFound = dd.CheckBreak()
+ }
+ if canChange && j < len(v) {
+ v = v[:j]
changed = true
}
}
@@ -18681,29 +19321,36 @@ func (_ fastpathT) DecSliceUintptrV(v []uintptr, canChange bool, d *Decoder) (_
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)
+func (f *decFnInfo) fastpathDecSliceIntR(rv reflect.Value) {
+ array := f.seq == seqTypeArray
+ if !array && rv.CanAddr() {
+ vp := rv.Addr().Interface().(*[]int)
+ v, changed := fastpathTV.DecSliceIntV(*vp, fastpathCheckNilFalse, !array, f.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)
- }
+ v := rv.Interface().([]int)
+ fastpathTV.DecSliceIntV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecSliceIntX(vp *[]int, d *Decoder) {
- v, changed := f.DecSliceIntV(*vp, true, d)
+
+func (f fastpathT) DecSliceIntX(vp *[]int, checkNil bool, d *Decoder) {
+ v, changed := f.DecSliceIntV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecSliceIntV(v []int, canChange bool, d *Decoder) (_ []int, changed bool) {
+func (_ fastpathT) DecSliceIntV(v []int, checkNil bool, canChange bool, d *Decoder) (_ []int, changed bool) {
dd := d.d
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
slh, containerLenS := d.decSliceHelperStart()
if containerLenS == 0 {
if canChange {
@@ -18717,59 +19364,89 @@ func (_ fastpathT) DecSliceIntV(v []int, canChange bool, d *Decoder) (_ []int, c
slh.End()
return v, changed
}
- hasLen := containerLenS > 0
- var xlen int
- if hasLen && canChange {
+
+ if containerLenS > 0 {
+ x2read := containerLenS
+ var xtrunc bool
if containerLenS > cap(v) {
- xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8)
- if xlen <= cap(v) {
- v = v[:xlen]
- } else {
- v = make([]int, xlen)
- }
- changed = true
- } else if containerLenS != len(v) {
- v = v[:containerLenS]
- changed = true
- }
- }
- j := 0
- for ; (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, 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)
+ var xlen int
+ xlen, xtrunc = decInferLen(containerLenS, d.h.MaxInitLen, 8)
+ if xtrunc {
+ if xlen <= cap(v) {
+ v = v[:xlen]
+ } else {
+ v = make([]int, xlen)
+ }
+ } else {
+ v = make([]int, xlen)
+ }
changed = true
} else {
- d.arrayCannotExpand(len(v), j+1)
- decodeIntoBlank = true
+ d.arrayCannotExpand(len(v), containerLenS)
+ }
+ x2read = len(v)
+ } else if containerLenS != len(v) {
+ if canChange {
+ v = v[:containerLenS]
+ changed = true
}
}
- slh.ElemContainerState(j)
- if decodeIntoBlank {
- d.swallow()
- } else if dd.TryDecodeAsNil() {
- v[j] = 0
- } else {
- v[j] = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize))
+ j := 0
+ for ; j < x2read; j++ {
+ slh.ElemContainerState(j)
+ v[j] = int(dd.DecodeInt(intBitsize))
}
- }
- if canChange {
- if j < len(v) {
- v = v[:j]
+ if xtrunc {
+ for ; j < containerLenS; j++ {
+ v = append(v, 0)
+ slh.ElemContainerState(j)
+ v[j] = int(dd.DecodeInt(intBitsize))
+ }
+ } else if !canChange {
+ for ; j < containerLenS; j++ {
+ slh.ElemContainerState(j)
+ d.swallow()
+ }
+ }
+ } else {
+ breakFound := dd.CheckBreak()
+ if breakFound {
+ if canChange {
+ if v == nil {
+ v = []int{}
+ } else if len(v) != 0 {
+ v = v[:0]
+ }
+ changed = true
+ }
+ slh.End()
+ return v, changed
+ }
+ if cap(v) == 0 {
+ v = make([]int, 1, 4)
changed = true
- } else if j == 0 && v == nil {
- v = make([]int, 0)
+ }
+ j := 0
+ for ; !breakFound; j++ {
+ if j >= len(v) {
+ if canChange {
+ v = append(v, 0)
+ changed = true
+ } else {
+ d.arrayCannotExpand(len(v), j+1)
+ }
+ }
+ slh.ElemContainerState(j)
+ if j < len(v) {
+ v[j] = int(dd.DecodeInt(intBitsize))
+ } else {
+ d.swallow()
+ }
+ breakFound = dd.CheckBreak()
+ }
+ if canChange && j < len(v) {
+ v = v[:j]
changed = true
}
}
@@ -18777,29 +19454,36 @@ func (_ fastpathT) DecSliceIntV(v []int, canChange bool, d *Decoder) (_ []int, c
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)
+func (f *decFnInfo) fastpathDecSliceInt8R(rv reflect.Value) {
+ array := f.seq == seqTypeArray
+ if !array && rv.CanAddr() {
+ vp := rv.Addr().Interface().(*[]int8)
+ v, changed := fastpathTV.DecSliceInt8V(*vp, fastpathCheckNilFalse, !array, f.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)
- }
+ v := rv.Interface().([]int8)
+ fastpathTV.DecSliceInt8V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecSliceInt8X(vp *[]int8, d *Decoder) {
- v, changed := f.DecSliceInt8V(*vp, true, d)
+
+func (f fastpathT) DecSliceInt8X(vp *[]int8, checkNil bool, d *Decoder) {
+ v, changed := f.DecSliceInt8V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecSliceInt8V(v []int8, canChange bool, d *Decoder) (_ []int8, changed bool) {
+func (_ fastpathT) DecSliceInt8V(v []int8, checkNil bool, canChange bool, d *Decoder) (_ []int8, changed bool) {
dd := d.d
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
slh, containerLenS := d.decSliceHelperStart()
if containerLenS == 0 {
if canChange {
@@ -18813,59 +19497,89 @@ func (_ fastpathT) DecSliceInt8V(v []int8, canChange bool, d *Decoder) (_ []int8
slh.End()
return v, changed
}
- hasLen := containerLenS > 0
- var xlen int
- if hasLen && canChange {
+
+ if containerLenS > 0 {
+ x2read := containerLenS
+ var xtrunc bool
if containerLenS > cap(v) {
- xlen = decInferLen(containerLenS, d.h.MaxInitLen, 1)
- if xlen <= cap(v) {
- v = v[:xlen]
- } else {
- v = make([]int8, xlen)
- }
- changed = true
- } else if containerLenS != len(v) {
- v = v[:containerLenS]
- changed = true
- }
- }
- j := 0
- for ; (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, 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)
+ var xlen int
+ xlen, xtrunc = decInferLen(containerLenS, d.h.MaxInitLen, 1)
+ if xtrunc {
+ if xlen <= cap(v) {
+ v = v[:xlen]
+ } else {
+ v = make([]int8, xlen)
+ }
+ } else {
+ v = make([]int8, xlen)
+ }
changed = true
} else {
- d.arrayCannotExpand(len(v), j+1)
- decodeIntoBlank = true
+ d.arrayCannotExpand(len(v), containerLenS)
+ }
+ x2read = len(v)
+ } else if containerLenS != len(v) {
+ if canChange {
+ v = v[:containerLenS]
+ changed = true
}
}
- slh.ElemContainerState(j)
- if decodeIntoBlank {
- d.swallow()
- } else if dd.TryDecodeAsNil() {
- v[j] = 0
- } else {
- v[j] = int8(chkOvf.IntV(dd.DecodeInt64(), 8))
+ j := 0
+ for ; j < x2read; j++ {
+ slh.ElemContainerState(j)
+ v[j] = int8(dd.DecodeInt(8))
}
- }
- if canChange {
- if j < len(v) {
- v = v[:j]
+ if xtrunc {
+ for ; j < containerLenS; j++ {
+ v = append(v, 0)
+ slh.ElemContainerState(j)
+ v[j] = int8(dd.DecodeInt(8))
+ }
+ } else if !canChange {
+ for ; j < containerLenS; j++ {
+ slh.ElemContainerState(j)
+ d.swallow()
+ }
+ }
+ } else {
+ breakFound := dd.CheckBreak()
+ if breakFound {
+ if canChange {
+ if v == nil {
+ v = []int8{}
+ } else if len(v) != 0 {
+ v = v[:0]
+ }
+ changed = true
+ }
+ slh.End()
+ return v, changed
+ }
+ if cap(v) == 0 {
+ v = make([]int8, 1, 4)
changed = true
- } else if j == 0 && v == nil {
- v = make([]int8, 0)
+ }
+ j := 0
+ for ; !breakFound; j++ {
+ if j >= len(v) {
+ if canChange {
+ v = append(v, 0)
+ changed = true
+ } else {
+ d.arrayCannotExpand(len(v), j+1)
+ }
+ }
+ slh.ElemContainerState(j)
+ if j < len(v) {
+ v[j] = int8(dd.DecodeInt(8))
+ } else {
+ d.swallow()
+ }
+ breakFound = dd.CheckBreak()
+ }
+ if canChange && j < len(v) {
+ v = v[:j]
changed = true
}
}
@@ -18873,29 +19587,36 @@ func (_ fastpathT) DecSliceInt8V(v []int8, canChange bool, d *Decoder) (_ []int8
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)
+func (f *decFnInfo) fastpathDecSliceInt16R(rv reflect.Value) {
+ array := f.seq == seqTypeArray
+ if !array && rv.CanAddr() {
+ vp := rv.Addr().Interface().(*[]int16)
+ v, changed := fastpathTV.DecSliceInt16V(*vp, fastpathCheckNilFalse, !array, f.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)
- }
+ v := rv.Interface().([]int16)
+ fastpathTV.DecSliceInt16V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecSliceInt16X(vp *[]int16, d *Decoder) {
- v, changed := f.DecSliceInt16V(*vp, true, d)
+
+func (f fastpathT) DecSliceInt16X(vp *[]int16, checkNil bool, d *Decoder) {
+ v, changed := f.DecSliceInt16V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecSliceInt16V(v []int16, canChange bool, d *Decoder) (_ []int16, changed bool) {
+func (_ fastpathT) DecSliceInt16V(v []int16, checkNil bool, canChange bool, d *Decoder) (_ []int16, changed bool) {
dd := d.d
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
slh, containerLenS := d.decSliceHelperStart()
if containerLenS == 0 {
if canChange {
@@ -18909,59 +19630,89 @@ func (_ fastpathT) DecSliceInt16V(v []int16, canChange bool, d *Decoder) (_ []in
slh.End()
return v, changed
}
- hasLen := containerLenS > 0
- var xlen int
- if hasLen && canChange {
+
+ if containerLenS > 0 {
+ x2read := containerLenS
+ var xtrunc bool
if containerLenS > cap(v) {
- xlen = decInferLen(containerLenS, d.h.MaxInitLen, 2)
- if xlen <= cap(v) {
- v = v[:xlen]
- } else {
- v = make([]int16, xlen)
- }
- changed = true
- } else if containerLenS != len(v) {
- v = v[:containerLenS]
- changed = true
- }
- }
- j := 0
- for ; (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, 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)
+ var xlen int
+ xlen, xtrunc = decInferLen(containerLenS, d.h.MaxInitLen, 2)
+ if xtrunc {
+ if xlen <= cap(v) {
+ v = v[:xlen]
+ } else {
+ v = make([]int16, xlen)
+ }
+ } else {
+ v = make([]int16, xlen)
+ }
changed = true
} else {
- d.arrayCannotExpand(len(v), j+1)
- decodeIntoBlank = true
+ d.arrayCannotExpand(len(v), containerLenS)
+ }
+ x2read = len(v)
+ } else if containerLenS != len(v) {
+ if canChange {
+ v = v[:containerLenS]
+ changed = true
}
}
- slh.ElemContainerState(j)
- if decodeIntoBlank {
- d.swallow()
- } else if dd.TryDecodeAsNil() {
- v[j] = 0
- } else {
- v[j] = int16(chkOvf.IntV(dd.DecodeInt64(), 16))
+ j := 0
+ for ; j < x2read; j++ {
+ slh.ElemContainerState(j)
+ v[j] = int16(dd.DecodeInt(16))
}
- }
- if canChange {
- if j < len(v) {
- v = v[:j]
+ if xtrunc {
+ for ; j < containerLenS; j++ {
+ v = append(v, 0)
+ slh.ElemContainerState(j)
+ v[j] = int16(dd.DecodeInt(16))
+ }
+ } else if !canChange {
+ for ; j < containerLenS; j++ {
+ slh.ElemContainerState(j)
+ d.swallow()
+ }
+ }
+ } else {
+ breakFound := dd.CheckBreak()
+ if breakFound {
+ if canChange {
+ if v == nil {
+ v = []int16{}
+ } else if len(v) != 0 {
+ v = v[:0]
+ }
+ changed = true
+ }
+ slh.End()
+ return v, changed
+ }
+ if cap(v) == 0 {
+ v = make([]int16, 1, 4)
changed = true
- } else if j == 0 && v == nil {
- v = make([]int16, 0)
+ }
+ j := 0
+ for ; !breakFound; j++ {
+ if j >= len(v) {
+ if canChange {
+ v = append(v, 0)
+ changed = true
+ } else {
+ d.arrayCannotExpand(len(v), j+1)
+ }
+ }
+ slh.ElemContainerState(j)
+ if j < len(v) {
+ v[j] = int16(dd.DecodeInt(16))
+ } else {
+ d.swallow()
+ }
+ breakFound = dd.CheckBreak()
+ }
+ if canChange && j < len(v) {
+ v = v[:j]
changed = true
}
}
@@ -18969,29 +19720,36 @@ func (_ fastpathT) DecSliceInt16V(v []int16, canChange bool, d *Decoder) (_ []in
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)
+func (f *decFnInfo) fastpathDecSliceInt32R(rv reflect.Value) {
+ array := f.seq == seqTypeArray
+ if !array && rv.CanAddr() {
+ vp := rv.Addr().Interface().(*[]int32)
+ v, changed := fastpathTV.DecSliceInt32V(*vp, fastpathCheckNilFalse, !array, f.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)
- }
+ v := rv.Interface().([]int32)
+ fastpathTV.DecSliceInt32V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecSliceInt32X(vp *[]int32, d *Decoder) {
- v, changed := f.DecSliceInt32V(*vp, true, d)
+
+func (f fastpathT) DecSliceInt32X(vp *[]int32, checkNil bool, d *Decoder) {
+ v, changed := f.DecSliceInt32V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecSliceInt32V(v []int32, canChange bool, d *Decoder) (_ []int32, changed bool) {
+func (_ fastpathT) DecSliceInt32V(v []int32, checkNil bool, canChange bool, d *Decoder) (_ []int32, changed bool) {
dd := d.d
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
slh, containerLenS := d.decSliceHelperStart()
if containerLenS == 0 {
if canChange {
@@ -19005,59 +19763,89 @@ func (_ fastpathT) DecSliceInt32V(v []int32, canChange bool, d *Decoder) (_ []in
slh.End()
return v, changed
}
- hasLen := containerLenS > 0
- var xlen int
- if hasLen && canChange {
+
+ if containerLenS > 0 {
+ x2read := containerLenS
+ var xtrunc bool
if containerLenS > cap(v) {
- xlen = decInferLen(containerLenS, d.h.MaxInitLen, 4)
- if xlen <= cap(v) {
- v = v[:xlen]
- } else {
- v = make([]int32, xlen)
- }
- changed = true
- } else if containerLenS != len(v) {
- v = v[:containerLenS]
- changed = true
- }
- }
- j := 0
- for ; (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, 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)
+ var xlen int
+ xlen, xtrunc = decInferLen(containerLenS, d.h.MaxInitLen, 4)
+ if xtrunc {
+ if xlen <= cap(v) {
+ v = v[:xlen]
+ } else {
+ v = make([]int32, xlen)
+ }
+ } else {
+ v = make([]int32, xlen)
+ }
changed = true
} else {
- d.arrayCannotExpand(len(v), j+1)
- decodeIntoBlank = true
+ d.arrayCannotExpand(len(v), containerLenS)
+ }
+ x2read = len(v)
+ } else if containerLenS != len(v) {
+ if canChange {
+ v = v[:containerLenS]
+ changed = true
}
}
- slh.ElemContainerState(j)
- if decodeIntoBlank {
- d.swallow()
- } else if dd.TryDecodeAsNil() {
- v[j] = 0
- } else {
- v[j] = int32(chkOvf.IntV(dd.DecodeInt64(), 32))
+ j := 0
+ for ; j < x2read; j++ {
+ slh.ElemContainerState(j)
+ v[j] = int32(dd.DecodeInt(32))
}
- }
- if canChange {
- if j < len(v) {
- v = v[:j]
+ if xtrunc {
+ for ; j < containerLenS; j++ {
+ v = append(v, 0)
+ slh.ElemContainerState(j)
+ v[j] = int32(dd.DecodeInt(32))
+ }
+ } else if !canChange {
+ for ; j < containerLenS; j++ {
+ slh.ElemContainerState(j)
+ d.swallow()
+ }
+ }
+ } else {
+ breakFound := dd.CheckBreak()
+ if breakFound {
+ if canChange {
+ if v == nil {
+ v = []int32{}
+ } else if len(v) != 0 {
+ v = v[:0]
+ }
+ changed = true
+ }
+ slh.End()
+ return v, changed
+ }
+ if cap(v) == 0 {
+ v = make([]int32, 1, 4)
changed = true
- } else if j == 0 && v == nil {
- v = make([]int32, 0)
+ }
+ j := 0
+ for ; !breakFound; j++ {
+ if j >= len(v) {
+ if canChange {
+ v = append(v, 0)
+ changed = true
+ } else {
+ d.arrayCannotExpand(len(v), j+1)
+ }
+ }
+ slh.ElemContainerState(j)
+ if j < len(v) {
+ v[j] = int32(dd.DecodeInt(32))
+ } else {
+ d.swallow()
+ }
+ breakFound = dd.CheckBreak()
+ }
+ if canChange && j < len(v) {
+ v = v[:j]
changed = true
}
}
@@ -19065,29 +19853,36 @@ func (_ fastpathT) DecSliceInt32V(v []int32, canChange bool, d *Decoder) (_ []in
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)
+func (f *decFnInfo) fastpathDecSliceInt64R(rv reflect.Value) {
+ array := f.seq == seqTypeArray
+ if !array && rv.CanAddr() {
+ vp := rv.Addr().Interface().(*[]int64)
+ v, changed := fastpathTV.DecSliceInt64V(*vp, fastpathCheckNilFalse, !array, f.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)
- }
+ v := rv.Interface().([]int64)
+ fastpathTV.DecSliceInt64V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecSliceInt64X(vp *[]int64, d *Decoder) {
- v, changed := f.DecSliceInt64V(*vp, true, d)
+
+func (f fastpathT) DecSliceInt64X(vp *[]int64, checkNil bool, d *Decoder) {
+ v, changed := f.DecSliceInt64V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecSliceInt64V(v []int64, canChange bool, d *Decoder) (_ []int64, changed bool) {
+func (_ fastpathT) DecSliceInt64V(v []int64, checkNil bool, canChange bool, d *Decoder) (_ []int64, changed bool) {
dd := d.d
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
slh, containerLenS := d.decSliceHelperStart()
if containerLenS == 0 {
if canChange {
@@ -19101,59 +19896,89 @@ func (_ fastpathT) DecSliceInt64V(v []int64, canChange bool, d *Decoder) (_ []in
slh.End()
return v, changed
}
- hasLen := containerLenS > 0
- var xlen int
- if hasLen && canChange {
+
+ if containerLenS > 0 {
+ x2read := containerLenS
+ var xtrunc bool
if containerLenS > cap(v) {
- xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8)
- if xlen <= cap(v) {
- v = v[:xlen]
- } else {
- v = make([]int64, xlen)
- }
- changed = true
- } else if containerLenS != len(v) {
- v = v[:containerLenS]
- changed = true
- }
- }
- j := 0
- for ; (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, 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)
+ var xlen int
+ xlen, xtrunc = decInferLen(containerLenS, d.h.MaxInitLen, 8)
+ if xtrunc {
+ if xlen <= cap(v) {
+ v = v[:xlen]
+ } else {
+ v = make([]int64, xlen)
+ }
+ } else {
+ v = make([]int64, xlen)
+ }
changed = true
} else {
- d.arrayCannotExpand(len(v), j+1)
- decodeIntoBlank = true
+ d.arrayCannotExpand(len(v), containerLenS)
+ }
+ x2read = len(v)
+ } else if containerLenS != len(v) {
+ if canChange {
+ v = v[:containerLenS]
+ changed = true
}
}
- slh.ElemContainerState(j)
- if decodeIntoBlank {
- d.swallow()
- } else if dd.TryDecodeAsNil() {
- v[j] = 0
- } else {
- v[j] = dd.DecodeInt64()
+ j := 0
+ for ; j < x2read; j++ {
+ slh.ElemContainerState(j)
+ v[j] = dd.DecodeInt(64)
}
- }
- if canChange {
- if j < len(v) {
- v = v[:j]
+ if xtrunc {
+ for ; j < containerLenS; j++ {
+ v = append(v, 0)
+ slh.ElemContainerState(j)
+ v[j] = dd.DecodeInt(64)
+ }
+ } else if !canChange {
+ for ; j < containerLenS; j++ {
+ slh.ElemContainerState(j)
+ d.swallow()
+ }
+ }
+ } else {
+ breakFound := dd.CheckBreak()
+ if breakFound {
+ if canChange {
+ if v == nil {
+ v = []int64{}
+ } else if len(v) != 0 {
+ v = v[:0]
+ }
+ changed = true
+ }
+ slh.End()
+ return v, changed
+ }
+ if cap(v) == 0 {
+ v = make([]int64, 1, 4)
changed = true
- } else if j == 0 && v == nil {
- v = make([]int64, 0)
+ }
+ j := 0
+ for ; !breakFound; j++ {
+ if j >= len(v) {
+ if canChange {
+ v = append(v, 0)
+ changed = true
+ } else {
+ d.arrayCannotExpand(len(v), j+1)
+ }
+ }
+ slh.ElemContainerState(j)
+ if j < len(v) {
+ v[j] = dd.DecodeInt(64)
+ } else {
+ d.swallow()
+ }
+ breakFound = dd.CheckBreak()
+ }
+ if canChange && j < len(v) {
+ v = v[:j]
changed = true
}
}
@@ -19161,29 +19986,36 @@ func (_ fastpathT) DecSliceInt64V(v []int64, canChange bool, d *Decoder) (_ []in
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)
+func (f *decFnInfo) fastpathDecSliceBoolR(rv reflect.Value) {
+ array := f.seq == seqTypeArray
+ if !array && rv.CanAddr() {
+ vp := rv.Addr().Interface().(*[]bool)
+ v, changed := fastpathTV.DecSliceBoolV(*vp, fastpathCheckNilFalse, !array, f.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)
- }
+ v := rv.Interface().([]bool)
+ fastpathTV.DecSliceBoolV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecSliceBoolX(vp *[]bool, d *Decoder) {
- v, changed := f.DecSliceBoolV(*vp, true, d)
+
+func (f fastpathT) DecSliceBoolX(vp *[]bool, checkNil bool, d *Decoder) {
+ v, changed := f.DecSliceBoolV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecSliceBoolV(v []bool, canChange bool, d *Decoder) (_ []bool, changed bool) {
+func (_ fastpathT) DecSliceBoolV(v []bool, checkNil bool, canChange bool, d *Decoder) (_ []bool, changed bool) {
dd := d.d
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
slh, containerLenS := d.decSliceHelperStart()
if containerLenS == 0 {
if canChange {
@@ -19197,59 +20029,89 @@ func (_ fastpathT) DecSliceBoolV(v []bool, canChange bool, d *Decoder) (_ []bool
slh.End()
return v, changed
}
- hasLen := containerLenS > 0
- var xlen int
- if hasLen && canChange {
+
+ if containerLenS > 0 {
+ x2read := containerLenS
+ var xtrunc bool
if containerLenS > cap(v) {
- xlen = decInferLen(containerLenS, d.h.MaxInitLen, 1)
- if xlen <= cap(v) {
- v = v[:xlen]
- } else {
- v = make([]bool, xlen)
- }
- changed = true
- } else if containerLenS != len(v) {
- v = v[:containerLenS]
- changed = true
- }
- }
- j := 0
- for ; (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, 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)
+ var xlen int
+ xlen, xtrunc = decInferLen(containerLenS, d.h.MaxInitLen, 1)
+ if xtrunc {
+ if xlen <= cap(v) {
+ v = v[:xlen]
+ } else {
+ v = make([]bool, xlen)
+ }
+ } else {
+ v = make([]bool, xlen)
+ }
changed = true
} else {
- d.arrayCannotExpand(len(v), j+1)
- decodeIntoBlank = true
+ d.arrayCannotExpand(len(v), containerLenS)
+ }
+ x2read = len(v)
+ } else if containerLenS != len(v) {
+ if canChange {
+ v = v[:containerLenS]
+ changed = true
}
}
- slh.ElemContainerState(j)
- if decodeIntoBlank {
- d.swallow()
- } else if dd.TryDecodeAsNil() {
- v[j] = false
- } else {
+ j := 0
+ for ; j < x2read; j++ {
+ slh.ElemContainerState(j)
v[j] = dd.DecodeBool()
}
- }
- if canChange {
- if j < len(v) {
- v = v[:j]
+ if xtrunc {
+ for ; j < containerLenS; j++ {
+ v = append(v, false)
+ slh.ElemContainerState(j)
+ v[j] = dd.DecodeBool()
+ }
+ } else if !canChange {
+ for ; j < containerLenS; j++ {
+ slh.ElemContainerState(j)
+ d.swallow()
+ }
+ }
+ } else {
+ breakFound := dd.CheckBreak()
+ if breakFound {
+ if canChange {
+ if v == nil {
+ v = []bool{}
+ } else if len(v) != 0 {
+ v = v[:0]
+ }
+ changed = true
+ }
+ slh.End()
+ return v, changed
+ }
+ if cap(v) == 0 {
+ v = make([]bool, 1, 4)
changed = true
- } else if j == 0 && v == nil {
- v = make([]bool, 0)
+ }
+ j := 0
+ for ; !breakFound; j++ {
+ if j >= len(v) {
+ if canChange {
+ v = append(v, false)
+ changed = true
+ } else {
+ d.arrayCannotExpand(len(v), j+1)
+ }
+ }
+ slh.ElemContainerState(j)
+ if j < len(v) {
+ v[j] = dd.DecodeBool()
+ } else {
+ d.swallow()
+ }
+ breakFound = dd.CheckBreak()
+ }
+ if canChange && j < len(v) {
+ v = v[:j]
changed = true
}
}
@@ -19257,15266 +20119,19234 @@ func (_ fastpathT) DecSliceBoolV(v []bool, canChange bool, d *Decoder) (_ []bool
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)
+func (f *decFnInfo) fastpathDecMapIntfIntfR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[interface{}]interface{})
+ v, changed := fastpathTV.DecMapIntfIntfV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapIntfIntfV(rv2i(rv).(map[interface{}]interface{}), false, d)
+ v := rv.Interface().(map[interface{}]interface{})
+ fastpathTV.DecMapIntfIntfV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapIntfIntfX(vp *map[interface{}]interface{}, d *Decoder) {
- v, changed := f.DecMapIntfIntfV(*vp, true, d)
+func (f fastpathT) DecMapIntfIntfX(vp *map[interface{}]interface{}, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapIntfIntfV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapIntfIntfV(v map[interface{}]interface{}, canChange bool,
+func (_ fastpathT) DecMapIntfIntfV(v map[interface{}]interface{}, checkNil bool, canChange bool,
d *Decoder) (_ map[interface{}]interface{}, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 32)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 32)
v = make(map[interface{}]interface{}, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset
+ mapGet := !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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = nil
+ d.decode(&mk)
+ if bv, bok := mk.([]byte); bok {
+ mk = d.string(bv)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ if mapGet {
+ mv = v[mk]
+ } else {
+ mv = nil
+ }
+ d.decode(&mv)
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- if mapGet {
- mv = v[mk]
- } else {
- mv = nil
- }
- d.decode(&mv)
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = nil
+ d.decode(&mk)
+ if bv, bok := mk.([]byte); bok {
+ mk = d.string(bv)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ if mapGet {
+ mv = v[mk]
+ } else {
+ mv = nil
+ }
+ d.decode(&mv)
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapIntfStringR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[interface{}]string)
+ v, changed := fastpathTV.DecMapIntfStringV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapIntfStringV(rv2i(rv).(map[interface{}]string), false, d)
+ v := rv.Interface().(map[interface{}]string)
+ fastpathTV.DecMapIntfStringV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapIntfStringX(vp *map[interface{}]string, d *Decoder) {
- v, changed := f.DecMapIntfStringV(*vp, true, d)
+func (f fastpathT) DecMapIntfStringX(vp *map[interface{}]string, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapIntfStringV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapIntfStringV(v map[interface{}]string, canChange bool,
+func (_ fastpathT) DecMapIntfStringV(v map[interface{}]string, checkNil bool, canChange bool,
d *Decoder) (_ map[interface{}]string, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 32)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 32)
v = make(map[interface{}]string, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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] = ""
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = nil
+ d.decode(&mk)
+ if bv, bok := mk.([]byte); bok {
+ mk = d.string(bv)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeString()
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeString()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = nil
+ d.decode(&mk)
+ if bv, bok := mk.([]byte); bok {
+ mk = d.string(bv)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeString()
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapIntfUintR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[interface{}]uint)
+ v, changed := fastpathTV.DecMapIntfUintV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapIntfUintV(rv2i(rv).(map[interface{}]uint), false, d)
+ v := rv.Interface().(map[interface{}]uint)
+ fastpathTV.DecMapIntfUintV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapIntfUintX(vp *map[interface{}]uint, d *Decoder) {
- v, changed := f.DecMapIntfUintV(*vp, true, d)
+func (f fastpathT) DecMapIntfUintX(vp *map[interface{}]uint, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapIntfUintV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapIntfUintV(v map[interface{}]uint, canChange bool,
+func (_ fastpathT) DecMapIntfUintV(v map[interface{}]uint, checkNil bool, canChange bool,
d *Decoder) (_ map[interface{}]uint, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 24)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 24)
v = make(map[interface{}]uint, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = nil
+ d.decode(&mk)
+ if bv, bok := mk.([]byte); bok {
+ mk = d.string(bv)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint(dd.DecodeUint(uintBitsize))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = nil
+ d.decode(&mk)
+ if bv, bok := mk.([]byte); bok {
+ mk = d.string(bv)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint(dd.DecodeUint(uintBitsize))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapIntfUint8R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[interface{}]uint8)
+ v, changed := fastpathTV.DecMapIntfUint8V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapIntfUint8V(rv2i(rv).(map[interface{}]uint8), false, d)
+ v := rv.Interface().(map[interface{}]uint8)
+ fastpathTV.DecMapIntfUint8V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapIntfUint8X(vp *map[interface{}]uint8, d *Decoder) {
- v, changed := f.DecMapIntfUint8V(*vp, true, d)
+func (f fastpathT) DecMapIntfUint8X(vp *map[interface{}]uint8, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapIntfUint8V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapIntfUint8V(v map[interface{}]uint8, canChange bool,
+func (_ fastpathT) DecMapIntfUint8V(v map[interface{}]uint8, checkNil bool, canChange bool,
d *Decoder) (_ map[interface{}]uint8, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 17)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 17)
v = make(map[interface{}]uint8, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = nil
+ d.decode(&mk)
+ if bv, bok := mk.([]byte); bok {
+ mk = d.string(bv)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint8(dd.DecodeUint(8))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uint8(chkOvf.UintV(dd.DecodeUint64(), 8))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = nil
+ d.decode(&mk)
+ if bv, bok := mk.([]byte); bok {
+ mk = d.string(bv)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint8(dd.DecodeUint(8))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapIntfUint16R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[interface{}]uint16)
+ v, changed := fastpathTV.DecMapIntfUint16V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapIntfUint16V(rv2i(rv).(map[interface{}]uint16), false, d)
+ v := rv.Interface().(map[interface{}]uint16)
+ fastpathTV.DecMapIntfUint16V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapIntfUint16X(vp *map[interface{}]uint16, d *Decoder) {
- v, changed := f.DecMapIntfUint16V(*vp, true, d)
+func (f fastpathT) DecMapIntfUint16X(vp *map[interface{}]uint16, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapIntfUint16V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapIntfUint16V(v map[interface{}]uint16, canChange bool,
+func (_ fastpathT) DecMapIntfUint16V(v map[interface{}]uint16, checkNil bool, canChange bool,
d *Decoder) (_ map[interface{}]uint16, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 18)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 18)
v = make(map[interface{}]uint16, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = nil
+ d.decode(&mk)
+ if bv, bok := mk.([]byte); bok {
+ mk = d.string(bv)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint16(dd.DecodeUint(16))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uint16(chkOvf.UintV(dd.DecodeUint64(), 16))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = nil
+ d.decode(&mk)
+ if bv, bok := mk.([]byte); bok {
+ mk = d.string(bv)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint16(dd.DecodeUint(16))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapIntfUint32R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[interface{}]uint32)
+ v, changed := fastpathTV.DecMapIntfUint32V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapIntfUint32V(rv2i(rv).(map[interface{}]uint32), false, d)
+ v := rv.Interface().(map[interface{}]uint32)
+ fastpathTV.DecMapIntfUint32V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapIntfUint32X(vp *map[interface{}]uint32, d *Decoder) {
- v, changed := f.DecMapIntfUint32V(*vp, true, d)
+func (f fastpathT) DecMapIntfUint32X(vp *map[interface{}]uint32, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapIntfUint32V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapIntfUint32V(v map[interface{}]uint32, canChange bool,
+func (_ fastpathT) DecMapIntfUint32V(v map[interface{}]uint32, checkNil bool, canChange bool,
d *Decoder) (_ map[interface{}]uint32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 20)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 20)
v = make(map[interface{}]uint32, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = nil
+ d.decode(&mk)
+ if bv, bok := mk.([]byte); bok {
+ mk = d.string(bv)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint32(dd.DecodeUint(32))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uint32(chkOvf.UintV(dd.DecodeUint64(), 32))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = nil
+ d.decode(&mk)
+ if bv, bok := mk.([]byte); bok {
+ mk = d.string(bv)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint32(dd.DecodeUint(32))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapIntfUint64R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[interface{}]uint64)
+ v, changed := fastpathTV.DecMapIntfUint64V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapIntfUint64V(rv2i(rv).(map[interface{}]uint64), false, d)
+ v := rv.Interface().(map[interface{}]uint64)
+ fastpathTV.DecMapIntfUint64V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapIntfUint64X(vp *map[interface{}]uint64, d *Decoder) {
- v, changed := f.DecMapIntfUint64V(*vp, true, d)
+func (f fastpathT) DecMapIntfUint64X(vp *map[interface{}]uint64, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapIntfUint64V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapIntfUint64V(v map[interface{}]uint64, canChange bool,
+func (_ fastpathT) DecMapIntfUint64V(v map[interface{}]uint64, checkNil bool, canChange bool,
d *Decoder) (_ map[interface{}]uint64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 24)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 24)
v = make(map[interface{}]uint64, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = nil
+ d.decode(&mk)
+ if bv, bok := mk.([]byte); bok {
+ mk = d.string(bv)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeUint(64)
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeUint64()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = nil
+ d.decode(&mk)
+ if bv, bok := mk.([]byte); bok {
+ mk = d.string(bv)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeUint(64)
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapIntfUintptrR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[interface{}]uintptr)
+ v, changed := fastpathTV.DecMapIntfUintptrV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapIntfUintptrV(rv2i(rv).(map[interface{}]uintptr), false, d)
+ v := rv.Interface().(map[interface{}]uintptr)
+ fastpathTV.DecMapIntfUintptrV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapIntfUintptrX(vp *map[interface{}]uintptr, d *Decoder) {
- v, changed := f.DecMapIntfUintptrV(*vp, true, d)
+func (f fastpathT) DecMapIntfUintptrX(vp *map[interface{}]uintptr, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapIntfUintptrV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapIntfUintptrV(v map[interface{}]uintptr, canChange bool,
+func (_ fastpathT) DecMapIntfUintptrV(v map[interface{}]uintptr, checkNil bool, canChange bool,
d *Decoder) (_ map[interface{}]uintptr, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 24)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 24)
v = make(map[interface{}]uintptr, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = nil
+ d.decode(&mk)
+ if bv, bok := mk.([]byte); bok {
+ mk = d.string(bv)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uintptr(dd.DecodeUint(uintBitsize))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = nil
+ d.decode(&mk)
+ if bv, bok := mk.([]byte); bok {
+ mk = d.string(bv)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uintptr(dd.DecodeUint(uintBitsize))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapIntfIntR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[interface{}]int)
+ v, changed := fastpathTV.DecMapIntfIntV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapIntfIntV(rv2i(rv).(map[interface{}]int), false, d)
+ v := rv.Interface().(map[interface{}]int)
+ fastpathTV.DecMapIntfIntV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapIntfIntX(vp *map[interface{}]int, d *Decoder) {
- v, changed := f.DecMapIntfIntV(*vp, true, d)
+func (f fastpathT) DecMapIntfIntX(vp *map[interface{}]int, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapIntfIntV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapIntfIntV(v map[interface{}]int, canChange bool,
+func (_ fastpathT) DecMapIntfIntV(v map[interface{}]int, checkNil bool, canChange bool,
d *Decoder) (_ map[interface{}]int, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 24)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 24)
v = make(map[interface{}]int, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = nil
+ d.decode(&mk)
+ if bv, bok := mk.([]byte); bok {
+ mk = d.string(bv)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int(dd.DecodeInt(intBitsize))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = nil
+ d.decode(&mk)
+ if bv, bok := mk.([]byte); bok {
+ mk = d.string(bv)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int(dd.DecodeInt(intBitsize))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapIntfInt8R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[interface{}]int8)
+ v, changed := fastpathTV.DecMapIntfInt8V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapIntfInt8V(rv2i(rv).(map[interface{}]int8), false, d)
+ v := rv.Interface().(map[interface{}]int8)
+ fastpathTV.DecMapIntfInt8V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapIntfInt8X(vp *map[interface{}]int8, d *Decoder) {
- v, changed := f.DecMapIntfInt8V(*vp, true, d)
+func (f fastpathT) DecMapIntfInt8X(vp *map[interface{}]int8, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapIntfInt8V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapIntfInt8V(v map[interface{}]int8, canChange bool,
+func (_ fastpathT) DecMapIntfInt8V(v map[interface{}]int8, checkNil bool, canChange bool,
d *Decoder) (_ map[interface{}]int8, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 17)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 17)
v = make(map[interface{}]int8, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = nil
+ d.decode(&mk)
+ if bv, bok := mk.([]byte); bok {
+ mk = d.string(bv)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int8(dd.DecodeInt(8))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = int8(chkOvf.IntV(dd.DecodeInt64(), 8))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = nil
+ d.decode(&mk)
+ if bv, bok := mk.([]byte); bok {
+ mk = d.string(bv)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int8(dd.DecodeInt(8))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapIntfInt16R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[interface{}]int16)
+ v, changed := fastpathTV.DecMapIntfInt16V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapIntfInt16V(rv2i(rv).(map[interface{}]int16), false, d)
+ v := rv.Interface().(map[interface{}]int16)
+ fastpathTV.DecMapIntfInt16V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapIntfInt16X(vp *map[interface{}]int16, d *Decoder) {
- v, changed := f.DecMapIntfInt16V(*vp, true, d)
+func (f fastpathT) DecMapIntfInt16X(vp *map[interface{}]int16, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapIntfInt16V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapIntfInt16V(v map[interface{}]int16, canChange bool,
+func (_ fastpathT) DecMapIntfInt16V(v map[interface{}]int16, checkNil bool, canChange bool,
d *Decoder) (_ map[interface{}]int16, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 18)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 18)
v = make(map[interface{}]int16, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = nil
+ d.decode(&mk)
+ if bv, bok := mk.([]byte); bok {
+ mk = d.string(bv)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int16(dd.DecodeInt(16))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = int16(chkOvf.IntV(dd.DecodeInt64(), 16))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = nil
+ d.decode(&mk)
+ if bv, bok := mk.([]byte); bok {
+ mk = d.string(bv)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int16(dd.DecodeInt(16))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapIntfInt32R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[interface{}]int32)
+ v, changed := fastpathTV.DecMapIntfInt32V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapIntfInt32V(rv2i(rv).(map[interface{}]int32), false, d)
+ v := rv.Interface().(map[interface{}]int32)
+ fastpathTV.DecMapIntfInt32V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapIntfInt32X(vp *map[interface{}]int32, d *Decoder) {
- v, changed := f.DecMapIntfInt32V(*vp, true, d)
+func (f fastpathT) DecMapIntfInt32X(vp *map[interface{}]int32, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapIntfInt32V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapIntfInt32V(v map[interface{}]int32, canChange bool,
+func (_ fastpathT) DecMapIntfInt32V(v map[interface{}]int32, checkNil bool, canChange bool,
d *Decoder) (_ map[interface{}]int32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 20)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 20)
v = make(map[interface{}]int32, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = nil
+ d.decode(&mk)
+ if bv, bok := mk.([]byte); bok {
+ mk = d.string(bv)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int32(dd.DecodeInt(32))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = int32(chkOvf.IntV(dd.DecodeInt64(), 32))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = nil
+ d.decode(&mk)
+ if bv, bok := mk.([]byte); bok {
+ mk = d.string(bv)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int32(dd.DecodeInt(32))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapIntfInt64R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[interface{}]int64)
+ v, changed := fastpathTV.DecMapIntfInt64V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapIntfInt64V(rv2i(rv).(map[interface{}]int64), false, d)
+ v := rv.Interface().(map[interface{}]int64)
+ fastpathTV.DecMapIntfInt64V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapIntfInt64X(vp *map[interface{}]int64, d *Decoder) {
- v, changed := f.DecMapIntfInt64V(*vp, true, d)
+func (f fastpathT) DecMapIntfInt64X(vp *map[interface{}]int64, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapIntfInt64V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapIntfInt64V(v map[interface{}]int64, canChange bool,
+func (_ fastpathT) DecMapIntfInt64V(v map[interface{}]int64, checkNil bool, canChange bool,
d *Decoder) (_ map[interface{}]int64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 24)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 24)
v = make(map[interface{}]int64, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = nil
+ d.decode(&mk)
+ if bv, bok := mk.([]byte); bok {
+ mk = d.string(bv)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeInt(64)
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeInt64()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = nil
+ d.decode(&mk)
+ if bv, bok := mk.([]byte); bok {
+ mk = d.string(bv)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeInt(64)
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapIntfFloat32R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[interface{}]float32)
+ v, changed := fastpathTV.DecMapIntfFloat32V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapIntfFloat32V(rv2i(rv).(map[interface{}]float32), false, d)
+ v := rv.Interface().(map[interface{}]float32)
+ fastpathTV.DecMapIntfFloat32V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapIntfFloat32X(vp *map[interface{}]float32, d *Decoder) {
- v, changed := f.DecMapIntfFloat32V(*vp, true, d)
+func (f fastpathT) DecMapIntfFloat32X(vp *map[interface{}]float32, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapIntfFloat32V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapIntfFloat32V(v map[interface{}]float32, canChange bool,
+func (_ fastpathT) DecMapIntfFloat32V(v map[interface{}]float32, checkNil bool, canChange bool,
d *Decoder) (_ map[interface{}]float32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 20)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 20)
v = make(map[interface{}]float32, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = nil
+ d.decode(&mk)
+ if bv, bok := mk.([]byte); bok {
+ mk = d.string(bv)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = float32(dd.DecodeFloat(true))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = float32(chkOvf.Float32V(dd.DecodeFloat64()))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = nil
+ d.decode(&mk)
+ if bv, bok := mk.([]byte); bok {
+ mk = d.string(bv)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = float32(dd.DecodeFloat(true))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapIntfFloat64R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[interface{}]float64)
+ v, changed := fastpathTV.DecMapIntfFloat64V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapIntfFloat64V(rv2i(rv).(map[interface{}]float64), false, d)
+ v := rv.Interface().(map[interface{}]float64)
+ fastpathTV.DecMapIntfFloat64V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapIntfFloat64X(vp *map[interface{}]float64, d *Decoder) {
- v, changed := f.DecMapIntfFloat64V(*vp, true, d)
+func (f fastpathT) DecMapIntfFloat64X(vp *map[interface{}]float64, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapIntfFloat64V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapIntfFloat64V(v map[interface{}]float64, canChange bool,
+func (_ fastpathT) DecMapIntfFloat64V(v map[interface{}]float64, checkNil bool, canChange bool,
d *Decoder) (_ map[interface{}]float64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 24)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 24)
v = make(map[interface{}]float64, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = nil
+ d.decode(&mk)
+ if bv, bok := mk.([]byte); bok {
+ mk = d.string(bv)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeFloat(false)
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeFloat64()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = nil
+ d.decode(&mk)
+ if bv, bok := mk.([]byte); bok {
+ mk = d.string(bv)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeFloat(false)
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapIntfBoolR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[interface{}]bool)
+ v, changed := fastpathTV.DecMapIntfBoolV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapIntfBoolV(rv2i(rv).(map[interface{}]bool), false, d)
+ v := rv.Interface().(map[interface{}]bool)
+ fastpathTV.DecMapIntfBoolV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapIntfBoolX(vp *map[interface{}]bool, d *Decoder) {
- v, changed := f.DecMapIntfBoolV(*vp, true, d)
+func (f fastpathT) DecMapIntfBoolX(vp *map[interface{}]bool, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapIntfBoolV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapIntfBoolV(v map[interface{}]bool, canChange bool,
+func (_ fastpathT) DecMapIntfBoolV(v map[interface{}]bool, checkNil bool, canChange bool,
d *Decoder) (_ map[interface{}]bool, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 17)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 17)
v = make(map[interface{}]bool, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = nil
+ d.decode(&mk)
+ if bv, bok := mk.([]byte); bok {
+ mk = d.string(bv)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeBool()
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeBool()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = nil
+ d.decode(&mk)
+ if bv, bok := mk.([]byte); bok {
+ mk = d.string(bv)
+ }
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeBool()
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapStringIntfR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[string]interface{})
+ v, changed := fastpathTV.DecMapStringIntfV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapStringIntfV(rv2i(rv).(map[string]interface{}), false, d)
+ v := rv.Interface().(map[string]interface{})
+ fastpathTV.DecMapStringIntfV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapStringIntfX(vp *map[string]interface{}, d *Decoder) {
- v, changed := f.DecMapStringIntfV(*vp, true, d)
+func (f fastpathT) DecMapStringIntfX(vp *map[string]interface{}, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapStringIntfV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapStringIntfV(v map[string]interface{}, canChange bool,
+func (_ fastpathT) DecMapStringIntfV(v map[string]interface{}, checkNil bool, canChange bool,
d *Decoder) (_ map[string]interface{}, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 32)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 32)
v = make(map[string]interface{}, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset
+ mapGet := !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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeString()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ if mapGet {
+ mv = v[mk]
+ } else {
+ mv = nil
+ }
+ d.decode(&mv)
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- if mapGet {
- mv = v[mk]
- } else {
- mv = nil
- }
- d.decode(&mv)
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeString()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ if mapGet {
+ mv = v[mk]
+ } else {
+ mv = nil
+ }
+ d.decode(&mv)
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapStringStringR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[string]string)
+ v, changed := fastpathTV.DecMapStringStringV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapStringStringV(rv2i(rv).(map[string]string), false, d)
+ v := rv.Interface().(map[string]string)
+ fastpathTV.DecMapStringStringV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapStringStringX(vp *map[string]string, d *Decoder) {
- v, changed := f.DecMapStringStringV(*vp, true, d)
+func (f fastpathT) DecMapStringStringX(vp *map[string]string, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapStringStringV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapStringStringV(v map[string]string, canChange bool,
+func (_ fastpathT) DecMapStringStringV(v map[string]string, checkNil bool, canChange bool,
d *Decoder) (_ map[string]string, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 32)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 32)
v = make(map[string]string, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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] = ""
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeString()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeString()
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeString()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeString()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeString()
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapStringUintR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[string]uint)
+ v, changed := fastpathTV.DecMapStringUintV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapStringUintV(rv2i(rv).(map[string]uint), false, d)
+ v := rv.Interface().(map[string]uint)
+ fastpathTV.DecMapStringUintV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapStringUintX(vp *map[string]uint, d *Decoder) {
- v, changed := f.DecMapStringUintV(*vp, true, d)
+func (f fastpathT) DecMapStringUintX(vp *map[string]uint, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapStringUintV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapStringUintV(v map[string]uint, canChange bool,
+func (_ fastpathT) DecMapStringUintV(v map[string]uint, checkNil bool, canChange bool,
d *Decoder) (_ map[string]uint, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 24)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 24)
v = make(map[string]uint, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeString()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint(dd.DecodeUint(uintBitsize))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeString()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint(dd.DecodeUint(uintBitsize))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapStringUint8R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[string]uint8)
+ v, changed := fastpathTV.DecMapStringUint8V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapStringUint8V(rv2i(rv).(map[string]uint8), false, d)
+ v := rv.Interface().(map[string]uint8)
+ fastpathTV.DecMapStringUint8V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapStringUint8X(vp *map[string]uint8, d *Decoder) {
- v, changed := f.DecMapStringUint8V(*vp, true, d)
+func (f fastpathT) DecMapStringUint8X(vp *map[string]uint8, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapStringUint8V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapStringUint8V(v map[string]uint8, canChange bool,
+func (_ fastpathT) DecMapStringUint8V(v map[string]uint8, checkNil bool, canChange bool,
d *Decoder) (_ map[string]uint8, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 17)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 17)
v = make(map[string]uint8, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeString()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint8(dd.DecodeUint(8))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uint8(chkOvf.UintV(dd.DecodeUint64(), 8))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeString()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint8(dd.DecodeUint(8))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapStringUint16R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[string]uint16)
+ v, changed := fastpathTV.DecMapStringUint16V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapStringUint16V(rv2i(rv).(map[string]uint16), false, d)
+ v := rv.Interface().(map[string]uint16)
+ fastpathTV.DecMapStringUint16V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapStringUint16X(vp *map[string]uint16, d *Decoder) {
- v, changed := f.DecMapStringUint16V(*vp, true, d)
+func (f fastpathT) DecMapStringUint16X(vp *map[string]uint16, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapStringUint16V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapStringUint16V(v map[string]uint16, canChange bool,
+func (_ fastpathT) DecMapStringUint16V(v map[string]uint16, checkNil bool, canChange bool,
d *Decoder) (_ map[string]uint16, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 18)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 18)
v = make(map[string]uint16, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeString()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint16(dd.DecodeUint(16))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uint16(chkOvf.UintV(dd.DecodeUint64(), 16))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeString()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint16(dd.DecodeUint(16))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapStringUint32R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[string]uint32)
+ v, changed := fastpathTV.DecMapStringUint32V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapStringUint32V(rv2i(rv).(map[string]uint32), false, d)
+ v := rv.Interface().(map[string]uint32)
+ fastpathTV.DecMapStringUint32V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapStringUint32X(vp *map[string]uint32, d *Decoder) {
- v, changed := f.DecMapStringUint32V(*vp, true, d)
+func (f fastpathT) DecMapStringUint32X(vp *map[string]uint32, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapStringUint32V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapStringUint32V(v map[string]uint32, canChange bool,
+func (_ fastpathT) DecMapStringUint32V(v map[string]uint32, checkNil bool, canChange bool,
d *Decoder) (_ map[string]uint32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 20)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 20)
v = make(map[string]uint32, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeString()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint32(dd.DecodeUint(32))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uint32(chkOvf.UintV(dd.DecodeUint64(), 32))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeString()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint32(dd.DecodeUint(32))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapStringUint64R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[string]uint64)
+ v, changed := fastpathTV.DecMapStringUint64V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapStringUint64V(rv2i(rv).(map[string]uint64), false, d)
+ v := rv.Interface().(map[string]uint64)
+ fastpathTV.DecMapStringUint64V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapStringUint64X(vp *map[string]uint64, d *Decoder) {
- v, changed := f.DecMapStringUint64V(*vp, true, d)
+func (f fastpathT) DecMapStringUint64X(vp *map[string]uint64, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapStringUint64V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapStringUint64V(v map[string]uint64, canChange bool,
+func (_ fastpathT) DecMapStringUint64V(v map[string]uint64, checkNil bool, canChange bool,
d *Decoder) (_ map[string]uint64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 24)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 24)
v = make(map[string]uint64, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeString()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeUint(64)
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeUint64()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeString()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeUint(64)
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapStringUintptrR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[string]uintptr)
+ v, changed := fastpathTV.DecMapStringUintptrV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapStringUintptrV(rv2i(rv).(map[string]uintptr), false, d)
+ v := rv.Interface().(map[string]uintptr)
+ fastpathTV.DecMapStringUintptrV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapStringUintptrX(vp *map[string]uintptr, d *Decoder) {
- v, changed := f.DecMapStringUintptrV(*vp, true, d)
+func (f fastpathT) DecMapStringUintptrX(vp *map[string]uintptr, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapStringUintptrV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapStringUintptrV(v map[string]uintptr, canChange bool,
+func (_ fastpathT) DecMapStringUintptrV(v map[string]uintptr, checkNil bool, canChange bool,
d *Decoder) (_ map[string]uintptr, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 24)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 24)
v = make(map[string]uintptr, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeString()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uintptr(dd.DecodeUint(uintBitsize))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeString()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uintptr(dd.DecodeUint(uintBitsize))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapStringIntR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[string]int)
+ v, changed := fastpathTV.DecMapStringIntV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapStringIntV(rv2i(rv).(map[string]int), false, d)
+ v := rv.Interface().(map[string]int)
+ fastpathTV.DecMapStringIntV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapStringIntX(vp *map[string]int, d *Decoder) {
- v, changed := f.DecMapStringIntV(*vp, true, d)
+func (f fastpathT) DecMapStringIntX(vp *map[string]int, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapStringIntV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapStringIntV(v map[string]int, canChange bool,
+func (_ fastpathT) DecMapStringIntV(v map[string]int, checkNil bool, canChange bool,
d *Decoder) (_ map[string]int, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 24)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 24)
v = make(map[string]int, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeString()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int(dd.DecodeInt(intBitsize))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeString()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int(dd.DecodeInt(intBitsize))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapStringInt8R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[string]int8)
+ v, changed := fastpathTV.DecMapStringInt8V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapStringInt8V(rv2i(rv).(map[string]int8), false, d)
+ v := rv.Interface().(map[string]int8)
+ fastpathTV.DecMapStringInt8V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapStringInt8X(vp *map[string]int8, d *Decoder) {
- v, changed := f.DecMapStringInt8V(*vp, true, d)
+func (f fastpathT) DecMapStringInt8X(vp *map[string]int8, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapStringInt8V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapStringInt8V(v map[string]int8, canChange bool,
+func (_ fastpathT) DecMapStringInt8V(v map[string]int8, checkNil bool, canChange bool,
d *Decoder) (_ map[string]int8, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 17)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 17)
v = make(map[string]int8, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeString()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int8(dd.DecodeInt(8))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = int8(chkOvf.IntV(dd.DecodeInt64(), 8))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeString()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int8(dd.DecodeInt(8))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapStringInt16R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[string]int16)
+ v, changed := fastpathTV.DecMapStringInt16V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapStringInt16V(rv2i(rv).(map[string]int16), false, d)
+ v := rv.Interface().(map[string]int16)
+ fastpathTV.DecMapStringInt16V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapStringInt16X(vp *map[string]int16, d *Decoder) {
- v, changed := f.DecMapStringInt16V(*vp, true, d)
+func (f fastpathT) DecMapStringInt16X(vp *map[string]int16, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapStringInt16V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapStringInt16V(v map[string]int16, canChange bool,
+func (_ fastpathT) DecMapStringInt16V(v map[string]int16, checkNil bool, canChange bool,
d *Decoder) (_ map[string]int16, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 18)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 18)
v = make(map[string]int16, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeString()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int16(dd.DecodeInt(16))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = int16(chkOvf.IntV(dd.DecodeInt64(), 16))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeString()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int16(dd.DecodeInt(16))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapStringInt32R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[string]int32)
+ v, changed := fastpathTV.DecMapStringInt32V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapStringInt32V(rv2i(rv).(map[string]int32), false, d)
+ v := rv.Interface().(map[string]int32)
+ fastpathTV.DecMapStringInt32V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapStringInt32X(vp *map[string]int32, d *Decoder) {
- v, changed := f.DecMapStringInt32V(*vp, true, d)
+func (f fastpathT) DecMapStringInt32X(vp *map[string]int32, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapStringInt32V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapStringInt32V(v map[string]int32, canChange bool,
+func (_ fastpathT) DecMapStringInt32V(v map[string]int32, checkNil bool, canChange bool,
d *Decoder) (_ map[string]int32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 20)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 20)
v = make(map[string]int32, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeString()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int32(dd.DecodeInt(32))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = int32(chkOvf.IntV(dd.DecodeInt64(), 32))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeString()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int32(dd.DecodeInt(32))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapStringInt64R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[string]int64)
+ v, changed := fastpathTV.DecMapStringInt64V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapStringInt64V(rv2i(rv).(map[string]int64), false, d)
+ v := rv.Interface().(map[string]int64)
+ fastpathTV.DecMapStringInt64V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapStringInt64X(vp *map[string]int64, d *Decoder) {
- v, changed := f.DecMapStringInt64V(*vp, true, d)
+func (f fastpathT) DecMapStringInt64X(vp *map[string]int64, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapStringInt64V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapStringInt64V(v map[string]int64, canChange bool,
+func (_ fastpathT) DecMapStringInt64V(v map[string]int64, checkNil bool, canChange bool,
d *Decoder) (_ map[string]int64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 24)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 24)
v = make(map[string]int64, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeString()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeInt(64)
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeInt64()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeString()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeInt(64)
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapStringFloat32R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[string]float32)
+ v, changed := fastpathTV.DecMapStringFloat32V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapStringFloat32V(rv2i(rv).(map[string]float32), false, d)
+ v := rv.Interface().(map[string]float32)
+ fastpathTV.DecMapStringFloat32V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapStringFloat32X(vp *map[string]float32, d *Decoder) {
- v, changed := f.DecMapStringFloat32V(*vp, true, d)
+func (f fastpathT) DecMapStringFloat32X(vp *map[string]float32, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapStringFloat32V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapStringFloat32V(v map[string]float32, canChange bool,
+func (_ fastpathT) DecMapStringFloat32V(v map[string]float32, checkNil bool, canChange bool,
d *Decoder) (_ map[string]float32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 20)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 20)
v = make(map[string]float32, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeString()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = float32(dd.DecodeFloat(true))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = float32(chkOvf.Float32V(dd.DecodeFloat64()))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeString()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = float32(dd.DecodeFloat(true))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapStringFloat64R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[string]float64)
+ v, changed := fastpathTV.DecMapStringFloat64V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapStringFloat64V(rv2i(rv).(map[string]float64), false, d)
+ v := rv.Interface().(map[string]float64)
+ fastpathTV.DecMapStringFloat64V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapStringFloat64X(vp *map[string]float64, d *Decoder) {
- v, changed := f.DecMapStringFloat64V(*vp, true, d)
+func (f fastpathT) DecMapStringFloat64X(vp *map[string]float64, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapStringFloat64V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapStringFloat64V(v map[string]float64, canChange bool,
+func (_ fastpathT) DecMapStringFloat64V(v map[string]float64, checkNil bool, canChange bool,
d *Decoder) (_ map[string]float64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 24)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 24)
v = make(map[string]float64, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeString()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeFloat(false)
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeFloat64()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeString()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeFloat(false)
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapStringBoolR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[string]bool)
+ v, changed := fastpathTV.DecMapStringBoolV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapStringBoolV(rv2i(rv).(map[string]bool), false, d)
+ v := rv.Interface().(map[string]bool)
+ fastpathTV.DecMapStringBoolV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapStringBoolX(vp *map[string]bool, d *Decoder) {
- v, changed := f.DecMapStringBoolV(*vp, true, d)
+func (f fastpathT) DecMapStringBoolX(vp *map[string]bool, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapStringBoolV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapStringBoolV(v map[string]bool, canChange bool,
+func (_ fastpathT) DecMapStringBoolV(v map[string]bool, checkNil bool, canChange bool,
d *Decoder) (_ map[string]bool, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 17)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 17)
v = make(map[string]bool, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeString()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeBool()
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeBool()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeString()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeBool()
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapFloat32IntfR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[float32]interface{})
+ v, changed := fastpathTV.DecMapFloat32IntfV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapFloat32IntfV(rv2i(rv).(map[float32]interface{}), false, d)
+ v := rv.Interface().(map[float32]interface{})
+ fastpathTV.DecMapFloat32IntfV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapFloat32IntfX(vp *map[float32]interface{}, d *Decoder) {
- v, changed := f.DecMapFloat32IntfV(*vp, true, d)
+func (f fastpathT) DecMapFloat32IntfX(vp *map[float32]interface{}, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapFloat32IntfV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapFloat32IntfV(v map[float32]interface{}, canChange bool,
+func (_ fastpathT) DecMapFloat32IntfV(v map[float32]interface{}, checkNil bool, canChange bool,
d *Decoder) (_ map[float32]interface{}, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 20)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 20)
v = make(map[float32]interface{}, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset
+ mapGet := !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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = float32(dd.DecodeFloat(true))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ if mapGet {
+ mv = v[mk]
+ } else {
+ mv = nil
+ }
+ d.decode(&mv)
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- if mapGet {
- mv = v[mk]
- } else {
- mv = nil
- }
- d.decode(&mv)
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = float32(dd.DecodeFloat(true))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ if mapGet {
+ mv = v[mk]
+ } else {
+ mv = nil
+ }
+ d.decode(&mv)
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapFloat32StringR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[float32]string)
+ v, changed := fastpathTV.DecMapFloat32StringV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapFloat32StringV(rv2i(rv).(map[float32]string), false, d)
+ v := rv.Interface().(map[float32]string)
+ fastpathTV.DecMapFloat32StringV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapFloat32StringX(vp *map[float32]string, d *Decoder) {
- v, changed := f.DecMapFloat32StringV(*vp, true, d)
+func (f fastpathT) DecMapFloat32StringX(vp *map[float32]string, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapFloat32StringV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapFloat32StringV(v map[float32]string, canChange bool,
+func (_ fastpathT) DecMapFloat32StringV(v map[float32]string, checkNil bool, canChange bool,
d *Decoder) (_ map[float32]string, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 20)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 20)
v = make(map[float32]string, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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] = ""
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = float32(dd.DecodeFloat(true))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeString()
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeString()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = float32(dd.DecodeFloat(true))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeString()
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapFloat32UintR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[float32]uint)
+ v, changed := fastpathTV.DecMapFloat32UintV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapFloat32UintV(rv2i(rv).(map[float32]uint), false, d)
+ v := rv.Interface().(map[float32]uint)
+ fastpathTV.DecMapFloat32UintV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapFloat32UintX(vp *map[float32]uint, d *Decoder) {
- v, changed := f.DecMapFloat32UintV(*vp, true, d)
+func (f fastpathT) DecMapFloat32UintX(vp *map[float32]uint, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapFloat32UintV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapFloat32UintV(v map[float32]uint, canChange bool,
+func (_ fastpathT) DecMapFloat32UintV(v map[float32]uint, checkNil bool, canChange bool,
d *Decoder) (_ map[float32]uint, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12)
v = make(map[float32]uint, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = float32(dd.DecodeFloat(true))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint(dd.DecodeUint(uintBitsize))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = float32(dd.DecodeFloat(true))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint(dd.DecodeUint(uintBitsize))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapFloat32Uint8R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[float32]uint8)
+ v, changed := fastpathTV.DecMapFloat32Uint8V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapFloat32Uint8V(rv2i(rv).(map[float32]uint8), false, d)
+ v := rv.Interface().(map[float32]uint8)
+ fastpathTV.DecMapFloat32Uint8V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapFloat32Uint8X(vp *map[float32]uint8, d *Decoder) {
- v, changed := f.DecMapFloat32Uint8V(*vp, true, d)
+func (f fastpathT) DecMapFloat32Uint8X(vp *map[float32]uint8, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapFloat32Uint8V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapFloat32Uint8V(v map[float32]uint8, canChange bool,
+func (_ fastpathT) DecMapFloat32Uint8V(v map[float32]uint8, checkNil bool, canChange bool,
d *Decoder) (_ map[float32]uint8, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 5)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 5)
v = make(map[float32]uint8, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = float32(dd.DecodeFloat(true))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint8(dd.DecodeUint(8))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uint8(chkOvf.UintV(dd.DecodeUint64(), 8))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = float32(dd.DecodeFloat(true))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint8(dd.DecodeUint(8))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapFloat32Uint16R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[float32]uint16)
+ v, changed := fastpathTV.DecMapFloat32Uint16V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapFloat32Uint16V(rv2i(rv).(map[float32]uint16), false, d)
+ v := rv.Interface().(map[float32]uint16)
+ fastpathTV.DecMapFloat32Uint16V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapFloat32Uint16X(vp *map[float32]uint16, d *Decoder) {
- v, changed := f.DecMapFloat32Uint16V(*vp, true, d)
+func (f fastpathT) DecMapFloat32Uint16X(vp *map[float32]uint16, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapFloat32Uint16V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapFloat32Uint16V(v map[float32]uint16, canChange bool,
+func (_ fastpathT) DecMapFloat32Uint16V(v map[float32]uint16, checkNil bool, canChange bool,
d *Decoder) (_ map[float32]uint16, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 6)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 6)
v = make(map[float32]uint16, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = float32(dd.DecodeFloat(true))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint16(dd.DecodeUint(16))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uint16(chkOvf.UintV(dd.DecodeUint64(), 16))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = float32(dd.DecodeFloat(true))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint16(dd.DecodeUint(16))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapFloat32Uint32R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[float32]uint32)
+ v, changed := fastpathTV.DecMapFloat32Uint32V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapFloat32Uint32V(rv2i(rv).(map[float32]uint32), false, d)
+ v := rv.Interface().(map[float32]uint32)
+ fastpathTV.DecMapFloat32Uint32V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapFloat32Uint32X(vp *map[float32]uint32, d *Decoder) {
- v, changed := f.DecMapFloat32Uint32V(*vp, true, d)
+func (f fastpathT) DecMapFloat32Uint32X(vp *map[float32]uint32, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapFloat32Uint32V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapFloat32Uint32V(v map[float32]uint32, canChange bool,
+func (_ fastpathT) DecMapFloat32Uint32V(v map[float32]uint32, checkNil bool, canChange bool,
d *Decoder) (_ map[float32]uint32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 8)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 8)
v = make(map[float32]uint32, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = float32(dd.DecodeFloat(true))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint32(dd.DecodeUint(32))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uint32(chkOvf.UintV(dd.DecodeUint64(), 32))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = float32(dd.DecodeFloat(true))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint32(dd.DecodeUint(32))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapFloat32Uint64R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[float32]uint64)
+ v, changed := fastpathTV.DecMapFloat32Uint64V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapFloat32Uint64V(rv2i(rv).(map[float32]uint64), false, d)
+ v := rv.Interface().(map[float32]uint64)
+ fastpathTV.DecMapFloat32Uint64V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapFloat32Uint64X(vp *map[float32]uint64, d *Decoder) {
- v, changed := f.DecMapFloat32Uint64V(*vp, true, d)
+func (f fastpathT) DecMapFloat32Uint64X(vp *map[float32]uint64, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapFloat32Uint64V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapFloat32Uint64V(v map[float32]uint64, canChange bool,
+func (_ fastpathT) DecMapFloat32Uint64V(v map[float32]uint64, checkNil bool, canChange bool,
d *Decoder) (_ map[float32]uint64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12)
v = make(map[float32]uint64, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = float32(dd.DecodeFloat(true))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeUint(64)
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeUint64()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = float32(dd.DecodeFloat(true))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeUint(64)
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapFloat32UintptrR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[float32]uintptr)
+ v, changed := fastpathTV.DecMapFloat32UintptrV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapFloat32UintptrV(rv2i(rv).(map[float32]uintptr), false, d)
+ v := rv.Interface().(map[float32]uintptr)
+ fastpathTV.DecMapFloat32UintptrV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapFloat32UintptrX(vp *map[float32]uintptr, d *Decoder) {
- v, changed := f.DecMapFloat32UintptrV(*vp, true, d)
+func (f fastpathT) DecMapFloat32UintptrX(vp *map[float32]uintptr, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapFloat32UintptrV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapFloat32UintptrV(v map[float32]uintptr, canChange bool,
+func (_ fastpathT) DecMapFloat32UintptrV(v map[float32]uintptr, checkNil bool, canChange bool,
d *Decoder) (_ map[float32]uintptr, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12)
v = make(map[float32]uintptr, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = float32(dd.DecodeFloat(true))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uintptr(dd.DecodeUint(uintBitsize))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = float32(dd.DecodeFloat(true))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uintptr(dd.DecodeUint(uintBitsize))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapFloat32IntR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[float32]int)
+ v, changed := fastpathTV.DecMapFloat32IntV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapFloat32IntV(rv2i(rv).(map[float32]int), false, d)
+ v := rv.Interface().(map[float32]int)
+ fastpathTV.DecMapFloat32IntV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapFloat32IntX(vp *map[float32]int, d *Decoder) {
- v, changed := f.DecMapFloat32IntV(*vp, true, d)
+func (f fastpathT) DecMapFloat32IntX(vp *map[float32]int, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapFloat32IntV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapFloat32IntV(v map[float32]int, canChange bool,
+func (_ fastpathT) DecMapFloat32IntV(v map[float32]int, checkNil bool, canChange bool,
d *Decoder) (_ map[float32]int, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12)
v = make(map[float32]int, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = float32(dd.DecodeFloat(true))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int(dd.DecodeInt(intBitsize))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = float32(dd.DecodeFloat(true))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int(dd.DecodeInt(intBitsize))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapFloat32Int8R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[float32]int8)
+ v, changed := fastpathTV.DecMapFloat32Int8V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapFloat32Int8V(rv2i(rv).(map[float32]int8), false, d)
+ v := rv.Interface().(map[float32]int8)
+ fastpathTV.DecMapFloat32Int8V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapFloat32Int8X(vp *map[float32]int8, d *Decoder) {
- v, changed := f.DecMapFloat32Int8V(*vp, true, d)
+func (f fastpathT) DecMapFloat32Int8X(vp *map[float32]int8, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapFloat32Int8V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapFloat32Int8V(v map[float32]int8, canChange bool,
+func (_ fastpathT) DecMapFloat32Int8V(v map[float32]int8, checkNil bool, canChange bool,
d *Decoder) (_ map[float32]int8, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 5)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 5)
v = make(map[float32]int8, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = float32(dd.DecodeFloat(true))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int8(dd.DecodeInt(8))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = int8(chkOvf.IntV(dd.DecodeInt64(), 8))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = float32(dd.DecodeFloat(true))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int8(dd.DecodeInt(8))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapFloat32Int16R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[float32]int16)
+ v, changed := fastpathTV.DecMapFloat32Int16V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapFloat32Int16V(rv2i(rv).(map[float32]int16), false, d)
+ v := rv.Interface().(map[float32]int16)
+ fastpathTV.DecMapFloat32Int16V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapFloat32Int16X(vp *map[float32]int16, d *Decoder) {
- v, changed := f.DecMapFloat32Int16V(*vp, true, d)
+func (f fastpathT) DecMapFloat32Int16X(vp *map[float32]int16, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapFloat32Int16V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapFloat32Int16V(v map[float32]int16, canChange bool,
+func (_ fastpathT) DecMapFloat32Int16V(v map[float32]int16, checkNil bool, canChange bool,
d *Decoder) (_ map[float32]int16, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 6)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 6)
v = make(map[float32]int16, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = float32(dd.DecodeFloat(true))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int16(dd.DecodeInt(16))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = int16(chkOvf.IntV(dd.DecodeInt64(), 16))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = float32(dd.DecodeFloat(true))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int16(dd.DecodeInt(16))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapFloat32Int32R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[float32]int32)
+ v, changed := fastpathTV.DecMapFloat32Int32V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapFloat32Int32V(rv2i(rv).(map[float32]int32), false, d)
+ v := rv.Interface().(map[float32]int32)
+ fastpathTV.DecMapFloat32Int32V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapFloat32Int32X(vp *map[float32]int32, d *Decoder) {
- v, changed := f.DecMapFloat32Int32V(*vp, true, d)
+func (f fastpathT) DecMapFloat32Int32X(vp *map[float32]int32, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapFloat32Int32V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapFloat32Int32V(v map[float32]int32, canChange bool,
+func (_ fastpathT) DecMapFloat32Int32V(v map[float32]int32, checkNil bool, canChange bool,
d *Decoder) (_ map[float32]int32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 8)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 8)
v = make(map[float32]int32, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = float32(dd.DecodeFloat(true))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int32(dd.DecodeInt(32))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = int32(chkOvf.IntV(dd.DecodeInt64(), 32))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = float32(dd.DecodeFloat(true))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int32(dd.DecodeInt(32))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapFloat32Int64R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[float32]int64)
+ v, changed := fastpathTV.DecMapFloat32Int64V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapFloat32Int64V(rv2i(rv).(map[float32]int64), false, d)
+ v := rv.Interface().(map[float32]int64)
+ fastpathTV.DecMapFloat32Int64V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapFloat32Int64X(vp *map[float32]int64, d *Decoder) {
- v, changed := f.DecMapFloat32Int64V(*vp, true, d)
+func (f fastpathT) DecMapFloat32Int64X(vp *map[float32]int64, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapFloat32Int64V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapFloat32Int64V(v map[float32]int64, canChange bool,
+func (_ fastpathT) DecMapFloat32Int64V(v map[float32]int64, checkNil bool, canChange bool,
d *Decoder) (_ map[float32]int64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12)
v = make(map[float32]int64, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = float32(dd.DecodeFloat(true))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeInt(64)
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeInt64()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = float32(dd.DecodeFloat(true))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeInt(64)
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapFloat32Float32R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[float32]float32)
+ v, changed := fastpathTV.DecMapFloat32Float32V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapFloat32Float32V(rv2i(rv).(map[float32]float32), false, d)
+ v := rv.Interface().(map[float32]float32)
+ fastpathTV.DecMapFloat32Float32V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapFloat32Float32X(vp *map[float32]float32, d *Decoder) {
- v, changed := f.DecMapFloat32Float32V(*vp, true, d)
+func (f fastpathT) DecMapFloat32Float32X(vp *map[float32]float32, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapFloat32Float32V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapFloat32Float32V(v map[float32]float32, canChange bool,
+func (_ fastpathT) DecMapFloat32Float32V(v map[float32]float32, checkNil bool, canChange bool,
d *Decoder) (_ map[float32]float32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 8)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 8)
v = make(map[float32]float32, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = float32(dd.DecodeFloat(true))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = float32(dd.DecodeFloat(true))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = float32(chkOvf.Float32V(dd.DecodeFloat64()))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = float32(dd.DecodeFloat(true))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = float32(dd.DecodeFloat(true))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapFloat32Float64R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[float32]float64)
+ v, changed := fastpathTV.DecMapFloat32Float64V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapFloat32Float64V(rv2i(rv).(map[float32]float64), false, d)
+ v := rv.Interface().(map[float32]float64)
+ fastpathTV.DecMapFloat32Float64V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapFloat32Float64X(vp *map[float32]float64, d *Decoder) {
- v, changed := f.DecMapFloat32Float64V(*vp, true, d)
+func (f fastpathT) DecMapFloat32Float64X(vp *map[float32]float64, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapFloat32Float64V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapFloat32Float64V(v map[float32]float64, canChange bool,
+func (_ fastpathT) DecMapFloat32Float64V(v map[float32]float64, checkNil bool, canChange bool,
d *Decoder) (_ map[float32]float64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12)
v = make(map[float32]float64, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = float32(dd.DecodeFloat(true))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeFloat(false)
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeFloat64()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = float32(dd.DecodeFloat(true))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeFloat(false)
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapFloat32BoolR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[float32]bool)
+ v, changed := fastpathTV.DecMapFloat32BoolV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapFloat32BoolV(rv2i(rv).(map[float32]bool), false, d)
+ v := rv.Interface().(map[float32]bool)
+ fastpathTV.DecMapFloat32BoolV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapFloat32BoolX(vp *map[float32]bool, d *Decoder) {
- v, changed := f.DecMapFloat32BoolV(*vp, true, d)
+func (f fastpathT) DecMapFloat32BoolX(vp *map[float32]bool, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapFloat32BoolV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapFloat32BoolV(v map[float32]bool, canChange bool,
+func (_ fastpathT) DecMapFloat32BoolV(v map[float32]bool, checkNil bool, canChange bool,
d *Decoder) (_ map[float32]bool, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 5)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 5)
v = make(map[float32]bool, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = float32(dd.DecodeFloat(true))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeBool()
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeBool()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = float32(dd.DecodeFloat(true))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeBool()
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapFloat64IntfR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[float64]interface{})
+ v, changed := fastpathTV.DecMapFloat64IntfV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapFloat64IntfV(rv2i(rv).(map[float64]interface{}), false, d)
+ v := rv.Interface().(map[float64]interface{})
+ fastpathTV.DecMapFloat64IntfV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapFloat64IntfX(vp *map[float64]interface{}, d *Decoder) {
- v, changed := f.DecMapFloat64IntfV(*vp, true, d)
+func (f fastpathT) DecMapFloat64IntfX(vp *map[float64]interface{}, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapFloat64IntfV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapFloat64IntfV(v map[float64]interface{}, canChange bool,
+func (_ fastpathT) DecMapFloat64IntfV(v map[float64]interface{}, checkNil bool, canChange bool,
d *Decoder) (_ map[float64]interface{}, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 24)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 24)
v = make(map[float64]interface{}, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset
+ mapGet := !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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeFloat(false)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ if mapGet {
+ mv = v[mk]
+ } else {
+ mv = nil
+ }
+ d.decode(&mv)
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- if mapGet {
- mv = v[mk]
- } else {
- mv = nil
- }
- d.decode(&mv)
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeFloat(false)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ if mapGet {
+ mv = v[mk]
+ } else {
+ mv = nil
+ }
+ d.decode(&mv)
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapFloat64StringR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[float64]string)
+ v, changed := fastpathTV.DecMapFloat64StringV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapFloat64StringV(rv2i(rv).(map[float64]string), false, d)
+ v := rv.Interface().(map[float64]string)
+ fastpathTV.DecMapFloat64StringV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapFloat64StringX(vp *map[float64]string, d *Decoder) {
- v, changed := f.DecMapFloat64StringV(*vp, true, d)
+func (f fastpathT) DecMapFloat64StringX(vp *map[float64]string, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapFloat64StringV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapFloat64StringV(v map[float64]string, canChange bool,
+func (_ fastpathT) DecMapFloat64StringV(v map[float64]string, checkNil bool, canChange bool,
d *Decoder) (_ map[float64]string, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 24)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 24)
v = make(map[float64]string, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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] = ""
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeFloat(false)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeString()
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeString()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeFloat(false)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeString()
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapFloat64UintR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[float64]uint)
+ v, changed := fastpathTV.DecMapFloat64UintV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapFloat64UintV(rv2i(rv).(map[float64]uint), false, d)
+ v := rv.Interface().(map[float64]uint)
+ fastpathTV.DecMapFloat64UintV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapFloat64UintX(vp *map[float64]uint, d *Decoder) {
- v, changed := f.DecMapFloat64UintV(*vp, true, d)
+func (f fastpathT) DecMapFloat64UintX(vp *map[float64]uint, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapFloat64UintV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapFloat64UintV(v map[float64]uint, canChange bool,
+func (_ fastpathT) DecMapFloat64UintV(v map[float64]uint, checkNil bool, canChange bool,
d *Decoder) (_ map[float64]uint, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16)
v = make(map[float64]uint, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeFloat(false)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint(dd.DecodeUint(uintBitsize))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeFloat(false)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint(dd.DecodeUint(uintBitsize))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapFloat64Uint8R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[float64]uint8)
+ v, changed := fastpathTV.DecMapFloat64Uint8V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapFloat64Uint8V(rv2i(rv).(map[float64]uint8), false, d)
+ v := rv.Interface().(map[float64]uint8)
+ fastpathTV.DecMapFloat64Uint8V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapFloat64Uint8X(vp *map[float64]uint8, d *Decoder) {
- v, changed := f.DecMapFloat64Uint8V(*vp, true, d)
+func (f fastpathT) DecMapFloat64Uint8X(vp *map[float64]uint8, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapFloat64Uint8V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapFloat64Uint8V(v map[float64]uint8, canChange bool,
+func (_ fastpathT) DecMapFloat64Uint8V(v map[float64]uint8, checkNil bool, canChange bool,
d *Decoder) (_ map[float64]uint8, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9)
v = make(map[float64]uint8, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeFloat(false)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint8(dd.DecodeUint(8))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uint8(chkOvf.UintV(dd.DecodeUint64(), 8))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeFloat(false)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint8(dd.DecodeUint(8))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapFloat64Uint16R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[float64]uint16)
+ v, changed := fastpathTV.DecMapFloat64Uint16V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapFloat64Uint16V(rv2i(rv).(map[float64]uint16), false, d)
+ v := rv.Interface().(map[float64]uint16)
+ fastpathTV.DecMapFloat64Uint16V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapFloat64Uint16X(vp *map[float64]uint16, d *Decoder) {
- v, changed := f.DecMapFloat64Uint16V(*vp, true, d)
+func (f fastpathT) DecMapFloat64Uint16X(vp *map[float64]uint16, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapFloat64Uint16V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapFloat64Uint16V(v map[float64]uint16, canChange bool,
+func (_ fastpathT) DecMapFloat64Uint16V(v map[float64]uint16, checkNil bool, canChange bool,
d *Decoder) (_ map[float64]uint16, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 10)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 10)
v = make(map[float64]uint16, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeFloat(false)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint16(dd.DecodeUint(16))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uint16(chkOvf.UintV(dd.DecodeUint64(), 16))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeFloat(false)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint16(dd.DecodeUint(16))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapFloat64Uint32R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[float64]uint32)
+ v, changed := fastpathTV.DecMapFloat64Uint32V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapFloat64Uint32V(rv2i(rv).(map[float64]uint32), false, d)
+ v := rv.Interface().(map[float64]uint32)
+ fastpathTV.DecMapFloat64Uint32V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapFloat64Uint32X(vp *map[float64]uint32, d *Decoder) {
- v, changed := f.DecMapFloat64Uint32V(*vp, true, d)
+func (f fastpathT) DecMapFloat64Uint32X(vp *map[float64]uint32, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapFloat64Uint32V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapFloat64Uint32V(v map[float64]uint32, canChange bool,
+func (_ fastpathT) DecMapFloat64Uint32V(v map[float64]uint32, checkNil bool, canChange bool,
d *Decoder) (_ map[float64]uint32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12)
v = make(map[float64]uint32, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeFloat(false)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint32(dd.DecodeUint(32))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uint32(chkOvf.UintV(dd.DecodeUint64(), 32))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeFloat(false)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint32(dd.DecodeUint(32))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapFloat64Uint64R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[float64]uint64)
+ v, changed := fastpathTV.DecMapFloat64Uint64V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapFloat64Uint64V(rv2i(rv).(map[float64]uint64), false, d)
+ v := rv.Interface().(map[float64]uint64)
+ fastpathTV.DecMapFloat64Uint64V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapFloat64Uint64X(vp *map[float64]uint64, d *Decoder) {
- v, changed := f.DecMapFloat64Uint64V(*vp, true, d)
+func (f fastpathT) DecMapFloat64Uint64X(vp *map[float64]uint64, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapFloat64Uint64V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapFloat64Uint64V(v map[float64]uint64, canChange bool,
+func (_ fastpathT) DecMapFloat64Uint64V(v map[float64]uint64, checkNil bool, canChange bool,
d *Decoder) (_ map[float64]uint64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16)
v = make(map[float64]uint64, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeFloat(false)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeUint(64)
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeUint64()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeFloat(false)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeUint(64)
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapFloat64UintptrR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[float64]uintptr)
+ v, changed := fastpathTV.DecMapFloat64UintptrV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapFloat64UintptrV(rv2i(rv).(map[float64]uintptr), false, d)
+ v := rv.Interface().(map[float64]uintptr)
+ fastpathTV.DecMapFloat64UintptrV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapFloat64UintptrX(vp *map[float64]uintptr, d *Decoder) {
- v, changed := f.DecMapFloat64UintptrV(*vp, true, d)
+func (f fastpathT) DecMapFloat64UintptrX(vp *map[float64]uintptr, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapFloat64UintptrV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapFloat64UintptrV(v map[float64]uintptr, canChange bool,
+func (_ fastpathT) DecMapFloat64UintptrV(v map[float64]uintptr, checkNil bool, canChange bool,
d *Decoder) (_ map[float64]uintptr, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16)
v = make(map[float64]uintptr, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeFloat(false)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uintptr(dd.DecodeUint(uintBitsize))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeFloat(false)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uintptr(dd.DecodeUint(uintBitsize))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapFloat64IntR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[float64]int)
+ v, changed := fastpathTV.DecMapFloat64IntV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapFloat64IntV(rv2i(rv).(map[float64]int), false, d)
+ v := rv.Interface().(map[float64]int)
+ fastpathTV.DecMapFloat64IntV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapFloat64IntX(vp *map[float64]int, d *Decoder) {
- v, changed := f.DecMapFloat64IntV(*vp, true, d)
+func (f fastpathT) DecMapFloat64IntX(vp *map[float64]int, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapFloat64IntV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapFloat64IntV(v map[float64]int, canChange bool,
+func (_ fastpathT) DecMapFloat64IntV(v map[float64]int, checkNil bool, canChange bool,
d *Decoder) (_ map[float64]int, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16)
v = make(map[float64]int, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeFloat(false)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int(dd.DecodeInt(intBitsize))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeFloat(false)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int(dd.DecodeInt(intBitsize))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapFloat64Int8R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[float64]int8)
+ v, changed := fastpathTV.DecMapFloat64Int8V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapFloat64Int8V(rv2i(rv).(map[float64]int8), false, d)
+ v := rv.Interface().(map[float64]int8)
+ fastpathTV.DecMapFloat64Int8V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapFloat64Int8X(vp *map[float64]int8, d *Decoder) {
- v, changed := f.DecMapFloat64Int8V(*vp, true, d)
+func (f fastpathT) DecMapFloat64Int8X(vp *map[float64]int8, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapFloat64Int8V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapFloat64Int8V(v map[float64]int8, canChange bool,
+func (_ fastpathT) DecMapFloat64Int8V(v map[float64]int8, checkNil bool, canChange bool,
d *Decoder) (_ map[float64]int8, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9)
v = make(map[float64]int8, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeFloat(false)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int8(dd.DecodeInt(8))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = int8(chkOvf.IntV(dd.DecodeInt64(), 8))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeFloat(false)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int8(dd.DecodeInt(8))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapFloat64Int16R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[float64]int16)
+ v, changed := fastpathTV.DecMapFloat64Int16V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapFloat64Int16V(rv2i(rv).(map[float64]int16), false, d)
+ v := rv.Interface().(map[float64]int16)
+ fastpathTV.DecMapFloat64Int16V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapFloat64Int16X(vp *map[float64]int16, d *Decoder) {
- v, changed := f.DecMapFloat64Int16V(*vp, true, d)
+func (f fastpathT) DecMapFloat64Int16X(vp *map[float64]int16, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapFloat64Int16V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapFloat64Int16V(v map[float64]int16, canChange bool,
+func (_ fastpathT) DecMapFloat64Int16V(v map[float64]int16, checkNil bool, canChange bool,
d *Decoder) (_ map[float64]int16, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 10)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 10)
v = make(map[float64]int16, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeFloat(false)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int16(dd.DecodeInt(16))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = int16(chkOvf.IntV(dd.DecodeInt64(), 16))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeFloat(false)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int16(dd.DecodeInt(16))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapFloat64Int32R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[float64]int32)
+ v, changed := fastpathTV.DecMapFloat64Int32V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapFloat64Int32V(rv2i(rv).(map[float64]int32), false, d)
+ v := rv.Interface().(map[float64]int32)
+ fastpathTV.DecMapFloat64Int32V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapFloat64Int32X(vp *map[float64]int32, d *Decoder) {
- v, changed := f.DecMapFloat64Int32V(*vp, true, d)
+func (f fastpathT) DecMapFloat64Int32X(vp *map[float64]int32, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapFloat64Int32V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapFloat64Int32V(v map[float64]int32, canChange bool,
+func (_ fastpathT) DecMapFloat64Int32V(v map[float64]int32, checkNil bool, canChange bool,
d *Decoder) (_ map[float64]int32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12)
v = make(map[float64]int32, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeFloat(false)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int32(dd.DecodeInt(32))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = int32(chkOvf.IntV(dd.DecodeInt64(), 32))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeFloat(false)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int32(dd.DecodeInt(32))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapFloat64Int64R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[float64]int64)
+ v, changed := fastpathTV.DecMapFloat64Int64V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapFloat64Int64V(rv2i(rv).(map[float64]int64), false, d)
+ v := rv.Interface().(map[float64]int64)
+ fastpathTV.DecMapFloat64Int64V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapFloat64Int64X(vp *map[float64]int64, d *Decoder) {
- v, changed := f.DecMapFloat64Int64V(*vp, true, d)
+func (f fastpathT) DecMapFloat64Int64X(vp *map[float64]int64, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapFloat64Int64V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapFloat64Int64V(v map[float64]int64, canChange bool,
+func (_ fastpathT) DecMapFloat64Int64V(v map[float64]int64, checkNil bool, canChange bool,
d *Decoder) (_ map[float64]int64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16)
v = make(map[float64]int64, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeFloat(false)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeInt(64)
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeInt64()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeFloat(false)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeInt(64)
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapFloat64Float32R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[float64]float32)
+ v, changed := fastpathTV.DecMapFloat64Float32V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapFloat64Float32V(rv2i(rv).(map[float64]float32), false, d)
+ v := rv.Interface().(map[float64]float32)
+ fastpathTV.DecMapFloat64Float32V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapFloat64Float32X(vp *map[float64]float32, d *Decoder) {
- v, changed := f.DecMapFloat64Float32V(*vp, true, d)
+func (f fastpathT) DecMapFloat64Float32X(vp *map[float64]float32, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapFloat64Float32V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapFloat64Float32V(v map[float64]float32, canChange bool,
+func (_ fastpathT) DecMapFloat64Float32V(v map[float64]float32, checkNil bool, canChange bool,
d *Decoder) (_ map[float64]float32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12)
v = make(map[float64]float32, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeFloat(false)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = float32(dd.DecodeFloat(true))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = float32(chkOvf.Float32V(dd.DecodeFloat64()))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeFloat(false)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = float32(dd.DecodeFloat(true))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapFloat64Float64R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[float64]float64)
+ v, changed := fastpathTV.DecMapFloat64Float64V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapFloat64Float64V(rv2i(rv).(map[float64]float64), false, d)
+ v := rv.Interface().(map[float64]float64)
+ fastpathTV.DecMapFloat64Float64V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapFloat64Float64X(vp *map[float64]float64, d *Decoder) {
- v, changed := f.DecMapFloat64Float64V(*vp, true, d)
+func (f fastpathT) DecMapFloat64Float64X(vp *map[float64]float64, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapFloat64Float64V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapFloat64Float64V(v map[float64]float64, canChange bool,
+func (_ fastpathT) DecMapFloat64Float64V(v map[float64]float64, checkNil bool, canChange bool,
d *Decoder) (_ map[float64]float64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16)
v = make(map[float64]float64, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeFloat(false)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeFloat(false)
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeFloat64()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeFloat(false)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeFloat(false)
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapFloat64BoolR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[float64]bool)
+ v, changed := fastpathTV.DecMapFloat64BoolV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapFloat64BoolV(rv2i(rv).(map[float64]bool), false, d)
+ v := rv.Interface().(map[float64]bool)
+ fastpathTV.DecMapFloat64BoolV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapFloat64BoolX(vp *map[float64]bool, d *Decoder) {
- v, changed := f.DecMapFloat64BoolV(*vp, true, d)
+func (f fastpathT) DecMapFloat64BoolX(vp *map[float64]bool, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapFloat64BoolV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapFloat64BoolV(v map[float64]bool, canChange bool,
+func (_ fastpathT) DecMapFloat64BoolV(v map[float64]bool, checkNil bool, canChange bool,
d *Decoder) (_ map[float64]bool, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9)
v = make(map[float64]bool, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeFloat(false)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeBool()
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeBool()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeFloat(false)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeBool()
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUintIntfR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint]interface{})
+ v, changed := fastpathTV.DecMapUintIntfV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUintIntfV(rv2i(rv).(map[uint]interface{}), false, d)
+ v := rv.Interface().(map[uint]interface{})
+ fastpathTV.DecMapUintIntfV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUintIntfX(vp *map[uint]interface{}, d *Decoder) {
- v, changed := f.DecMapUintIntfV(*vp, true, d)
+func (f fastpathT) DecMapUintIntfX(vp *map[uint]interface{}, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUintIntfV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUintIntfV(v map[uint]interface{}, canChange bool,
+func (_ fastpathT) DecMapUintIntfV(v map[uint]interface{}, checkNil bool, canChange bool,
d *Decoder) (_ map[uint]interface{}, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 24)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 24)
v = make(map[uint]interface{}, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset
+ mapGet := !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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint(dd.DecodeUint(uintBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ if mapGet {
+ mv = v[mk]
+ } else {
+ mv = nil
+ }
+ d.decode(&mv)
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- if mapGet {
- mv = v[mk]
- } else {
- mv = nil
- }
- d.decode(&mv)
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint(dd.DecodeUint(uintBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ if mapGet {
+ mv = v[mk]
+ } else {
+ mv = nil
+ }
+ d.decode(&mv)
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUintStringR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint]string)
+ v, changed := fastpathTV.DecMapUintStringV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUintStringV(rv2i(rv).(map[uint]string), false, d)
+ v := rv.Interface().(map[uint]string)
+ fastpathTV.DecMapUintStringV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUintStringX(vp *map[uint]string, d *Decoder) {
- v, changed := f.DecMapUintStringV(*vp, true, d)
+func (f fastpathT) DecMapUintStringX(vp *map[uint]string, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUintStringV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUintStringV(v map[uint]string, canChange bool,
+func (_ fastpathT) DecMapUintStringV(v map[uint]string, checkNil bool, canChange bool,
d *Decoder) (_ map[uint]string, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 24)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 24)
v = make(map[uint]string, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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] = ""
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint(dd.DecodeUint(uintBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeString()
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeString()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint(dd.DecodeUint(uintBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeString()
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUintUintR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint]uint)
+ v, changed := fastpathTV.DecMapUintUintV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUintUintV(rv2i(rv).(map[uint]uint), false, d)
+ v := rv.Interface().(map[uint]uint)
+ fastpathTV.DecMapUintUintV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUintUintX(vp *map[uint]uint, d *Decoder) {
- v, changed := f.DecMapUintUintV(*vp, true, d)
+func (f fastpathT) DecMapUintUintX(vp *map[uint]uint, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUintUintV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUintUintV(v map[uint]uint, canChange bool,
+func (_ fastpathT) DecMapUintUintV(v map[uint]uint, checkNil bool, canChange bool,
d *Decoder) (_ map[uint]uint, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16)
v = make(map[uint]uint, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint(dd.DecodeUint(uintBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint(dd.DecodeUint(uintBitsize))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint(dd.DecodeUint(uintBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint(dd.DecodeUint(uintBitsize))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUintUint8R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint]uint8)
+ v, changed := fastpathTV.DecMapUintUint8V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUintUint8V(rv2i(rv).(map[uint]uint8), false, d)
+ v := rv.Interface().(map[uint]uint8)
+ fastpathTV.DecMapUintUint8V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUintUint8X(vp *map[uint]uint8, d *Decoder) {
- v, changed := f.DecMapUintUint8V(*vp, true, d)
+func (f fastpathT) DecMapUintUint8X(vp *map[uint]uint8, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUintUint8V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUintUint8V(v map[uint]uint8, canChange bool,
+func (_ fastpathT) DecMapUintUint8V(v map[uint]uint8, checkNil bool, canChange bool,
d *Decoder) (_ map[uint]uint8, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9)
v = make(map[uint]uint8, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint(dd.DecodeUint(uintBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint8(dd.DecodeUint(8))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uint8(chkOvf.UintV(dd.DecodeUint64(), 8))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint(dd.DecodeUint(uintBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint8(dd.DecodeUint(8))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUintUint16R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint]uint16)
+ v, changed := fastpathTV.DecMapUintUint16V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUintUint16V(rv2i(rv).(map[uint]uint16), false, d)
+ v := rv.Interface().(map[uint]uint16)
+ fastpathTV.DecMapUintUint16V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUintUint16X(vp *map[uint]uint16, d *Decoder) {
- v, changed := f.DecMapUintUint16V(*vp, true, d)
+func (f fastpathT) DecMapUintUint16X(vp *map[uint]uint16, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUintUint16V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUintUint16V(v map[uint]uint16, canChange bool,
+func (_ fastpathT) DecMapUintUint16V(v map[uint]uint16, checkNil bool, canChange bool,
d *Decoder) (_ map[uint]uint16, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 10)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 10)
v = make(map[uint]uint16, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint(dd.DecodeUint(uintBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint16(dd.DecodeUint(16))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uint16(chkOvf.UintV(dd.DecodeUint64(), 16))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint(dd.DecodeUint(uintBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint16(dd.DecodeUint(16))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUintUint32R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint]uint32)
+ v, changed := fastpathTV.DecMapUintUint32V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUintUint32V(rv2i(rv).(map[uint]uint32), false, d)
+ v := rv.Interface().(map[uint]uint32)
+ fastpathTV.DecMapUintUint32V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUintUint32X(vp *map[uint]uint32, d *Decoder) {
- v, changed := f.DecMapUintUint32V(*vp, true, d)
+func (f fastpathT) DecMapUintUint32X(vp *map[uint]uint32, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUintUint32V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUintUint32V(v map[uint]uint32, canChange bool,
+func (_ fastpathT) DecMapUintUint32V(v map[uint]uint32, checkNil bool, canChange bool,
d *Decoder) (_ map[uint]uint32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12)
v = make(map[uint]uint32, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint(dd.DecodeUint(uintBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint32(dd.DecodeUint(32))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uint32(chkOvf.UintV(dd.DecodeUint64(), 32))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint(dd.DecodeUint(uintBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint32(dd.DecodeUint(32))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUintUint64R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint]uint64)
+ v, changed := fastpathTV.DecMapUintUint64V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUintUint64V(rv2i(rv).(map[uint]uint64), false, d)
+ v := rv.Interface().(map[uint]uint64)
+ fastpathTV.DecMapUintUint64V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUintUint64X(vp *map[uint]uint64, d *Decoder) {
- v, changed := f.DecMapUintUint64V(*vp, true, d)
+func (f fastpathT) DecMapUintUint64X(vp *map[uint]uint64, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUintUint64V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUintUint64V(v map[uint]uint64, canChange bool,
+func (_ fastpathT) DecMapUintUint64V(v map[uint]uint64, checkNil bool, canChange bool,
d *Decoder) (_ map[uint]uint64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16)
v = make(map[uint]uint64, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint(dd.DecodeUint(uintBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeUint(64)
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeUint64()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint(dd.DecodeUint(uintBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeUint(64)
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUintUintptrR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint]uintptr)
+ v, changed := fastpathTV.DecMapUintUintptrV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUintUintptrV(rv2i(rv).(map[uint]uintptr), false, d)
+ v := rv.Interface().(map[uint]uintptr)
+ fastpathTV.DecMapUintUintptrV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUintUintptrX(vp *map[uint]uintptr, d *Decoder) {
- v, changed := f.DecMapUintUintptrV(*vp, true, d)
+func (f fastpathT) DecMapUintUintptrX(vp *map[uint]uintptr, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUintUintptrV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUintUintptrV(v map[uint]uintptr, canChange bool,
+func (_ fastpathT) DecMapUintUintptrV(v map[uint]uintptr, checkNil bool, canChange bool,
d *Decoder) (_ map[uint]uintptr, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16)
v = make(map[uint]uintptr, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint(dd.DecodeUint(uintBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uintptr(dd.DecodeUint(uintBitsize))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint(dd.DecodeUint(uintBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uintptr(dd.DecodeUint(uintBitsize))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUintIntR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint]int)
+ v, changed := fastpathTV.DecMapUintIntV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUintIntV(rv2i(rv).(map[uint]int), false, d)
+ v := rv.Interface().(map[uint]int)
+ fastpathTV.DecMapUintIntV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUintIntX(vp *map[uint]int, d *Decoder) {
- v, changed := f.DecMapUintIntV(*vp, true, d)
+func (f fastpathT) DecMapUintIntX(vp *map[uint]int, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUintIntV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUintIntV(v map[uint]int, canChange bool,
+func (_ fastpathT) DecMapUintIntV(v map[uint]int, checkNil bool, canChange bool,
d *Decoder) (_ map[uint]int, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16)
v = make(map[uint]int, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint(dd.DecodeUint(uintBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int(dd.DecodeInt(intBitsize))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint(dd.DecodeUint(uintBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int(dd.DecodeInt(intBitsize))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUintInt8R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint]int8)
+ v, changed := fastpathTV.DecMapUintInt8V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUintInt8V(rv2i(rv).(map[uint]int8), false, d)
+ v := rv.Interface().(map[uint]int8)
+ fastpathTV.DecMapUintInt8V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUintInt8X(vp *map[uint]int8, d *Decoder) {
- v, changed := f.DecMapUintInt8V(*vp, true, d)
+func (f fastpathT) DecMapUintInt8X(vp *map[uint]int8, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUintInt8V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUintInt8V(v map[uint]int8, canChange bool,
+func (_ fastpathT) DecMapUintInt8V(v map[uint]int8, checkNil bool, canChange bool,
d *Decoder) (_ map[uint]int8, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9)
v = make(map[uint]int8, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint(dd.DecodeUint(uintBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int8(dd.DecodeInt(8))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = int8(chkOvf.IntV(dd.DecodeInt64(), 8))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint(dd.DecodeUint(uintBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int8(dd.DecodeInt(8))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUintInt16R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint]int16)
+ v, changed := fastpathTV.DecMapUintInt16V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUintInt16V(rv2i(rv).(map[uint]int16), false, d)
+ v := rv.Interface().(map[uint]int16)
+ fastpathTV.DecMapUintInt16V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUintInt16X(vp *map[uint]int16, d *Decoder) {
- v, changed := f.DecMapUintInt16V(*vp, true, d)
+func (f fastpathT) DecMapUintInt16X(vp *map[uint]int16, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUintInt16V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUintInt16V(v map[uint]int16, canChange bool,
+func (_ fastpathT) DecMapUintInt16V(v map[uint]int16, checkNil bool, canChange bool,
d *Decoder) (_ map[uint]int16, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 10)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 10)
v = make(map[uint]int16, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint(dd.DecodeUint(uintBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int16(dd.DecodeInt(16))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = int16(chkOvf.IntV(dd.DecodeInt64(), 16))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint(dd.DecodeUint(uintBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int16(dd.DecodeInt(16))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUintInt32R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint]int32)
+ v, changed := fastpathTV.DecMapUintInt32V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUintInt32V(rv2i(rv).(map[uint]int32), false, d)
+ v := rv.Interface().(map[uint]int32)
+ fastpathTV.DecMapUintInt32V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUintInt32X(vp *map[uint]int32, d *Decoder) {
- v, changed := f.DecMapUintInt32V(*vp, true, d)
+func (f fastpathT) DecMapUintInt32X(vp *map[uint]int32, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUintInt32V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUintInt32V(v map[uint]int32, canChange bool,
+func (_ fastpathT) DecMapUintInt32V(v map[uint]int32, checkNil bool, canChange bool,
d *Decoder) (_ map[uint]int32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12)
v = make(map[uint]int32, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint(dd.DecodeUint(uintBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int32(dd.DecodeInt(32))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = int32(chkOvf.IntV(dd.DecodeInt64(), 32))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint(dd.DecodeUint(uintBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int32(dd.DecodeInt(32))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUintInt64R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint]int64)
+ v, changed := fastpathTV.DecMapUintInt64V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUintInt64V(rv2i(rv).(map[uint]int64), false, d)
+ v := rv.Interface().(map[uint]int64)
+ fastpathTV.DecMapUintInt64V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUintInt64X(vp *map[uint]int64, d *Decoder) {
- v, changed := f.DecMapUintInt64V(*vp, true, d)
+func (f fastpathT) DecMapUintInt64X(vp *map[uint]int64, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUintInt64V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUintInt64V(v map[uint]int64, canChange bool,
+func (_ fastpathT) DecMapUintInt64V(v map[uint]int64, checkNil bool, canChange bool,
d *Decoder) (_ map[uint]int64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16)
v = make(map[uint]int64, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint(dd.DecodeUint(uintBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeInt(64)
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeInt64()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint(dd.DecodeUint(uintBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeInt(64)
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUintFloat32R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint]float32)
+ v, changed := fastpathTV.DecMapUintFloat32V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUintFloat32V(rv2i(rv).(map[uint]float32), false, d)
+ v := rv.Interface().(map[uint]float32)
+ fastpathTV.DecMapUintFloat32V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUintFloat32X(vp *map[uint]float32, d *Decoder) {
- v, changed := f.DecMapUintFloat32V(*vp, true, d)
+func (f fastpathT) DecMapUintFloat32X(vp *map[uint]float32, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUintFloat32V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUintFloat32V(v map[uint]float32, canChange bool,
+func (_ fastpathT) DecMapUintFloat32V(v map[uint]float32, checkNil bool, canChange bool,
d *Decoder) (_ map[uint]float32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12)
v = make(map[uint]float32, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint(dd.DecodeUint(uintBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = float32(dd.DecodeFloat(true))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = float32(chkOvf.Float32V(dd.DecodeFloat64()))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint(dd.DecodeUint(uintBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = float32(dd.DecodeFloat(true))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUintFloat64R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint]float64)
+ v, changed := fastpathTV.DecMapUintFloat64V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUintFloat64V(rv2i(rv).(map[uint]float64), false, d)
+ v := rv.Interface().(map[uint]float64)
+ fastpathTV.DecMapUintFloat64V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUintFloat64X(vp *map[uint]float64, d *Decoder) {
- v, changed := f.DecMapUintFloat64V(*vp, true, d)
+func (f fastpathT) DecMapUintFloat64X(vp *map[uint]float64, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUintFloat64V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUintFloat64V(v map[uint]float64, canChange bool,
+func (_ fastpathT) DecMapUintFloat64V(v map[uint]float64, checkNil bool, canChange bool,
d *Decoder) (_ map[uint]float64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16)
v = make(map[uint]float64, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint(dd.DecodeUint(uintBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeFloat(false)
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeFloat64()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint(dd.DecodeUint(uintBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeFloat(false)
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUintBoolR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint]bool)
+ v, changed := fastpathTV.DecMapUintBoolV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUintBoolV(rv2i(rv).(map[uint]bool), false, d)
+ v := rv.Interface().(map[uint]bool)
+ fastpathTV.DecMapUintBoolV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUintBoolX(vp *map[uint]bool, d *Decoder) {
- v, changed := f.DecMapUintBoolV(*vp, true, d)
+func (f fastpathT) DecMapUintBoolX(vp *map[uint]bool, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUintBoolV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUintBoolV(v map[uint]bool, canChange bool,
+func (_ fastpathT) DecMapUintBoolV(v map[uint]bool, checkNil bool, canChange bool,
d *Decoder) (_ map[uint]bool, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9)
v = make(map[uint]bool, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint(dd.DecodeUint(uintBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeBool()
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeBool()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint(dd.DecodeUint(uintBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeBool()
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUint8IntfR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint8]interface{})
+ v, changed := fastpathTV.DecMapUint8IntfV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUint8IntfV(rv2i(rv).(map[uint8]interface{}), false, d)
+ v := rv.Interface().(map[uint8]interface{})
+ fastpathTV.DecMapUint8IntfV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUint8IntfX(vp *map[uint8]interface{}, d *Decoder) {
- v, changed := f.DecMapUint8IntfV(*vp, true, d)
+func (f fastpathT) DecMapUint8IntfX(vp *map[uint8]interface{}, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUint8IntfV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUint8IntfV(v map[uint8]interface{}, canChange bool,
+func (_ fastpathT) DecMapUint8IntfV(v map[uint8]interface{}, checkNil bool, canChange bool,
d *Decoder) (_ map[uint8]interface{}, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 17)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 17)
v = make(map[uint8]interface{}, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset
+ mapGet := !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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint8(dd.DecodeUint(8))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ if mapGet {
+ mv = v[mk]
+ } else {
+ mv = nil
+ }
+ d.decode(&mv)
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- if mapGet {
- mv = v[mk]
- } else {
- mv = nil
- }
- d.decode(&mv)
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint8(dd.DecodeUint(8))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ if mapGet {
+ mv = v[mk]
+ } else {
+ mv = nil
+ }
+ d.decode(&mv)
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUint8StringR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint8]string)
+ v, changed := fastpathTV.DecMapUint8StringV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUint8StringV(rv2i(rv).(map[uint8]string), false, d)
+ v := rv.Interface().(map[uint8]string)
+ fastpathTV.DecMapUint8StringV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUint8StringX(vp *map[uint8]string, d *Decoder) {
- v, changed := f.DecMapUint8StringV(*vp, true, d)
+func (f fastpathT) DecMapUint8StringX(vp *map[uint8]string, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUint8StringV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUint8StringV(v map[uint8]string, canChange bool,
+func (_ fastpathT) DecMapUint8StringV(v map[uint8]string, checkNil bool, canChange bool,
d *Decoder) (_ map[uint8]string, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 17)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 17)
v = make(map[uint8]string, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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] = ""
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint8(dd.DecodeUint(8))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeString()
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeString()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint8(dd.DecodeUint(8))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeString()
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUint8UintR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint8]uint)
+ v, changed := fastpathTV.DecMapUint8UintV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUint8UintV(rv2i(rv).(map[uint8]uint), false, d)
+ v := rv.Interface().(map[uint8]uint)
+ fastpathTV.DecMapUint8UintV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUint8UintX(vp *map[uint8]uint, d *Decoder) {
- v, changed := f.DecMapUint8UintV(*vp, true, d)
+func (f fastpathT) DecMapUint8UintX(vp *map[uint8]uint, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUint8UintV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUint8UintV(v map[uint8]uint, canChange bool,
+func (_ fastpathT) DecMapUint8UintV(v map[uint8]uint, checkNil bool, canChange bool,
d *Decoder) (_ map[uint8]uint, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9)
v = make(map[uint8]uint, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint8(dd.DecodeUint(8))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint(dd.DecodeUint(uintBitsize))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint8(dd.DecodeUint(8))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint(dd.DecodeUint(uintBitsize))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUint8Uint8R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint8]uint8)
+ v, changed := fastpathTV.DecMapUint8Uint8V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUint8Uint8V(rv2i(rv).(map[uint8]uint8), false, d)
+ v := rv.Interface().(map[uint8]uint8)
+ fastpathTV.DecMapUint8Uint8V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUint8Uint8X(vp *map[uint8]uint8, d *Decoder) {
- v, changed := f.DecMapUint8Uint8V(*vp, true, d)
+func (f fastpathT) DecMapUint8Uint8X(vp *map[uint8]uint8, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUint8Uint8V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUint8Uint8V(v map[uint8]uint8, canChange bool,
+func (_ fastpathT) DecMapUint8Uint8V(v map[uint8]uint8, checkNil bool, canChange bool,
d *Decoder) (_ map[uint8]uint8, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 2)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 2)
v = make(map[uint8]uint8, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint8(dd.DecodeUint(8))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint8(dd.DecodeUint(8))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uint8(chkOvf.UintV(dd.DecodeUint64(), 8))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint8(dd.DecodeUint(8))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint8(dd.DecodeUint(8))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUint8Uint16R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint8]uint16)
+ v, changed := fastpathTV.DecMapUint8Uint16V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUint8Uint16V(rv2i(rv).(map[uint8]uint16), false, d)
+ v := rv.Interface().(map[uint8]uint16)
+ fastpathTV.DecMapUint8Uint16V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUint8Uint16X(vp *map[uint8]uint16, d *Decoder) {
- v, changed := f.DecMapUint8Uint16V(*vp, true, d)
+func (f fastpathT) DecMapUint8Uint16X(vp *map[uint8]uint16, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUint8Uint16V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUint8Uint16V(v map[uint8]uint16, canChange bool,
+func (_ fastpathT) DecMapUint8Uint16V(v map[uint8]uint16, checkNil bool, canChange bool,
d *Decoder) (_ map[uint8]uint16, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 3)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 3)
v = make(map[uint8]uint16, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint8(dd.DecodeUint(8))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint16(dd.DecodeUint(16))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uint16(chkOvf.UintV(dd.DecodeUint64(), 16))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint8(dd.DecodeUint(8))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint16(dd.DecodeUint(16))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUint8Uint32R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint8]uint32)
+ v, changed := fastpathTV.DecMapUint8Uint32V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUint8Uint32V(rv2i(rv).(map[uint8]uint32), false, d)
+ v := rv.Interface().(map[uint8]uint32)
+ fastpathTV.DecMapUint8Uint32V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUint8Uint32X(vp *map[uint8]uint32, d *Decoder) {
- v, changed := f.DecMapUint8Uint32V(*vp, true, d)
+func (f fastpathT) DecMapUint8Uint32X(vp *map[uint8]uint32, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUint8Uint32V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUint8Uint32V(v map[uint8]uint32, canChange bool,
+func (_ fastpathT) DecMapUint8Uint32V(v map[uint8]uint32, checkNil bool, canChange bool,
d *Decoder) (_ map[uint8]uint32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 5)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 5)
v = make(map[uint8]uint32, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint8(dd.DecodeUint(8))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint32(dd.DecodeUint(32))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uint32(chkOvf.UintV(dd.DecodeUint64(), 32))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint8(dd.DecodeUint(8))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint32(dd.DecodeUint(32))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUint8Uint64R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint8]uint64)
+ v, changed := fastpathTV.DecMapUint8Uint64V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUint8Uint64V(rv2i(rv).(map[uint8]uint64), false, d)
+ v := rv.Interface().(map[uint8]uint64)
+ fastpathTV.DecMapUint8Uint64V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUint8Uint64X(vp *map[uint8]uint64, d *Decoder) {
- v, changed := f.DecMapUint8Uint64V(*vp, true, d)
+func (f fastpathT) DecMapUint8Uint64X(vp *map[uint8]uint64, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUint8Uint64V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUint8Uint64V(v map[uint8]uint64, canChange bool,
+func (_ fastpathT) DecMapUint8Uint64V(v map[uint8]uint64, checkNil bool, canChange bool,
d *Decoder) (_ map[uint8]uint64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9)
v = make(map[uint8]uint64, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint8(dd.DecodeUint(8))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeUint(64)
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeUint64()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint8(dd.DecodeUint(8))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeUint(64)
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUint8UintptrR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint8]uintptr)
+ v, changed := fastpathTV.DecMapUint8UintptrV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUint8UintptrV(rv2i(rv).(map[uint8]uintptr), false, d)
+ v := rv.Interface().(map[uint8]uintptr)
+ fastpathTV.DecMapUint8UintptrV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUint8UintptrX(vp *map[uint8]uintptr, d *Decoder) {
- v, changed := f.DecMapUint8UintptrV(*vp, true, d)
+func (f fastpathT) DecMapUint8UintptrX(vp *map[uint8]uintptr, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUint8UintptrV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUint8UintptrV(v map[uint8]uintptr, canChange bool,
+func (_ fastpathT) DecMapUint8UintptrV(v map[uint8]uintptr, checkNil bool, canChange bool,
d *Decoder) (_ map[uint8]uintptr, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9)
v = make(map[uint8]uintptr, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint8(dd.DecodeUint(8))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uintptr(dd.DecodeUint(uintBitsize))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint8(dd.DecodeUint(8))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uintptr(dd.DecodeUint(uintBitsize))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUint8IntR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint8]int)
+ v, changed := fastpathTV.DecMapUint8IntV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUint8IntV(rv2i(rv).(map[uint8]int), false, d)
+ v := rv.Interface().(map[uint8]int)
+ fastpathTV.DecMapUint8IntV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUint8IntX(vp *map[uint8]int, d *Decoder) {
- v, changed := f.DecMapUint8IntV(*vp, true, d)
+func (f fastpathT) DecMapUint8IntX(vp *map[uint8]int, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUint8IntV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUint8IntV(v map[uint8]int, canChange bool,
+func (_ fastpathT) DecMapUint8IntV(v map[uint8]int, checkNil bool, canChange bool,
d *Decoder) (_ map[uint8]int, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9)
v = make(map[uint8]int, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint8(dd.DecodeUint(8))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int(dd.DecodeInt(intBitsize))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint8(dd.DecodeUint(8))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int(dd.DecodeInt(intBitsize))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUint8Int8R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint8]int8)
+ v, changed := fastpathTV.DecMapUint8Int8V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUint8Int8V(rv2i(rv).(map[uint8]int8), false, d)
+ v := rv.Interface().(map[uint8]int8)
+ fastpathTV.DecMapUint8Int8V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUint8Int8X(vp *map[uint8]int8, d *Decoder) {
- v, changed := f.DecMapUint8Int8V(*vp, true, d)
+func (f fastpathT) DecMapUint8Int8X(vp *map[uint8]int8, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUint8Int8V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUint8Int8V(v map[uint8]int8, canChange bool,
+func (_ fastpathT) DecMapUint8Int8V(v map[uint8]int8, checkNil bool, canChange bool,
d *Decoder) (_ map[uint8]int8, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 2)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 2)
v = make(map[uint8]int8, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint8(dd.DecodeUint(8))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int8(dd.DecodeInt(8))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = int8(chkOvf.IntV(dd.DecodeInt64(), 8))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint8(dd.DecodeUint(8))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int8(dd.DecodeInt(8))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUint8Int16R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint8]int16)
+ v, changed := fastpathTV.DecMapUint8Int16V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUint8Int16V(rv2i(rv).(map[uint8]int16), false, d)
+ v := rv.Interface().(map[uint8]int16)
+ fastpathTV.DecMapUint8Int16V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUint8Int16X(vp *map[uint8]int16, d *Decoder) {
- v, changed := f.DecMapUint8Int16V(*vp, true, d)
+func (f fastpathT) DecMapUint8Int16X(vp *map[uint8]int16, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUint8Int16V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUint8Int16V(v map[uint8]int16, canChange bool,
+func (_ fastpathT) DecMapUint8Int16V(v map[uint8]int16, checkNil bool, canChange bool,
d *Decoder) (_ map[uint8]int16, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 3)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 3)
v = make(map[uint8]int16, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint8(dd.DecodeUint(8))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int16(dd.DecodeInt(16))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = int16(chkOvf.IntV(dd.DecodeInt64(), 16))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint8(dd.DecodeUint(8))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int16(dd.DecodeInt(16))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUint8Int32R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint8]int32)
+ v, changed := fastpathTV.DecMapUint8Int32V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUint8Int32V(rv2i(rv).(map[uint8]int32), false, d)
+ v := rv.Interface().(map[uint8]int32)
+ fastpathTV.DecMapUint8Int32V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUint8Int32X(vp *map[uint8]int32, d *Decoder) {
- v, changed := f.DecMapUint8Int32V(*vp, true, d)
+func (f fastpathT) DecMapUint8Int32X(vp *map[uint8]int32, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUint8Int32V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUint8Int32V(v map[uint8]int32, canChange bool,
+func (_ fastpathT) DecMapUint8Int32V(v map[uint8]int32, checkNil bool, canChange bool,
d *Decoder) (_ map[uint8]int32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 5)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 5)
v = make(map[uint8]int32, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint8(dd.DecodeUint(8))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int32(dd.DecodeInt(32))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = int32(chkOvf.IntV(dd.DecodeInt64(), 32))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint8(dd.DecodeUint(8))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int32(dd.DecodeInt(32))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUint8Int64R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint8]int64)
+ v, changed := fastpathTV.DecMapUint8Int64V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUint8Int64V(rv2i(rv).(map[uint8]int64), false, d)
+ v := rv.Interface().(map[uint8]int64)
+ fastpathTV.DecMapUint8Int64V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUint8Int64X(vp *map[uint8]int64, d *Decoder) {
- v, changed := f.DecMapUint8Int64V(*vp, true, d)
+func (f fastpathT) DecMapUint8Int64X(vp *map[uint8]int64, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUint8Int64V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUint8Int64V(v map[uint8]int64, canChange bool,
+func (_ fastpathT) DecMapUint8Int64V(v map[uint8]int64, checkNil bool, canChange bool,
d *Decoder) (_ map[uint8]int64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9)
v = make(map[uint8]int64, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint8(dd.DecodeUint(8))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeInt(64)
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeInt64()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint8(dd.DecodeUint(8))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeInt(64)
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUint8Float32R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint8]float32)
+ v, changed := fastpathTV.DecMapUint8Float32V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUint8Float32V(rv2i(rv).(map[uint8]float32), false, d)
+ v := rv.Interface().(map[uint8]float32)
+ fastpathTV.DecMapUint8Float32V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUint8Float32X(vp *map[uint8]float32, d *Decoder) {
- v, changed := f.DecMapUint8Float32V(*vp, true, d)
+func (f fastpathT) DecMapUint8Float32X(vp *map[uint8]float32, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUint8Float32V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUint8Float32V(v map[uint8]float32, canChange bool,
+func (_ fastpathT) DecMapUint8Float32V(v map[uint8]float32, checkNil bool, canChange bool,
d *Decoder) (_ map[uint8]float32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 5)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 5)
v = make(map[uint8]float32, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint8(dd.DecodeUint(8))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = float32(dd.DecodeFloat(true))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = float32(chkOvf.Float32V(dd.DecodeFloat64()))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint8(dd.DecodeUint(8))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = float32(dd.DecodeFloat(true))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUint8Float64R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint8]float64)
+ v, changed := fastpathTV.DecMapUint8Float64V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUint8Float64V(rv2i(rv).(map[uint8]float64), false, d)
+ v := rv.Interface().(map[uint8]float64)
+ fastpathTV.DecMapUint8Float64V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUint8Float64X(vp *map[uint8]float64, d *Decoder) {
- v, changed := f.DecMapUint8Float64V(*vp, true, d)
+func (f fastpathT) DecMapUint8Float64X(vp *map[uint8]float64, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUint8Float64V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUint8Float64V(v map[uint8]float64, canChange bool,
+func (_ fastpathT) DecMapUint8Float64V(v map[uint8]float64, checkNil bool, canChange bool,
d *Decoder) (_ map[uint8]float64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9)
v = make(map[uint8]float64, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint8(dd.DecodeUint(8))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeFloat(false)
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeFloat64()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint8(dd.DecodeUint(8))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeFloat(false)
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUint8BoolR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint8]bool)
+ v, changed := fastpathTV.DecMapUint8BoolV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUint8BoolV(rv2i(rv).(map[uint8]bool), false, d)
+ v := rv.Interface().(map[uint8]bool)
+ fastpathTV.DecMapUint8BoolV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUint8BoolX(vp *map[uint8]bool, d *Decoder) {
- v, changed := f.DecMapUint8BoolV(*vp, true, d)
+func (f fastpathT) DecMapUint8BoolX(vp *map[uint8]bool, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUint8BoolV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUint8BoolV(v map[uint8]bool, canChange bool,
+func (_ fastpathT) DecMapUint8BoolV(v map[uint8]bool, checkNil bool, canChange bool,
d *Decoder) (_ map[uint8]bool, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 2)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 2)
v = make(map[uint8]bool, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint8(dd.DecodeUint(8))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeBool()
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeBool()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint8(dd.DecodeUint(8))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeBool()
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUint16IntfR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint16]interface{})
+ v, changed := fastpathTV.DecMapUint16IntfV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUint16IntfV(rv2i(rv).(map[uint16]interface{}), false, d)
+ v := rv.Interface().(map[uint16]interface{})
+ fastpathTV.DecMapUint16IntfV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUint16IntfX(vp *map[uint16]interface{}, d *Decoder) {
- v, changed := f.DecMapUint16IntfV(*vp, true, d)
+func (f fastpathT) DecMapUint16IntfX(vp *map[uint16]interface{}, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUint16IntfV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUint16IntfV(v map[uint16]interface{}, canChange bool,
+func (_ fastpathT) DecMapUint16IntfV(v map[uint16]interface{}, checkNil bool, canChange bool,
d *Decoder) (_ map[uint16]interface{}, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 18)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 18)
v = make(map[uint16]interface{}, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset
+ mapGet := !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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint16(dd.DecodeUint(16))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ if mapGet {
+ mv = v[mk]
+ } else {
+ mv = nil
+ }
+ d.decode(&mv)
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- if mapGet {
- mv = v[mk]
- } else {
- mv = nil
- }
- d.decode(&mv)
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint16(dd.DecodeUint(16))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ if mapGet {
+ mv = v[mk]
+ } else {
+ mv = nil
+ }
+ d.decode(&mv)
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUint16StringR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint16]string)
+ v, changed := fastpathTV.DecMapUint16StringV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUint16StringV(rv2i(rv).(map[uint16]string), false, d)
+ v := rv.Interface().(map[uint16]string)
+ fastpathTV.DecMapUint16StringV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUint16StringX(vp *map[uint16]string, d *Decoder) {
- v, changed := f.DecMapUint16StringV(*vp, true, d)
+func (f fastpathT) DecMapUint16StringX(vp *map[uint16]string, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUint16StringV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUint16StringV(v map[uint16]string, canChange bool,
+func (_ fastpathT) DecMapUint16StringV(v map[uint16]string, checkNil bool, canChange bool,
d *Decoder) (_ map[uint16]string, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 18)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 18)
v = make(map[uint16]string, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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] = ""
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint16(dd.DecodeUint(16))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeString()
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeString()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint16(dd.DecodeUint(16))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeString()
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUint16UintR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint16]uint)
+ v, changed := fastpathTV.DecMapUint16UintV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUint16UintV(rv2i(rv).(map[uint16]uint), false, d)
+ v := rv.Interface().(map[uint16]uint)
+ fastpathTV.DecMapUint16UintV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUint16UintX(vp *map[uint16]uint, d *Decoder) {
- v, changed := f.DecMapUint16UintV(*vp, true, d)
+func (f fastpathT) DecMapUint16UintX(vp *map[uint16]uint, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUint16UintV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUint16UintV(v map[uint16]uint, canChange bool,
+func (_ fastpathT) DecMapUint16UintV(v map[uint16]uint, checkNil bool, canChange bool,
d *Decoder) (_ map[uint16]uint, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 10)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 10)
v = make(map[uint16]uint, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint16(dd.DecodeUint(16))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint(dd.DecodeUint(uintBitsize))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint16(dd.DecodeUint(16))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint(dd.DecodeUint(uintBitsize))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUint16Uint8R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint16]uint8)
+ v, changed := fastpathTV.DecMapUint16Uint8V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUint16Uint8V(rv2i(rv).(map[uint16]uint8), false, d)
+ v := rv.Interface().(map[uint16]uint8)
+ fastpathTV.DecMapUint16Uint8V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUint16Uint8X(vp *map[uint16]uint8, d *Decoder) {
- v, changed := f.DecMapUint16Uint8V(*vp, true, d)
+func (f fastpathT) DecMapUint16Uint8X(vp *map[uint16]uint8, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUint16Uint8V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUint16Uint8V(v map[uint16]uint8, canChange bool,
+func (_ fastpathT) DecMapUint16Uint8V(v map[uint16]uint8, checkNil bool, canChange bool,
d *Decoder) (_ map[uint16]uint8, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 3)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 3)
v = make(map[uint16]uint8, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint16(dd.DecodeUint(16))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint8(dd.DecodeUint(8))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uint8(chkOvf.UintV(dd.DecodeUint64(), 8))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint16(dd.DecodeUint(16))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint8(dd.DecodeUint(8))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUint16Uint16R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint16]uint16)
+ v, changed := fastpathTV.DecMapUint16Uint16V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUint16Uint16V(rv2i(rv).(map[uint16]uint16), false, d)
+ v := rv.Interface().(map[uint16]uint16)
+ fastpathTV.DecMapUint16Uint16V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUint16Uint16X(vp *map[uint16]uint16, d *Decoder) {
- v, changed := f.DecMapUint16Uint16V(*vp, true, d)
+func (f fastpathT) DecMapUint16Uint16X(vp *map[uint16]uint16, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUint16Uint16V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUint16Uint16V(v map[uint16]uint16, canChange bool,
+func (_ fastpathT) DecMapUint16Uint16V(v map[uint16]uint16, checkNil bool, canChange bool,
d *Decoder) (_ map[uint16]uint16, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 4)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 4)
v = make(map[uint16]uint16, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint16(dd.DecodeUint(16))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint16(dd.DecodeUint(16))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uint16(chkOvf.UintV(dd.DecodeUint64(), 16))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint16(dd.DecodeUint(16))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint16(dd.DecodeUint(16))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUint16Uint32R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint16]uint32)
+ v, changed := fastpathTV.DecMapUint16Uint32V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUint16Uint32V(rv2i(rv).(map[uint16]uint32), false, d)
+ v := rv.Interface().(map[uint16]uint32)
+ fastpathTV.DecMapUint16Uint32V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUint16Uint32X(vp *map[uint16]uint32, d *Decoder) {
- v, changed := f.DecMapUint16Uint32V(*vp, true, d)
+func (f fastpathT) DecMapUint16Uint32X(vp *map[uint16]uint32, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUint16Uint32V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUint16Uint32V(v map[uint16]uint32, canChange bool,
+func (_ fastpathT) DecMapUint16Uint32V(v map[uint16]uint32, checkNil bool, canChange bool,
d *Decoder) (_ map[uint16]uint32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 6)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 6)
v = make(map[uint16]uint32, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint16(dd.DecodeUint(16))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint32(dd.DecodeUint(32))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uint32(chkOvf.UintV(dd.DecodeUint64(), 32))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint16(dd.DecodeUint(16))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint32(dd.DecodeUint(32))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUint16Uint64R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint16]uint64)
+ v, changed := fastpathTV.DecMapUint16Uint64V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUint16Uint64V(rv2i(rv).(map[uint16]uint64), false, d)
+ v := rv.Interface().(map[uint16]uint64)
+ fastpathTV.DecMapUint16Uint64V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUint16Uint64X(vp *map[uint16]uint64, d *Decoder) {
- v, changed := f.DecMapUint16Uint64V(*vp, true, d)
+func (f fastpathT) DecMapUint16Uint64X(vp *map[uint16]uint64, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUint16Uint64V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUint16Uint64V(v map[uint16]uint64, canChange bool,
+func (_ fastpathT) DecMapUint16Uint64V(v map[uint16]uint64, checkNil bool, canChange bool,
d *Decoder) (_ map[uint16]uint64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 10)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 10)
v = make(map[uint16]uint64, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint16(dd.DecodeUint(16))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeUint(64)
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeUint64()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint16(dd.DecodeUint(16))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeUint(64)
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUint16UintptrR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint16]uintptr)
+ v, changed := fastpathTV.DecMapUint16UintptrV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUint16UintptrV(rv2i(rv).(map[uint16]uintptr), false, d)
+ v := rv.Interface().(map[uint16]uintptr)
+ fastpathTV.DecMapUint16UintptrV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUint16UintptrX(vp *map[uint16]uintptr, d *Decoder) {
- v, changed := f.DecMapUint16UintptrV(*vp, true, d)
+func (f fastpathT) DecMapUint16UintptrX(vp *map[uint16]uintptr, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUint16UintptrV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUint16UintptrV(v map[uint16]uintptr, canChange bool,
+func (_ fastpathT) DecMapUint16UintptrV(v map[uint16]uintptr, checkNil bool, canChange bool,
d *Decoder) (_ map[uint16]uintptr, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 10)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 10)
v = make(map[uint16]uintptr, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint16(dd.DecodeUint(16))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uintptr(dd.DecodeUint(uintBitsize))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint16(dd.DecodeUint(16))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uintptr(dd.DecodeUint(uintBitsize))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUint16IntR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint16]int)
+ v, changed := fastpathTV.DecMapUint16IntV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUint16IntV(rv2i(rv).(map[uint16]int), false, d)
+ v := rv.Interface().(map[uint16]int)
+ fastpathTV.DecMapUint16IntV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUint16IntX(vp *map[uint16]int, d *Decoder) {
- v, changed := f.DecMapUint16IntV(*vp, true, d)
+func (f fastpathT) DecMapUint16IntX(vp *map[uint16]int, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUint16IntV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUint16IntV(v map[uint16]int, canChange bool,
+func (_ fastpathT) DecMapUint16IntV(v map[uint16]int, checkNil bool, canChange bool,
d *Decoder) (_ map[uint16]int, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 10)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 10)
v = make(map[uint16]int, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint16(dd.DecodeUint(16))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int(dd.DecodeInt(intBitsize))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint16(dd.DecodeUint(16))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int(dd.DecodeInt(intBitsize))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUint16Int8R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint16]int8)
+ v, changed := fastpathTV.DecMapUint16Int8V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUint16Int8V(rv2i(rv).(map[uint16]int8), false, d)
+ v := rv.Interface().(map[uint16]int8)
+ fastpathTV.DecMapUint16Int8V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUint16Int8X(vp *map[uint16]int8, d *Decoder) {
- v, changed := f.DecMapUint16Int8V(*vp, true, d)
+func (f fastpathT) DecMapUint16Int8X(vp *map[uint16]int8, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUint16Int8V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUint16Int8V(v map[uint16]int8, canChange bool,
+func (_ fastpathT) DecMapUint16Int8V(v map[uint16]int8, checkNil bool, canChange bool,
d *Decoder) (_ map[uint16]int8, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 3)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 3)
v = make(map[uint16]int8, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint16(dd.DecodeUint(16))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int8(dd.DecodeInt(8))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = int8(chkOvf.IntV(dd.DecodeInt64(), 8))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint16(dd.DecodeUint(16))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int8(dd.DecodeInt(8))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUint16Int16R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint16]int16)
+ v, changed := fastpathTV.DecMapUint16Int16V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUint16Int16V(rv2i(rv).(map[uint16]int16), false, d)
+ v := rv.Interface().(map[uint16]int16)
+ fastpathTV.DecMapUint16Int16V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUint16Int16X(vp *map[uint16]int16, d *Decoder) {
- v, changed := f.DecMapUint16Int16V(*vp, true, d)
+func (f fastpathT) DecMapUint16Int16X(vp *map[uint16]int16, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUint16Int16V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUint16Int16V(v map[uint16]int16, canChange bool,
+func (_ fastpathT) DecMapUint16Int16V(v map[uint16]int16, checkNil bool, canChange bool,
d *Decoder) (_ map[uint16]int16, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 4)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 4)
v = make(map[uint16]int16, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint16(dd.DecodeUint(16))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int16(dd.DecodeInt(16))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = int16(chkOvf.IntV(dd.DecodeInt64(), 16))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint16(dd.DecodeUint(16))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int16(dd.DecodeInt(16))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUint16Int32R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint16]int32)
+ v, changed := fastpathTV.DecMapUint16Int32V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUint16Int32V(rv2i(rv).(map[uint16]int32), false, d)
+ v := rv.Interface().(map[uint16]int32)
+ fastpathTV.DecMapUint16Int32V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUint16Int32X(vp *map[uint16]int32, d *Decoder) {
- v, changed := f.DecMapUint16Int32V(*vp, true, d)
+func (f fastpathT) DecMapUint16Int32X(vp *map[uint16]int32, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUint16Int32V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUint16Int32V(v map[uint16]int32, canChange bool,
+func (_ fastpathT) DecMapUint16Int32V(v map[uint16]int32, checkNil bool, canChange bool,
d *Decoder) (_ map[uint16]int32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 6)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 6)
v = make(map[uint16]int32, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint16(dd.DecodeUint(16))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int32(dd.DecodeInt(32))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = int32(chkOvf.IntV(dd.DecodeInt64(), 32))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint16(dd.DecodeUint(16))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int32(dd.DecodeInt(32))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUint16Int64R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint16]int64)
+ v, changed := fastpathTV.DecMapUint16Int64V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUint16Int64V(rv2i(rv).(map[uint16]int64), false, d)
+ v := rv.Interface().(map[uint16]int64)
+ fastpathTV.DecMapUint16Int64V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUint16Int64X(vp *map[uint16]int64, d *Decoder) {
- v, changed := f.DecMapUint16Int64V(*vp, true, d)
+func (f fastpathT) DecMapUint16Int64X(vp *map[uint16]int64, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUint16Int64V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUint16Int64V(v map[uint16]int64, canChange bool,
+func (_ fastpathT) DecMapUint16Int64V(v map[uint16]int64, checkNil bool, canChange bool,
d *Decoder) (_ map[uint16]int64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 10)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 10)
v = make(map[uint16]int64, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint16(dd.DecodeUint(16))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeInt(64)
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeInt64()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint16(dd.DecodeUint(16))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeInt(64)
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUint16Float32R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint16]float32)
+ v, changed := fastpathTV.DecMapUint16Float32V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUint16Float32V(rv2i(rv).(map[uint16]float32), false, d)
+ v := rv.Interface().(map[uint16]float32)
+ fastpathTV.DecMapUint16Float32V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUint16Float32X(vp *map[uint16]float32, d *Decoder) {
- v, changed := f.DecMapUint16Float32V(*vp, true, d)
+func (f fastpathT) DecMapUint16Float32X(vp *map[uint16]float32, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUint16Float32V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUint16Float32V(v map[uint16]float32, canChange bool,
+func (_ fastpathT) DecMapUint16Float32V(v map[uint16]float32, checkNil bool, canChange bool,
d *Decoder) (_ map[uint16]float32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 6)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 6)
v = make(map[uint16]float32, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint16(dd.DecodeUint(16))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = float32(dd.DecodeFloat(true))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = float32(chkOvf.Float32V(dd.DecodeFloat64()))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint16(dd.DecodeUint(16))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = float32(dd.DecodeFloat(true))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUint16Float64R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint16]float64)
+ v, changed := fastpathTV.DecMapUint16Float64V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUint16Float64V(rv2i(rv).(map[uint16]float64), false, d)
+ v := rv.Interface().(map[uint16]float64)
+ fastpathTV.DecMapUint16Float64V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUint16Float64X(vp *map[uint16]float64, d *Decoder) {
- v, changed := f.DecMapUint16Float64V(*vp, true, d)
+func (f fastpathT) DecMapUint16Float64X(vp *map[uint16]float64, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUint16Float64V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUint16Float64V(v map[uint16]float64, canChange bool,
+func (_ fastpathT) DecMapUint16Float64V(v map[uint16]float64, checkNil bool, canChange bool,
d *Decoder) (_ map[uint16]float64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 10)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 10)
v = make(map[uint16]float64, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint16(dd.DecodeUint(16))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeFloat(false)
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeFloat64()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint16(dd.DecodeUint(16))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeFloat(false)
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUint16BoolR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint16]bool)
+ v, changed := fastpathTV.DecMapUint16BoolV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUint16BoolV(rv2i(rv).(map[uint16]bool), false, d)
+ v := rv.Interface().(map[uint16]bool)
+ fastpathTV.DecMapUint16BoolV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUint16BoolX(vp *map[uint16]bool, d *Decoder) {
- v, changed := f.DecMapUint16BoolV(*vp, true, d)
+func (f fastpathT) DecMapUint16BoolX(vp *map[uint16]bool, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUint16BoolV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUint16BoolV(v map[uint16]bool, canChange bool,
+func (_ fastpathT) DecMapUint16BoolV(v map[uint16]bool, checkNil bool, canChange bool,
d *Decoder) (_ map[uint16]bool, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 3)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 3)
v = make(map[uint16]bool, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint16(dd.DecodeUint(16))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeBool()
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeBool()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint16(dd.DecodeUint(16))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeBool()
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUint32IntfR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint32]interface{})
+ v, changed := fastpathTV.DecMapUint32IntfV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUint32IntfV(rv2i(rv).(map[uint32]interface{}), false, d)
+ v := rv.Interface().(map[uint32]interface{})
+ fastpathTV.DecMapUint32IntfV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUint32IntfX(vp *map[uint32]interface{}, d *Decoder) {
- v, changed := f.DecMapUint32IntfV(*vp, true, d)
+func (f fastpathT) DecMapUint32IntfX(vp *map[uint32]interface{}, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUint32IntfV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUint32IntfV(v map[uint32]interface{}, canChange bool,
+func (_ fastpathT) DecMapUint32IntfV(v map[uint32]interface{}, checkNil bool, canChange bool,
d *Decoder) (_ map[uint32]interface{}, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 20)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 20)
v = make(map[uint32]interface{}, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset
+ mapGet := !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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint32(dd.DecodeUint(32))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ if mapGet {
+ mv = v[mk]
+ } else {
+ mv = nil
+ }
+ d.decode(&mv)
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- if mapGet {
- mv = v[mk]
- } else {
- mv = nil
- }
- d.decode(&mv)
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint32(dd.DecodeUint(32))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ if mapGet {
+ mv = v[mk]
+ } else {
+ mv = nil
+ }
+ d.decode(&mv)
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUint32StringR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint32]string)
+ v, changed := fastpathTV.DecMapUint32StringV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUint32StringV(rv2i(rv).(map[uint32]string), false, d)
+ v := rv.Interface().(map[uint32]string)
+ fastpathTV.DecMapUint32StringV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUint32StringX(vp *map[uint32]string, d *Decoder) {
- v, changed := f.DecMapUint32StringV(*vp, true, d)
+func (f fastpathT) DecMapUint32StringX(vp *map[uint32]string, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUint32StringV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUint32StringV(v map[uint32]string, canChange bool,
+func (_ fastpathT) DecMapUint32StringV(v map[uint32]string, checkNil bool, canChange bool,
d *Decoder) (_ map[uint32]string, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 20)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 20)
v = make(map[uint32]string, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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] = ""
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint32(dd.DecodeUint(32))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeString()
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeString()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint32(dd.DecodeUint(32))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeString()
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUint32UintR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint32]uint)
+ v, changed := fastpathTV.DecMapUint32UintV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUint32UintV(rv2i(rv).(map[uint32]uint), false, d)
+ v := rv.Interface().(map[uint32]uint)
+ fastpathTV.DecMapUint32UintV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUint32UintX(vp *map[uint32]uint, d *Decoder) {
- v, changed := f.DecMapUint32UintV(*vp, true, d)
+func (f fastpathT) DecMapUint32UintX(vp *map[uint32]uint, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUint32UintV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUint32UintV(v map[uint32]uint, canChange bool,
+func (_ fastpathT) DecMapUint32UintV(v map[uint32]uint, checkNil bool, canChange bool,
d *Decoder) (_ map[uint32]uint, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12)
v = make(map[uint32]uint, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint32(dd.DecodeUint(32))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint(dd.DecodeUint(uintBitsize))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint32(dd.DecodeUint(32))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint(dd.DecodeUint(uintBitsize))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUint32Uint8R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint32]uint8)
+ v, changed := fastpathTV.DecMapUint32Uint8V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUint32Uint8V(rv2i(rv).(map[uint32]uint8), false, d)
+ v := rv.Interface().(map[uint32]uint8)
+ fastpathTV.DecMapUint32Uint8V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUint32Uint8X(vp *map[uint32]uint8, d *Decoder) {
- v, changed := f.DecMapUint32Uint8V(*vp, true, d)
+func (f fastpathT) DecMapUint32Uint8X(vp *map[uint32]uint8, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUint32Uint8V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUint32Uint8V(v map[uint32]uint8, canChange bool,
+func (_ fastpathT) DecMapUint32Uint8V(v map[uint32]uint8, checkNil bool, canChange bool,
d *Decoder) (_ map[uint32]uint8, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 5)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 5)
v = make(map[uint32]uint8, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint32(dd.DecodeUint(32))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint8(dd.DecodeUint(8))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uint8(chkOvf.UintV(dd.DecodeUint64(), 8))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint32(dd.DecodeUint(32))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint8(dd.DecodeUint(8))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUint32Uint16R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint32]uint16)
+ v, changed := fastpathTV.DecMapUint32Uint16V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUint32Uint16V(rv2i(rv).(map[uint32]uint16), false, d)
+ v := rv.Interface().(map[uint32]uint16)
+ fastpathTV.DecMapUint32Uint16V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUint32Uint16X(vp *map[uint32]uint16, d *Decoder) {
- v, changed := f.DecMapUint32Uint16V(*vp, true, d)
+func (f fastpathT) DecMapUint32Uint16X(vp *map[uint32]uint16, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUint32Uint16V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUint32Uint16V(v map[uint32]uint16, canChange bool,
+func (_ fastpathT) DecMapUint32Uint16V(v map[uint32]uint16, checkNil bool, canChange bool,
d *Decoder) (_ map[uint32]uint16, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 6)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 6)
v = make(map[uint32]uint16, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint32(dd.DecodeUint(32))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint16(dd.DecodeUint(16))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uint16(chkOvf.UintV(dd.DecodeUint64(), 16))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint32(dd.DecodeUint(32))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint16(dd.DecodeUint(16))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUint32Uint32R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint32]uint32)
+ v, changed := fastpathTV.DecMapUint32Uint32V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUint32Uint32V(rv2i(rv).(map[uint32]uint32), false, d)
+ v := rv.Interface().(map[uint32]uint32)
+ fastpathTV.DecMapUint32Uint32V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUint32Uint32X(vp *map[uint32]uint32, d *Decoder) {
- v, changed := f.DecMapUint32Uint32V(*vp, true, d)
+func (f fastpathT) DecMapUint32Uint32X(vp *map[uint32]uint32, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUint32Uint32V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUint32Uint32V(v map[uint32]uint32, canChange bool,
+func (_ fastpathT) DecMapUint32Uint32V(v map[uint32]uint32, checkNil bool, canChange bool,
d *Decoder) (_ map[uint32]uint32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 8)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 8)
v = make(map[uint32]uint32, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint32(dd.DecodeUint(32))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint32(dd.DecodeUint(32))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uint32(chkOvf.UintV(dd.DecodeUint64(), 32))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint32(dd.DecodeUint(32))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint32(dd.DecodeUint(32))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUint32Uint64R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint32]uint64)
+ v, changed := fastpathTV.DecMapUint32Uint64V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUint32Uint64V(rv2i(rv).(map[uint32]uint64), false, d)
+ v := rv.Interface().(map[uint32]uint64)
+ fastpathTV.DecMapUint32Uint64V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUint32Uint64X(vp *map[uint32]uint64, d *Decoder) {
- v, changed := f.DecMapUint32Uint64V(*vp, true, d)
+func (f fastpathT) DecMapUint32Uint64X(vp *map[uint32]uint64, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUint32Uint64V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUint32Uint64V(v map[uint32]uint64, canChange bool,
+func (_ fastpathT) DecMapUint32Uint64V(v map[uint32]uint64, checkNil bool, canChange bool,
d *Decoder) (_ map[uint32]uint64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12)
v = make(map[uint32]uint64, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint32(dd.DecodeUint(32))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeUint(64)
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeUint64()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint32(dd.DecodeUint(32))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeUint(64)
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUint32UintptrR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint32]uintptr)
+ v, changed := fastpathTV.DecMapUint32UintptrV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUint32UintptrV(rv2i(rv).(map[uint32]uintptr), false, d)
+ v := rv.Interface().(map[uint32]uintptr)
+ fastpathTV.DecMapUint32UintptrV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUint32UintptrX(vp *map[uint32]uintptr, d *Decoder) {
- v, changed := f.DecMapUint32UintptrV(*vp, true, d)
+func (f fastpathT) DecMapUint32UintptrX(vp *map[uint32]uintptr, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUint32UintptrV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUint32UintptrV(v map[uint32]uintptr, canChange bool,
+func (_ fastpathT) DecMapUint32UintptrV(v map[uint32]uintptr, checkNil bool, canChange bool,
d *Decoder) (_ map[uint32]uintptr, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12)
v = make(map[uint32]uintptr, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint32(dd.DecodeUint(32))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uintptr(dd.DecodeUint(uintBitsize))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint32(dd.DecodeUint(32))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uintptr(dd.DecodeUint(uintBitsize))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUint32IntR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint32]int)
+ v, changed := fastpathTV.DecMapUint32IntV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUint32IntV(rv2i(rv).(map[uint32]int), false, d)
+ v := rv.Interface().(map[uint32]int)
+ fastpathTV.DecMapUint32IntV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUint32IntX(vp *map[uint32]int, d *Decoder) {
- v, changed := f.DecMapUint32IntV(*vp, true, d)
+func (f fastpathT) DecMapUint32IntX(vp *map[uint32]int, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUint32IntV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUint32IntV(v map[uint32]int, canChange bool,
+func (_ fastpathT) DecMapUint32IntV(v map[uint32]int, checkNil bool, canChange bool,
d *Decoder) (_ map[uint32]int, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12)
v = make(map[uint32]int, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint32(dd.DecodeUint(32))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int(dd.DecodeInt(intBitsize))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint32(dd.DecodeUint(32))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int(dd.DecodeInt(intBitsize))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUint32Int8R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint32]int8)
+ v, changed := fastpathTV.DecMapUint32Int8V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUint32Int8V(rv2i(rv).(map[uint32]int8), false, d)
+ v := rv.Interface().(map[uint32]int8)
+ fastpathTV.DecMapUint32Int8V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUint32Int8X(vp *map[uint32]int8, d *Decoder) {
- v, changed := f.DecMapUint32Int8V(*vp, true, d)
+func (f fastpathT) DecMapUint32Int8X(vp *map[uint32]int8, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUint32Int8V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUint32Int8V(v map[uint32]int8, canChange bool,
+func (_ fastpathT) DecMapUint32Int8V(v map[uint32]int8, checkNil bool, canChange bool,
d *Decoder) (_ map[uint32]int8, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 5)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 5)
v = make(map[uint32]int8, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint32(dd.DecodeUint(32))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int8(dd.DecodeInt(8))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = int8(chkOvf.IntV(dd.DecodeInt64(), 8))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint32(dd.DecodeUint(32))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int8(dd.DecodeInt(8))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUint32Int16R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint32]int16)
+ v, changed := fastpathTV.DecMapUint32Int16V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUint32Int16V(rv2i(rv).(map[uint32]int16), false, d)
+ v := rv.Interface().(map[uint32]int16)
+ fastpathTV.DecMapUint32Int16V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUint32Int16X(vp *map[uint32]int16, d *Decoder) {
- v, changed := f.DecMapUint32Int16V(*vp, true, d)
+func (f fastpathT) DecMapUint32Int16X(vp *map[uint32]int16, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUint32Int16V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUint32Int16V(v map[uint32]int16, canChange bool,
+func (_ fastpathT) DecMapUint32Int16V(v map[uint32]int16, checkNil bool, canChange bool,
d *Decoder) (_ map[uint32]int16, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 6)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 6)
v = make(map[uint32]int16, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint32(dd.DecodeUint(32))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int16(dd.DecodeInt(16))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = int16(chkOvf.IntV(dd.DecodeInt64(), 16))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint32(dd.DecodeUint(32))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int16(dd.DecodeInt(16))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUint32Int32R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint32]int32)
+ v, changed := fastpathTV.DecMapUint32Int32V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUint32Int32V(rv2i(rv).(map[uint32]int32), false, d)
+ v := rv.Interface().(map[uint32]int32)
+ fastpathTV.DecMapUint32Int32V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUint32Int32X(vp *map[uint32]int32, d *Decoder) {
- v, changed := f.DecMapUint32Int32V(*vp, true, d)
+func (f fastpathT) DecMapUint32Int32X(vp *map[uint32]int32, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUint32Int32V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUint32Int32V(v map[uint32]int32, canChange bool,
+func (_ fastpathT) DecMapUint32Int32V(v map[uint32]int32, checkNil bool, canChange bool,
d *Decoder) (_ map[uint32]int32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 8)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 8)
v = make(map[uint32]int32, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint32(dd.DecodeUint(32))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int32(dd.DecodeInt(32))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = int32(chkOvf.IntV(dd.DecodeInt64(), 32))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint32(dd.DecodeUint(32))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int32(dd.DecodeInt(32))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUint32Int64R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint32]int64)
+ v, changed := fastpathTV.DecMapUint32Int64V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUint32Int64V(rv2i(rv).(map[uint32]int64), false, d)
+ v := rv.Interface().(map[uint32]int64)
+ fastpathTV.DecMapUint32Int64V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUint32Int64X(vp *map[uint32]int64, d *Decoder) {
- v, changed := f.DecMapUint32Int64V(*vp, true, d)
+func (f fastpathT) DecMapUint32Int64X(vp *map[uint32]int64, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUint32Int64V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUint32Int64V(v map[uint32]int64, canChange bool,
+func (_ fastpathT) DecMapUint32Int64V(v map[uint32]int64, checkNil bool, canChange bool,
d *Decoder) (_ map[uint32]int64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12)
v = make(map[uint32]int64, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint32(dd.DecodeUint(32))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeInt(64)
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeInt64()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint32(dd.DecodeUint(32))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeInt(64)
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUint32Float32R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint32]float32)
+ v, changed := fastpathTV.DecMapUint32Float32V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUint32Float32V(rv2i(rv).(map[uint32]float32), false, d)
+ v := rv.Interface().(map[uint32]float32)
+ fastpathTV.DecMapUint32Float32V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUint32Float32X(vp *map[uint32]float32, d *Decoder) {
- v, changed := f.DecMapUint32Float32V(*vp, true, d)
+func (f fastpathT) DecMapUint32Float32X(vp *map[uint32]float32, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUint32Float32V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUint32Float32V(v map[uint32]float32, canChange bool,
+func (_ fastpathT) DecMapUint32Float32V(v map[uint32]float32, checkNil bool, canChange bool,
d *Decoder) (_ map[uint32]float32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 8)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 8)
v = make(map[uint32]float32, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint32(dd.DecodeUint(32))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = float32(dd.DecodeFloat(true))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = float32(chkOvf.Float32V(dd.DecodeFloat64()))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint32(dd.DecodeUint(32))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = float32(dd.DecodeFloat(true))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUint32Float64R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint32]float64)
+ v, changed := fastpathTV.DecMapUint32Float64V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUint32Float64V(rv2i(rv).(map[uint32]float64), false, d)
+ v := rv.Interface().(map[uint32]float64)
+ fastpathTV.DecMapUint32Float64V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUint32Float64X(vp *map[uint32]float64, d *Decoder) {
- v, changed := f.DecMapUint32Float64V(*vp, true, d)
+func (f fastpathT) DecMapUint32Float64X(vp *map[uint32]float64, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUint32Float64V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUint32Float64V(v map[uint32]float64, canChange bool,
+func (_ fastpathT) DecMapUint32Float64V(v map[uint32]float64, checkNil bool, canChange bool,
d *Decoder) (_ map[uint32]float64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12)
v = make(map[uint32]float64, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint32(dd.DecodeUint(32))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeFloat(false)
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeFloat64()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint32(dd.DecodeUint(32))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeFloat(false)
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUint32BoolR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint32]bool)
+ v, changed := fastpathTV.DecMapUint32BoolV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUint32BoolV(rv2i(rv).(map[uint32]bool), false, d)
+ v := rv.Interface().(map[uint32]bool)
+ fastpathTV.DecMapUint32BoolV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUint32BoolX(vp *map[uint32]bool, d *Decoder) {
- v, changed := f.DecMapUint32BoolV(*vp, true, d)
+func (f fastpathT) DecMapUint32BoolX(vp *map[uint32]bool, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUint32BoolV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUint32BoolV(v map[uint32]bool, canChange bool,
+func (_ fastpathT) DecMapUint32BoolV(v map[uint32]bool, checkNil bool, canChange bool,
d *Decoder) (_ map[uint32]bool, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 5)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 5)
v = make(map[uint32]bool, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint32(dd.DecodeUint(32))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeBool()
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeBool()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uint32(dd.DecodeUint(32))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeBool()
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUint64IntfR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint64]interface{})
+ v, changed := fastpathTV.DecMapUint64IntfV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUint64IntfV(rv2i(rv).(map[uint64]interface{}), false, d)
+ v := rv.Interface().(map[uint64]interface{})
+ fastpathTV.DecMapUint64IntfV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUint64IntfX(vp *map[uint64]interface{}, d *Decoder) {
- v, changed := f.DecMapUint64IntfV(*vp, true, d)
+func (f fastpathT) DecMapUint64IntfX(vp *map[uint64]interface{}, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUint64IntfV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUint64IntfV(v map[uint64]interface{}, canChange bool,
+func (_ fastpathT) DecMapUint64IntfV(v map[uint64]interface{}, checkNil bool, canChange bool,
d *Decoder) (_ map[uint64]interface{}, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 24)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 24)
v = make(map[uint64]interface{}, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset
+ mapGet := !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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeUint(64)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ if mapGet {
+ mv = v[mk]
+ } else {
+ mv = nil
+ }
+ d.decode(&mv)
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- if mapGet {
- mv = v[mk]
- } else {
- mv = nil
- }
- d.decode(&mv)
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeUint(64)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ if mapGet {
+ mv = v[mk]
+ } else {
+ mv = nil
+ }
+ d.decode(&mv)
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUint64StringR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint64]string)
+ v, changed := fastpathTV.DecMapUint64StringV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUint64StringV(rv2i(rv).(map[uint64]string), false, d)
+ v := rv.Interface().(map[uint64]string)
+ fastpathTV.DecMapUint64StringV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUint64StringX(vp *map[uint64]string, d *Decoder) {
- v, changed := f.DecMapUint64StringV(*vp, true, d)
+func (f fastpathT) DecMapUint64StringX(vp *map[uint64]string, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUint64StringV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUint64StringV(v map[uint64]string, canChange bool,
+func (_ fastpathT) DecMapUint64StringV(v map[uint64]string, checkNil bool, canChange bool,
d *Decoder) (_ map[uint64]string, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 24)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 24)
v = make(map[uint64]string, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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] = ""
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeUint(64)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeString()
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeString()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeUint(64)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeString()
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUint64UintR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint64]uint)
+ v, changed := fastpathTV.DecMapUint64UintV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUint64UintV(rv2i(rv).(map[uint64]uint), false, d)
+ v := rv.Interface().(map[uint64]uint)
+ fastpathTV.DecMapUint64UintV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUint64UintX(vp *map[uint64]uint, d *Decoder) {
- v, changed := f.DecMapUint64UintV(*vp, true, d)
+func (f fastpathT) DecMapUint64UintX(vp *map[uint64]uint, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUint64UintV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUint64UintV(v map[uint64]uint, canChange bool,
+func (_ fastpathT) DecMapUint64UintV(v map[uint64]uint, checkNil bool, canChange bool,
d *Decoder) (_ map[uint64]uint, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16)
v = make(map[uint64]uint, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeUint(64)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint(dd.DecodeUint(uintBitsize))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeUint(64)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint(dd.DecodeUint(uintBitsize))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUint64Uint8R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint64]uint8)
+ v, changed := fastpathTV.DecMapUint64Uint8V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUint64Uint8V(rv2i(rv).(map[uint64]uint8), false, d)
+ v := rv.Interface().(map[uint64]uint8)
+ fastpathTV.DecMapUint64Uint8V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUint64Uint8X(vp *map[uint64]uint8, d *Decoder) {
- v, changed := f.DecMapUint64Uint8V(*vp, true, d)
+func (f fastpathT) DecMapUint64Uint8X(vp *map[uint64]uint8, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUint64Uint8V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUint64Uint8V(v map[uint64]uint8, canChange bool,
+func (_ fastpathT) DecMapUint64Uint8V(v map[uint64]uint8, checkNil bool, canChange bool,
d *Decoder) (_ map[uint64]uint8, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9)
v = make(map[uint64]uint8, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeUint(64)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint8(dd.DecodeUint(8))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uint8(chkOvf.UintV(dd.DecodeUint64(), 8))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeUint(64)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint8(dd.DecodeUint(8))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUint64Uint16R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint64]uint16)
+ v, changed := fastpathTV.DecMapUint64Uint16V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUint64Uint16V(rv2i(rv).(map[uint64]uint16), false, d)
+ v := rv.Interface().(map[uint64]uint16)
+ fastpathTV.DecMapUint64Uint16V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUint64Uint16X(vp *map[uint64]uint16, d *Decoder) {
- v, changed := f.DecMapUint64Uint16V(*vp, true, d)
+func (f fastpathT) DecMapUint64Uint16X(vp *map[uint64]uint16, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUint64Uint16V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUint64Uint16V(v map[uint64]uint16, canChange bool,
+func (_ fastpathT) DecMapUint64Uint16V(v map[uint64]uint16, checkNil bool, canChange bool,
d *Decoder) (_ map[uint64]uint16, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 10)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 10)
v = make(map[uint64]uint16, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeUint(64)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint16(dd.DecodeUint(16))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uint16(chkOvf.UintV(dd.DecodeUint64(), 16))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeUint(64)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint16(dd.DecodeUint(16))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUint64Uint32R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint64]uint32)
+ v, changed := fastpathTV.DecMapUint64Uint32V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUint64Uint32V(rv2i(rv).(map[uint64]uint32), false, d)
+ v := rv.Interface().(map[uint64]uint32)
+ fastpathTV.DecMapUint64Uint32V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUint64Uint32X(vp *map[uint64]uint32, d *Decoder) {
- v, changed := f.DecMapUint64Uint32V(*vp, true, d)
+func (f fastpathT) DecMapUint64Uint32X(vp *map[uint64]uint32, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUint64Uint32V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUint64Uint32V(v map[uint64]uint32, canChange bool,
+func (_ fastpathT) DecMapUint64Uint32V(v map[uint64]uint32, checkNil bool, canChange bool,
d *Decoder) (_ map[uint64]uint32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12)
v = make(map[uint64]uint32, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeUint(64)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint32(dd.DecodeUint(32))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uint32(chkOvf.UintV(dd.DecodeUint64(), 32))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeUint(64)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint32(dd.DecodeUint(32))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUint64Uint64R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint64]uint64)
+ v, changed := fastpathTV.DecMapUint64Uint64V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUint64Uint64V(rv2i(rv).(map[uint64]uint64), false, d)
+ v := rv.Interface().(map[uint64]uint64)
+ fastpathTV.DecMapUint64Uint64V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUint64Uint64X(vp *map[uint64]uint64, d *Decoder) {
- v, changed := f.DecMapUint64Uint64V(*vp, true, d)
+func (f fastpathT) DecMapUint64Uint64X(vp *map[uint64]uint64, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUint64Uint64V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUint64Uint64V(v map[uint64]uint64, canChange bool,
+func (_ fastpathT) DecMapUint64Uint64V(v map[uint64]uint64, checkNil bool, canChange bool,
d *Decoder) (_ map[uint64]uint64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16)
v = make(map[uint64]uint64, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeUint(64)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeUint(64)
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeUint64()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeUint(64)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeUint(64)
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUint64UintptrR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint64]uintptr)
+ v, changed := fastpathTV.DecMapUint64UintptrV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUint64UintptrV(rv2i(rv).(map[uint64]uintptr), false, d)
+ v := rv.Interface().(map[uint64]uintptr)
+ fastpathTV.DecMapUint64UintptrV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUint64UintptrX(vp *map[uint64]uintptr, d *Decoder) {
- v, changed := f.DecMapUint64UintptrV(*vp, true, d)
+func (f fastpathT) DecMapUint64UintptrX(vp *map[uint64]uintptr, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUint64UintptrV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUint64UintptrV(v map[uint64]uintptr, canChange bool,
+func (_ fastpathT) DecMapUint64UintptrV(v map[uint64]uintptr, checkNil bool, canChange bool,
d *Decoder) (_ map[uint64]uintptr, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16)
v = make(map[uint64]uintptr, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeUint(64)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uintptr(dd.DecodeUint(uintBitsize))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeUint(64)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uintptr(dd.DecodeUint(uintBitsize))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUint64IntR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint64]int)
+ v, changed := fastpathTV.DecMapUint64IntV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUint64IntV(rv2i(rv).(map[uint64]int), false, d)
+ v := rv.Interface().(map[uint64]int)
+ fastpathTV.DecMapUint64IntV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUint64IntX(vp *map[uint64]int, d *Decoder) {
- v, changed := f.DecMapUint64IntV(*vp, true, d)
+func (f fastpathT) DecMapUint64IntX(vp *map[uint64]int, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUint64IntV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUint64IntV(v map[uint64]int, canChange bool,
+func (_ fastpathT) DecMapUint64IntV(v map[uint64]int, checkNil bool, canChange bool,
d *Decoder) (_ map[uint64]int, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16)
v = make(map[uint64]int, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeUint(64)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int(dd.DecodeInt(intBitsize))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeUint(64)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int(dd.DecodeInt(intBitsize))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUint64Int8R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint64]int8)
+ v, changed := fastpathTV.DecMapUint64Int8V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUint64Int8V(rv2i(rv).(map[uint64]int8), false, d)
+ v := rv.Interface().(map[uint64]int8)
+ fastpathTV.DecMapUint64Int8V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUint64Int8X(vp *map[uint64]int8, d *Decoder) {
- v, changed := f.DecMapUint64Int8V(*vp, true, d)
+func (f fastpathT) DecMapUint64Int8X(vp *map[uint64]int8, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUint64Int8V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUint64Int8V(v map[uint64]int8, canChange bool,
+func (_ fastpathT) DecMapUint64Int8V(v map[uint64]int8, checkNil bool, canChange bool,
d *Decoder) (_ map[uint64]int8, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9)
v = make(map[uint64]int8, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeUint(64)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int8(dd.DecodeInt(8))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = int8(chkOvf.IntV(dd.DecodeInt64(), 8))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeUint(64)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int8(dd.DecodeInt(8))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUint64Int16R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint64]int16)
+ v, changed := fastpathTV.DecMapUint64Int16V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUint64Int16V(rv2i(rv).(map[uint64]int16), false, d)
+ v := rv.Interface().(map[uint64]int16)
+ fastpathTV.DecMapUint64Int16V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUint64Int16X(vp *map[uint64]int16, d *Decoder) {
- v, changed := f.DecMapUint64Int16V(*vp, true, d)
+func (f fastpathT) DecMapUint64Int16X(vp *map[uint64]int16, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUint64Int16V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUint64Int16V(v map[uint64]int16, canChange bool,
+func (_ fastpathT) DecMapUint64Int16V(v map[uint64]int16, checkNil bool, canChange bool,
d *Decoder) (_ map[uint64]int16, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 10)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 10)
v = make(map[uint64]int16, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeUint(64)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int16(dd.DecodeInt(16))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = int16(chkOvf.IntV(dd.DecodeInt64(), 16))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeUint(64)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int16(dd.DecodeInt(16))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUint64Int32R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint64]int32)
+ v, changed := fastpathTV.DecMapUint64Int32V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUint64Int32V(rv2i(rv).(map[uint64]int32), false, d)
+ v := rv.Interface().(map[uint64]int32)
+ fastpathTV.DecMapUint64Int32V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUint64Int32X(vp *map[uint64]int32, d *Decoder) {
- v, changed := f.DecMapUint64Int32V(*vp, true, d)
+func (f fastpathT) DecMapUint64Int32X(vp *map[uint64]int32, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUint64Int32V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUint64Int32V(v map[uint64]int32, canChange bool,
+func (_ fastpathT) DecMapUint64Int32V(v map[uint64]int32, checkNil bool, canChange bool,
d *Decoder) (_ map[uint64]int32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12)
v = make(map[uint64]int32, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeUint(64)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int32(dd.DecodeInt(32))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = int32(chkOvf.IntV(dd.DecodeInt64(), 32))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeUint(64)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int32(dd.DecodeInt(32))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUint64Int64R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint64]int64)
+ v, changed := fastpathTV.DecMapUint64Int64V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUint64Int64V(rv2i(rv).(map[uint64]int64), false, d)
+ v := rv.Interface().(map[uint64]int64)
+ fastpathTV.DecMapUint64Int64V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUint64Int64X(vp *map[uint64]int64, d *Decoder) {
- v, changed := f.DecMapUint64Int64V(*vp, true, d)
+func (f fastpathT) DecMapUint64Int64X(vp *map[uint64]int64, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUint64Int64V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUint64Int64V(v map[uint64]int64, canChange bool,
+func (_ fastpathT) DecMapUint64Int64V(v map[uint64]int64, checkNil bool, canChange bool,
d *Decoder) (_ map[uint64]int64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16)
v = make(map[uint64]int64, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeUint(64)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeInt(64)
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeInt64()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeUint(64)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeInt(64)
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUint64Float32R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint64]float32)
+ v, changed := fastpathTV.DecMapUint64Float32V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUint64Float32V(rv2i(rv).(map[uint64]float32), false, d)
+ v := rv.Interface().(map[uint64]float32)
+ fastpathTV.DecMapUint64Float32V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUint64Float32X(vp *map[uint64]float32, d *Decoder) {
- v, changed := f.DecMapUint64Float32V(*vp, true, d)
+func (f fastpathT) DecMapUint64Float32X(vp *map[uint64]float32, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUint64Float32V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUint64Float32V(v map[uint64]float32, canChange bool,
+func (_ fastpathT) DecMapUint64Float32V(v map[uint64]float32, checkNil bool, canChange bool,
d *Decoder) (_ map[uint64]float32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12)
v = make(map[uint64]float32, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeUint(64)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = float32(dd.DecodeFloat(true))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = float32(chkOvf.Float32V(dd.DecodeFloat64()))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeUint(64)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = float32(dd.DecodeFloat(true))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUint64Float64R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint64]float64)
+ v, changed := fastpathTV.DecMapUint64Float64V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUint64Float64V(rv2i(rv).(map[uint64]float64), false, d)
+ v := rv.Interface().(map[uint64]float64)
+ fastpathTV.DecMapUint64Float64V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUint64Float64X(vp *map[uint64]float64, d *Decoder) {
- v, changed := f.DecMapUint64Float64V(*vp, true, d)
+func (f fastpathT) DecMapUint64Float64X(vp *map[uint64]float64, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUint64Float64V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUint64Float64V(v map[uint64]float64, canChange bool,
+func (_ fastpathT) DecMapUint64Float64V(v map[uint64]float64, checkNil bool, canChange bool,
d *Decoder) (_ map[uint64]float64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16)
v = make(map[uint64]float64, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeUint(64)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeFloat(false)
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeFloat64()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeUint(64)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeFloat(false)
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUint64BoolR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uint64]bool)
+ v, changed := fastpathTV.DecMapUint64BoolV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUint64BoolV(rv2i(rv).(map[uint64]bool), false, d)
+ v := rv.Interface().(map[uint64]bool)
+ fastpathTV.DecMapUint64BoolV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUint64BoolX(vp *map[uint64]bool, d *Decoder) {
- v, changed := f.DecMapUint64BoolV(*vp, true, d)
+func (f fastpathT) DecMapUint64BoolX(vp *map[uint64]bool, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUint64BoolV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUint64BoolV(v map[uint64]bool, canChange bool,
+func (_ fastpathT) DecMapUint64BoolV(v map[uint64]bool, checkNil bool, canChange bool,
d *Decoder) (_ map[uint64]bool, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9)
v = make(map[uint64]bool, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeUint(64)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeBool()
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeBool()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeUint(64)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeBool()
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUintptrIntfR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uintptr]interface{})
+ v, changed := fastpathTV.DecMapUintptrIntfV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUintptrIntfV(rv2i(rv).(map[uintptr]interface{}), false, d)
+ v := rv.Interface().(map[uintptr]interface{})
+ fastpathTV.DecMapUintptrIntfV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUintptrIntfX(vp *map[uintptr]interface{}, d *Decoder) {
- v, changed := f.DecMapUintptrIntfV(*vp, true, d)
+func (f fastpathT) DecMapUintptrIntfX(vp *map[uintptr]interface{}, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUintptrIntfV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUintptrIntfV(v map[uintptr]interface{}, canChange bool,
+func (_ fastpathT) DecMapUintptrIntfV(v map[uintptr]interface{}, checkNil bool, canChange bool,
d *Decoder) (_ map[uintptr]interface{}, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 24)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 24)
v = make(map[uintptr]interface{}, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset
+ mapGet := !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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uintptr(dd.DecodeUint(uintBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ if mapGet {
+ mv = v[mk]
+ } else {
+ mv = nil
+ }
+ d.decode(&mv)
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- if mapGet {
- mv = v[mk]
- } else {
- mv = nil
- }
- d.decode(&mv)
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uintptr(dd.DecodeUint(uintBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ if mapGet {
+ mv = v[mk]
+ } else {
+ mv = nil
+ }
+ d.decode(&mv)
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUintptrStringR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uintptr]string)
+ v, changed := fastpathTV.DecMapUintptrStringV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUintptrStringV(rv2i(rv).(map[uintptr]string), false, d)
+ v := rv.Interface().(map[uintptr]string)
+ fastpathTV.DecMapUintptrStringV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUintptrStringX(vp *map[uintptr]string, d *Decoder) {
- v, changed := f.DecMapUintptrStringV(*vp, true, d)
+func (f fastpathT) DecMapUintptrStringX(vp *map[uintptr]string, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUintptrStringV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUintptrStringV(v map[uintptr]string, canChange bool,
+func (_ fastpathT) DecMapUintptrStringV(v map[uintptr]string, checkNil bool, canChange bool,
d *Decoder) (_ map[uintptr]string, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 24)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 24)
v = make(map[uintptr]string, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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] = ""
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uintptr(dd.DecodeUint(uintBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeString()
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeString()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uintptr(dd.DecodeUint(uintBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeString()
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUintptrUintR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uintptr]uint)
+ v, changed := fastpathTV.DecMapUintptrUintV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUintptrUintV(rv2i(rv).(map[uintptr]uint), false, d)
+ v := rv.Interface().(map[uintptr]uint)
+ fastpathTV.DecMapUintptrUintV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUintptrUintX(vp *map[uintptr]uint, d *Decoder) {
- v, changed := f.DecMapUintptrUintV(*vp, true, d)
+func (f fastpathT) DecMapUintptrUintX(vp *map[uintptr]uint, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUintptrUintV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUintptrUintV(v map[uintptr]uint, canChange bool,
+func (_ fastpathT) DecMapUintptrUintV(v map[uintptr]uint, checkNil bool, canChange bool,
d *Decoder) (_ map[uintptr]uint, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16)
v = make(map[uintptr]uint, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uintptr(dd.DecodeUint(uintBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint(dd.DecodeUint(uintBitsize))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uintptr(dd.DecodeUint(uintBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint(dd.DecodeUint(uintBitsize))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUintptrUint8R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uintptr]uint8)
+ v, changed := fastpathTV.DecMapUintptrUint8V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUintptrUint8V(rv2i(rv).(map[uintptr]uint8), false, d)
+ v := rv.Interface().(map[uintptr]uint8)
+ fastpathTV.DecMapUintptrUint8V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUintptrUint8X(vp *map[uintptr]uint8, d *Decoder) {
- v, changed := f.DecMapUintptrUint8V(*vp, true, d)
+func (f fastpathT) DecMapUintptrUint8X(vp *map[uintptr]uint8, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUintptrUint8V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUintptrUint8V(v map[uintptr]uint8, canChange bool,
+func (_ fastpathT) DecMapUintptrUint8V(v map[uintptr]uint8, checkNil bool, canChange bool,
d *Decoder) (_ map[uintptr]uint8, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9)
v = make(map[uintptr]uint8, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uintptr(dd.DecodeUint(uintBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint8(dd.DecodeUint(8))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uint8(chkOvf.UintV(dd.DecodeUint64(), 8))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uintptr(dd.DecodeUint(uintBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint8(dd.DecodeUint(8))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUintptrUint16R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uintptr]uint16)
+ v, changed := fastpathTV.DecMapUintptrUint16V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUintptrUint16V(rv2i(rv).(map[uintptr]uint16), false, d)
+ v := rv.Interface().(map[uintptr]uint16)
+ fastpathTV.DecMapUintptrUint16V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUintptrUint16X(vp *map[uintptr]uint16, d *Decoder) {
- v, changed := f.DecMapUintptrUint16V(*vp, true, d)
+func (f fastpathT) DecMapUintptrUint16X(vp *map[uintptr]uint16, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUintptrUint16V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUintptrUint16V(v map[uintptr]uint16, canChange bool,
+func (_ fastpathT) DecMapUintptrUint16V(v map[uintptr]uint16, checkNil bool, canChange bool,
d *Decoder) (_ map[uintptr]uint16, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 10)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 10)
v = make(map[uintptr]uint16, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uintptr(dd.DecodeUint(uintBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint16(dd.DecodeUint(16))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uint16(chkOvf.UintV(dd.DecodeUint64(), 16))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uintptr(dd.DecodeUint(uintBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint16(dd.DecodeUint(16))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUintptrUint32R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uintptr]uint32)
+ v, changed := fastpathTV.DecMapUintptrUint32V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUintptrUint32V(rv2i(rv).(map[uintptr]uint32), false, d)
+ v := rv.Interface().(map[uintptr]uint32)
+ fastpathTV.DecMapUintptrUint32V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUintptrUint32X(vp *map[uintptr]uint32, d *Decoder) {
- v, changed := f.DecMapUintptrUint32V(*vp, true, d)
+func (f fastpathT) DecMapUintptrUint32X(vp *map[uintptr]uint32, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUintptrUint32V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUintptrUint32V(v map[uintptr]uint32, canChange bool,
+func (_ fastpathT) DecMapUintptrUint32V(v map[uintptr]uint32, checkNil bool, canChange bool,
d *Decoder) (_ map[uintptr]uint32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12)
v = make(map[uintptr]uint32, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uintptr(dd.DecodeUint(uintBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint32(dd.DecodeUint(32))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uint32(chkOvf.UintV(dd.DecodeUint64(), 32))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uintptr(dd.DecodeUint(uintBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint32(dd.DecodeUint(32))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUintptrUint64R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uintptr]uint64)
+ v, changed := fastpathTV.DecMapUintptrUint64V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUintptrUint64V(rv2i(rv).(map[uintptr]uint64), false, d)
+ v := rv.Interface().(map[uintptr]uint64)
+ fastpathTV.DecMapUintptrUint64V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUintptrUint64X(vp *map[uintptr]uint64, d *Decoder) {
- v, changed := f.DecMapUintptrUint64V(*vp, true, d)
+func (f fastpathT) DecMapUintptrUint64X(vp *map[uintptr]uint64, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUintptrUint64V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUintptrUint64V(v map[uintptr]uint64, canChange bool,
+func (_ fastpathT) DecMapUintptrUint64V(v map[uintptr]uint64, checkNil bool, canChange bool,
d *Decoder) (_ map[uintptr]uint64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16)
v = make(map[uintptr]uint64, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uintptr(dd.DecodeUint(uintBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeUint(64)
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeUint64()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uintptr(dd.DecodeUint(uintBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeUint(64)
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUintptrUintptrR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uintptr]uintptr)
+ v, changed := fastpathTV.DecMapUintptrUintptrV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUintptrUintptrV(rv2i(rv).(map[uintptr]uintptr), false, d)
+ v := rv.Interface().(map[uintptr]uintptr)
+ fastpathTV.DecMapUintptrUintptrV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUintptrUintptrX(vp *map[uintptr]uintptr, d *Decoder) {
- v, changed := f.DecMapUintptrUintptrV(*vp, true, d)
+func (f fastpathT) DecMapUintptrUintptrX(vp *map[uintptr]uintptr, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUintptrUintptrV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUintptrUintptrV(v map[uintptr]uintptr, canChange bool,
+func (_ fastpathT) DecMapUintptrUintptrV(v map[uintptr]uintptr, checkNil bool, canChange bool,
d *Decoder) (_ map[uintptr]uintptr, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16)
v = make(map[uintptr]uintptr, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uintptr(dd.DecodeUint(uintBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uintptr(dd.DecodeUint(uintBitsize))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uintptr(dd.DecodeUint(uintBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uintptr(dd.DecodeUint(uintBitsize))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUintptrIntR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uintptr]int)
+ v, changed := fastpathTV.DecMapUintptrIntV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUintptrIntV(rv2i(rv).(map[uintptr]int), false, d)
+ v := rv.Interface().(map[uintptr]int)
+ fastpathTV.DecMapUintptrIntV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUintptrIntX(vp *map[uintptr]int, d *Decoder) {
- v, changed := f.DecMapUintptrIntV(*vp, true, d)
+func (f fastpathT) DecMapUintptrIntX(vp *map[uintptr]int, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUintptrIntV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUintptrIntV(v map[uintptr]int, canChange bool,
+func (_ fastpathT) DecMapUintptrIntV(v map[uintptr]int, checkNil bool, canChange bool,
d *Decoder) (_ map[uintptr]int, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16)
v = make(map[uintptr]int, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uintptr(dd.DecodeUint(uintBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int(dd.DecodeInt(intBitsize))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uintptr(dd.DecodeUint(uintBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int(dd.DecodeInt(intBitsize))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUintptrInt8R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uintptr]int8)
+ v, changed := fastpathTV.DecMapUintptrInt8V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUintptrInt8V(rv2i(rv).(map[uintptr]int8), false, d)
+ v := rv.Interface().(map[uintptr]int8)
+ fastpathTV.DecMapUintptrInt8V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUintptrInt8X(vp *map[uintptr]int8, d *Decoder) {
- v, changed := f.DecMapUintptrInt8V(*vp, true, d)
+func (f fastpathT) DecMapUintptrInt8X(vp *map[uintptr]int8, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUintptrInt8V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUintptrInt8V(v map[uintptr]int8, canChange bool,
+func (_ fastpathT) DecMapUintptrInt8V(v map[uintptr]int8, checkNil bool, canChange bool,
d *Decoder) (_ map[uintptr]int8, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9)
v = make(map[uintptr]int8, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uintptr(dd.DecodeUint(uintBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int8(dd.DecodeInt(8))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = int8(chkOvf.IntV(dd.DecodeInt64(), 8))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uintptr(dd.DecodeUint(uintBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int8(dd.DecodeInt(8))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUintptrInt16R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uintptr]int16)
+ v, changed := fastpathTV.DecMapUintptrInt16V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUintptrInt16V(rv2i(rv).(map[uintptr]int16), false, d)
+ v := rv.Interface().(map[uintptr]int16)
+ fastpathTV.DecMapUintptrInt16V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUintptrInt16X(vp *map[uintptr]int16, d *Decoder) {
- v, changed := f.DecMapUintptrInt16V(*vp, true, d)
+func (f fastpathT) DecMapUintptrInt16X(vp *map[uintptr]int16, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUintptrInt16V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUintptrInt16V(v map[uintptr]int16, canChange bool,
+func (_ fastpathT) DecMapUintptrInt16V(v map[uintptr]int16, checkNil bool, canChange bool,
d *Decoder) (_ map[uintptr]int16, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 10)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 10)
v = make(map[uintptr]int16, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uintptr(dd.DecodeUint(uintBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int16(dd.DecodeInt(16))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = int16(chkOvf.IntV(dd.DecodeInt64(), 16))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uintptr(dd.DecodeUint(uintBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int16(dd.DecodeInt(16))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUintptrInt32R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uintptr]int32)
+ v, changed := fastpathTV.DecMapUintptrInt32V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUintptrInt32V(rv2i(rv).(map[uintptr]int32), false, d)
+ v := rv.Interface().(map[uintptr]int32)
+ fastpathTV.DecMapUintptrInt32V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUintptrInt32X(vp *map[uintptr]int32, d *Decoder) {
- v, changed := f.DecMapUintptrInt32V(*vp, true, d)
+func (f fastpathT) DecMapUintptrInt32X(vp *map[uintptr]int32, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUintptrInt32V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUintptrInt32V(v map[uintptr]int32, canChange bool,
+func (_ fastpathT) DecMapUintptrInt32V(v map[uintptr]int32, checkNil bool, canChange bool,
d *Decoder) (_ map[uintptr]int32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12)
v = make(map[uintptr]int32, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uintptr(dd.DecodeUint(uintBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int32(dd.DecodeInt(32))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = int32(chkOvf.IntV(dd.DecodeInt64(), 32))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uintptr(dd.DecodeUint(uintBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int32(dd.DecodeInt(32))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUintptrInt64R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uintptr]int64)
+ v, changed := fastpathTV.DecMapUintptrInt64V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUintptrInt64V(rv2i(rv).(map[uintptr]int64), false, d)
+ v := rv.Interface().(map[uintptr]int64)
+ fastpathTV.DecMapUintptrInt64V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUintptrInt64X(vp *map[uintptr]int64, d *Decoder) {
- v, changed := f.DecMapUintptrInt64V(*vp, true, d)
+func (f fastpathT) DecMapUintptrInt64X(vp *map[uintptr]int64, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUintptrInt64V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUintptrInt64V(v map[uintptr]int64, canChange bool,
+func (_ fastpathT) DecMapUintptrInt64V(v map[uintptr]int64, checkNil bool, canChange bool,
d *Decoder) (_ map[uintptr]int64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16)
v = make(map[uintptr]int64, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uintptr(dd.DecodeUint(uintBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeInt(64)
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeInt64()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uintptr(dd.DecodeUint(uintBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeInt(64)
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUintptrFloat32R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uintptr]float32)
+ v, changed := fastpathTV.DecMapUintptrFloat32V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUintptrFloat32V(rv2i(rv).(map[uintptr]float32), false, d)
+ v := rv.Interface().(map[uintptr]float32)
+ fastpathTV.DecMapUintptrFloat32V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUintptrFloat32X(vp *map[uintptr]float32, d *Decoder) {
- v, changed := f.DecMapUintptrFloat32V(*vp, true, d)
+func (f fastpathT) DecMapUintptrFloat32X(vp *map[uintptr]float32, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUintptrFloat32V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUintptrFloat32V(v map[uintptr]float32, canChange bool,
+func (_ fastpathT) DecMapUintptrFloat32V(v map[uintptr]float32, checkNil bool, canChange bool,
d *Decoder) (_ map[uintptr]float32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12)
v = make(map[uintptr]float32, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uintptr(dd.DecodeUint(uintBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = float32(dd.DecodeFloat(true))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = float32(chkOvf.Float32V(dd.DecodeFloat64()))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uintptr(dd.DecodeUint(uintBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = float32(dd.DecodeFloat(true))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapUintptrFloat64R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uintptr]float64)
+ v, changed := fastpathTV.DecMapUintptrFloat64V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUintptrFloat64V(rv2i(rv).(map[uintptr]float64), false, d)
+ v := rv.Interface().(map[uintptr]float64)
+ fastpathTV.DecMapUintptrFloat64V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUintptrFloat64X(vp *map[uintptr]float64, d *Decoder) {
- v, changed := f.DecMapUintptrFloat64V(*vp, true, d)
+func (f fastpathT) DecMapUintptrFloat64X(vp *map[uintptr]float64, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUintptrFloat64V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUintptrFloat64V(v map[uintptr]float64, canChange bool,
+func (_ fastpathT) DecMapUintptrFloat64V(v map[uintptr]float64, checkNil bool, canChange bool,
d *Decoder) (_ map[uintptr]float64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16)
v = make(map[uintptr]float64, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uintptr(dd.DecodeUint(uintBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeFloat(false)
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeFloat64()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uintptr(dd.DecodeUint(uintBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeFloat(false)
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
return v, changed
}
-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)
+func (f *decFnInfo) fastpathDecMapUintptrBoolR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[uintptr]bool)
+ v, changed := fastpathTV.DecMapUintptrBoolV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapUintptrBoolV(rv2i(rv).(map[uintptr]bool), false, d)
+ v := rv.Interface().(map[uintptr]bool)
+ fastpathTV.DecMapUintptrBoolV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapUintptrBoolX(vp *map[uintptr]bool, d *Decoder) {
- v, changed := f.DecMapUintptrBoolV(*vp, true, d)
+func (f fastpathT) DecMapUintptrBoolX(vp *map[uintptr]bool, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapUintptrBoolV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapUintptrBoolV(v map[uintptr]bool, canChange bool,
+func (_ fastpathT) DecMapUintptrBoolV(v map[uintptr]bool, checkNil bool, canChange bool,
d *Decoder) (_ map[uintptr]bool, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9)
v = make(map[uintptr]bool, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uintptr(dd.DecodeUint(uintBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeBool()
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeBool()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = uintptr(dd.DecodeUint(uintBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeBool()
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
return v, changed
}
-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)
+func (f *decFnInfo) fastpathDecMapIntIntfR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int]interface{})
+ v, changed := fastpathTV.DecMapIntIntfV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapIntIntfV(rv2i(rv).(map[int]interface{}), false, d)
+ v := rv.Interface().(map[int]interface{})
+ fastpathTV.DecMapIntIntfV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapIntIntfX(vp *map[int]interface{}, d *Decoder) {
- v, changed := f.DecMapIntIntfV(*vp, true, d)
+func (f fastpathT) DecMapIntIntfX(vp *map[int]interface{}, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapIntIntfV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapIntIntfV(v map[int]interface{}, canChange bool,
+func (_ fastpathT) DecMapIntIntfV(v map[int]interface{}, checkNil bool, canChange bool,
d *Decoder) (_ map[int]interface{}, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 24)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 24)
v = make(map[int]interface{}, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset
+ mapGet := !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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int(dd.DecodeInt(intBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ if mapGet {
+ mv = v[mk]
+ } else {
+ mv = nil
+ }
+ d.decode(&mv)
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- if mapGet {
- mv = v[mk]
- } else {
- mv = nil
- }
- d.decode(&mv)
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int(dd.DecodeInt(intBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ if mapGet {
+ mv = v[mk]
+ } else {
+ mv = nil
+ }
+ d.decode(&mv)
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
return v, changed
}
-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)
+func (f *decFnInfo) fastpathDecMapIntStringR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int]string)
+ v, changed := fastpathTV.DecMapIntStringV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapIntStringV(rv2i(rv).(map[int]string), false, d)
+ v := rv.Interface().(map[int]string)
+ fastpathTV.DecMapIntStringV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapIntStringX(vp *map[int]string, d *Decoder) {
- v, changed := f.DecMapIntStringV(*vp, true, d)
+func (f fastpathT) DecMapIntStringX(vp *map[int]string, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapIntStringV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapIntStringV(v map[int]string, canChange bool,
+func (_ fastpathT) DecMapIntStringV(v map[int]string, checkNil bool, canChange bool,
d *Decoder) (_ map[int]string, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 24)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 24)
v = make(map[int]string, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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] = ""
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int(dd.DecodeInt(intBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeString()
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeString()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int(dd.DecodeInt(intBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeString()
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
return v, changed
}
-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)
+func (f *decFnInfo) fastpathDecMapIntUintR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int]uint)
+ v, changed := fastpathTV.DecMapIntUintV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapIntUintV(rv2i(rv).(map[int]uint), false, d)
+ v := rv.Interface().(map[int]uint)
+ fastpathTV.DecMapIntUintV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapIntUintX(vp *map[int]uint, d *Decoder) {
- v, changed := f.DecMapIntUintV(*vp, true, d)
+func (f fastpathT) DecMapIntUintX(vp *map[int]uint, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapIntUintV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapIntUintV(v map[int]uint, canChange bool,
+func (_ fastpathT) DecMapIntUintV(v map[int]uint, checkNil bool, canChange bool,
d *Decoder) (_ map[int]uint, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16)
v = make(map[int]uint, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int(dd.DecodeInt(intBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint(dd.DecodeUint(uintBitsize))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int(dd.DecodeInt(intBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint(dd.DecodeUint(uintBitsize))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapIntUint8R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int]uint8)
+ v, changed := fastpathTV.DecMapIntUint8V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapIntUint8V(rv2i(rv).(map[int]uint8), false, d)
+ v := rv.Interface().(map[int]uint8)
+ fastpathTV.DecMapIntUint8V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapIntUint8X(vp *map[int]uint8, d *Decoder) {
- v, changed := f.DecMapIntUint8V(*vp, true, d)
+func (f fastpathT) DecMapIntUint8X(vp *map[int]uint8, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapIntUint8V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapIntUint8V(v map[int]uint8, canChange bool,
+func (_ fastpathT) DecMapIntUint8V(v map[int]uint8, checkNil bool, canChange bool,
d *Decoder) (_ map[int]uint8, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9)
v = make(map[int]uint8, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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)
- } else {
- v[mk] = 0
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int(dd.DecodeInt(intBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint8(dd.DecodeUint(8))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uint8(chkOvf.UintV(dd.DecodeUint64(), 8))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int(dd.DecodeInt(intBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint8(dd.DecodeUint(8))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapIntUint16R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int]uint16)
+ v, changed := fastpathTV.DecMapIntUint16V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapIntUint16V(rv2i(rv).(map[int]uint16), false, d)
+ v := rv.Interface().(map[int]uint16)
+ fastpathTV.DecMapIntUint16V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapIntUint16X(vp *map[int]uint16, d *Decoder) {
- v, changed := f.DecMapIntUint16V(*vp, true, d)
+func (f fastpathT) DecMapIntUint16X(vp *map[int]uint16, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapIntUint16V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapIntUint16V(v map[int]uint16, canChange bool,
+func (_ fastpathT) DecMapIntUint16V(v map[int]uint16, checkNil bool, canChange bool,
d *Decoder) (_ map[int]uint16, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 10)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 10)
v = make(map[int]uint16, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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)
- } else {
- v[mk] = 0
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int(dd.DecodeInt(intBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint16(dd.DecodeUint(16))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uint16(chkOvf.UintV(dd.DecodeUint64(), 16))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int(dd.DecodeInt(intBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint16(dd.DecodeUint(16))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapIntUint32R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int]uint32)
+ v, changed := fastpathTV.DecMapIntUint32V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapIntUint32V(rv2i(rv).(map[int]uint32), false, d)
+ v := rv.Interface().(map[int]uint32)
+ fastpathTV.DecMapIntUint32V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapIntUint32X(vp *map[int]uint32, d *Decoder) {
- v, changed := f.DecMapIntUint32V(*vp, true, d)
+func (f fastpathT) DecMapIntUint32X(vp *map[int]uint32, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapIntUint32V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapIntUint32V(v map[int]uint32, canChange bool,
+func (_ fastpathT) DecMapIntUint32V(v map[int]uint32, checkNil bool, canChange bool,
d *Decoder) (_ map[int]uint32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12)
v = make(map[int]uint32, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int(dd.DecodeInt(intBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint32(dd.DecodeUint(32))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uint32(chkOvf.UintV(dd.DecodeUint64(), 32))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int(dd.DecodeInt(intBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint32(dd.DecodeUint(32))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapIntUint64R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int]uint64)
+ v, changed := fastpathTV.DecMapIntUint64V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapIntUint64V(rv2i(rv).(map[int]uint64), false, d)
+ v := rv.Interface().(map[int]uint64)
+ fastpathTV.DecMapIntUint64V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapIntUint64X(vp *map[int]uint64, d *Decoder) {
- v, changed := f.DecMapIntUint64V(*vp, true, d)
+func (f fastpathT) DecMapIntUint64X(vp *map[int]uint64, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapIntUint64V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapIntUint64V(v map[int]uint64, canChange bool,
+func (_ fastpathT) DecMapIntUint64V(v map[int]uint64, checkNil bool, canChange bool,
d *Decoder) (_ map[int]uint64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16)
v = make(map[int]uint64, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int(dd.DecodeInt(intBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeUint(64)
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeUint64()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int(dd.DecodeInt(intBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeUint(64)
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapIntUintptrR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int]uintptr)
+ v, changed := fastpathTV.DecMapIntUintptrV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapIntUintptrV(rv2i(rv).(map[int]uintptr), false, d)
+ v := rv.Interface().(map[int]uintptr)
+ fastpathTV.DecMapIntUintptrV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapIntUintptrX(vp *map[int]uintptr, d *Decoder) {
- v, changed := f.DecMapIntUintptrV(*vp, true, d)
+func (f fastpathT) DecMapIntUintptrX(vp *map[int]uintptr, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapIntUintptrV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapIntUintptrV(v map[int]uintptr, canChange bool,
+func (_ fastpathT) DecMapIntUintptrV(v map[int]uintptr, checkNil bool, canChange bool,
d *Decoder) (_ map[int]uintptr, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16)
v = make(map[int]uintptr, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int(dd.DecodeInt(intBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uintptr(dd.DecodeUint(uintBitsize))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int(dd.DecodeInt(intBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uintptr(dd.DecodeUint(uintBitsize))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
return v, changed
}
-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)
+func (f *decFnInfo) fastpathDecMapIntIntR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int]int)
+ v, changed := fastpathTV.DecMapIntIntV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapIntIntV(rv2i(rv).(map[int]int), false, d)
+ v := rv.Interface().(map[int]int)
+ fastpathTV.DecMapIntIntV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapIntIntX(vp *map[int]int, d *Decoder) {
- v, changed := f.DecMapIntIntV(*vp, true, d)
+func (f fastpathT) DecMapIntIntX(vp *map[int]int, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapIntIntV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapIntIntV(v map[int]int, canChange bool,
+func (_ fastpathT) DecMapIntIntV(v map[int]int, checkNil bool, canChange bool,
d *Decoder) (_ map[int]int, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16)
v = make(map[int]int, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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)
- } else {
- v[mk] = 0
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int(dd.DecodeInt(intBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int(dd.DecodeInt(intBitsize))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int(dd.DecodeInt(intBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int(dd.DecodeInt(intBitsize))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapIntInt8R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int]int8)
+ v, changed := fastpathTV.DecMapIntInt8V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapIntInt8V(rv2i(rv).(map[int]int8), false, d)
+ v := rv.Interface().(map[int]int8)
+ fastpathTV.DecMapIntInt8V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapIntInt8X(vp *map[int]int8, d *Decoder) {
- v, changed := f.DecMapIntInt8V(*vp, true, d)
+func (f fastpathT) DecMapIntInt8X(vp *map[int]int8, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapIntInt8V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapIntInt8V(v map[int]int8, canChange bool,
+func (_ fastpathT) DecMapIntInt8V(v map[int]int8, checkNil bool, canChange bool,
d *Decoder) (_ map[int]int8, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9)
v = make(map[int]int8, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int(dd.DecodeInt(intBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int8(dd.DecodeInt(8))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = int8(chkOvf.IntV(dd.DecodeInt64(), 8))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int(dd.DecodeInt(intBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int8(dd.DecodeInt(8))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
return v, changed
}
-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)
+func (f *decFnInfo) fastpathDecMapIntInt16R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int]int16)
+ v, changed := fastpathTV.DecMapIntInt16V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapIntInt16V(rv2i(rv).(map[int]int16), false, d)
+ v := rv.Interface().(map[int]int16)
+ fastpathTV.DecMapIntInt16V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapIntInt16X(vp *map[int]int16, d *Decoder) {
- v, changed := f.DecMapIntInt16V(*vp, true, d)
+func (f fastpathT) DecMapIntInt16X(vp *map[int]int16, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapIntInt16V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapIntInt16V(v map[int]int16, canChange bool,
+func (_ fastpathT) DecMapIntInt16V(v map[int]int16, checkNil bool, canChange bool,
d *Decoder) (_ map[int]int16, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 10)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 10)
v = make(map[int]int16, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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)
- } else {
- v[mk] = 0
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int(dd.DecodeInt(intBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int16(dd.DecodeInt(16))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = int16(chkOvf.IntV(dd.DecodeInt64(), 16))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int(dd.DecodeInt(intBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int16(dd.DecodeInt(16))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapIntInt32R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int]int32)
+ v, changed := fastpathTV.DecMapIntInt32V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapIntInt32V(rv2i(rv).(map[int]int32), false, d)
+ v := rv.Interface().(map[int]int32)
+ fastpathTV.DecMapIntInt32V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapIntInt32X(vp *map[int]int32, d *Decoder) {
- v, changed := f.DecMapIntInt32V(*vp, true, d)
+func (f fastpathT) DecMapIntInt32X(vp *map[int]int32, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapIntInt32V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapIntInt32V(v map[int]int32, canChange bool,
+func (_ fastpathT) DecMapIntInt32V(v map[int]int32, checkNil bool, canChange bool,
d *Decoder) (_ map[int]int32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12)
v = make(map[int]int32, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int(dd.DecodeInt(intBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int32(dd.DecodeInt(32))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = int32(chkOvf.IntV(dd.DecodeInt64(), 32))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int(dd.DecodeInt(intBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int32(dd.DecodeInt(32))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
return v, changed
}
-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)
+func (f *decFnInfo) fastpathDecMapIntInt64R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int]int64)
+ v, changed := fastpathTV.DecMapIntInt64V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapIntInt64V(rv2i(rv).(map[int]int64), false, d)
+ v := rv.Interface().(map[int]int64)
+ fastpathTV.DecMapIntInt64V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapIntInt64X(vp *map[int]int64, d *Decoder) {
- v, changed := f.DecMapIntInt64V(*vp, true, d)
+func (f fastpathT) DecMapIntInt64X(vp *map[int]int64, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapIntInt64V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapIntInt64V(v map[int]int64, canChange bool,
+func (_ fastpathT) DecMapIntInt64V(v map[int]int64, checkNil bool, canChange bool,
d *Decoder) (_ map[int]int64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16)
v = make(map[int]int64, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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)
- } else {
- v[mk] = 0
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int(dd.DecodeInt(intBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeInt(64)
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeInt64()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int(dd.DecodeInt(intBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeInt(64)
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapIntFloat32R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int]float32)
+ v, changed := fastpathTV.DecMapIntFloat32V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapIntFloat32V(rv2i(rv).(map[int]float32), false, d)
+ v := rv.Interface().(map[int]float32)
+ fastpathTV.DecMapIntFloat32V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapIntFloat32X(vp *map[int]float32, d *Decoder) {
- v, changed := f.DecMapIntFloat32V(*vp, true, d)
+func (f fastpathT) DecMapIntFloat32X(vp *map[int]float32, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapIntFloat32V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapIntFloat32V(v map[int]float32, canChange bool,
+func (_ fastpathT) DecMapIntFloat32V(v map[int]float32, checkNil bool, canChange bool,
d *Decoder) (_ map[int]float32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12)
v = make(map[int]float32, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int(dd.DecodeInt(intBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = float32(dd.DecodeFloat(true))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = float32(chkOvf.Float32V(dd.DecodeFloat64()))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int(dd.DecodeInt(intBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = float32(dd.DecodeFloat(true))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
return v, changed
}
-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)
+func (f *decFnInfo) fastpathDecMapIntFloat64R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int]float64)
+ v, changed := fastpathTV.DecMapIntFloat64V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapIntFloat64V(rv2i(rv).(map[int]float64), false, d)
+ v := rv.Interface().(map[int]float64)
+ fastpathTV.DecMapIntFloat64V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapIntFloat64X(vp *map[int]float64, d *Decoder) {
- v, changed := f.DecMapIntFloat64V(*vp, true, d)
+func (f fastpathT) DecMapIntFloat64X(vp *map[int]float64, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapIntFloat64V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapIntFloat64V(v map[int]float64, canChange bool,
+func (_ fastpathT) DecMapIntFloat64V(v map[int]float64, checkNil bool, canChange bool,
d *Decoder) (_ map[int]float64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16)
v = make(map[int]float64, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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)
- } else {
- v[mk] = 0
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int(dd.DecodeInt(intBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeFloat(false)
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeFloat64()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int(dd.DecodeInt(intBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeFloat(false)
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
return v, changed
}
-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)
+func (f *decFnInfo) fastpathDecMapIntBoolR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int]bool)
+ v, changed := fastpathTV.DecMapIntBoolV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapIntBoolV(rv2i(rv).(map[int]bool), false, d)
+ v := rv.Interface().(map[int]bool)
+ fastpathTV.DecMapIntBoolV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapIntBoolX(vp *map[int]bool, d *Decoder) {
- v, changed := f.DecMapIntBoolV(*vp, true, d)
+func (f fastpathT) DecMapIntBoolX(vp *map[int]bool, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapIntBoolV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapIntBoolV(v map[int]bool, canChange bool,
+func (_ fastpathT) DecMapIntBoolV(v map[int]bool, checkNil bool, canChange bool,
d *Decoder) (_ map[int]bool, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9)
v = make(map[int]bool, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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)
- } else {
- v[mk] = false
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int(dd.DecodeInt(intBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeBool()
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeBool()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int(dd.DecodeInt(intBitsize))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeBool()
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
return v, changed
}
-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)
+func (f *decFnInfo) fastpathDecMapInt8IntfR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int8]interface{})
+ v, changed := fastpathTV.DecMapInt8IntfV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt8IntfV(rv2i(rv).(map[int8]interface{}), false, d)
+ v := rv.Interface().(map[int8]interface{})
+ fastpathTV.DecMapInt8IntfV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapInt8IntfX(vp *map[int8]interface{}, d *Decoder) {
- v, changed := f.DecMapInt8IntfV(*vp, true, d)
+func (f fastpathT) DecMapInt8IntfX(vp *map[int8]interface{}, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapInt8IntfV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt8IntfV(v map[int8]interface{}, canChange bool,
+func (_ fastpathT) DecMapInt8IntfV(v map[int8]interface{}, checkNil bool, canChange bool,
d *Decoder) (_ map[int8]interface{}, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 17)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 17)
v = make(map[int8]interface{}, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset
+ mapGet := !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)
- } else {
- v[mk] = nil
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int8(dd.DecodeInt(8))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ if mapGet {
+ mv = v[mk]
+ } else {
+ mv = nil
+ }
+ d.decode(&mv)
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- if mapGet {
- mv = v[mk]
- } else {
- mv = nil
- }
- d.decode(&mv)
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int8(dd.DecodeInt(8))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ if mapGet {
+ mv = v[mk]
+ } else {
+ mv = nil
+ }
+ d.decode(&mv)
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
return v, changed
}
-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)
+func (f *decFnInfo) fastpathDecMapInt8StringR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int8]string)
+ v, changed := fastpathTV.DecMapInt8StringV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt8StringV(rv2i(rv).(map[int8]string), false, d)
+ v := rv.Interface().(map[int8]string)
+ fastpathTV.DecMapInt8StringV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapInt8StringX(vp *map[int8]string, d *Decoder) {
- v, changed := f.DecMapInt8StringV(*vp, true, d)
+func (f fastpathT) DecMapInt8StringX(vp *map[int8]string, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapInt8StringV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt8StringV(v map[int8]string, canChange bool,
+func (_ fastpathT) DecMapInt8StringV(v map[int8]string, checkNil bool, canChange bool,
d *Decoder) (_ map[int8]string, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 17)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 17)
v = make(map[int8]string, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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)
- } else {
- v[mk] = ""
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int8(dd.DecodeInt(8))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeString()
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeString()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int8(dd.DecodeInt(8))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeString()
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapInt8UintR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int8]uint)
+ v, changed := fastpathTV.DecMapInt8UintV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt8UintV(rv2i(rv).(map[int8]uint), false, d)
+ v := rv.Interface().(map[int8]uint)
+ fastpathTV.DecMapInt8UintV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapInt8UintX(vp *map[int8]uint, d *Decoder) {
- v, changed := f.DecMapInt8UintV(*vp, true, d)
+func (f fastpathT) DecMapInt8UintX(vp *map[int8]uint, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapInt8UintV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt8UintV(v map[int8]uint, canChange bool,
+func (_ fastpathT) DecMapInt8UintV(v map[int8]uint, checkNil bool, canChange bool,
d *Decoder) (_ map[int8]uint, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9)
v = make(map[int8]uint, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int8(dd.DecodeInt(8))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint(dd.DecodeUint(uintBitsize))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int8(dd.DecodeInt(8))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint(dd.DecodeUint(uintBitsize))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
return v, changed
}
-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)
+func (f *decFnInfo) fastpathDecMapInt8Uint8R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int8]uint8)
+ v, changed := fastpathTV.DecMapInt8Uint8V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt8Uint8V(rv2i(rv).(map[int8]uint8), false, d)
+ v := rv.Interface().(map[int8]uint8)
+ fastpathTV.DecMapInt8Uint8V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapInt8Uint8X(vp *map[int8]uint8, d *Decoder) {
- v, changed := f.DecMapInt8Uint8V(*vp, true, d)
+func (f fastpathT) DecMapInt8Uint8X(vp *map[int8]uint8, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapInt8Uint8V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt8Uint8V(v map[int8]uint8, canChange bool,
+func (_ fastpathT) DecMapInt8Uint8V(v map[int8]uint8, checkNil bool, canChange bool,
d *Decoder) (_ map[int8]uint8, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 2)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 2)
v = make(map[int8]uint8, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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)
- } else {
- v[mk] = 0
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int8(dd.DecodeInt(8))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint8(dd.DecodeUint(8))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uint8(chkOvf.UintV(dd.DecodeUint64(), 8))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int8(dd.DecodeInt(8))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint8(dd.DecodeUint(8))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapInt8Uint16R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int8]uint16)
+ v, changed := fastpathTV.DecMapInt8Uint16V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt8Uint16V(rv2i(rv).(map[int8]uint16), false, d)
+ v := rv.Interface().(map[int8]uint16)
+ fastpathTV.DecMapInt8Uint16V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapInt8Uint16X(vp *map[int8]uint16, d *Decoder) {
- v, changed := f.DecMapInt8Uint16V(*vp, true, d)
+func (f fastpathT) DecMapInt8Uint16X(vp *map[int8]uint16, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapInt8Uint16V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt8Uint16V(v map[int8]uint16, canChange bool,
+func (_ fastpathT) DecMapInt8Uint16V(v map[int8]uint16, checkNil bool, canChange bool,
d *Decoder) (_ map[int8]uint16, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 3)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 3)
v = make(map[int8]uint16, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int8(dd.DecodeInt(8))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint16(dd.DecodeUint(16))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uint16(chkOvf.UintV(dd.DecodeUint64(), 16))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int8(dd.DecodeInt(8))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint16(dd.DecodeUint(16))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
return v, changed
}
-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)
+func (f *decFnInfo) fastpathDecMapInt8Uint32R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int8]uint32)
+ v, changed := fastpathTV.DecMapInt8Uint32V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt8Uint32V(rv2i(rv).(map[int8]uint32), false, d)
+ v := rv.Interface().(map[int8]uint32)
+ fastpathTV.DecMapInt8Uint32V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapInt8Uint32X(vp *map[int8]uint32, d *Decoder) {
- v, changed := f.DecMapInt8Uint32V(*vp, true, d)
+func (f fastpathT) DecMapInt8Uint32X(vp *map[int8]uint32, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapInt8Uint32V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt8Uint32V(v map[int8]uint32, canChange bool,
+func (_ fastpathT) DecMapInt8Uint32V(v map[int8]uint32, checkNil bool, canChange bool,
d *Decoder) (_ map[int8]uint32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 5)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 5)
v = make(map[int8]uint32, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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)
- } else {
- v[mk] = 0
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int8(dd.DecodeInt(8))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint32(dd.DecodeUint(32))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uint32(chkOvf.UintV(dd.DecodeUint64(), 32))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int8(dd.DecodeInt(8))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint32(dd.DecodeUint(32))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapInt8Uint64R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int8]uint64)
+ v, changed := fastpathTV.DecMapInt8Uint64V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt8Uint64V(rv2i(rv).(map[int8]uint64), false, d)
+ v := rv.Interface().(map[int8]uint64)
+ fastpathTV.DecMapInt8Uint64V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapInt8Uint64X(vp *map[int8]uint64, d *Decoder) {
- v, changed := f.DecMapInt8Uint64V(*vp, true, d)
+func (f fastpathT) DecMapInt8Uint64X(vp *map[int8]uint64, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapInt8Uint64V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt8Uint64V(v map[int8]uint64, canChange bool,
+func (_ fastpathT) DecMapInt8Uint64V(v map[int8]uint64, checkNil bool, canChange bool,
d *Decoder) (_ map[int8]uint64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9)
v = make(map[int8]uint64, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int8(dd.DecodeInt(8))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeUint(64)
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeUint64()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int8(dd.DecodeInt(8))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeUint(64)
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
return v, changed
}
-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)
+func (f *decFnInfo) fastpathDecMapInt8UintptrR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int8]uintptr)
+ v, changed := fastpathTV.DecMapInt8UintptrV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt8UintptrV(rv2i(rv).(map[int8]uintptr), false, d)
+ v := rv.Interface().(map[int8]uintptr)
+ fastpathTV.DecMapInt8UintptrV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapInt8UintptrX(vp *map[int8]uintptr, d *Decoder) {
- v, changed := f.DecMapInt8UintptrV(*vp, true, d)
+func (f fastpathT) DecMapInt8UintptrX(vp *map[int8]uintptr, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapInt8UintptrV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt8UintptrV(v map[int8]uintptr, canChange bool,
+func (_ fastpathT) DecMapInt8UintptrV(v map[int8]uintptr, checkNil bool, canChange bool,
d *Decoder) (_ map[int8]uintptr, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9)
v = make(map[int8]uintptr, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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)
- } else {
- v[mk] = 0
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int8(dd.DecodeInt(8))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uintptr(dd.DecodeUint(uintBitsize))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int8(dd.DecodeInt(8))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uintptr(dd.DecodeUint(uintBitsize))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapInt8IntR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int8]int)
+ v, changed := fastpathTV.DecMapInt8IntV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt8IntV(rv2i(rv).(map[int8]int), false, d)
+ v := rv.Interface().(map[int8]int)
+ fastpathTV.DecMapInt8IntV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapInt8IntX(vp *map[int8]int, d *Decoder) {
- v, changed := f.DecMapInt8IntV(*vp, true, d)
+func (f fastpathT) DecMapInt8IntX(vp *map[int8]int, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapInt8IntV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt8IntV(v map[int8]int, canChange bool,
+func (_ fastpathT) DecMapInt8IntV(v map[int8]int, checkNil bool, canChange bool,
d *Decoder) (_ map[int8]int, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9)
v = make(map[int8]int, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int8(dd.DecodeInt(8))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int(dd.DecodeInt(intBitsize))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int8(dd.DecodeInt(8))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int(dd.DecodeInt(intBitsize))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
return v, changed
}
-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)
+func (f *decFnInfo) fastpathDecMapInt8Int8R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int8]int8)
+ v, changed := fastpathTV.DecMapInt8Int8V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt8Int8V(rv2i(rv).(map[int8]int8), false, d)
+ v := rv.Interface().(map[int8]int8)
+ fastpathTV.DecMapInt8Int8V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapInt8Int8X(vp *map[int8]int8, d *Decoder) {
- v, changed := f.DecMapInt8Int8V(*vp, true, d)
+func (f fastpathT) DecMapInt8Int8X(vp *map[int8]int8, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapInt8Int8V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt8Int8V(v map[int8]int8, canChange bool,
+func (_ fastpathT) DecMapInt8Int8V(v map[int8]int8, checkNil bool, canChange bool,
d *Decoder) (_ map[int8]int8, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 2)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 2)
v = make(map[int8]int8, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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)
- } else {
- v[mk] = 0
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int8(dd.DecodeInt(8))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int8(dd.DecodeInt(8))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = int8(chkOvf.IntV(dd.DecodeInt64(), 8))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int8(dd.DecodeInt(8))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int8(dd.DecodeInt(8))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapInt8Int16R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int8]int16)
+ v, changed := fastpathTV.DecMapInt8Int16V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt8Int16V(rv2i(rv).(map[int8]int16), false, d)
+ v := rv.Interface().(map[int8]int16)
+ fastpathTV.DecMapInt8Int16V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapInt8Int16X(vp *map[int8]int16, d *Decoder) {
- v, changed := f.DecMapInt8Int16V(*vp, true, d)
+func (f fastpathT) DecMapInt8Int16X(vp *map[int8]int16, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapInt8Int16V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt8Int16V(v map[int8]int16, canChange bool,
+func (_ fastpathT) DecMapInt8Int16V(v map[int8]int16, checkNil bool, canChange bool,
d *Decoder) (_ map[int8]int16, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 3)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 3)
v = make(map[int8]int16, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int8(dd.DecodeInt(8))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int16(dd.DecodeInt(16))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = int16(chkOvf.IntV(dd.DecodeInt64(), 16))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int8(dd.DecodeInt(8))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int16(dd.DecodeInt(16))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
return v, changed
}
-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)
+func (f *decFnInfo) fastpathDecMapInt8Int32R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int8]int32)
+ v, changed := fastpathTV.DecMapInt8Int32V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt8Int32V(rv2i(rv).(map[int8]int32), false, d)
+ v := rv.Interface().(map[int8]int32)
+ fastpathTV.DecMapInt8Int32V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapInt8Int32X(vp *map[int8]int32, d *Decoder) {
- v, changed := f.DecMapInt8Int32V(*vp, true, d)
+func (f fastpathT) DecMapInt8Int32X(vp *map[int8]int32, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapInt8Int32V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt8Int32V(v map[int8]int32, canChange bool,
+func (_ fastpathT) DecMapInt8Int32V(v map[int8]int32, checkNil bool, canChange bool,
d *Decoder) (_ map[int8]int32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 5)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 5)
v = make(map[int8]int32, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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)
- } else {
- v[mk] = 0
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int8(dd.DecodeInt(8))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int32(dd.DecodeInt(32))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = int32(chkOvf.IntV(dd.DecodeInt64(), 32))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int8(dd.DecodeInt(8))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int32(dd.DecodeInt(32))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapInt8Int64R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int8]int64)
+ v, changed := fastpathTV.DecMapInt8Int64V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt8Int64V(rv2i(rv).(map[int8]int64), false, d)
+ v := rv.Interface().(map[int8]int64)
+ fastpathTV.DecMapInt8Int64V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapInt8Int64X(vp *map[int8]int64, d *Decoder) {
- v, changed := f.DecMapInt8Int64V(*vp, true, d)
+func (f fastpathT) DecMapInt8Int64X(vp *map[int8]int64, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapInt8Int64V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt8Int64V(v map[int8]int64, canChange bool,
+func (_ fastpathT) DecMapInt8Int64V(v map[int8]int64, checkNil bool, canChange bool,
d *Decoder) (_ map[int8]int64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9)
v = make(map[int8]int64, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int8(dd.DecodeInt(8))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeInt(64)
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeInt64()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int8(dd.DecodeInt(8))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeInt(64)
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
return v, changed
}
-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)
+func (f *decFnInfo) fastpathDecMapInt8Float32R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int8]float32)
+ v, changed := fastpathTV.DecMapInt8Float32V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt8Float32V(rv2i(rv).(map[int8]float32), false, d)
+ v := rv.Interface().(map[int8]float32)
+ fastpathTV.DecMapInt8Float32V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapInt8Float32X(vp *map[int8]float32, d *Decoder) {
- v, changed := f.DecMapInt8Float32V(*vp, true, d)
+func (f fastpathT) DecMapInt8Float32X(vp *map[int8]float32, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapInt8Float32V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt8Float32V(v map[int8]float32, canChange bool,
+func (_ fastpathT) DecMapInt8Float32V(v map[int8]float32, checkNil bool, canChange bool,
d *Decoder) (_ map[int8]float32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 5)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 5)
v = make(map[int8]float32, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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)
- } else {
- v[mk] = 0
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int8(dd.DecodeInt(8))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = float32(dd.DecodeFloat(true))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = float32(chkOvf.Float32V(dd.DecodeFloat64()))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int8(dd.DecodeInt(8))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = float32(dd.DecodeFloat(true))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapInt8Float64R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int8]float64)
+ v, changed := fastpathTV.DecMapInt8Float64V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt8Float64V(rv2i(rv).(map[int8]float64), false, d)
+ v := rv.Interface().(map[int8]float64)
+ fastpathTV.DecMapInt8Float64V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapInt8Float64X(vp *map[int8]float64, d *Decoder) {
- v, changed := f.DecMapInt8Float64V(*vp, true, d)
+func (f fastpathT) DecMapInt8Float64X(vp *map[int8]float64, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapInt8Float64V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt8Float64V(v map[int8]float64, canChange bool,
+func (_ fastpathT) DecMapInt8Float64V(v map[int8]float64, checkNil bool, canChange bool,
d *Decoder) (_ map[int8]float64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9)
v = make(map[int8]float64, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int8(dd.DecodeInt(8))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeFloat(false)
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeFloat64()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int8(dd.DecodeInt(8))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeFloat(false)
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
return v, changed
}
-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)
+func (f *decFnInfo) fastpathDecMapInt8BoolR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int8]bool)
+ v, changed := fastpathTV.DecMapInt8BoolV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt8BoolV(rv2i(rv).(map[int8]bool), false, d)
+ v := rv.Interface().(map[int8]bool)
+ fastpathTV.DecMapInt8BoolV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapInt8BoolX(vp *map[int8]bool, d *Decoder) {
- v, changed := f.DecMapInt8BoolV(*vp, true, d)
+func (f fastpathT) DecMapInt8BoolX(vp *map[int8]bool, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapInt8BoolV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt8BoolV(v map[int8]bool, canChange bool,
+func (_ fastpathT) DecMapInt8BoolV(v map[int8]bool, checkNil bool, canChange bool,
d *Decoder) (_ map[int8]bool, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 2)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 2)
v = make(map[int8]bool, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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)
- } else {
- v[mk] = false
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int8(dd.DecodeInt(8))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeBool()
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeBool()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int8(dd.DecodeInt(8))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeBool()
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapInt16IntfR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int16]interface{})
+ v, changed := fastpathTV.DecMapInt16IntfV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt16IntfV(rv2i(rv).(map[int16]interface{}), false, d)
+ v := rv.Interface().(map[int16]interface{})
+ fastpathTV.DecMapInt16IntfV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapInt16IntfX(vp *map[int16]interface{}, d *Decoder) {
- v, changed := f.DecMapInt16IntfV(*vp, true, d)
+func (f fastpathT) DecMapInt16IntfX(vp *map[int16]interface{}, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapInt16IntfV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt16IntfV(v map[int16]interface{}, canChange bool,
+func (_ fastpathT) DecMapInt16IntfV(v map[int16]interface{}, checkNil bool, canChange bool,
d *Decoder) (_ map[int16]interface{}, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 18)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 18)
v = make(map[int16]interface{}, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset
+ mapGet := !d.h.MapValueReset && !d.h.InterfaceReset
var mk int16
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int16(dd.DecodeInt(16))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ if mapGet {
+ mv = v[mk]
+ } else {
+ mv = nil
+ }
+ d.decode(&mv)
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- if mapGet {
- mv = v[mk]
- } else {
- mv = nil
- }
- d.decode(&mv)
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int16(dd.DecodeInt(16))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ if mapGet {
+ mv = v[mk]
+ } else {
+ mv = nil
+ }
+ d.decode(&mv)
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapInt16StringR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int16]string)
+ v, changed := fastpathTV.DecMapInt16StringV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt16StringV(rv2i(rv).(map[int16]string), false, d)
+ v := rv.Interface().(map[int16]string)
+ fastpathTV.DecMapInt16StringV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapInt16StringX(vp *map[int16]string, d *Decoder) {
- v, changed := f.DecMapInt16StringV(*vp, true, d)
+func (f fastpathT) DecMapInt16StringX(vp *map[int16]string, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapInt16StringV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt16StringV(v map[int16]string, canChange bool,
+func (_ fastpathT) DecMapInt16StringV(v map[int16]string, checkNil bool, canChange bool,
d *Decoder) (_ map[int16]string, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 18)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 18)
v = make(map[int16]string, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
var mk int16
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] = ""
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int16(dd.DecodeInt(16))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeString()
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeString()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int16(dd.DecodeInt(16))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeString()
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapInt16UintR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int16]uint)
+ v, changed := fastpathTV.DecMapInt16UintV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt16UintV(rv2i(rv).(map[int16]uint), false, d)
+ v := rv.Interface().(map[int16]uint)
+ fastpathTV.DecMapInt16UintV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapInt16UintX(vp *map[int16]uint, d *Decoder) {
- v, changed := f.DecMapInt16UintV(*vp, true, d)
+func (f fastpathT) DecMapInt16UintX(vp *map[int16]uint, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapInt16UintV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt16UintV(v map[int16]uint, canChange bool,
+func (_ fastpathT) DecMapInt16UintV(v map[int16]uint, checkNil bool, canChange bool,
d *Decoder) (_ map[int16]uint, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 10)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 10)
v = make(map[int16]uint, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
var mk int16
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int16(dd.DecodeInt(16))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint(dd.DecodeUint(uintBitsize))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int16(dd.DecodeInt(16))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint(dd.DecodeUint(uintBitsize))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapInt16Uint8R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int16]uint8)
+ v, changed := fastpathTV.DecMapInt16Uint8V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt16Uint8V(rv2i(rv).(map[int16]uint8), false, d)
+ v := rv.Interface().(map[int16]uint8)
+ fastpathTV.DecMapInt16Uint8V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapInt16Uint8X(vp *map[int16]uint8, d *Decoder) {
- v, changed := f.DecMapInt16Uint8V(*vp, true, d)
+func (f fastpathT) DecMapInt16Uint8X(vp *map[int16]uint8, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapInt16Uint8V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt16Uint8V(v map[int16]uint8, canChange bool,
+func (_ fastpathT) DecMapInt16Uint8V(v map[int16]uint8, checkNil bool, canChange bool,
d *Decoder) (_ map[int16]uint8, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 3)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 3)
v = make(map[int16]uint8, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
var mk int16
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int16(dd.DecodeInt(16))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint8(dd.DecodeUint(8))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uint8(chkOvf.UintV(dd.DecodeUint64(), 8))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int16(dd.DecodeInt(16))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint8(dd.DecodeUint(8))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapInt16Uint16R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int16]uint16)
+ v, changed := fastpathTV.DecMapInt16Uint16V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt16Uint16V(rv2i(rv).(map[int16]uint16), false, d)
+ v := rv.Interface().(map[int16]uint16)
+ fastpathTV.DecMapInt16Uint16V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapInt16Uint16X(vp *map[int16]uint16, d *Decoder) {
- v, changed := f.DecMapInt16Uint16V(*vp, true, d)
+func (f fastpathT) DecMapInt16Uint16X(vp *map[int16]uint16, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapInt16Uint16V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt16Uint16V(v map[int16]uint16, canChange bool,
+func (_ fastpathT) DecMapInt16Uint16V(v map[int16]uint16, checkNil bool, canChange bool,
d *Decoder) (_ map[int16]uint16, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 4)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 4)
v = make(map[int16]uint16, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
var mk int16
var mv uint16
- 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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int16(dd.DecodeInt(16))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint16(dd.DecodeUint(16))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uint16(chkOvf.UintV(dd.DecodeUint64(), 16))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int16(dd.DecodeInt(16))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint16(dd.DecodeUint(16))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapInt16Uint32R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int16]uint32)
+ v, changed := fastpathTV.DecMapInt16Uint32V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt16Uint32V(rv2i(rv).(map[int16]uint32), false, d)
+ v := rv.Interface().(map[int16]uint32)
+ fastpathTV.DecMapInt16Uint32V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapInt16Uint32X(vp *map[int16]uint32, d *Decoder) {
- v, changed := f.DecMapInt16Uint32V(*vp, true, d)
+func (f fastpathT) DecMapInt16Uint32X(vp *map[int16]uint32, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapInt16Uint32V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt16Uint32V(v map[int16]uint32, canChange bool,
+func (_ fastpathT) DecMapInt16Uint32V(v map[int16]uint32, checkNil bool, canChange bool,
d *Decoder) (_ map[int16]uint32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 6)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 6)
v = make(map[int16]uint32, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
var mk int16
var mv uint32
- 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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int16(dd.DecodeInt(16))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint32(dd.DecodeUint(32))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uint32(chkOvf.UintV(dd.DecodeUint64(), 32))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int16(dd.DecodeInt(16))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint32(dd.DecodeUint(32))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapInt16Uint64R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int16]uint64)
+ v, changed := fastpathTV.DecMapInt16Uint64V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt16Uint64V(rv2i(rv).(map[int16]uint64), false, d)
+ v := rv.Interface().(map[int16]uint64)
+ fastpathTV.DecMapInt16Uint64V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapInt16Uint64X(vp *map[int16]uint64, d *Decoder) {
- v, changed := f.DecMapInt16Uint64V(*vp, true, d)
+func (f fastpathT) DecMapInt16Uint64X(vp *map[int16]uint64, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapInt16Uint64V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt16Uint64V(v map[int16]uint64, canChange bool,
+func (_ fastpathT) DecMapInt16Uint64V(v map[int16]uint64, checkNil bool, canChange bool,
d *Decoder) (_ map[int16]uint64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 10)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 10)
v = make(map[int16]uint64, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
var mk int16
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] = 0
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int16(dd.DecodeInt(16))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeUint(64)
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeUint64()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int16(dd.DecodeInt(16))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeUint(64)
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapInt16UintptrR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int16]uintptr)
+ v, changed := fastpathTV.DecMapInt16UintptrV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt16UintptrV(rv2i(rv).(map[int16]uintptr), false, d)
+ v := rv.Interface().(map[int16]uintptr)
+ fastpathTV.DecMapInt16UintptrV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapInt16UintptrX(vp *map[int16]uintptr, d *Decoder) {
- v, changed := f.DecMapInt16UintptrV(*vp, true, d)
+func (f fastpathT) DecMapInt16UintptrX(vp *map[int16]uintptr, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapInt16UintptrV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt16UintptrV(v map[int16]uintptr, canChange bool,
+func (_ fastpathT) DecMapInt16UintptrV(v map[int16]uintptr, checkNil bool, canChange bool,
d *Decoder) (_ map[int16]uintptr, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 10)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 10)
v = make(map[int16]uintptr, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
var mk int16
var mv uintptr
- 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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int16(dd.DecodeInt(16))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uintptr(dd.DecodeUint(uintBitsize))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int16(dd.DecodeInt(16))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uintptr(dd.DecodeUint(uintBitsize))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapInt16IntR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int16]int)
+ v, changed := fastpathTV.DecMapInt16IntV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt16IntV(rv2i(rv).(map[int16]int), false, d)
+ v := rv.Interface().(map[int16]int)
+ fastpathTV.DecMapInt16IntV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapInt16IntX(vp *map[int16]int, d *Decoder) {
- v, changed := f.DecMapInt16IntV(*vp, true, d)
+func (f fastpathT) DecMapInt16IntX(vp *map[int16]int, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapInt16IntV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt16IntV(v map[int16]int, canChange bool,
+func (_ fastpathT) DecMapInt16IntV(v map[int16]int, checkNil bool, canChange bool,
d *Decoder) (_ map[int16]int, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 10)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 10)
v = make(map[int16]int, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
var mk int16
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int16(dd.DecodeInt(16))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int(dd.DecodeInt(intBitsize))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int16(dd.DecodeInt(16))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int(dd.DecodeInt(intBitsize))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapInt16Int8R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int16]int8)
+ v, changed := fastpathTV.DecMapInt16Int8V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt16Int8V(rv2i(rv).(map[int16]int8), false, d)
+ v := rv.Interface().(map[int16]int8)
+ fastpathTV.DecMapInt16Int8V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapInt16Int8X(vp *map[int16]int8, d *Decoder) {
- v, changed := f.DecMapInt16Int8V(*vp, true, d)
+func (f fastpathT) DecMapInt16Int8X(vp *map[int16]int8, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapInt16Int8V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt16Int8V(v map[int16]int8, canChange bool,
+func (_ fastpathT) DecMapInt16Int8V(v map[int16]int8, checkNil bool, canChange bool,
d *Decoder) (_ map[int16]int8, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 3)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 3)
v = make(map[int16]int8, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
var mk int16
var mv int8
- 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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int16(dd.DecodeInt(16))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int8(dd.DecodeInt(8))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = int8(chkOvf.IntV(dd.DecodeInt64(), 8))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int16(dd.DecodeInt(16))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int8(dd.DecodeInt(8))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapInt16Int16R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int16]int16)
+ v, changed := fastpathTV.DecMapInt16Int16V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt16Int16V(rv2i(rv).(map[int16]int16), false, d)
+ v := rv.Interface().(map[int16]int16)
+ fastpathTV.DecMapInt16Int16V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapInt16Int16X(vp *map[int16]int16, d *Decoder) {
- v, changed := f.DecMapInt16Int16V(*vp, true, d)
+func (f fastpathT) DecMapInt16Int16X(vp *map[int16]int16, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapInt16Int16V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt16Int16V(v map[int16]int16, canChange bool,
+func (_ fastpathT) DecMapInt16Int16V(v map[int16]int16, checkNil bool, canChange bool,
d *Decoder) (_ map[int16]int16, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 4)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 4)
v = make(map[int16]int16, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
var mk int16
var mv int16
- 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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int16(dd.DecodeInt(16))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int16(dd.DecodeInt(16))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = int16(chkOvf.IntV(dd.DecodeInt64(), 16))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int16(dd.DecodeInt(16))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int16(dd.DecodeInt(16))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapInt16Int32R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int16]int32)
+ v, changed := fastpathTV.DecMapInt16Int32V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt16Int32V(rv2i(rv).(map[int16]int32), false, d)
+ v := rv.Interface().(map[int16]int32)
+ fastpathTV.DecMapInt16Int32V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapInt16Int32X(vp *map[int16]int32, d *Decoder) {
- v, changed := f.DecMapInt16Int32V(*vp, true, d)
+func (f fastpathT) DecMapInt16Int32X(vp *map[int16]int32, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapInt16Int32V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt16Int32V(v map[int16]int32, canChange bool,
+func (_ fastpathT) DecMapInt16Int32V(v map[int16]int32, checkNil bool, canChange bool,
d *Decoder) (_ map[int16]int32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 6)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 6)
v = make(map[int16]int32, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
var mk int16
var mv int32
- 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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int16(dd.DecodeInt(16))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int32(dd.DecodeInt(32))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = int32(chkOvf.IntV(dd.DecodeInt64(), 32))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int16(dd.DecodeInt(16))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int32(dd.DecodeInt(32))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapInt16Int64R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int16]int64)
+ v, changed := fastpathTV.DecMapInt16Int64V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt16Int64V(rv2i(rv).(map[int16]int64), false, d)
+ v := rv.Interface().(map[int16]int64)
+ fastpathTV.DecMapInt16Int64V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapInt16Int64X(vp *map[int16]int64, d *Decoder) {
- v, changed := f.DecMapInt16Int64V(*vp, true, d)
+func (f fastpathT) DecMapInt16Int64X(vp *map[int16]int64, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapInt16Int64V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt16Int64V(v map[int16]int64, canChange bool,
+func (_ fastpathT) DecMapInt16Int64V(v map[int16]int64, checkNil bool, canChange bool,
d *Decoder) (_ map[int16]int64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 10)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 10)
v = make(map[int16]int64, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
var mk int16
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int16(dd.DecodeInt(16))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeInt(64)
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeInt64()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int16(dd.DecodeInt(16))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeInt(64)
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapInt16Float32R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int16]float32)
+ v, changed := fastpathTV.DecMapInt16Float32V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt16Float32V(rv2i(rv).(map[int16]float32), false, d)
+ v := rv.Interface().(map[int16]float32)
+ fastpathTV.DecMapInt16Float32V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapInt16Float32X(vp *map[int16]float32, d *Decoder) {
- v, changed := f.DecMapInt16Float32V(*vp, true, d)
+func (f fastpathT) DecMapInt16Float32X(vp *map[int16]float32, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapInt16Float32V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt16Float32V(v map[int16]float32, canChange bool,
+func (_ fastpathT) DecMapInt16Float32V(v map[int16]float32, checkNil bool, canChange bool,
d *Decoder) (_ map[int16]float32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 6)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 6)
v = make(map[int16]float32, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
var mk int16
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int16(dd.DecodeInt(16))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = float32(dd.DecodeFloat(true))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = float32(chkOvf.Float32V(dd.DecodeFloat64()))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int16(dd.DecodeInt(16))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = float32(dd.DecodeFloat(true))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapInt16Float64R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int16]float64)
+ v, changed := fastpathTV.DecMapInt16Float64V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt16Float64V(rv2i(rv).(map[int16]float64), false, d)
+ v := rv.Interface().(map[int16]float64)
+ fastpathTV.DecMapInt16Float64V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapInt16Float64X(vp *map[int16]float64, d *Decoder) {
- v, changed := f.DecMapInt16Float64V(*vp, true, d)
+func (f fastpathT) DecMapInt16Float64X(vp *map[int16]float64, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapInt16Float64V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt16Float64V(v map[int16]float64, canChange bool,
+func (_ fastpathT) DecMapInt16Float64V(v map[int16]float64, checkNil bool, canChange bool,
d *Decoder) (_ map[int16]float64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 10)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 10)
v = make(map[int16]float64, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
var mk int16
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int16(dd.DecodeInt(16))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeFloat(false)
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeFloat64()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int16(dd.DecodeInt(16))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeFloat(false)
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapInt16BoolR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int16]bool)
+ v, changed := fastpathTV.DecMapInt16BoolV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt16BoolV(rv2i(rv).(map[int16]bool), false, d)
+ v := rv.Interface().(map[int16]bool)
+ fastpathTV.DecMapInt16BoolV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapInt16BoolX(vp *map[int16]bool, d *Decoder) {
- v, changed := f.DecMapInt16BoolV(*vp, true, d)
+func (f fastpathT) DecMapInt16BoolX(vp *map[int16]bool, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapInt16BoolV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt16BoolV(v map[int16]bool, canChange bool,
+func (_ fastpathT) DecMapInt16BoolV(v map[int16]bool, checkNil bool, canChange bool,
d *Decoder) (_ map[int16]bool, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 3)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 3)
v = make(map[int16]bool, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
var mk int16
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] = false
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int16(dd.DecodeInt(16))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeBool()
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeBool()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int16(dd.DecodeInt(16))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeBool()
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapInt32IntfR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int32]interface{})
+ v, changed := fastpathTV.DecMapInt32IntfV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt32IntfV(rv2i(rv).(map[int32]interface{}), false, d)
+ v := rv.Interface().(map[int32]interface{})
+ fastpathTV.DecMapInt32IntfV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapInt32IntfX(vp *map[int32]interface{}, d *Decoder) {
- v, changed := f.DecMapInt32IntfV(*vp, true, d)
+func (f fastpathT) DecMapInt32IntfX(vp *map[int32]interface{}, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapInt32IntfV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt32IntfV(v map[int32]interface{}, canChange bool,
+func (_ fastpathT) DecMapInt32IntfV(v map[int32]interface{}, checkNil bool, canChange bool,
d *Decoder) (_ map[int32]interface{}, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 20)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 20)
v = make(map[int32]interface{}, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset
+ mapGet := !d.h.MapValueReset && !d.h.InterfaceReset
var mk int32
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] = nil
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int32(dd.DecodeInt(32))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ if mapGet {
+ mv = v[mk]
+ } else {
+ mv = nil
+ }
+ d.decode(&mv)
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- if mapGet {
- mv = v[mk]
- } else {
- mv = nil
- }
- d.decode(&mv)
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int32(dd.DecodeInt(32))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ if mapGet {
+ mv = v[mk]
+ } else {
+ mv = nil
+ }
+ d.decode(&mv)
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapInt32StringR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int32]string)
+ v, changed := fastpathTV.DecMapInt32StringV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt32StringV(rv2i(rv).(map[int32]string), false, d)
+ v := rv.Interface().(map[int32]string)
+ fastpathTV.DecMapInt32StringV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapInt32StringX(vp *map[int32]string, d *Decoder) {
- v, changed := f.DecMapInt32StringV(*vp, true, d)
+func (f fastpathT) DecMapInt32StringX(vp *map[int32]string, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapInt32StringV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt32StringV(v map[int32]string, canChange bool,
+func (_ fastpathT) DecMapInt32StringV(v map[int32]string, checkNil bool, canChange bool,
d *Decoder) (_ map[int32]string, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 20)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 20)
v = make(map[int32]string, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
var mk int32
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] = ""
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int32(dd.DecodeInt(32))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeString()
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeString()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int32(dd.DecodeInt(32))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeString()
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapInt32UintR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int32]uint)
+ v, changed := fastpathTV.DecMapInt32UintV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt32UintV(rv2i(rv).(map[int32]uint), false, d)
+ v := rv.Interface().(map[int32]uint)
+ fastpathTV.DecMapInt32UintV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapInt32UintX(vp *map[int32]uint, d *Decoder) {
- v, changed := f.DecMapInt32UintV(*vp, true, d)
+func (f fastpathT) DecMapInt32UintX(vp *map[int32]uint, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapInt32UintV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt32UintV(v map[int32]uint, canChange bool,
+func (_ fastpathT) DecMapInt32UintV(v map[int32]uint, checkNil bool, canChange bool,
d *Decoder) (_ map[int32]uint, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12)
v = make(map[int32]uint, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
var mk int32
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int32(dd.DecodeInt(32))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint(dd.DecodeUint(uintBitsize))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int32(dd.DecodeInt(32))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint(dd.DecodeUint(uintBitsize))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapInt32Uint8R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int32]uint8)
+ v, changed := fastpathTV.DecMapInt32Uint8V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt32Uint8V(rv2i(rv).(map[int32]uint8), false, d)
+ v := rv.Interface().(map[int32]uint8)
+ fastpathTV.DecMapInt32Uint8V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapInt32Uint8X(vp *map[int32]uint8, d *Decoder) {
- v, changed := f.DecMapInt32Uint8V(*vp, true, d)
+func (f fastpathT) DecMapInt32Uint8X(vp *map[int32]uint8, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapInt32Uint8V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt32Uint8V(v map[int32]uint8, canChange bool,
+func (_ fastpathT) DecMapInt32Uint8V(v map[int32]uint8, checkNil bool, canChange bool,
d *Decoder) (_ map[int32]uint8, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 5)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 5)
v = make(map[int32]uint8, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
var mk int32
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int32(dd.DecodeInt(32))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint8(dd.DecodeUint(8))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uint8(chkOvf.UintV(dd.DecodeUint64(), 8))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int32(dd.DecodeInt(32))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint8(dd.DecodeUint(8))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapInt32Uint16R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int32]uint16)
+ v, changed := fastpathTV.DecMapInt32Uint16V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt32Uint16V(rv2i(rv).(map[int32]uint16), false, d)
+ v := rv.Interface().(map[int32]uint16)
+ fastpathTV.DecMapInt32Uint16V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapInt32Uint16X(vp *map[int32]uint16, d *Decoder) {
- v, changed := f.DecMapInt32Uint16V(*vp, true, d)
+func (f fastpathT) DecMapInt32Uint16X(vp *map[int32]uint16, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapInt32Uint16V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt32Uint16V(v map[int32]uint16, canChange bool,
+func (_ fastpathT) DecMapInt32Uint16V(v map[int32]uint16, checkNil bool, canChange bool,
d *Decoder) (_ map[int32]uint16, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 6)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 6)
v = make(map[int32]uint16, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
var mk int32
var mv uint16
- 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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int32(dd.DecodeInt(32))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint16(dd.DecodeUint(16))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uint16(chkOvf.UintV(dd.DecodeUint64(), 16))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int32(dd.DecodeInt(32))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint16(dd.DecodeUint(16))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapInt32Uint32R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int32]uint32)
+ v, changed := fastpathTV.DecMapInt32Uint32V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt32Uint32V(rv2i(rv).(map[int32]uint32), false, d)
+ v := rv.Interface().(map[int32]uint32)
+ fastpathTV.DecMapInt32Uint32V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapInt32Uint32X(vp *map[int32]uint32, d *Decoder) {
- v, changed := f.DecMapInt32Uint32V(*vp, true, d)
+func (f fastpathT) DecMapInt32Uint32X(vp *map[int32]uint32, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapInt32Uint32V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt32Uint32V(v map[int32]uint32, canChange bool,
+func (_ fastpathT) DecMapInt32Uint32V(v map[int32]uint32, checkNil bool, canChange bool,
d *Decoder) (_ map[int32]uint32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 8)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 8)
v = make(map[int32]uint32, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
var mk int32
var mv uint32
- 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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int32(dd.DecodeInt(32))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint32(dd.DecodeUint(32))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uint32(chkOvf.UintV(dd.DecodeUint64(), 32))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int32(dd.DecodeInt(32))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint32(dd.DecodeUint(32))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapInt32Uint64R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int32]uint64)
+ v, changed := fastpathTV.DecMapInt32Uint64V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt32Uint64V(rv2i(rv).(map[int32]uint64), false, d)
+ v := rv.Interface().(map[int32]uint64)
+ fastpathTV.DecMapInt32Uint64V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapInt32Uint64X(vp *map[int32]uint64, d *Decoder) {
- v, changed := f.DecMapInt32Uint64V(*vp, true, d)
+func (f fastpathT) DecMapInt32Uint64X(vp *map[int32]uint64, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapInt32Uint64V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt32Uint64V(v map[int32]uint64, canChange bool,
+func (_ fastpathT) DecMapInt32Uint64V(v map[int32]uint64, checkNil bool, canChange bool,
d *Decoder) (_ map[int32]uint64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12)
v = make(map[int32]uint64, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
var mk int32
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int32(dd.DecodeInt(32))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeUint(64)
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeUint64()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int32(dd.DecodeInt(32))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeUint(64)
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapInt32UintptrR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int32]uintptr)
+ v, changed := fastpathTV.DecMapInt32UintptrV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt32UintptrV(rv2i(rv).(map[int32]uintptr), false, d)
+ v := rv.Interface().(map[int32]uintptr)
+ fastpathTV.DecMapInt32UintptrV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapInt32UintptrX(vp *map[int32]uintptr, d *Decoder) {
- v, changed := f.DecMapInt32UintptrV(*vp, true, d)
+func (f fastpathT) DecMapInt32UintptrX(vp *map[int32]uintptr, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapInt32UintptrV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt32UintptrV(v map[int32]uintptr, canChange bool,
+func (_ fastpathT) DecMapInt32UintptrV(v map[int32]uintptr, checkNil bool, canChange bool,
d *Decoder) (_ map[int32]uintptr, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12)
v = make(map[int32]uintptr, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
var mk int32
var mv uintptr
- 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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int32(dd.DecodeInt(32))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uintptr(dd.DecodeUint(uintBitsize))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int32(dd.DecodeInt(32))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uintptr(dd.DecodeUint(uintBitsize))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapInt32IntR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int32]int)
+ v, changed := fastpathTV.DecMapInt32IntV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt32IntV(rv2i(rv).(map[int32]int), false, d)
+ v := rv.Interface().(map[int32]int)
+ fastpathTV.DecMapInt32IntV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapInt32IntX(vp *map[int32]int, d *Decoder) {
- v, changed := f.DecMapInt32IntV(*vp, true, d)
+func (f fastpathT) DecMapInt32IntX(vp *map[int32]int, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapInt32IntV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt32IntV(v map[int32]int, canChange bool,
+func (_ fastpathT) DecMapInt32IntV(v map[int32]int, checkNil bool, canChange bool,
d *Decoder) (_ map[int32]int, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12)
v = make(map[int32]int, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
var mk int32
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int32(dd.DecodeInt(32))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int(dd.DecodeInt(intBitsize))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int32(dd.DecodeInt(32))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int(dd.DecodeInt(intBitsize))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapInt32Int8R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int32]int8)
+ v, changed := fastpathTV.DecMapInt32Int8V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt32Int8V(rv2i(rv).(map[int32]int8), false, d)
+ v := rv.Interface().(map[int32]int8)
+ fastpathTV.DecMapInt32Int8V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapInt32Int8X(vp *map[int32]int8, d *Decoder) {
- v, changed := f.DecMapInt32Int8V(*vp, true, d)
+func (f fastpathT) DecMapInt32Int8X(vp *map[int32]int8, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapInt32Int8V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt32Int8V(v map[int32]int8, canChange bool,
+func (_ fastpathT) DecMapInt32Int8V(v map[int32]int8, checkNil bool, canChange bool,
d *Decoder) (_ map[int32]int8, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 5)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 5)
v = make(map[int32]int8, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
var mk int32
var mv int8
- 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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int32(dd.DecodeInt(32))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int8(dd.DecodeInt(8))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = int8(chkOvf.IntV(dd.DecodeInt64(), 8))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int32(dd.DecodeInt(32))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int8(dd.DecodeInt(8))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapInt32Int16R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int32]int16)
+ v, changed := fastpathTV.DecMapInt32Int16V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt32Int16V(rv2i(rv).(map[int32]int16), false, d)
+ v := rv.Interface().(map[int32]int16)
+ fastpathTV.DecMapInt32Int16V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapInt32Int16X(vp *map[int32]int16, d *Decoder) {
- v, changed := f.DecMapInt32Int16V(*vp, true, d)
+func (f fastpathT) DecMapInt32Int16X(vp *map[int32]int16, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapInt32Int16V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt32Int16V(v map[int32]int16, canChange bool,
+func (_ fastpathT) DecMapInt32Int16V(v map[int32]int16, checkNil bool, canChange bool,
d *Decoder) (_ map[int32]int16, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 6)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 6)
v = make(map[int32]int16, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
var mk int32
var mv int16
- 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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int32(dd.DecodeInt(32))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int16(dd.DecodeInt(16))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = int16(chkOvf.IntV(dd.DecodeInt64(), 16))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int32(dd.DecodeInt(32))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int16(dd.DecodeInt(16))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapInt32Int32R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int32]int32)
+ v, changed := fastpathTV.DecMapInt32Int32V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt32Int32V(rv2i(rv).(map[int32]int32), false, d)
+ v := rv.Interface().(map[int32]int32)
+ fastpathTV.DecMapInt32Int32V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapInt32Int32X(vp *map[int32]int32, d *Decoder) {
- v, changed := f.DecMapInt32Int32V(*vp, true, d)
+func (f fastpathT) DecMapInt32Int32X(vp *map[int32]int32, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapInt32Int32V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt32Int32V(v map[int32]int32, canChange bool,
+func (_ fastpathT) DecMapInt32Int32V(v map[int32]int32, checkNil bool, canChange bool,
d *Decoder) (_ map[int32]int32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 8)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 8)
v = make(map[int32]int32, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
var mk int32
var mv int32
- 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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int32(dd.DecodeInt(32))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int32(dd.DecodeInt(32))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = int32(chkOvf.IntV(dd.DecodeInt64(), 32))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int32(dd.DecodeInt(32))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int32(dd.DecodeInt(32))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapInt32Int64R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int32]int64)
+ v, changed := fastpathTV.DecMapInt32Int64V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt32Int64V(rv2i(rv).(map[int32]int64), false, d)
+ v := rv.Interface().(map[int32]int64)
+ fastpathTV.DecMapInt32Int64V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapInt32Int64X(vp *map[int32]int64, d *Decoder) {
- v, changed := f.DecMapInt32Int64V(*vp, true, d)
+func (f fastpathT) DecMapInt32Int64X(vp *map[int32]int64, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapInt32Int64V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt32Int64V(v map[int32]int64, canChange bool,
+func (_ fastpathT) DecMapInt32Int64V(v map[int32]int64, checkNil bool, canChange bool,
d *Decoder) (_ map[int32]int64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12)
v = make(map[int32]int64, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
var mk int32
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int32(dd.DecodeInt(32))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeInt(64)
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeInt64()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int32(dd.DecodeInt(32))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeInt(64)
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapInt32Float32R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int32]float32)
+ v, changed := fastpathTV.DecMapInt32Float32V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt32Float32V(rv2i(rv).(map[int32]float32), false, d)
+ v := rv.Interface().(map[int32]float32)
+ fastpathTV.DecMapInt32Float32V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapInt32Float32X(vp *map[int32]float32, d *Decoder) {
- v, changed := f.DecMapInt32Float32V(*vp, true, d)
+func (f fastpathT) DecMapInt32Float32X(vp *map[int32]float32, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapInt32Float32V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt32Float32V(v map[int32]float32, canChange bool,
+func (_ fastpathT) DecMapInt32Float32V(v map[int32]float32, checkNil bool, canChange bool,
d *Decoder) (_ map[int32]float32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 8)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 8)
v = make(map[int32]float32, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
var mk int32
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int32(dd.DecodeInt(32))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = float32(dd.DecodeFloat(true))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = float32(chkOvf.Float32V(dd.DecodeFloat64()))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int32(dd.DecodeInt(32))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = float32(dd.DecodeFloat(true))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapInt32Float64R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int32]float64)
+ v, changed := fastpathTV.DecMapInt32Float64V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt32Float64V(rv2i(rv).(map[int32]float64), false, d)
+ v := rv.Interface().(map[int32]float64)
+ fastpathTV.DecMapInt32Float64V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapInt32Float64X(vp *map[int32]float64, d *Decoder) {
- v, changed := f.DecMapInt32Float64V(*vp, true, d)
+func (f fastpathT) DecMapInt32Float64X(vp *map[int32]float64, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapInt32Float64V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt32Float64V(v map[int32]float64, canChange bool,
+func (_ fastpathT) DecMapInt32Float64V(v map[int32]float64, checkNil bool, canChange bool,
d *Decoder) (_ map[int32]float64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12)
v = make(map[int32]float64, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
var mk int32
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int32(dd.DecodeInt(32))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeFloat(false)
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeFloat64()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int32(dd.DecodeInt(32))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeFloat(false)
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapInt32BoolR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int32]bool)
+ v, changed := fastpathTV.DecMapInt32BoolV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt32BoolV(rv2i(rv).(map[int32]bool), false, d)
+ v := rv.Interface().(map[int32]bool)
+ fastpathTV.DecMapInt32BoolV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapInt32BoolX(vp *map[int32]bool, d *Decoder) {
- v, changed := f.DecMapInt32BoolV(*vp, true, d)
+func (f fastpathT) DecMapInt32BoolX(vp *map[int32]bool, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapInt32BoolV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt32BoolV(v map[int32]bool, canChange bool,
+func (_ fastpathT) DecMapInt32BoolV(v map[int32]bool, checkNil bool, canChange bool,
d *Decoder) (_ map[int32]bool, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 5)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 5)
v = make(map[int32]bool, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
var mk int32
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int32(dd.DecodeInt(32))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeBool()
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeBool()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = int32(dd.DecodeInt(32))
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeBool()
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapInt64IntfR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int64]interface{})
+ v, changed := fastpathTV.DecMapInt64IntfV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt64IntfV(rv2i(rv).(map[int64]interface{}), false, d)
+ v := rv.Interface().(map[int64]interface{})
+ fastpathTV.DecMapInt64IntfV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapInt64IntfX(vp *map[int64]interface{}, d *Decoder) {
- v, changed := f.DecMapInt64IntfV(*vp, true, d)
+func (f fastpathT) DecMapInt64IntfX(vp *map[int64]interface{}, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapInt64IntfV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt64IntfV(v map[int64]interface{}, canChange bool,
+func (_ fastpathT) DecMapInt64IntfV(v map[int64]interface{}, checkNil bool, canChange bool,
d *Decoder) (_ map[int64]interface{}, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 24)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 24)
v = make(map[int64]interface{}, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset
+ mapGet := !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.DecodeInt64()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = nil
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeInt(64)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ if mapGet {
+ mv = v[mk]
+ } else {
+ mv = nil
+ }
+ d.decode(&mv)
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- if mapGet {
- mv = v[mk]
- } else {
- mv = nil
- }
- d.decode(&mv)
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeInt(64)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ if mapGet {
+ mv = v[mk]
+ } else {
+ mv = nil
+ }
+ d.decode(&mv)
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapInt64StringR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int64]string)
+ v, changed := fastpathTV.DecMapInt64StringV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt64StringV(rv2i(rv).(map[int64]string), false, d)
+ v := rv.Interface().(map[int64]string)
+ fastpathTV.DecMapInt64StringV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapInt64StringX(vp *map[int64]string, d *Decoder) {
- v, changed := f.DecMapInt64StringV(*vp, true, d)
+func (f fastpathT) DecMapInt64StringX(vp *map[int64]string, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapInt64StringV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt64StringV(v map[int64]string, canChange bool,
+func (_ fastpathT) DecMapInt64StringV(v map[int64]string, checkNil bool, canChange bool,
d *Decoder) (_ map[int64]string, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 24)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 24)
v = make(map[int64]string, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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.DecodeInt64()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = ""
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeInt(64)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeString()
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeString()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeInt(64)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeString()
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapInt64UintR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int64]uint)
+ v, changed := fastpathTV.DecMapInt64UintV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt64UintV(rv2i(rv).(map[int64]uint), false, d)
+ v := rv.Interface().(map[int64]uint)
+ fastpathTV.DecMapInt64UintV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapInt64UintX(vp *map[int64]uint, d *Decoder) {
- v, changed := f.DecMapInt64UintV(*vp, true, d)
+func (f fastpathT) DecMapInt64UintX(vp *map[int64]uint, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapInt64UintV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt64UintV(v map[int64]uint, canChange bool,
+func (_ fastpathT) DecMapInt64UintV(v map[int64]uint, checkNil bool, canChange bool,
d *Decoder) (_ map[int64]uint, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16)
v = make(map[int64]uint, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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.DecodeInt64()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeInt(64)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint(dd.DecodeUint(uintBitsize))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeInt(64)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint(dd.DecodeUint(uintBitsize))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapInt64Uint8R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int64]uint8)
+ v, changed := fastpathTV.DecMapInt64Uint8V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt64Uint8V(rv2i(rv).(map[int64]uint8), false, d)
+ v := rv.Interface().(map[int64]uint8)
+ fastpathTV.DecMapInt64Uint8V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapInt64Uint8X(vp *map[int64]uint8, d *Decoder) {
- v, changed := f.DecMapInt64Uint8V(*vp, true, d)
+func (f fastpathT) DecMapInt64Uint8X(vp *map[int64]uint8, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapInt64Uint8V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt64Uint8V(v map[int64]uint8, canChange bool,
+func (_ fastpathT) DecMapInt64Uint8V(v map[int64]uint8, checkNil bool, canChange bool,
d *Decoder) (_ map[int64]uint8, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9)
v = make(map[int64]uint8, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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.DecodeInt64()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeInt(64)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint8(dd.DecodeUint(8))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uint8(chkOvf.UintV(dd.DecodeUint64(), 8))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeInt(64)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint8(dd.DecodeUint(8))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapInt64Uint16R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int64]uint16)
+ v, changed := fastpathTV.DecMapInt64Uint16V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt64Uint16V(rv2i(rv).(map[int64]uint16), false, d)
+ v := rv.Interface().(map[int64]uint16)
+ fastpathTV.DecMapInt64Uint16V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapInt64Uint16X(vp *map[int64]uint16, d *Decoder) {
- v, changed := f.DecMapInt64Uint16V(*vp, true, d)
+func (f fastpathT) DecMapInt64Uint16X(vp *map[int64]uint16, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapInt64Uint16V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt64Uint16V(v map[int64]uint16, canChange bool,
+func (_ fastpathT) DecMapInt64Uint16V(v map[int64]uint16, checkNil bool, canChange bool,
d *Decoder) (_ map[int64]uint16, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 10)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 10)
v = make(map[int64]uint16, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
var mk int64
var mv uint16
- 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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeInt(64)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint16(dd.DecodeUint(16))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uint16(chkOvf.UintV(dd.DecodeUint64(), 16))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeInt(64)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint16(dd.DecodeUint(16))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapInt64Uint32R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int64]uint32)
+ v, changed := fastpathTV.DecMapInt64Uint32V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt64Uint32V(rv2i(rv).(map[int64]uint32), false, d)
+ v := rv.Interface().(map[int64]uint32)
+ fastpathTV.DecMapInt64Uint32V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapInt64Uint32X(vp *map[int64]uint32, d *Decoder) {
- v, changed := f.DecMapInt64Uint32V(*vp, true, d)
+func (f fastpathT) DecMapInt64Uint32X(vp *map[int64]uint32, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapInt64Uint32V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt64Uint32V(v map[int64]uint32, canChange bool,
+func (_ fastpathT) DecMapInt64Uint32V(v map[int64]uint32, checkNil bool, canChange bool,
d *Decoder) (_ map[int64]uint32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12)
v = make(map[int64]uint32, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
var mk int64
var mv uint32
- 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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeInt(64)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint32(dd.DecodeUint(32))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uint32(chkOvf.UintV(dd.DecodeUint64(), 32))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeInt(64)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint32(dd.DecodeUint(32))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapInt64Uint64R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int64]uint64)
+ v, changed := fastpathTV.DecMapInt64Uint64V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt64Uint64V(rv2i(rv).(map[int64]uint64), false, d)
+ v := rv.Interface().(map[int64]uint64)
+ fastpathTV.DecMapInt64Uint64V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapInt64Uint64X(vp *map[int64]uint64, d *Decoder) {
- v, changed := f.DecMapInt64Uint64V(*vp, true, d)
+func (f fastpathT) DecMapInt64Uint64X(vp *map[int64]uint64, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapInt64Uint64V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt64Uint64V(v map[int64]uint64, canChange bool,
+func (_ fastpathT) DecMapInt64Uint64V(v map[int64]uint64, checkNil bool, canChange bool,
d *Decoder) (_ map[int64]uint64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16)
v = make(map[int64]uint64, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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.DecodeInt64()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeInt(64)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeUint(64)
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeUint64()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeInt(64)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeUint(64)
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapInt64UintptrR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int64]uintptr)
+ v, changed := fastpathTV.DecMapInt64UintptrV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt64UintptrV(rv2i(rv).(map[int64]uintptr), false, d)
+ v := rv.Interface().(map[int64]uintptr)
+ fastpathTV.DecMapInt64UintptrV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapInt64UintptrX(vp *map[int64]uintptr, d *Decoder) {
- v, changed := f.DecMapInt64UintptrV(*vp, true, d)
+func (f fastpathT) DecMapInt64UintptrX(vp *map[int64]uintptr, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapInt64UintptrV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt64UintptrV(v map[int64]uintptr, canChange bool,
+func (_ fastpathT) DecMapInt64UintptrV(v map[int64]uintptr, checkNil bool, canChange bool,
d *Decoder) (_ map[int64]uintptr, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16)
v = make(map[int64]uintptr, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
var mk int64
var mv uintptr
- 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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeInt(64)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uintptr(dd.DecodeUint(uintBitsize))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeInt(64)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uintptr(dd.DecodeUint(uintBitsize))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapInt64IntR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int64]int)
+ v, changed := fastpathTV.DecMapInt64IntV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt64IntV(rv2i(rv).(map[int64]int), false, d)
+ v := rv.Interface().(map[int64]int)
+ fastpathTV.DecMapInt64IntV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapInt64IntX(vp *map[int64]int, d *Decoder) {
- v, changed := f.DecMapInt64IntV(*vp, true, d)
+func (f fastpathT) DecMapInt64IntX(vp *map[int64]int, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapInt64IntV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt64IntV(v map[int64]int, canChange bool,
+func (_ fastpathT) DecMapInt64IntV(v map[int64]int, checkNil bool, canChange bool,
d *Decoder) (_ map[int64]int, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16)
v = make(map[int64]int, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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.DecodeInt64()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeInt(64)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int(dd.DecodeInt(intBitsize))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeInt(64)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int(dd.DecodeInt(intBitsize))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapInt64Int8R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int64]int8)
+ v, changed := fastpathTV.DecMapInt64Int8V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt64Int8V(rv2i(rv).(map[int64]int8), false, d)
+ v := rv.Interface().(map[int64]int8)
+ fastpathTV.DecMapInt64Int8V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapInt64Int8X(vp *map[int64]int8, d *Decoder) {
- v, changed := f.DecMapInt64Int8V(*vp, true, d)
+func (f fastpathT) DecMapInt64Int8X(vp *map[int64]int8, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapInt64Int8V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt64Int8V(v map[int64]int8, canChange bool,
+func (_ fastpathT) DecMapInt64Int8V(v map[int64]int8, checkNil bool, canChange bool,
d *Decoder) (_ map[int64]int8, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9)
v = make(map[int64]int8, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
var mk int64
var mv int8
- 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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeInt(64)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int8(dd.DecodeInt(8))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = int8(chkOvf.IntV(dd.DecodeInt64(), 8))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeInt(64)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int8(dd.DecodeInt(8))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapInt64Int16R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int64]int16)
+ v, changed := fastpathTV.DecMapInt64Int16V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt64Int16V(rv2i(rv).(map[int64]int16), false, d)
+ v := rv.Interface().(map[int64]int16)
+ fastpathTV.DecMapInt64Int16V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapInt64Int16X(vp *map[int64]int16, d *Decoder) {
- v, changed := f.DecMapInt64Int16V(*vp, true, d)
+func (f fastpathT) DecMapInt64Int16X(vp *map[int64]int16, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapInt64Int16V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt64Int16V(v map[int64]int16, canChange bool,
+func (_ fastpathT) DecMapInt64Int16V(v map[int64]int16, checkNil bool, canChange bool,
d *Decoder) (_ map[int64]int16, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 10)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 10)
v = make(map[int64]int16, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
var mk int64
var mv int16
- 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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeInt(64)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int16(dd.DecodeInt(16))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = int16(chkOvf.IntV(dd.DecodeInt64(), 16))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeInt(64)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int16(dd.DecodeInt(16))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapInt64Int32R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int64]int32)
+ v, changed := fastpathTV.DecMapInt64Int32V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt64Int32V(rv2i(rv).(map[int64]int32), false, d)
+ v := rv.Interface().(map[int64]int32)
+ fastpathTV.DecMapInt64Int32V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapInt64Int32X(vp *map[int64]int32, d *Decoder) {
- v, changed := f.DecMapInt64Int32V(*vp, true, d)
+func (f fastpathT) DecMapInt64Int32X(vp *map[int64]int32, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapInt64Int32V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt64Int32V(v map[int64]int32, canChange bool,
+func (_ fastpathT) DecMapInt64Int32V(v map[int64]int32, checkNil bool, canChange bool,
d *Decoder) (_ map[int64]int32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12)
v = make(map[int64]int32, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
var mk int64
var mv int32
- 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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeInt(64)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int32(dd.DecodeInt(32))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = int32(chkOvf.IntV(dd.DecodeInt64(), 32))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeInt(64)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int32(dd.DecodeInt(32))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapInt64Int64R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int64]int64)
+ v, changed := fastpathTV.DecMapInt64Int64V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt64Int64V(rv2i(rv).(map[int64]int64), false, d)
+ v := rv.Interface().(map[int64]int64)
+ fastpathTV.DecMapInt64Int64V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapInt64Int64X(vp *map[int64]int64, d *Decoder) {
- v, changed := f.DecMapInt64Int64V(*vp, true, d)
+func (f fastpathT) DecMapInt64Int64X(vp *map[int64]int64, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapInt64Int64V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt64Int64V(v map[int64]int64, canChange bool,
+func (_ fastpathT) DecMapInt64Int64V(v map[int64]int64, checkNil bool, canChange bool,
d *Decoder) (_ map[int64]int64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16)
v = make(map[int64]int64, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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.DecodeInt64()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeInt(64)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeInt(64)
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeInt64()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeInt(64)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeInt(64)
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapInt64Float32R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int64]float32)
+ v, changed := fastpathTV.DecMapInt64Float32V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt64Float32V(rv2i(rv).(map[int64]float32), false, d)
+ v := rv.Interface().(map[int64]float32)
+ fastpathTV.DecMapInt64Float32V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapInt64Float32X(vp *map[int64]float32, d *Decoder) {
- v, changed := f.DecMapInt64Float32V(*vp, true, d)
+func (f fastpathT) DecMapInt64Float32X(vp *map[int64]float32, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapInt64Float32V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt64Float32V(v map[int64]float32, canChange bool,
+func (_ fastpathT) DecMapInt64Float32V(v map[int64]float32, checkNil bool, canChange bool,
d *Decoder) (_ map[int64]float32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 12)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 12)
v = make(map[int64]float32, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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.DecodeInt64()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeInt(64)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = float32(dd.DecodeFloat(true))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = float32(chkOvf.Float32V(dd.DecodeFloat64()))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeInt(64)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = float32(dd.DecodeFloat(true))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapInt64Float64R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int64]float64)
+ v, changed := fastpathTV.DecMapInt64Float64V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt64Float64V(rv2i(rv).(map[int64]float64), false, d)
+ v := rv.Interface().(map[int64]float64)
+ fastpathTV.DecMapInt64Float64V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapInt64Float64X(vp *map[int64]float64, d *Decoder) {
- v, changed := f.DecMapInt64Float64V(*vp, true, d)
+func (f fastpathT) DecMapInt64Float64X(vp *map[int64]float64, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapInt64Float64V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt64Float64V(v map[int64]float64, canChange bool,
+func (_ fastpathT) DecMapInt64Float64V(v map[int64]float64, checkNil bool, canChange bool,
d *Decoder) (_ map[int64]float64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 16)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 16)
v = make(map[int64]float64, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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.DecodeInt64()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = 0
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeInt(64)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeFloat(false)
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeFloat64()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeInt(64)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeFloat(false)
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapInt64BoolR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[int64]bool)
+ v, changed := fastpathTV.DecMapInt64BoolV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapInt64BoolV(rv2i(rv).(map[int64]bool), false, d)
+ v := rv.Interface().(map[int64]bool)
+ fastpathTV.DecMapInt64BoolV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapInt64BoolX(vp *map[int64]bool, d *Decoder) {
- v, changed := f.DecMapInt64BoolV(*vp, true, d)
+func (f fastpathT) DecMapInt64BoolX(vp *map[int64]bool, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapInt64BoolV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapInt64BoolV(v map[int64]bool, canChange bool,
+func (_ fastpathT) DecMapInt64BoolV(v map[int64]bool, checkNil bool, canChange bool,
d *Decoder) (_ map[int64]bool, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9)
v = make(map[int64]bool, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
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.DecodeInt64()
- if esep {
- dd.ReadMapElemValue()
- }
- if dd.TryDecodeAsNil() {
- if v == nil {
- } else if d.h.DeleteOnNilMapValue {
- delete(v, mk)
- } else {
- v[mk] = false
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeInt(64)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeBool()
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeBool()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeInt(64)
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeBool()
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapBoolIntfR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[bool]interface{})
+ v, changed := fastpathTV.DecMapBoolIntfV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapBoolIntfV(rv2i(rv).(map[bool]interface{}), false, d)
+ v := rv.Interface().(map[bool]interface{})
+ fastpathTV.DecMapBoolIntfV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapBoolIntfX(vp *map[bool]interface{}, d *Decoder) {
- v, changed := f.DecMapBoolIntfV(*vp, true, d)
+func (f fastpathT) DecMapBoolIntfX(vp *map[bool]interface{}, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapBoolIntfV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapBoolIntfV(v map[bool]interface{}, canChange bool,
+func (_ fastpathT) DecMapBoolIntfV(v map[bool]interface{}, checkNil bool, canChange bool,
d *Decoder) (_ map[bool]interface{}, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 17)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 17)
v = make(map[bool]interface{}, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset
+ mapGet := !d.h.MapValueReset && !d.h.InterfaceReset
var mk bool
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] = nil
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeBool()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ if mapGet {
+ mv = v[mk]
+ } else {
+ mv = nil
+ }
+ d.decode(&mv)
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- if mapGet {
- mv = v[mk]
- } else {
- mv = nil
- }
- d.decode(&mv)
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeBool()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ if mapGet {
+ mv = v[mk]
+ } else {
+ mv = nil
+ }
+ d.decode(&mv)
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapBoolStringR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[bool]string)
+ v, changed := fastpathTV.DecMapBoolStringV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapBoolStringV(rv2i(rv).(map[bool]string), false, d)
+ v := rv.Interface().(map[bool]string)
+ fastpathTV.DecMapBoolStringV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapBoolStringX(vp *map[bool]string, d *Decoder) {
- v, changed := f.DecMapBoolStringV(*vp, true, d)
+func (f fastpathT) DecMapBoolStringX(vp *map[bool]string, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapBoolStringV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapBoolStringV(v map[bool]string, canChange bool,
+func (_ fastpathT) DecMapBoolStringV(v map[bool]string, checkNil bool, canChange bool,
d *Decoder) (_ map[bool]string, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 17)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 17)
v = make(map[bool]string, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
var mk bool
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] = ""
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeBool()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeString()
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeString()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeBool()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeString()
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapBoolUintR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[bool]uint)
+ v, changed := fastpathTV.DecMapBoolUintV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapBoolUintV(rv2i(rv).(map[bool]uint), false, d)
+ v := rv.Interface().(map[bool]uint)
+ fastpathTV.DecMapBoolUintV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapBoolUintX(vp *map[bool]uint, d *Decoder) {
- v, changed := f.DecMapBoolUintV(*vp, true, d)
+func (f fastpathT) DecMapBoolUintX(vp *map[bool]uint, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapBoolUintV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapBoolUintV(v map[bool]uint, canChange bool,
+func (_ fastpathT) DecMapBoolUintV(v map[bool]uint, checkNil bool, canChange bool,
d *Decoder) (_ map[bool]uint, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9)
v = make(map[bool]uint, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
var mk bool
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeBool()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint(dd.DecodeUint(uintBitsize))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uint(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeBool()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint(dd.DecodeUint(uintBitsize))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapBoolUint8R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[bool]uint8)
+ v, changed := fastpathTV.DecMapBoolUint8V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapBoolUint8V(rv2i(rv).(map[bool]uint8), false, d)
+ v := rv.Interface().(map[bool]uint8)
+ fastpathTV.DecMapBoolUint8V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapBoolUint8X(vp *map[bool]uint8, d *Decoder) {
- v, changed := f.DecMapBoolUint8V(*vp, true, d)
+func (f fastpathT) DecMapBoolUint8X(vp *map[bool]uint8, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapBoolUint8V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapBoolUint8V(v map[bool]uint8, canChange bool,
+func (_ fastpathT) DecMapBoolUint8V(v map[bool]uint8, checkNil bool, canChange bool,
d *Decoder) (_ map[bool]uint8, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 2)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 2)
v = make(map[bool]uint8, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
var mk bool
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeBool()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint8(dd.DecodeUint(8))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uint8(chkOvf.UintV(dd.DecodeUint64(), 8))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeBool()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint8(dd.DecodeUint(8))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapBoolUint16R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[bool]uint16)
+ v, changed := fastpathTV.DecMapBoolUint16V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapBoolUint16V(rv2i(rv).(map[bool]uint16), false, d)
+ v := rv.Interface().(map[bool]uint16)
+ fastpathTV.DecMapBoolUint16V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapBoolUint16X(vp *map[bool]uint16, d *Decoder) {
- v, changed := f.DecMapBoolUint16V(*vp, true, d)
+func (f fastpathT) DecMapBoolUint16X(vp *map[bool]uint16, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapBoolUint16V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapBoolUint16V(v map[bool]uint16, canChange bool,
+func (_ fastpathT) DecMapBoolUint16V(v map[bool]uint16, checkNil bool, canChange bool,
d *Decoder) (_ map[bool]uint16, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 3)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 3)
v = make(map[bool]uint16, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
var mk bool
var mv uint16
- 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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeBool()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint16(dd.DecodeUint(16))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uint16(chkOvf.UintV(dd.DecodeUint64(), 16))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeBool()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint16(dd.DecodeUint(16))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapBoolUint32R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[bool]uint32)
+ v, changed := fastpathTV.DecMapBoolUint32V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapBoolUint32V(rv2i(rv).(map[bool]uint32), false, d)
+ v := rv.Interface().(map[bool]uint32)
+ fastpathTV.DecMapBoolUint32V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapBoolUint32X(vp *map[bool]uint32, d *Decoder) {
- v, changed := f.DecMapBoolUint32V(*vp, true, d)
+func (f fastpathT) DecMapBoolUint32X(vp *map[bool]uint32, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapBoolUint32V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapBoolUint32V(v map[bool]uint32, canChange bool,
+func (_ fastpathT) DecMapBoolUint32V(v map[bool]uint32, checkNil bool, canChange bool,
d *Decoder) (_ map[bool]uint32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 5)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 5)
v = make(map[bool]uint32, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
var mk bool
var mv uint32
- 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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeBool()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint32(dd.DecodeUint(32))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uint32(chkOvf.UintV(dd.DecodeUint64(), 32))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeBool()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uint32(dd.DecodeUint(32))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapBoolUint64R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[bool]uint64)
+ v, changed := fastpathTV.DecMapBoolUint64V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapBoolUint64V(rv2i(rv).(map[bool]uint64), false, d)
+ v := rv.Interface().(map[bool]uint64)
+ fastpathTV.DecMapBoolUint64V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapBoolUint64X(vp *map[bool]uint64, d *Decoder) {
- v, changed := f.DecMapBoolUint64V(*vp, true, d)
+func (f fastpathT) DecMapBoolUint64X(vp *map[bool]uint64, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapBoolUint64V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapBoolUint64V(v map[bool]uint64, canChange bool,
+func (_ fastpathT) DecMapBoolUint64V(v map[bool]uint64, checkNil bool, canChange bool,
d *Decoder) (_ map[bool]uint64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9)
v = make(map[bool]uint64, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
var mk bool
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeBool()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeUint(64)
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeUint64()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeBool()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeUint(64)
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapBoolUintptrR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[bool]uintptr)
+ v, changed := fastpathTV.DecMapBoolUintptrV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapBoolUintptrV(rv2i(rv).(map[bool]uintptr), false, d)
+ v := rv.Interface().(map[bool]uintptr)
+ fastpathTV.DecMapBoolUintptrV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapBoolUintptrX(vp *map[bool]uintptr, d *Decoder) {
- v, changed := f.DecMapBoolUintptrV(*vp, true, d)
+func (f fastpathT) DecMapBoolUintptrX(vp *map[bool]uintptr, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapBoolUintptrV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapBoolUintptrV(v map[bool]uintptr, canChange bool,
+func (_ fastpathT) DecMapBoolUintptrV(v map[bool]uintptr, checkNil bool, canChange bool,
d *Decoder) (_ map[bool]uintptr, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9)
v = make(map[bool]uintptr, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
var mk bool
var mv uintptr
- 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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeBool()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uintptr(dd.DecodeUint(uintBitsize))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeBool()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = uintptr(dd.DecodeUint(uintBitsize))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapBoolIntR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[bool]int)
+ v, changed := fastpathTV.DecMapBoolIntV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapBoolIntV(rv2i(rv).(map[bool]int), false, d)
+ v := rv.Interface().(map[bool]int)
+ fastpathTV.DecMapBoolIntV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapBoolIntX(vp *map[bool]int, d *Decoder) {
- v, changed := f.DecMapBoolIntV(*vp, true, d)
+func (f fastpathT) DecMapBoolIntX(vp *map[bool]int, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapBoolIntV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapBoolIntV(v map[bool]int, canChange bool,
+func (_ fastpathT) DecMapBoolIntV(v map[bool]int, checkNil bool, canChange bool,
d *Decoder) (_ map[bool]int, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9)
v = make(map[bool]int, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
var mk bool
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeBool()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int(dd.DecodeInt(intBitsize))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = int(chkOvf.IntV(dd.DecodeInt64(), intBitsize))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeBool()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int(dd.DecodeInt(intBitsize))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapBoolInt8R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[bool]int8)
+ v, changed := fastpathTV.DecMapBoolInt8V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapBoolInt8V(rv2i(rv).(map[bool]int8), false, d)
+ v := rv.Interface().(map[bool]int8)
+ fastpathTV.DecMapBoolInt8V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapBoolInt8X(vp *map[bool]int8, d *Decoder) {
- v, changed := f.DecMapBoolInt8V(*vp, true, d)
+func (f fastpathT) DecMapBoolInt8X(vp *map[bool]int8, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapBoolInt8V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapBoolInt8V(v map[bool]int8, canChange bool,
+func (_ fastpathT) DecMapBoolInt8V(v map[bool]int8, checkNil bool, canChange bool,
d *Decoder) (_ map[bool]int8, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 2)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 2)
v = make(map[bool]int8, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
var mk bool
var mv int8
- 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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeBool()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int8(dd.DecodeInt(8))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = int8(chkOvf.IntV(dd.DecodeInt64(), 8))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeBool()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int8(dd.DecodeInt(8))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapBoolInt16R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[bool]int16)
+ v, changed := fastpathTV.DecMapBoolInt16V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapBoolInt16V(rv2i(rv).(map[bool]int16), false, d)
+ v := rv.Interface().(map[bool]int16)
+ fastpathTV.DecMapBoolInt16V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapBoolInt16X(vp *map[bool]int16, d *Decoder) {
- v, changed := f.DecMapBoolInt16V(*vp, true, d)
+func (f fastpathT) DecMapBoolInt16X(vp *map[bool]int16, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapBoolInt16V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapBoolInt16V(v map[bool]int16, canChange bool,
+func (_ fastpathT) DecMapBoolInt16V(v map[bool]int16, checkNil bool, canChange bool,
d *Decoder) (_ map[bool]int16, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 3)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 3)
v = make(map[bool]int16, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
var mk bool
var mv int16
- 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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeBool()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int16(dd.DecodeInt(16))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = int16(chkOvf.IntV(dd.DecodeInt64(), 16))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeBool()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int16(dd.DecodeInt(16))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapBoolInt32R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[bool]int32)
+ v, changed := fastpathTV.DecMapBoolInt32V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapBoolInt32V(rv2i(rv).(map[bool]int32), false, d)
+ v := rv.Interface().(map[bool]int32)
+ fastpathTV.DecMapBoolInt32V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapBoolInt32X(vp *map[bool]int32, d *Decoder) {
- v, changed := f.DecMapBoolInt32V(*vp, true, d)
+func (f fastpathT) DecMapBoolInt32X(vp *map[bool]int32, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapBoolInt32V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapBoolInt32V(v map[bool]int32, canChange bool,
+func (_ fastpathT) DecMapBoolInt32V(v map[bool]int32, checkNil bool, canChange bool,
d *Decoder) (_ map[bool]int32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 5)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 5)
v = make(map[bool]int32, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
var mk bool
var mv int32
- 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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeBool()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int32(dd.DecodeInt(32))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = int32(chkOvf.IntV(dd.DecodeInt64(), 32))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeBool()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = int32(dd.DecodeInt(32))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapBoolInt64R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[bool]int64)
+ v, changed := fastpathTV.DecMapBoolInt64V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapBoolInt64V(rv2i(rv).(map[bool]int64), false, d)
+ v := rv.Interface().(map[bool]int64)
+ fastpathTV.DecMapBoolInt64V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapBoolInt64X(vp *map[bool]int64, d *Decoder) {
- v, changed := f.DecMapBoolInt64V(*vp, true, d)
+func (f fastpathT) DecMapBoolInt64X(vp *map[bool]int64, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapBoolInt64V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapBoolInt64V(v map[bool]int64, canChange bool,
+func (_ fastpathT) DecMapBoolInt64V(v map[bool]int64, checkNil bool, canChange bool,
d *Decoder) (_ map[bool]int64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9)
v = make(map[bool]int64, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
var mk bool
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeBool()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeInt(64)
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeInt64()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeBool()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeInt(64)
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapBoolFloat32R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[bool]float32)
+ v, changed := fastpathTV.DecMapBoolFloat32V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapBoolFloat32V(rv2i(rv).(map[bool]float32), false, d)
+ v := rv.Interface().(map[bool]float32)
+ fastpathTV.DecMapBoolFloat32V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapBoolFloat32X(vp *map[bool]float32, d *Decoder) {
- v, changed := f.DecMapBoolFloat32V(*vp, true, d)
+func (f fastpathT) DecMapBoolFloat32X(vp *map[bool]float32, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapBoolFloat32V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapBoolFloat32V(v map[bool]float32, canChange bool,
+func (_ fastpathT) DecMapBoolFloat32V(v map[bool]float32, checkNil bool, canChange bool,
d *Decoder) (_ map[bool]float32, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 5)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 5)
v = make(map[bool]float32, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
var mk bool
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeBool()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = float32(dd.DecodeFloat(true))
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = float32(chkOvf.Float32V(dd.DecodeFloat64()))
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeBool()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = float32(dd.DecodeFloat(true))
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapBoolFloat64R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[bool]float64)
+ v, changed := fastpathTV.DecMapBoolFloat64V(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapBoolFloat64V(rv2i(rv).(map[bool]float64), false, d)
+ v := rv.Interface().(map[bool]float64)
+ fastpathTV.DecMapBoolFloat64V(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapBoolFloat64X(vp *map[bool]float64, d *Decoder) {
- v, changed := f.DecMapBoolFloat64V(*vp, true, d)
+func (f fastpathT) DecMapBoolFloat64X(vp *map[bool]float64, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapBoolFloat64V(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapBoolFloat64V(v map[bool]float64, canChange bool,
+func (_ fastpathT) DecMapBoolFloat64V(v map[bool]float64, checkNil bool, canChange bool,
d *Decoder) (_ map[bool]float64, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 9)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 9)
v = make(map[bool]float64, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
var mk bool
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeBool()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeFloat(false)
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeFloat64()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeBool()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeFloat(false)
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
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)
+func (f *decFnInfo) fastpathDecMapBoolBoolR(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[bool]bool)
+ v, changed := fastpathTV.DecMapBoolBoolV(*vp, fastpathCheckNilFalse, true, f.d)
if changed {
*vp = v
}
} else {
- fastpathTV.DecMapBoolBoolV(rv2i(rv).(map[bool]bool), false, d)
+ v := rv.Interface().(map[bool]bool)
+ fastpathTV.DecMapBoolBoolV(v, fastpathCheckNilFalse, false, f.d)
}
}
-func (f fastpathT) DecMapBoolBoolX(vp *map[bool]bool, d *Decoder) {
- v, changed := f.DecMapBoolBoolV(*vp, true, d)
+func (f fastpathT) DecMapBoolBoolX(vp *map[bool]bool, checkNil bool, d *Decoder) {
+ v, changed := f.DecMapBoolBoolV(*vp, checkNil, true, d)
if changed {
*vp = v
}
}
-func (_ fastpathT) DecMapBoolBoolV(v map[bool]bool, canChange bool,
+func (_ fastpathT) DecMapBoolBoolV(v map[bool]bool, checkNil bool, canChange bool,
d *Decoder) (_ map[bool]bool, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators()
+ dd := d.d
+ cr := d.cr
+
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, 2)
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, 2)
v = make(map[bool]bool, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
+
var mk bool
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
+ if containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeBool()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeBool()
+ if v != nil {
+ v[mk] = mv
}
- continue
}
- mv = dd.DecodeBool()
- if v != nil {
- v[mk] = mv
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil {
+ cr.sendContainerState(containerMapKey)
+ }
+ mk = dd.DecodeBool()
+ if cr != nil {
+ cr.sendContainerState(containerMapValue)
+ }
+ mv = dd.DecodeBool()
+ if v != nil {
+ v[mk] = mv
+ }
}
}
- dd.ReadMapEnd()
+ if cr != nil {
+ cr.sendContainerState(containerMapEnd)
+ }
return v, changed
}
diff --git a/vendor/github.com/ugorji/go/codec/fast-path.go.tmpl b/vendor/github.com/ugorji/go/codec/fast-path.go.tmpl
index 2023e05d38..c3ffdf93d9 100644
--- a/vendor/github.com/ugorji/go/codec/fast-path.go.tmpl
+++ b/vendor/github.com/ugorji/go/codec/fast-path.go.tmpl
@@ -3,7 +3,10 @@
// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved.
// Use of this source code is governed by a MIT license found in the LICENSE file.
-// Code generated from fast-path.go.tmpl - DO NOT EDIT.
+// ************************************************************
+// DO NOT EDIT.
+// THIS FILE IS AUTO-GENERATED from fast-path.go.tmpl
+// ************************************************************
package codec
@@ -15,19 +18,19 @@ package codec
// This file can be omitted without causing a build failure.
//
// The advantage of fast paths is:
-// - Many calls bypass reflection altogether
+// - 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,
+// - map of all builtin types to string or interface value
+// - symmetrical maps of all builtin types (e.g. str-str, uint8-uint8)
// This should provide adequate "typical" implementations.
//
// Note that fast track decode functions must handle values for which an address cannot be obtained.
// For example:
-// m2 := map[string]int{}
-// p2 := []interface{}{m2}
-// // decoding into p2 will bomb if fast track functions do not treat like unaddressable.
+// m2 := map[string]int{}
+// p2 := []interface{}{m2}
+// // decoding into p2 will bomb if fast track functions do not treat like unaddressable.
//
import (
@@ -37,6 +40,9 @@ import (
const fastpathEnabled = true
+const fastpathCheckNilFalse = false // for reflect
+const fastpathCheckNilTrue = true // for type switch
+
type fastpathT struct {}
var fastpathTV fastpathT
@@ -44,8 +50,8 @@ var fastpathTV fastpathT
type fastpathE struct {
rtid uintptr
rt reflect.Type
- encfn func(*Encoder, *codecFnInfo, reflect.Value)
- decfn func(*Decoder, *codecFnInfo, reflect.Value)
+ encfn func(*encFnInfo, reflect.Value)
+ decfn func(*decFnInfo, reflect.Value)
}
type fastpathA [{{ .FastpathLen }}]fastpathE
@@ -78,21 +84,19 @@ var fastpathAV fastpathA
// due to possible initialization loop error, make fastpath in an init()
func init() {
i := 0
- fn := func(v interface{},
- fe func(*Encoder, *codecFnInfo, reflect.Value),
- fd func(*Decoder, *codecFnInfo, reflect.Value)) (f fastpathE) {
+ fn := func(v interface{}, fe func(*encFnInfo, reflect.Value), fd func(*decFnInfo, reflect.Value)) (f fastpathE) {
xrt := reflect.TypeOf(v)
- xptr := rt2id(xrt)
+ xptr := reflect.ValueOf(xrt).Pointer()
fastpathAV[i] = fastpathE{xptr, xrt, fe, fd}
i++
return
}
- {{/* 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 }}
+ fn([]{{ .Elem }}(nil), (*encFnInfo).{{ .MethodNamePfx "fastpathEnc" false }}R, (*decFnInfo).{{ .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}}
+ fn(map[{{ .MapKey }}]{{ .Elem }}(nil), (*encFnInfo).{{ .MethodNamePfx "fastpathEnc" false }}R, (*decFnInfo).{{ .MethodNamePfx "fastpathDec" false }}R){{end}}{{end}}{{end}}
sort.Sort(fastpathAslice(fastpathAV[:]))
}
@@ -102,47 +106,31 @@ 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"}}
- case []{{ .Elem }}:
- fastpathTV.{{ .MethodNamePfx "Enc" false }}V(v, e)
- case *[]{{ .Elem }}:
- fastpathTV.{{ .MethodNamePfx "Enc" false }}V(*v, e){{/*
-*/}}{{end}}{{end}}{{end}}{{end}}
-
-{{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}}
-
+{{range .Values}}{{if not .Primitive}}{{if not .MapKey }}
+ case []{{ .Elem }}:{{else}}
+ case map[{{ .MapKey }}]{{ .Elem }}:{{end}}
+ fastpathTV.{{ .MethodNamePfx "Enc" false }}V(v, fastpathCheckNilTrue, e){{if not .MapKey }}
+ case *[]{{ .Elem }}:{{else}}
+ case *map[{{ .MapKey }}]{{ .Elem }}:{{end}}
+ fastpathTV.{{ .MethodNamePfx "Enc" false }}V(*v, fastpathCheckNilTrue, e)
+{{end}}{{end}}
default:
- _ = v // workaround https://github.com/golang/go/issues/12927 seen in go1.4
+ _ = v // TODO: workaround https://github.com/golang/go/issues/12927 (remove after go 1.6 release)
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)
+ fastpathTV.{{ .MethodNamePfx "Enc" false }}V(v, fastpathCheckNilTrue, e)
case *[]{{ .Elem }}:
- fastpathTV.{{ .MethodNamePfx "Enc" false }}V(*v, e)
+ fastpathTV.{{ .MethodNamePfx "Enc" false }}V(*v, fastpathCheckNilTrue, e)
{{end}}{{end}}{{end}}
default:
- _ = v // workaround https://github.com/golang/go/issues/12927 seen in go1.4
+ _ = v // TODO: workaround https://github.com/golang/go/issues/12927 (remove after go 1.6 release)
return false
}
return true
@@ -152,99 +140,84 @@ 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)
+ fastpathTV.{{ .MethodNamePfx "Enc" false }}V(v, fastpathCheckNilTrue, e)
case *map[{{ .MapKey }}]{{ .Elem }}:
- fastpathTV.{{ .MethodNamePfx "Enc" false }}V(*v, e)
+ fastpathTV.{{ .MethodNamePfx "Enc" false }}V(*v, fastpathCheckNilTrue, e)
{{end}}{{end}}{{end}}
default:
- _ = v // workaround https://github.com/golang/go/issues/12927 seen in go1.4
+ _ = v // TODO: workaround https://github.com/golang/go/issues/12927 (remove after go 1.6 release)
return false
}
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 }}
-func (e *Encoder) {{ .MethodNamePfx "fastpathEnc" false }}R(f *codecFnInfo, rv reflect.Value) {
+
+func (f *encFnInfo) {{ .MethodNamePfx "fastpathEnc" false }}R(rv reflect.Value) {
if f.ti.mbs {
- fastpathTV.{{ .MethodNamePfx "EncAsMap" false }}V(rv2i(rv).([]{{ .Elem }}), e)
+ fastpathTV.{{ .MethodNamePfx "EncAsMap" false }}V(rv.Interface().([]{{ .Elem }}), fastpathCheckNilFalse, f.e)
} else {
- fastpathTV.{{ .MethodNamePfx "Enc" false }}V(rv2i(rv).([]{{ .Elem }}), e)
+ fastpathTV.{{ .MethodNamePfx "Enc" false }}V(rv.Interface().([]{{ .Elem }}), fastpathCheckNilFalse, f.e)
}
}
-func (_ fastpathT) {{ .MethodNamePfx "Enc" false }}V(v []{{ .Elem }}, e *Encoder) {
- if v == nil { e.e.EncodeNil(); return }
- ee, esep := e.e, e.hh.hasElemSeparators()
- ee.WriteArrayStart(len(v))
- if esep {
- for _, v2 := range v {
- ee.WriteArrayElem()
- {{ encmd .Elem "v2"}}
- }
- } else {
- for _, v2 := range v {
- {{ encmd .Elem "v2"}}
- }
- } {{/*
+func (_ fastpathT) {{ .MethodNamePfx "Enc" false }}V(v []{{ .Elem }}, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeArrayStart(len(v))
for _, v2 := range v {
- if esep { ee.WriteArrayElem() }
+ if cr != nil { cr.sendContainerState(containerArrayElem) }
{{ encmd .Elem "v2"}}
- } */}}
- ee.WriteArrayEnd()
+ }
+ if cr != nil { cr.sendContainerState(containerArrayEnd) }{{/* ee.EncodeEnd() */}}
}
-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 }}, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
if len(v)%2 == 1 {
e.errorf("mapBySlice requires even slice length, but got %v", len(v))
return
}
- ee.WriteMapStart(len(v) / 2)
- if esep {
- for j, v2 := range v {
- if j%2 == 0 {
- ee.WriteMapElemKey()
- } else {
- ee.WriteMapElemValue()
- }
- {{ encmd .Elem "v2"}}
- }
- } else {
- for _, v2 := range v {
- {{ encmd .Elem "v2"}}
- }
- } {{/*
+ ee.EncodeMapStart(len(v) / 2)
for j, v2 := range v {
- if esep {
+ if cr != nil {
if j%2 == 0 {
- ee.WriteMapElemKey()
+ cr.sendContainerState(containerMapKey)
} else {
- ee.WriteMapElemValue()
+ cr.sendContainerState(containerMapValue)
}
}
{{ encmd .Elem "v2"}}
- } */}}
- ee.WriteMapEnd()
+ }
+ if cr != nil { cr.sendContainerState(containerMapEnd) }
}
+
{{end}}{{end}}{{end}}
{{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 (f *encFnInfo) {{ .MethodNamePfx "fastpathEnc" false }}R(rv reflect.Value) {
+ fastpathTV.{{ .MethodNamePfx "Enc" false }}V(rv.Interface().(map[{{ .MapKey }}]{{ .Elem }}), fastpathCheckNilFalse, f.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 {
+func (_ fastpathT) {{ .MethodNamePfx "Enc" false }}V(v map[{{ .MapKey }}]{{ .Elem }}, checkNil bool, e *Encoder) {
+ ee := e.e
+ cr := e.cr
+ if checkNil && v == nil {
+ ee.EncodeNil()
+ return
+ }
+ ee.EncodeMapStart(len(v))
+ {{if eq .MapKey "string"}}asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0
+ {{end}}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
e2 := NewEncoderBytes(&mksv, e.hh)
@@ -260,126 +233,63 @@ func (_ fastpathT) {{ .MethodNamePfx "Enc" false }}V(v map[{{ .MapKey }}]{{ .Ele
i++
}
sort.Sort(bytesISlice(v2))
- if esep {
- for j := range v2 {
- ee.WriteMapElemKey()
- e.asis(v2[j].v)
- ee.WriteMapElemValue()
- e.encode(v[v2[j].i])
- }
- } else {
- for j := range v2 {
- e.asis(v2[j].v)
- e.encode(v[v2[j].i])
- }
- } {{/*
for j := range v2 {
- if esep { ee.WriteMapElemKey() }
+ if cr != nil { cr.sendContainerState(containerMapKey) }
e.asis(v2[j].v)
- if esep { ee.WriteMapElemValue() }
+ if cr != nil { cr.sendContainerState(containerMapValue) }
e.encode(v[v2[j].i])
- } */}} {{else}}{{ $x := sorttype .MapKey true}}v2 := make([]{{ $x }}, len(v))
+ } {{else}}{{ $x := sorttype .MapKey true}}v2 := make([]{{ $x }}, len(v))
var i int
for k, _ := range v {
v2[i] = {{ $x }}(k)
i++
}
sort.Sort({{ sorttype .MapKey false}}(v2))
- if esep {
- for _, k2 := range v2 {
- ee.WriteMapElemKey()
- {{if eq .MapKey "string"}}ee.EncodeString(cUTF8, k2){{else}}{{ $y := printf "%s(k2)" .MapKey }}{{ encmd .MapKey $y }}{{end}}
- ee.WriteMapElemValue()
- {{ $y := printf "v[%s(k2)]" .MapKey }}{{ encmd .Elem $y }}
- }
- } else {
- for _, k2 := range v2 {
- {{if eq .MapKey "string"}}ee.EncodeString(cUTF8, k2){{else}}{{ $y := printf "%s(k2)" .MapKey }}{{ encmd .MapKey $y }}{{end}}
- {{ $y := printf "v[%s(k2)]" .MapKey }}{{ encmd .Elem $y }}
- }
- } {{/*
for _, k2 := range v2 {
- if esep { ee.WriteMapElemKey() }
- {{if eq .MapKey "string"}}ee.EncodeString(cUTF8, k2){{else}}{{ $y := printf "%s(k2)" .MapKey }}{{ encmd .MapKey $y }}{{end}}
- if esep { ee.WriteMapElemValue() }
+ if cr != nil { cr.sendContainerState(containerMapKey) }
+ {{if eq .MapKey "string"}}if asSymbols {
+ ee.EncodeSymbol(k2)
+ } else {
+ ee.EncodeString(c_UTF8, k2)
+ }{{else}}{{ $y := printf "%s(k2)" .MapKey }}{{ encmd .MapKey $y }}{{end}}
+ if cr != nil { cr.sendContainerState(containerMapValue) }
{{ $y := printf "v[%s(k2)]" .MapKey }}{{ encmd .Elem $y }}
- } */}} {{end}}
+ } {{end}}
} else {
- if esep {
- for k2, v2 := range v {
- ee.WriteMapElemKey()
- {{if eq .MapKey "string"}}ee.EncodeString(cUTF8, k2){{else}}{{ encmd .MapKey "k2"}}{{end}}
- ee.WriteMapElemValue()
- {{ encmd .Elem "v2"}}
- }
- } else {
- for k2, v2 := range v {
- {{if eq .MapKey "string"}}ee.EncodeString(cUTF8, k2){{else}}{{ encmd .MapKey "k2"}}{{end}}
- {{ encmd .Elem "v2"}}
- }
- } {{/*
for k2, v2 := range v {
- if esep { ee.WriteMapElemKey() }
- {{if eq .MapKey "string"}}ee.EncodeString(cUTF8, k2){{else}}{{ encmd .MapKey "k2"}}{{end}}
- if esep { ee.WriteMapElemValue() }
+ if cr != nil { cr.sendContainerState(containerMapKey) }
+ {{if eq .MapKey "string"}}if asSymbols {
+ ee.EncodeSymbol(k2)
+ } else {
+ ee.EncodeString(c_UTF8, k2)
+ }{{else}}{{ encmd .MapKey "k2"}}{{end}}
+ if cr != nil { cr.sendContainerState(containerMapValue) }
{{ encmd .Elem "v2"}}
- } */}}
+ }
}
- ee.WriteMapEnd()
+ if cr != nil { cr.sendContainerState(containerMapEnd) }{{/* ee.EncodeEnd() */}}
}
+
{{end}}{{end}}{{end}}
// -- decode
// -- -- fast path type switch
func fastpathDecodeTypeSwitch(iv interface{}, d *Decoder) bool {
- var changed bool
- switch v := iv.(type) {
-{{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)
- }
- case *[]{{ .Elem }}:
- var v2 []{{ .Elem }}
- v2, changed = fastpathTV.{{ .MethodNamePfx "Dec" false }}V(*v, true, d)
- if 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)
- 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}}
- 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) {
{{range .Values}}{{if not .Primitive}}{{if not .MapKey }}
- case *[]{{ .Elem }}:
- *v = nil {{/*
-*/}}{{end}}{{end}}{{end}}
-{{range .Values}}{{if not .Primitive}}{{if .MapKey }}
- case *map[{{ .MapKey }}]{{ .Elem }}:
- *v = nil {{/*
-*/}}{{end}}{{end}}{{end}}
+ case []{{ .Elem }}:{{else}}
+ case map[{{ .MapKey }}]{{ .Elem }}:{{end}}
+ fastpathTV.{{ .MethodNamePfx "Dec" false }}V(v, fastpathCheckNilFalse, false, d){{if not .MapKey }}
+ case *[]{{ .Elem }}:{{else}}
+ case *map[{{ .MapKey }}]{{ .Elem }}:{{end}}
+ v2, changed2 := fastpathTV.{{ .MethodNamePfx "Dec" false }}V(*v, fastpathCheckNilFalse, true, d)
+ if changed2 {
+ *v = v2
+ }
+{{end}}{{end}}
default:
- _ = v // workaround https://github.com/golang/go/issues/12927 seen in go1.4
+ _ = v // TODO: workaround https://github.com/golang/go/issues/12927 (remove after go 1.6 release)
return false
}
return true
@@ -393,152 +303,225 @@ Slices can change if they
- 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 {
- vp := rv2i(rv).(*[]{{ .Elem }})
- v, changed := fastpathTV.{{ .MethodNamePfx "Dec" false }}V(*vp, !array, d)
- if changed { *vp = v }
+func (f *decFnInfo) {{ .MethodNamePfx "fastpathDec" false }}R(rv reflect.Value) {
+ array := f.seq == seqTypeArray
+ if !array && rv.CanAddr() { {{/* // CanSet => CanAddr + Exported */}}
+ vp := rv.Addr().Interface().(*[]{{ .Elem }})
+ v, changed := fastpathTV.{{ .MethodNamePfx "Dec" false }}V(*vp, fastpathCheckNilFalse, !array, f.d)
+ if 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)
- }
+ v := rv.Interface().([]{{ .Elem }})
+ fastpathTV.{{ .MethodNamePfx "Dec" false }}V(v, fastpathCheckNilFalse, false, f.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 }
+
+func (f fastpathT) {{ .MethodNamePfx "Dec" false }}X(vp *[]{{ .Elem }}, checkNil bool, d *Decoder) {
+ v, changed := f.{{ .MethodNamePfx "Dec" false }}V(*vp, checkNil, true, d)
+ if 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 }}V(v []{{ .Elem }}, checkNil bool, canChange bool, d *Decoder) (_ []{{ .Elem }}, changed bool) {
+ dd := d.d
+ {{/* // if dd.isContainerType(valueTypeNil) { dd.TryDecodeAsNil() */}}
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
slh, containerLenS := d.decSliceHelperStart()
if containerLenS == 0 {
if canChange {
- if v == nil { v = []{{ .Elem }}{} } else if len(v) != 0 { v = v[:0] }
+ if v == nil {
+ v = []{{ .Elem }}{}
+ } else if len(v) != 0 {
+ v = v[:0]
+ }
changed = true
}
slh.End()
return v, changed
}
- hasLen := containerLenS > 0
- var xlen int
- if hasLen && canChange {
+
+ if containerLenS > 0 {
+ x2read := containerLenS
+ var xtrunc bool
if containerLenS > cap(v) {
- xlen = decInferLen(containerLenS, d.h.MaxInitLen, {{ .Size }})
- if xlen <= cap(v) {
- v = v[:xlen]
- } else {
- v = make([]{{ .Elem }}, xlen)
- }
- changed = true
- } else if containerLenS != len(v) {
- v = v[:containerLenS]
- changed = true
- }
- }
- j := 0
- for ; (hasLen && j < containerLenS) || !(hasLen || dd.CheckBreak()); j++ {
- if j == 0 && len(v) == 0 && canChange {
- if hasLen {
- xlen = decInferLen(containerLenS, d.h.MaxInitLen, {{ .Size }})
- } else {
- xlen = 8
- }
- v = make([]{{ .Elem }}, xlen)
- changed = true
- }
- // if indefinite, etc, then expand the slice if necessary
- var decodeIntoBlank bool
- if j >= len(v) {
- if canChange {
- v = append(v, {{ zerocmd .Elem }})
+ if canChange { {{/*
+ // fast-path is for "basic" immutable types, so no need to copy them over
+ // s := make([]{{ .Elem }}, decInferLen(containerLenS, d.h.MaxInitLen))
+ // copy(s, v[:cap(v)])
+ // v = s */}}
+ var xlen int
+ xlen, xtrunc = decInferLen(containerLenS, d.h.MaxInitLen, {{ .Size }})
+ if xtrunc {
+ if xlen <= cap(v) {
+ v = v[:xlen]
+ } else {
+ v = make([]{{ .Elem }}, xlen)
+ }
+ } else {
+ v = make([]{{ .Elem }}, xlen)
+ }
changed = true
} else {
- d.arrayCannotExpand(len(v), j+1)
- decodeIntoBlank = true
+ d.arrayCannotExpand(len(v), containerLenS)
}
- }
- slh.ElemContainerState(j)
- if decodeIntoBlank {
- d.swallow()
- } else if dd.TryDecodeAsNil() {
- v[j] = {{ zerocmd .Elem }}
- } else {
+ x2read = len(v)
+ } else if containerLenS != len(v) {
+ if canChange {
+ v = v[:containerLenS]
+ changed = true
+ }
+ } {{/* // all checks done. cannot go past len. */}}
+ j := 0
+ for ; j < x2read; j++ {
+ slh.ElemContainerState(j)
{{ if eq .Elem "interface{}" }}d.decode(&v[j]){{ else }}v[j] = {{ decmd .Elem }}{{ end }}
}
- }
- if canChange {
- if j < len(v) {
- v = v[:j]
+ if xtrunc { {{/* // means canChange=true, changed=true already. */}}
+ for ; j < containerLenS; j++ {
+ v = append(v, {{ zerocmd .Elem }})
+ slh.ElemContainerState(j)
+ {{ if eq .Elem "interface{}" }}d.decode(&v[j]){{ else }}v[j] = {{ decmd .Elem }}{{ end }}
+ }
+ } else if !canChange {
+ for ; j < containerLenS; j++ {
+ slh.ElemContainerState(j)
+ d.swallow()
+ }
+ }
+ } else {
+ breakFound := dd.CheckBreak() {{/* check break first, so we can initialize v with a capacity of 4 if necessary */}}
+ if breakFound {
+ if canChange {
+ if v == nil {
+ v = []{{ .Elem }}{}
+ } else if len(v) != 0 {
+ v = v[:0]
+ }
+ changed = true
+ }
+ slh.End()
+ return v, changed
+ }
+ if cap(v) == 0 {
+ v = make([]{{ .Elem }}, 1, 4)
changed = true
- } else if j == 0 && v == nil {
- v = make([]{{ .Elem }}, 0)
+ }
+ j := 0
+ for ; !breakFound; j++ {
+ if j >= len(v) {
+ if canChange {
+ v = append(v, {{ zerocmd .Elem }})
+ changed = true
+ } else {
+ d.arrayCannotExpand(len(v), j+1)
+ }
+ }
+ slh.ElemContainerState(j)
+ if j < len(v) { {{/* // all checks done. cannot go past len. */}}
+ {{ if eq .Elem "interface{}" }}d.decode(&v[j])
+ {{ else }}v[j] = {{ decmd .Elem }}{{ end }}
+ } else {
+ d.swallow()
+ }
+ breakFound = dd.CheckBreak()
+ }
+ if canChange && j < len(v) {
+ v = v[:j]
changed = true
}
}
- slh.End()
+ slh.End()
return v, changed
}
+
{{end}}{{end}}{{end}}
+
{{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 }
+func (f *decFnInfo) {{ .MethodNamePfx "fastpathDec" false }}R(rv reflect.Value) {
+ if rv.CanAddr() {
+ vp := rv.Addr().Interface().(*map[{{ .MapKey }}]{{ .Elem }})
+ v, changed := fastpathTV.{{ .MethodNamePfx "Dec" false }}V(*vp, fastpathCheckNilFalse, true, f.d)
+ if changed {
+ *vp = v
+ }
} else {
- fastpathTV.{{ .MethodNamePfx "Dec" false }}V(rv2i(rv).(map[{{ .MapKey }}]{{ .Elem }}), false, d)
- }
+ v := rv.Interface().(map[{{ .MapKey }}]{{ .Elem }})
+ fastpathTV.{{ .MethodNamePfx "Dec" false }}V(v, fastpathCheckNilFalse, false, f.d)
+ }
}
-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 (f fastpathT) {{ .MethodNamePfx "Dec" false }}X(vp *map[{{ .MapKey }}]{{ .Elem }}, checkNil bool, d *Decoder) {
+ v, changed := f.{{ .MethodNamePfx "Dec" false }}V(*vp, checkNil, true, d)
+ if changed {
+ *vp = v
+ }
}
-func (_ fastpathT) {{ .MethodNamePfx "Dec" false }}V(v map[{{ .MapKey }}]{{ .Elem }}, canChange bool,
+func (_ fastpathT) {{ .MethodNamePfx "Dec" false }}V(v map[{{ .MapKey }}]{{ .Elem }}, checkNil bool, canChange bool,
d *Decoder) (_ map[{{ .MapKey }}]{{ .Elem }}, changed bool) {
- dd, esep := d.d, d.hh.hasElemSeparators(){{/*
- // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil()
- */}}
+ dd := d.d
+ cr := d.cr
+ {{/* // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() */}}
+ if checkNil && dd.TryDecodeAsNil() {
+ if v != nil {
+ changed = true
+ }
+ return nil, changed
+ }
+
containerLen := dd.ReadMapStart()
if canChange && v == nil {
- xlen := decInferLen(containerLen, d.h.MaxInitLen, {{ .Size }})
+ xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, {{ .Size }})
v = make(map[{{ .MapKey }}]{{ .Elem }}, xlen)
changed = true
}
- if containerLen == 0 {
- dd.ReadMapEnd()
- return v, changed
- }
- {{ if eq .Elem "interface{}" }}mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset
- {{end}}var mk {{ .MapKey }}
+ {{ if eq .Elem "interface{}" }}mapGet := !d.h.MapValueReset && !d.h.InterfaceReset{{end}}
+ var mk {{ .MapKey }}
var mv {{ .Elem }}
- hasLen := containerLen > 0
- for j := 0; (hasLen && j < containerLen) || !(hasLen || dd.CheckBreak()); j++ {
- if esep { dd.ReadMapElemKey() }
- {{ 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 containerLen > 0 {
+ for j := 0; j < containerLen; j++ {
+ if cr != nil { cr.sendContainerState(containerMapKey) }
+ {{ 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 cr != nil { cr.sendContainerState(containerMapValue) }
+ {{ if eq .Elem "interface{}" }}if mapGet { mv = v[mk] } else { mv = nil }
+ d.decode(&mv){{ else }}mv = {{ decmd .Elem }}{{ end }}
+ if v != nil {
+ v[mk] = mv
+ }
+ }
+ } else if containerLen < 0 {
+ for j := 0; !dd.CheckBreak(); j++ {
+ if cr != nil { cr.sendContainerState(containerMapKey) }
+ {{ 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 cr != nil { cr.sendContainerState(containerMapValue) }
+ {{ if eq .Elem "interface{}" }}if mapGet { mv = v[mk] } else { mv = nil }
+ d.decode(&mv){{ else }}mv = {{ decmd .Elem }}{{ end }}
+ if v != nil {
+ v[mk] = mv
+ }
}
- {{ if eq .Elem "interface{}" }}if mapGet { mv = v[mk] } else { mv = nil }
- d.decode(&mv){{ else }}mv = {{ decmd .Elem }}{{ end }}
- if v != nil { v[mk] = mv }
}
- dd.ReadMapEnd()
+ if cr != nil { cr.sendContainerState(containerMapEnd) }
return v, changed
}
+
{{end}}{{end}}{{end}}
diff --git a/vendor/github.com/ugorji/go/codec/fast-path.not.go b/vendor/github.com/ugorji/go/codec/fast-path.not.go
index f11b4674f8..63e5911452 100644
--- a/vendor/github.com/ugorji/go/codec/fast-path.not.go
+++ b/vendor/github.com/ugorji/go/codec/fast-path.not.go
@@ -1,6 +1,3 @@
-// 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 notfastpath
package codec
@@ -21,27 +18,17 @@ func fastpathDecodeTypeSwitch(iv interface{}, d *Decoder) bool { return fal
func fastpathEncodeTypeSwitch(iv interface{}, e *Encoder) bool { return false }
func fastpathEncodeTypeSwitchSlice(iv interface{}, e *Encoder) bool { return false }
func fastpathEncodeTypeSwitchMap(iv interface{}, e *Encoder) bool { return false }
-func fastpathDecodeSetZeroTypeSwitch(iv interface{}) bool { return false }
type fastpathT struct{}
type fastpathE struct {
rtid uintptr
rt reflect.Type
- encfn func(*Encoder, *codecFnInfo, reflect.Value)
- decfn func(*Decoder, *codecFnInfo, reflect.Value)
+ encfn func(*encFnInfo, reflect.Value)
+ decfn func(*decFnInfo, reflect.Value)
}
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.cfer().get(uint8SliceTyp, true, true)
- d.kSlice(&fn.i, reflect.ValueOf(&v).Elem())
- return v, true
-}
-
var fastpathAV fastpathA
var fastpathTV fastpathT
-
-// ----
-type TestMammoth2Wrapper struct{} // to allow testMammoth work in notfastpath mode
diff --git a/vendor/github.com/ugorji/go/codec/gen-dec-array.go.tmpl b/vendor/github.com/ugorji/go/codec/gen-dec-array.go.tmpl
index 59c5983698..32df54144c 100644
--- a/vendor/github.com/ugorji/go/codec/gen-dec-array.go.tmpl
+++ b/vendor/github.com/ugorji/go/codec/gen-dec-array.go.tmpl
@@ -9,68 +9,94 @@ if {{var "l"}} == 0 {
} else if len({{var "v"}}) != 0 {
{{var "v"}} = {{var "v"}}[:0]
{{var "c"}} = true
- } {{else if isChan }}if {{var "v"}} == nil {
+ } {{end}} {{if isChan }}if {{var "v"}} == nil {
{{var "v"}} = make({{ .CTyp }}, 0)
{{var "c"}} = true
} {{end}}
-} else {
- {{var "hl"}} := {{var "l"}} > 0
- var {{var "rl"}} int
- _ = {{var "rl"}}
- {{if isSlice }} if {{var "hl"}} {
+} else if {{var "l"}} > 0 {
+ {{if isChan }}if {{var "v"}} == nil {
+ {{var "rl"}}, _ = z.DecInferLen({{var "l"}}, z.DecBasicHandle().MaxInitLen, {{ .Size }})
+ {{var "v"}} = make({{ .CTyp }}, {{var "rl"}})
+ {{var "c"}} = true
+ }
+ for {{var "r"}} := 0; {{var "r"}} < {{var "l"}}; {{var "r"}}++ {
+ {{var "h"}}.ElemContainerState({{var "r"}})
+ var {{var "t"}} {{ .Typ }}
+ {{ $x := printf "%st%s" .TempVar .Rand }}{{ decLineVar $x }}
+ {{var "v"}} <- {{var "t"}}
+ }
+ {{ else }} var {{var "rr"}}, {{var "rl"}} int {{/* // num2read, length of slice/array/chan */}}
+ var {{var "rt"}} bool {{/* truncated */}}
+ _, _ = {{var "rl"}}, {{var "rt"}}
+ {{var "rr"}} = {{var "l"}} // len({{var "v"}})
if {{var "l"}} > cap({{var "v"}}) {
- {{var "rl"}} = z.DecInferLen({{var "l"}}, z.DecBasicHandle().MaxInitLen, {{ .Size }})
- if {{var "rl"}} <= cap({{var "v"}}) {
- {{var "v"}} = {{var "v"}}[:{{var "rl"}}]
+ {{if isArray }}z.DecArrayCannotExpand(len({{var "v"}}), {{var "l"}})
+ {{ else }}{{if not .Immutable }}
+ {{var "rg"}} := len({{var "v"}}) > 0
+ {{var "v2"}} := {{var "v"}} {{end}}
+ {{var "rl"}}, {{var "rt"}} = z.DecInferLen({{var "l"}}, z.DecBasicHandle().MaxInitLen, {{ .Size }})
+ if {{var "rt"}} {
+ if {{var "rl"}} <= cap({{var "v"}}) {
+ {{var "v"}} = {{var "v"}}[:{{var "rl"}}]
+ } else {
+ {{var "v"}} = make([]{{ .Typ }}, {{var "rl"}})
+ }
} else {
{{var "v"}} = make([]{{ .Typ }}, {{var "rl"}})
}
{{var "c"}} = true
- } else if {{var "l"}} != len({{var "v"}}) {
+ {{var "rr"}} = len({{var "v"}}) {{if not .Immutable }}
+ if {{var "rg"}} { copy({{var "v"}}, {{var "v2"}}) } {{end}} {{end}}{{/* end not Immutable, isArray */}}
+ } {{if isSlice }} else if {{var "l"}} != len({{var "v"}}) {
{{var "v"}} = {{var "v"}}[:{{var "l"}}]
{{var "c"}} = true
- }
- } {{end}}
- var {{var "j"}} int
- // var {{var "dn"}} bool
- for ; ({{var "hl"}} && {{var "j"}} < {{var "l"}}) || !({{var "hl"}} || r.CheckBreak()); {{var "j"}}++ {
- {{if not isArray}} if {{var "j"}} == 0 && {{var "v"}} == nil {
- if {{var "hl"}} {
- {{var "rl"}} = z.DecInferLen({{var "l"}}, z.DecBasicHandle().MaxInitLen, {{ .Size }})
- } else {
- {{var "rl"}} = {{if isSlice}}8{{else if isChan}}64{{end}}
- }
- {{var "v"}} = make({{if isSlice}}[]{{ .Typ }}{{else if isChan}}{{.CTyp}}{{end}}, {{var "rl"}})
- {{var "c"}} = true
- }{{end}}
+ } {{end}} {{/* end isSlice:47 */}}
+ {{var "j"}} := 0
+ for ; {{var "j"}} < {{var "rr"}} ; {{var "j"}}++ {
{{var "h"}}.ElemContainerState({{var "j"}})
- {{/* {{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 }}
- {{var "v"}} <- {{ $x }}
- // println(">>>> sending ", {{ $x }}, " into ", {{var "v"}}) // TODO: remove this
- {{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}}
- }
- if {{var "db"}} {
- z.DecSwallow()
- } else {
+ {{ $x := printf "%[1]vv%[2]v[%[1]vj%[2]v]" .TempVar .Rand }}{{ decLineVar $x }}
+ }
+ {{if isArray }}for ; {{var "j"}} < {{var "l"}} ; {{var "j"}}++ {
+ {{var "h"}}.ElemContainerState({{var "j"}})
+ z.DecSwallow()
+ }
+ {{ else }}if {{var "rt"}} {
+ for ; {{var "j"}} < {{var "l"}} ; {{var "j"}}++ {
+ {{var "v"}} = append({{var "v"}}, {{ zero}})
+ {{var "h"}}.ElemContainerState({{var "j"}})
{{ $x := printf "%[1]vv%[2]v[%[1]vj%[2]v]" .TempVar .Rand }}{{ decLineVar $x }}
}
- {{end}}
+ } {{end}} {{/* end isArray:56 */}}
+ {{end}} {{/* end isChan:16 */}}
+} else { {{/* len < 0 */}}
+ {{var "j"}} := 0
+ for ; !r.CheckBreak(); {{var "j"}}++ {
+ {{if isChan }}
+ {{var "h"}}.ElemContainerState({{var "j"}})
+ var {{var "t"}} {{ .Typ }}
+ {{ $x := printf "%st%s" .TempVar .Rand }}{{ decLineVar $x }}
+ {{var "v"}} <- {{var "t"}}
+ {{ else }}
+ if {{var "j"}} >= len({{var "v"}}) {
+ {{if isArray }}z.DecArrayCannotExpand(len({{var "v"}}), {{var "j"}}+1)
+ {{ else }}{{var "v"}} = append({{var "v"}}, {{zero}})// var {{var "z"}} {{ .Typ }}
+ {{var "c"}} = true {{end}}
+ }
+ {{var "h"}}.ElemContainerState({{var "j"}})
+ if {{var "j"}} < len({{var "v"}}) {
+ {{ $x := printf "%[1]vv%[2]v[%[1]vj%[2]v]" .TempVar .Rand }}{{ decLineVar $x }}
+ } else {
+ z.DecSwallow()
+ }
+ {{end}}
}
- {{if isSlice}} if {{var "j"}} < len({{var "v"}}) {
+ {{if isSlice }}if {{var "j"}} < len({{var "v"}}) {
{{var "v"}} = {{var "v"}}[:{{var "j"}}]
{{var "c"}} = true
} else if {{var "j"}} == 0 && {{var "v"}} == nil {
- {{var "v"}} = make([]{{ .Typ }}, 0)
+ {{var "v"}} = []{{ .Typ }}{}
{{var "c"}} = true
- } {{end}}
+ }{{end}}
}
{{var "h"}}.End()
{{if not isArray }}if {{var "c"}} {
diff --git a/vendor/github.com/ugorji/go/codec/gen-dec-map.go.tmpl b/vendor/github.com/ugorji/go/codec/gen-dec-map.go.tmpl
index 8323b54940..77400e0a11 100644
--- a/vendor/github.com/ugorji/go/codec/gen-dec-map.go.tmpl
+++ b/vendor/github.com/ugorji/go/codec/gen-dec-map.go.tmpl
@@ -2,22 +2,21 @@
{{var "l"}} := r.ReadMapStart()
{{var "bh"}} := z.DecBasicHandle()
if {{var "v"}} == nil {
- {{var "rl"}} := z.DecInferLen({{var "l"}}, {{var "bh"}}.MaxInitLen, {{ .Size }})
+ {{var "rl"}}, _ := z.DecInferLen({{var "l"}}, {{var "bh"}}.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
+var {{var "mg"}} {{if decElemKindPtr}}, {{var "ms"}}, {{var "mok"}}{{end}} bool
if {{var "bh"}}.MapValueReset {
{{if decElemKindPtr}}{{var "mg"}} = true
{{else if decElemKindIntf}}if !{{var "bh"}}.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 }}) */}}
+if {{var "l"}} > 0 {
+for {{var "j"}} := 0; {{var "j"}} < {{var "l"}}; {{var "j"}}++ {
+ 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 "mk"}} = string({{var "bv"}})
@@ -29,14 +28,31 @@ if {{var "l"}} != 0 {
{{var "ms"}} = false
} {{else}}{{var "mv"}} = {{var "v"}}[{{var "mk"}}] {{end}}
} {{if not decElemKindImmutable}}else { {{var "mv"}} = {{decElemZero}} }{{end}}
- r.ReadMapElemValue() {{/* z.DecSendContainerState(codecSelfer_containerMapValue{{ .Sfx }}) */}}
- {{var "mdn"}} = false
- {{ $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}} }
- } else if {{if decElemKindPtr}} {{var "ms"}} && {{end}} {{var "v"}} != nil {
+ z.DecSendContainerState(codecSelfer_containerMapValue{{ .Sfx }})
+ {{ $x := printf "%vmv%v" .TempVar .Rand }}{{ decLineVar $x }}
+ if {{if decElemKindPtr}} {{var "ms"}} && {{end}} {{var "v"}} != nil {
+ {{var "v"}}[{{var "mk"}}] = {{var "mv"}}
+ }
+}
+} else if {{var "l"}} < 0 {
+for {{var "j"}} := 0; !r.CheckBreak(); {{var "j"}}++ {
+ 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 "mk"}} = string({{var "bv"}})
+ }{{ end }}{{if decElemKindPtr}}
+ {{var "ms"}} = true {{ end }}
+ if {{var "mg"}} {
+ {{if decElemKindPtr}}{{var "mv"}}, {{var "mok"}} = {{var "v"}}[{{var "mk"}}]
+ if {{var "mok"}} {
+ {{var "ms"}} = false
+ } {{else}}{{var "mv"}} = {{var "v"}}[{{var "mk"}}] {{end}}
+ } {{if not decElemKindImmutable}}else { {{var "mv"}} = {{decElemZero}} }{{end}}
+ z.DecSendContainerState(codecSelfer_containerMapValue{{ .Sfx }})
+ {{ $x := printf "%vmv%v" .TempVar .Rand }}{{ decLineVar $x }}
+ 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.DecSendContainerState(codecSelfer_containerMapEnd{{ .Sfx }})
diff --git a/vendor/github.com/ugorji/go/codec/gen-enc-chan.go.tmpl b/vendor/github.com/ugorji/go/codec/gen-enc-chan.go.tmpl
deleted file mode 100644
index 4249588a3c..0000000000
--- a/vendor/github.com/ugorji/go/codec/gen-enc-chan.go.tmpl
+++ /dev/null
@@ -1,27 +0,0 @@
-{{.Label}}:
-switch timeout{{.Sfx}} := z.EncBasicHandle().ChanRecvTimeout; {
-case timeout{{.Sfx}} == 0: // only consume available
- for {
- select {
- case b{{.Sfx}} := <-{{.Chan}}:
- {{ .Slice }} = append({{.Slice}}, b{{.Sfx}})
- default:
- break {{.Label}}
- }
- }
-case timeout{{.Sfx}} > 0: // consume until timeout
- tt{{.Sfx}} := time.NewTimer(timeout{{.Sfx}})
- for {
- select {
- case b{{.Sfx}} := <-{{.Chan}}:
- {{.Slice}} = append({{.Slice}}, b{{.Sfx}})
- case <-tt{{.Sfx}}.C:
- // close(tt.C)
- break {{.Label}}
- }
- }
-default: // consume until close
- for b{{.Sfx}} := range {{.Chan}} {
- {{.Slice}} = append({{.Slice}}, b{{.Sfx}})
- }
-}
diff --git a/vendor/github.com/ugorji/go/codec/gen-helper.generated.go b/vendor/github.com/ugorji/go/codec/gen-helper.generated.go
index 917d282837..96a6b61d9a 100644
--- a/vendor/github.com/ugorji/go/codec/gen-helper.generated.go
+++ b/vendor/github.com/ugorji/go/codec/gen-helper.generated.go
@@ -1,9 +1,12 @@
-/* // +build ignore */
+// // +build ignore
// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved.
// Use of this source code is governed by a MIT license found in the LICENSE file.
-// Code generated from gen-helper.go.tmpl - DO NOT EDIT.
+// ************************************************************
+// DO NOT EDIT.
+// THIS FILE IS AUTO-GENERATED from gen-helper.go.tmpl
+// ************************************************************
package codec
@@ -12,9 +15,6 @@ import (
"reflect"
)
-// GenVersion is the current version of codecgen.
-const GenVersion = 8
-
// 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.
@@ -26,75 +26,25 @@ const GenVersion = 8
// 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.
-//
// Library users: DO NOT USE IT DIRECTLY. IT WILL CHANGE CONTINOUSLY WITHOUT NOTICE.
-func GenHelperEncoder(e *Encoder) (ge genHelperEncoder, ee genHelperEncDriver) {
- ge = genHelperEncoder{e: e}
- ee = genHelperEncDriver{encDriver: e.e}
- return
+func GenHelperEncoder(e *Encoder) (genHelperEncoder, encDriver) {
+ return genHelperEncoder{e: e}, e.e
}
// GenHelperDecoder is exported so that it can be used externally by codecgen.
-//
// Library users: DO NOT USE IT DIRECTLY. IT WILL CHANGE CONTINOUSLY WITHOUT NOTICE.
-func GenHelperDecoder(d *Decoder) (gd genHelperDecoder, dd genHelperDecDriver) {
- gd = genHelperDecoder{d: d}
- dd = genHelperDecDriver{decDriver: d.d}
- return
-}
-
-type genHelperEncDriver struct {
- encDriver
-}
-
-func (x genHelperEncDriver) EncodeBuiltin(rt uintptr, v interface{}) {}
-func (x genHelperEncDriver) EncStructFieldKey(keyType valueType, s string) {
- encStructFieldKey(x.encDriver, keyType, s)
-}
-func (x genHelperEncDriver) EncodeSymbol(s string) {
- x.encDriver.EncodeString(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
+func GenHelperDecoder(d *Decoder) (genHelperDecoder, decDriver) {
+ return genHelperDecoder{d: d}, d.d
}
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
type genHelperEncoder struct {
- M must
e *Encoder
F fastpathT
}
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
type genHelperDecoder struct {
- C checkOverflow
d *Decoder
F fastpathT
}
@@ -109,86 +59,74 @@ func (f genHelperEncoder) EncBinary() bool {
return f.e.be // f.e.hh.isBinaryEncoding()
}
-// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
-func (f genHelperEncoder) IsJSONHandle() bool {
- return f.e.js
-}
-
// 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.encodeI(iv, false, false)
}
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
func (f genHelperEncoder) EncTextMarshal(iv encoding.TextMarshaler) {
bs, fnerr := iv.MarshalText()
- f.e.marshal(bs, fnerr, false, cUTF8)
+ f.e.marshal(bs, fnerr, false, c_UTF8)
}
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
func (f genHelperEncoder) EncJSONMarshal(iv jsonMarshaler) {
bs, fnerr := iv.MarshalJSON()
- f.e.marshal(bs, fnerr, true, cUTF8)
+ f.e.marshal(bs, fnerr, true, c_UTF8)
}
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
func (f genHelperEncoder) EncBinaryMarshal(iv encoding.BinaryMarshaler) {
bs, fnerr := iv.MarshalBinary()
- f.e.marshal(bs, fnerr, false, cRAW)
+ f.e.marshal(bs, fnerr, false, c_RAW)
}
// 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)
+func (f genHelperEncoder) EncRaw(iv Raw) {
+ f.e.raw(iv)
}
// 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)
+func (f genHelperEncoder) TimeRtidIfBinc() uintptr {
+ if _, ok := f.e.hh.(*BincHandle); ok {
+ return timeTypId
+ }
+ return 0
}
// 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)
+func (f genHelperEncoder) IsJSONHandle() bool {
+ return f.e.js
}
// 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
}
// 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 {
+ rt := reflect.TypeOf(v)
+ if rt.Kind() == reflect.Ptr {
+ rt = rt.Elem()
+ }
+ rtid := reflect.ValueOf(rt).Pointer()
+ if xfFn := f.e.h.getExt(rtid); xfFn != nil {
f.e.e.EncodeExt(v, xfFn.tag, xfFn.ext, f.e)
return true
}
return false
}
+// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
+func (f genHelperEncoder) EncSendContainerState(c containerState) {
+ if f.e.cr != nil {
+ f.e.cr.sendContainerState(c)
+ }
+}
+
// ---------------- DECODER FOLLOWS -----------------
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
@@ -202,27 +140,19 @@ func (f genHelperDecoder) DecBinary() bool {
}
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
-func (f genHelperDecoder) DecSwallow() { f.d.swallow() }
+func (f genHelperDecoder) DecSwallow() {
+ f.d.swallow()
+}
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
func (f genHelperDecoder) DecScratchBuffer() []byte {
return f.d.b[:]
}
-// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
-func (f genHelperDecoder) DecScratchArrayBuffer() *[decScratchByteArrayLen]byte {
- return &f.d.b
-}
-
// 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)
- if chkPtr {
- rv = f.d.ensureDecodeable(rv)
- }
- f.d.decodeValue(rv, nil, false)
- // f.d.decodeValueFallback(rv)
+ f.d.decodeI(iv, chkPtr, false, false, false)
}
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
@@ -242,7 +172,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())
+ fnerr := tm.UnmarshalText(f.d.d.DecodeBytes(f.d.b[:], true, true))
if fnerr != nil {
panic(fnerr)
}
@@ -250,7 +180,7 @@ func (f genHelperDecoder) DecTextUnmarshal(tm encoding.TextUnmarshaler) {
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
func (f genHelperDecoder) DecJSONUnmarshal(tm jsonUnmarshaler) {
- // bs := f.dd.DecodeStringAsBytes()
+ // bs := f.dd.DecodeBytes(f.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(f.d.nextValueBytes())
if fnerr != nil {
@@ -260,28 +190,24 @@ func (f genHelperDecoder) DecJSONUnmarshal(tm jsonUnmarshaler) {
// 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))
+ fnerr := bm.UnmarshalBinary(f.d.d.DecodeBytes(nil, false, true))
if 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() }
+func (f genHelperDecoder) DecRaw() []byte {
+ return f.d.raw()
+}
// 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
-// }
+func (f genHelperDecoder) TimeRtidIfBinc() uintptr {
+ 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 {
@@ -289,34 +215,15 @@ func (f genHelperDecoder) IsJSONHandle() bool {
}
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
-func (f genHelperDecoder) I2Rtid(v interface{}) uintptr {
- return i2rtid(v)
-}
-
-// 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)
-}
-
-// 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 {
+ rt := reflect.TypeOf(v).Elem()
+ rtid := reflect.ValueOf(rt).Pointer()
+ if xfFn := f.d.h.getExt(rtid); xfFn != nil {
f.d.d.DecodeExt(v, xfFn.tag, xfFn.ext)
return true
}
@@ -324,12 +231,13 @@ func (f genHelperDecoder) DecExt(v interface{}) (r bool) {
}
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
-func (f genHelperDecoder) DecInferLen(clen, maxlen, unit int) (rvlen int) {
+func (f genHelperDecoder) DecInferLen(clen, maxlen, unit int) (rvlen int, truncated bool) {
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) }
+func (f genHelperDecoder) DecSendContainerState(c containerState) {
+ if f.d.cr != nil {
+ f.d.cr.sendContainerState(c)
+ }
+}
diff --git a/vendor/github.com/ugorji/go/codec/gen-helper.go.tmpl b/vendor/github.com/ugorji/go/codec/gen-helper.go.tmpl
index 6aeb856501..9b276d4201 100644
--- a/vendor/github.com/ugorji/go/codec/gen-helper.go.tmpl
+++ b/vendor/github.com/ugorji/go/codec/gen-helper.go.tmpl
@@ -1,9 +1,12 @@
-/* // +build ignore */
+// // +build ignore
// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved.
// Use of this source code is governed by a MIT license found in the LICENSE file.
-// Code generated from gen-helper.go.tmpl - DO NOT EDIT.
+// ************************************************************
+// DO NOT EDIT.
+// THIS FILE IS AUTO-GENERATED from gen-helper.go.tmpl
+// ************************************************************
package codec
@@ -12,89 +15,36 @@ import (
"reflect"
)
-// GenVersion is the current version of codecgen.
-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.
-//
// Library users: DO NOT USE IT DIRECTLY. IT WILL CHANGE CONTINOUSLY WITHOUT NOTICE.
-func GenHelperEncoder(e *Encoder) (ge genHelperEncoder, ee genHelperEncDriver) {
- ge = genHelperEncoder{e: e}
- ee = genHelperEncDriver{encDriver: e.e}
- return
+func GenHelperEncoder(e *Encoder) (genHelperEncoder, encDriver) {
+ return genHelperEncoder{e:e}, e.e
}
// GenHelperDecoder is exported so that it can be used externally by codecgen.
-//
// Library users: DO NOT USE IT DIRECTLY. IT WILL CHANGE CONTINOUSLY WITHOUT NOTICE.
-func GenHelperDecoder(d *Decoder) (gd genHelperDecoder, dd genHelperDecDriver) {
- gd = genHelperDecoder{d: d}
- dd = genHelperDecDriver{decDriver: d.d}
- return
-}
-
-type genHelperEncDriver struct {
- encDriver
-}
-
-func (x genHelperEncDriver) EncodeBuiltin(rt uintptr, v interface{}) {}
-func (x genHelperEncDriver) EncStructFieldKey(keyType valueType, s string) {
- encStructFieldKey(x.encDriver, keyType, s)
-}
-func (x genHelperEncDriver) EncodeSymbol(s string) {
- x.encDriver.EncodeString(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
+func GenHelperDecoder(d *Decoder) (genHelperDecoder, decDriver) {
+ return genHelperDecoder{d:d}, d.d
}
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
type genHelperEncoder struct {
- M must
e *Encoder
F fastpathT
}
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
type genHelperDecoder struct {
- C checkOverflow
d *Decoder
F fastpathT
}
@@ -103,78 +53,69 @@ type genHelperDecoder struct {
func (f genHelperEncoder) EncBasicHandle() *BasicHandle {
return f.e.h
}
+
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
func (f genHelperEncoder) EncBinary() bool {
return f.e.be // f.e.hh.isBinaryEncoding()
}
// 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)
+}
+// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
+func (f genHelperEncoder) EncTextMarshal(iv encoding.TextMarshaler) {
+ bs, fnerr := iv.MarshalText()
+ f.e.marshal(bs, fnerr, false, c_UTF8)
+}
+// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
+func (f genHelperEncoder) EncJSONMarshal(iv jsonMarshaler) {
+ bs, fnerr := iv.MarshalJSON()
+ f.e.marshal(bs, fnerr, true, c_UTF8)
+}
+// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
+func (f genHelperEncoder) EncBinaryMarshal(iv encoding.BinaryMarshaler) {
+ bs, fnerr := iv.MarshalBinary()
+ f.e.marshal(bs, fnerr, false, c_RAW)
+}
+// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
+func (f genHelperEncoder) EncRaw(iv Raw) {
+ f.e.raw(iv)
+}
+// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
+func (f genHelperEncoder) TimeRtidIfBinc() uintptr {
+ if _, ok := f.e.hh.(*BincHandle); ok {
+ return timeTypId
+ }
+ return 0
+}
+// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
func (f genHelperEncoder) IsJSONHandle() bool {
return f.e.js
}
// 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)
-}
-// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
-func (f genHelperEncoder) EncTextMarshal(iv encoding.TextMarshaler) {
- bs, fnerr := iv.MarshalText()
- f.e.marshal(bs, fnerr, false, cUTF8)
-}
-// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
-func (f genHelperEncoder) EncJSONMarshal(iv jsonMarshaler) {
- bs, fnerr := iv.MarshalJSON()
- f.e.marshal(bs, fnerr, true, cUTF8)
-}
-// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
-func (f genHelperEncoder) EncBinaryMarshal(iv encoding.BinaryMarshaler) {
- bs, fnerr := iv.MarshalBinary()
- f.e.marshal(bs, fnerr, false, cRAW)
-}
-// 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)
-}
-// 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)
-}
-// 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)
-}
-// 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
}
// 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 {
+ rt := reflect.TypeOf(v)
+ if rt.Kind() == reflect.Ptr {
+ rt = rt.Elem()
+ }
+ rtid := reflect.ValueOf(rt).Pointer()
+ if xfFn := f.e.h.getExt(rtid); xfFn != nil {
f.e.e.EncodeExt(v, xfFn.tag, xfFn.ext, f.e)
return true
}
return false
}
+// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
+func (f genHelperEncoder) EncSendContainerState(c containerState) {
+ if f.e.cr != nil {
+ f.e.cr.sendContainerState(c)
+ }
+}
// ---------------- DECODER FOLLOWS -----------------
@@ -187,24 +128,17 @@ func (f genHelperDecoder) DecBinary() bool {
return f.d.be // f.d.hh.isBinaryEncoding()
}
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
-func (f genHelperDecoder) DecSwallow() { f.d.swallow() }
+func (f genHelperDecoder) DecSwallow() {
+ f.d.swallow()
+}
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
func (f genHelperDecoder) DecScratchBuffer() []byte {
return f.d.b[:]
}
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
-func (f genHelperDecoder) DecScratchArrayBuffer() *[decScratchByteArrayLen]byte {
- return &f.d.b
-}
-// 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)
- if chkPtr {
- rv = f.d.ensureDecodeable(rv)
- }
- f.d.decodeValue(rv, nil, false)
- // f.d.decodeValueFallback(rv)
+ f.d.decodeI(iv, chkPtr, false, false, false)
}
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
func (f genHelperDecoder) DecSliceHelperStart() (decSliceHelper, int) {
@@ -220,14 +154,14 @@ 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())
+ fnerr := tm.UnmarshalText(f.d.d.DecodeBytes(f.d.b[:], true, true))
if fnerr != nil {
panic(fnerr)
}
}
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
func (f genHelperDecoder) DecJSONUnmarshal(tm jsonUnmarshaler) {
- // bs := f.dd.DecodeStringAsBytes()
+ // bs := f.dd.DecodeBytes(f.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(f.d.nextValueBytes())
if fnerr != nil {
@@ -236,67 +170,203 @@ func (f genHelperDecoder) DecJSONUnmarshal(tm jsonUnmarshaler) {
}
// 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))
+ fnerr := bm.UnmarshalBinary(f.d.d.DecodeBytes(nil, false, true))
if 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() }
+func (f genHelperDecoder) DecRaw() []byte {
+ return f.d.raw()
+}
// 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
-// }
-
+func (f genHelperDecoder) TimeRtidIfBinc() uintptr {
+ 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
}
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
-func (f genHelperDecoder) I2Rtid(v interface{}) uintptr {
- return i2rtid(v)
-}
-// 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)
-}
-// 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 {
+ rt := reflect.TypeOf(v).Elem()
+ rtid := reflect.ValueOf(rt).Pointer()
+ if xfFn := f.d.h.getExt(rtid); 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) {
+func (f genHelperDecoder) DecInferLen(clen, maxlen, unit int) (rvlen int, truncated bool) {
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) }
+func (f genHelperDecoder) DecSendContainerState(c containerState) {
+ if f.d.cr != nil {
+ f.d.cr.sendContainerState(c)
+ }
+}
+{{/*
+
+// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
+func (f genHelperEncoder) EncDriver() encDriver {
+ return f.e.e
+}
+// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
+func (f genHelperDecoder) DecDriver() decDriver {
+ return f.d.d
+}
+
+// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
+func (f genHelperEncoder) EncNil() {
+ f.e.e.EncodeNil()
+}
+// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
+func (f genHelperEncoder) EncBytes(v []byte) {
+ f.e.e.EncodeStringBytes(c_RAW, v)
+}
+// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
+func (f genHelperEncoder) EncArrayStart(length int) {
+ f.e.e.EncodeArrayStart(length)
+}
+// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
+func (f genHelperEncoder) EncArrayEnd() {
+ f.e.e.EncodeArrayEnd()
+}
+// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
+func (f genHelperEncoder) EncArrayEntrySeparator() {
+ f.e.e.EncodeArrayEntrySeparator()
+}
+// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
+func (f genHelperEncoder) EncMapStart(length int) {
+ f.e.e.EncodeMapStart(length)
+}
+// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
+func (f genHelperEncoder) EncMapEnd() {
+ f.e.e.EncodeMapEnd()
+}
+// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
+func (f genHelperEncoder) EncMapEntrySeparator() {
+ f.e.e.EncodeMapEntrySeparator()
+}
+// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
+func (f genHelperEncoder) EncMapKVSeparator() {
+ f.e.e.EncodeMapKVSeparator()
+}
+
+// ---------
+
+// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
+func (f genHelperDecoder) DecBytes(v *[]byte) {
+ *v = f.d.d.DecodeBytes(*v)
+}
+// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
+func (f genHelperDecoder) DecTryNil() bool {
+ return f.d.d.TryDecodeAsNil()
+}
+// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
+func (f genHelperDecoder) DecContainerIsNil() (b bool) {
+ return f.d.d.IsContainerType(valueTypeNil)
+}
+// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
+func (f genHelperDecoder) DecContainerIsMap() (b bool) {
+ return f.d.d.IsContainerType(valueTypeMap)
+}
+// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
+func (f genHelperDecoder) DecContainerIsArray() (b bool) {
+ return f.d.d.IsContainerType(valueTypeArray)
+}
+// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
+func (f genHelperDecoder) DecCheckBreak() bool {
+ return f.d.d.CheckBreak()
+}
+// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
+func (f genHelperDecoder) DecMapStart() int {
+ return f.d.d.ReadMapStart()
+}
+// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
+func (f genHelperDecoder) DecArrayStart() int {
+ return f.d.d.ReadArrayStart()
+}
+// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
+func (f genHelperDecoder) DecMapEnd() {
+ f.d.d.ReadMapEnd()
+}
+// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
+func (f genHelperDecoder) DecArrayEnd() {
+ f.d.d.ReadArrayEnd()
+}
+// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
+func (f genHelperDecoder) DecArrayEntrySeparator() {
+ f.d.d.ReadArrayEntrySeparator()
+}
+// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
+func (f genHelperDecoder) DecMapEntrySeparator() {
+ f.d.d.ReadMapEntrySeparator()
+}
+// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
+func (f genHelperDecoder) DecMapKVSeparator() {
+ f.d.d.ReadMapKVSeparator()
+}
+// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
+func (f genHelperDecoder) ReadStringAsBytes(bs []byte) []byte {
+ return f.d.d.DecodeStringAsBytes(bs)
+}
+
+
+// -- encode calls (primitives)
+{{range .Values}}{{if .Primitive }}{{if ne .Primitive "interface{}" }}
+// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
+func (f genHelperEncoder) {{ .MethodNamePfx "Enc" true }}(v {{ .Primitive }}) {
+ ee := f.e.e
+ {{ encmd .Primitive "v" }}
+}
+{{ end }}{{ end }}{{ end }}
+
+// -- decode calls (primitives)
+{{range .Values}}{{if .Primitive }}{{if ne .Primitive "interface{}" }}
+// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
+func (f genHelperDecoder) {{ .MethodNamePfx "Dec" true }}(vp *{{ .Primitive }}) {
+ dd := f.d.d
+ *vp = {{ decmd .Primitive }}
+}
+// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
+func (f genHelperDecoder) {{ .MethodNamePfx "Read" true }}() (v {{ .Primitive }}) {
+ dd := f.d.d
+ v = {{ decmd .Primitive }}
+ return
+}
+{{ end }}{{ end }}{{ end }}
+
+
+// -- encode calls (slices/maps)
+{{range .Values}}{{if not .Primitive }}{{if .Slice }}
+// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
+func (f genHelperEncoder) {{ .MethodNamePfx "Enc" false }}(v []{{ .Elem }}) { {{ else }}
+// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
+func (f genHelperEncoder) {{ .MethodNamePfx "Enc" false }}(v map[{{ .MapKey }}]{{ .Elem }}) { {{end}}
+ f.F.{{ .MethodNamePfx "Enc" false }}V(v, false, f.e)
+}
+{{ end }}{{ end }}
+
+// -- decode calls (slices/maps)
+{{range .Values}}{{if not .Primitive }}
+// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
+{{if .Slice }}func (f genHelperDecoder) {{ .MethodNamePfx "Dec" false }}(vp *[]{{ .Elem }}) {
+{{else}}func (f genHelperDecoder) {{ .MethodNamePfx "Dec" false }}(vp *map[{{ .MapKey }}]{{ .Elem }}) { {{end}}
+ v, changed := f.F.{{ .MethodNamePfx "Dec" false }}V(*vp, false, true, f.d)
+ if changed {
+ *vp = v
+ }
+}
+{{ end }}{{ end }}
+*/}}
diff --git a/vendor/github.com/ugorji/go/codec/gen.generated.go b/vendor/github.com/ugorji/go/codec/gen.generated.go
index 240ba9f8c7..2ace97b78c 100644
--- a/vendor/github.com/ugorji/go/codec/gen.generated.go
+++ b/vendor/github.com/ugorji/go/codec/gen.generated.go
@@ -1,5 +1,3 @@
-// +build codecgen.exec
-
// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved.
// Use of this source code is governed by a MIT license found in the LICENSE file.
@@ -12,22 +10,21 @@ const genDecMapTmpl = `
{{var "l"}} := r.ReadMapStart()
{{var "bh"}} := z.DecBasicHandle()
if {{var "v"}} == nil {
- {{var "rl"}} := z.DecInferLen({{var "l"}}, {{var "bh"}}.MaxInitLen, {{ .Size }})
+ {{var "rl"}}, _ := z.DecInferLen({{var "l"}}, {{var "bh"}}.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
+var {{var "mg"}} {{if decElemKindPtr}}, {{var "ms"}}, {{var "mok"}}{{end}} bool
if {{var "bh"}}.MapValueReset {
{{if decElemKindPtr}}{{var "mg"}} = true
{{else if decElemKindIntf}}if !{{var "bh"}}.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 }}) */}}
+if {{var "l"}} > 0 {
+for {{var "j"}} := 0; {{var "j"}} < {{var "l"}}; {{var "j"}}++ {
+ 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 "mk"}} = string({{var "bv"}})
@@ -39,17 +36,34 @@ if {{var "l"}} != 0 {
{{var "ms"}} = false
} {{else}}{{var "mv"}} = {{var "v"}}[{{var "mk"}}] {{end}}
} {{if not decElemKindImmutable}}else { {{var "mv"}} = {{decElemZero}} }{{end}}
- r.ReadMapElemValue() {{/* z.DecSendContainerState(codecSelfer_containerMapValue{{ .Sfx }}) */}}
- {{var "mdn"}} = false
- {{ $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}} }
- } else if {{if decElemKindPtr}} {{var "ms"}} && {{end}} {{var "v"}} != nil {
+ z.DecSendContainerState(codecSelfer_containerMapValue{{ .Sfx }})
+ {{ $x := printf "%vmv%v" .TempVar .Rand }}{{ decLineVar $x }}
+ if {{if decElemKindPtr}} {{var "ms"}} && {{end}} {{var "v"}} != nil {
+ {{var "v"}}[{{var "mk"}}] = {{var "mv"}}
+ }
+}
+} else if {{var "l"}} < 0 {
+for {{var "j"}} := 0; !r.CheckBreak(); {{var "j"}}++ {
+ 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 "mk"}} = string({{var "bv"}})
+ }{{ end }}{{if decElemKindPtr}}
+ {{var "ms"}} = true {{ end }}
+ if {{var "mg"}} {
+ {{if decElemKindPtr}}{{var "mv"}}, {{var "mok"}} = {{var "v"}}[{{var "mk"}}]
+ if {{var "mok"}} {
+ {{var "ms"}} = false
+ } {{else}}{{var "mv"}} = {{var "v"}}[{{var "mk"}}] {{end}}
+ } {{if not decElemKindImmutable}}else { {{var "mv"}} = {{decElemZero}} }{{end}}
+ z.DecSendContainerState(codecSelfer_containerMapValue{{ .Sfx }})
+ {{ $x := printf "%vmv%v" .TempVar .Rand }}{{ decLineVar $x }}
+ 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.DecSendContainerState(codecSelfer_containerMapEnd{{ .Sfx }})
`
const genDecListTmpl = `
@@ -64,68 +78,94 @@ if {{var "l"}} == 0 {
} else if len({{var "v"}}) != 0 {
{{var "v"}} = {{var "v"}}[:0]
{{var "c"}} = true
- } {{else if isChan }}if {{var "v"}} == nil {
+ } {{end}} {{if isChan }}if {{var "v"}} == nil {
{{var "v"}} = make({{ .CTyp }}, 0)
{{var "c"}} = true
} {{end}}
-} else {
- {{var "hl"}} := {{var "l"}} > 0
- var {{var "rl"}} int
- _ = {{var "rl"}}
- {{if isSlice }} if {{var "hl"}} {
+} else if {{var "l"}} > 0 {
+ {{if isChan }}if {{var "v"}} == nil {
+ {{var "rl"}}, _ = z.DecInferLen({{var "l"}}, z.DecBasicHandle().MaxInitLen, {{ .Size }})
+ {{var "v"}} = make({{ .CTyp }}, {{var "rl"}})
+ {{var "c"}} = true
+ }
+ for {{var "r"}} := 0; {{var "r"}} < {{var "l"}}; {{var "r"}}++ {
+ {{var "h"}}.ElemContainerState({{var "r"}})
+ var {{var "t"}} {{ .Typ }}
+ {{ $x := printf "%st%s" .TempVar .Rand }}{{ decLineVar $x }}
+ {{var "v"}} <- {{var "t"}}
+ }
+ {{ else }} var {{var "rr"}}, {{var "rl"}} int {{/* // num2read, length of slice/array/chan */}}
+ var {{var "rt"}} bool {{/* truncated */}}
+ _, _ = {{var "rl"}}, {{var "rt"}}
+ {{var "rr"}} = {{var "l"}} // len({{var "v"}})
if {{var "l"}} > cap({{var "v"}}) {
- {{var "rl"}} = z.DecInferLen({{var "l"}}, z.DecBasicHandle().MaxInitLen, {{ .Size }})
- if {{var "rl"}} <= cap({{var "v"}}) {
- {{var "v"}} = {{var "v"}}[:{{var "rl"}}]
+ {{if isArray }}z.DecArrayCannotExpand(len({{var "v"}}), {{var "l"}})
+ {{ else }}{{if not .Immutable }}
+ {{var "rg"}} := len({{var "v"}}) > 0
+ {{var "v2"}} := {{var "v"}} {{end}}
+ {{var "rl"}}, {{var "rt"}} = z.DecInferLen({{var "l"}}, z.DecBasicHandle().MaxInitLen, {{ .Size }})
+ if {{var "rt"}} {
+ if {{var "rl"}} <= cap({{var "v"}}) {
+ {{var "v"}} = {{var "v"}}[:{{var "rl"}}]
+ } else {
+ {{var "v"}} = make([]{{ .Typ }}, {{var "rl"}})
+ }
} else {
{{var "v"}} = make([]{{ .Typ }}, {{var "rl"}})
}
{{var "c"}} = true
- } else if {{var "l"}} != len({{var "v"}}) {
+ {{var "rr"}} = len({{var "v"}}) {{if not .Immutable }}
+ if {{var "rg"}} { copy({{var "v"}}, {{var "v2"}}) } {{end}} {{end}}{{/* end not Immutable, isArray */}}
+ } {{if isSlice }} else if {{var "l"}} != len({{var "v"}}) {
{{var "v"}} = {{var "v"}}[:{{var "l"}}]
{{var "c"}} = true
- }
- } {{end}}
- var {{var "j"}} int
- // var {{var "dn"}} bool
- for ; ({{var "hl"}} && {{var "j"}} < {{var "l"}}) || !({{var "hl"}} || r.CheckBreak()); {{var "j"}}++ {
- {{if not isArray}} if {{var "j"}} == 0 && {{var "v"}} == nil {
- if {{var "hl"}} {
- {{var "rl"}} = z.DecInferLen({{var "l"}}, z.DecBasicHandle().MaxInitLen, {{ .Size }})
- } else {
- {{var "rl"}} = {{if isSlice}}8{{else if isChan}}64{{end}}
- }
- {{var "v"}} = make({{if isSlice}}[]{{ .Typ }}{{else if isChan}}{{.CTyp}}{{end}}, {{var "rl"}})
- {{var "c"}} = true
- }{{end}}
+ } {{end}} {{/* end isSlice:47 */}}
+ {{var "j"}} := 0
+ for ; {{var "j"}} < {{var "rr"}} ; {{var "j"}}++ {
{{var "h"}}.ElemContainerState({{var "j"}})
- {{/* {{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 }}
- {{var "v"}} <- {{ $x }}
- // println(">>>> sending ", {{ $x }}, " into ", {{var "v"}}) // TODO: remove this
- {{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}}
- }
- if {{var "db"}} {
- z.DecSwallow()
- } else {
+ {{ $x := printf "%[1]vv%[2]v[%[1]vj%[2]v]" .TempVar .Rand }}{{ decLineVar $x }}
+ }
+ {{if isArray }}for ; {{var "j"}} < {{var "l"}} ; {{var "j"}}++ {
+ {{var "h"}}.ElemContainerState({{var "j"}})
+ z.DecSwallow()
+ }
+ {{ else }}if {{var "rt"}} {
+ for ; {{var "j"}} < {{var "l"}} ; {{var "j"}}++ {
+ {{var "v"}} = append({{var "v"}}, {{ zero}})
+ {{var "h"}}.ElemContainerState({{var "j"}})
{{ $x := printf "%[1]vv%[2]v[%[1]vj%[2]v]" .TempVar .Rand }}{{ decLineVar $x }}
}
- {{end}}
+ } {{end}} {{/* end isArray:56 */}}
+ {{end}} {{/* end isChan:16 */}}
+} else { {{/* len < 0 */}}
+ {{var "j"}} := 0
+ for ; !r.CheckBreak(); {{var "j"}}++ {
+ {{if isChan }}
+ {{var "h"}}.ElemContainerState({{var "j"}})
+ var {{var "t"}} {{ .Typ }}
+ {{ $x := printf "%st%s" .TempVar .Rand }}{{ decLineVar $x }}
+ {{var "v"}} <- {{var "t"}}
+ {{ else }}
+ if {{var "j"}} >= len({{var "v"}}) {
+ {{if isArray }}z.DecArrayCannotExpand(len({{var "v"}}), {{var "j"}}+1)
+ {{ else }}{{var "v"}} = append({{var "v"}}, {{zero}})// var {{var "z"}} {{ .Typ }}
+ {{var "c"}} = true {{end}}
+ }
+ {{var "h"}}.ElemContainerState({{var "j"}})
+ if {{var "j"}} < len({{var "v"}}) {
+ {{ $x := printf "%[1]vv%[2]v[%[1]vj%[2]v]" .TempVar .Rand }}{{ decLineVar $x }}
+ } else {
+ z.DecSwallow()
+ }
+ {{end}}
}
- {{if isSlice}} if {{var "j"}} < len({{var "v"}}) {
+ {{if isSlice }}if {{var "j"}} < len({{var "v"}}) {
{{var "v"}} = {{var "v"}}[:{{var "j"}}]
{{var "c"}} = true
} else if {{var "j"}} == 0 && {{var "v"}} == nil {
- {{var "v"}} = make([]{{ .Typ }}, 0)
+ {{var "v"}} = []{{ .Typ }}{}
{{var "c"}} = true
- } {{end}}
+ }{{end}}
}
{{var "h"}}.End()
{{if not isArray }}if {{var "c"}} {
@@ -133,32 +173,3 @@ if {{var "l"}} == 0 {
}{{end}}
`
-const genEncChanTmpl = `
-{{.Label}}:
-switch timeout{{.Sfx}} := z.EncBasicHandle().ChanRecvTimeout; {
-case timeout{{.Sfx}} == 0: // only consume available
- for {
- select {
- case b{{.Sfx}} := <-{{.Chan}}:
- {{ .Slice }} = append({{.Slice}}, b{{.Sfx}})
- default:
- break {{.Label}}
- }
- }
-case timeout{{.Sfx}} > 0: // consume until timeout
- tt{{.Sfx}} := time.NewTimer(timeout{{.Sfx}})
- for {
- select {
- case b{{.Sfx}} := <-{{.Chan}}:
- {{.Slice}} = append({{.Slice}}, b{{.Sfx}})
- case <-tt{{.Sfx}}.C:
- // close(tt.C)
- break {{.Label}}
- }
- }
-default: // consume until close
- for b{{.Sfx}} := range {{.Chan}} {
- {{.Slice}} = append({{.Slice}}, b{{.Sfx}})
- }
-}
-`
diff --git a/vendor/github.com/ugorji/go/codec/gen.go b/vendor/github.com/ugorji/go/codec/gen.go
index b4c4031ff4..1a27675fd0 100644
--- a/vendor/github.com/ugorji/go/codec/gen.go
+++ b/vendor/github.com/ugorji/go/codec/gen.go
@@ -1,6 +1,4 @@
-// +build codecgen.exec
-
-// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved.
+// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved.
// Use of this source code is governed by a MIT license found in the LICENSE file.
package codec
@@ -30,6 +28,7 @@ import (
// codecgen supports the full cycle of reflection-based codec:
// - RawExt
// - Raw
+// - Builtins
// - Extensions
// - (Binary|Text|JSON)(Unm|M)arshal
// - generic by-kind
@@ -81,10 +80,6 @@ import (
// Note:
// It was a conscious decision to have gen.go always explicitly call EncodeNil or TryDecodeAsNil.
// This way, there isn't a function call overhead just to see that we should not enter a block of code.
-//
-// Note:
-// codecgen-generated code depends on the variables defined by fast-path.generated.go.
-// consequently, you cannot run with tags "codecgen notfastpath".
// GenVersion is the current version of codecgen.
//
@@ -99,10 +94,7 @@ import (
// changes in signature of some unpublished helper methods and codecgen cmdline arguments.
// v4: Removed separator support from (en|de)cDriver, and refactored codec(gen)
// v5: changes to support faster json decoding. Let encoder/decoder maintain state of collections.
-// v6: removed unsafe from gen, and now uses codecgen.exec tag
-// v7:
-// v8: current - we now maintain compatibility with old generated code.
-const genVersion = 8
+const GenVersion = 5
const (
genCodecPkg = "codec1978"
@@ -130,27 +122,13 @@ const (
)
var (
- errGenAllTypesSamePkg = errors.New("All types must be in the same package")
- errGenExpectArrayOrMap = errors.New("unexpected type. Expecting array/map/slice")
-
- genBase64enc = base64.NewEncoding("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789__")
- genQNameRegex = regexp.MustCompile(`[A-Za-z_.]+`)
+ genAllTypesSamePkgErr = errors.New("All types must be in the same package")
+ genExpectArrayOrMapErr = errors.New("unexpected type. Expecting array/map/slice")
+ genBase64enc = base64.NewEncoding("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789__")
+ genQNameRegex = regexp.MustCompile(`[A-Za-z_.]+`)
+ genCheckVendor bool
)
-type genBuf struct {
- buf []byte
-}
-
-func (x *genBuf) s(s string) *genBuf { x.buf = append(x.buf, s...); return x }
-func (x *genBuf) b(s []byte) *genBuf { x.buf = append(x.buf, s...); return x }
-func (x *genBuf) v() string { return string(x.buf) }
-func (x *genBuf) f(s string, args ...interface{}) { x.s(fmt.Sprintf(s, args...)) }
-func (x *genBuf) reset() {
- if x.buf != nil {
- x.buf = x.buf[:0]
- }
-}
-
// genRunner holds some state used during a Gen run.
type genRunner struct {
w io.Writer // output
@@ -169,7 +147,8 @@ type genRunner struct {
is map[reflect.Type]struct{} // types seen during import search
bp string // base PkgPath, for which we are generating for
- cpfx string // codec package prefix
+ cpfx string // codec package prefix
+ unsafe bool // is unsafe to be used in generated code?
tm map[reflect.Type]struct{} // types for which enc/dec must be generated
ts []reflect.Type // types for which enc/dec must be generated
@@ -179,37 +158,40 @@ type genRunner struct {
ti *TypeInfos
// rr *rand.Rand // random generator for file-specific types
-
- nx bool // no extensions
}
// Gen will write a complete go file containing Selfer implementations for each
// type passed. All the types must be in the same package.
//
-// Library users: DO NOT USE IT DIRECTLY. IT WILL CHANGE CONTINUOUSLY WITHOUT NOTICE.
-func Gen(w io.Writer, buildTags, pkgName, uid string, noExtensions bool,
- ti *TypeInfos, typ ...reflect.Type) {
- // All types passed to this method do not have a codec.Selfer method implemented directly.
- // codecgen already checks the AST and skips any types that define the codec.Selfer methods.
- // Consequently, there's no need to check and trim them if they implement codec.Selfer
+// Library users: *DO NOT USE IT DIRECTLY. IT WILL CHANGE CONTINOUSLY WITHOUT NOTICE.*
+func Gen(w io.Writer, buildTags, pkgName, uid string, useUnsafe bool, ti *TypeInfos, typ ...reflect.Type) {
+ // trim out all types which already implement Selfer
+ typ2 := make([]reflect.Type, 0, len(typ))
+ for _, t := range typ {
+ if reflect.PtrTo(t).Implements(selferTyp) || t.Implements(selferTyp) {
+ continue
+ }
+ typ2 = append(typ2, t)
+ }
+ typ = typ2
if len(typ) == 0 {
return
}
x := genRunner{
- w: w,
- t: typ,
- te: make(map[uintptr]bool),
- td: make(map[uintptr]bool),
- im: make(map[string]reflect.Type),
- imn: make(map[string]string),
- is: make(map[reflect.Type]struct{}),
- tm: make(map[reflect.Type]struct{}),
- ts: []reflect.Type{},
- bp: genImportPath(typ[0]),
- xs: uid,
- ti: ti,
- nx: noExtensions,
+ unsafe: useUnsafe,
+ w: w,
+ t: typ,
+ te: make(map[uintptr]bool),
+ td: make(map[uintptr]bool),
+ im: make(map[string]reflect.Type),
+ imn: make(map[string]string),
+ is: make(map[reflect.Type]struct{}),
+ tm: make(map[reflect.Type]struct{}),
+ ts: []reflect.Type{},
+ bp: genImportPath(typ[0]),
+ xs: uid,
+ ti: ti,
}
if x.ti == nil {
x.ti = defTypeInfos
@@ -225,7 +207,7 @@ func Gen(w io.Writer, buildTags, pkgName, uid string, noExtensions bool,
for _, t := range typ {
// fmt.Printf("###########: PkgPath: '%v', Name: '%s'\n", genImportPath(t), t.Name())
if genImportPath(t) != x.bp {
- panic(errGenAllTypesSamePkg)
+ panic(genAllTypesSamePkgErr)
}
x.genRefPkgs(t)
}
@@ -235,7 +217,10 @@ func Gen(w io.Writer, buildTags, pkgName, uid string, noExtensions bool,
}
x.line(`
-// Code generated by codecgen - DO NOT EDIT.
+// ************************************************************
+// DO NOT EDIT.
+// THIS FILE IS AUTO-GENERATED BY codecgen.
+// ************************************************************
`)
x.line("package " + pkgName)
@@ -247,20 +232,19 @@ func Gen(w io.Writer, buildTags, pkgName, uid string, noExtensions bool,
}
// use a sorted set of im keys, so that we can get consistent output
imKeys := make([]string, 0, len(x.im))
- for k := range x.im {
+ for k, _ := range x.im {
imKeys = append(imKeys, k)
}
sort.Strings(imKeys)
for _, k := range imKeys { // for k, _ := range x.im {
- if k == x.imn[k] {
- x.linef("\"%s\"", k)
- } else {
- x.linef("%s \"%s\"", x.imn[k], k)
- }
+ x.linef("%s \"%s\"", x.imn[k], k)
}
// add required packages
- for _, k := range [...]string{"runtime", "errors", "strconv"} { // "reflect", "fmt"
+ for _, k := range [...]string{"reflect", "unsafe", "runtime", "fmt", "errors"} {
if _, ok := x.im[k]; !ok {
+ if k == "unsafe" && !x.unsafe {
+ continue
+ }
x.line("\"" + k + "\"")
}
}
@@ -269,36 +253,41 @@ func Gen(w io.Writer, buildTags, pkgName, uid string, noExtensions bool,
x.line("const (")
x.linef("// ----- content types ----")
- x.linef("codecSelferCcUTF8%s = %v", x.xs, int64(cUTF8))
- x.linef("codecSelferCcRAW%s = %v", x.xs, int64(cRAW))
+ x.linef("codecSelferC_UTF8%s = %v", x.xs, int64(c_UTF8))
+ x.linef("codecSelferC_RAW%s = %v", x.xs, int64(c_RAW))
x.linef("// ----- value types used ----")
- for _, vt := range [...]valueType{
- valueTypeArray, valueTypeMap, valueTypeString,
- valueTypeInt, valueTypeUint, valueTypeFloat} {
- 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("codecSelferValueTypeArray%s = %v", x.xs, int64(valueTypeArray))
+ x.linef("codecSelferValueTypeMap%s = %v", x.xs, int64(valueTypeMap))
+ x.linef("// ----- containerStateValues ----")
+ x.linef("codecSelfer_containerMapKey%s = %v", x.xs, int64(containerMapKey))
+ x.linef("codecSelfer_containerMapValue%s = %v", x.xs, int64(containerMapValue))
+ x.linef("codecSelfer_containerMapEnd%s = %v", x.xs, int64(containerMapEnd))
+ x.linef("codecSelfer_containerArrayElem%s = %v", x.xs, int64(containerArrayElem))
+ x.linef("codecSelfer_containerArrayEnd%s = %v", x.xs, int64(containerArrayEnd))
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("codecSelferBitsize" + x.xs + " = uint8(reflect.TypeOf(uint(0)).Bits())")
+ x.line("codecSelferOnlyMapOrArrayEncodeToStructErr" + x.xs + " = errors.New(`only encoded map or array can be decoded into a struct`)")
x.line(")")
x.line("")
+ if x.unsafe {
+ x.line("type codecSelferUnsafeString" + x.xs + " struct { Data uintptr; Len int}")
+ x.line("")
+ }
x.hn = "codecSelfer" + x.xs
x.line("type " + x.hn + " struct{}")
x.line("")
x.varsfxreset()
x.line("func init() {")
- x.linef("if %sGenVersion != %v {", x.cpfx, genVersion)
+ 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.line(`err := fmt.Errorf("codecgen version mismatch: current: %v, need %v. Re-generate file: %v", `)
+ x.linef(`%v, %sGenVersion, file)`, GenVersion, x.cpfx)
+ x.line("panic(err)")
x.linef("}")
x.line("if false { // 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 {
@@ -306,6 +295,10 @@ func Gen(w io.Writer, buildTags, pkgName, uid string, noExtensions bool,
x.linef("var v%v %s.%s", n, x.imn[k], t.Name())
n++
}
+ if x.unsafe {
+ x.linef("var v%v unsafe.Pointer", n)
+ n++
+ }
if n > 0 {
x.out("_")
for i := 1; i < n; i++ {
@@ -328,7 +321,7 @@ func Gen(w io.Writer, buildTags, pkgName, uid string, noExtensions bool,
}
for _, t := range x.ts {
- rtid := rt2id(t)
+ rtid := reflect.ValueOf(t).Pointer()
// generate enc functions for all these slice/map types.
x.varsfxreset()
x.linef("func (x %s) enc%s(v %s%s, e *%sEncoder) {", x.hn, x.genMethodNameT(t), x.arr2str(t, "*"), x.genTypeName(t), x.cpfx)
@@ -339,7 +332,7 @@ func Gen(w io.Writer, buildTags, pkgName, uid string, noExtensions bool,
case reflect.Map:
x.encMapFallback("v", t)
default:
- panic(errGenExpectArrayOrMap)
+ panic(genExpectArrayOrMapErr)
}
x.line("}")
x.line("")
@@ -354,7 +347,7 @@ func Gen(w io.Writer, buildTags, pkgName, uid string, noExtensions bool,
case reflect.Map:
x.decMapFallback("v", rtid, t)
default:
- panic(errGenExpectArrayOrMap)
+ panic(genExpectArrayOrMapErr)
}
x.line("}")
x.line("")
@@ -390,6 +383,7 @@ func (x *genRunner) genRefPkgs(t reflect.Type) {
if _, ok := x.is[t]; ok {
return
}
+ // fmt.Printf(">>>>>>: PkgPath: '%v', Name: '%s'\n", genImportPath(t), t.Name())
x.is[t] = struct{}{}
tpkg, tname := genImportPath(t), t.Name()
if tpkg != "" && tpkg != x.bp && tpkg != x.cp && tname != "" && tname[0] >= 'A' && tname[0] <= 'Z' {
@@ -418,6 +412,13 @@ func (x *genRunner) genRefPkgs(t reflect.Type) {
}
}
+func (x *genRunner) line(s string) {
+ x.out(s)
+ if len(s) == 0 || s[len(s)-1] != '\n' {
+ x.out("\n")
+ }
+}
+
func (x *genRunner) varsfx() string {
x.c++
return strconv.FormatUint(x.c, 10)
@@ -428,31 +429,17 @@ func (x *genRunner) varsfxreset() {
}
func (x *genRunner) out(s string) {
- _, err := io.WriteString(x.w, s)
- if err != nil {
+ if _, err := io.WriteString(x.w, s); err != nil {
panic(err)
}
}
-func (x *genRunner) outf(s string, params ...interface{}) {
- _, err := fmt.Fprintf(x.w, s, params...)
- if err != nil {
- panic(err)
- }
-}
-
-func (x *genRunner) line(s string) {
- x.out(s)
- if len(s) == 0 || s[len(s)-1] != '\n' {
- x.out("\n")
- }
-}
-
func (x *genRunner) linef(s string, params ...interface{}) {
- x.outf(s, params...)
- if len(s) == 0 || s[len(s)-1] != '\n' {
- x.out("\n")
- }
+ x.line(fmt.Sprintf(s, params...))
+}
+
+func (x *genRunner) outf(s string, params ...interface{}) {
+ x.out(fmt.Sprintf(s, params...))
}
func (x *genRunner) genTypeName(t reflect.Type) (n string) {
@@ -525,23 +512,23 @@ func (x *genRunner) selfer(encode bool) {
t := x.tc
t0 := t
// always make decode use a pointer receiver,
- // and structs/arrays always use a ptr receiver (encode|decode)
- isptr := !encode || t.Kind() == reflect.Array || (t.Kind() == reflect.Struct && t != timeTyp)
+ // and structs always use a ptr receiver (encode|decode)
+ isptr := !encode || t.Kind() == reflect.Struct
x.varsfxreset()
-
- fnSigPfx := "func (" + genTopLevelVarName + " "
+ fnSigPfx := "func (x "
if isptr {
fnSigPfx += "*"
}
fnSigPfx += x.genTypeName(t)
- x.out(fnSigPfx)
+ x.out(fnSigPfx)
if isptr {
t = reflect.PtrTo(t)
}
if encode {
x.line(") CodecEncodeSelf(e *" + x.cpfx + "Encoder) {")
x.genRequiredMethodVars(true)
+ // x.enc(genTopLevelVarName, t)
x.encVar(genTopLevelVarName, t)
} else {
x.line(") CodecDecodeSelf(d *" + x.cpfx + "Decoder) {")
@@ -550,7 +537,7 @@ func (x *genRunner) selfer(encode bool) {
// or way to elegantly handle that, and also setting it to a
// non-nil value doesn't affect the pointer passed.
// x.decVar(genTopLevelVarName, t, false)
- x.dec(genTopLevelVarName, t0, true)
+ x.dec(genTopLevelVarName, t0)
}
x.line("}")
x.line("")
@@ -564,21 +551,21 @@ func (x *genRunner) selfer(encode bool) {
x.out(fnSigPfx)
x.line(") codecDecodeSelfFromMap(l int, d *" + x.cpfx + "Decoder) {")
x.genRequiredMethodVars(false)
- x.decStructMap(genTopLevelVarName, "l", rt2id(t0), t0, genStructMapStyleConsolidated)
+ x.decStructMap(genTopLevelVarName, "l", reflect.ValueOf(t0).Pointer(), t0, genStructMapStyleConsolidated)
x.line("}")
x.line("")
} else {
x.out(fnSigPfx)
x.line(") codecDecodeSelfFromMapLenPrefix(l int, d *" + x.cpfx + "Decoder) {")
x.genRequiredMethodVars(false)
- x.decStructMap(genTopLevelVarName, "l", rt2id(t0), t0, genStructMapStyleLenPrefix)
+ x.decStructMap(genTopLevelVarName, "l", reflect.ValueOf(t0).Pointer(), t0, genStructMapStyleLenPrefix)
x.line("}")
x.line("")
x.out(fnSigPfx)
x.line(") codecDecodeSelfFromMapCheckBreak(l int, d *" + x.cpfx + "Decoder) {")
x.genRequiredMethodVars(false)
- x.decStructMap(genTopLevelVarName, "l", rt2id(t0), t0, genStructMapStyleCheckBreak)
+ x.decStructMap(genTopLevelVarName, "l", reflect.ValueOf(t0).Pointer(), t0, genStructMapStyleCheckBreak)
x.line("}")
x.line("")
}
@@ -587,24 +574,18 @@ func (x *genRunner) selfer(encode bool) {
x.out(fnSigPfx)
x.line(") codecDecodeSelfFromArray(l int, d *" + x.cpfx + "Decoder) {")
x.genRequiredMethodVars(false)
- x.decStructArray(genTopLevelVarName, "l", "return", rt2id(t0), t0)
+ x.decStructArray(genTopLevelVarName, "l", "return", reflect.ValueOf(t0).Pointer(), t0)
x.line("}")
x.line("")
}
// used for chan, array, slice, map
-func (x *genRunner) xtraSM(varname string, t reflect.Type, encode, isptr bool) {
- var ptrPfx, addrPfx string
- if isptr {
- ptrPfx = "*"
- } else {
- addrPfx = "&"
- }
+func (x *genRunner) xtraSM(varname string, encode bool, t reflect.Type) {
if encode {
- x.linef("h.enc%s((%s%s)(%s), e)", x.genMethodNameT(t), ptrPfx, x.genTypeName(t), varname)
+ x.linef("h.enc%s((%s%s)(%s), e)", x.genMethodNameT(t), x.arr2str(t, "*"), x.genTypeName(t), varname)
} else {
- x.linef("h.dec%s((*%s)(%s%s), d)", x.genMethodNameT(t), x.genTypeName(t), addrPfx, varname)
+ x.linef("h.dec%s((*%s)(%s), d)", x.genMethodNameT(t), x.genTypeName(t), varname)
}
x.registerXtraT(t)
}
@@ -643,23 +624,17 @@ func (x *genRunner) encVar(varname string, t reflect.Type) {
if checkNil {
x.linef("if %s == nil { r.EncodeNil() } else { ", varname)
}
-
switch t.Kind() {
case reflect.Ptr:
- telem := t.Elem()
- tek := telem.Kind()
- if tek == reflect.Array || (tek == reflect.Struct && telem != timeTyp) {
+ switch t.Elem().Kind() {
+ case reflect.Struct, reflect.Array:
x.enc(varname, genNonPtr(t))
- break
+ default:
+ i := x.varsfx()
+ x.line(genTempVarPfx + i + " := *" + varname)
+ x.enc(genTempVarPfx+i, genNonPtr(t))
}
- i := x.varsfx()
- x.line(genTempVarPfx + i + " := *" + varname)
- x.enc(genTempVarPfx+i, genNonPtr(t))
case reflect.Struct, reflect.Array:
- if t == timeTyp {
- x.enc(varname, t)
- break
- }
i := x.varsfx()
x.line(genTempVarPfx + i + " := &" + varname)
x.enc(genTempVarPfx+i, t)
@@ -673,33 +648,29 @@ func (x *genRunner) encVar(varname string, t reflect.Type) {
}
-// enc will encode a variable (varname) of type t, where t represents T.
-// if t is !time.Time and t is of kind reflect.Struct or reflect.Array, varname is of type *T
-// (to prevent copying),
-// else t is of type T
+// enc will encode a variable (varname) of type t,
+// except t is of kind reflect.Struct or reflect.Array, wherein varname is of type ptrTo(T) (to prevent copying)
func (x *genRunner) enc(varname string, t reflect.Type) {
- rtid := rt2id(t)
- ti2 := x.ti.get(rtid, t)
+ rtid := reflect.ValueOf(t).Pointer()
// We call CodecEncodeSelf if one of the following are honored:
// - the type already implements Selfer, call that
// - the type has a Selfer implementation just created, use that
// - the type is in the list of the ones we will generate for, but it is not currently being generated
mi := x.varsfx()
- // tptr := reflect.PtrTo(t)
+ 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 tptr.Implements(selferTyp) || t.Implements(selferTyp) {
- if ti2.isFlag(typeInfoFlagIsZeroerPtr) || ti2.isFlag(typeInfoFlagIsZeroer) {
+ if tk == reflect.Array || tk == reflect.Struct { // varname is of type *T
+ if tptr.Implements(selferTyp) || t.Implements(selferTyp) {
x.line(varname + ".CodecEncodeSelf(e)")
return
}
} else { // varname is of type T
- if ti2.cs { // t.Implements(selferTyp) {
+ if t.Implements(selferTyp) {
x.line(varname + ".CodecEncodeSelf(e)")
return
- } else if ti2.csp { // tptr.Implements(selferTyp) {
+ } else if tptr.Implements(selferTyp) {
x.linef("%ssf%s := &%s", genTempVarPfx, mi, varname)
x.linef("%ssf%s.CodecEncodeSelf(e)", genTempVarPfx, mi)
return
@@ -731,53 +702,57 @@ func (x *genRunner) enc(varname string, t reflect.Type) {
}
// check if
- // - type is time.Time, RawExt, Raw
+ // - type is RawExt, Raw
// - the type implements (Text|JSON|Binary)(Unm|M)arshal
-
+ x.linef("%sm%s := z.EncBinary()", genTempVarPfx, mi)
+ x.linef("_ = %sm%s", genTempVarPfx, mi)
x.line("if false {") //start if block
defer func() { x.line("}") }() //end if block
- if t == timeTyp {
- x.linef("} else { r.EncodeTime(%s)", varname)
- return
- }
if t == rawTyp {
- x.linef("} else { z.EncRaw(%s)", varname)
+ x.linef("} else { z.EncRaw(%v)", varname)
return
}
if t == rawExtTyp {
- x.linef("} else { r.EncodeRawExt(%s, e)", varname)
+ x.linef("} else { r.EncodeRawExt(%v, e)", varname)
return
}
- // only check for extensions if the type is named, and has a packagePath.
- var arrayOrStruct = tk == reflect.Array || tk == reflect.Struct // meaning varname if of type *T
- if !x.nx && 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)
+ // HACK: Support for Builtins.
+ // Currently, only Binc supports builtins, and the only builtin type is time.Time.
+ // Have a method that returns the rtid for time.Time if Handle is Binc.
+ if t == timeTyp {
+ vrtid := genTempVarPfx + "m" + x.varsfx()
+ x.linef("} else if %s := z.TimeRtidIfBinc(); %s != 0 { ", vrtid, vrtid)
+ x.linef("r.EncodeBuiltin(%s, %s)", vrtid, varname)
}
- 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)
+ // only check for extensions if the type is named, and has a packagePath.
+ if genImportPath(t) != "" && t.Name() != "" {
+ // first check if extensions are configued, before doing the interface conversion
+ x.linef("} else if z.HasExtensions() && z.EncExt(%s) {", varname)
+ }
+ if tk == reflect.Array || tk == reflect.Struct { // varname is of type *T
+ if t.Implements(binaryMarshalerTyp) || tptr.Implements(binaryMarshalerTyp) {
+ x.linef("} else if %sm%s { z.EncBinaryMarshal(%v) ", genTempVarPfx, mi, 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 t.Implements(jsonMarshalerTyp) || tptr.Implements(jsonMarshalerTyp) {
+ x.linef("} else if !%sm%s && z.IsJSONHandle() { z.EncJSONMarshal(%v) ", genTempVarPfx, mi, varname)
+ } else if t.Implements(textMarshalerTyp) || tptr.Implements(textMarshalerTyp) {
+ x.linef("} else if !%sm%s { z.EncTextMarshal(%v) ", genTempVarPfx, mi, 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 t.Implements(binaryMarshalerTyp) {
+ x.linef("} else if %sm%s { z.EncBinaryMarshal(%v) ", genTempVarPfx, mi, varname)
+ } else if tptr.Implements(binaryMarshalerTyp) {
+ x.linef("} else if %sm%s { z.EncBinaryMarshal(&%v) ", genTempVarPfx, mi, 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 t.Implements(jsonMarshalerTyp) {
+ x.linef("} else if !%sm%s && z.IsJSONHandle() { z.EncJSONMarshal(%v) ", genTempVarPfx, mi, varname)
+ } else if tptr.Implements(jsonMarshalerTyp) {
+ x.linef("} else if !%sm%s && z.IsJSONHandle() { z.EncJSONMarshal(&%v) ", genTempVarPfx, mi, varname)
+ } else if t.Implements(textMarshalerTyp) {
+ x.linef("} else if !%sm%s { z.EncTextMarshal(%v) ", genTempVarPfx, mi, varname)
+ } else if tptr.Implements(textMarshalerTyp) {
+ x.linef("} else if !%sm%s { z.EncTextMarshal(&%v) ", genTempVarPfx, mi, varname)
}
}
x.line("} else {")
@@ -794,12 +769,12 @@ func (x *genRunner) enc(varname string, t reflect.Type) {
case reflect.Bool:
x.line("r.EncodeBool(bool(" + varname + "))")
case reflect.String:
- x.line("r.EncodeString(codecSelferCcUTF8" + x.xs + ", string(" + varname + "))")
+ x.line("r.EncodeString(codecSelferC_UTF8" + x.xs + ", string(" + varname + "))")
case reflect.Chan:
- x.xtraSM(varname, t, true, false)
+ x.xtraSM(varname, true, t)
// x.encListFallback(varname, rtid, t)
case reflect.Array:
- x.xtraSM(varname, t, true, true)
+ x.xtraSM(varname, true, t)
case reflect.Slice:
// if nil, call dedicated function
// if a []uint8, call dedicated function
@@ -808,12 +783,12 @@ func (x *genRunner) enc(varname string, t reflect.Type) {
// - if elements are primitives or Selfers, call dedicated function on each member.
// - else call Encoder.encode(XXX) on it.
if rtid == uint8SliceTypId {
- x.line("r.EncodeStringBytes(codecSelferCcRAW" + x.xs + ", []byte(" + varname + "))")
+ x.line("r.EncodeStringBytes(codecSelferC_RAW" + x.xs + ", []byte(" + varname + "))")
} else if fastpathAV.index(rtid) != -1 {
g := x.newGenV(t)
- x.line("z.F." + g.MethodNamePfx("Enc", false) + "V(" + varname + ", e)")
+ x.line("z.F." + g.MethodNamePfx("Enc", false) + "V(" + varname + ", false, e)")
} else {
- x.xtraSM(varname, t, true, false)
+ x.xtraSM(varname, true, t)
// x.encListFallback(varname, rtid, t)
}
case reflect.Map:
@@ -825,9 +800,9 @@ func (x *genRunner) enc(varname string, t reflect.Type) {
// x.line("if " + varname + " == nil { \nr.EncodeNil()\n } else { ")
if fastpathAV.index(rtid) != -1 {
g := x.newGenV(t)
- x.line("z.F." + g.MethodNamePfx("Enc", false) + "V(" + varname + ", e)")
+ x.line("z.F." + g.MethodNamePfx("Enc", false) + "V(" + varname + ", false, e)")
} else {
- x.xtraSM(varname, t, true, false)
+ x.xtraSM(varname, true, t)
// x.encMapFallback(varname, rtid, t)
}
case reflect.Struct:
@@ -858,53 +833,12 @@ func (x *genRunner) encZero(t reflect.Type) {
case reflect.Bool:
x.line("r.EncodeBool(false)")
case reflect.String:
- x.line("r.EncodeString(codecSelferCcUTF8" + x.xs + `, "")`)
+ x.line("r.EncodeString(codecSelferC_UTF8" + x.xs + `, "")`)
default:
x.line("r.EncodeNil()")
}
}
-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)
- varname2 := varname + "." + t2.Name
- switch t2.Type.Kind() {
- case reflect.Struct:
- rtid2 := rt2id(t2.Type)
- ti2 := x.ti.get(rtid2, t2.Type)
- // fmt.Printf(">>>> structfield: omitempty: type: %s, field: %s\n", t2.Type.Name(), t2.Name)
- if ti2.rtid == timeTypId {
- buf.s("!(").s(varname2).s(".IsZero())")
- break
- }
- if ti2.isFlag(typeInfoFlagIsZeroerPtr) || ti2.isFlag(typeInfoFlagIsZeroer) {
- buf.s("!(").s(varname2).s(".IsZero())")
- break
- }
- if ti2.isFlag(typeInfoFlagComparable) {
- buf.s(varname2).s(" != ").s(x.genZeroValueR(t2.Type))
- break
- }
- // buf.s("(")
- buf.s("false")
- for i, n := 0, t2.Type.NumField(); i < n; i++ {
- f := t2.Type.Field(i)
- if f.PkgPath != "" { // unexported
- continue
- }
- buf.s(" || ")
- x.encOmitEmptyLine(f, varname2, buf)
- }
- //buf.s(")")
- case reflect.Bool:
- buf.s(varname2)
- case reflect.Map, reflect.Slice, reflect.Array, reflect.Chan:
- buf.s("len(").s(varname2).s(") != 0")
- default:
- buf.s(varname2).s(" != ").s(x.genZeroValueR(t2.Type))
- }
-}
-
func (x *genRunner) encStruct(varname string, rtid uintptr, t reflect.Type) {
// Use knowledge from structfieldinfo (mbs, encodable fields. Ignore omitempty. )
// replicate code in kStruct i.e. for each field, deref type to non-pointer, and call x.enc on it
@@ -919,71 +853,60 @@ func (x *genRunner) encStruct(varname string, rtid uintptr, t reflect.Type) {
x.line(sepVarname + " := !z.EncBinary()")
x.linef("%s := z.EncBasicHandle().StructToArray", struct2arrvar)
- x.linef("_, _ = %s, %s", sepVarname, struct2arrvar)
- x.linef("const %s bool = %v // struct tag has 'toArray'", ti2arrayvar, ti.toArray)
-
- tisfi := ti.sfiSrc // always use sequence from file. decStruct expects same thing.
-
- // var nn int
+ tisfi := ti.sfip // always use sequence from file. decStruct expects same thing.
// due to omitEmpty, we need to calculate the
// number of non-empty things we write out first.
// This is required as we need to pre-determine the size of the container,
// to support length-prefixing.
- if ti.anyOmitEmpty {
- x.linef("var %s = [%v]bool{ // should field at this index be written?", numfieldsvar, len(tisfi))
-
- 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
- var omitline genBuf
- {
- t2typ := t
- varname3 := varname
- // go through the loop, record the t2 field explicitly,
- // and gather the omit line if embedded in pointers.
- for ij, ix := range si.is {
- if uint8(ij) == si.nis {
- break
- }
- for t2typ.Kind() == reflect.Ptr {
- t2typ = t2typ.Elem()
- }
- t2 = t2typ.Field(int(ix))
- t2typ = t2.Type
- varname3 = varname3 + "." + t2.Name
- // do not include actual field in the omit line.
- // that is done subsequently (right after - below).
- if uint8(ij+1) < si.nis && t2typ.Kind() == reflect.Ptr {
- omitline.s(varname3).s(" != nil && ")
- }
+ x.linef("var %s [%v]bool", numfieldsvar, len(tisfi))
+ x.linef("_, _, _ = %s, %s, %s", sepVarname, numfieldsvar, struct2arrvar)
+ x.linef("const %s bool = %v", ti2arrayvar, ti.toArray)
+ nn := 0
+ for j, si := range tisfi {
+ if !si.omitEmpty {
+ nn++
+ continue
+ }
+ var t2 reflect.StructField
+ var omitline string
+ if si.i != -1 {
+ t2 = t.Field(int(si.i))
+ } else {
+ t2typ := t
+ varname3 := varname
+ for _, ix := range si.is {
+ for t2typ.Kind() == reflect.Ptr {
+ t2typ = t2typ.Elem()
+ }
+ t2 = t2typ.Field(ix)
+ t2typ = t2.Type
+ varname3 = varname3 + "." + t2.Name
+ if t2typ.Kind() == reflect.Ptr {
+ omitline += varname3 + " != nil && "
}
}
- x.encOmitEmptyLine(t2, varname, &omitline)
- x.linef("%s, // %s", omitline.v(), si.fieldName)
}
- x.line("}")
- x.linef("_ = %s", numfieldsvar)
+ // never 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)
+ switch t2.Type.Kind() {
+ case reflect.Struct:
+ omitline += " true"
+ case reflect.Map, reflect.Slice, reflect.Array, reflect.Chan:
+ omitline += "len(" + varname + "." + t2.Name + ") != 0"
+ default:
+ omitline += varname + "." + t2.Name + " != " + x.genZeroValueR(t2.Type)
+ }
+ x.linef("%s[%v] = %s", numfieldsvar, j, omitline)
}
- // x.linef("var %snn%s int", genTempVarPfx, i)
+ 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.line("r.EncodeArrayStart(" + strconv.FormatInt(int64(len(tisfi)), 10) + ")")
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))
- }
+ x.linef("%snn%s = %v", genTempVarPfx, i, nn)
+ x.linef("for _, b := range %s { if b { %snn%s++ } }", numfieldsvar, genTempVarPfx, i)
+ x.linef("r.EncodeMapStart(%snn%s)", genTempVarPfx, i)
+ x.linef("%snn%s = %v", genTempVarPfx, i, 0)
+ // x.line("r.EncodeMapStart(" + strconv.FormatInt(int64(len(tisfi)), 10) + ")")
x.line("}") // close if not StructToArray
for j, si := range tisfi {
@@ -991,17 +914,17 @@ func (x *genRunner) encStruct(varname string, rtid uintptr, t reflect.Type) {
isNilVarName := genTempVarPfx + "n" + i
var labelUsed bool
var t2 reflect.StructField
- {
+ if si.i != -1 {
+ t2 = t.Field(int(si.i))
+ } else {
t2typ := t
varname3 := varname
- for ij, ix := range si.is {
- if uint8(ij) == si.nis {
- break
- }
+ for _, ix := range si.is {
+ // fmt.Printf("%%%% %v, ix: %v\n", t2typ, ix)
for t2typ.Kind() == reflect.Ptr {
t2typ = t2typ.Elem()
}
- t2 = t2typ.Field(int(ix))
+ t2 = t2typ.Field(ix)
t2typ = t2.Type
varname3 = varname3 + "." + t2.Name
if t2typ.Kind() == reflect.Ptr {
@@ -1024,14 +947,14 @@ func (x *genRunner) encStruct(varname string, rtid uintptr, t reflect.Type) {
x.linef("if %s || %s {", ti2arrayvar, struct2arrvar) // if ti.toArray
if labelUsed {
- x.linef("if %s { r.WriteArrayElem(); r.EncodeNil() } else { ", isNilVarName)
+ x.line("if " + isNilVarName + " { r.EncodeNil() } else { ")
}
- x.line("r.WriteArrayElem()")
- if si.omitEmpty() {
+ x.linef("z.EncSendContainerState(codecSelfer_containerArrayElem%s)", x.xs)
+ if si.omitEmpty {
x.linef("if %s[%v] {", numfieldsvar, j)
}
x.encVar(varname+"."+t2.Name, t2.Type)
- if si.omitEmpty() {
+ if si.omitEmpty {
x.linef("} else {")
x.encZero(t2.Type)
x.linef("}")
@@ -1042,25 +965,12 @@ func (x *genRunner) encStruct(varname string, rtid uintptr, t reflect.Type) {
x.linef("} else {") // if not ti.toArray
- if si.omitEmpty() {
+ if si.omitEmpty {
x.linef("if %s[%v] {", numfieldsvar, j)
}
- x.line("r.WriteMapElemKey()")
-
- // x.line("r.EncodeString(codecSelferCcUTF8" + x.xs + ", `" + si.encName + "`)")
- // emulate EncStructFieldKey
- switch ti.keyType {
- case valueTypeInt:
- x.linef("r.EncodeInt(z.M.Int(strconv.ParseInt(`%s`, 10, 64)))", si.encName)
- case valueTypeUint:
- x.linef("r.EncodeUint(z.M.Uint(strconv.ParseUint(`%s`, 10, 64)))", si.encName)
- case valueTypeFloat:
- x.linef("r.EncodeFloat64(z.M.Float(strconv.ParseFloat(`%s`, 64)))", si.encName)
- default: // string
- x.linef("r.EncodeString(codecSelferCcUTF8%s, `%s`)", x.xs, si.encName)
- }
- // x.linef("r.EncStructFieldKey(codecSelferValueType%s%s, `%s`)", ti.keyType.String(), x.xs, si.encName)
- x.line("r.WriteMapElemValue()")
+ x.linef("z.EncSendContainerState(codecSelfer_containerMapKey%s)", x.xs)
+ x.line("r.EncodeString(codecSelferC_UTF8" + x.xs + ", string(\"" + si.encName + "\"))")
+ x.linef("z.EncSendContainerState(codecSelfer_containerMapValue%s)", x.xs)
if labelUsed {
x.line("if " + isNilVarName + " { r.EncodeNil() } else { ")
x.encVar(varname+"."+t2.Name, t2.Type)
@@ -1068,218 +978,136 @@ func (x *genRunner) encStruct(varname string, rtid uintptr, t reflect.Type) {
} else {
x.encVar(varname+"."+t2.Name, t2.Type)
}
- if si.omitEmpty() {
+ 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.linef("z.EncSendContainerState(codecSelfer_containerArrayEnd%s)", x.xs)
x.line("} else {")
- x.line("r.WriteMapEnd()")
+ x.linef("z.EncSendContainerState(codecSelfer_containerMapEnd%s)", x.xs)
x.line("}")
}
func (x *genRunner) encListFallback(varname string, t reflect.Type) {
- elemBytes := t.Elem().Kind() == reflect.Uint8
if t.AssignableTo(uint8SliceTyp) {
- x.linef("r.EncodeStringBytes(codecSelferCcRAW%s, []byte(%s))", x.xs, varname)
+ x.linef("r.EncodeStringBytes(codecSelferC_RAW%s, []byte(%s))", x.xs, varname)
return
}
- if t.Kind() == reflect.Array && elemBytes {
- x.linef("r.EncodeStringBytes(codecSelferCcRAW%s, ((*[%d]byte)(%s))[:])", x.xs, t.Len(), varname)
+ if t.Kind() == reflect.Array && t.Elem().Kind() == reflect.Uint8 {
+ x.linef("r.EncodeStringBytes(codecSelferC_RAW%s, ([%v]byte(%s))[:])", x.xs, t.Len(), varname)
return
}
i := x.varsfx()
+ g := genTempVarPfx
+ x.line("r.EncodeArrayStart(len(" + varname + "))")
if t.Kind() == reflect.Chan {
- type ts struct {
- Label, Chan, Slice, Sfx string
- }
- tm, err := template.New("").Parse(genEncChanTmpl)
- if err != nil {
- panic(err)
- }
- x.linef("if %s == nil { r.EncodeNil() } else { ", varname)
- x.linef("var sch%s []%s", i, x.genTypeName(t.Elem()))
- err = tm.Execute(x.w, &ts{"Lsch" + i, varname, "sch" + i, i})
- if err != nil {
- panic(err)
- }
- // x.linef("%s = sch%s", varname, i)
- if elemBytes {
- x.linef("r.EncodeStringBytes(codecSelferCcRAW%s, []byte(%s))", x.xs, "sch"+i)
- x.line("}")
- return
- }
- varname = "sch" + i
+ x.linef("for %si%s, %si2%s := 0, len(%s); %si%s < %si2%s; %si%s++ {", g, i, g, i, varname, g, i, g, i, g, i)
+ x.linef("z.EncSendContainerState(codecSelfer_containerArrayElem%s)", x.xs)
+ x.linef("%sv%s := <-%s", g, i, varname)
+ } else {
+ // x.linef("for %si%s, %sv%s := range %s {", genTempVarPfx, i, genTempVarPfx, i, varname)
+ x.linef("for _, %sv%s := range %s {", genTempVarPfx, i, varname)
+ x.linef("z.EncSendContainerState(codecSelfer_containerArrayElem%s)", x.xs)
}
-
- x.line("r.WriteArrayStart(len(" + varname + "))")
- x.linef("for _, %sv%s := range %s {", genTempVarPfx, i, varname)
- x.line("r.WriteArrayElem()")
-
x.encVar(genTempVarPfx+"v"+i, t.Elem())
x.line("}")
- x.line("r.WriteArrayEnd()")
- if t.Kind() == reflect.Chan {
- x.line("}")
- }
+ x.linef("z.EncSendContainerState(codecSelfer_containerArrayEnd%s)", x.xs)
}
func (x *genRunner) encMapFallback(varname string, t reflect.Type) {
// TODO: expand this to handle canonical.
i := x.varsfx()
- x.line("r.WriteMapStart(len(" + varname + "))")
+ x.line("r.EncodeMapStart(len(" + varname + "))")
x.linef("for %sk%s, %sv%s := range %s {", genTempVarPfx, i, genTempVarPfx, i, varname)
- x.line("r.WriteMapElemKey()")
+ // x.line("for " + genTempVarPfx + "k" + i + ", " + genTempVarPfx + "v" + i + " := range " + varname + " {")
+ x.linef("z.EncSendContainerState(codecSelfer_containerMapKey%s)", x.xs)
x.encVar(genTempVarPfx+"k"+i, t.Key())
- x.line("r.WriteMapElemValue()")
+ x.linef("z.EncSendContainerState(codecSelfer_containerMapValue%s)", x.xs)
x.encVar(genTempVarPfx+"v"+i, t.Elem())
x.line("}")
- x.line("r.WriteMapEnd()")
+ x.linef("z.EncSendContainerState(codecSelfer_containerMapEnd%s)", x.xs)
}
-func (x *genRunner) decVarInitPtr(varname, nilvar string, t reflect.Type, si *structFieldInfo,
- newbuf, nilbuf *genBuf) (t2 reflect.StructField) {
- //we must accommodate anonymous fields, where the embedded field is a nil pointer in the value.
- // t2 = t.FieldByIndex(si.is)
- t2typ := t
- varname3 := varname
- t2kind := t2typ.Kind()
- var nilbufed bool
- if si != nil {
- for ij, ix := range si.is {
- if uint8(ij) == si.nis {
- break
- }
- for t2typ.Kind() == reflect.Ptr {
- t2typ = t2typ.Elem()
- }
- t2 = t2typ.Field(int(ix))
- t2typ = t2.Type
- varname3 = varname3 + "." + t2.Name
- t2kind = t2typ.Kind()
- if t2kind != reflect.Ptr {
- continue
- }
- if newbuf != nil {
- newbuf.f("if %s == nil { %s = new(%s) }\n", varname3, varname3, x.genTypeName(t2typ.Elem()))
- }
- if nilbuf != nil {
- if !nilbufed {
- nilbuf.s("if true")
- nilbufed = true
- }
- nilbuf.s(" && ").s(varname3).s(" != nil")
- }
- }
- }
- // if t2typ.Kind() == reflect.Ptr {
- // varname3 = varname3 + t2.Name
- // }
- if nilbuf != nil {
- if nilbufed {
- nilbuf.s(" { ")
- }
- if nilvar != "" {
- nilbuf.s(nilvar).s(" = true")
- } else if tk := t2typ.Kind(); tk == reflect.Ptr {
- if strings.IndexByte(varname3, '.') != -1 || strings.IndexByte(varname3, '[') != -1 {
- nilbuf.s(varname3).s(" = nil")
- } else {
- nilbuf.s("*").s(varname3).s(" = ").s(x.genZeroValueR(t2typ.Elem()))
- }
- } else {
- nilbuf.s(varname3).s(" = ").s(x.genZeroValueR(t2typ))
- }
- if nilbufed {
- nilbuf.s("}")
- }
- }
- return t2
-}
-
-// decVar takes a variable called varname, of type t
-func (x *genRunner) decVarMain(varname, rand string, t reflect.Type, checkNotNil bool) {
+func (x *genRunner) decVar(varname string, t reflect.Type, canBeNil bool) {
// We only encode as nil if a nillable value.
// This removes some of the wasted checks for TryDecodeAsNil.
// We need to think about this more, to see what happens if omitempty, etc
// cause a nil value to be stored when something is expected.
// 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.
- var varname2 string
+ i := x.varsfx()
+ if !canBeNil {
+ canBeNil = genAnythingCanBeNil || !genIsImmutable(t)
+ }
+ if canBeNil {
+ x.line("if r.TryDecodeAsNil() {")
+ if t.Kind() == reflect.Ptr {
+ x.line("if " + varname + " != nil { ")
+
+ // if varname is a field of a struct (has a dot in it),
+ // then just set it to nil
+ if strings.IndexByte(varname, '.') != -1 {
+ x.line(varname + " = nil")
+ } else {
+ x.line("*" + varname + " = " + x.genZeroValueR(t.Elem()))
+ }
+ x.line("}")
+ } else {
+ x.line(varname + " = " + x.genZeroValueR(t))
+ }
+ x.line("} else {")
+ } else {
+ x.line("// cannot be nil")
+ }
if t.Kind() != reflect.Ptr {
- if t.PkgPath() != "" || !x.decTryAssignPrimitive(varname, t, false) {
- x.dec(varname, t, false)
+ if x.decTryAssignPrimitive(varname, t) {
+ x.line(genTempVarPfx + "v" + i + " := &" + varname)
+ x.dec(genTempVarPfx+"v"+i, t)
}
} else {
- if checkNotNil {
- x.linef("if %s == nil { %s = new(%s) }", varname, varname, x.genTypeName(t.Elem()))
- }
+ x.linef("if %s == nil { %s = new(%s) }", varname, varname, x.genTypeName(t.Elem()))
// Ensure we set underlying ptr to a non-nil value (so we can deref to it later).
// There's a chance of a **T in here which is nil.
var ptrPfx string
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))
+ }
+ // if varname has [ in it, then create temp variable for this ptr thingie
+ if strings.Index(varname, "[") >= 0 {
+ varname2 := genTempVarPfx + "w" + i
+ x.line(varname2 + " := " + varname)
+ varname = varname2
}
- // Should we create temp var if a slice/map indexing? No. dec(...) can now handle it.
if ptrPfx == "" {
- x.dec(varname, t, true)
+ x.dec(varname, t)
} else {
- varname2 = genTempVarPfx + "z" + rand
- x.line(varname2 + " := " + ptrPfx + varname)
- x.dec(varname2, t, true)
+ x.line(genTempVarPfx + "z" + i + " := " + ptrPfx + varname)
+ x.dec(genTempVarPfx+"z"+i, t)
}
+
}
-}
-
-// 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.
- // We need to think about this more, to see what happens if omitempty, etc
- // cause a nil value to be stored when something is expected.
- // 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 {
- 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.line("} ")
}
}
-// dec will decode a variable (varname) of type t or ptrTo(t) if isptr==true.
+// dec will decode a variable (varname) of type ptrTo(t).
// t is always a basetype (i.e. not of kind reflect.Ptr).
-func (x *genRunner) dec(varname string, t reflect.Type, isptr bool) {
+func (x *genRunner) dec(varname string, t reflect.Type) {
// assumptions:
// - the varname is to a pointer already. No need to take address of it
// - t is always a baseType T (not a *T, etc).
- rtid := rt2id(t)
- ti2 := x.ti.get(rtid, t)
- // tptr := reflect.PtrTo(t)
+ rtid := reflect.ValueOf(t).Pointer()
+ tptr := reflect.PtrTo(t)
if x.checkForSelfer(t, varname) {
- if ti2.cs || ti2.csp { // t.Implements(selferTyp) || tptr.Implements(selferTyp) {
+ if t.Implements(selferTyp) || tptr.Implements(selferTyp) {
x.line(varname + ".CodecDecodeSelf(d)")
return
}
@@ -1308,61 +1136,100 @@ func (x *genRunner) dec(varname string, t reflect.Type, isptr bool) {
}
// check if
- // - type is time.Time, Raw, RawExt
+ // - type is Raw, RawExt
// - 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.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 ptrPfx, addrPfx string
- if isptr {
- ptrPfx = "*"
- } else {
- addrPfx = "&"
- }
- if t == timeTyp {
- x.linef("} else { %s%v = r.DecodeTime()", ptrPfx, varname)
- return
- }
if t == rawTyp {
- x.linef("} else { %s%v = z.DecRaw()", ptrPfx, varname)
+ x.linef("} else { *%v = z.DecRaw()", varname)
return
}
-
if t == rawExtTyp {
- x.linef("} else { r.DecodeExt(%s%v, 0, nil)", addrPfx, varname)
+ x.linef("} else { r.DecodeExt(%v, 0, nil)", varname)
return
}
+ // HACK: Support for Builtins.
+ // Currently, only Binc supports builtins, and the only builtin type is time.Time.
+ // Have a method that returns the rtid for time.Time if Handle is Binc.
+ if t == timeTyp {
+ vrtid := genTempVarPfx + "m" + x.varsfx()
+ x.linef("} else if %s := z.TimeRtidIfBinc(); %s != 0 { ", vrtid, vrtid)
+ x.linef("r.DecodeBuiltin(%s, %s)", vrtid, varname)
+ }
// only check for extensions if the type is named, and has a packagePath.
- if !x.nx && genImportPath(t) != "" && t.Name() != "" {
+ if 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("} else if z.HasExtensions() && z.DecExt(%s) {", varname)
}
- if ti2.bu || ti2.bup { // t.Implements(binaryUnmarshalerTyp) || tptr.Implements(binaryUnmarshalerTyp) {
- x.linef("} else if z.DecBinary() { z.DecBinaryUnmarshal(%s%v) ", addrPfx, varname)
+ if t.Implements(binaryUnmarshalerTyp) || tptr.Implements(binaryUnmarshalerTyp) {
+ x.linef("} else if %sm%s { z.DecBinaryUnmarshal(%v) ", genTempVarPfx, mi, 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 t.Implements(jsonUnmarshalerTyp) || tptr.Implements(jsonUnmarshalerTyp) {
+ x.linef("} else if !%sm%s && z.IsJSONHandle() { z.DecJSONUnmarshal(%v)", genTempVarPfx, mi, varname)
+ } else if t.Implements(textUnmarshalerTyp) || tptr.Implements(textUnmarshalerTyp) {
+ x.linef("} else if !%sm%s { z.DecTextUnmarshal(%v)", genTempVarPfx, mi, varname)
}
x.line("} else {")
- if x.decTryAssignPrimitive(varname, t, isptr) {
- return
- }
-
+ // Since these are pointers, we cannot share, and have to use them one by one
switch t.Kind() {
+ case reflect.Int:
+ x.line("*((*int)(" + varname + ")) = int(r.DecodeInt(codecSelferBitsize" + x.xs + "))")
+ // x.line("z.DecInt((*int)(" + varname + "))")
+ case reflect.Int8:
+ x.line("*((*int8)(" + varname + ")) = int8(r.DecodeInt(8))")
+ // x.line("z.DecInt8((*int8)(" + varname + "))")
+ case reflect.Int16:
+ x.line("*((*int16)(" + varname + ")) = int16(r.DecodeInt(16))")
+ // x.line("z.DecInt16((*int16)(" + varname + "))")
+ case reflect.Int32:
+ x.line("*((*int32)(" + varname + ")) = int32(r.DecodeInt(32))")
+ // x.line("z.DecInt32((*int32)(" + varname + "))")
+ case reflect.Int64:
+ x.line("*((*int64)(" + varname + ")) = int64(r.DecodeInt(64))")
+ // x.line("z.DecInt64((*int64)(" + varname + "))")
+
+ case reflect.Uint:
+ x.line("*((*uint)(" + varname + ")) = uint(r.DecodeUint(codecSelferBitsize" + x.xs + "))")
+ // x.line("z.DecUint((*uint)(" + varname + "))")
+ case reflect.Uint8:
+ x.line("*((*uint8)(" + varname + ")) = uint8(r.DecodeUint(8))")
+ // x.line("z.DecUint8((*uint8)(" + varname + "))")
+ case reflect.Uint16:
+ x.line("*((*uint16)(" + varname + ")) = uint16(r.DecodeUint(16))")
+ //x.line("z.DecUint16((*uint16)(" + varname + "))")
+ case reflect.Uint32:
+ x.line("*((*uint32)(" + varname + ")) = uint32(r.DecodeUint(32))")
+ //x.line("z.DecUint32((*uint32)(" + varname + "))")
+ case reflect.Uint64:
+ x.line("*((*uint64)(" + varname + ")) = uint64(r.DecodeUint(64))")
+ //x.line("z.DecUint64((*uint64)(" + varname + "))")
+ case reflect.Uintptr:
+ x.line("*((*uintptr)(" + varname + ")) = uintptr(r.DecodeUint(codecSelferBitsize" + x.xs + "))")
+
+ case reflect.Float32:
+ x.line("*((*float32)(" + varname + ")) = float32(r.DecodeFloat(true))")
+ //x.line("z.DecFloat32((*float32)(" + varname + "))")
+ case reflect.Float64:
+ x.line("*((*float64)(" + varname + ")) = float64(r.DecodeFloat(false))")
+ // x.line("z.DecFloat64((*float64)(" + varname + "))")
+
+ case reflect.Bool:
+ x.line("*((*bool)(" + varname + ")) = r.DecodeBool()")
+ // x.line("z.DecBool((*bool)(" + varname + "))")
+ case reflect.String:
+ x.line("*((*string)(" + varname + ")) = r.DecodeString()")
+ // x.line("z.DecString((*string)(" + varname + "))")
case reflect.Array, reflect.Chan:
- x.xtraSM(varname, t, false, isptr)
+ x.xtraSM(varname, false, t)
+ // x.decListFallback(varname, rtid, true, t)
case reflect.Slice:
// if a []uint8, call dedicated function
// if a known fastpath slice, call dedicated function
@@ -1370,13 +1237,12 @@ 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 rtid == uint8SliceTypId {
- x.linef("%s%s = r.DecodeBytes(%s(%s[]byte)(%s), false)",
- ptrPfx, varname, ptrPfx, ptrPfx, varname)
+ x.line("*" + varname + " = r.DecodeBytes(*(*[]byte)(" + varname + "), false, false)")
} else if fastpathAV.index(rtid) != -1 {
g := x.newGenV(t)
- x.linef("z.F.%sX(%s%s, d)", g.MethodNamePfx("Dec", false), addrPfx, varname)
+ x.line("z.F." + g.MethodNamePfx("Dec", false) + "X(" + varname + ", false, d)")
} else {
- x.xtraSM(varname, t, false, isptr)
+ x.xtraSM(varname, false, t)
// x.decListFallback(varname, rtid, false, t)
}
case reflect.Map:
@@ -1386,89 +1252,83 @@ func (x *genRunner) dec(varname string, t reflect.Type, isptr bool) {
// - else call Encoder.encode(XXX) on it.
if fastpathAV.index(rtid) != -1 {
g := x.newGenV(t)
- x.linef("z.F.%sX(%s%s, d)", g.MethodNamePfx("Dec", false), addrPfx, varname)
+ x.line("z.F." + g.MethodNamePfx("Dec", false) + "X(" + varname + ", false, d)")
} else {
- x.xtraSM(varname, t, false, isptr)
+ x.xtraSM(varname, false, t)
// x.decMapFallback(varname, rtid, t)
}
case reflect.Struct:
if inlist {
- // no need to create temp variable if isptr, or x.F or x[F]
- if isptr || strings.IndexByte(varname, '.') != -1 || strings.IndexByte(varname, '[') != -1 {
- x.decStruct(varname, rtid, t)
- } else {
- varname2 := genTempVarPfx + "j" + mi
- x.line(varname2 + " := &" + varname)
- x.decStruct(varname2, rtid, t)
- }
+ x.decStruct(varname, rtid, t)
} else {
// delete(x.td, rtid)
- x.line("z.DecFallback(" + addrPfx + varname + ", false)")
+ x.line("z.DecFallback(" + varname + ", false)")
}
default:
if rtidAdded {
delete(x.te, rtid)
}
- x.line("z.DecFallback(" + addrPfx + varname + ", true)")
+ x.line("z.DecFallback(" + varname + ", true)")
}
}
-func (x *genRunner) decTryAssignPrimitive(varname string, t reflect.Type, isptr bool) (done bool) {
+func (x *genRunner) decTryAssignPrimitive(varname string, t reflect.Type) (tryAsPtr bool) {
// This should only be used for exact primitives (ie un-named types).
// Named types may be implementations of Selfer, Unmarshaler, etc.
// They should be handled by dec(...)
- var ptr string
- if isptr {
- ptr = "*"
+ if t.Name() != "" {
+ tryAsPtr = true
+ return
}
+
switch t.Kind() {
case reflect.Int:
- x.linef("%s%s = (%s)(z.C.IntV(r.DecodeInt64(), codecSelferBitsize%s))", ptr, varname, x.genTypeName(t), x.xs)
+ x.linef("%s = r.DecodeInt(codecSelferBitsize%s)", varname, x.xs)
case reflect.Int8:
- x.linef("%s%s = (%s)(z.C.IntV(r.DecodeInt64(), 8))", ptr, varname, x.genTypeName(t))
+ x.linef("%s = r.DecodeInt(8)", varname)
case reflect.Int16:
- x.linef("%s%s = (%s)(z.C.IntV(r.DecodeInt64(), 16))", ptr, varname, x.genTypeName(t))
+ x.linef("%s = r.DecodeInt(16)", varname)
case reflect.Int32:
- x.linef("%s%s = (%s)(z.C.IntV(r.DecodeInt64(), 32))", ptr, varname, x.genTypeName(t))
+ x.linef("%s = r.DecodeInt(32)", varname)
case reflect.Int64:
- x.linef("%s%s = (%s)(r.DecodeInt64())", ptr, varname, x.genTypeName(t))
+ x.linef("%s = r.DecodeInt(64)", varname)
case reflect.Uint:
- x.linef("%s%s = (%s)(z.C.UintV(r.DecodeUint64(), codecSelferBitsize%s))", ptr, varname, x.genTypeName(t), x.xs)
+ x.linef("%s = r.DecodeUint(codecSelferBitsize%s)", varname, x.xs)
case reflect.Uint8:
- x.linef("%s%s = (%s)(z.C.UintV(r.DecodeUint64(), 8))", ptr, varname, x.genTypeName(t))
+ x.linef("%s = r.DecodeUint(8)", varname)
case reflect.Uint16:
- x.linef("%s%s = (%s)(z.C.UintV(r.DecodeUint64(), 16))", ptr, varname, x.genTypeName(t))
+ x.linef("%s = r.DecodeUint(16)", varname)
case reflect.Uint32:
- x.linef("%s%s = (%s)(z.C.UintV(r.DecodeUint64(), 32))", ptr, varname, x.genTypeName(t))
+ x.linef("%s = r.DecodeUint(32)", varname)
case reflect.Uint64:
- x.linef("%s%s = (%s)(r.DecodeUint64())", ptr, varname, x.genTypeName(t))
+ x.linef("%s = r.DecodeUint(64)", varname)
case reflect.Uintptr:
- x.linef("%s%s = (%s)(z.C.UintV(r.DecodeUint64(), codecSelferBitsize%s))", ptr, varname, x.genTypeName(t), x.xs)
+ x.linef("%s = r.DecodeUint(codecSelferBitsize%s)", varname, x.xs)
case reflect.Float32:
- x.linef("%s%s = (%s)(r.DecodeFloat32As64())", ptr, varname, x.genTypeName(t))
+ x.linef("%s = r.DecodeFloat(true)", varname)
case reflect.Float64:
- x.linef("%s%s = (%s)(r.DecodeFloat64())", ptr, varname, x.genTypeName(t))
+ x.linef("%s = r.DecodeFloat(false)", varname)
case reflect.Bool:
- x.linef("%s%s = (%s)(r.DecodeBool())", ptr, varname, x.genTypeName(t))
+ x.linef("%s = r.DecodeBool()", varname)
case reflect.String:
- x.linef("%s%s = (%s)(r.DecodeString())", ptr, varname, x.genTypeName(t))
+ x.linef("%s = r.DecodeString()", varname)
default:
- return false
+ tryAsPtr = true
}
- return true
+ return
}
func (x *genRunner) decListFallback(varname string, rtid uintptr, t reflect.Type) {
if t.AssignableTo(uint8SliceTyp) {
- x.line("*" + varname + " = r.DecodeBytes(*((*[]byte)(" + varname + ")), false)")
+ x.line("*" + varname + " = r.DecodeBytes(*((*[]byte)(" + varname + ")), false, false)")
return
}
if t.Kind() == reflect.Array && t.Elem().Kind() == reflect.Uint8 {
- x.linef("r.DecodeBytes( ((*[%d]byte)(%s))[:], true)", t.Len(), varname)
+ x.linef("r.DecodeBytes( ((*[%s]byte)(%s))[:], false, true)", t.Len(), varname)
return
}
type tstruc struct {
@@ -1486,7 +1346,11 @@ func (x *genRunner) decListFallback(varname string, rtid uintptr, t reflect.Type
funcs := make(template.FuncMap)
funcs["decLineVar"] = func(varname string) string {
- x.decVar(varname, "", telem, false, true)
+ x.decVar(varname, telem, false)
+ return ""
+ }
+ funcs["decLine"] = func(pfx string) string {
+ x.decVar(ts.TempVar+pfx+ts.Rand, reflect.PtrTo(telem), false)
return ""
}
funcs["var"] = func(s string) string {
@@ -1544,11 +1408,19 @@ func (x *genRunner) decMapFallback(varname string, rtid uintptr, t reflect.Type)
return telem.Kind() == reflect.Interface
}
funcs["decLineVarK"] = func(varname string) string {
- x.decVar(varname, "", tkey, false, true)
+ x.decVar(varname, tkey, false)
return ""
}
- funcs["decLineVar"] = func(varname, decodedNilVarname string) string {
- x.decVar(varname, decodedNilVarname, telem, false, true)
+ funcs["decLineVar"] = func(varname string) string {
+ x.decVar(varname, telem, false)
+ return ""
+ }
+ funcs["decLineK"] = func(pfx string) string {
+ x.decVar(ts.TempVar+pfx+ts.Rand, reflect.PtrTo(tkey), false)
+ return ""
+ }
+ funcs["decLine"] = func(pfx string) string {
+ x.decVar(ts.TempVar+pfx+ts.Rand, reflect.PtrTo(telem), false)
return ""
}
funcs["var"] = func(s string) string {
@@ -1566,17 +1438,31 @@ func (x *genRunner) decMapFallback(varname string, rtid uintptr, t reflect.Type)
func (x *genRunner) decStructMapSwitch(kName string, varname string, rtid uintptr, t reflect.Type) {
ti := x.ti.get(rtid, t)
- tisfi := ti.sfiSrc // always use sequence from file. decStruct expects same thing.
+ tisfi := ti.sfip // always use sequence from file. decStruct expects same thing.
x.line("switch (" + kName + ") {")
- var newbuf, nilbuf genBuf
for _, si := range tisfi {
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("}")
+ var t2 reflect.StructField
+ if si.i != -1 {
+ t2 = t.Field(int(si.i))
+ } else {
+ //we must accommodate anonymous fields, where the embedded field is a nil pointer in the value.
+ // t2 = t.FieldByIndex(si.is)
+ t2typ := t
+ varname3 := varname
+ for _, ix := range si.is {
+ for t2typ.Kind() == reflect.Ptr {
+ t2typ = t2typ.Elem()
+ }
+ t2 = t2typ.Field(ix)
+ t2typ = t2.Type
+ varname3 = varname3 + "." + t2.Name
+ if t2typ.Kind() == reflect.Ptr {
+ x.linef("if %s == nil { %s = new(%s) }", varname3, varname3, x.genTypeName(t2typ.Elem()))
+ }
+ }
+ }
+ x.decVar(varname+"."+t2.Name, t2.Type, false)
}
x.line("default:")
// pass the slice here, so that the string will not escape, and maybe save allocation
@@ -1586,10 +1472,27 @@ func (x *genRunner) decStructMapSwitch(kName string, varname string, rtid uintpt
func (x *genRunner) decStructMap(varname, lenvarname string, rtid uintptr, t reflect.Type, style genStructMapStyle) {
tpfx := genTempVarPfx
- ti := x.ti.get(rtid, t)
i := x.varsfx()
kName := tpfx + "s" + i
+ // We thought to use ReadStringAsBytes, as go compiler might optimize the copy out.
+ // However, using that was more expensive, as it seems that the switch expression
+ // is evaluated each time.
+ //
+ // We could depend on decodeString using a temporary/shared buffer internally.
+ // However, this model of creating a byte array, and using explicitly is faster,
+ // and allows optional use of unsafe []byte->string conversion without alloc.
+
+ // Also, ensure that the slice array doesn't escape.
+ // That will help escape analysis prevent allocation when it gets better.
+
+ // x.line("var " + kName + "Arr = [32]byte{} // default string to decode into")
+ // x.line("var " + kName + "Slc = " + kName + "Arr[:] // default slice to decode into")
+ // use the scratch buffer to avoid allocation (most field names are < 32).
+
+ x.line("var " + kName + "Slc = z.DecScratchBuffer() // default slice to decode into")
+
+ x.line("_ = " + kName + "Slc")
switch style {
case genStructMapStyleLenPrefix:
x.linef("for %sj%s := 0; %sj%s < %s; %sj%s++ {", tpfx, i, tpfx, i, lenvarname, tpfx, i)
@@ -1601,49 +1504,60 @@ func (x *genRunner) decStructMap(varname, lenvarname string, rtid uintptr, t ref
x.linef("if %shl%s { if %sj%s >= %s { break }", tpfx, i, tpfx, i, lenvarname)
x.line("} else { if r.CheckBreak() { break }; }")
}
- x.line("r.ReadMapElemKey()")
-
- // emulate decstructfieldkey
- switch ti.keyType {
- case valueTypeInt:
- x.linef("%s := z.StringView(strconv.AppendInt(z.DecScratchArrayBuffer()[:0], r.DecodeInt64(), 10))", kName)
- case valueTypeUint:
- x.linef("%s := z.StringView(strconv.AppendUint(z.DecScratchArrayBuffer()[:0], r.DecodeUint64(), 10))", kName)
- case valueTypeFloat:
- x.linef("%s := z.StringView(strconv.AppendFloat(z.DecScratchArrayBuffer()[:0], r.DecodeFloat64(), 'f', -1, 64))", kName)
- default: // string
- x.linef("%s := z.StringView(r.DecodeStringAsBytes())", kName)
+ x.linef("z.DecSendContainerState(codecSelfer_containerMapKey%s)", x.xs)
+ x.line(kName + "Slc = r.DecodeBytes(" + kName + "Slc, true, true)")
+ // let string be scoped to this loop alone, so it doesn't escape.
+ if x.unsafe {
+ x.line(kName + "SlcHdr := codecSelferUnsafeString" + x.xs + "{uintptr(unsafe.Pointer(&" +
+ kName + "Slc[0])), len(" + kName + "Slc)}")
+ x.line(kName + " := *(*string)(unsafe.Pointer(&" + kName + "SlcHdr))")
+ } else {
+ x.line(kName + " := string(" + kName + "Slc)")
}
- // x.linef("%s := z.StringView(r.DecStructFieldKey(codecSelferValueType%s%s, z.DecScratchArrayBuffer()))", kName, ti.keyType.String(), x.xs)
-
- x.line("r.ReadMapElemValue()")
+ x.linef("z.DecSendContainerState(codecSelfer_containerMapValue%s)", x.xs)
x.decStructMapSwitch(kName, varname, rtid, t)
x.line("} // end for " + tpfx + "j" + i)
- x.line("r.ReadMapEnd()")
+ x.linef("z.DecSendContainerState(codecSelfer_containerMapEnd%s)", x.xs)
}
func (x *genRunner) decStructArray(varname, lenvarname, breakString string, rtid uintptr, t reflect.Type) {
tpfx := genTempVarPfx
i := x.varsfx()
ti := x.ti.get(rtid, t)
- tisfi := ti.sfiSrc // always use sequence from file. decStruct expects same thing.
+ tisfi := ti.sfip // always use sequence from file. decStruct expects same thing.
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 {
+ var t2 reflect.StructField
+ if si.i != -1 {
+ t2 = t.Field(int(si.i))
+ } else {
+ //we must accommodate anonymous fields, where the embedded field is a nil pointer in the value.
+ // t2 = t.FieldByIndex(si.is)
+ t2typ := t
+ varname3 := varname
+ for _, ix := range si.is {
+ for t2typ.Kind() == reflect.Ptr {
+ t2typ = t2typ.Elem()
+ }
+ t2 = t2typ.Field(ix)
+ t2typ = t2.Type
+ varname3 = varname3 + "." + t2.Name
+ if t2typ.Kind() == reflect.Ptr {
+ x.linef("if %s == nil { %s = new(%s) }", varname3, varname3, x.genTypeName(t2typ.Elem()))
+ }
+ }
+ }
+
x.linef("%sj%s++; if %shl%s { %sb%s = %sj%s > %s } else { %sb%s = r.CheckBreak() }",
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()")
- 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("}")
+ x.linef("if %sb%s { z.DecSendContainerState(codecSelfer_containerArrayEnd%s); %s }",
+ tpfx, i, x.xs, breakString)
+ x.linef("z.DecSendContainerState(codecSelfer_containerArrayElem%s)", x.xs)
+ x.decVar(varname+"."+t2.Name, t2.Type, true)
}
// read remaining values and throw away.
x.line("for {")
@@ -1651,28 +1565,28 @@ func (x *genRunner) decStructArray(varname, lenvarname, breakString string, rtid
tpfx, i, tpfx, i, tpfx, i,
tpfx, i, lenvarname, tpfx, i)
x.linef("if %sb%s { break }", tpfx, i)
- x.line("r.ReadArrayElem()")
+ x.linef("z.DecSendContainerState(codecSelfer_containerArrayElem%s)", x.xs)
x.linef(`z.DecStructFieldNotFound(%sj%s - 1, "")`, tpfx, i)
x.line("}")
- x.line("r.ReadArrayEnd()")
+ x.linef("z.DecSendContainerState(codecSelfer_containerArrayEnd%s)", x.xs)
}
func (x *genRunner) decStruct(varname string, rtid uintptr, t reflect.Type) {
- // varname MUST be a ptr, or a struct field or a slice element.
+ // if container is map
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 %sl%s == 0 {", genTempVarPfx, i)
- x.line("r.ReadMapEnd()")
+ x.linef("z.DecSendContainerState(codecSelfer_containerMapEnd%s)", x.xs)
if genUseOneFunctionForDecStructMap {
x.line("} else { ")
- x.linef("%s.codecDecodeSelfFromMap(%sl%s, d)", varname, genTempVarPfx, i)
+ x.linef("x.codecDecodeSelfFromMap(%sl%s, d)", genTempVarPfx, i)
} else {
x.line("} else if " + genTempVarPfx + "l" + i + " > 0 { ")
- x.line(varname + ".codecDecodeSelfFromMapLenPrefix(" + genTempVarPfx + "l" + i + ", d)")
+ x.line("x.codecDecodeSelfFromMapLenPrefix(" + genTempVarPfx + "l" + i + ", d)")
x.line("} else {")
- x.line(varname + ".codecDecodeSelfFromMapCheckBreak(" + genTempVarPfx + "l" + i + ", d)")
+ x.line("x.codecDecodeSelfFromMapCheckBreak(" + genTempVarPfx + "l" + i + ", d)")
}
x.line("}")
@@ -1680,13 +1594,13 @@ func (x *genRunner) decStruct(varname string, rtid uintptr, t reflect.Type) {
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.linef("z.DecSendContainerState(codecSelfer_containerArrayEnd%s)", x.xs)
x.line("} else { ")
- x.linef("%s.codecDecodeSelfFromArray(%sl%s, d)", varname, genTempVarPfx, i)
+ x.linef("x.codecDecodeSelfFromArray(%sl%s, d)", genTempVarPfx, i)
x.line("}")
// else panic
x.line("} else { ")
- x.line("panic(errCodecSelferOnlyMapOrArrayEncodeToStruct" + x.xs + ")")
+ x.line("panic(codecSelferOnlyMapOrArrayEncodeToStructErr" + x.xs + ")")
x.line("} ")
}
@@ -1745,8 +1659,15 @@ func (x *genV) MethodNamePfx(prefix string, prim bool) string {
func genImportPath(t reflect.Type) (s string) {
s = t.PkgPath()
if genCheckVendor {
- // HACK: always handle vendoring. It should be typically on in go 1.6, 1.7
- s = genStripVendor(s)
+ // HACK: Misbehaviour occurs in go 1.5. May have to re-visit this later.
+ // if s contains /vendor/ OR startsWith vendor/, then return everything after it.
+ const vendorStart = "vendor/"
+ const vendorInline = "/vendor/"
+ if i := strings.LastIndex(s, vendorInline); i >= 0 {
+ s = s[i+len(vendorInline):]
+ } else if strings.HasPrefix(s, vendorStart) {
+ s = s[len(vendorStart):]
+ }
}
return
}
@@ -1868,13 +1789,13 @@ func genIsImmutable(t reflect.Type) (v bool) {
}
type genInternal struct {
- Version int
- Values []genV
+ Values []genV
+ Unsafe bool
}
func (x genInternal) FastpathLen() (l int) {
for _, v := range x.Values {
- if v.Primitive == "" && !(v.MapKey == "" && v.Elem == "uint8") {
+ if v.Primitive == "" {
l++
}
}
@@ -1894,32 +1815,6 @@ 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"},
-}
-
-func genInternalNonZeroValue(s string) string {
- switch s {
- case "interface{}", "interface {}":
- genInternalNonZeroValueIdx[0]++
- return genInternalNonZeroValueStrs[genInternalNonZeroValueIdx[0]%2][0] // return string, to remove ambiguity
- case "bool":
- genInternalNonZeroValueIdx[1]++
- return genInternalNonZeroValueStrs[genInternalNonZeroValueIdx[1]%2][1]
- case "string":
- genInternalNonZeroValueIdx[2]++
- return genInternalNonZeroValueStrs[genInternalNonZeroValueIdx[2]%2][2]
- case "float32", "float64", "float", "double":
- genInternalNonZeroValueIdx[3]++
- return genInternalNonZeroValueStrs[genInternalNonZeroValueIdx[3]%2][3]
- default:
- genInternalNonZeroValueIdx[4]++
- return genInternalNonZeroValueStrs[genInternalNonZeroValueIdx[4]%2][4]
- }
-}
-
func genInternalEncCommandAsString(s string, vname string) string {
switch s {
case "uint", "uint8", "uint16", "uint32", "uint64":
@@ -1927,15 +1822,15 @@ func genInternalEncCommandAsString(s string, vname string) string {
case "int", "int8", "int16", "int32", "int64":
return "ee.EncodeInt(int64(" + vname + "))"
case "string":
- return "ee.EncodeString(cUTF8, " + vname + ")"
+ return "ee.EncodeString(c_UTF8, " + vname + ")"
case "float32":
return "ee.EncodeFloat32(" + vname + ")"
case "float64":
return "ee.EncodeFloat64(" + vname + ")"
case "bool":
return "ee.EncodeBool(" + vname + ")"
- // case "symbol":
- // return "ee.EncodeSymbol(" + vname + ")"
+ case "symbol":
+ return "ee.EncodeSymbol(" + vname + ")"
default:
return "e.encode(" + vname + ")"
}
@@ -1944,34 +1839,34 @@ 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(dd.DecodeUint(uintBitsize))"
case "uint8":
- return "uint8(chkOvf.UintV(dd.DecodeUint64(), 8))"
+ return "uint8(dd.DecodeUint(8))"
case "uint16":
- return "uint16(chkOvf.UintV(dd.DecodeUint64(), 16))"
+ return "uint16(dd.DecodeUint(16))"
case "uint32":
- return "uint32(chkOvf.UintV(dd.DecodeUint64(), 32))"
+ return "uint32(dd.DecodeUint(32))"
case "uint64":
- return "dd.DecodeUint64()"
+ return "dd.DecodeUint(64)"
case "uintptr":
- return "uintptr(chkOvf.UintV(dd.DecodeUint64(), uintBitsize))"
+ return "uintptr(dd.DecodeUint(uintBitsize))"
case "int":
- return "int(chkOvf.IntV(dd.DecodeInt64(), intBitsize))"
+ return "int(dd.DecodeInt(intBitsize))"
case "int8":
- return "int8(chkOvf.IntV(dd.DecodeInt64(), 8))"
+ return "int8(dd.DecodeInt(8))"
case "int16":
- return "int16(chkOvf.IntV(dd.DecodeInt64(), 16))"
+ return "int16(dd.DecodeInt(16))"
case "int32":
- return "int32(chkOvf.IntV(dd.DecodeInt64(), 32))"
+ return "int32(dd.DecodeInt(32))"
case "int64":
- return "dd.DecodeInt64()"
+ return "dd.DecodeInt(64)"
case "string":
return "dd.DecodeString()"
case "float32":
- return "float32(chkOvf.Float32V(dd.DecodeFloat64()))"
+ return "float32(dd.DecodeFloat(true))"
case "float64":
- return "dd.DecodeFloat64()"
+ return "dd.DecodeFloat(false)"
case "bool":
return "dd.DecodeBool()"
default:
@@ -1995,21 +1890,8 @@ func genInternalSortType(s string, elem bool) string {
panic("sorttype: unexpected type: " + s)
}
-func genStripVendor(s string) string {
- // HACK: Misbehaviour occurs in go 1.5. May have to re-visit this later.
- // if s contains /vendor/ OR startsWith vendor/, then return everything after it.
- const vendorStart = "vendor/"
- const vendorInline = "/vendor/"
- if i := strings.LastIndex(s, vendorInline); i >= 0 {
- s = s[i+len(vendorInline):]
- } else if strings.HasPrefix(s, vendorStart) {
- s = s[len(vendorStart):]
- }
- return s
-}
-
// var genInternalMu sync.Mutex
-var genInternalV = genInternal{Version: genVersion}
+var genInternalV genInternal
var genInternalTmplFuncs template.FuncMap
var genInternalOnce sync.Once
@@ -2072,15 +1954,14 @@ func genInternalInit() {
"float64": 8,
"bool": 1,
}
- var gt = genInternal{Version: genVersion}
+ var gt genInternal
// 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]})
- // 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, genV{Elem: s, Size: mapvaltypes2[s]})
+ 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]})
+ }
if _, ok := mapvaltypes2[s]; !ok {
gt.Values = append(gt.Values, genV{MapKey: s, Elem: s, Size: 2 * mapvaltypes2[s]})
}
@@ -2094,7 +1975,6 @@ func genInternalInit() {
funcs["encmd"] = genInternalEncCommandAsString
funcs["decmd"] = genInternalDecCommandAsString
funcs["zerocmd"] = genInternalZeroValue
- funcs["nonzerocmd"] = genInternalNonZeroValue
funcs["hasprefix"] = strings.HasPrefix
funcs["sorttype"] = genInternalSortType
@@ -2106,10 +1986,11 @@ func genInternalInit() {
// It is run by the program author alone.
// Unfortunately, it has to be exported so that it can be called from a command line tool.
// *** DO NOT USE ***
-func genInternalGoFile(r io.Reader, w io.Writer) (err error) {
+func genInternalGoFile(r io.Reader, w io.Writer, safe bool) (err error) {
genInternalOnce.Do(genInternalInit)
gt := genInternalV
+ gt.Unsafe = !safe
t := template.New("").Funcs(genInternalTmplFuncs)
diff --git a/vendor/github.com/ugorji/go/codec/gen_15.go b/vendor/github.com/ugorji/go/codec/gen_15.go
new file mode 100644
index 0000000000..ab76c31027
--- /dev/null
+++ b/vendor/github.com/ugorji/go/codec/gen_15.go
@@ -0,0 +1,12 @@
+// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved.
+// Use of this source code is governed by a MIT license found in the LICENSE file.
+
+// +build go1.5,!go1.6
+
+package codec
+
+import "os"
+
+func init() {
+ genCheckVendor = os.Getenv("GO15VENDOREXPERIMENT") == "1"
+}
diff --git a/vendor/github.com/ugorji/go/codec/gen_16.go b/vendor/github.com/ugorji/go/codec/gen_16.go
new file mode 100644
index 0000000000..87c04e2e18
--- /dev/null
+++ b/vendor/github.com/ugorji/go/codec/gen_16.go
@@ -0,0 +1,12 @@
+// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved.
+// Use of this source code is governed by a MIT license found in the LICENSE file.
+
+// +build go1.6
+
+package codec
+
+import "os"
+
+func init() {
+ genCheckVendor = os.Getenv("GO15VENDOREXPERIMENT") != "0"
+}
diff --git a/vendor/github.com/ugorji/go/codec/goversion_vendor_gte_go17.go b/vendor/github.com/ugorji/go/codec/gen_17.go
similarity index 53%
rename from vendor/github.com/ugorji/go/codec/goversion_vendor_gte_go17.go
rename to vendor/github.com/ugorji/go/codec/gen_17.go
index c5b8155053..3881a43ce6 100644
--- a/vendor/github.com/ugorji/go/codec/goversion_vendor_gte_go17.go
+++ b/vendor/github.com/ugorji/go/codec/gen_17.go
@@ -1,8 +1,10 @@
-// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved.
+// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved.
// Use of this source code is governed by a MIT license found in the LICENSE file.
// +build go1.7
package codec
-const genCheckVendor = true
+func init() {
+ genCheckVendor = true
+}
diff --git a/vendor/github.com/ugorji/go/codec/goversion_arrayof_gte_go15.go b/vendor/github.com/ugorji/go/codec/goversion_arrayof_gte_go15.go
deleted file mode 100644
index 9ddbe20593..0000000000
--- a/vendor/github.com/ugorji/go/codec/goversion_arrayof_gte_go15.go
+++ /dev/null
@@ -1,14 +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 go1.5
-
-package codec
-
-import "reflect"
-
-const reflectArrayOfSupported = true
-
-func reflectArrayOf(count int, elem reflect.Type) reflect.Type {
- return reflect.ArrayOf(count, elem)
-}
diff --git a/vendor/github.com/ugorji/go/codec/goversion_arrayof_lt_go15.go b/vendor/github.com/ugorji/go/codec/goversion_arrayof_lt_go15.go
deleted file mode 100644
index c5fcd6697e..0000000000
--- a/vendor/github.com/ugorji/go/codec/goversion_arrayof_lt_go15.go
+++ /dev/null
@@ -1,14 +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 !go1.5
-
-package codec
-
-import "reflect"
-
-const reflectArrayOfSupported = false
-
-func reflectArrayOf(count int, elem reflect.Type) reflect.Type {
- panic("codec: reflect.ArrayOf unsupported in this go version")
-}
diff --git a/vendor/github.com/ugorji/go/codec/goversion_makemap_gte_go19.go b/vendor/github.com/ugorji/go/codec/goversion_makemap_gte_go19.go
deleted file mode 100644
index bc39d6b719..0000000000
--- a/vendor/github.com/ugorji/go/codec/goversion_makemap_gte_go19.go
+++ /dev/null
@@ -1,15 +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 go1.9
-
-package codec
-
-import "reflect"
-
-func makeMapReflect(t reflect.Type, size int) reflect.Value {
- if size < 0 {
- return reflect.MakeMapWithSize(t, 4)
- }
- return reflect.MakeMapWithSize(t, size)
-}
diff --git a/vendor/github.com/ugorji/go/codec/goversion_makemap_lt_go19.go b/vendor/github.com/ugorji/go/codec/goversion_makemap_lt_go19.go
deleted file mode 100644
index cde4cd3725..0000000000
--- a/vendor/github.com/ugorji/go/codec/goversion_makemap_lt_go19.go
+++ /dev/null
@@ -1,12 +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 !go1.9
-
-package codec
-
-import "reflect"
-
-func makeMapReflect(t reflect.Type, size int) reflect.Value {
- return reflect.MakeMap(t)
-}
diff --git a/vendor/github.com/ugorji/go/codec/goversion_unexportedembeddedptr_gte_go110.go b/vendor/github.com/ugorji/go/codec/goversion_unexportedembeddedptr_gte_go110.go
deleted file mode 100644
index 794133a3cb..0000000000
--- a/vendor/github.com/ugorji/go/codec/goversion_unexportedembeddedptr_gte_go110.go
+++ /dev/null
@@ -1,8 +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 go1.10
-
-package codec
-
-const allowSetUnexportedEmbeddedPtr = false
diff --git a/vendor/github.com/ugorji/go/codec/goversion_unexportedembeddedptr_lt_go110.go b/vendor/github.com/ugorji/go/codec/goversion_unexportedembeddedptr_lt_go110.go
deleted file mode 100644
index fd92ede355..0000000000
--- a/vendor/github.com/ugorji/go/codec/goversion_unexportedembeddedptr_lt_go110.go
+++ /dev/null
@@ -1,8 +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 !go1.10
-
-package codec
-
-const allowSetUnexportedEmbeddedPtr = true
diff --git a/vendor/github.com/ugorji/go/codec/goversion_unsupported_lt_go14.go b/vendor/github.com/ugorji/go/codec/goversion_unsupported_lt_go14.go
deleted file mode 100644
index 8debfa6137..0000000000
--- a/vendor/github.com/ugorji/go/codec/goversion_unsupported_lt_go14.go
+++ /dev/null
@@ -1,17 +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 !go1.4
-
-package codec
-
-// This codec package will only work for go1.4 and above.
-// This is for the following reasons:
-// - go 1.4 was released in 2014
-// - go runtime is written fully in go
-// - interface only holds pointers
-// - reflect.Value is stabilized as 3 words
-
-func init() {
- panic("codec: go 1.3 and below are not supported")
-}
diff --git a/vendor/github.com/ugorji/go/codec/goversion_vendor_eq_go15.go b/vendor/github.com/ugorji/go/codec/goversion_vendor_eq_go15.go
deleted file mode 100644
index 0f1bb01e5a..0000000000
--- a/vendor/github.com/ugorji/go/codec/goversion_vendor_eq_go15.go
+++ /dev/null
@@ -1,10 +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 go1.5,!go1.6
-
-package codec
-
-import "os"
-
-var genCheckVendor = os.Getenv("GO15VENDOREXPERIMENT") == "1"
diff --git a/vendor/github.com/ugorji/go/codec/goversion_vendor_eq_go16.go b/vendor/github.com/ugorji/go/codec/goversion_vendor_eq_go16.go
deleted file mode 100644
index 2fb4b057dd..0000000000
--- a/vendor/github.com/ugorji/go/codec/goversion_vendor_eq_go16.go
+++ /dev/null
@@ -1,10 +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 go1.6,!go1.7
-
-package codec
-
-import "os"
-
-var genCheckVendor = os.Getenv("GO15VENDOREXPERIMENT") != "0"
diff --git a/vendor/github.com/ugorji/go/codec/goversion_vendor_lt_go15.go b/vendor/github.com/ugorji/go/codec/goversion_vendor_lt_go15.go
deleted file mode 100644
index 837cf240ba..0000000000
--- a/vendor/github.com/ugorji/go/codec/goversion_vendor_lt_go15.go
+++ /dev/null
@@ -1,8 +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 !go1.5
-
-package codec
-
-var genCheckVendor = false
diff --git a/vendor/github.com/ugorji/go/codec/helper.go b/vendor/github.com/ugorji/go/codec/helper.go
index bd29895b6d..8b94fc1e4d 100644
--- a/vendor/github.com/ugorji/go/codec/helper.go
+++ b/vendor/github.com/ugorji/go/codec/helper.go
@@ -1,4 +1,4 @@
-// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved.
+// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved.
// Use of this source code is governed by a MIT license found in the LICENSE file.
package codec
@@ -102,11 +102,9 @@ import (
"encoding/binary"
"errors"
"fmt"
- "io"
"math"
"reflect"
"sort"
- "strconv"
"strings"
"sync"
"time"
@@ -114,28 +112,32 @@ import (
const (
scratchByteArrayLen = 32
- // initCollectionCap = 16 // 32 is defensive. 16 is preferred.
+ initCollectionCap = 32 // 32 is defensive. 16 is preferred.
// Support encoding.(Binary|Text)(Unm|M)arshaler.
// This constant flag will enable or disable it.
supportMarshalInterfaces = true
+ // Each Encoder or Decoder uses a cache of functions based on conditionals,
+ // so that the conditionals are not run every time.
+ //
+ // Either a map or a slice is used to keep track of the functions.
+ // The map is more natural, but has a higher cost than a slice/array.
+ // This flag (useMapForCodecCache) controls which is used.
+ //
+ // From benchmarks, slices with linear search perform better with < 32 entries.
+ // We have typically seen a high threshold of about 24 entries.
+ useMapForCodecCache = false
+
// for debugging, set this to false, to catch panic traces.
// Note that this will always cause rpc tests to fail, since they need io.EOF sent via panic.
recoverPanicToErr = true
- // arrayCacheLen is the length of the cache used in encoder or decoder for
- // allowing zero-alloc initialization.
- arrayCacheLen = 8
-
- // size of the cacheline: defaulting to value for archs: amd64, arm64, 386
- // should use "runtime/internal/sys".CacheLineSize, but that is not exposed.
- cacheLineSize = 64
-
- wordSizeBits = 32 << (^uint(0) >> 63) // strconv.IntSize
- wordSize = wordSizeBits / 8
-
- maxLevelsEmbedding = 15 // use this, so structFieldInfo fits into 8 bytes
+ // if resetSliceElemToZeroValue, then on decoding a slice, reset the element to a zero value first.
+ // Only concern is that, if the slice already contained some garbage, we will decode into that garbage.
+ // The chances of this are slim, so leave this "optimization".
+ // TODO: should this be true, to ensure that we always decode into a "zero" "empty" value?
+ resetSliceElemToZeroValue bool = false
)
var (
@@ -143,28 +145,15 @@ var (
zeroByteSlice = oneByteArr[:0:0]
)
-var refBitset bitset32
-var pool pooler
-var panicv panicHdl
-
-func init() {
- pool.init()
-
- refBitset.set(byte(reflect.Map))
- refBitset.set(byte(reflect.Ptr))
- refBitset.set(byte(reflect.Func))
- refBitset.set(byte(reflect.Chan))
-}
-
type charEncoding uint8
const (
- cRAW charEncoding = iota
- cUTF8
- cUTF16LE
- cUTF16BE
- cUTF32LE
- cUTF32BE
+ c_RAW charEncoding = iota
+ c_UTF8
+ c_UTF16LE
+ c_UTF16BE
+ c_UTF32LE
+ c_UTF32BE
)
// valueType is the stream type
@@ -182,35 +171,12 @@ const (
valueTypeBytes
valueTypeMap
valueTypeArray
- valueTypeTime
+ valueTypeTimestamp
valueTypeExt
// valueTypeInvalid = 0xff
)
-var valueTypeStrings = [...]string{
- "Unset",
- "Nil",
- "Int",
- "Uint",
- "Float",
- "Bool",
- "String",
- "Symbol",
- "Bytes",
- "Map",
- "Array",
- "Timestamp",
- "Ext",
-}
-
-func (x valueType) String() string {
- if int(x) < len(valueTypeStrings) {
- return valueTypeStrings[x]
- }
- return strconv.FormatInt(int64(x), 10)
-}
-
type seqType uint8
const (
@@ -236,11 +202,11 @@ const (
containerArrayEnd
)
-// // sfiIdx used for tracking where a (field/enc)Name is seen in a []*structFieldInfo
-// type sfiIdx struct {
-// name string
-// index int
-// }
+// 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).
@@ -249,39 +215,34 @@ const (
const rgetMaxRecursion = 2
// Anecdotally, we believe most types have <= 12 fields.
-// - even Java's PMD rules set TooManyFields threshold to 15.
-// However, go has embedded fields, which should be regarded as
-// top level, allowing structs to possibly double or triple.
-// In addition, we don't want to keep creating transient arrays,
-// especially for the sfi index tracking, and the evtypes tracking.
-//
-// So - try to keep typeInfoLoadArray within 2K bytes
-const (
- typeInfoLoadArraySfisLen = 16
- typeInfoLoadArraySfiidxLen = 8 * 112
- typeInfoLoadArrayEtypesLen = 12
- typeInfoLoadArrayBLen = 8 * 4
-)
+// Java's PMD rules set TooManyFields threshold to 15.
+const rgetPoolTArrayLen = 12
-type typeInfoLoad struct {
- // fNames []string
- // encNames []string
- etypes []uintptr
- sfis []structFieldInfo
+type rgetT struct {
+ fNames []string
+ encNames []string
+ etypes []uintptr
+ sfis []*structFieldInfo
}
-type typeInfoLoadArray struct {
- // fNames [typeInfoLoadArrayLen]string
- // encNames [typeInfoLoadArrayLen]string
- sfis [typeInfoLoadArraySfisLen]structFieldInfo
- sfiidx [typeInfoLoadArraySfiidxLen]byte
- etypes [typeInfoLoadArrayEtypesLen]uintptr
- b [typeInfoLoadArrayBLen]byte // scratch - used for struct field names
+type rgetPoolT struct {
+ fNames [rgetPoolTArrayLen]string
+ encNames [rgetPoolTArrayLen]string
+ etypes [rgetPoolTArrayLen]uintptr
+ sfis [rgetPoolTArrayLen]*structFieldInfo
+ sfiidx [rgetPoolTArrayLen]sfiIdx
+}
+
+var rgetPool = sync.Pool{
+ New: func() interface{} { return new(rgetPoolT) },
+}
+
+type containerStateRecv interface {
+ sendContainerState(containerState)
}
// mirror json.Marshaler and json.Unmarshaler here,
// so we don't import the encoding/json package
-
type jsonMarshaler interface {
MarshalJSON() ([]byte, error)
}
@@ -289,12 +250,6 @@ type jsonUnmarshaler interface {
UnmarshalJSON([]byte) error
}
-type isZeroer interface {
- IsZero() bool
-}
-
-// type byteAccepter func(byte) bool
-
var (
bigen = binary.BigEndian
structInfoFieldName = "_struct"
@@ -304,17 +259,11 @@ var (
intfSliceTyp = reflect.TypeOf([]interface{}(nil))
intfTyp = intfSliceTyp.Elem()
- reflectValTyp = reflect.TypeOf((*reflect.Value)(nil)).Elem()
-
stringTyp = reflect.TypeOf("")
timeTyp = reflect.TypeOf(time.Time{})
rawExtTyp = reflect.TypeOf(RawExt{})
rawTyp = reflect.TypeOf(Raw{})
- uintptrTyp = reflect.TypeOf(uintptr(0))
- uint8Typ = reflect.TypeOf(uint8(0))
uint8SliceTyp = reflect.TypeOf([]uint8(nil))
- uintTyp = reflect.TypeOf(uint(0))
- intTyp = reflect.TypeOf(int(0))
mapBySliceTyp = reflect.TypeOf((*MapBySlice)(nil)).Elem()
@@ -328,130 +277,65 @@ var (
jsonUnmarshalerTyp = reflect.TypeOf((*jsonUnmarshaler)(nil)).Elem()
selferTyp = reflect.TypeOf((*Selfer)(nil)).Elem()
- iszeroTyp = reflect.TypeOf((*isZeroer)(nil)).Elem()
- uint8TypId = rt2id(uint8Typ)
- uint8SliceTypId = rt2id(uint8SliceTyp)
- rawExtTypId = rt2id(rawExtTyp)
- rawTypId = rt2id(rawTyp)
- intfTypId = rt2id(intfTyp)
- timeTypId = rt2id(timeTyp)
- stringTypId = rt2id(stringTyp)
+ uint8SliceTypId = reflect.ValueOf(uint8SliceTyp).Pointer()
+ rawExtTypId = reflect.ValueOf(rawExtTyp).Pointer()
+ rawTypId = reflect.ValueOf(rawTyp).Pointer()
+ intfTypId = reflect.ValueOf(intfTyp).Pointer()
+ timeTypId = reflect.ValueOf(timeTyp).Pointer()
+ stringTypId = reflect.ValueOf(stringTyp).Pointer()
- mapStrIntfTypId = rt2id(mapStrIntfTyp)
- mapIntfIntfTypId = rt2id(mapIntfIntfTyp)
- intfSliceTypId = rt2id(intfSliceTyp)
- // mapBySliceTypId = rt2id(mapBySliceTyp)
+ mapStrIntfTypId = reflect.ValueOf(mapStrIntfTyp).Pointer()
+ mapIntfIntfTypId = reflect.ValueOf(mapIntfIntfTyp).Pointer()
+ intfSliceTypId = reflect.ValueOf(intfSliceTyp).Pointer()
+ // mapBySliceTypId = reflect.ValueOf(mapBySliceTyp).Pointer()
- intBitsize = uint8(intTyp.Bits())
- uintBitsize = uint8(uintTyp.Bits())
+ intBitsize uint8 = uint8(reflect.TypeOf(int(0)).Bits())
+ uintBitsize uint8 = uint8(reflect.TypeOf(uint(0)).Bits())
bsAll0x00 = []byte{0, 0, 0, 0, 0, 0, 0, 0}
bsAll0xff = []byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}
chkOvf checkOverflow
- errNoFieldNameToStructFieldInfo = errors.New("no field name passed to parseStructFieldInfo")
+ noFieldNameToStructFieldInfoErr = errors.New("no field name passed to parseStructFieldInfo")
)
var defTypeInfos = NewTypeInfos([]string{"codec", "json"})
-var immutableKindsSet = [32]bool{
- // reflect.Invalid: ,
- reflect.Bool: true,
- reflect.Int: true,
- reflect.Int8: true,
- reflect.Int16: true,
- reflect.Int32: true,
- reflect.Int64: true,
- reflect.Uint: true,
- reflect.Uint8: true,
- reflect.Uint16: true,
- reflect.Uint32: true,
- reflect.Uint64: true,
- reflect.Uintptr: true,
- reflect.Float32: true,
- reflect.Float64: true,
- reflect.Complex64: true,
- reflect.Complex128: true,
- // reflect.Array
- // reflect.Chan
- // reflect.Func: true,
- // reflect.Interface
- // reflect.Map
- // reflect.Ptr
- // reflect.Slice
- reflect.String: true,
- // reflect.Struct
- // reflect.UnsafePointer
-}
-
// 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.
// Consequently, during (en|de)code, this takes precedence over
// (text|binary)(M|Unm)arshal or extension support.
-//
-// Note: *the first set of bytes of any value MUST NOT represent nil in the format*.
-// This is because, during each decode, we first check the the next set of bytes
-// represent nil, and if so, we just set the value to nil.
type Selfer interface {
CodecEncodeSelf(*Encoder)
CodecDecodeSelf(*Decoder)
}
-// MapBySlice is a tag interface that denotes wrapped slice should encode as a map in the stream.
+// MapBySlice represents a slice which should be encoded as a map in the stream.
// The slice contains a sequence of key-value pairs.
// This affords storing a map in a specific sequence in the stream.
//
-// Example usage:
-// type T1 []string // or []int or []Point or any other "slice" type
-// func (_ T1) MapBySlice{} // T1 now implements MapBySlice, and will be encoded as a map
-// type T2 struct { KeyValues T1 }
-//
-// var kvs = []string{"one", "1", "two", "2", "three", "3"}
-// var v2 = T2{ KeyValues: T1(kvs) }
-// // v2 will be encoded like the map: {"KeyValues": {"one": "1", "two": "2", "three": "3"} }
-//
// The support of MapBySlice affords the following:
// - A slice type which implements MapBySlice will be encoded as a map
// - A slice can be decoded from a map in the stream
-// - It MUST be a slice type (not a pointer receiver) that implements MapBySlice
type MapBySlice interface {
MapBySlice()
}
-// BasicHandle encapsulates the common options and extension functions.
+// WARNING: DO NOT USE DIRECTLY. EXPORTED FOR GODOC BENEFIT. WILL BE REMOVED.
//
-// Deprecated: DO NOT USE DIRECTLY. EXPORTED FOR GODOC BENEFIT. WILL BE REMOVED.
+// BasicHandle encapsulates the common options and extension functions.
type BasicHandle struct {
- // BasicHandle is always a part of a different type.
- // It doesn't have to fit into it own cache lines.
-
// TypeInfos is used to get the type info for any type.
//
// If not configured, the default TypeInfos is used, which uses struct tag keys: codec, json
TypeInfos *TypeInfos
- // Note: BasicHandle is not comparable, due to these slices here (extHandle, intf2impls).
- // If *[]T is used instead, this becomes comparable, at the cost of extra indirection.
- // Thses slices are used all the time, so keep as slices (not pointers).
-
extHandle
-
- intf2impls
-
- RPCOptions
-
- // ---- cache line
-
- DecodeOptions
-
- // ---- cache line
-
EncodeOptions
-
- // noBuiltInTypeChecker
+ DecodeOptions
}
func (x *BasicHandle) getBasicHandle() *BasicHandle {
@@ -459,10 +343,10 @@ func (x *BasicHandle) getBasicHandle() *BasicHandle {
}
func (x *BasicHandle) getTypeInfo(rtid uintptr, rt reflect.Type) (pti *typeInfo) {
- if x.TypeInfos == nil {
- return defTypeInfos.get(rtid, rt)
+ if x.TypeInfos != nil {
+ return x.TypeInfos.get(rtid, rt)
}
- return x.TypeInfos.get(rtid, rt)
+ return defTypeInfos.get(rtid, rt)
}
// Handle is the interface for a specific encoding format.
@@ -471,36 +355,28 @@ func (x *BasicHandle) getTypeInfo(rtid uintptr, rt reflect.Type) (pti *typeInfo)
// and not modified while in use. Such a pre-configured Handle
// is safe for concurrent access.
type Handle interface {
- Name() string
getBasicHandle() *BasicHandle
- recreateEncDriver(encDriver) bool
newEncDriver(w *Encoder) encDriver
newDecDriver(r *Decoder) decDriver
isBinary() bool
- hasElemSeparators() bool
- // IsBuiltinType(rtid uintptr) bool
}
// Raw represents raw formatted bytes.
-// We "blindly" store it during encode and retrieve the raw bytes during decode.
-// Note: it is dangerous during encode, so we may gate the behaviour
-// behind an Encode flag which must be explicitly set.
+// We "blindly" store it during encode and store the raw bytes during decode.
+// Note: it is dangerous during encode, so we may gate the behaviour behind an Encode flag which must be explicitly set.
type Raw []byte
// RawExt represents raw unprocessed extension data.
-// Some codecs will decode extension data as a *RawExt
-// if there is no registered extension for the tag.
+// Some codecs will decode extension data as a *RawExt if there is no registered extension for the tag.
//
-// Only one of Data or Value is nil.
-// If Data is nil, then the content of the RawExt is in the Value.
+// Only one of Data or Value is nil. If Data is nil, then the content of the RawExt is in the Value.
type RawExt struct {
Tag uint64
- // Data is the []byte which represents the raw ext. If nil, ext is exposed in Value.
- // Data is used by codecs (e.g. binc, msgpack, simple) which do custom serialization of types
+ // Data is the []byte which represents the raw ext. If Data is nil, ext is exposed in Value.
+ // Data is used by codecs (e.g. binc, msgpack, simple) which do custom serialization of the types
Data []byte
// Value represents the extension, if Data is nil.
- // Value is used by codecs (e.g. cbor, json) which leverage the format to do
- // custom serialization of the types.
+ // Value is used by codecs (e.g. cbor, json) which use the format to do custom serialization of the types.
Value interface{}
}
@@ -509,30 +385,24 @@ type RawExt struct {
type BytesExt interface {
// WriteExt converts a value to a []byte.
//
- // Note: v is a pointer iff the registered extension type is a struct or array kind.
+ // Note: v *may* be a pointer to the extension type, if the extension type was a struct or array.
WriteExt(v interface{}) []byte
// ReadExt updates a value from a []byte.
- //
- // Note: dst is always a pointer kind to the registered extension type.
ReadExt(dst interface{}, src []byte)
}
// InterfaceExt handles custom (de)serialization of types to/from another interface{} value.
// The Encoder or Decoder will then handle the further (de)serialization of that known type.
//
-// It is used by codecs (e.g. cbor, json) which use the format to do custom serialization of types.
+// It is used by codecs (e.g. cbor, json) which use the format to do custom serialization of the types.
type InterfaceExt interface {
- // ConvertExt converts a value into a simpler interface for easy encoding
- // e.g. convert time.Time to int64.
+ // ConvertExt converts a value into a simpler interface for easy encoding e.g. convert time.Time to int64.
//
- // Note: v is a pointer iff the registered extension type is a struct or array kind.
+ // Note: v *may* be a pointer to the extension type, if the extension type was a struct or array.
ConvertExt(v interface{}) interface{}
- // UpdateExt updates a value from a simpler interface for easy decoding
- // e.g. convert int64 to time.Time.
- //
- // Note: dst is always a pointer kind to the registered extension type.
+ // UpdateExt updates a value from a simpler interface for easy decoding e.g. convert int64 to time.Time.
UpdateExt(dst interface{}, src interface{})
}
@@ -570,59 +440,64 @@ func (x addExtWrapper) UpdateExt(dest interface{}, v interface{}) {
x.ReadExt(dest, v.([]byte))
}
-type extWrapper struct {
- BytesExt
- InterfaceExt
+type setExtWrapper struct {
+ b BytesExt
+ i InterfaceExt
}
-type bytesExtFailer struct{}
-
-func (bytesExtFailer) WriteExt(v interface{}) []byte {
- panicv.errorstr("BytesExt.WriteExt is not supported")
- return nil
-}
-func (bytesExtFailer) ReadExt(v interface{}, bs []byte) {
- panicv.errorstr("BytesExt.ReadExt is not supported")
+func (x *setExtWrapper) WriteExt(v interface{}) []byte {
+ if x.b == nil {
+ panic("BytesExt.WriteExt is not supported")
+ }
+ return x.b.WriteExt(v)
}
-type interfaceExtFailer struct{}
+func (x *setExtWrapper) ReadExt(v interface{}, bs []byte) {
+ if x.b == nil {
+ panic("BytesExt.WriteExt is not supported")
-func (interfaceExtFailer) ConvertExt(v interface{}) interface{} {
- panicv.errorstr("InterfaceExt.ConvertExt is not supported")
- return nil
+ }
+ x.b.ReadExt(v, bs)
}
-func (interfaceExtFailer) UpdateExt(dest interface{}, v interface{}) {
- panicv.errorstr("InterfaceExt.UpdateExt is not supported")
+
+func (x *setExtWrapper) ConvertExt(v interface{}) interface{} {
+ if x.i == nil {
+ panic("InterfaceExt.ConvertExt is not supported")
+
+ }
+ return x.i.ConvertExt(v)
}
+func (x *setExtWrapper) UpdateExt(dest interface{}, v interface{}) {
+ if x.i == nil {
+ panic("InterfaceExxt.UpdateExt is not supported")
+
+ }
+ x.i.UpdateExt(dest, v)
+}
+
+// type errorString string
+// func (x errorString) Error() string { return string(x) }
+
type binaryEncodingType struct{}
-func (binaryEncodingType) isBinary() bool { return true }
+func (_ binaryEncodingType) isBinary() bool { return true }
type textEncodingType struct{}
-func (textEncodingType) isBinary() bool { return false }
+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{}) {}
+func (_ noBuiltInTypes) IsBuiltinType(rt uintptr) bool { return false }
+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 noStreamingCodec struct{}
-type noElemSeparators struct{}
-
-func (noElemSeparators) hasElemSeparators() (v bool) { return }
-func (noElemSeparators) recreateEncDriver(e encDriver) (v bool) { return }
+func (_ noStreamingCodec) CheckBreak() bool { return false }
// bigenHelper.
// Users must already slice the x completely, because we will not reslice.
@@ -647,256 +522,165 @@ func (z bigenHelper) writeUint64(v uint64) {
}
type extTypeTagFn struct {
- rtid uintptr
- rtidptr uintptr
- rt reflect.Type
- tag uint64
- ext Ext
- _ [1]uint64 // padding
+ rtid uintptr
+ rt reflect.Type
+ tag uint64
+ ext Ext
}
type extHandle []extTypeTagFn
-// AddExt registes an encode and decode function for a reflect.Type.
-// To deregister an Ext, call AddExt with nil encfn and/or nil decfn.
+// DEPRECATED: Use SetBytesExt or SetInterfaceExt on the Handle instead.
//
-// Deprecated: Use SetBytesExt or SetInterfaceExt on the Handle instead.
-func (o *extHandle) AddExt(rt reflect.Type, tag byte,
- encfn func(reflect.Value) ([]byte, error),
- decfn func(reflect.Value, []byte) error) (err error) {
+// AddExt registes an encode and decode function for a reflect.Type.
+// AddExt internally calls SetExt.
+// To deregister an Ext, call AddExt with nil encfn and/or nil decfn.
+func (o *extHandle) AddExt(
+ rt reflect.Type, tag byte,
+ encfn func(reflect.Value) ([]byte, error), decfn func(reflect.Value, []byte) error,
+) (err error) {
if encfn == nil || decfn == nil {
return o.SetExt(rt, uint64(tag), nil)
}
return o.SetExt(rt, uint64(tag), addExtWrapper{encfn, decfn})
}
-// SetExt will set the extension for a tag and reflect.Type.
-// Note that the type must be a named type, and specifically not a pointer or Interface.
-// An error is returned if that is not honored.
-// To Deregister an ext, call SetExt with nil Ext.
+// DEPRECATED: Use SetBytesExt or SetInterfaceExt on the Handle instead.
//
-// Deprecated: Use SetBytesExt or SetInterfaceExt on the Handle instead.
+// Note that the type must be a named type, and specifically not
+// a pointer or Interface. An error is returned if that is not honored.
+//
+// To Deregister an ext, call SetExt with nil Ext
func (o *extHandle) SetExt(rt reflect.Type, tag uint64, ext Ext) (err error) {
// o is a pointer, because we may need to initialize it
- rk := rt.Kind()
- for rk == reflect.Ptr {
- rt = rt.Elem()
- rk = rt.Kind()
+ if rt.PkgPath() == "" || rt.Kind() == reflect.Interface {
+ err = fmt.Errorf("codec.Handle.AddExt: Takes named type, not a pointer or interface: %T",
+ reflect.Zero(rt).Interface())
+ return
}
- if rt.PkgPath() == "" || rk == reflect.Interface { // || rk == reflect.Ptr {
- return fmt.Errorf("codec.Handle.SetExt: Takes named type, not a pointer or interface: %v", rt)
- }
-
- 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???
- }
- // 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]
+ rtid := reflect.ValueOf(rt).Pointer()
+ for _, v := range *o {
if v.rtid == rtid {
v.tag, v.ext = tag, ext
return
}
}
- rtidptr := rt2id(reflect.PtrTo(rt))
- *o = append(o2, extTypeTagFn{rtid, rtidptr, rt, tag, ext, [1]uint64{}})
+
+ if *o == nil {
+ *o = make([]extTypeTagFn, 0, 4)
+ }
+ *o = append(*o, extTypeTagFn{rtid, rt, tag, ext})
return
}
-func (o extHandle) getExt(rtid uintptr) (v *extTypeTagFn) {
+func (o extHandle) getExt(rtid uintptr) *extTypeTagFn {
+ var v *extTypeTagFn
for i := range o {
v = &o[i]
- if v.rtid == rtid || v.rtidptr == rtid {
- return
+ if v.rtid == rtid {
+ return v
}
}
return nil
}
-func (o extHandle) getExtForTag(tag uint64) (v *extTypeTagFn) {
+func (o extHandle) getExtForTag(tag uint64) *extTypeTagFn {
+ var v *extTypeTagFn
for i := range o {
v = &o[i]
if v.tag == tag {
- return
+ return v
}
}
return nil
}
-type intf2impl struct {
- rtid uintptr // for intf
- impl reflect.Type
- // _ [1]uint64 // padding // not-needed, as *intf2impl is never returned.
-}
-
-type intf2impls []intf2impl
-
-// Intf2Impl maps an interface to an implementing type.
-// This allows us support infering the concrete type
-// and populating it when passed an interface.
-// e.g. var v io.Reader can be decoded as a bytes.Buffer, etc.
-//
-// Passing a nil impl will clear the mapping.
-func (o *intf2impls) Intf2Impl(intf, impl reflect.Type) (err error) {
- if impl != nil && !impl.Implements(intf) {
- return fmt.Errorf("Intf2Impl: %v does not implement %v", impl, intf)
- }
- rtid := rt2id(intf)
- o2 := *o
- for i := range o2 {
- v := &o2[i]
- if v.rtid == rtid {
- v.impl = impl
- return
- }
- }
- *o = append(o2, intf2impl{rtid, impl})
- return
-}
-
-func (o intf2impls) intf2impl(rtid uintptr) (rv reflect.Value) {
- for i := range o {
- v := &o[i]
- if v.rtid == rtid {
- if v.impl == nil {
- return
- }
- if v.impl.Kind() == reflect.Ptr {
- return reflect.New(v.impl.Elem())
- }
- return reflect.New(v.impl).Elem()
- }
- }
- return
-}
-
-type structFieldInfoFlag uint8
-
-const (
- _ structFieldInfoFlag = 1 << iota
- structFieldInfoFlagReady
- structFieldInfoFlagOmitEmpty
-)
-
-func (x *structFieldInfoFlag) flagSet(f structFieldInfoFlag) {
- *x = *x | f
-}
-
-func (x *structFieldInfoFlag) flagClr(f structFieldInfoFlag) {
- *x = *x &^ f
-}
-
-func (x structFieldInfoFlag) flagGet(f structFieldInfoFlag) bool {
- return x&f != 0
-}
-
-func (x structFieldInfoFlag) omitEmpty() bool {
- return x.flagGet(structFieldInfoFlagOmitEmpty)
-}
-
-func (x structFieldInfoFlag) ready() bool {
- return x.flagGet(structFieldInfoFlagReady)
-}
-
type structFieldInfo struct {
encName string // encode name
fieldName string // field name
- is [maxLevelsEmbedding]uint16 // (recursive/embedded) field index in struct
- nis uint8 // num levels of embedding. if 1, then it's not embedded.
- structFieldInfoFlag
+ // only one of 'i' or 'is' can be set. If 'i' is -1, then 'is' has been set.
+
+ is []int // (recursive/embedded) field index in struct
+ i int16 // field index in struct
+ omitEmpty bool
+ toArray bool // if field is _struct, is the toArray set?
+}
+
+// func (si *structFieldInfo) isZero() bool {
+// return si.encName == "" && len(si.is) == 0 && si.i == 0 && !si.omitEmpty && !si.toArray
+// }
+
+// rv returns the field of the struct.
+// If anonymous, it returns an Invalid
+func (si *structFieldInfo) field(v reflect.Value, update bool) (rv2 reflect.Value) {
+ if si.i != -1 {
+ v = v.Field(int(si.i))
+ return v
+ }
+ // replicate FieldByIndex
+ for _, x := range si.is {
+ for v.Kind() == reflect.Ptr {
+ if v.IsNil() {
+ if !update {
+ return
+ }
+ v.Set(reflect.New(v.Type().Elem()))
+ }
+ v = v.Elem()
+ }
+ v = v.Field(x)
+ }
+ return v
}
func (si *structFieldInfo) setToZeroValue(v reflect.Value) {
- if v, valid := si.field(v, false); valid {
+ if si.i != -1 {
+ v = v.Field(int(si.i))
+ v.Set(reflect.Zero(v.Type()))
+ // v.Set(reflect.New(v.Type()).Elem())
+ // v.Set(reflect.New(v.Type()))
+ } else {
+ // replicate FieldByIndex
+ for _, x := range si.is {
+ for v.Kind() == reflect.Ptr {
+ if v.IsNil() {
+ return
+ }
+ v = v.Elem()
+ }
+ v = v.Field(x)
+ }
v.Set(reflect.Zero(v.Type()))
}
}
-// rv returns the field of the struct.
-// If anonymous, it returns an Invalid
-func (si *structFieldInfo) field(v reflect.Value, update bool) (rv2 reflect.Value, valid bool) {
- // replicate FieldByIndex
- for i, x := range si.is {
- if uint8(i) == si.nis {
- break
- }
- if v, valid = baseStructRv(v, update); !valid {
- return
- }
- v = v.Field(int(x))
- }
-
- 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 == "" {
- return
- }
- for i, s := range strings.Split(stag, ",") {
- if i == 0 {
- } else {
- switch s {
- case "omitempty":
- omitEmpty = true
- case "toarray":
- toArray = true
- case "int":
- keytype = valueTypeInt
- case "uint":
- keytype = valueTypeUint
- case "float":
- keytype = valueTypeFloat
- // case "bool":
- // keytype = valueTypeBool
- case "string":
- keytype = valueTypeString
- }
- }
- }
- return
-}
-
-func (si *structFieldInfo) parseTag(stag string) {
+func parseStructFieldInfo(fname string, stag string) *structFieldInfo {
// if fname == "" {
- // panic(errNoFieldNameToStructFieldInfo)
+ // panic(noFieldNameToStructFieldInfoErr)
// }
-
- if stag == "" {
- return
+ si := structFieldInfo{
+ encName: fname,
}
- for i, s := range strings.Split(stag, ",") {
- if i == 0 {
- if s != "" {
- si.encName = s
- }
- } else {
- switch s {
- case "omitempty":
- si.flagSet(structFieldInfoFlagOmitEmpty)
- // si.omitEmpty = true
- // case "toarray":
- // si.toArray = true
+
+ if stag != "" {
+ for i, s := range strings.Split(stag, ",") {
+ if i == 0 {
+ if s != "" {
+ si.encName = s
+ }
+ } else {
+ if s == "omitempty" {
+ si.omitEmpty = true
+ } else if s == "toarray" {
+ si.toArray = true
+ }
}
}
}
+ // si.encNameBs = []byte(si.encName)
+ return &si
}
type sfiSortedByEncName []*structFieldInfo
@@ -913,105 +697,7 @@ func (p sfiSortedByEncName) Swap(i, j int) {
p[i], p[j] = p[j], p[i]
}
-const structFieldNodeNumToCache = 4
-
-type structFieldNodeCache struct {
- rv [structFieldNodeNumToCache]reflect.Value
- idx [structFieldNodeNumToCache]uint32
- num uint8
-}
-
-func (x *structFieldNodeCache) get(key uint32) (fv reflect.Value, valid bool) {
- for i, k := range &x.idx {
- if uint8(i) == x.num {
- return // break
- }
- if key == k {
- return x.rv[i], true
- }
- }
- return
-}
-
-func (x *structFieldNodeCache) tryAdd(fv reflect.Value, key uint32) {
- if x.num < structFieldNodeNumToCache {
- x.rv[x.num] = fv
- x.idx[x.num] = key
- x.num++
- return
- }
-}
-
-type structFieldNode struct {
- v reflect.Value
- cache2 structFieldNodeCache
- cache3 structFieldNodeCache
- update bool
-}
-
-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
- switch si.nis {
- case 1:
- fv = x.v.Field(int(si.is[0]))
- case 2:
- if fv, valid = x.cache2.get(uint32(si.is[0])); valid {
- fv = fv.Field(int(si.is[1]))
- return
- }
- fv = x.v.Field(int(si.is[0]))
- if fv, valid = baseStructRv(fv, x.update); !valid {
- return
- }
- x.cache2.tryAdd(fv, uint32(si.is[0]))
- fv = fv.Field(int(si.is[1]))
- case 3:
- var key uint32 = uint32(si.is[0])<<16 | uint32(si.is[1])
- if fv, valid = x.cache3.get(key); valid {
- fv = fv.Field(int(si.is[2]))
- return
- }
- fv = x.v.Field(int(si.is[0]))
- if fv, valid = baseStructRv(fv, x.update); !valid {
- return
- }
- fv = fv.Field(int(si.is[1]))
- if fv, valid = baseStructRv(fv, x.update); !valid {
- return
- }
- x.cache3.tryAdd(fv, key)
- fv = fv.Field(int(si.is[2]))
- default:
- fv, _ = si.field(x.v, x.update)
- }
- return
-}
-
-func baseStructRv(v reflect.Value, update bool) (v2 reflect.Value, valid bool) {
- for v.Kind() == reflect.Ptr {
- if v.IsNil() {
- if !update {
- return
- }
- v.Set(reflect.New(v.Type().Elem()))
- }
- v = v.Elem()
- }
- return v, true
-}
-
-type typeInfoFlag uint8
-
-const (
- typeInfoFlagComparable = 1 << iota
- typeInfoFlagIsZeroer
- typeInfoFlagIsZeroerPtr
-)
-
-// typeInfo keeps information about each (non-ptr) type referenced in the encode/decode sequence.
+// typeInfo keeps information about each 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
@@ -1020,82 +706,70 @@ const (
// - If type is text(M/Unm)arshaler, call Text(M/Unm)arshal method
// - Else decode appropriately based on the reflect.Kind
type typeInfo struct {
- rt reflect.Type
- elem reflect.Type
- pkgpath string
+ sfi []*structFieldInfo // sorted. Used when enc/dec struct to map.
+ sfip []*structFieldInfo // unsorted. Used when enc/dec struct to array.
+ rt reflect.Type
rtid uintptr
- // rv0 reflect.Value // saved zero value, used if immutableKind
numMeth uint16 // number of methods
- kind uint8
- chandir uint8
- anyOmitEmpty bool // true if a struct, and any of the fields are tagged "omitempty"
- toArray bool // whether this (struct) type should be encoded as an array
- keyType valueType // if struct, how is the field name stored in a stream? default is string
- mbs bool // base type (T or *T) is a MapBySlice
+ // baseId gives pointer to the base reflect.Type, after deferencing
+ // the pointers. E.g. base type of ***time.Time is time.Time.
+ base reflect.Type
+ baseId uintptr
+ baseIndir int8 // number of indirections to get to base
- // ---- cpu cache line boundary?
- sfiSort []*structFieldInfo // sorted. Used when enc/dec struct to map.
- sfiSrc []*structFieldInfo // unsorted. Used when enc/dec struct to array.
+ mbs bool // base type (T or *T) is a MapBySlice
- key reflect.Type
+ bm bool // base type (T or *T) is a binaryMarshaler
+ bunm bool // base type (T or *T) is a binaryUnmarshaler
+ bmIndir int8 // number of indirections to get to binaryMarshaler type
+ bunmIndir int8 // number of indirections to get to binaryUnmarshaler type
- // ---- cpu cache line boundary?
- // sfis []structFieldInfo // all sfi, in src order, as created.
- sfiNamesSort []byte // all names, with indexes into the sfiSort
+ tm bool // base type (T or *T) is a textMarshaler
+ tunm bool // base type (T or *T) is a textUnmarshaler
+ tmIndir int8 // number of indirections to get to textMarshaler type
+ tunmIndir int8 // number of indirections to get to textUnmarshaler type
- // format of marshal type fields below: [btj][mu]p? OR csp?
+ jm bool // base type (T or *T) is a jsonMarshaler
+ junm bool // base type (T or *T) is a jsonUnmarshaler
+ jmIndir int8 // number of indirections to get to jsonMarshaler type
+ junmIndir int8 // number of indirections to get to jsonUnmarshaler type
- 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
+ cs bool // base type (T or *T) is a Selfer
+ csIndir int8 // number of indirections to get to Selfer type
- 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
-
- // other flags, with individual bits representing if set.
- flags typeInfoFlag
-
- // _ [2]byte // padding
- _ [3]uint64 // padding
+ toArray bool // whether this (struct) type should be encoded as an array
}
-func (ti *typeInfo) isFlag(f typeInfoFlag) bool {
- return ti.flags&f != 0
-}
-
-func (ti *typeInfo) indexForEncName(name []byte) (index int16) {
- var sn []byte
- if len(name)+2 <= 32 {
- var buf [32]byte // should not escape
- sn = buf[:len(name)+2]
+func (ti *typeInfo) indexForEncName(name string) int {
+ // NOTE: name may be a stringView, so don't pass it to another function.
+ //tisfi := ti.sfi
+ const binarySearchThreshold = 16
+ if sfilen := len(ti.sfi); sfilen < binarySearchThreshold {
+ // linear search. faster than binary search in my testing up to 16-field structs.
+ for i, si := range ti.sfi {
+ if si.encName == name {
+ return i
+ }
+ }
} else {
- sn = make([]byte, len(name)+2)
+ // binary search. adapted from sort/search.go.
+ h, i, j := 0, 0, sfilen
+ for i < j {
+ h = i + (j-i)/2
+ if ti.sfi[h].encName < name {
+ i = h + 1
+ } else {
+ j = h
+ }
+ }
+ if i < sfilen && ti.sfi[i].encName == name {
+ return i
+ }
}
- copy(sn[1:], name)
- sn[0], sn[len(sn)-1] = tiSep2(name), 0xff
- j := bytes.Index(ti.sfiNamesSort, sn)
- if j < 0 {
- return -1
- }
- index = int16(uint16(ti.sfiNamesSort[j+len(sn)+1]) | uint16(ti.sfiNamesSort[j+len(sn)])<<8)
- return
-}
-
-type rtid2ti struct {
- rtid uintptr
- ti *typeInfo
+ return -1
}
// TypeInfos caches typeInfo for each type on first inspection.
@@ -1103,11 +777,9 @@ type rtid2ti struct {
// It is configured with a set of tag keys, which are used to get
// configuration for the type.
type TypeInfos struct {
- // infos: formerly map[uintptr]*typeInfo, now *[]rtid2ti, 2 words expected
- infos atomicTypeInfoSlice
- mu sync.Mutex
+ infos map[uintptr]*typeInfo
+ mu sync.RWMutex
tags []string
- _ [2]uint64 // padding
}
// NewTypeInfos creates a TypeInfos given a set of struct tags keys.
@@ -1115,7 +787,7 @@ type TypeInfos struct {
// This allows users customize the struct tag keys which contain configuration
// of their types.
func NewTypeInfos(tags []string) *TypeInfos {
- return &TypeInfos{tags: tags}
+ return &TypeInfos{tags: tags, infos: make(map[uintptr]*typeInfo, 64)}
}
func (x *TypeInfos) structTag(t reflect.StructTag) (s string) {
@@ -1130,124 +802,91 @@ func (x *TypeInfos) structTag(t reflect.StructTag) (s string) {
return
}
-func (x *TypeInfos) find(s []rtid2ti, rtid uintptr) (idx int, ti *typeInfo) {
- // binary search. adapted from sort/search.go.
- // if sp == nil {
- // return -1, nil
- // }
- // s := *sp
- h, i, j := 0, 0, len(s)
- for i < j {
- h = i + (j-i)/2
- if s[h].rtid < rtid {
- i = h + 1
- } else {
- j = h
- }
- }
- if i < len(s) && s[i].rtid == rtid {
- return i, s[i].ti
- }
- return i, nil
-}
-
func (x *TypeInfos) get(rtid uintptr, rt reflect.Type) (pti *typeInfo) {
- sp := x.infos.load()
- var idx int
- if sp != nil {
- idx, pti = x.find(sp, rtid)
- if pti != nil {
- return
- }
- }
-
- rk := rt.Kind()
-
- if rk == reflect.Ptr { // || (rk == reflect.Interface && rtid != intfTypId) {
- panicv.errorf("invalid kind passed to TypeInfos.get: %v - %v", rk, rt)
+ var ok bool
+ x.mu.RLock()
+ pti, ok = x.infos[rtid]
+ x.mu.RUnlock()
+ if ok {
+ return
}
// do not hold lock while computing this.
// it may lead to duplication, but that's ok.
- ti := typeInfo{rt: rt, rtid: rtid, kind: uint8(rk), pkgpath: rt.PkgPath()}
- // ti.rv0 = reflect.Zero(rt)
-
- // ti.comparable = rt.Comparable()
+ ti := typeInfo{rt: rt, rtid: rtid}
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)
-
- b1, b2 := implIntf(rt, iszeroTyp)
- if b1 {
- ti.flags |= typeInfoFlagIsZeroer
+ var indir int8
+ if ok, indir = implementsIntf(rt, binaryMarshalerTyp); ok {
+ ti.bm, ti.bmIndir = true, indir
}
- if b2 {
- ti.flags |= typeInfoFlagIsZeroerPtr
+ if ok, indir = implementsIntf(rt, binaryUnmarshalerTyp); ok {
+ ti.bunm, ti.bunmIndir = true, indir
}
- if rt.Comparable() {
- ti.flags |= typeInfoFlagComparable
+ if ok, indir = implementsIntf(rt, textMarshalerTyp); ok {
+ ti.tm, ti.tmIndir = true, indir
+ }
+ if ok, indir = implementsIntf(rt, textUnmarshalerTyp); ok {
+ ti.tunm, ti.tunmIndir = true, indir
+ }
+ if ok, indir = implementsIntf(rt, jsonMarshalerTyp); ok {
+ ti.jm, ti.jmIndir = true, indir
+ }
+ if ok, indir = implementsIntf(rt, jsonUnmarshalerTyp); ok {
+ ti.junm, ti.junmIndir = true, indir
+ }
+ if ok, indir = implementsIntf(rt, selferTyp); ok {
+ ti.cs, ti.csIndir = true, indir
+ }
+ if ok, _ = implementsIntf(rt, mapBySliceTyp); ok {
+ ti.mbs = true
}
- switch rk {
- case reflect.Struct:
+ pt := rt
+ var ptIndir int8
+ // for ; pt.Kind() == reflect.Ptr; pt, ptIndir = pt.Elem(), ptIndir+1 { }
+ for pt.Kind() == reflect.Ptr {
+ pt = pt.Elem()
+ ptIndir++
+ }
+ if ptIndir == 0 {
+ ti.base = rt
+ ti.baseId = rtid
+ } else {
+ ti.base = pt
+ ti.baseId = reflect.ValueOf(pt).Pointer()
+ ti.baseIndir = ptIndir
+ }
+
+ if rt.Kind() == reflect.Struct {
var omitEmpty bool
if f, ok := rt.FieldByName(structInfoFieldName); ok {
- ti.toArray, omitEmpty, ti.keyType = parseStructInfo(x.structTag(f.Tag))
- } else {
- ti.keyType = valueTypeString
+ siInfo := parseStructFieldInfo(structInfoFieldName, x.structTag(f.Tag))
+ ti.toArray = siInfo.toArray
+ omitEmpty = siInfo.omitEmpty
}
- pp, pi := 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]}
+ pi := rgetPool.Get()
+ pv := pi.(*rgetPoolT)
+ pv.etypes[0] = ti.baseId
+ vv := rgetT{pv.fNames[:0], pv.encNames[:0], 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:
- ti.elem = rt.Elem()
- ti.key = rt.Key()
- case reflect.Slice:
- ti.mbs, _ = implIntf(rt, mapBySliceTyp)
- ti.elem = rt.Elem()
- case reflect.Chan:
- ti.elem = rt.Elem()
- ti.chandir = uint8(rt.ChanDir())
- case reflect.Array, reflect.Ptr:
- ti.elem = rt.Elem()
+ ti.sfip, ti.sfi = rgetResolveSFI(vv.sfis, pv.sfiidx[:0])
+ rgetPool.Put(pi)
}
- // sfi = sfiSrc
+ // sfi = sfip
x.mu.Lock()
- sp = x.infos.load()
- if sp == nil {
+ if pti, ok = x.infos[rtid]; !ok {
pti = &ti
- vs := []rtid2ti{{rtid, pti}}
- x.infos.store(vs)
- } else {
- idx, pti = x.find(sp, rtid)
- if pti == nil {
- pti = &ti
- vs := make([]rtid2ti, len(sp)+1)
- copy(vs, sp[:idx])
- copy(vs[idx+1:], sp[idx:])
- vs[idx] = rtid2ti{rtid, pti}
- x.infos.store(vs)
- }
+ x.infos[rtid] = pti
}
x.mu.Unlock()
return
}
func (x *TypeInfos) rget(rt reflect.Type, rtid uintptr, omitEmpty bool,
- indexstack []uint16, pv *typeInfoLoad) {
+ indexstack []int, pv *rgetT,
+) {
// Read up fields and store how to access the value.
//
// It uses go's rules for message selectors,
@@ -1256,15 +895,10 @@ func (x *TypeInfos) rget(rt reflect.Type, rtid uintptr, omitEmpty bool,
// Note: we consciously use slices, not a map, to simulate a set.
// Typically, types have < 16 fields,
// and iteration using equals is faster than maps there
- flen := rt.NumField()
- if flen > (1< %v fields are not supported - has %v fields",
- (1< maxLevelsEmbedding-1 {
- panicv.errorf("codec: only supports up to %v depth of embedding - type has %v depth",
- maxLevelsEmbedding-1, len(indexstack))
+ if len(indexstack) == 0 {
+ si.i = int16(j)
+ } else {
+ si.i = -1
+ si.is = make([]int, len(indexstack)+1)
+ copy(si.is, indexstack)
+ si.is[len(indexstack)] = j
+ // si.is = append(append(make([]int, 0, len(indexstack)+4), indexstack...), j)
}
- si.nis = uint8(len(indexstack)) + 1
- copy(si.is[:], indexstack)
- si.is[len(indexstack)] = j
if omitEmpty {
- si.flagSet(structFieldInfoFlagOmitEmpty)
+ si.omitEmpty = true
}
pv.sfis = append(pv.sfis, si)
}
}
-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))
- return 0xfe - (name[0] & 63) - uint8(len(name)&63)
-}
-
-func tiSep2(name []byte) uint8 {
- return 0xfe - (name[0] & 63) - uint8(len(name)&63)
-}
-
// resolves the struct field info got from a call to rget.
// Returns a trimmed, unsorted and sorted []*structFieldInfo.
-func rgetResolveSFI(rt reflect.Type, x []structFieldInfo, pv *typeInfoLoadArray) (
- y, z []*structFieldInfo, ss []byte, anyOmitEmpty bool) {
- sa := pv.sfiidx[:0]
- sn := pv.b[:]
- n := len(x)
-
- var xn string
- var ui uint16
- var sep byte
-
- 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) {
- sn = make([]byte, len(xn)+2)
- } else {
- sn = sn[:len(xn)+2]
- }
- // use a custom sep, so that misses are less frequent,
- // since the sep (first char in search) is as unique as first char in field name.
- sep = tiSep(xn)
- sn[0], sn[len(sn)-1] = sep, 0xff
- copy(sn[1:], xn)
- j := bytes.Index(sa, sn)
- if j == -1 {
- sa = append(sa, sep)
- sa = append(sa, xn...)
- 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 {
- 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--
+func rgetResolveSFI(x []*structFieldInfo, pv []sfiIdx) (y, z []*structFieldInfo) {
+ var n int
+ for i, v := range x {
+ xn := v.encName //TODO: fieldName or encName? use encName for now.
+ var found bool
+ for j, k := range pv {
+ if k.name == xn {
+ // one of them must be reset to nil, and the index updated appropriately to the other one
+ if len(v.is) == len(x[k.index].is) {
+ } else if len(v.is) < len(x[k.index].is) {
+ pv[j].index = i
+ if x[k.index] != nil {
+ x[k.index] = nil
+ n++
+ }
+ } else {
+ if x[i] != nil {
+ x[i] = nil
+ n++
+ }
}
+ found = true
+ break
}
}
-
- }
- var w []structFieldInfo
- sharingArray := len(x) <= typeInfoLoadArraySfisLen // sharing array with typeInfoLoadArray
- if sharingArray {
- w = make([]structFieldInfo, n)
+ if !found {
+ pv = append(pv, sfiIdx{xn, i})
+ }
}
- // remove all the nils (non-ready)
- y = make([]*structFieldInfo, n)
+ // remove all the nils
+ y = make([]*structFieldInfo, len(x)-n)
n = 0
- var sslen int
- for i := range x {
- if !x[i].ready() {
+ for _, v := range x {
+ if v == nil {
continue
}
- if !anyOmitEmpty && x[i].omitEmpty() {
- anyOmitEmpty = true
- }
- if sharingArray {
- w[n] = x[i]
- y[n] = &w[n]
- } else {
- y[n] = &x[i]
- }
- sslen = sslen + len(x[i].encName) + 4
+ y[n] = v
n++
}
- if n != len(y) {
- panicv.errorf("failure reading struct %v - expecting %d of %d valid fields, got %d",
- rt, len(y), len(x), n)
- }
z = make([]*structFieldInfo, len(y))
copy(z, y)
sort.Sort(sfiSortedByEncName(z))
-
- sharingArray = len(sa) <= typeInfoLoadArraySfiidxLen
- if sharingArray {
- ss = make([]byte, 0, sslen)
- } else {
- ss = sa[:0] // reuse the newly made sa array if necessary
- }
- for i := range z {
- xn = z[i].encName
- sep = tiSep(xn)
- ui = uint16(i)
- ss = append(ss, sep)
- ss = append(ss, xn...)
- ss = append(ss, 0xff, byte(ui>>8), byte(ui))
- }
return
}
-func implIntf(rt, iTyp reflect.Type) (base bool, indir bool) {
- return rt.Implements(iTyp), reflect.PtrTo(rt).Implements(iTyp)
-}
-
-// isEmptyStruct is only called from isEmptyValue, and checks if a struct is empty:
-// - does it implement IsZero() bool
-// - is it comparable, and can i compare directly using ==
-// - if checkStruct, then walk through the encodable fields
-// and check if they are empty or not.
-func isEmptyStruct(v reflect.Value, tinfos *TypeInfos, deref, checkStruct bool) bool {
- // v is a struct kind - no need to check again.
- // We only check isZero on a struct kind, to reduce the amount of times
- // that we lookup the rtid and typeInfo for each type as we walk the tree.
-
- vt := v.Type()
- rtid := rt2id(vt)
- if tinfos == nil {
- tinfos = defTypeInfos
- }
- ti := tinfos.get(rtid, vt)
- if ti.rtid == timeTypId {
- return rv2i(v).(time.Time).IsZero()
- }
- if ti.isFlag(typeInfoFlagIsZeroerPtr) && v.CanAddr() {
- return rv2i(v.Addr()).(isZeroer).IsZero()
- }
- if ti.isFlag(typeInfoFlagIsZeroer) {
- return rv2i(v).(isZeroer).IsZero()
- }
- if ti.isFlag(typeInfoFlagComparable) {
- return rv2i(v) == rv2i(reflect.Zero(vt))
- }
- if !checkStruct {
- return false
- }
- // We only care about what we can encode/decode,
- // so that is what we use to check omitEmpty.
- for _, si := range ti.sfiSrc {
- sfv, valid := si.field(v, false)
- if valid && !isEmptyValue(sfv, tinfos, deref, checkStruct) {
- return false
- }
- }
- return true
-}
-
-// func roundFloat(x float64) float64 {
-// t := math.Trunc(x)
-// if math.Abs(x-t) >= 0.5 {
-// return t + math.Copysign(1, x)
-// }
-// return t
-// }
-
-func panicToErr(h errstrDecorator, err *error) {
- // Note: This method MUST be called directly from defer i.e. defer panicToErr ...
- // else it seems the recover is not fully handled
+func panicToErr(err *error) {
if recoverPanicToErr {
if x := recover(); x != nil {
- // fmt.Printf("panic'ing with: %v\n", x)
- // debug.PrintStack()
- panicValToErr(h, x, err)
+ //debug.PrintStack()
+ panicValToErr(x, err)
}
}
}
-func panicValToErr(h errstrDecorator, v interface{}, err *error) {
- switch xerr := v.(type) {
- case nil:
- case error:
- switch xerr {
- case nil:
- case io.EOF, io.ErrUnexpectedEOF, errEncoderNotInitialized, errDecoderNotInitialized:
- // treat as special (bubble up)
- *err = xerr
- default:
- h.wrapErrstr(xerr.Error(), err)
- }
- case string:
- if xerr != "" {
- h.wrapErrstr(xerr, err)
- }
- case fmt.Stringer:
- if xerr != nil {
- h.wrapErrstr(xerr.String(), err)
- }
- default:
- h.wrapErrstr(v, err)
- }
-}
-
-func isImmutableKind(k reflect.Kind) (v bool) {
- return immutableKindsSet[k]
-}
-
-// ----
-
-type codecFnInfo struct {
- ti *typeInfo
- xfFn Ext
- xfTag uint64
- seq seqType
- addrD bool
- addrF bool // if addrD, this says whether decode function can take a value or a ptr
- addrE bool
- ready bool // ready to use
-}
-
-// codecFn encapsulates the captured variables and the encode function.
-// This way, we only do some calculations one times, and pass to the
-// code block that should be called (encapsulated in a function)
-// instead of executing the checks every time.
-type codecFn struct {
- i codecFnInfo
- fe func(*Encoder, *codecFnInfo, reflect.Value)
- fd func(*Decoder, *codecFnInfo, reflect.Value)
- _ [1]uint64 // padding
-}
-
-type codecRtidFn struct {
- rtid uintptr
- fn *codecFn
-}
-
-type codecFner struct {
- // hh Handle
- h *BasicHandle
- s []codecRtidFn
- be bool
- js bool
- _ [6]byte // padding
- _ [3]uint64 // padding
-}
-
-func (c *codecFner) reset(hh Handle) {
- bh := hh.getBasicHandle()
- // only reset iff extensions changed or *TypeInfos changed
- var hhSame = true &&
- c.h == bh && c.h.TypeInfos == bh.TypeInfos &&
- len(c.h.extHandle) == len(bh.extHandle) &&
- (len(c.h.extHandle) == 0 || &c.h.extHandle[0] == &bh.extHandle[0])
- if !hhSame {
- // c.hh = hh
- c.h, bh = bh, c.h // swap both
- _, c.js = hh.(*JsonHandle)
- c.be = hh.isBinary()
- for i := range c.s {
- c.s[i].fn.i.ready = false
- }
- }
-}
-
-func (c *codecFner) get(rt reflect.Type, checkFastpath, checkCodecSelfer bool) (fn *codecFn) {
- rtid := rt2id(rt)
-
- for _, x := range c.s {
- if x.rtid == rtid {
- // if rtid exists, then there's a *codenFn attached (non-nil)
- fn = x.fn
- if fn.i.ready {
- return
- }
- break
- }
- }
- var ti *typeInfo
- if fn == nil {
- fn = new(codecFn)
- if c.s == nil {
- c.s = make([]codecRtidFn, 0, 8)
- }
- c.s = append(c.s, codecRtidFn{rtid, fn})
- } else {
- ti = fn.i.ti
- *fn = codecFn{}
- fn.i.ti = ti
- // fn.fe, fn.fd = nil, nil
- }
- fi := &(fn.i)
- fi.ready = true
- if ti == nil {
- ti = c.h.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 {
- fn.fe = (*Encoder).kTime
- fn.fd = (*Decoder).kTime
- } else if rtid == rawTypId {
- fn.fe = (*Encoder).raw
- fn.fd = (*Decoder).raw
- } else if rtid == rawExtTypId {
- fn.fe = (*Encoder).rawExt
- fn.fd = (*Decoder).rawExt
- fi.addrF = true
- fi.addrD = true
- fi.addrE = true
- } else if xfFn := c.h.getExt(rtid); xfFn != nil {
- fi.xfTag, fi.xfFn = xfFn.tag, xfFn.ext
- fn.fe = (*Encoder).ext
- fn.fd = (*Decoder).ext
- fi.addrF = true
- fi.addrD = true
- if rk == reflect.Struct || rk == reflect.Array {
- fi.addrE = true
- }
- } else if supportMarshalInterfaces && c.be && (ti.bm || ti.bmp) && (ti.bu || ti.bup) {
- 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) {
- //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) {
- fn.fe = (*Encoder).textMarshal
- fn.fd = (*Decoder).textUnmarshal
- fi.addrF = true
- fi.addrD = ti.tup
- fi.addrE = ti.tmp
- } else {
- if fastpathEnabled && checkFastpath && (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
- fn.fd = fastpathAV[idx].decfn
- fi.addrD = true
- fi.addrF = false
- }
- } else {
- // use mapping for underlying type if there
- var rtu reflect.Type
- if rk == reflect.Map {
- rtu = reflect.MapOf(ti.key, ti.elem)
- } else {
- rtu = reflect.SliceOf(ti.elem)
- }
- rtuid := rt2id(rtu)
- if idx := fastpathAV.index(rtuid); idx != -1 {
- xfnf := fastpathAV[idx].encfn
- xrt := fastpathAV[idx].rt
- fn.fe = func(e *Encoder, xf *codecFnInfo, xrv reflect.Value) {
- xfnf(e, xf, xrv.Convert(xrt))
- }
- fi.addrD = true
- fi.addrF = false // meaning it can be an address(ptr) or a value
- xfnf2 := fastpathAV[idx].decfn
- fn.fd = func(d *Decoder, xf *codecFnInfo, xrv reflect.Value) {
- if xrv.Kind() == reflect.Ptr {
- xfnf2(d, xf, xrv.Convert(reflect.PtrTo(xrt)))
- } else {
- xfnf2(d, xf, xrv.Convert(xrt))
- }
- }
- }
- }
- }
- if fn.fe == nil && fn.fd == nil {
- switch rk {
- case reflect.Bool:
- fn.fe = (*Encoder).kBool
- fn.fd = (*Decoder).kBool
- case reflect.String:
- fn.fe = (*Encoder).kString
- fn.fd = (*Decoder).kString
- case reflect.Int:
- fn.fd = (*Decoder).kInt
- fn.fe = (*Encoder).kInt
- case reflect.Int8:
- fn.fe = (*Encoder).kInt8
- fn.fd = (*Decoder).kInt8
- case reflect.Int16:
- fn.fe = (*Encoder).kInt16
- fn.fd = (*Decoder).kInt16
- case reflect.Int32:
- fn.fe = (*Encoder).kInt32
- fn.fd = (*Decoder).kInt32
- case reflect.Int64:
- fn.fe = (*Encoder).kInt64
- fn.fd = (*Decoder).kInt64
- case reflect.Uint:
- fn.fd = (*Decoder).kUint
- fn.fe = (*Encoder).kUint
- case reflect.Uint8:
- fn.fe = (*Encoder).kUint8
- fn.fd = (*Decoder).kUint8
- case reflect.Uint16:
- fn.fe = (*Encoder).kUint16
- fn.fd = (*Decoder).kUint16
- case reflect.Uint32:
- fn.fe = (*Encoder).kUint32
- fn.fd = (*Decoder).kUint32
- case reflect.Uint64:
- fn.fe = (*Encoder).kUint64
- fn.fd = (*Decoder).kUint64
- case reflect.Uintptr:
- fn.fe = (*Encoder).kUintptr
- fn.fd = (*Decoder).kUintptr
- case reflect.Float32:
- fn.fe = (*Encoder).kFloat32
- fn.fd = (*Decoder).kFloat32
- case reflect.Float64:
- fn.fe = (*Encoder).kFloat64
- fn.fd = (*Decoder).kFloat64
- case reflect.Invalid:
- fn.fe = (*Encoder).kInvalid
- fn.fd = (*Decoder).kErr
- case reflect.Chan:
- fi.seq = seqTypeChan
- fn.fe = (*Encoder).kSlice
- fn.fd = (*Decoder).kSlice
- case reflect.Slice:
- fi.seq = seqTypeSlice
- fn.fe = (*Encoder).kSlice
- fn.fd = (*Decoder).kSlice
- case reflect.Array:
- fi.seq = seqTypeArray
- fn.fe = (*Encoder).kSlice
- fi.addrF = false
- fi.addrD = false
- rt2 := reflect.SliceOf(ti.elem)
- fn.fd = func(d *Decoder, xf *codecFnInfo, xrv reflect.Value) {
- d.cfer().get(rt2, true, false).fd(d, xf, xrv.Slice(0, xrv.Len()))
- }
- // fn.fd = (*Decoder).kArray
- case reflect.Struct:
- if ti.anyOmitEmpty {
- fn.fe = (*Encoder).kStruct
- } else {
- fn.fe = (*Encoder).kStructNoOmitempty
- }
- fn.fd = (*Decoder).kStruct
- case reflect.Map:
- fn.fe = (*Encoder).kMap
- fn.fd = (*Decoder).kMap
- case reflect.Interface:
- // encode: reflect.Interface are handled already by preEncodeValue
- fn.fd = (*Decoder).kInterface
- fn.fe = (*Encoder).kErr
- default:
- // reflect.Ptr and reflect.Interface are handled already by preEncodeValue
- fn.fe = (*Encoder).kErr
- fn.fd = (*Decoder).kErr
- }
- }
- }
- return
-}
-
-type codecFnPooler struct {
- cf *codecFner
- cfp *sync.Pool
- hh Handle
-}
-
-func (d *codecFnPooler) cfer() *codecFner {
- if d.cf == nil {
- var v interface{}
- d.cfp, v = pool.codecFner()
- d.cf = v.(*codecFner)
- d.cf.reset(d.hh)
- }
- return d.cf
-}
-
-func (d *codecFnPooler) alwaysAtEnd() {
- if d.cf != nil {
- d.cfp.Put(d.cf)
- d.cf, d.cfp = nil, nil
- }
-}
-
-// ----
-
-// these "checkOverflow" functions must be inlinable, and not call anybody.
-// Overflow means that the value cannot be represented without wrapping/overflow.
-// Overflow=false does not mean that the value can be represented without losing precision
-// (especially for floating point).
-
-type checkOverflow struct{}
-
-// func (checkOverflow) Float16(f float64) (overflow bool) {
-// panicv.errorf("unimplemented")
-// if f < 0 {
-// f = -f
-// }
-// return math.MaxFloat32 < f && f <= math.MaxFloat64
+// func doPanic(tag string, format string, params ...interface{}) {
+// params2 := make([]interface{}, len(params)+1)
+// params2[0] = tag
+// copy(params2[1:], params)
+// panic(fmt.Errorf("%s: "+format, params2...))
// }
-func (checkOverflow) Float32(v float64) (overflow bool) {
- if v < 0 {
- v = -v
- }
- return math.MaxFloat32 < v && v <= math.MaxFloat64
+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
}
-func (checkOverflow) Uint(v uint64, bitsize uint8) (overflow bool) {
+
+// these functions must be inlinable, and not call anybody
+type checkOverflow struct{}
+
+func (_ checkOverflow) Float32(f float64) (overflow bool) {
+ if f < 0 {
+ f = -f
+ }
+ return math.MaxFloat32 < f && f <= math.MaxFloat64
+}
+
+func (_ checkOverflow) Uint(v uint64, bitsize uint8) (overflow bool) {
if bitsize == 0 || bitsize >= 64 || v == 0 {
return
}
@@ -1909,7 +1102,8 @@ func (checkOverflow) Uint(v uint64, bitsize uint8) (overflow bool) {
}
return
}
-func (checkOverflow) Int(v int64, bitsize uint8) (overflow bool) {
+
+func (_ checkOverflow) Int(v int64, bitsize uint8) (overflow bool) {
if bitsize == 0 || bitsize >= 64 || v == 0 {
return
}
@@ -1918,76 +1112,38 @@ func (checkOverflow) Int(v int64, bitsize uint8) (overflow bool) {
}
return
}
-func (checkOverflow) SignedInt(v uint64) (overflow bool) {
+
+func (_ checkOverflow) SignedInt(v uint64) (i int64, overflow bool) {
//e.g. -127 to 128 for int8
pos := (v >> 63) == 0
ui2 := v & 0x7fffffffffffffff
if pos {
if ui2 > math.MaxInt64 {
overflow = true
+ return
}
} else {
if ui2 > math.MaxInt64-1 {
overflow = true
+ return
}
}
+ i = int64(v)
return
}
-func (x checkOverflow) Float32V(v float64) float64 {
- if x.Float32(v) {
- panicv.errorf("float32 overflow: %v", v)
- }
- return v
-}
-func (x checkOverflow) UintV(v uint64, bitsize uint8) uint64 {
- if x.Uint(v, bitsize) {
- panicv.errorf("uint64 overflow: %v", v)
- }
- return v
-}
-func (x checkOverflow) IntV(v int64, bitsize uint8) int64 {
- if x.Int(v, bitsize) {
- panicv.errorf("int64 overflow: %v", v)
- }
- return v
-}
-func (x checkOverflow) SignedIntV(v uint64) int64 {
- if x.SignedInt(v) {
- panicv.errorf("uint64 to int64 overflow: %v", v)
- }
- return int64(v)
-}
-
// ------------------ SORT -----------------
func isNaN(f float64) bool { return f != f }
// -----------------------
-type ioFlusher interface {
- Flush() error
-}
-
-type ioPeeker interface {
- Peek(int) ([]byte, error)
-}
-
-type ioBuffered interface {
- Buffered() int
-}
-
-// -----------------------
-
type intSlice []int64
type uintSlice []uint64
-
-// type uintptrSlice []uintptr
type floatSlice []float64
type boolSlice []bool
type stringSlice []string
-
-// type bytesSlice [][]byte
+type bytesSlice [][]byte
func (p intSlice) Len() int { return len(p) }
func (p intSlice) Less(i, j int) bool { return p[i] < p[j] }
@@ -1997,10 +1153,6 @@ func (p uintSlice) Len() int { return len(p) }
func (p uintSlice) Less(i, j int) bool { return p[i] < p[j] }
func (p uintSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
-// func (p uintptrSlice) Len() int { return len(p) }
-// func (p uintptrSlice) Less(i, j int) bool { return p[i] < p[j] }
-// func (p uintptrSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
-
func (p floatSlice) Len() int { return len(p) }
func (p floatSlice) Less(i, j int) bool {
return p[i] < p[j] || isNaN(p[i]) && !isNaN(p[j])
@@ -2011,9 +1163,9 @@ func (p stringSlice) Len() int { return len(p) }
func (p stringSlice) Less(i, j int) bool { return p[i] < p[j] }
func (p stringSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
-// func (p bytesSlice) Len() int { return len(p) }
-// func (p bytesSlice) Less(i, j int) bool { return bytes.Compare(p[i], p[j]) == -1 }
-// func (p bytesSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
+func (p bytesSlice) Len() int { return len(p) }
+func (p bytesSlice) Less(i, j int) bool { return bytes.Compare(p[i], p[j]) == -1 }
+func (p bytesSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
func (p boolSlice) Len() int { return len(p) }
func (p boolSlice) Less(i, j int) bool { return !p[i] && p[j] }
@@ -2051,11 +1203,6 @@ type bytesRv struct {
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[i].v < p[j].v }
@@ -2083,10 +1230,6 @@ func (p boolRvSlice) Len() int { return len(p) }
func (p boolRvSlice) Less(i, j int) bool { return !p[i].v && p[j].v }
func (p boolRvSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
-func (p timeRvSlice) Len() int { return len(p) }
-func (p timeRvSlice) Less(i, j int) bool { return p[i].v.Before(p[j].v) }
-func (p timeRvSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
-
// -----------------
type bytesI struct {
@@ -2106,6 +1249,7 @@ type set []uintptr
func (s *set) add(v uintptr) (exists bool) {
// e.ci is always nil, or len >= 1
+ // defer func() { fmt.Printf("$$$$$$$$$$$ cirRef Add: %v, exists: %v\n", v, exists) }()
x := *s
if x == nil {
x = make([]uintptr, 1, 8)
@@ -2146,6 +1290,7 @@ func (s *set) add(v uintptr) (exists bool) {
}
func (s *set) remove(v uintptr) (exists bool) {
+ // defer func() { fmt.Printf("$$$$$$$$$$$ cirRef Rm: %v, exists: %v\n", v, exists) }()
x := *s
if len(x) == 0 {
return
@@ -2167,248 +1312,3 @@ func (s *set) remove(v uintptr) (exists bool) {
}
return
}
-
-// ------
-
-// bitset types are better than [256]bool, because they permit the whole
-// bitset array being on a single cache line and use less memory.
-
-// given x > 0 and n > 0 and x is exactly 2^n, then pos/x === pos>>n AND pos%x === pos&(x-1).
-// consequently, pos/32 === pos>>5, pos/16 === pos>>4, pos/8 === pos>>3, pos%8 == pos&7
-
-type bitset256 [32]byte
-
-func (x *bitset256) isset(pos byte) bool {
- return x[pos>>3]&(1<<(pos&7)) != 0
-}
-func (x *bitset256) issetv(pos byte) byte {
- return x[pos>>3] & (1 << (pos & 7))
-}
-func (x *bitset256) set(pos byte) {
- x[pos>>3] |= (1 << (pos & 7))
-}
-
-// func (x *bitset256) unset(pos byte) {
-// x[pos>>3] &^= (1 << (pos & 7))
-// }
-
-type bitset128 [16]byte
-
-func (x *bitset128) isset(pos byte) bool {
- return x[pos>>3]&(1<<(pos&7)) != 0
-}
-func (x *bitset128) set(pos byte) {
- x[pos>>3] |= (1 << (pos & 7))
-}
-
-// func (x *bitset128) unset(pos byte) {
-// x[pos>>3] &^= (1 << (pos & 7))
-// }
-
-type bitset32 [4]byte
-
-func (x *bitset32) isset(pos byte) bool {
- return x[pos>>3]&(1<<(pos&7)) != 0
-}
-func (x *bitset32) set(pos byte) {
- x[pos>>3] |= (1 << (pos & 7))
-}
-
-// func (x *bitset32) unset(pos byte) {
-// x[pos>>3] &^= (1 << (pos & 7))
-// }
-
-// type bit2set256 [64]byte
-
-// func (x *bit2set256) set(pos byte, v1, v2 bool) {
-// var pos2 uint8 = (pos & 3) << 1 // returning 0, 2, 4 or 6
-// if v1 {
-// x[pos>>2] |= 1 << (pos2 + 1)
-// }
-// if v2 {
-// x[pos>>2] |= 1 << pos2
-// }
-// }
-// func (x *bit2set256) get(pos byte) uint8 {
-// var pos2 uint8 = (pos & 3) << 1 // returning 0, 2, 4 or 6
-// return x[pos>>2] << (6 - pos2) >> 6 // 11000000 -> 00000011
-// }
-
-// ------------
-
-type pooler struct {
- dn sync.Pool // for decNaked
- cfn sync.Pool // for codecFner
- tiload sync.Pool
- strRv8, strRv16, strRv32, strRv64, strRv128 sync.Pool // for stringRV
-}
-
-func (p *pooler) init() {
- p.strRv8.New = func() interface{} { return new([8]stringRv) }
- p.strRv16.New = func() interface{} { return new([16]stringRv) }
- p.strRv32.New = func() interface{} { return new([32]stringRv) }
- p.strRv64.New = func() interface{} { return new([64]stringRv) }
- p.strRv128.New = func() interface{} { return new([128]stringRv) }
- p.dn.New = func() interface{} { x := new(decNaked); x.init(); return x }
- p.tiload.New = func() interface{} { return new(typeInfoLoadArray) }
- p.cfn.New = func() interface{} { return new(codecFner) }
-}
-
-func (p *pooler) stringRv8() (sp *sync.Pool, v interface{}) {
- return &p.strRv8, p.strRv8.Get()
-}
-func (p *pooler) stringRv16() (sp *sync.Pool, v interface{}) {
- return &p.strRv16, p.strRv16.Get()
-}
-func (p *pooler) stringRv32() (sp *sync.Pool, v interface{}) {
- return &p.strRv32, p.strRv32.Get()
-}
-func (p *pooler) stringRv64() (sp *sync.Pool, v interface{}) {
- return &p.strRv64, p.strRv64.Get()
-}
-func (p *pooler) stringRv128() (sp *sync.Pool, v interface{}) {
- return &p.strRv128, p.strRv128.Get()
-}
-func (p *pooler) decNaked() (sp *sync.Pool, v interface{}) {
- return &p.dn, p.dn.Get()
-}
-func (p *pooler) codecFner() (sp *sync.Pool, v interface{}) {
- return &p.cfn, p.cfn.Get()
-}
-func (p *pooler) tiLoad() (sp *sync.Pool, v interface{}) {
- return &p.tiload, p.tiload.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) codecFnerGet() (v interface{}) {
-// return p.cfn.Get()
-// }
-// func (p *pooler) tiLoadGet() (v interface{}) {
-// return p.tiload.Get()
-// }
-// func (p *pooler) decNakedPut(v interface{}) {
-// p.dn.Put(v)
-// }
-// func (p *pooler) codecFnerPut(v interface{}) {
-// p.cfn.Put(v)
-// }
-// func (p *pooler) tiLoadPut(v interface{}) {
-// p.tiload.Put(v)
-// }
-
-type panicHdl struct{}
-
-func (panicHdl) errorv(err error) {
- if err != nil {
- panic(err)
- }
-}
-
-func (panicHdl) errorstr(message string) {
- if message != "" {
- panic(message)
- }
-}
-
-func (panicHdl) errorf(format string, params ...interface{}) {
- if format != "" {
- if len(params) == 0 {
- panic(format)
- } else {
- panic(fmt.Sprintf(format, params...))
- }
- }
-}
-
-type errstrDecorator interface {
- wrapErrstr(interface{}, *error)
-}
-
-type errstrDecoratorDef struct{}
-
-func (errstrDecoratorDef) wrapErrstr(v interface{}, e *error) { *e = fmt.Errorf("%v", v) }
-
-type must struct{}
-
-func (must) String(s string, err error) string {
- if err != nil {
- panicv.errorv(err)
- }
- return s
-}
-func (must) Int(s int64, err error) int64 {
- if err != nil {
- panicv.errorv(err)
- }
- return s
-}
-func (must) Uint(s uint64, err error) uint64 {
- if err != nil {
- panicv.errorv(err)
- }
- return s
-}
-func (must) Float(s float64, err error) float64 {
- if err != nil {
- panicv.errorv(err)
- }
- return s
-}
-
-// xdebugf prints the message in red on the terminal.
-// Use it in place of fmt.Printf (which it calls internally)
-func xdebugf(pattern string, args ...interface{}) {
- 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
-// }
-
-// 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)
-// }
diff --git a/vendor/github.com/ugorji/go/codec/helper_internal.go b/vendor/github.com/ugorji/go/codec/helper_internal.go
index 0cbd665e25..5d0727f77f 100644
--- a/vendor/github.com/ugorji/go/codec/helper_internal.go
+++ b/vendor/github.com/ugorji/go/codec/helper_internal.go
@@ -6,6 +6,74 @@ package codec
// All non-std package dependencies live in this file,
// so porting to different environment is easy (just update functions).
+import (
+ "errors"
+ "fmt"
+ "math"
+ "reflect"
+)
+
+func panicValToErr(panicVal interface{}, err *error) {
+ if panicVal == nil {
+ return
+ }
+ // case nil
+ switch xerr := panicVal.(type) {
+ case error:
+ *err = xerr
+ case string:
+ *err = errors.New(xerr)
+ default:
+ *err = fmt.Errorf("%v", panicVal)
+ }
+ return
+}
+
+func hIsEmptyValue(v reflect.Value, deref, checkStruct bool) bool {
+ switch v.Kind() {
+ case reflect.Invalid:
+ return true
+ case reflect.Array, reflect.Map, reflect.Slice, reflect.String:
+ return v.Len() == 0
+ case reflect.Bool:
+ return !v.Bool()
+ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
+ return v.Int() == 0
+ case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
+ return v.Uint() == 0
+ case reflect.Float32, reflect.Float64:
+ return v.Float() == 0
+ case reflect.Interface, reflect.Ptr:
+ if deref {
+ if v.IsNil() {
+ return true
+ }
+ return hIsEmptyValue(v.Elem(), deref, checkStruct)
+ } else {
+ return v.IsNil()
+ }
+ case reflect.Struct:
+ if !checkStruct {
+ return false
+ }
+ // return true if all fields are empty. else return false.
+ // we cannot use equality check, because some fields may be maps/slices/etc
+ // and consequently the structs are not comparable.
+ // return v.Interface() == reflect.Zero(v.Type()).Interface()
+ for i, n := 0, v.NumField(); i < n; i++ {
+ if !hIsEmptyValue(v.Field(i), deref, checkStruct) {
+ return false
+ }
+ }
+ return true
+ }
+ return false
+}
+
+func isEmptyValue(v reflect.Value, deref, checkStruct bool) bool {
+ return hIsEmptyValue(v, deref, checkStruct)
+}
+
func pruneSignExt(v []byte, pos bool) (n int) {
if len(v) < 2 {
} else if pos && v[0] == 0 {
@@ -18,6 +86,37 @@ func pruneSignExt(v []byte, pos bool) (n int) {
return
}
+func implementsIntf(typ, iTyp reflect.Type) (success bool, indir int8) {
+ if typ == nil {
+ return
+ }
+ rt := typ
+ // The type might be a pointer and we need to keep
+ // dereferencing to the base type until we find an implementation.
+ for {
+ if rt.Implements(iTyp) {
+ return true, indir
+ }
+ if p := rt; p.Kind() == reflect.Ptr {
+ indir++
+ if indir >= math.MaxInt8 { // insane number of indirections
+ return false, 0
+ }
+ rt = p.Elem()
+ continue
+ }
+ break
+ }
+ // No luck yet, but if this is a base type (non-pointer), the pointer might satisfy.
+ if typ.Kind() != reflect.Ptr {
+ // Not a pointer, but does the pointer work?
+ if reflect.PtrTo(typ).Implements(iTyp) {
+ return true, -1
+ }
+ }
+ return false, 0
+}
+
// validate that this function is correct ...
// culled from OGRE (Object-Oriented Graphics Rendering Engine)
// function: halfToFloatI (http://stderr.org/doc/ogre-doc/api/OgreBitwise_8h-source.html)
@@ -30,20 +129,21 @@ func halfFloatToFloatBits(yy uint16) (d uint32) {
if e == 0 {
if m == 0 { // plu or minus 0
return s << 31
+ } else { // Denormalized number -- renormalize it
+ for (m & 0x00000400) == 0 {
+ m <<= 1
+ e -= 1
+ }
+ e += 1
+ const zz uint32 = 0x0400
+ m &= ^zz
}
- // Denormalized number -- renormalize it
- for (m & 0x00000400) == 0 {
- m <<= 1
- e -= 1
- }
- e += 1
- const zz uint32 = 0x0400
- m &= ^zz
} else if e == 31 {
if m == 0 { // Inf
return (s << 31) | 0x7f800000
+ } else { // NaN
+ return (s << 31) | 0x7f800000 | (m << 13)
}
- return (s << 31) | 0x7f800000 | (m << 13) // NaN
}
e = e + (127 - 15)
m = m << 13
@@ -119,3 +219,24 @@ func growCap(oldCap, unit, num int) (newCap int) {
}
return
}
+
+func expandSliceValue(s reflect.Value, num int) reflect.Value {
+ if num <= 0 {
+ return s
+ }
+ l0 := s.Len()
+ l1 := l0 + num // new slice length
+ if l1 < l0 {
+ panic("ExpandSlice: slice overflow")
+ }
+ c0 := s.Cap()
+ if l1 <= c0 {
+ return s.Slice(0, l1)
+ }
+ st := s.Type()
+ c1 := growCap(c0, int(st.Elem().Size()), num)
+ s2 := reflect.MakeSlice(st, l1, c1)
+ // println("expandslicevalue: cap-old: ", c0, ", cap-new: ", c1, ", len-new: ", l1)
+ reflect.Copy(s2, s)
+ return s2
+}
diff --git a/vendor/github.com/ugorji/go/codec/helper_not_unsafe.go b/vendor/github.com/ugorji/go/codec/helper_not_unsafe.go
index fd52690c94..8b06a00459 100644
--- a/vendor/github.com/ugorji/go/codec/helper_not_unsafe.go
+++ b/vendor/github.com/ugorji/go/codec/helper_not_unsafe.go
@@ -1,24 +1,13 @@
-// +build !go1.7 safe appengine
+// +build !unsafe
-// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved.
+// Copyright (c) 2012-2015 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"
- "sync/atomic"
- "time"
-)
-
-const safeMode = true
-
// stringView returns a view of the []byte as a string.
// In unsafe mode, it doesn't incur allocation and copying caused by conversion.
// In regular safe mode, it is an allocation and copy.
-//
-// Usage: Always maintain a reference to v while result of this call is in use,
-// and call keepAlive4BytesView(v) at point where done with view.
func stringView(v []byte) string {
return string(v)
}
@@ -26,247 +15,6 @@ func stringView(v []byte) string {
// bytesView returns a view of the string as a []byte.
// In unsafe mode, it doesn't incur allocation and copying caused by conversion.
// In regular safe mode, it is an allocation and copy.
-//
-// Usage: Always maintain a reference to v while result of this call is in use,
-// and call keepAlive4BytesView(v) at point where done with view.
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
-}
-
-func rv2i(rv reflect.Value) interface{} {
- return rv.Interface()
-}
-
-func rt2id(rt reflect.Type) uintptr {
- return reflect.ValueOf(rt).Pointer()
-}
-
-func rv2rtid(rv reflect.Value) uintptr {
- return reflect.ValueOf(rv.Type()).Pointer()
-}
-
-func i2rtid(i interface{}) uintptr {
- return reflect.ValueOf(reflect.TypeOf(i)).Pointer()
-}
-
-// --------------------------
-
-func isEmptyValue(v reflect.Value, tinfos *TypeInfos, deref, checkStruct bool) bool {
- switch v.Kind() {
- case reflect.Invalid:
- return true
- case reflect.Array, reflect.Map, reflect.Slice, reflect.String:
- return v.Len() == 0
- case reflect.Bool:
- return !v.Bool()
- case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
- return v.Int() == 0
- case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
- return v.Uint() == 0
- case reflect.Float32, reflect.Float64:
- return v.Float() == 0
- case reflect.Interface, reflect.Ptr:
- if deref {
- if v.IsNil() {
- return true
- }
- return isEmptyValue(v.Elem(), tinfos, deref, checkStruct)
- }
- return v.IsNil()
- case reflect.Struct:
- return isEmptyStruct(v, tinfos, deref, checkStruct)
- }
- return false
-}
-
-// --------------------------
-// type ptrToRvMap struct{}
-
-// func (*ptrToRvMap) init() {}
-// func (*ptrToRvMap) get(i interface{}) reflect.Value {
-// return reflect.ValueOf(i).Elem()
-// }
-
-// --------------------------
-type atomicTypeInfoSlice struct { // expected to be 2 words
- v atomic.Value
-}
-
-func (x *atomicTypeInfoSlice) load() []rtid2ti {
- i := x.v.Load()
- if i == nil {
- return nil
- }
- return i.([]rtid2ti)
-}
-
-func (x *atomicTypeInfoSlice) store(p []rtid2ti) {
- x.v.Store(p)
-}
-
-// --------------------------
-func (d *Decoder) raw(f *codecFnInfo, rv reflect.Value) {
- rv.SetBytes(d.rawBytes())
-}
-
-func (d *Decoder) kString(f *codecFnInfo, rv reflect.Value) {
- rv.SetString(d.d.DecodeString())
-}
-
-func (d *Decoder) kBool(f *codecFnInfo, rv reflect.Value) {
- rv.SetBool(d.d.DecodeBool())
-}
-
-func (d *Decoder) kTime(f *codecFnInfo, rv reflect.Value) {
- rv.Set(reflect.ValueOf(d.d.DecodeTime()))
-}
-
-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 (d *Decoder) kFloat64(f *codecFnInfo, rv reflect.Value) {
- rv.SetFloat(d.d.DecodeFloat64())
-}
-
-func (d *Decoder) kInt(f *codecFnInfo, rv reflect.Value) {
- rv.SetInt(chkOvf.IntV(d.d.DecodeInt64(), intBitsize))
-}
-
-func (d *Decoder) kInt8(f *codecFnInfo, rv reflect.Value) {
- rv.SetInt(chkOvf.IntV(d.d.DecodeInt64(), 8))
-}
-
-func (d *Decoder) kInt16(f *codecFnInfo, rv reflect.Value) {
- rv.SetInt(chkOvf.IntV(d.d.DecodeInt64(), 16))
-}
-
-func (d *Decoder) kInt32(f *codecFnInfo, rv reflect.Value) {
- rv.SetInt(chkOvf.IntV(d.d.DecodeInt64(), 32))
-}
-
-func (d *Decoder) kInt64(f *codecFnInfo, rv reflect.Value) {
- rv.SetInt(d.d.DecodeInt64())
-}
-
-func (d *Decoder) kUint(f *codecFnInfo, rv reflect.Value) {
- rv.SetUint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize))
-}
-
-func (d *Decoder) kUintptr(f *codecFnInfo, rv reflect.Value) {
- rv.SetUint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize))
-}
-
-func (d *Decoder) kUint8(f *codecFnInfo, rv reflect.Value) {
- rv.SetUint(chkOvf.UintV(d.d.DecodeUint64(), 8))
-}
-
-func (d *Decoder) kUint16(f *codecFnInfo, rv reflect.Value) {
- rv.SetUint(chkOvf.UintV(d.d.DecodeUint64(), 16))
-}
-
-func (d *Decoder) kUint32(f *codecFnInfo, rv reflect.Value) {
- rv.SetUint(chkOvf.UintV(d.d.DecodeUint64(), 32))
-}
-
-func (d *Decoder) kUint64(f *codecFnInfo, rv reflect.Value) {
- rv.SetUint(d.d.DecodeUint64())
-}
-
-// ----------------
-
-func (e *Encoder) kBool(f *codecFnInfo, rv reflect.Value) {
- e.e.EncodeBool(rv.Bool())
-}
-
-func (e *Encoder) kTime(f *codecFnInfo, rv reflect.Value) {
- e.e.EncodeTime(rv2i(rv).(time.Time))
-}
-
-func (e *Encoder) kString(f *codecFnInfo, rv reflect.Value) {
- e.e.EncodeString(cUTF8, rv.String())
-}
-
-func (e *Encoder) kFloat64(f *codecFnInfo, rv reflect.Value) {
- e.e.EncodeFloat64(rv.Float())
-}
-
-func (e *Encoder) kFloat32(f *codecFnInfo, rv reflect.Value) {
- e.e.EncodeFloat32(float32(rv.Float()))
-}
-
-func (e *Encoder) kInt(f *codecFnInfo, rv reflect.Value) {
- e.e.EncodeInt(rv.Int())
-}
-
-func (e *Encoder) kInt8(f *codecFnInfo, rv reflect.Value) {
- e.e.EncodeInt(rv.Int())
-}
-
-func (e *Encoder) kInt16(f *codecFnInfo, rv reflect.Value) {
- e.e.EncodeInt(rv.Int())
-}
-
-func (e *Encoder) kInt32(f *codecFnInfo, rv reflect.Value) {
- e.e.EncodeInt(rv.Int())
-}
-
-func (e *Encoder) kInt64(f *codecFnInfo, rv reflect.Value) {
- e.e.EncodeInt(rv.Int())
-}
-
-func (e *Encoder) kUint(f *codecFnInfo, rv reflect.Value) {
- e.e.EncodeUint(rv.Uint())
-}
-
-func (e *Encoder) kUint8(f *codecFnInfo, rv reflect.Value) {
- e.e.EncodeUint(rv.Uint())
-}
-
-func (e *Encoder) kUint16(f *codecFnInfo, rv reflect.Value) {
- e.e.EncodeUint(rv.Uint())
-}
-
-func (e *Encoder) kUint32(f *codecFnInfo, rv reflect.Value) {
- e.e.EncodeUint(rv.Uint())
-}
-
-func (e *Encoder) kUint64(f *codecFnInfo, rv reflect.Value) {
- e.e.EncodeUint(rv.Uint())
-}
-
-func (e *Encoder) kUintptr(f *codecFnInfo, rv reflect.Value) {
- e.e.EncodeUint(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) {}
-
-// // 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 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
-// }
-// }
diff --git a/vendor/github.com/ugorji/go/codec/helper_unsafe.go b/vendor/github.com/ugorji/go/codec/helper_unsafe.go
index e3df60abea..0f596c71aa 100644
--- a/vendor/github.com/ugorji/go/codec/helper_unsafe.go
+++ b/vendor/github.com/ugorji/go/codec/helper_unsafe.go
@@ -1,639 +1,49 @@
-// +build !safe
-// +build !appengine
-// +build go1.7
+// +build unsafe
-// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved.
+// Copyright (c) 2012-2015 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"
- "sync/atomic"
- "time"
"unsafe"
)
// This file has unsafe variants of some helper methods.
-// NOTE: See helper_not_unsafe.go for the usage information.
-
-// var zeroRTv [4]uintptr
-
-const safeMode = false
-const unsafeFlagIndir = 1 << 7 // keep in sync with GO_ROOT/src/reflect/value.go
type unsafeString struct {
- Data unsafe.Pointer
+ Data uintptr
Len int
}
type unsafeSlice struct {
- Data unsafe.Pointer
+ Data uintptr
Len int
Cap int
}
-type unsafeIntf struct {
- typ unsafe.Pointer
- word unsafe.Pointer
-}
-
-type unsafeReflectValue struct {
- typ unsafe.Pointer
- ptr unsafe.Pointer
- flag uintptr
-}
-
+// stringView returns a view of the []byte as a string.
+// In unsafe mode, it doesn't incur allocation and copying caused by conversion.
+// In regular safe mode, it is an allocation and copy.
func stringView(v []byte) string {
if len(v) == 0 {
return ""
}
+
bx := (*unsafeSlice)(unsafe.Pointer(&v))
- return *(*string)(unsafe.Pointer(&unsafeString{bx.Data, bx.Len}))
+ sx := unsafeString{bx.Data, bx.Len}
+ return *(*string)(unsafe.Pointer(&sx))
}
+// bytesView returns a view of the string as a []byte.
+// In unsafe mode, it doesn't incur allocation and copying caused by conversion.
+// In regular safe mode, it is an allocation and copy.
func bytesView(v string) []byte {
if len(v) == 0 {
return zeroByteSlice
}
+
sx := (*unsafeString)(unsafe.Pointer(&v))
- return *(*[]byte)(unsafe.Pointer(&unsafeSlice{sx.Data, sx.Len, sx.Len}))
+ bx := unsafeSlice{sx.Data, sx.Len, sx.Len}
+ return *(*[]byte)(unsafe.Pointer(&bx))
}
-
-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)
-
- return ((*unsafeIntf)(unsafe.Pointer(&v))).word == nil
-}
-
-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
- // the source go stdlib reflect/value.go, and trims the implementation.
-
- 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
- }
- return *(*interface{})(unsafe.Pointer(&unsafeIntf{typ: urv.typ, word: ptr}))
-}
-
-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)
-}
-
-// --------------------------
-
-func isEmptyValue(v reflect.Value, tinfos *TypeInfos, deref, checkStruct bool) bool {
- urv := (*unsafeReflectValue)(unsafe.Pointer(&v))
- if urv.flag == 0 {
- return true
- }
- switch v.Kind() {
- case reflect.Invalid:
- return true
- case reflect.String:
- return (*unsafeString)(urv.ptr).Len == 0
- case reflect.Slice:
- return (*unsafeSlice)(urv.ptr).Len == 0
- case reflect.Bool:
- return !*(*bool)(urv.ptr)
- case reflect.Int:
- return *(*int)(urv.ptr) == 0
- case reflect.Int8:
- return *(*int8)(urv.ptr) == 0
- case reflect.Int16:
- return *(*int16)(urv.ptr) == 0
- case reflect.Int32:
- return *(*int32)(urv.ptr) == 0
- case reflect.Int64:
- return *(*int64)(urv.ptr) == 0
- case reflect.Uint:
- return *(*uint)(urv.ptr) == 0
- case reflect.Uint8:
- return *(*uint8)(urv.ptr) == 0
- case reflect.Uint16:
- return *(*uint16)(urv.ptr) == 0
- case reflect.Uint32:
- return *(*uint32)(urv.ptr) == 0
- case reflect.Uint64:
- return *(*uint64)(urv.ptr) == 0
- case reflect.Uintptr:
- return *(*uintptr)(urv.ptr) == 0
- case reflect.Float32:
- return *(*float32)(urv.ptr) == 0
- case reflect.Float64:
- return *(*float64)(urv.ptr) == 0
- case reflect.Interface:
- isnil := urv.ptr == nil || *(*unsafe.Pointer)(urv.ptr) == nil
- if deref {
- if isnil {
- return true
- }
- return isEmptyValue(v.Elem(), tinfos, deref, checkStruct)
- }
- return isnil
- case reflect.Ptr:
- // 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 {
- return true
- }
- return isEmptyValue(v.Elem(), tinfos, deref, checkStruct)
- }
- return isnil
- case reflect.Struct:
- return isEmptyStruct(v, tinfos, deref, checkStruct)
- case reflect.Map, reflect.Array, reflect.Chan:
- return v.Len() == 0
- }
- return false
-}
-
-// --------------------------
-
-// atomicTypeInfoSlice contains length and pointer to the array for a slice.
-// It is expected to be 2 words.
-//
-// Previously, we atomically loaded and stored the length and array pointer separately,
-// which could lead to some races.
-// We now just atomically store and load the pointer to the value directly.
-
-type atomicTypeInfoSlice struct { // expected to be 2 words
- l int // length of the data array (must be first in struct, for 64-bit alignment necessary for 386)
- v unsafe.Pointer // data array - Pointer (not uintptr) to maintain GC reference
-}
-
-func (x *atomicTypeInfoSlice) load() []rtid2ti {
- xp := unsafe.Pointer(x)
- x2 := *(*atomicTypeInfoSlice)(atomic.LoadPointer(&xp))
- if x2.l == 0 {
- return nil
- }
- return *(*[]rtid2ti)(unsafe.Pointer(&unsafeSlice{Data: x2.v, Len: x2.l, Cap: x2.l}))
-}
-
-func (x *atomicTypeInfoSlice) store(p []rtid2ti) {
- s := (*unsafeSlice)(unsafe.Pointer(&p))
- xp := unsafe.Pointer(x)
- atomic.StorePointer(&xp, unsafe.Pointer(&atomicTypeInfoSlice{l: s.Len, v: s.Data}))
-}
-
-// --------------------------
-func (d *Decoder) raw(f *codecFnInfo, rv reflect.Value) {
- urv := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- *(*[]byte)(urv.ptr) = d.rawBytes()
-}
-
-func (d *Decoder) kString(f *codecFnInfo, rv reflect.Value) {
- urv := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- *(*string)(urv.ptr) = d.d.DecodeString()
-}
-
-func (d *Decoder) kBool(f *codecFnInfo, rv reflect.Value) {
- urv := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- *(*bool)(urv.ptr) = d.d.DecodeBool()
-}
-
-func (d *Decoder) kTime(f *codecFnInfo, rv reflect.Value) {
- urv := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- *(*time.Time)(urv.ptr) = d.d.DecodeTime()
-}
-
-func (d *Decoder) kFloat32(f *codecFnInfo, rv reflect.Value) {
- fv := d.d.DecodeFloat64()
- if chkOvf.Float32(fv) {
- d.errorf("float32 overflow: %v", fv)
- }
- urv := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- *(*float32)(urv.ptr) = float32(fv)
-}
-
-func (d *Decoder) kFloat64(f *codecFnInfo, rv reflect.Value) {
- urv := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- *(*float64)(urv.ptr) = d.d.DecodeFloat64()
-}
-
-func (d *Decoder) kInt(f *codecFnInfo, rv reflect.Value) {
- urv := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- *(*int)(urv.ptr) = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize))
-}
-
-func (d *Decoder) kInt8(f *codecFnInfo, rv reflect.Value) {
- urv := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- *(*int8)(urv.ptr) = int8(chkOvf.IntV(d.d.DecodeInt64(), 8))
-}
-
-func (d *Decoder) kInt16(f *codecFnInfo, rv reflect.Value) {
- urv := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- *(*int16)(urv.ptr) = int16(chkOvf.IntV(d.d.DecodeInt64(), 16))
-}
-
-func (d *Decoder) kInt32(f *codecFnInfo, rv reflect.Value) {
- urv := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- *(*int32)(urv.ptr) = int32(chkOvf.IntV(d.d.DecodeInt64(), 32))
-}
-
-func (d *Decoder) kInt64(f *codecFnInfo, rv reflect.Value) {
- urv := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- *(*int64)(urv.ptr) = d.d.DecodeInt64()
-}
-
-func (d *Decoder) kUint(f *codecFnInfo, rv reflect.Value) {
- urv := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- *(*uint)(urv.ptr) = uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize))
-}
-
-func (d *Decoder) kUintptr(f *codecFnInfo, rv reflect.Value) {
- urv := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- *(*uintptr)(urv.ptr) = uintptr(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize))
-}
-
-func (d *Decoder) kUint8(f *codecFnInfo, rv reflect.Value) {
- urv := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- *(*uint8)(urv.ptr) = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8))
-}
-
-func (d *Decoder) kUint16(f *codecFnInfo, rv reflect.Value) {
- urv := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- *(*uint16)(urv.ptr) = uint16(chkOvf.UintV(d.d.DecodeUint64(), 16))
-}
-
-func (d *Decoder) kUint32(f *codecFnInfo, rv reflect.Value) {
- urv := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- *(*uint32)(urv.ptr) = uint32(chkOvf.UintV(d.d.DecodeUint64(), 32))
-}
-
-func (d *Decoder) kUint64(f *codecFnInfo, rv reflect.Value) {
- urv := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- *(*uint64)(urv.ptr) = d.d.DecodeUint64()
-}
-
-// ------------
-
-func (e *Encoder) kBool(f *codecFnInfo, rv reflect.Value) {
- v := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- e.e.EncodeBool(*(*bool)(v.ptr))
-}
-
-func (e *Encoder) kTime(f *codecFnInfo, rv reflect.Value) {
- v := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- e.e.EncodeTime(*(*time.Time)(v.ptr))
-}
-
-func (e *Encoder) kString(f *codecFnInfo, rv reflect.Value) {
- v := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- e.e.EncodeString(cUTF8, *(*string)(v.ptr))
-}
-
-func (e *Encoder) kFloat64(f *codecFnInfo, rv reflect.Value) {
- v := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- e.e.EncodeFloat64(*(*float64)(v.ptr))
-}
-
-func (e *Encoder) kFloat32(f *codecFnInfo, rv reflect.Value) {
- v := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- e.e.EncodeFloat32(*(*float32)(v.ptr))
-}
-
-func (e *Encoder) kInt(f *codecFnInfo, rv reflect.Value) {
- v := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- e.e.EncodeInt(int64(*(*int)(v.ptr)))
-}
-
-func (e *Encoder) kInt8(f *codecFnInfo, rv reflect.Value) {
- v := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- e.e.EncodeInt(int64(*(*int8)(v.ptr)))
-}
-
-func (e *Encoder) kInt16(f *codecFnInfo, rv reflect.Value) {
- v := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- e.e.EncodeInt(int64(*(*int16)(v.ptr)))
-}
-
-func (e *Encoder) kInt32(f *codecFnInfo, rv reflect.Value) {
- v := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- e.e.EncodeInt(int64(*(*int32)(v.ptr)))
-}
-
-func (e *Encoder) kInt64(f *codecFnInfo, rv reflect.Value) {
- v := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- e.e.EncodeInt(int64(*(*int64)(v.ptr)))
-}
-
-func (e *Encoder) kUint(f *codecFnInfo, rv reflect.Value) {
- v := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- e.e.EncodeUint(uint64(*(*uint)(v.ptr)))
-}
-
-func (e *Encoder) kUint8(f *codecFnInfo, rv reflect.Value) {
- v := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- e.e.EncodeUint(uint64(*(*uint8)(v.ptr)))
-}
-
-func (e *Encoder) kUint16(f *codecFnInfo, rv reflect.Value) {
- v := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- e.e.EncodeUint(uint64(*(*uint16)(v.ptr)))
-}
-
-func (e *Encoder) kUint32(f *codecFnInfo, rv reflect.Value) {
- v := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- e.e.EncodeUint(uint64(*(*uint32)(v.ptr)))
-}
-
-func (e *Encoder) kUint64(f *codecFnInfo, rv reflect.Value) {
- v := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- e.e.EncodeUint(uint64(*(*uint64)(v.ptr)))
-}
-
-func (e *Encoder) kUintptr(f *codecFnInfo, rv reflect.Value) {
- v := (*unsafeReflectValue)(unsafe.Pointer(&rv))
- e.e.EncodeUint(uint64(*(*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()
-// }
-
-// 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})
-// }
-
-// 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}))
-// }
-
-// 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)
-// }
-
-// func keepAlive4BytesView(v string) {
-// runtime.KeepAlive(v)
-// }
-
-// func keepAlive4StringView(v []byte) {
-// runtime.KeepAlive(v)
-// }
-
-// 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 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}))
-// }
-
-// 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 _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()
-// }
-
-// 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 init() {
-// staticRv2iTest()
-// }
-
-// 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
-// }
diff --git a/vendor/github.com/ugorji/go/codec/json.go b/vendor/github.com/ugorji/go/codec/json.go
index bdd1996639..5bb3896289 100644
--- a/vendor/github.com/ugorji/go/codec/json.go
+++ b/vendor/github.com/ugorji/go/codec/json.go
@@ -1,4 +1,4 @@
-// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved.
+// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved.
// Use of this source code is governed by a MIT license found in the LICENSE file.
package codec
@@ -17,6 +17,16 @@ package codec
// Note:
// - we cannot use strconv.Quote and strconv.Unquote because json quotes/unquotes differently.
// We implement it here.
+// - Also, strconv.ParseXXX for floats and integers
+// - only works on strings resulting in unnecessary allocation and []byte-string conversion.
+// - it does a lot of redundant checks, because json numbers are simpler that what it supports.
+// - We parse numbers (floats and integers) directly here.
+// We only delegate parsing floats if it is a hairy float which could cause a loss of precision.
+// In that case, we delegate to strconv.ParseFloat.
+//
+// Note:
+// - encode does not beautify. There is no whitespace when encoding.
+// - rpc calls which take single integer arguments or write single numeric arguments will need care.
// Top-level methods of json(End|Dec)Driver (which are implementations of (en|de)cDriver
// MUST not call one-another.
@@ -24,41 +34,42 @@ package codec
import (
"bytes"
"encoding/base64"
- "math"
+ "fmt"
"reflect"
"strconv"
- "time"
- "unicode"
"unicode/utf16"
"unicode/utf8"
)
//--------------------------------
-var jsonLiterals = [...]byte{
- '"', 't', 'r', 'u', 'e', '"',
- '"', 'f', 'a', 'l', 's', 'e', '"',
- '"', 'n', 'u', 'l', 'l', '"',
-}
+var (
+ jsonLiterals = [...]byte{'t', 'r', 'u', 'e', 'f', 'a', 'l', 's', 'e', 'n', 'u', 'l', 'l'}
-const (
- jsonLitTrueQ = 0
- jsonLitTrue = 1
- jsonLitFalseQ = 6
- jsonLitFalse = 7
- jsonLitNullQ = 13
- jsonLitNull = 14
+ jsonFloat64Pow10 = [...]float64{
+ 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9,
+ 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19,
+ 1e20, 1e21, 1e22,
+ }
+
+ jsonUint64Pow10 = [...]uint64{
+ 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9,
+ 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19,
+ }
+
+ // jsonTabs and jsonSpaces are used as caches for indents
+ jsonTabs, jsonSpaces string
)
const (
- jsonU4Chk2 = '0'
- jsonU4Chk1 = 'a' - 10
- jsonU4Chk0 = 'A' - 10
+ // jsonUnreadAfterDecNum controls whether we unread after decoding a number.
+ //
+ // instead of unreading, just update d.tok (iff it's not a whitespace char)
+ // However, doing this means that we may HOLD onto some data which belongs to another stream.
+ // Thus, it is safest to unread the data when done.
+ // keep behind a constant flag for now.
+ jsonUnreadAfterDecNum = true
- jsonScratchArrayLen = 64
-)
-
-const (
// If !jsonValidateSymbols, decoding will be faster, by skipping some checks:
// - If we see first character of null, false or true,
// do not validate subsequent characters.
@@ -67,156 +78,48 @@ const (
// P.S. Do not expect a significant decoding boost from this.
jsonValidateSymbols = true
+ // if jsonTruncateMantissa, truncate mantissa if trailing 0's.
+ // This is important because it could allow some floats to be decoded without
+ // deferring to strconv.ParseFloat.
+ jsonTruncateMantissa = true
+
+ // if mantissa >= jsonNumUintCutoff before multiplying by 10, this is an overflow
+ jsonNumUintCutoff = (1<<64-1)/uint64(10) + 1 // cutoff64(base)
+
+ // if mantissa >= jsonNumUintMaxVal, this is an overflow
+ jsonNumUintMaxVal = 1< &
- var i byte
- for i = 32; i < utf8.RuneSelf; i++ {
- switch i {
- case '"', '\\':
- case '<', '>', '&':
- jsonCharSafeSet.set(i) // = true
- default:
- jsonCharSafeSet.set(i)
- jsonCharHtmlSafeSet.set(i)
- }
- }
- for i = 0; i <= utf8.RuneSelf; i++ {
- switch i {
- case ' ', '\t', '\r', '\n':
- jsonCharWhitespaceSet.set(i)
- case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'e', 'E', '.', '+', '-':
- jsonNumSet.set(i)
- }
+ for i := 0; i < jsonSpacesOrTabsLen; i++ {
+ bs[i] = '\t'
}
+ jsonTabs = string(bs[:])
}
-// ----------------
-
-type jsonEncDriverTypical struct {
- w encWriter
- // w *encWriterSwitch
- b *[jsonScratchArrayLen]byte
- tw bool // term white space
+type jsonEncDriver struct {
+ e *Encoder
+ w encWriter
+ h *JsonHandle
+ b [64]byte // scratch
+ bs []byte // scratch
+ se setExtWrapper
+ ds string // indent string
+ dl uint16 // indent level
+ dt bool // indent using tabs
+ d bool // indent
c containerState
-}
-
-func (e *jsonEncDriverTypical) typical() {}
-
-func (e *jsonEncDriverTypical) reset(ee *jsonEncDriver) {
- e.w = ee.ew
- // e.w = &ee.e.encWriterSwitch
- e.b = &ee.b
- e.tw = ee.h.TermWhitespace
- e.c = 0
-}
-
-func (e *jsonEncDriverTypical) WriteArrayStart(length int) {
- e.w.writen1('[')
- e.c = containerArrayStart
-}
-
-func (e *jsonEncDriverTypical) WriteArrayElem() {
- if e.c != containerArrayStart {
- e.w.writen1(',')
- }
- e.c = containerArrayElem
-}
-
-func (e *jsonEncDriverTypical) WriteArrayEnd() {
- e.w.writen1(']')
- e.c = containerArrayEnd
-}
-
-func (e *jsonEncDriverTypical) WriteMapStart(length int) {
- e.w.writen1('{')
- e.c = containerMapStart
-}
-
-func (e *jsonEncDriverTypical) WriteMapElemKey() {
- if e.c != containerMapStart {
- e.w.writen1(',')
- }
- e.c = containerMapKey
-}
-
-func (e *jsonEncDriverTypical) WriteMapElemValue() {
- e.w.writen1(':')
- e.c = containerMapValue
-}
-
-func (e *jsonEncDriverTypical) WriteMapEnd() {
- e.w.writen1('}')
- e.c = containerMapEnd
-}
-
-func (e *jsonEncDriverTypical) EncodeBool(b bool) {
- if b {
- e.w.writeb(jsonLiterals[jsonLitTrue : jsonLitTrue+4])
- } 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(' ')
- }
-}
-
-// ----------------
-
-type jsonEncDriverGeneric struct {
- w encWriter // encWriter // *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
+ noBuiltInTypes
}
// indent is done as below:
@@ -224,227 +127,115 @@ type jsonEncDriverGeneric struct {
// - 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)
- }
- e.ks = h.MapKeyAsString
- e.is = h.IntegerAsString
-}
-
-func (e *jsonEncDriverGeneric) WriteArrayStart(length int) {
- if e.d {
- e.dl++
- }
- e.w.writen1('[')
- e.c = containerArrayStart
-}
-
-func (e *jsonEncDriverGeneric) WriteArrayElem() {
- if e.c != containerArrayStart {
- e.w.writen1(',')
- }
- if e.d {
- e.writeIndent()
- }
- e.c = containerArrayElem
-}
-
-func (e *jsonEncDriverGeneric) WriteArrayEnd() {
- if e.d {
- e.dl--
- if e.c != containerArrayStart {
- e.writeIndent()
- }
- }
- 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 *jsonEncDriverGeneric) WriteMapElemKey() {
- if e.c != containerMapStart {
- e.w.writen1(',')
- }
- if e.d {
- e.writeIndent()
- }
- e.c = containerMapKey
-}
-
-func (e *jsonEncDriverGeneric) WriteMapElemValue() {
- if e.d {
- e.w.writen2(':', ' ')
- } else {
- e.w.writen1(':')
- }
- e.c = containerMapValue
-}
-
-func (e *jsonEncDriverGeneric) WriteMapEnd() {
- if e.d {
- e.dl--
+func (e *jsonEncDriver) sendContainerState(c containerState) {
+ // determine whether to output separators
+ if c == containerMapKey {
if e.c != containerMapStart {
+ e.w.writen1(',')
+ }
+ if e.d {
e.writeIndent()
}
+ } else if c == containerMapValue {
+ if e.d {
+ e.w.writen2(':', ' ')
+ } else {
+ e.w.writen1(':')
+ }
+ } else if c == containerMapEnd {
+ if e.d {
+ e.dl--
+ if e.c != containerMapStart {
+ e.writeIndent()
+ }
+ }
+ e.w.writen1('}')
+ } else if c == containerArrayElem {
+ if e.c != containerArrayStart {
+ e.w.writen1(',')
+ }
+ if e.d {
+ e.writeIndent()
+ }
+ } else if c == containerArrayEnd {
+ if e.d {
+ e.dl--
+ if e.c != containerArrayStart {
+ e.writeIndent()
+ }
+ }
+ e.w.writen1(']')
}
- e.w.writen1('}')
- e.c = containerMapEnd
+ e.c = c
}
-func (e *jsonEncDriverGeneric) writeIndent() {
+func (e *jsonEncDriver) 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])
- } else {
- for x > jsonSpacesOrTabsLen {
- e.w.writeb(jsonSpaces[:])
- x -= jsonSpacesOrTabsLen
- }
- e.w.writeb(jsonSpaces[:x])
- }
-}
-
-func (e *jsonEncDriverGeneric) EncodeBool(b bool) {
- if e.ks && e.c == containerMapKey {
- if b {
- e.w.writeb(jsonLiterals[jsonLitTrueQ : jsonLitTrueQ+6])
+ if x := len(e.ds) * int(e.dl); x <= jsonSpacesOrTabsLen {
+ if e.dt {
+ e.w.writestr(jsonTabs[:x])
} else {
- e.w.writeb(jsonLiterals[jsonLitFalseQ : jsonLitFalseQ+7])
+ e.w.writestr(jsonSpaces[:x])
}
} else {
- if b {
- e.w.writeb(jsonLiterals[jsonLitTrue : jsonLitTrue+4])
- } else {
- e.w.writeb(jsonLiterals[jsonLitFalse : jsonLitFalse+5])
+ for i := uint16(0); i < e.dl; i++ {
+ e.w.writestr(e.ds)
}
}
}
-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))
- e.b[0] = '"'
- e.b[blen-1] = '"'
- } else {
- blen = len(strconv.AppendFloat(e.b[:0], f, fmt, prec, 64))
- }
- e.w.writeb(e.b[:blen])
+func (e *jsonEncDriver) EncodeNil() {
+ e.w.writeb(jsonLiterals[9:13]) // null
}
-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) {
- blen := 2 + len(strconv.AppendInt(e.b[1:1], v, 10))
- e.b[0] = '"'
- e.b[blen-1] = '"'
- e.w.writeb(e.b[:blen])
+func (e *jsonEncDriver) EncodeBool(b bool) {
+ if b {
+ e.w.writeb(jsonLiterals[0:4]) // true
+ } else {
+ e.w.writeb(jsonLiterals[4:9]) // false
+ }
+}
+
+func (e *jsonEncDriver) EncodeFloat32(f float32) {
+ e.encodeFloat(float64(f), 32)
+}
+
+func (e *jsonEncDriver) EncodeFloat64(f float64) {
+ // e.w.writestr(strconv.FormatFloat(f, 'E', -1, 64))
+ e.encodeFloat(f, 64)
+}
+
+func (e *jsonEncDriver) encodeFloat(f float64, numbits int) {
+ x := strconv.AppendFloat(e.b[:0], f, 'G', -1, numbits)
+ e.w.writeb(x)
+ if bytes.IndexByte(x, 'E') == -1 && bytes.IndexByte(x, '.') == -1 {
+ e.w.writen2('.', '0')
+ }
+}
+
+func (e *jsonEncDriver) EncodeInt(v int64) {
+ if x := e.h.IntegerAsString; x == 'A' || x == 'L' && (v > 1<<53 || v < -(1<<53)) {
+ e.w.writen1('"')
+ e.w.writeb(strconv.AppendInt(e.b[:0], v, 10))
+ e.w.writen1('"')
return
}
e.w.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) {
- blen := 2 + len(strconv.AppendUint(e.b[1:1], v, 10))
- e.b[0] = '"'
- e.b[blen-1] = '"'
- e.w.writeb(e.b[:blen])
+func (e *jsonEncDriver) EncodeUint(v uint64) {
+ if x := e.h.IntegerAsString; x == 'A' || x == 'L' && v > 1<<53 {
+ e.w.writen1('"')
+ e.w.writeb(strconv.AppendUint(e.b[:0], v, 10))
+ e.w.writen1('"')
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 encWriter // encWriter // *encWriterSwitch
- se extWrapper
- // ---- cpu cache line boundary?
- bs []byte // scratch
- // ---- cpu cache line boundary?
- b [jsonScratchArrayLen]byte // scratch (encode time,
-}
-
-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])
- // }
-}
-
-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()
+ e.w.writeb(jsonLiterals[9:13]) // null // e.EncodeNil()
} else {
en.encode(v)
}
@@ -453,61 +244,74 @@ func (e *jsonEncDriver) EncodeExt(rv interface{}, xtag uint64, ext Ext, en *Enco
func (e *jsonEncDriver) EncodeRawExt(re *RawExt, en *Encoder) {
// only encodes re.Value (never re.Data)
if re.Value == nil {
- e.EncodeNil()
+ e.w.writeb(jsonLiterals[9:13]) // null // e.EncodeNil()
} else {
en.encode(re.Value)
}
}
+func (e *jsonEncDriver) EncodeArrayStart(length int) {
+ if e.d {
+ e.dl++
+ }
+ e.w.writen1('[')
+ e.c = containerArrayStart
+}
+
+func (e *jsonEncDriver) EncodeMapStart(length int) {
+ if e.d {
+ e.dl++
+ }
+ e.w.writen1('{')
+ e.c = containerMapStart
+}
+
func (e *jsonEncDriver) EncodeString(c charEncoding, v string) {
+ // e.w.writestr(strconv.Quote(v))
+ e.quoteStr(v)
+}
+
+func (e *jsonEncDriver) EncodeSymbol(v string) {
+ // e.EncodeString(c_UTF8, v)
e.quoteStr(v)
}
func (e *jsonEncDriver) EncodeStringBytes(c charEncoding, v []byte) {
// if encoding raw bytes and RawBytesExt is configured, use it to encode
- if v == nil {
- e.EncodeNil()
+ if c == c_RAW && e.se.i != nil {
+ e.EncodeExt(v, 0, &e.se, e.e)
return
}
- if c == cRAW {
- if e.se.InterfaceExt != nil {
- e.EncodeExt(v, 0, &e.se, e.e)
- return
- }
-
+ if c == c_RAW {
slen := base64.StdEncoding.EncodedLen(len(v))
- if cap(e.bs) >= slen+2 {
- e.bs = e.bs[:slen+2]
+ if cap(e.bs) >= slen {
+ e.bs = e.bs[:slen]
} else {
- e.bs = make([]byte, slen+2)
+ e.bs = make([]byte, slen)
}
- e.bs[0] = '"'
- base64.StdEncoding.Encode(e.bs[1:], v)
- e.bs[slen+1] = '"'
- e.ew.writeb(e.bs)
+ base64.StdEncoding.Encode(e.bs, v)
+ e.w.writen1('"')
+ e.w.writeb(e.bs)
+ e.w.writen1('"')
} else {
+ // e.EncodeString(c, string(v))
e.quoteStr(stringView(v))
}
}
func (e *jsonEncDriver) EncodeAsis(v []byte) {
- e.ew.writeb(v)
+ e.w.writeb(v)
}
func (e *jsonEncDriver) quoteStr(s string) {
// adapted from std pkg encoding/json
const hex = "0123456789abcdef"
- w := e.ew
- htmlasis := e.h.HTMLCharsAsIs
+ w := e.w
w.writen1('"')
- var start int
- for i, slen := 0, len(s); i < slen; {
- // encode all bytes < 0x20 (except \r, \n).
- // also encode < > & to prevent security holes when served to some browsers.
+ start := 0
+ for i := 0; i < len(s); {
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)) {
+ if 0x20 <= b && b != '\\' && b != '"' && b != '<' && b != '>' && b != '&' {
i++
continue
}
@@ -528,6 +332,8 @@ func (e *jsonEncDriver) quoteStr(s string) {
case '\t':
w.writen2('\\', 't')
default:
+ // encode all bytes < 0x20 (except \r, \n).
+ // also encode < > & to prevent security holes when served to some browsers.
w.writestr(`\u00`)
w.writen2(hex[b>>4], hex[b&0xF])
}
@@ -546,7 +352,7 @@ func (e *jsonEncDriver) quoteStr(s string) {
continue
}
// U+2028 is LINE SEPARATOR. U+2029 is PARAGRAPH SEPARATOR.
- // Both technically valid JSON, but bomb on JSONP, so fix here unconditionally.
+ // Both technically valid JSON, but bomb on JSONP, so fix here.
if c == '\u2028' || c == '\u2029' {
if start < i {
w.writestr(s[start:i])
@@ -565,32 +371,123 @@ func (e *jsonEncDriver) quoteStr(s string) {
w.writen1('"')
}
+//--------------------------------
+
+type jsonNum struct {
+ // bytes []byte // may have [+-.eE0-9]
+ mantissa uint64 // where mantissa ends, and maybe dot begins.
+ exponent int16 // exponent value.
+ manOverflow bool
+ neg bool // started with -. No initial sign in the bytes above.
+ dot bool // has dot
+ explicitExponent bool // explicit exponent
+}
+
+func (x *jsonNum) reset() {
+ x.manOverflow = false
+ x.neg = false
+ x.dot = false
+ x.explicitExponent = false
+ x.mantissa = 0
+ x.exponent = 0
+}
+
+// uintExp is called only if exponent > 0.
+func (x *jsonNum) uintExp() (n uint64, overflow bool) {
+ n = x.mantissa
+ e := x.exponent
+ if e >= int16(len(jsonUint64Pow10)) {
+ overflow = true
+ return
+ }
+ n *= jsonUint64Pow10[e]
+ if n < x.mantissa || n > jsonNumUintMaxVal {
+ overflow = true
+ return
+ }
+ return
+ // for i := int16(0); i < e; i++ {
+ // if n >= jsonNumUintCutoff {
+ // overflow = true
+ // return
+ // }
+ // n *= 10
+ // }
+ // return
+}
+
+// these constants are only used withn floatVal.
+// They are brought out, so that floatVal can be inlined.
+const (
+ jsonUint64MantissaBits = 52
+ jsonMaxExponent = int16(len(jsonFloat64Pow10)) - 1
+)
+
+func (x *jsonNum) floatVal() (f float64, parseUsingStrConv bool) {
+ // We do not want to lose precision.
+ // Consequently, we will delegate to strconv.ParseFloat if any of the following happen:
+ // - There are more digits than in math.MaxUint64: 18446744073709551615 (20 digits)
+ // We expect up to 99.... (19 digits)
+ // - The mantissa cannot fit into a 52 bits of uint64
+ // - The exponent is beyond our scope ie beyong 22.
+ parseUsingStrConv = x.manOverflow ||
+ x.exponent > jsonMaxExponent ||
+ (x.exponent < 0 && -(x.exponent) > jsonMaxExponent) ||
+ x.mantissa>>jsonUint64MantissaBits != 0
+
+ if parseUsingStrConv {
+ return
+ }
+
+ // all good. so handle parse here.
+ f = float64(x.mantissa)
+ // fmt.Printf(".Float: uint64 value: %v, float: %v\n", m, f)
+ if x.neg {
+ f = -f
+ }
+ if x.exponent > 0 {
+ f *= jsonFloat64Pow10[x.exponent]
+ } else if x.exponent < 0 {
+ f /= jsonFloat64Pow10[-x.exponent]
+ }
+ return
+}
+
type jsonDecDriver struct {
noBuiltInTypes
- d *Decoder
- h *JsonHandle
- r decReader // *decReaderSwitch // decReader
- se extWrapper
-
- // ---- writable fields during execution --- *try* to keep in sep cache line
+ d *Decoder
+ h *JsonHandle
+ r decReader
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
- // ---- 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
+ tok uint8
- _ [3]uint64 // padding
- // n jsonNum
+ bstr [8]byte // scratch used for string \UXXX parsing
+ b [64]byte // scratch, used for parsing strings or numbers
+ b2 [64]byte // scratch, used only for decodeBytes (after base64)
+ bs []byte // scratch. Initialized from b. Used for parsing strings or numbers.
+
+ se setExtWrapper
+
+ n jsonNum
}
-// func jsonIsWS(b byte) bool {
-// // return b == ' ' || b == '\t' || b == '\r' || b == '\n'
-// return jsonCharWhitespaceSet.isset(b)
+func jsonIsWS(b byte) bool {
+ return b == ' ' || b == '\t' || b == '\r' || b == '\n'
+}
+
+// // This will skip whitespace characters and return the next byte to read.
+// // The next byte determines what the value will be one of.
+// func (d *jsonDecDriver) skipWhitespace() {
+// // fast-path: do not enter loop. Just check first (in case no whitespace).
+// b := d.r.readn1()
+// if jsonIsWS(b) {
+// r := d.r
+// for b = r.readn1(); jsonIsWS(b); b = r.readn1() {
+// }
+// }
+// d.tok = b
// }
func (d *jsonDecDriver) uncacheRead() {
@@ -600,13 +497,110 @@ func (d *jsonDecDriver) uncacheRead() {
}
}
+func (d *jsonDecDriver) sendContainerState(c containerState) {
+ if d.tok == 0 {
+ var b byte
+ r := d.r
+ for b = r.readn1(); jsonIsWS(b); b = r.readn1() {
+ }
+ d.tok = b
+ }
+ var xc uint8 // char expected
+ if c == containerMapKey {
+ if d.c != containerMapStart {
+ xc = ','
+ }
+ } else if c == containerMapValue {
+ xc = ':'
+ } else if c == containerMapEnd {
+ xc = '}'
+ } else if c == containerArrayElem {
+ if d.c != containerArrayStart {
+ xc = ','
+ }
+ } else if c == containerArrayEnd {
+ xc = ']'
+ }
+ if xc != 0 {
+ if d.tok != xc {
+ d.d.errorf("json: expect char '%c' but got char '%c'", xc, d.tok)
+ }
+ d.tok = 0
+ }
+ d.c = c
+}
+
+func (d *jsonDecDriver) CheckBreak() bool {
+ if d.tok == 0 {
+ var b byte
+ r := d.r
+ for b = r.readn1(); jsonIsWS(b); b = r.readn1() {
+ }
+ d.tok = b
+ }
+ if d.tok == '}' || d.tok == ']' {
+ // d.tok = 0 // only checking, not consuming
+ return true
+ }
+ return false
+}
+
+func (d *jsonDecDriver) readStrIdx(fromIdx, toIdx uint8) {
+ bs := d.r.readx(int(toIdx - fromIdx))
+ d.tok = 0
+ if jsonValidateSymbols {
+ if !bytes.Equal(bs, jsonLiterals[fromIdx:toIdx]) {
+ d.d.errorf("json: expecting %s: got %s", jsonLiterals[fromIdx:toIdx], bs)
+ return
+ }
+ }
+}
+
+func (d *jsonDecDriver) TryDecodeAsNil() bool {
+ if d.tok == 0 {
+ var b byte
+ r := d.r
+ for b = r.readn1(); jsonIsWS(b); b = r.readn1() {
+ }
+ d.tok = b
+ }
+ if d.tok == 'n' {
+ d.readStrIdx(10, 13) // ull
+ return true
+ }
+ return false
+}
+
+func (d *jsonDecDriver) DecodeBool() bool {
+ if d.tok == 0 {
+ var b byte
+ r := d.r
+ for b = r.readn1(); jsonIsWS(b); b = r.readn1() {
+ }
+ d.tok = b
+ }
+ if d.tok == 'f' {
+ d.readStrIdx(5, 9) // alse
+ return false
+ }
+ if d.tok == 't' {
+ d.readStrIdx(1, 4) // rue
+ return true
+ }
+ d.d.errorf("json: decode bool: got first char %c", d.tok)
+ return false // "unreachable"
+}
+
func (d *jsonDecDriver) ReadMapStart() int {
if d.tok == 0 {
- d.tok = d.r.skip(&jsonCharWhitespaceSet)
+ var b byte
+ r := d.r
+ for b = r.readn1(); jsonIsWS(b); b = r.readn1() {
+ }
+ d.tok = b
}
- 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("json: expect char '%c' but got char '%c'", '{', d.tok)
}
d.tok = 0
d.c = containerMapStart
@@ -615,169 +609,29 @@ func (d *jsonDecDriver) ReadMapStart() int {
func (d *jsonDecDriver) ReadArrayStart() int {
if d.tok == 0 {
- d.tok = d.r.skip(&jsonCharWhitespaceSet)
+ var b byte
+ r := d.r
+ for b = r.readn1(); jsonIsWS(b); b = r.readn1() {
+ }
+ d.tok = b
}
- 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("json: expect char '%c' but got char '%c'", '[', d.tok)
}
d.tok = 0
d.c = containerArrayStart
return -1
}
-func (d *jsonDecDriver) CheckBreak() bool {
- if d.tok == 0 {
- d.tok = d.r.skip(&jsonCharWhitespaceSet)
- }
- 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.tok != xc {
- d.d.errorf("read array element - expect char '%c' but got char '%c'", xc, d.tok)
- }
- d.tok = 0
- }
- d.c = containerArrayElem
-}
-
-func (d *jsonDecDriver) ReadArrayEnd() {
- const xc uint8 = ']'
- if d.tok == 0 {
- d.tok = d.r.skip(&jsonCharWhitespaceSet)
- }
- if d.tok != xc {
- d.d.errorf("read array end - expect char '%c' but got char '%c'", xc, d.tok)
- }
- 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.tok != xc {
- d.d.errorf("read map key - expect char '%c' but got char '%c'", xc, d.tok)
- }
- d.tok = 0
- }
- d.c = containerMapKey
-}
-
-func (d *jsonDecDriver) ReadMapElemValue() {
- const xc uint8 = ':'
- if d.tok == 0 {
- d.tok = d.r.skip(&jsonCharWhitespaceSet)
- }
- if d.tok != xc {
- d.d.errorf("read map value - expect char '%c' but got char '%c'", xc, d.tok)
- }
- d.tok = 0
- d.c = containerMapValue
-}
-
-func (d *jsonDecDriver) ReadMapEnd() {
- const xc uint8 = '}'
- if d.tok == 0 {
- d.tok = d.r.skip(&jsonCharWhitespaceSet)
- }
- if d.tok != xc {
- d.d.errorf("read map end - expect char '%c' but got char '%c'", xc, d.tok)
- }
- d.tok = 0
- d.c = containerMapEnd
-}
-
-func (d *jsonDecDriver) readLit(length, fromIdx uint8) {
- 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)
- return
- }
-}
-
-func (d *jsonDecDriver) TryDecodeAsNil() bool {
- if d.tok == 0 {
- d.tok = d.r.skip(&jsonCharWhitespaceSet)
- }
- // we shouldn't try to see if "null" was here, right?
- // only the plain string: `null` denotes a nil (ie not quotes)
- if d.tok == 'n' {
- d.readLit(3, jsonLitNull+1) // (n)ull
- return true
- }
- return false
-}
-
-func (d *jsonDecDriver) DecodeBool() (v bool) {
- if d.tok == 0 {
- d.tok = d.r.skip(&jsonCharWhitespaceSet)
- }
- fquot := d.c == containerMapKey && d.tok == '"'
- if fquot {
- d.tok = d.r.readn1()
- }
- switch d.tok {
- case 'f':
- d.readLit(4, jsonLitFalse+1) // (f)alse
- // v = false
- case 't':
- d.readLit(3, jsonLitTrue+1) // (t)rue
- v = true
- default:
- d.d.errorf("decode bool: got first char %c", d.tok)
- // v = false // "unreachable"
- }
- if fquot {
- d.r.readn1()
- }
- return
-}
-
-func (d *jsonDecDriver) DecodeTime() (t time.Time) {
- // read string, and pass the string into json.unmarshal
- d.appendStringAsBytes()
- if d.fnull {
- return
- }
- t, err := time.Parse(time.RFC3339, stringView(d.bs))
- if err != nil {
- d.d.errorv(err)
- }
- return
-}
-
func (d *jsonDecDriver) ContainerType() (vt valueType) {
// check container type by checking the first char
if d.tok == 0 {
- d.tok = d.r.skip(&jsonCharWhitespaceSet)
+ var b byte
+ r := d.r
+ for b = r.readn1(); jsonIsWS(b); b = r.readn1() {
+ }
+ d.tok = b
}
-
- // 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 == '{' {
return valueTypeMap
} else if b == '[' {
@@ -788,87 +642,265 @@ func (d *jsonDecDriver) ContainerType() (vt valueType) {
return valueTypeString
}
return valueTypeUnset
+ // d.d.errorf("isContainerType: unsupported parameter: %v", vt)
+ // return false // "unreachable"
}
-func (d *jsonDecDriver) decNumBytes() (bs []byte) {
- // stores num bytes in d.bs
+func (d *jsonDecDriver) decNum(storeBytes bool) {
+ // If it is has a . or an e|E, decode as a float; else decode as an int.
if d.tok == 0 {
- d.tok = d.r.skip(&jsonCharWhitespaceSet)
+ var b byte
+ r := d.r
+ for b = r.readn1(); jsonIsWS(b); b = r.readn1() {
+ }
+ d.tok = b
}
- if d.tok == '"' {
- bs = d.r.readUntil(d.b2[:0], '"')
- bs = bs[:len(bs)-1]
- } else {
- d.r.unreadn1()
- bs = d.r.readTo(d.bs[:0], &jsonNumSet)
+ b := d.tok
+ var str bool
+ if b == '"' {
+ str = true
+ b = d.r.readn1()
+ }
+ if !(b == '+' || b == '-' || b == '.' || (b >= '0' && b <= '9')) {
+ d.d.errorf("json: decNum: got first char '%c'", b)
+ return
}
d.tok = 0
- return bs
-}
-func (d *jsonDecDriver) DecodeUint64() (u uint64) {
- bs := d.decNumBytes()
- n, neg, badsyntax, overflow := jsonParseInteger(bs)
- if overflow {
- d.d.errorf("overflow parsing unsigned integer: %s", bs)
- } else if neg {
- 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))
+ const cutoff = (1<<64-1)/uint64(10) + 1 // cutoff64(base)
+ const jsonNumUintMaxVal = 1<= jsonNumUintCutoff {
+ n.manOverflow = true
+ break
+ }
+ v := uint64(b - '0')
+ n.mantissa *= 10
+ if v != 0 {
+ n1 := n.mantissa + v
+ if n1 < n.mantissa || n1 > jsonNumUintMaxVal {
+ n.manOverflow = true // n+v overflows
+ break
+ }
+ n.mantissa = n1
+ }
+ case 6:
+ state = 7
+ fallthrough
+ case 7:
+ if !(b == '0' && e == 0) {
+ e = e*10 + int16(b-'0')
+ }
+ default:
+ break LOOP
+ }
+ case '"':
+ if str {
+ if storeBytes {
+ d.bs = append(d.bs, '"')
+ }
+ b, eof = r.readn1eof()
+ }
+ break LOOP
+ default:
+ break LOOP
+ }
+ if storeBytes {
+ d.bs = append(d.bs, b)
+ }
+ b, eof = r.readn1eof()
+ }
+
+ if jsonTruncateMantissa && n.mantissa != 0 {
+ for n.mantissa%10 == 0 {
+ n.mantissa /= 10
+ n.exponent++
+ }
+ }
+
+ if e != 0 {
+ if eNeg {
+ n.exponent -= e
} else {
- n = d.decUint64ViaFloat(stringView(bs))
+ n.exponent += e
}
}
- if neg {
- if n > cutoff {
- d.d.errorf("overflow parsing integer: %s", bs)
+
+ // d.n = n
+
+ if !eof {
+ if jsonUnreadAfterDecNum {
+ r.unreadn1()
+ } else {
+ if !jsonIsWS(b) {
+ d.tok = b
+ }
}
- i = -(int64(n))
- } else {
- if n >= cutoff {
- d.d.errorf("overflow parsing integer: %s", bs)
+ }
+ // fmt.Printf("1: n: bytes: %s, neg: %v, dot: %v, exponent: %v, mantissaEndIndex: %v\n",
+ // n.bytes, n.neg, n.dot, n.exponent, n.mantissaEndIndex)
+ return
+}
+
+func (d *jsonDecDriver) DecodeInt(bitsize uint8) (i int64) {
+ d.decNum(false)
+ n := &d.n
+ if n.manOverflow {
+ d.d.errorf("json: overflow integer after: %v", n.mantissa)
+ return
+ }
+ var u uint64
+ if n.exponent == 0 {
+ u = n.mantissa
+ } else if n.exponent < 0 {
+ d.d.errorf("json: fractional integer")
+ return
+ } else if n.exponent > 0 {
+ var overflow bool
+ if u, overflow = n.uintExp(); overflow {
+ d.d.errorf("json: overflow integer")
+ return
+ }
+ }
+ i = int64(u)
+ if n.neg {
+ i = -i
+ }
+ if chkOvf.Int(i, bitsize) {
+ d.d.errorf("json: overflow %v bits: %s", bitsize, d.bs)
+ return
+ }
+ // fmt.Printf("DecodeInt: %v\n", i)
+ return
+}
+
+// floatVal MUST only be called after a decNum, as d.bs now contains the bytes of the number
+func (d *jsonDecDriver) floatVal() (f float64) {
+ f, useStrConv := d.n.floatVal()
+ if useStrConv {
+ var err error
+ if f, err = strconv.ParseFloat(stringView(d.bs), 64); err != nil {
+ panic(fmt.Errorf("parse float: %s, %v", d.bs, err))
+ }
+ if d.n.neg {
+ f = -f
}
- i = int64(n)
}
return
}
-func (d *jsonDecDriver) decUint64ViaFloat(s string) (u uint64) {
- f, err := strconv.ParseFloat(s, 64)
- if err != nil {
- d.d.errorf("invalid syntax for integer: %s", s)
- // d.d.errorv(err)
+func (d *jsonDecDriver) DecodeUint(bitsize uint8) (u uint64) {
+ d.decNum(false)
+ n := &d.n
+ if n.neg {
+ d.d.errorf("json: unsigned integer cannot be negative")
+ return
}
- fi, ff := math.Modf(f)
- if ff > 0 {
- d.d.errorf("fractional part found parsing integer: %s", s)
- } else if fi > float64(math.MaxUint64) {
- d.d.errorf("overflow parsing integer: %s", s)
+ if n.manOverflow {
+ d.d.errorf("json: overflow integer after: %v", n.mantissa)
+ return
}
- return uint64(fi)
+ if n.exponent == 0 {
+ u = n.mantissa
+ } else if n.exponent < 0 {
+ d.d.errorf("json: fractional integer")
+ return
+ } else if n.exponent > 0 {
+ var overflow bool
+ if u, overflow = n.uintExp(); overflow {
+ d.d.errorf("json: overflow integer")
+ return
+ }
+ }
+ if chkOvf.Uint(u, bitsize) {
+ d.d.errorf("json: overflow %v bits: %s", bitsize, d.bs)
+ return
+ }
+ // fmt.Printf("DecodeUint: %v\n", u)
+ return
}
-func (d *jsonDecDriver) DecodeFloat64() (f float64) {
- bs := d.decNumBytes()
- f, err := strconv.ParseFloat(stringView(bs), 64)
- if err != nil {
- d.d.errorv(err)
+func (d *jsonDecDriver) DecodeFloat(chkOverflow32 bool) (f float64) {
+ d.decNum(true)
+ f = d.floatVal()
+ if chkOverflow32 && chkOvf.Float32(f) {
+ d.d.errorf("json: overflow float32: %v, %s", f, d.bs)
+ return
}
return
}
@@ -886,31 +918,23 @@ func (d *jsonDecDriver) DecodeExt(rv interface{}, xtag uint64, ext Ext) (realxta
return
}
-func (d *jsonDecDriver) DecodeBytes(bs []byte, zerocopy bool) (bsOut []byte) {
+func (d *jsonDecDriver) DecodeBytes(bs []byte, isstring, zerocopy bool) (bsOut []byte) {
// if decoding into raw bytes, and the RawBytesExt is configured, use it to decode.
- if d.se.InterfaceExt != nil {
+ if !isstring && d.se.i != nil {
bsOut = bs
d.DecodeExt(&bsOut, 0, &d.se)
return
}
- if d.tok == 0 {
- d.tok = d.r.skip(&jsonCharWhitespaceSet)
- }
- // 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
- }
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 isstring, then just return the bytes, even if it is using the scratch buffer.
+ // the bytes will be converted to a string as needed.
+ if isstring {
+ return d.bs
+ }
+ // if appendStringAsBytes returned a zero-len slice, then treat as nil.
+ // This should only happen for null, and "".
if len(d.bs) == 0 {
- if d.fnull {
- return nil
- }
- return []byte{}
+ return nil
}
bs0 := d.bs
slen := base64.StdEncoding.DecodedLen(len(bs0))
@@ -923,7 +947,7 @@ func (d *jsonDecDriver) DecodeBytes(bs []byte, zerocopy bool) (bsOut []byte) {
}
slen2, err := base64.StdEncoding.Decode(bsOut, bs0)
if err != nil {
- d.d.errorf("error decoding base64 binary '%s': %v", bs0, err)
+ d.d.errorf("json: error decoding base64 binary '%s': %v", bs0, err)
return nil
}
if slen != slen2 {
@@ -934,256 +958,172 @@ func (d *jsonDecDriver) DecodeBytes(bs []byte, zerocopy bool) (bsOut []byte) {
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
- 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.readLit(3, jsonLitNull+1) // (n)ull
- d.bs = d.bs[:0]
- d.fnull = true
- case 'f':
- d.readLit(4, jsonLitFalse+1) // (f)alse
- d.bs = d.bs[:5]
- copy(d.bs, "false")
- case 't':
- d.readLit(3, jsonLitTrue+1) // (t)rue
- 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
- }
-
- d.tok = 0
- r := d.r
- var cs = r.readUntil(d.b2[:0], '"')
- var cslen = len(cs)
- var c uint8
- v := d.bs[: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
- for i, cursor := 0, 0; ; {
- if i == cslen {
- v = append(v, cs[cursor:]...)
- cs = r.readUntil(d.b2[:0], '"')
- cslen = len(cs)
- i, cursor = 0, 0
- }
- c = cs[i]
- if c == '"' {
- v = append(v, cs[cursor:i]...)
- break
- }
- if c != '\\' {
- i++
- continue
- }
- v = append(v, cs[cursor:i]...)
- i++
- c = cs[i]
- switch c {
- case '"', '\\', '/', '\'':
- v = append(v, c)
- case 'b':
- v = append(v, '\b')
- case 'f':
- v = append(v, '\f')
- case 'n':
- v = append(v, '\n')
- case 'r':
- v = append(v, '\r')
- case 't':
- v = append(v, '\t')
- case 'u':
- var r rune
- var rr uint32
- if len(cs) < i+4 { // may help reduce bounds-checking
- d.d.errorf("need at least 4 more bytes for unicode sequence")
- }
- // c = cs[i+4] // may help reduce bounds-checking
- for j := 1; j < 5; j++ {
- // best to use explicit if-else
- // - not a table, etc which involve memory loads, array lookup with bounds checks, etc
- c = cs[i+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 = rune(rr)
- i += 4
- if utf16.IsSurrogate(r) {
- if len(cs) >= i+6 && cs[i+2] == 'u' && cs[i+1] == '\\' {
- i += 2
- // c = cs[i+4] // may help reduce bounds-checking
- var rr1 uint32
- for j := 1; j < 5; j++ {
- c = cs[i+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))
- i += 4
- } else {
- r = unicode.ReplacementChar
- 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
- }
- d.bs = v
-}
-
-func (d *jsonDecDriver) nakedNum(z *decNaked, bs []byte) (err error) {
- const cutoff = uint64(1 << uint(64-1))
- var n uint64
- var neg, badsyntax, overflow bool
-
- if d.h.PreferFloat {
- goto F
- }
- n, neg, badsyntax, overflow = jsonParseInteger(bs)
- if badsyntax || overflow {
- goto F
- }
- if neg {
- if n > cutoff {
- goto F
- }
- z.v = valueTypeInt
- z.i = -(int64(n))
- } else if d.h.SignedInteger {
- if n >= cutoff {
- goto F
- }
- z.v = valueTypeInt
- z.i = int64(n)
- } else {
- z.v = valueTypeUint
- z.u = n
- }
- return
-F:
- z.v = valueTypeFloat
- z.f, err = strconv.ParseFloat(stringView(bs), 64)
- return
-}
-
-func (d *jsonDecDriver) bsToString() string {
// if x := d.s.sc; x != nil && x.so && x.st == '}' { // map key
- if jsonAlwaysReturnInternString || d.c == containerMapKey {
+ if d.c == containerMapKey {
return d.d.string(d.bs)
}
return string(d.bs)
}
+func (d *jsonDecDriver) appendStringAsBytes() {
+ if d.tok == 0 {
+ var b byte
+ r := d.r
+ for b = r.readn1(); jsonIsWS(b); b = r.readn1() {
+ }
+ d.tok = b
+ }
+
+ // handle null as a string
+ if d.tok == 'n' {
+ d.readStrIdx(10, 13) // ull
+ d.bs = d.bs[:0]
+ return
+ }
+
+ if d.tok != '"' {
+ d.d.errorf("json: expect char '%c' but got char '%c'", '"', d.tok)
+ }
+ d.tok = 0
+
+ v := d.bs[:0]
+ var c uint8
+ r := d.r
+ for {
+ c = r.readn1()
+ if c == '"' {
+ break
+ } else if c == '\\' {
+ c = r.readn1()
+ switch c {
+ case '"', '\\', '/', '\'':
+ v = append(v, c)
+ case 'b':
+ v = append(v, '\b')
+ case 'f':
+ v = append(v, '\f')
+ case 'n':
+ v = append(v, '\n')
+ case 'r':
+ v = append(v, '\r')
+ case 't':
+ v = append(v, '\t')
+ case 'u':
+ rr := d.jsonU4(false)
+ // fmt.Printf("$$$$$$$$$: is surrogate: %v\n", utf16.IsSurrogate(rr))
+ if utf16.IsSurrogate(rr) {
+ rr = utf16.DecodeRune(rr, d.jsonU4(true))
+ }
+ w2 := utf8.EncodeRune(d.bstr[:], rr)
+ v = append(v, d.bstr[:w2]...)
+ default:
+ d.d.errorf("json: unsupported escaped value: %c", c)
+ }
+ } else {
+ v = append(v, c)
+ }
+ }
+ d.bs = v
+}
+
+func (d *jsonDecDriver) jsonU4(checkSlashU bool) rune {
+ r := d.r
+ if checkSlashU && !(r.readn1() == '\\' && r.readn1() == 'u') {
+ d.d.errorf(`json: unquoteStr: invalid unicode sequence. Expecting \u`)
+ return 0
+ }
+ // u, _ := strconv.ParseUint(string(d.bstr[:4]), 16, 64)
+ var u uint32
+ for i := 0; i < 4; i++ {
+ v := r.readn1()
+ if '0' <= v && v <= '9' {
+ v = v - '0'
+ } else if 'a' <= v && v <= 'z' {
+ v = v - 'a' + 10
+ } else if 'A' <= v && v <= 'Z' {
+ v = v - 'A' + 10
+ } else {
+ d.d.errorf(`json: unquoteStr: invalid hex char in \u unicode sequence: %q`, v)
+ return 0
+ }
+ u = u*16 + uint32(v)
+ }
+ return rune(u)
+}
+
func (d *jsonDecDriver) DecodeNaked() {
- z := d.d.n
+ z := &d.d.n
// var decodeFurther bool
if d.tok == 0 {
- d.tok = d.r.skip(&jsonCharWhitespaceSet)
+ var b byte
+ r := d.r
+ for b = r.readn1(); jsonIsWS(b); b = r.readn1() {
+ }
+ d.tok = b
}
switch d.tok {
case 'n':
- d.readLit(3, jsonLitNull+1) // (n)ull
+ d.readStrIdx(10, 13) // ull
z.v = valueTypeNil
case 'f':
- d.readLit(4, jsonLitFalse+1) // (f)alse
+ d.readStrIdx(5, 9) // alse
z.v = valueTypeBool
z.b = false
case 't':
- d.readLit(3, jsonLitTrue+1) // (t)rue
+ d.readStrIdx(1, 4) // rue
z.v = valueTypeBool
z.b = true
case '{':
- z.v = valueTypeMap // don't consume. kInterfaceNaked will call ReadMapStart
+ z.v = valueTypeMap
+ // d.tok = 0 // don't consume. kInterfaceNaked will call ReadMapStart
+ // decodeFurther = true
case '[':
- z.v = valueTypeArray // don't consume. kInterfaceNaked will call ReadArrayStart
+ z.v = valueTypeArray
+ // d.tok = 0 // don't consume. kInterfaceNaked will call ReadArrayStart
+ // decodeFurther = true
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":
- z.v = valueTypeNil
- case "true":
- z.v = valueTypeBool
- z.b = true
- case "false":
- z.v = valueTypeBool
- z.b = false
- default:
- // check if a number: float, int or uint
- if err := d.nakedNum(z, d.bs); err != nil {
- z.v = valueTypeString
- z.s = d.bsToString()
- }
- }
- } else {
- z.v = valueTypeString
- z.s = d.bsToString()
- }
+ z.v = valueTypeString
+ z.s = d.DecodeString()
default: // number
- bs := d.decNumBytes()
- if len(bs) == 0 {
- d.d.errorf("decode number from empty string")
- return
- }
- if err := d.nakedNum(z, bs); err != nil {
- d.d.errorf("decode number from %s: %v", bs, err)
- return
+ d.decNum(true)
+ n := &d.n
+ // if the string had a any of [.eE], then decode as float.
+ switch {
+ case n.explicitExponent, n.dot, n.exponent < 0, n.manOverflow:
+ z.v = valueTypeFloat
+ z.f = d.floatVal()
+ case n.exponent == 0:
+ u := n.mantissa
+ switch {
+ case n.neg:
+ z.v = valueTypeInt
+ z.i = -int64(u)
+ case d.h.SignedInteger:
+ z.v = valueTypeInt
+ z.i = int64(u)
+ default:
+ z.v = valueTypeUint
+ z.u = u
+ }
+ default:
+ u, overflow := n.uintExp()
+ switch {
+ case overflow:
+ z.v = valueTypeFloat
+ z.f = d.floatVal()
+ case n.neg:
+ z.v = valueTypeInt
+ z.i = -int64(u)
+ case d.h.SignedInteger:
+ z.v = valueTypeInt
+ z.i = int64(u)
+ default:
+ z.v = valueTypeUint
+ z.u = u
+ }
}
+ // fmt.Printf("DecodeNaked: Number: %T, %v\n", v, v)
}
// if decodeFurther {
// d.s.sc.retryRead()
@@ -1197,26 +1137,24 @@ func (d *jsonDecDriver) DecodeNaked() {
//
// Json is comprehensively supported:
// - decodes numbers into interface{} as int, uint or float64
-// based on how the number looks and some config parameters e.g. PreferFloat, SignedInt, etc.
-// - decode integers from float formatted numbers e.g. 1.27e+8
-// - decode any json value (numbers, bool, etc) from quoted strings
// - configurable way to encode/decode []byte .
// by default, encodes and decodes []byte using base64 Std Encoding
// - UTF-8 support for encoding and decoding
//
// It has better performance than the json library in the standard library,
-// by leveraging the performance improvements of the codec library.
+// by leveraging the performance improvements of the codec library and
+// minimizing allocations.
//
// In addition, it doesn't read more bytes than necessary during a decode, which allows
// reading multiple values from a stream containing json and non-json content.
// For example, a user can read a json value, then a cbor value, then a msgpack value,
// all from the same stream in sequence.
-//
-// Note that, when decoding quoted strings, invalid UTF-8 or invalid UTF-16 surrogate pairs are
-// not treated as an error. Instead, they are replaced by the Unicode replacement character U+FFFD.
type JsonHandle struct {
textEncodingType
BasicHandle
+ // 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
// Indent indicates how a value is encoded.
// - If positive, indent by that number of spaces.
@@ -1234,190 +1172,63 @@ type JsonHandle struct {
// - if 'A', then encode all integers as a json string
// containing the exact integer representation as a decimal.
// - else encode all integers as a json number (default)
- IntegerAsString byte
-
- // HTMLCharsAsIs controls how to encode some special characters to html: < > &
- //
- // By default, we encode them as \uXXX
- // to prevent security holes when served from some browsers.
- HTMLCharsAsIs bool
-
- // PreferFloat says that we will default to decoding a number as a float.
- // If not set, we will examine the characters of the number and decode as an
- // integer type if it doesn't have any of the characters [.eE].
- PreferFloat bool
-
- // TermWhitespace says that we add a whitespace character
- // at the end of an encoding.
- //
- // The whitespace is important, especially if using numbers in a context
- // where multiple items are written to a stream.
- TermWhitespace bool
-
- // MapKeyAsString says to encode all map keys as strings.
- //
- // Use this to enforce strict json output.
- // The only caveat is that nil value is ALWAYS written as null (never as "null")
- MapKeyAsString bool
-
- // _ [2]byte // padding
-
- // Note: below, we store hardly-used items e.g. RawBytesExt is 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
+ IntegerAsString uint8
}
-// 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) 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})
+ return h.SetExt(rt, tag, &setExtWrapper{i: ext})
}
-type jsonEncDriverTypicalImpl struct {
- jsonEncDriver
- jsonEncDriverTypical
- _ [1]uint64 // padding
-}
+func (h *JsonHandle) newEncDriver(e *Encoder) encDriver {
+ hd := jsonEncDriver{e: e, h: h}
+ hd.bs = hd.b[:0]
-func (x *jsonEncDriverTypicalImpl) reset() {
- x.jsonEncDriver.reset()
- x.jsonEncDriverTypical.reset(&x.jsonEncDriver)
-}
+ hd.reset()
-type jsonEncDriverGenericImpl struct {
- jsonEncDriver
- jsonEncDriverGeneric
-}
-
-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
- } else {
- var v jsonEncDriverGenericImpl
- ee = &v
- hd = &v.jsonEncDriver
- }
- hd.e, hd.h, hd.bs = e, h, hd.b[:0]
- hd.se.BytesExt = bytesExtFailer{}
- ee.reset()
- return
+ return &hd
}
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.e.w // &e.e.encWriterSwitch
- e.se.InterfaceExt = e.h.RawBytesExt
+ e.w = e.e.w
+ e.se.i = e.h.RawBytesExt
if e.bs != nil {
e.bs = e.bs[:0]
}
+ e.d, e.dt, e.dl, e.ds = false, false, 0, ""
+ e.c = 0
+ if e.h.Indent > 0 {
+ e.d = true
+ e.ds = jsonSpaces[:e.h.Indent]
+ } else if e.h.Indent < 0 {
+ e.d = true
+ e.dt = true
+ e.ds = jsonTabs[:-(e.h.Indent)]
+ }
}
func (d *jsonDecDriver) reset() {
- d.r = d.d.r // &d.d.decReaderSwitch // d.d.r
- d.se.InterfaceExt = d.h.RawBytesExt
+ d.r = d.d.r
+ d.se.i = d.h.RawBytesExt
if d.bs != nil {
d.bs = d.bs[:0]
}
d.c, d.tok = 0, 0
- // d.n.reset()
+ d.n.reset()
}
-func jsonFloatStrconvFmtPrec(f float64) (fmt byte, prec int) {
- prec = -1
- var abs = math.Abs(f)
- if abs != 0 && (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
- }
- }
- return
-}
+var jsonEncodeTerminate = []byte{' '}
-// custom-fitted version of strconv.Parse(Ui|I)nt.
-// Also ensures we don't have to search for .eE to determine if a float or not.
-func jsonParseInteger(s []byte) (n uint64, neg, badSyntax, overflow bool) {
- const maxUint64 = (1<<64 - 1)
- const cutoff = maxUint64/10 + 1
-
- if len(s) == 0 {
- badSyntax = true
- return
- }
- switch s[0] {
- case '+':
- s = s[1:]
- case '-':
- s = s[1:]
- neg = true
- }
- for _, c := range s {
- if c < '0' || c > '9' {
- badSyntax = true
- return
- }
- // unsigned integers don't overflow well on multiplication, so check cutoff here
- // e.g. (maxUint64-5)*10 doesn't overflow well ...
- if n >= cutoff {
- overflow = true
- return
- }
- n *= 10
- n1 := n + uint64(c-'0')
- if n1 < n || n1 > maxUint64 {
- overflow = true
- return
- }
- n = n1
- }
- return
+func (h *JsonHandle) rpcEncodeTerminate() []byte {
+ return jsonEncodeTerminate
}
var _ decDriver = (*jsonDecDriver)(nil)
-var _ encDriver = (*jsonEncDriverGenericImpl)(nil)
-var _ encDriver = (*jsonEncDriverTypicalImpl)(nil)
-var _ jsonTypical = (*jsonEncDriverTypical)(nil)
+var _ encDriver = (*jsonEncDriver)(nil)
diff --git a/vendor/github.com/ugorji/go/codec/mammoth-test.go.tmpl b/vendor/github.com/ugorji/go/codec/mammoth-test.go.tmpl
deleted file mode 100644
index 90d758ce42..0000000000
--- a/vendor/github.com/ugorji/go/codec/mammoth-test.go.tmpl
+++ /dev/null
@@ -1,154 +0,0 @@
-// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved.
-// Use of this source code is governed by a MIT license found in the LICENSE file.
-
-// Code generated from mammoth-test.go.tmpl - DO NOT EDIT.
-
-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.
-//
-// For each of those types, it has a pointer and a non-pointer field.
-
-func init() { _ = fmt.Printf } // so we can include fmt as needed
-
-type TestMammoth struct {
-
-{{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 }}
-{{ .MethodNamePfx "Fptr" false }} *[]{{ .Elem }}
-{{end}}{{end}}{{end}}
-
-{{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 }}
-func (_ {{ .MethodNamePfx "typMbs" false }}) MapBySlice() { }
-{{end}}{{end}}{{end}}
-
-{{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 }}{{/*
-*/}}
- var v{{$i}}va [8]{{ .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
- // - check if equal to initial slice
- // - encode ptr to the value
- // - check if encode bytes are same
- // - decode into ptrs to: nil, then 1-elem slice, equal-length, then large len slice
- // - decode into non-addressable slice of equal length, then larger len
- // - for each decode, compare elem-by-elem to the original slice
- // -
- // - rinse and repeat for a MapBySlice version
- // -
- */}}
- var v{{$i}}v1, v{{$i}}v2 []{{ .Elem }}
- v{{$i}}v1 = v
- bs{{$i}} := testMarshalErr(v{{$i}}v1, h, t, "enc-slice-v{{$i}}")
- 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
- 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
- testUnmarshalErr(&v{{$i}}v2, bs{{$i}}, h, t, "dec-slice-v{{$i}}-p")
- testDeepEqualErr(v{{$i}}v1, v{{$i}}v2, t, "equal-slice-v{{$i}}-p")
- v{{$i}}va = [8]{{ .Elem }}{} // clear the array
- v{{$i}}v2 = v{{$i}}va[:1:1]
- testUnmarshalErr(&v{{$i}}v2, bs{{$i}}, h, t, "dec-slice-v{{$i}}-p-1")
- testDeepEqualErr(v{{$i}}v1, v{{$i}}v2, t, "equal-slice-v{{$i}}-p-1")
- v{{$i}}va = [8]{{ .Elem }}{} // clear the array
- v{{$i}}v2 = v{{$i}}va[:len(v{{$i}}v1):len(v{{$i}}v1)]
- testUnmarshalErr(&v{{$i}}v2, bs{{$i}}, h, t, "dec-slice-v{{$i}}-p-len")
- testDeepEqualErr(v{{$i}}v1, v{{$i}}v2, t, "equal-slice-v{{$i}}-p-len")
- v{{$i}}va = [8]{{ .Elem }}{} // clear the array
- v{{$i}}v2 = v{{$i}}va[:]
- testUnmarshalErr(&v{{$i}}v2, bs{{$i}}, h, t, "dec-slice-v{{$i}}-p-cap")
- testDeepEqualErr(v{{$i}}v1, v{{$i}}v2, t, "equal-slice-v{{$i}}-p-cap")
- if len(v{{$i}}v1) > 1 {
- v{{$i}}va = [8]{{ .Elem }}{} // clear the array
- testUnmarshalErr((&v{{$i}}va)[:len(v{{$i}}v1)], bs{{$i}}, h, t, "dec-slice-v{{$i}}-p-len-noaddr")
- testDeepEqualErr(v{{$i}}v1, v{{$i}}va[:len(v{{$i}}v1)], t, "equal-slice-v{{$i}}-p-len-noaddr")
- v{{$i}}va = [8]{{ .Elem }}{} // clear the array
- testUnmarshalErr((&v{{$i}}va)[:], bs{{$i}}, h, t, "dec-slice-v{{$i}}-p-cap-noaddr")
- testDeepEqualErr(v{{$i}}v1, v{{$i}}va[:len(v{{$i}}v1)], t, "equal-slice-v{{$i}}-p-cap-noaddr")
- }
- // ...
- var v{{$i}}v3, v{{$i}}v4 {{ .MethodNamePfx "typMbs" false }}
- v{{$i}}v2 = nil
- 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)
- 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)
- testUnmarshalErr(&v{{$i}}v4, bs{{$i}}, h, t, "dec-slice-v{{$i}}-custom-p")
- testDeepEqualErr(v{{$i}}v3, v{{$i}}v4, t, "equal-slice-v{{$i}}-custom-p")
- }
-{{end}}{{end}}{{end}}
-}
-
-func doTestMammothMaps(t *testing.T, h Handle) {
-{{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 }}
- v{{$i}}v1 = v
- bs{{$i}} := testMarshalErr(v{{$i}}v1, h, t, "enc-map-v{{$i}}")
- 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
- 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")
- bs{{$i}} = testMarshalErr(&v{{$i}}v1, h, t, "enc-map-v{{$i}}-p")
- v{{$i}}v2 = nil
- testUnmarshalErr(&v{{$i}}v2, bs{{$i}}, h, t, "dec-map-v{{$i}}-p-nil")
- testDeepEqualErr(v{{$i}}v1, v{{$i}}v2, t, "equal-map-v{{$i}}-p-nil")
- // ...
- if v == nil { v{{$i}}v2 = nil } else { v{{$i}}v2 = make(map[{{ .MapKey }}]{{ .Elem }}, len(v)) } // reset map
- 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)
- 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}}
-
-}
-
-func doTestMammothMapsAndSlices(t *testing.T, h Handle) {
- doTestMammothSlices(t, h)
- doTestMammothMaps(t, h)
-}
diff --git a/vendor/github.com/ugorji/go/codec/mammoth2-test.go.tmpl b/vendor/github.com/ugorji/go/codec/mammoth2-test.go.tmpl
deleted file mode 100644
index 7cdf8f5d71..0000000000
--- a/vendor/github.com/ugorji/go/codec/mammoth2-test.go.tmpl
+++ /dev/null
@@ -1,94 +0,0 @@
-// +build !notfastpath
-
-// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved.
-// Use of this source code is governed by a MIT license found in the LICENSE file.
-
-// Code generated from mammoth2-test.go.tmpl - DO NOT EDIT.
-
-package codec
-
-// Increase codecoverage by covering all the codecgen paths, in fast-path and gen-helper.go....
-//
-// Add:
-// - test file for creating a mammoth generated file as _mammoth_generated.go
-// - generate a second mammoth files in a different file: mammoth2_generated_test.go
-// - mammoth-test.go.tmpl will do this
-// - run codecgen on it, into mammoth2_codecgen_generated_test.go (no build tags)
-// - as part of TestMammoth, run it also
-// - this will cover all the codecgen, gen-helper, etc in one full run
-// - check in mammoth* files into github also
-// - then
-//
-// Now, add some types:
-// - some that implement BinaryMarshal, TextMarshal, JSONMarshal, and one that implements none of it
-// - create a wrapper type that includes TestMammoth2, with it in slices, and maps, and the custom types
-// - this wrapper object is what we work encode/decode (so that the codecgen methods are called)
-
-
-// import "encoding/binary"
-import "fmt"
-
-type TestMammoth2 struct {
-
-{{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 }}
-{{ .MethodNamePfx "Fptr" false }} *[]{{ .Elem }}
-{{end}}{{end}}{{end}}
-
-{{range .Values }}{{if not .Primitive }}{{if .MapKey }}{{/*
-*/}}{{ .MethodNamePfx "F" false }} map[{{ .MapKey }}]{{ .Elem }}
-{{ .MethodNamePfx "Fptr" false }} *map[{{ .MapKey }}]{{ .Elem }}
-{{end}}{{end}}{{end}}
-
-}
-
-// -----------
-
-type testMammoth2Binary uint64
-func (x testMammoth2Binary) MarshalBinary() (data []byte, err error) {
-data = make([]byte, 8)
-bigen.PutUint64(data, uint64(x))
-return
-}
-func (x *testMammoth2Binary) UnmarshalBinary(data []byte) (err error) {
-*x = testMammoth2Binary(bigen.Uint64(data))
-return
-}
-
-type testMammoth2Text uint64
-func (x testMammoth2Text) MarshalText() (data []byte, err error) {
-data = []byte(fmt.Sprintf("%b", uint64(x)))
-return
-}
-func (x *testMammoth2Text) UnmarshalText(data []byte) (err error) {
-_, err = fmt.Sscanf(string(data), "%b", (*uint64)(x))
-return
-}
-
-type testMammoth2Json uint64
-func (x testMammoth2Json) MarshalJSON() (data []byte, err error) {
-data = []byte(fmt.Sprintf("%v", uint64(x)))
-return
-}
-func (x *testMammoth2Json) UnmarshalJSON(data []byte) (err error) {
-_, err = fmt.Sscanf(string(data), "%v", (*uint64)(x))
-return
-}
-
-type testMammoth2Basic [4]uint64
-
-type TestMammoth2Wrapper struct {
- V TestMammoth2
- T testMammoth2Text
- B testMammoth2Binary
- J testMammoth2Json
- C testMammoth2Basic
- M map[testMammoth2Basic]TestMammoth2
- L []TestMammoth2
- A [4]int64
-}
diff --git a/vendor/github.com/ugorji/go/codec/msgpack.go b/vendor/github.com/ugorji/go/codec/msgpack.go
index 3271579a1a..e79830b562 100644
--- a/vendor/github.com/ugorji/go/codec/msgpack.go
+++ b/vendor/github.com/ugorji/go/codec/msgpack.go
@@ -1,4 +1,4 @@
-// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved.
+// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved.
// Use of this source code is governed by a MIT license found in the LICENSE file.
/*
@@ -15,8 +15,8 @@ For compatibility with behaviour of msgpack-c reference implementation:
- Go intX (<0)
IS ENCODED AS
msgpack -ve fixnum, signed
-*/
+*/
package codec
import (
@@ -25,7 +25,6 @@ import (
"math"
"net/rpc"
"reflect"
- "time"
)
const (
@@ -79,89 +78,6 @@ const (
mpNegFixNumMax = 0xff
)
-var mpTimeExtTag int8 = -1
-var mpTimeExtTagU = uint8(mpTimeExtTag)
-
-// var mpdesc = map[byte]string{
-// mpPosFixNumMin: "PosFixNumMin",
-// mpPosFixNumMax: "PosFixNumMax",
-// mpFixMapMin: "FixMapMin",
-// mpFixMapMax: "FixMapMax",
-// mpFixArrayMin: "FixArrayMin",
-// mpFixArrayMax: "FixArrayMax",
-// mpFixStrMin: "FixStrMin",
-// mpFixStrMax: "FixStrMax",
-// mpNil: "Nil",
-// mpFalse: "False",
-// mpTrue: "True",
-// mpFloat: "Float",
-// mpDouble: "Double",
-// mpUint8: "Uint8",
-// mpUint16: "Uint16",
-// mpUint32: "Uint32",
-// mpUint64: "Uint64",
-// mpInt8: "Int8",
-// mpInt16: "Int16",
-// mpInt32: "Int32",
-// mpInt64: "Int64",
-// mpBin8: "Bin8",
-// mpBin16: "Bin16",
-// mpBin32: "Bin32",
-// mpExt8: "Ext8",
-// mpExt16: "Ext16",
-// mpExt32: "Ext32",
-// mpFixExt1: "FixExt1",
-// mpFixExt2: "FixExt2",
-// mpFixExt4: "FixExt4",
-// mpFixExt8: "FixExt8",
-// mpFixExt16: "FixExt16",
-// mpStr8: "Str8",
-// mpStr16: "Str16",
-// mpStr32: "Str32",
-// mpArray16: "Array16",
-// mpArray32: "Array32",
-// mpMap16: "Map16",
-// mpMap32: "Map32",
-// mpNegFixNumMin: "NegFixNumMin",
-// mpNegFixNumMax: "NegFixNumMax",
-// }
-
-func mpdesc(bd byte) string {
- switch bd {
- case mpNil:
- return "nil"
- case mpFalse:
- return "false"
- case mpTrue:
- return "true"
- case mpFloat, mpDouble:
- return "float"
- case mpUint8, mpUint16, mpUint32, mpUint64:
- return "uint"
- case mpInt8, mpInt16, mpInt32, mpInt64:
- return "int"
- default:
- switch {
- case bd >= mpPosFixNumMin && bd <= mpPosFixNumMax:
- return "int"
- case bd >= mpNegFixNumMin && bd <= mpNegFixNumMax:
- return "int"
- case bd == mpStr8, bd == mpStr16, bd == mpStr32, bd >= mpFixStrMin && bd <= mpFixStrMax:
- return "string|bytes"
- case bd == mpBin8, bd == mpBin16, bd == mpBin32:
- return "bytes"
- case bd == mpArray16, bd == mpArray32, bd >= mpFixArrayMin && bd <= mpFixArrayMax:
- return "array"
- case bd == mpMap16, bd == mpMap32, bd >= mpFixMapMin && bd <= mpFixMapMax:
- return "map"
- case bd >= mpFixExt1 && bd <= mpFixExt16, bd >= mpExt8 && bd <= mpExt32:
- return "ext"
- default:
- return "unknown"
- }
- }
-}
-
// MsgpackSpecRpcMultiArgs is a special type which signifies to the MsgpackSpecRpcCodec
// that the backend RPC service takes multiple arguments, which have been arranged
// in sequence in the slice.
@@ -178,31 +94,21 @@ type msgpackContainerType struct {
}
var (
- msgpackContainerStr = msgpackContainerType{
- 32, mpFixStrMin, mpStr8, mpStr16, mpStr32, true, true, false,
- }
- msgpackContainerBin = msgpackContainerType{
- 0, 0, mpBin8, mpBin16, mpBin32, false, true, true,
- }
- msgpackContainerList = msgpackContainerType{
- 16, mpFixArrayMin, 0, mpArray16, mpArray32, true, false, false,
- }
- msgpackContainerMap = msgpackContainerType{
- 16, mpFixMapMin, 0, mpMap16, mpMap32, true, false, false,
- }
+ msgpackContainerStr = msgpackContainerType{32, mpFixStrMin, mpStr8, mpStr16, mpStr32, true, true, false}
+ msgpackContainerBin = msgpackContainerType{0, 0, mpBin8, mpBin16, mpBin32, false, true, true}
+ msgpackContainerList = msgpackContainerType{16, mpFixArrayMin, 0, mpArray16, mpArray32, true, false, false}
+ msgpackContainerMap = msgpackContainerType{16, mpFixMapMin, 0, mpMap16, mpMap32, true, false, false}
)
//---------------------------------------------
type msgpackEncDriver struct {
noBuiltInTypes
- encDriverNoopContainerWriter
- // encNoSeparator
+ encNoSeparator
e *Encoder
w encWriter
h *MsgpackHandle
x [8]byte
- _ [3]uint64 // padding
}
func (e *msgpackEncDriver) EncodeNil() {
@@ -210,26 +116,10 @@ func (e *msgpackEncDriver) EncodeNil() {
}
func (e *msgpackEncDriver) EncodeInt(i int64) {
- // if i >= 0 {
- // e.EncodeUint(uint64(i))
- // } else if false &&
- if i > math.MaxInt8 {
- if i <= math.MaxInt16 {
- e.w.writen1(mpInt16)
- bigenHelper{e.x[:2], e.w}.writeUint16(uint16(i))
- } else if i <= math.MaxInt32 {
- e.w.writen1(mpInt32)
- bigenHelper{e.x[:4], e.w}.writeUint32(uint32(i))
- } else {
- e.w.writen1(mpInt64)
- bigenHelper{e.x[:8], e.w}.writeUint64(uint64(i))
- }
+ if i >= 0 {
+ e.EncodeUint(uint64(i))
} else if i >= -32 {
- if e.h.NoFixedNum {
- e.w.writen2(mpInt8, byte(i))
- } else {
- e.w.writen1(byte(i))
- }
+ e.w.writen1(byte(i))
} else if i >= math.MinInt8 {
e.w.writen2(mpInt8, byte(i))
} else if i >= math.MinInt16 {
@@ -246,11 +136,7 @@ func (e *msgpackEncDriver) EncodeInt(i int64) {
func (e *msgpackEncDriver) EncodeUint(i uint64) {
if i <= math.MaxInt8 {
- if e.h.NoFixedNum {
- e.w.writen2(mpUint8, byte(i))
- } else {
- e.w.writen1(byte(i))
- }
+ e.w.writen1(byte(i))
} else if i <= math.MaxUint8 {
e.w.writen2(mpUint8, byte(i))
} else if i <= math.MaxUint16 {
@@ -283,39 +169,6 @@ func (e *msgpackEncDriver) EncodeFloat64(f float64) {
bigenHelper{e.x[:8], e.w}.writeUint64(math.Float64bits(f))
}
-func (e *msgpackEncDriver) EncodeTime(t time.Time) {
- if t.IsZero() {
- e.EncodeNil()
- return
- }
- t = t.UTC()
- sec, nsec := t.Unix(), uint64(t.Nanosecond())
- var data64 uint64
- var l = 4
- if sec >= 0 && sec>>34 == 0 {
- data64 = (nsec << 34) | uint64(sec)
- if data64&0xffffffff00000000 != 0 {
- l = 8
- }
- } else {
- l = 12
- }
- if e.h.WriteExt {
- e.encodeExtPreamble(mpTimeExtTagU, l)
- } else {
- e.writeContainerLen(msgpackContainerStr, l)
- }
- switch l {
- case 4:
- bigenHelper{e.x[:4], e.w}.writeUint32(uint32(data64))
- case 8:
- bigenHelper{e.x[:8], e.w}.writeUint64(data64)
- case 12:
- bigenHelper{e.x[:4], e.w}.writeUint32(uint32(nsec))
- bigenHelper{e.x[:8], e.w}.writeUint64(uint64(sec))
- }
-}
-
func (e *msgpackEncDriver) EncodeExt(v interface{}, xtag uint64, ext Ext, _ *Encoder) {
bs := ext.WriteExt(v)
if bs == nil {
@@ -326,7 +179,7 @@ func (e *msgpackEncDriver) EncodeExt(v interface{}, xtag uint64, ext Ext, _ *Enc
e.encodeExtPreamble(uint8(xtag), len(bs))
e.w.writeb(bs)
} else {
- e.EncodeStringBytes(cRAW, bs)
+ e.EncodeStringBytes(c_RAW, bs)
}
}
@@ -360,38 +213,36 @@ func (e *msgpackEncDriver) encodeExtPreamble(xtag byte, l int) {
}
}
-func (e *msgpackEncDriver) WriteArrayStart(length int) {
+func (e *msgpackEncDriver) EncodeArrayStart(length int) {
e.writeContainerLen(msgpackContainerList, length)
}
-func (e *msgpackEncDriver) WriteMapStart(length int) {
+func (e *msgpackEncDriver) EncodeMapStart(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)
+ if c == c_RAW && e.h.WriteExt {
+ e.writeContainerLen(msgpackContainerBin, len(s))
} else {
- e.writeContainerLen(msgpackContainerStr, slen)
+ e.writeContainerLen(msgpackContainerStr, len(s))
}
- if slen > 0 {
+ if len(s) > 0 {
e.w.writestr(s)
}
}
+func (e *msgpackEncDriver) EncodeSymbol(v string) {
+ e.EncodeString(c_UTF8, v)
+}
+
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)
+ if c == c_RAW && e.h.WriteExt {
+ e.writeContainerLen(msgpackContainerBin, len(bs))
} else {
- e.writeContainerLen(msgpackContainerStr, slen)
+ e.writeContainerLen(msgpackContainerStr, len(bs))
}
- if slen > 0 {
+ if len(bs) > 0 {
e.w.writeb(bs)
}
}
@@ -413,18 +264,16 @@ func (e *msgpackEncDriver) writeContainerLen(ct msgpackContainerType, l int) {
//---------------------------------------------
type msgpackDecDriver struct {
- d *Decoder
- r decReader // *Decoder decReader decReaderT
- h *MsgpackHandle
- // b [scratchByteArrayLen]byte
+ d *Decoder
+ r decReader // *Decoder decReader decReaderT
+ h *MsgpackHandle
+ b [scratchByteArrayLen]byte
bd byte
bdRead bool
br bool // bytes reader
noBuiltInTypes
- // noStreamingCodec
- // decNoSeparator
- decDriverNoopContainerReader
- _ [3]uint64 // padding
+ noStreamingCodec
+ decNoSeparator
}
// Note: This returns either a primitive (int, bool, etc) for non-containers,
@@ -437,7 +286,7 @@ func (d *msgpackDecDriver) DecodeNaked() {
d.readNextBd()
}
bd := d.bd
- n := d.d.n
+ n := &d.d.n
var decodeFurther bool
switch bd {
@@ -500,11 +349,11 @@ func (d *msgpackDecDriver) DecodeNaked() {
n.s = d.DecodeString()
} else {
n.v = valueTypeBytes
- n.l = d.DecodeBytes(nil, false)
+ n.l = d.DecodeBytes(nil, false, false)
}
case bd == mpBin8, bd == mpBin16, bd == mpBin32:
n.v = valueTypeBytes
- n.l = d.DecodeBytes(nil, false)
+ n.l = d.DecodeBytes(nil, false, false)
case bd == mpArray16, bd == mpArray32, bd >= mpFixArrayMin && bd <= mpFixArrayMax:
n.v = valueTypeArray
decodeFurther = true
@@ -515,14 +364,9 @@ func (d *msgpackDecDriver) DecodeNaked() {
n.v = valueTypeExt
clen := d.readExtLen()
n.u = uint64(d.r.readn1())
- if n.u == uint64(mpTimeExtTagU) {
- n.v = valueTypeTime
- n.t = d.decodeTime(clen)
- } else {
- n.l = d.r.readx(clen)
- }
+ n.l = d.r.readx(clen)
default:
- d.d.errorf("cannot infer value: %s: Ox%x/%d/%s", msgBadDesc, bd, bd, mpdesc(bd))
+ d.d.errorf("Nil-Deciphered DecodeValue: %s: hex: %x, dec: %d", msgBadDesc, bd, bd)
}
}
if !decodeFurther {
@@ -536,7 +380,7 @@ func (d *msgpackDecDriver) DecodeNaked() {
}
// int can be decoded from msgpack type: intXXX or uintXXX
-func (d *msgpackDecDriver) DecodeInt64() (i int64) {
+func (d *msgpackDecDriver) DecodeInt(bitsize uint8) (i int64) {
if !d.bdRead {
d.readNextBd()
}
@@ -564,7 +408,14 @@ func (d *msgpackDecDriver) DecodeInt64() (i int64) {
case d.bd >= mpNegFixNumMin && d.bd <= mpNegFixNumMax:
i = int64(int8(d.bd))
default:
- d.d.errorf("cannot decode signed integer: %s: %x/%s", msgBadDesc, d.bd, mpdesc(d.bd))
+ d.d.errorf("Unhandled single-byte unsigned integer value: %s: %x", msgBadDesc, d.bd)
+ return
+ }
+ }
+ // check overflow (logic adapted from std pkg reflect/value.go OverflowUint()
+ if bitsize > 0 {
+ if trunc := (i << (64 - bitsize)) >> (64 - bitsize); i != trunc {
+ d.d.errorf("Overflow int value: %v", i)
return
}
}
@@ -573,7 +424,7 @@ func (d *msgpackDecDriver) DecodeInt64() (i int64) {
}
// uint can be decoded from msgpack type: intXXX or uintXXX
-func (d *msgpackDecDriver) DecodeUint64() (ui uint64) {
+func (d *msgpackDecDriver) DecodeUint(bitsize uint8) (ui uint64) {
if !d.bdRead {
d.readNextBd()
}
@@ -590,28 +441,28 @@ func (d *msgpackDecDriver) DecodeUint64() (ui uint64) {
if i := int64(int8(d.r.readn1())); i >= 0 {
ui = uint64(i)
} else {
- d.d.errorf("assigning negative signed value: %v, to unsigned type", i)
+ 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 {
ui = uint64(i)
} else {
- d.d.errorf("assigning negative signed value: %v, to unsigned type", i)
+ 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 {
ui = uint64(i)
} else {
- d.d.errorf("assigning negative signed value: %v, to unsigned type", i)
+ 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 {
ui = uint64(i)
} else {
- d.d.errorf("assigning negative signed value: %v, to unsigned type", i)
+ d.d.errorf("Assigning negative signed value: %v, to unsigned type", i)
return
}
default:
@@ -619,10 +470,17 @@ func (d *msgpackDecDriver) DecodeUint64() (ui uint64) {
case d.bd >= mpPosFixNumMin && d.bd <= mpPosFixNumMax:
ui = uint64(d.bd)
case d.bd >= mpNegFixNumMin && d.bd <= mpNegFixNumMax:
- d.d.errorf("assigning negative signed value: %v, to unsigned type", int(d.bd))
+ d.d.errorf("Assigning negative signed value: %v, to unsigned type", int(d.bd))
return
default:
- d.d.errorf("cannot decode unsigned integer: %s: %x/%s", msgBadDesc, d.bd, mpdesc(d.bd))
+ d.d.errorf("Unhandled single-byte unsigned integer value: %s: %x", msgBadDesc, d.bd)
+ return
+ }
+ }
+ // check overflow (logic adapted from std pkg reflect/value.go OverflowUint()
+ if bitsize > 0 {
+ if trunc := (ui << (64 - bitsize)) >> (64 - bitsize); ui != trunc {
+ d.d.errorf("Overflow uint value: %v", ui)
return
}
}
@@ -631,7 +489,7 @@ func (d *msgpackDecDriver) DecodeUint64() (ui uint64) {
}
// float can either be decoded from msgpack type: float, double or intX
-func (d *msgpackDecDriver) DecodeFloat64() (f float64) {
+func (d *msgpackDecDriver) DecodeFloat(chkOverflow32 bool) (f float64) {
if !d.bdRead {
d.readNextBd()
}
@@ -640,7 +498,11 @@ func (d *msgpackDecDriver) DecodeFloat64() (f float64) {
} else if d.bd == mpDouble {
f = math.Float64frombits(bigen.Uint64(d.r.readx(8)))
} else {
- f = float64(d.DecodeInt64())
+ f = float64(d.DecodeInt(0))
+ }
+ if chkOverflow32 && chkOvf.Float32(f) {
+ d.d.errorf("msgpack: float32 overflow: %v", f)
+ return
}
d.bdRead = false
return
@@ -656,45 +518,25 @@ func (d *msgpackDecDriver) DecodeBool() (b bool) {
} else if d.bd == mpTrue || d.bd == 1 {
b = true
} else {
- d.d.errorf("cannot decode bool: %s: %x/%s", msgBadDesc, d.bd, mpdesc(d.bd))
+ d.d.errorf("Invalid single-byte value for bool: %s: %x", msgBadDesc, d.bd)
return
}
d.bdRead = false
return
}
-func (d *msgpackDecDriver) DecodeBytes(bs []byte, zerocopy bool) (bsOut []byte) {
+func (d *msgpackDecDriver) DecodeBytes(bs []byte, isstring, zerocopy bool) (bsOut []byte) {
if !d.bdRead {
d.readNextBd()
}
-
- // check if an "array" of uint8's (see ContainerType for how to infer if an array)
- bd := d.bd
- // DecodeBytes could be from: bin str fixstr fixarray array ...
var clen int
- vt := d.ContainerType()
- switch vt {
- case valueTypeBytes:
- // valueTypeBytes may be a mpBin or an mpStr container
- if bd == mpBin8 || bd == mpBin16 || bd == mpBin32 {
- clen = d.readContainerLen(msgpackContainerBin)
- } else {
- clen = d.readContainerLen(msgpackContainerStr)
- }
- case valueTypeString:
+ // ignore isstring. Expect that the bytes may be found from msgpackContainerStr or msgpackContainerBin
+ if bd := d.bd; bd == mpBin8 || bd == mpBin16 || bd == mpBin32 {
+ clen = d.readContainerLen(msgpackContainerBin)
+ } else {
clen = d.readContainerLen(msgpackContainerStr)
- case valueTypeArray:
- if zerocopy && len(bs) == 0 {
- bs = d.d.b[:]
- }
- bsOut, _ = fastpathTV.DecSliceUint8V(bs, true, d.d)
- return
- default:
- d.d.errorf("invalid container type: expecting bin|str|array, got: 0x%x", uint8(vt))
- return
}
-
- // these are (bin|str)(8|16|32)
+ // println("DecodeBytes: clen: ", clen)
d.bdRead = false
// bytes may be nil, so handle it. if nil, clen=-1.
if clen < 0 {
@@ -704,18 +546,14 @@ func (d *msgpackDecDriver) DecodeBytes(bs []byte, zerocopy bool) (bsOut []byte)
if d.br {
return d.r.readx(clen)
} else if len(bs) == 0 {
- bs = d.d.b[:]
+ bs = d.b[:]
}
}
- return decByteSlice(d.r, clen, d.h.MaxInitLen, bs)
+ return decByteSlice(d.r, clen, bs)
}
func (d *msgpackDecDriver) DecodeString() (s string) {
- return string(d.DecodeBytes(d.d.b[:], true))
-}
-
-func (d *msgpackDecDriver) DecodeStringAsBytes() (s []byte) {
- return d.DecodeBytes(d.d.b[:], true)
+ return string(d.DecodeBytes(d.b[:], true, true))
}
func (d *msgpackDecDriver) readNextBd() {
@@ -731,9 +569,6 @@ func (d *msgpackDecDriver) uncacheRead() {
}
func (d *msgpackDecDriver) ContainerType() (vt valueType) {
- if !d.bdRead {
- d.readNextBd()
- }
bd := d.bd
if bd == mpNil {
return valueTypeNil
@@ -748,10 +583,9 @@ func (d *msgpackDecDriver) ContainerType() (vt valueType) {
return valueTypeArray
} else if bd == mpMap16 || bd == mpMap32 || (bd >= mpFixMapMin && bd <= mpFixMapMax) {
return valueTypeMap
+ } else {
+ // d.d.errorf("isContainerType: unsupported parameter: %v", vt)
}
- // else {
- // d.d.errorf("isContainerType: unsupported parameter: %v", vt)
- // }
return valueTypeUnset
}
@@ -761,7 +595,7 @@ func (d *msgpackDecDriver) TryDecodeAsNil() (v bool) {
}
if d.bd == mpNil {
d.bdRead = false
- return true
+ v = true
}
return
}
@@ -779,7 +613,7 @@ func (d *msgpackDecDriver) readContainerLen(ct msgpackContainerType) (clen int)
} else if (ct.bFixMin & bd) == ct.bFixMin {
clen = int(ct.bFixMin ^ bd)
} else {
- d.d.errorf("cannot read container length: %s: hex: %x, decimal: %d", msgBadDesc, bd, bd)
+ d.d.errorf("readContainerLen: %s: hex: %x, decimal: %d", msgBadDesc, bd, bd)
return
}
d.bdRead = false
@@ -787,16 +621,10 @@ func (d *msgpackDecDriver) readContainerLen(ct msgpackContainerType) (clen int)
}
func (d *msgpackDecDriver) ReadMapStart() int {
- if !d.bdRead {
- d.readNextBd()
- }
return d.readContainerLen(msgpackContainerMap)
}
func (d *msgpackDecDriver) ReadArrayStart() int {
- if !d.bdRead {
- d.readNextBd()
- }
return d.readContainerLen(msgpackContainerList)
}
@@ -827,60 +655,9 @@ func (d *msgpackDecDriver) readExtLen() (clen int) {
return
}
-func (d *msgpackDecDriver) DecodeTime() (t time.Time) {
- // decode time from string bytes or ext
- if !d.bdRead {
- d.readNextBd()
- }
- if d.bd == mpNil {
- d.bdRead = false
- return
- }
- var clen int
- switch d.ContainerType() {
- case valueTypeBytes, valueTypeString:
- clen = d.readContainerLen(msgpackContainerStr)
- default:
- // expect to see mpFixExt4,-1 OR mpFixExt8,-1 OR mpExt8,12,-1
- d.bdRead = false
- b2 := d.r.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 {
- clen = 12
- } else {
- d.d.errorf("invalid bytes for decoding time as extension: got 0x%x, 0x%x", d.bd, b2)
- return
- }
- }
- return d.decodeTime(clen)
-}
-
-func (d *msgpackDecDriver) decodeTime(clen int) (t time.Time) {
- // bs = d.r.readx(clen)
- d.bdRead = false
- switch clen {
- case 4:
- t = time.Unix(int64(bigen.Uint32(d.r.readx(4))), 0).UTC()
- case 8:
- tv := bigen.Uint64(d.r.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))
- 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)
- return
- }
- return
-}
-
func (d *msgpackDecDriver) DecodeExt(rv interface{}, xtag uint64, ext Ext) (realxtag uint64) {
if xtag > 0xff {
- d.d.errorf("ext: tag must be <= 0xff; got: %v", xtag)
+ d.d.errorf("decodeExt: tag must be <= 0xff; got: %v", xtag)
return
}
realxtag1, xbs := d.decodeExtV(ext != nil, uint8(xtag))
@@ -901,15 +678,15 @@ func (d *msgpackDecDriver) decodeExtV(verifyTag bool, tag byte) (xtag byte, xbs
}
xbd := d.bd
if xbd == mpBin8 || xbd == mpBin16 || xbd == mpBin32 {
- xbs = d.DecodeBytes(nil, true)
+ xbs = d.DecodeBytes(nil, false, true)
} else if xbd == mpStr8 || xbd == mpStr16 || xbd == mpStr32 ||
(xbd >= mpFixStrMin && xbd <= mpFixStrMax) {
- xbs = d.DecodeStringAsBytes()
+ xbs = d.DecodeBytes(nil, true, true)
} else {
clen := d.readExtLen()
xtag = d.r.readn1()
if verifyTag && xtag != tag {
- d.d.errorf("wrong extension tag - got %b, expecting %v", xtag, tag)
+ d.d.errorf("Wrong extension tag. Got %b. Expecting: %v", xtag, tag)
return
}
xbs = d.r.readx(clen)
@@ -927,9 +704,6 @@ type MsgpackHandle struct {
// RawToString controls how raw bytes are decoded into a nil interface{}.
RawToString bool
- // NoFixedNum says to output all signed integers as 2-bytes, never as 1-byte fixednum.
- NoFixedNum bool
-
// WriteExt flag supports encoding configured extensions with extension tags.
// It also controls whether other elements of the new spec are encoded (ie Str8).
//
@@ -941,19 +715,11 @@ type MsgpackHandle struct {
// type is provided (e.g. decoding into a nil interface{}), you get back
// a []byte or string based on the setting of RawToString.
WriteExt bool
-
binaryEncodingType
- noElemSeparators
-
- // _ [1]uint64 // padding
}
-// 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{}})
+ return h.SetExt(rt, tag, &setExtWrapper{b: ext})
}
func (h *MsgpackHandle) newEncDriver(e *Encoder) encDriver {
@@ -961,7 +727,7 @@ func (h *MsgpackHandle) newEncDriver(e *Encoder) encDriver {
}
func (h *MsgpackHandle) newDecDriver(d *Decoder) decDriver {
- return &msgpackDecDriver{d: d, h: h, r: d.r, br: d.bytes}
+ return &msgpackDecDriver{d: d, r: d.r, h: h, br: d.bytes}
}
func (e *msgpackEncDriver) reset() {
@@ -969,7 +735,7 @@ func (e *msgpackEncDriver) reset() {
}
func (d *msgpackDecDriver) reset() {
- d.r, d.br = d.d.r, d.d.bytes
+ d.r = d.d.r
d.bd, d.bdRead = 0, false
}
@@ -991,7 +757,7 @@ func (c *msgpackSpecRpcCodec) WriteRequest(r *rpc.Request, body interface{}) err
bodyArr = []interface{}{body}
}
r2 := []interface{}{0, uint32(r.Seq), r.ServiceMethod, bodyArr}
- return c.write(r2, nil, false)
+ return c.write(r2, nil, false, true)
}
func (c *msgpackSpecRpcCodec) WriteResponse(r *rpc.Response, body interface{}) error {
@@ -1003,7 +769,7 @@ func (c *msgpackSpecRpcCodec) WriteResponse(r *rpc.Response, body interface{}) e
body = nil
}
r2 := []interface{}{1, uint32(r.Seq), moe, body}
- return c.write(r2, nil, false)
+ return c.write(r2, nil, false, true)
}
func (c *msgpackSpecRpcCodec) ReadResponseHeader(r *rpc.Response) error {
@@ -1023,6 +789,7 @@ func (c *msgpackSpecRpcCodec) ReadRequestBody(body interface{}) error {
}
func (c *msgpackSpecRpcCodec) parseCustomHeader(expectTypeByte byte, msgid *uint64, methodOrError *string) (err error) {
+
if c.isClosed() {
return io.EOF
}
@@ -1036,34 +803,28 @@ func (c *msgpackSpecRpcCodec) parseCustomHeader(expectTypeByte byte, msgid *uint
// err = fmt.Errorf("Unexpected value for array descriptor: Expecting %v. Received %v", fia, bs1)
// return
// }
- var ba [1]byte
- var n int
- for {
- n, err = c.r.Read(ba[:])
- if err != nil {
- return
- }
- if n == 1 {
- break
- }
+ var b byte
+ b, err = c.br.ReadByte()
+ if err != nil {
+ return
+ }
+ if b != fia {
+ err = fmt.Errorf("Unexpected value for array descriptor: Expecting %v. Received %v", fia, b)
+ return
}
- var b = ba[0]
- if b != fia {
- err = fmt.Errorf("not array - %s %x/%s", msgBadDesc, b, mpdesc(b))
- } else {
- err = c.read(&b)
- if err == nil {
- if b != expectTypeByte {
- err = fmt.Errorf("%s - expecting %v but got %x/%s",
- msgBadDesc, expectTypeByte, b, mpdesc(b))
- } else {
- err = c.read(msgid)
- if err == nil {
- err = c.read(methodOrError)
- }
- }
- }
+ if err = c.read(&b); err != nil {
+ return
+ }
+ if b != expectTypeByte {
+ err = fmt.Errorf("Unexpected byte descriptor in header. Expecting %v. Received %v", expectTypeByte, b)
+ return
+ }
+ if err = c.read(msgid); err != nil {
+ return
+ }
+ if err = c.read(methodOrError); err != nil {
+ return
}
return
}
@@ -1076,8 +837,7 @@ type msgpackSpecRpc struct{}
// MsgpackSpecRpc implements Rpc using the communication protocol defined in
// the msgpack spec at https://github.com/msgpack-rpc/msgpack-rpc/blob/master/spec.md .
-//
-// See GoRpc documentation, for information on buffering for better performance.
+// Its methods (ServerCodec and ClientCodec) return values that implement RpcCodecBuffered.
var MsgpackSpecRpc msgpackSpecRpc
func (x msgpackSpecRpc) ServerCodec(conn io.ReadWriteCloser, h Handle) rpc.ServerCodec {
diff --git a/vendor/github.com/ugorji/go/codec/noop.go b/vendor/github.com/ugorji/go/codec/noop.go
new file mode 100644
index 0000000000..cfee3d084d
--- /dev/null
+++ b/vendor/github.com/ugorji/go/codec/noop.go
@@ -0,0 +1,213 @@
+// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved.
+// Use of this source code is governed by a MIT license found in the LICENSE file.
+
+package codec
+
+import (
+ "math/rand"
+ "time"
+)
+
+// NoopHandle returns a no-op handle. It basically does nothing.
+// It is only useful for benchmarking, as it gives an idea of the
+// overhead from the codec framework.
+//
+// LIBRARY USERS: *** DO NOT USE ***
+func NoopHandle(slen int) *noopHandle {
+ h := noopHandle{}
+ h.rand = rand.New(rand.NewSource(time.Now().UnixNano()))
+ h.B = make([][]byte, slen)
+ h.S = make([]string, slen)
+ for i := 0; i < len(h.S); i++ {
+ b := make([]byte, i+1)
+ for j := 0; j < len(b); j++ {
+ b[j] = 'a' + byte(i)
+ }
+ h.B[i] = b
+ h.S[i] = string(b)
+ }
+ return &h
+}
+
+// noopHandle does nothing.
+// It is used to simulate the overhead of the codec framework.
+type noopHandle struct {
+ BasicHandle
+ binaryEncodingType
+ noopDrv // noopDrv is unexported here, so we can get a copy of it when needed.
+}
+
+type noopDrv struct {
+ d *Decoder
+ e *Encoder
+ i int
+ S []string
+ B [][]byte
+ mks []bool // stack. if map (true), else if array (false)
+ mk bool // top of stack. what container are we on? map or array?
+ ct valueType // last response for IsContainerType.
+ cb int // counter for ContainerType
+ rand *rand.Rand
+}
+
+func (h *noopDrv) r(v int) int { return h.rand.Intn(v) }
+func (h *noopDrv) m(v int) int { h.i++; return h.i % v }
+
+func (h *noopDrv) newEncDriver(e *Encoder) encDriver { h.e = e; return h }
+func (h *noopDrv) newDecDriver(d *Decoder) decDriver { h.d = d; return h }
+
+func (h *noopDrv) reset() {}
+func (h *noopDrv) uncacheRead() {}
+
+// --- encDriver
+
+// stack functions (for map and array)
+func (h *noopDrv) start(b bool) {
+ // println("start", len(h.mks)+1)
+ h.mks = append(h.mks, b)
+ h.mk = b
+}
+func (h *noopDrv) end() {
+ // println("end: ", len(h.mks)-1)
+ h.mks = h.mks[:len(h.mks)-1]
+ if len(h.mks) > 0 {
+ h.mk = h.mks[len(h.mks)-1]
+ } else {
+ h.mk = false
+ }
+}
+
+func (h *noopDrv) EncodeBuiltin(rt uintptr, v interface{}) {}
+func (h *noopDrv) EncodeNil() {}
+func (h *noopDrv) EncodeInt(i int64) {}
+func (h *noopDrv) EncodeUint(i uint64) {}
+func (h *noopDrv) EncodeBool(b bool) {}
+func (h *noopDrv) EncodeFloat32(f float32) {}
+func (h *noopDrv) EncodeFloat64(f float64) {}
+func (h *noopDrv) EncodeRawExt(re *RawExt, e *Encoder) {}
+func (h *noopDrv) EncodeArrayStart(length int) { h.start(true) }
+func (h *noopDrv) EncodeMapStart(length int) { h.start(false) }
+func (h *noopDrv) EncodeEnd() { h.end() }
+
+func (h *noopDrv) EncodeString(c charEncoding, v string) {}
+func (h *noopDrv) EncodeSymbol(v string) {}
+func (h *noopDrv) EncodeStringBytes(c charEncoding, v []byte) {}
+
+func (h *noopDrv) EncodeExt(rv interface{}, xtag uint64, ext Ext, e *Encoder) {}
+
+// ---- decDriver
+func (h *noopDrv) initReadNext() {}
+func (h *noopDrv) CheckBreak() bool { return false }
+func (h *noopDrv) IsBuiltinType(rt uintptr) bool { return false }
+func (h *noopDrv) DecodeBuiltin(rt uintptr, v interface{}) {}
+func (h *noopDrv) DecodeInt(bitsize uint8) (i int64) { return int64(h.m(15)) }
+func (h *noopDrv) DecodeUint(bitsize uint8) (ui uint64) { return uint64(h.m(35)) }
+func (h *noopDrv) DecodeFloat(chkOverflow32 bool) (f float64) { return float64(h.m(95)) }
+func (h *noopDrv) DecodeBool() (b bool) { return h.m(2) == 0 }
+func (h *noopDrv) DecodeString() (s string) { return h.S[h.m(8)] }
+
+// func (h *noopDrv) DecodeStringAsBytes(bs []byte) []byte { return h.DecodeBytes(bs) }
+
+func (h *noopDrv) DecodeBytes(bs []byte, isstring, zerocopy bool) []byte { return h.B[h.m(len(h.B))] }
+
+func (h *noopDrv) ReadEnd() { h.end() }
+
+// toggle map/slice
+func (h *noopDrv) ReadMapStart() int { h.start(true); return h.m(10) }
+func (h *noopDrv) ReadArrayStart() int { h.start(false); return h.m(10) }
+
+func (h *noopDrv) ContainerType() (vt valueType) {
+ // return h.m(2) == 0
+ // handle kStruct, which will bomb is it calls this and doesn't get back a map or array.
+ // consequently, if the return value is not map or array, reset it to one of them based on h.m(7) % 2
+ // for kstruct: at least one out of every 2 times, return one of valueTypeMap or Array (else kstruct bombs)
+ // however, every 10th time it is called, we just return something else.
+ var vals = [...]valueType{valueTypeArray, valueTypeMap}
+ // ------------ TAKE ------------
+ // if h.cb%2 == 0 {
+ // if h.ct == valueTypeMap || h.ct == valueTypeArray {
+ // } else {
+ // h.ct = vals[h.m(2)]
+ // }
+ // } else if h.cb%5 == 0 {
+ // h.ct = valueType(h.m(8))
+ // } else {
+ // h.ct = vals[h.m(2)]
+ // }
+ // ------------ TAKE ------------
+ // if h.cb%16 == 0 {
+ // h.ct = valueType(h.cb % 8)
+ // } else {
+ // h.ct = vals[h.cb%2]
+ // }
+ h.ct = vals[h.cb%2]
+ h.cb++
+ return h.ct
+
+ // if h.ct == valueTypeNil || h.ct == valueTypeString || h.ct == valueTypeBytes {
+ // return h.ct
+ // }
+ // return valueTypeUnset
+ // TODO: may need to tweak this so it works.
+ // if h.ct == valueTypeMap && vt == valueTypeArray || h.ct == valueTypeArray && vt == valueTypeMap {
+ // h.cb = !h.cb
+ // h.ct = vt
+ // return h.cb
+ // }
+ // // go in a loop and check it.
+ // h.ct = vt
+ // h.cb = h.m(7) == 0
+ // return h.cb
+}
+func (h *noopDrv) TryDecodeAsNil() bool {
+ if h.mk {
+ return false
+ } else {
+ return h.m(8) == 0
+ }
+}
+func (h *noopDrv) DecodeExt(rv interface{}, xtag uint64, ext Ext) uint64 {
+ return 0
+}
+
+func (h *noopDrv) DecodeNaked() {
+ // use h.r (random) not h.m() because h.m() could cause the same value to be given.
+ var sk int
+ if h.mk {
+ // if mapkey, do not support values of nil OR bytes, array, map or rawext
+ sk = h.r(7) + 1
+ } else {
+ sk = h.r(12)
+ }
+ n := &h.d.n
+ switch sk {
+ case 0:
+ n.v = valueTypeNil
+ case 1:
+ n.v, n.b = valueTypeBool, false
+ case 2:
+ n.v, n.b = valueTypeBool, true
+ case 3:
+ n.v, n.i = valueTypeInt, h.DecodeInt(64)
+ case 4:
+ n.v, n.u = valueTypeUint, h.DecodeUint(64)
+ case 5:
+ n.v, n.f = valueTypeFloat, h.DecodeFloat(true)
+ case 6:
+ n.v, n.f = valueTypeFloat, h.DecodeFloat(false)
+ case 7:
+ n.v, n.s = valueTypeString, h.DecodeString()
+ case 8:
+ n.v, n.l = valueTypeBytes, h.B[h.m(len(h.B))]
+ case 9:
+ n.v = valueTypeArray
+ case 10:
+ n.v = valueTypeMap
+ default:
+ n.v = valueTypeExt
+ n.u = h.DecodeUint(64)
+ n.l = h.B[h.m(len(h.B))]
+ }
+ h.ct = n.v
+ return
+}
diff --git a/vendor/github.com/ugorji/go/codec/prebuild.go b/vendor/github.com/ugorji/go/codec/prebuild.go
new file mode 100644
index 0000000000..2353263e88
--- /dev/null
+++ b/vendor/github.com/ugorji/go/codec/prebuild.go
@@ -0,0 +1,3 @@
+package codec
+
+//go:generate bash prebuild.sh
diff --git a/vendor/github.com/ugorji/go/codec/prebuild.sh b/vendor/github.com/ugorji/go/codec/prebuild.sh
new file mode 100755
index 0000000000..909f4bb0f2
--- /dev/null
+++ b/vendor/github.com/ugorji/go/codec/prebuild.sh
@@ -0,0 +1,199 @@
+#!/bin/bash
+
+# _needgen is a helper function to tell if we need to generate files for msgp, codecgen.
+_needgen() {
+ local a="$1"
+ zneedgen=0
+ if [[ ! -e "$a" ]]
+ then
+ zneedgen=1
+ echo 1
+ return 0
+ fi
+ for i in `ls -1 *.go.tmpl gen.go values_test.go`
+ do
+ if [[ "$a" -ot "$i" ]]
+ then
+ zneedgen=1
+ echo 1
+ return 0
+ fi
+ done
+ echo 0
+}
+
+# _build generates fast-path.go and gen-helper.go.
+#
+# It is needed because there is some dependency between the generated code
+# and the other classes. Consequently, we have to totally remove the
+# generated files and put stubs in place, before calling "go run" again
+# to recreate them.
+_build() {
+ if ! [[ "${zforce}" == "1" ||
+ "1" == $( _needgen "fast-path.generated.go" ) ||
+ "1" == $( _needgen "gen-helper.generated.go" ) ||
+ "1" == $( _needgen "gen.generated.go" ) ||
+ 1 == 0 ]]
+ then
+ return 0
+ fi
+
+ # echo "Running prebuild"
+ if [ "${zbak}" == "1" ]
+ then
+ # echo "Backing up old generated files"
+ _zts=`date '+%m%d%Y_%H%M%S'`
+ _gg=".generated.go"
+ [ -e "gen-helper${_gg}" ] && mv gen-helper${_gg} gen-helper${_gg}__${_zts}.bak
+ [ -e "fast-path${_gg}" ] && mv fast-path${_gg} fast-path${_gg}__${_zts}.bak
+ # [ -e "safe${_gg}" ] && mv safe${_gg} safe${_gg}__${_zts}.bak
+ # [ -e "unsafe${_gg}" ] && mv unsafe${_gg} unsafe${_gg}__${_zts}.bak
+ else
+ rm -f fast-path.generated.go gen.generated.go gen-helper.generated.go \
+ *safe.generated.go *_generated_test.go *.generated_ffjson_expose.go
+ fi
+
+ cat > gen.generated.go <> gen.generated.go < gen-dec-map.go.tmpl
+
+ cat >> gen.generated.go <> gen.generated.go < gen-dec-array.go.tmpl
+
+ cat >> gen.generated.go < gen-from-tmpl.codec.generated.go < gen-from-tmpl.generated.go <= simpleVdPosInt && d.bd <= simpleVdNegInt+3 {
- f = float64(d.DecodeInt64())
+ f = float64(d.DecodeInt(64))
} else {
- d.d.errorf("float only valid from float32/64: Invalid descriptor: %v", d.bd)
+ d.d.errorf("Float only valid from float32/64: Invalid descriptor: %v", d.bd)
return
}
}
+ if chkOverflow32 && chkOvf.Float32(f) {
+ d.d.errorf("msgpack: float32 overflow: %v", f)
+ return
+ }
d.bdRead = false
return
}
@@ -350,7 +307,7 @@ func (d *simpleDecDriver) DecodeBool() (b bool) {
b = true
} else if d.bd == simpleVdFalse {
} else {
- d.d.errorf("cannot decode bool - %s: %x", msgBadDesc, d.bd)
+ d.d.errorf("Invalid single-byte value for bool: %s: %x", msgBadDesc, d.bd)
return
}
d.bdRead = false
@@ -358,43 +315,15 @@ func (d *simpleDecDriver) DecodeBool() (b bool) {
}
func (d *simpleDecDriver) ReadMapStart() (length int) {
- if !d.bdRead {
- d.readNextBd()
- }
d.bdRead = false
- d.c = containerMapStart
return d.decLen()
}
func (d *simpleDecDriver) ReadArrayStart() (length int) {
- if !d.bdRead {
- d.readNextBd()
- }
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:
@@ -406,31 +335,27 @@ func (d *simpleDecDriver) decLen() int {
case 3:
ui := uint64(bigen.Uint32(d.r.readx(4)))
if chkOvf.Uint(ui, intBitsize) {
- d.d.errorf("overflow integer: %v", ui)
+ d.d.errorf("simple: overflow integer: %v", ui)
return 0
}
return int(ui)
case 4:
ui := bigen.Uint64(d.r.readx(8))
if chkOvf.Uint(ui, intBitsize) {
- d.d.errorf("overflow integer: %v", ui)
+ d.d.errorf("simple: overflow integer: %v", ui)
return 0
}
return int(ui)
}
- d.d.errorf("cannot read length: bd%%8 must be in range 0..4. Got: %d", d.bd%8)
+ d.d.errorf("decLen: Cannot read length: bd%8 must be in range 0..4. Got: %d", d.bd%8)
return -1
}
func (d *simpleDecDriver) DecodeString() (s string) {
- return string(d.DecodeBytes(d.d.b[:], true))
+ return string(d.DecodeBytes(d.b[:], true, true))
}
-func (d *simpleDecDriver) DecodeStringAsBytes() (s []byte) {
- return d.DecodeBytes(d.d.b[:], true)
-}
-
-func (d *simpleDecDriver) DecodeBytes(bs []byte, zerocopy bool) (bsOut []byte) {
+func (d *simpleDecDriver) DecodeBytes(bs []byte, isstring, zerocopy bool) (bsOut []byte) {
if !d.bdRead {
d.readNextBd()
}
@@ -438,51 +363,21 @@ func (d *simpleDecDriver) DecodeBytes(bs []byte, zerocopy bool) (bsOut []byte) {
d.bdRead = false
return
}
- // check if an "array" of uint8's (see ContainerType for how to infer if an array)
- if d.bd >= simpleVdArray && d.bd <= simpleVdMap+4 {
- if len(bs) == 0 && zerocopy {
- bs = d.d.b[:]
- }
- bsOut, _ = fastpathTV.DecSliceUint8V(bs, true, d.d)
- return
- }
-
clen := d.decLen()
d.bdRead = false
if zerocopy {
if d.br {
return d.r.readx(clen)
} else if len(bs) == 0 {
- bs = d.d.b[:]
+ bs = d.b[:]
}
}
- return decByteSlice(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
- return
- }
- if d.bd != simpleVdTime {
- d.d.errorf("invalid descriptor for time.Time - expect 0x%x, received 0x%x", simpleVdTime, d.bd)
- return
- }
- d.bdRead = false
- clen := int(d.r.readn1())
- b := d.r.readx(clen)
- if err := (&t).UnmarshalBinary(b); err != nil {
- d.d.errorv(err)
- }
- return
+ return decByteSlice(d.r, clen, bs)
}
func (d *simpleDecDriver) DecodeExt(rv interface{}, xtag uint64, ext Ext) (realxtag uint64) {
if xtag > 0xff {
- d.d.errorf("ext: tag must be <= 0xff; got: %v", xtag)
+ d.d.errorf("decodeExt: tag must be <= 0xff; got: %v", xtag)
return
}
realxtag1, xbs := d.decodeExtV(ext != nil, uint8(xtag))
@@ -506,15 +401,14 @@ func (d *simpleDecDriver) decodeExtV(verifyTag bool, tag byte) (xtag byte, xbs [
l := d.decLen()
xtag = d.r.readn1()
if verifyTag && xtag != tag {
- d.d.errorf("wrong extension tag. Got %b. Expecting: %v", xtag, tag)
+ d.d.errorf("Wrong extension tag. Got %b. Expecting: %v", xtag, tag)
return
}
xbs = d.r.readx(l)
- case simpleVdByteArray, simpleVdByteArray + 1,
- simpleVdByteArray + 2, simpleVdByteArray + 3, simpleVdByteArray + 4:
- xbs = d.DecodeBytes(nil, true)
+ case simpleVdByteArray, simpleVdByteArray + 1, simpleVdByteArray + 2, simpleVdByteArray + 3, simpleVdByteArray + 4:
+ xbs = d.DecodeBytes(nil, false, true)
default:
- d.d.errorf("ext - %s - expecting extensions/bytearray, got: 0x%x", msgBadDesc, d.bd)
+ d.d.errorf("Invalid d.bd for extensions (Expecting extensions or byte array). Got: 0x%x", d.bd)
return
}
d.bdRead = false
@@ -526,7 +420,7 @@ func (d *simpleDecDriver) DecodeNaked() {
d.readNextBd()
}
- n := d.d.n
+ n := &d.d.n
var decodeFurther bool
switch d.bd {
@@ -541,45 +435,39 @@ func (d *simpleDecDriver) DecodeNaked() {
case simpleVdPosInt, simpleVdPosInt + 1, simpleVdPosInt + 2, simpleVdPosInt + 3:
if d.h.SignedInteger {
n.v = valueTypeInt
- n.i = d.DecodeInt64()
+ n.i = d.DecodeInt(64)
} else {
n.v = valueTypeUint
- n.u = d.DecodeUint64()
+ n.u = d.DecodeUint(64)
}
case simpleVdNegInt, simpleVdNegInt + 1, simpleVdNegInt + 2, simpleVdNegInt + 3:
n.v = valueTypeInt
- n.i = d.DecodeInt64()
+ n.i = d.DecodeInt(64)
case simpleVdFloat32:
n.v = valueTypeFloat
- n.f = d.DecodeFloat64()
+ n.f = d.DecodeFloat(true)
case simpleVdFloat64:
n.v = valueTypeFloat
- n.f = d.DecodeFloat64()
- case simpleVdTime:
- n.v = valueTypeTime
- n.t = d.DecodeTime()
- case simpleVdString, simpleVdString + 1,
- simpleVdString + 2, simpleVdString + 3, simpleVdString + 4:
+ n.f = d.DecodeFloat(false)
+ case simpleVdString, simpleVdString + 1, simpleVdString + 2, simpleVdString + 3, simpleVdString + 4:
n.v = valueTypeString
n.s = d.DecodeString()
- case simpleVdByteArray, simpleVdByteArray + 1,
- simpleVdByteArray + 2, simpleVdByteArray + 3, simpleVdByteArray + 4:
+ case simpleVdByteArray, simpleVdByteArray + 1, simpleVdByteArray + 2, simpleVdByteArray + 3, simpleVdByteArray + 4:
n.v = valueTypeBytes
- n.l = d.DecodeBytes(nil, false)
+ n.l = d.DecodeBytes(nil, false, false)
case simpleVdExt, simpleVdExt + 1, simpleVdExt + 2, simpleVdExt + 3, simpleVdExt + 4:
n.v = valueTypeExt
l := d.decLen()
n.u = uint64(d.r.readn1())
n.l = d.r.readx(l)
- case simpleVdArray, simpleVdArray + 1, simpleVdArray + 2,
- simpleVdArray + 3, simpleVdArray + 4:
+ case simpleVdArray, simpleVdArray + 1, simpleVdArray + 2, simpleVdArray + 3, simpleVdArray + 4:
n.v = valueTypeArray
decodeFurther = true
case simpleVdMap, simpleVdMap + 1, simpleVdMap + 2, simpleVdMap + 3, simpleVdMap + 4:
n.v = valueTypeMap
decodeFurther = true
default:
- d.d.errorf("cannot infer value - %s 0x%x", msgBadDesc, d.bd)
+ d.d.errorf("decodeNaked: Unrecognized d.bd: 0x%x", d.bd)
}
if !decodeFurther {
@@ -598,7 +486,7 @@ func (d *simpleDecDriver) DecodeNaked() {
// - Integers (intXXX, uintXXX) are encoded in 1, 2, 4 or 8 bytes (plus a descriptor byte).
// There are positive (uintXXX and intXXX >= 0) and negative (intXXX < 0) integers.
// - Floats are encoded in 4 or 8 bytes (plus a descriptor byte)
-// - Length of containers (strings, bytes, array, map, extensions)
+// - Lenght of containers (strings, bytes, array, map, extensions)
// are encoded in 0, 1, 2, 4 or 8 bytes.
// Zero-length containers have no length encoded.
// For others, the number of bytes is given by pow(2, bd%3)
@@ -606,45 +494,31 @@ func (d *simpleDecDriver) DecodeNaked() {
// - arrays are encoded as [bd] [length] [value]...
// - extensions are encoded as [bd] [length] [tag] [byte]...
// - strings/bytearrays are encoded as [bd] [length] [byte]...
-// - time.Time are encoded as [bd] [length] [byte]...
//
// The full spec will be published soon.
type SimpleHandle struct {
BasicHandle
binaryEncodingType
- noElemSeparators
- // EncZeroValuesAsNil says to encode zero values for numbers, bool, string, etc as nil
- EncZeroValuesAsNil bool
-
- // _ [1]uint64 // padding
}
-// 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{}})
+ return h.SetExt(rt, tag, &setExtWrapper{b: ext})
}
-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) newDecDriver(d *Decoder) decDriver {
- return &simpleDecDriver{d: d, h: h, r: d.r, br: d.bytes}
+ return &simpleDecDriver{d: d, r: d.r, h: h, br: d.bytes}
}
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.r = d.d.r
d.bd, d.bdRead = 0, false
}
diff --git a/vendor/github.com/ugorji/go/codec/test.py b/vendor/github.com/ugorji/go/codec/test.py
index 800376f684..c0ad20b34c 100755
--- a/vendor/github.com/ugorji/go/codec/test.py
+++ b/vendor/github.com/ugorji/go/codec/test.py
@@ -34,7 +34,7 @@ def get_test_data_list():
True,
u"null",
None,
- u"some&day>some 0
@@ -96,14 +96,14 @@ def doRpcServer(port, stopTimeSec):
server.start()
def doRpcClientToPythonSvc(port):
- address = msgpackrpc.Address('127.0.0.1', port)
+ address = msgpackrpc.Address('localhost', port)
client = msgpackrpc.Client(address, unpack_encoding='utf-8')
print client.call("Echo123", "A1", "B2", "C3")
print client.call("EchoStruct", {"A" :"Aa", "B":"Bb", "C":"Cc"})
def doRpcClientToGoSvc(port):
# print ">>>> port: ", port, " <<<<<"
- address = msgpackrpc.Address('127.0.0.1', port)
+ address = msgpackrpc.Address('localhost', port)
client = msgpackrpc.Client(address, unpack_encoding='utf-8')
print client.call("TestRpcInt.Echo123", ["A1", "B2", "C3"])
print client.call("TestRpcInt.EchoStruct", {"A" :"Aa", "B":"Bb", "C":"Cc"})
diff --git a/vendor/github.com/ugorji/go/codec/tests.sh b/vendor/github.com/ugorji/go/codec/tests.sh
new file mode 100755
index 0000000000..00857b6209
--- /dev/null
+++ b/vendor/github.com/ugorji/go/codec/tests.sh
@@ -0,0 +1,80 @@
+#!/bin/bash
+
+# Run all the different permutations of all the tests.
+# This helps ensure that nothing gets broken.
+
+_run() {
+ # 1. VARIATIONS: regular (t), canonical (c), IO R/W (i),
+ # binc-nosymbols (n), struct2array (s), intern string (e),
+ # json-indent (d), circular (l)
+ # 2. MODE: reflection (r), external (x), codecgen (g), unsafe (u), notfastpath (f)
+ # 3. OPTIONS: verbose (v), reset (z), must (m),
+ #
+ # Use combinations of mode to get exactly what you want,
+ # and then pass the variations you need.
+
+ ztags=""
+ zargs=""
+ local OPTIND
+ OPTIND=1
+ while getopts "_xurtcinsvgzmefdl" flag
+ do
+ case "x$flag" in
+ 'xr') ;;
+ 'xf') ztags="$ztags notfastpath" ;;
+ 'xg') ztags="$ztags codecgen" ;;
+ 'xx') ztags="$ztags x" ;;
+ 'xu') ztags="$ztags unsafe" ;;
+ 'xv') zargs="$zargs -tv" ;;
+ 'xz') zargs="$zargs -tr" ;;
+ 'xm') zargs="$zargs -tm" ;;
+ 'xl') zargs="$zargs -tl" ;;
+ *) ;;
+ esac
+ done
+ # shift $((OPTIND-1))
+ printf '............. TAGS: %s .............\n' "$ztags"
+ # echo ">>>>>>> TAGS: $ztags"
+
+ OPTIND=1
+ while getopts "_xurtcinsvgzmefdl" flag
+ do
+ case "x$flag" in
+ 'xt') printf ">>>>>>> REGULAR : "; go test "-tags=$ztags" $zargs ; sleep 2 ;;
+ 'xc') printf ">>>>>>> CANONICAL : "; go test "-tags=$ztags" $zargs -tc; sleep 2 ;;
+ 'xi') printf ">>>>>>> I/O : "; go test "-tags=$ztags" $zargs -ti; sleep 2 ;;
+ 'xn') printf ">>>>>>> NO_SYMBOLS : "; go test "-tags=$ztags" -run=Binc $zargs -tn; sleep 2 ;;
+ 'xs') printf ">>>>>>> TO_ARRAY : "; go test "-tags=$ztags" $zargs -ts; sleep 2 ;;
+ 'xe') printf ">>>>>>> INTERN : "; go test "-tags=$ztags" $zargs -te; sleep 2 ;;
+ 'xd') printf ">>>>>>> INDENT : ";
+ go test "-tags=$ztags" -run=JsonCodecsTable -td=-1 $zargs;
+ go test "-tags=$ztags" -run=JsonCodecsTable -td=8 $zargs;
+ sleep 2 ;;
+ *) ;;
+ esac
+ done
+ shift $((OPTIND-1))
+
+ OPTIND=1
+}
+
+# echo ">>>>>>> RUNNING VARIATIONS OF TESTS"
+if [[ "x$@" = "x" ]]; then
+ # All: r, x, g, gu
+ _run "-_tcinsed_ml" # regular
+ _run "-_tcinsed_ml_z" # regular with reset
+ _run "-_tcinsed_ml_f" # regular with no fastpath (notfastpath)
+ _run "-x_tcinsed_ml" # external
+ _run "-gx_tcinsed_ml" # codecgen: requires external
+ _run "-gxu_tcinsed_ml" # codecgen + unsafe
+elif [[ "x$@" = "x-Z" ]]; then
+ # Regular
+ _run "-_tcinsed_ml" # regular
+ _run "-_tcinsed_ml_z" # regular with reset
+elif [[ "x$@" = "x-F" ]]; then
+ # regular with notfastpath
+ _run "-_tcinsed_ml_f" # regular
+ _run "-_tcinsed_ml_zf" # regular with reset
+else
+ _run "$@"
+fi
diff --git a/vendor/github.com/ugorji/go/codec/time.go b/vendor/github.com/ugorji/go/codec/time.go
new file mode 100644
index 0000000000..718b731ec5
--- /dev/null
+++ b/vendor/github.com/ugorji/go/codec/time.go
@@ -0,0 +1,233 @@
+// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved.
+// Use of this source code is governed by a MIT license found in the LICENSE file.
+
+package codec
+
+import (
+ "fmt"
+ "reflect"
+ "time"
+)
+
+var (
+ timeDigits = [...]byte{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'}
+ timeExtEncFn = func(rv reflect.Value) (bs []byte, err error) {
+ defer panicToErr(&err)
+ bs = timeExt{}.WriteExt(rv.Interface())
+ return
+ }
+ timeExtDecFn = func(rv reflect.Value, bs []byte) (err error) {
+ defer panicToErr(&err)
+ timeExt{}.ReadExt(rv.Interface(), bs)
+ return
+ }
+)
+
+type timeExt struct{}
+
+func (x timeExt) WriteExt(v interface{}) (bs []byte) {
+ switch v2 := v.(type) {
+ case time.Time:
+ bs = encodeTime(v2)
+ case *time.Time:
+ bs = encodeTime(*v2)
+ default:
+ panic(fmt.Errorf("unsupported format for time conversion: expecting time.Time; got %T", v2))
+ }
+ return
+}
+func (x timeExt) ReadExt(v interface{}, bs []byte) {
+ tt, err := decodeTime(bs)
+ if err != nil {
+ panic(err)
+ }
+ *(v.(*time.Time)) = tt
+}
+
+func (x timeExt) ConvertExt(v interface{}) interface{} {
+ return x.WriteExt(v)
+}
+func (x timeExt) UpdateExt(v interface{}, src interface{}) {
+ x.ReadExt(v, src.([]byte))
+}
+
+// EncodeTime encodes a time.Time as a []byte, including
+// information on the instant in time and UTC offset.
+//
+// Format Description
+//
+// A timestamp is composed of 3 components:
+//
+// - secs: signed integer representing seconds since unix epoch
+// - nsces: unsigned integer representing fractional seconds as a
+// nanosecond offset within secs, in the range 0 <= nsecs < 1e9
+// - tz: signed integer representing timezone offset in minutes east of UTC,
+// and a dst (daylight savings time) flag
+//
+// When encoding a timestamp, the first byte is the descriptor, which
+// defines which components are encoded and how many bytes are used to
+// encode secs and nsecs components. *If secs/nsecs is 0 or tz is UTC, it
+// is not encoded in the byte array explicitly*.
+//
+// Descriptor 8 bits are of the form `A B C DDD EE`:
+// A: Is secs component encoded? 1 = true
+// B: Is nsecs component encoded? 1 = true
+// C: Is tz component encoded? 1 = true
+// DDD: Number of extra bytes for secs (range 0-7).
+// If A = 1, secs encoded in DDD+1 bytes.
+// If A = 0, secs is not encoded, and is assumed to be 0.
+// If A = 1, then we need at least 1 byte to encode secs.
+// DDD says the number of extra bytes beyond that 1.
+// E.g. if DDD=0, then secs is represented in 1 byte.
+// if DDD=2, then secs is represented in 3 bytes.
+// EE: Number of extra bytes for nsecs (range 0-3).
+// If B = 1, nsecs encoded in EE+1 bytes (similar to secs/DDD above)
+//
+// Following the descriptor bytes, subsequent bytes are:
+//
+// secs component encoded in `DDD + 1` bytes (if A == 1)
+// nsecs component encoded in `EE + 1` bytes (if B == 1)
+// tz component encoded in 2 bytes (if C == 1)
+//
+// secs and nsecs components are integers encoded in a BigEndian
+// 2-complement encoding format.
+//
+// tz component is encoded as 2 bytes (16 bits). Most significant bit 15 to
+// Least significant bit 0 are described below:
+//
+// Timezone offset has a range of -12:00 to +14:00 (ie -720 to +840 minutes).
+// Bit 15 = have\_dst: set to 1 if we set the dst flag.
+// Bit 14 = dst\_on: set to 1 if dst is in effect at the time, or 0 if not.
+// Bits 13..0 = timezone offset in minutes. It is a signed integer in Big Endian format.
+//
+func encodeTime(t time.Time) []byte {
+ //t := rv.Interface().(time.Time)
+ tsecs, tnsecs := t.Unix(), t.Nanosecond()
+ var (
+ bd byte
+ btmp [8]byte
+ bs [16]byte
+ i int = 1
+ )
+ l := t.Location()
+ if l == time.UTC {
+ l = nil
+ }
+ if tsecs != 0 {
+ bd = bd | 0x80
+ bigen.PutUint64(btmp[:], uint64(tsecs))
+ f := pruneSignExt(btmp[:], tsecs >= 0)
+ bd = bd | (byte(7-f) << 2)
+ copy(bs[i:], btmp[f:])
+ i = i + (8 - f)
+ }
+ if tnsecs != 0 {
+ bd = bd | 0x40
+ bigen.PutUint32(btmp[:4], uint32(tnsecs))
+ f := pruneSignExt(btmp[:4], true)
+ bd = bd | byte(3-f)
+ copy(bs[i:], btmp[f:4])
+ i = i + (4 - f)
+ }
+ if l != nil {
+ bd = bd | 0x20
+ // Note that Go Libs do not give access to dst flag.
+ _, zoneOffset := t.Zone()
+ //zoneName, zoneOffset := t.Zone()
+ zoneOffset /= 60
+ z := uint16(zoneOffset)
+ bigen.PutUint16(btmp[:2], z)
+ // clear dst flags
+ bs[i] = btmp[0] & 0x3f
+ bs[i+1] = btmp[1]
+ i = i + 2
+ }
+ bs[0] = bd
+ return bs[0:i]
+}
+
+// DecodeTime decodes a []byte into a time.Time.
+func decodeTime(bs []byte) (tt time.Time, err error) {
+ bd := bs[0]
+ var (
+ tsec int64
+ tnsec uint32
+ tz uint16
+ i byte = 1
+ i2 byte
+ n byte
+ )
+ if bd&(1<<7) != 0 {
+ var btmp [8]byte
+ 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 bs[i]&(1<<7) != 0 {
+ copy(btmp[0:8-n], bsAll0xff)
+ //for j,k := byte(0), 8-n; j < k; j++ { btmp[j] = 0xff }
+ }
+ i = i2
+ tsec = int64(bigen.Uint64(btmp[:]))
+ }
+ if bd&(1<<6) != 0 {
+ var btmp [4]byte
+ n = (bd & 0x3) + 1
+ i2 = i + n
+ copy(btmp[4-n:], bs[i:i2])
+ i = i2
+ tnsec = bigen.Uint32(btmp[:])
+ }
+ if bd&(1<<5) == 0 {
+ tt = time.Unix(tsec, int64(tnsec)).UTC()
+ 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.
+ // Zone name is in form: UTC-08:00.
+ // Note that Go Libs do not give access to dst flag, so we ignore dst bits
+
+ i2 = i + 2
+ tz = bigen.Uint16(bs[i:i2])
+ i = i2
+ // sign extend sign bit into top 2 MSB (which were dst bits):
+ if tz&(1<<13) == 0 { // positive
+ tz = tz & 0x3fff //clear 2 MSBs: dst bits
+ } else { // negative
+ tz = tz | 0xc000 //set 2 MSBs: dst bits
+ //tzname[3] = '-' (TODO: verify. this works here)
+ }
+ tzint := int16(tz)
+ if tzint == 0 {
+ tt = time.Unix(tsec, int64(tnsec)).UTC()
+ } else {
+ // For Go Time, do not use a descriptive timezone.
+ // It's unnecessary, and makes it harder to do a reflect.DeepEqual.
+ // The Offset already tells what the offset should be, if not on UTC and unknown zone name.
+ // var zoneName = timeLocUTCName(tzint)
+ tt = time.Unix(tsec, int64(tnsec)).In(time.FixedZone("", int(tzint)*60))
+ }
+ 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] = '-' // (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)
+}
diff --git a/vendor/github.com/ugorji/go/codec/xml.go b/vendor/github.com/ugorji/go/codec/xml.go
deleted file mode 100644
index 19fc36caf3..0000000000
--- a/vendor/github.com/ugorji/go/codec/xml.go
+++ /dev/null
@@ -1,508 +0,0 @@
-// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved.
-// Use of this source code is governed by a MIT license found in the LICENSE file.
-
-// +build ignore
-
-package codec
-
-import "reflect"
-
-/*
-
-A strict Non-validating namespace-aware XML 1.0 parser and (en|de)coder.
-
-We are attempting this due to perceived issues with encoding/xml:
- - Complicated. It tried to do too much, and is not as simple to use as json.
- - Due to over-engineering, reflection is over-used AND performance suffers:
- java is 6X faster:http://fabsk.eu/blog/category/informatique/dev/golang/
- even PYTHON performs better: http://outgoing.typepad.com/outgoing/2014/07/exploring-golang.html
-
-codec framework will offer the following benefits
- - VASTLY improved performance (when using reflection-mode or codecgen)
- - simplicity and consistency: with the rest of the supported formats
- - all other benefits of codec framework (streaming, codegeneration, etc)
-
-codec is not a drop-in replacement for encoding/xml.
-It is a replacement, based on the simplicity and performance of codec.
-Look at it like JAXB for Go.
-
-Challenges:
- - Need to output XML preamble, with all namespaces at the right location in the output.
- - Each "end" block is dynamic, so we need to maintain a context-aware stack
- - How to decide when to use an attribute VS an element
- - How to handle chardata, attr, comment EXPLICITLY.
- - Should it output fragments?
- e.g. encoding a bool should just output true OR false, which is not well-formed XML.
-
-Extend the struct tag. See representative example:
- type X struct {
- ID uint8 `codec:"http://ugorji.net/x-namespace xid id,omitempty,toarray,attr,cdata"`
- // format: [namespace-uri ][namespace-prefix ]local-name, ...
- }
-
-Based on this, we encode
- - fields as elements, BUT
- encode as attributes if struct tag contains ",attr" and is a scalar (bool, number or string)
- - text as entity-escaped text, BUT encode as CDATA if struct tag contains ",cdata".
-
-To handle namespaces:
- - XMLHandle is denoted as being namespace-aware.
- Consequently, we WILL use the ns:name pair to encode and decode if defined, else use the plain name.
- - *Encoder and *Decoder know whether the Handle "prefers" namespaces.
- - add *Encoder.getEncName(*structFieldInfo).
- No one calls *structFieldInfo.indexForEncName directly anymore
- - OR better yet: indexForEncName is namespace-aware, and helper.go is all namespace-aware
- indexForEncName takes a parameter of the form namespace:local-name OR local-name
- - add *Decoder.getStructFieldInfo(encName string) // encName here is either like abc, or h1:nsabc
- by being a method on *Decoder, or maybe a method on the Handle itself.
- No one accesses .encName anymore
- - let encode.go and decode.go use these (for consistency)
- - only problem exists for gen.go, where we create a big switch on encName.
- Now, we also have to add a switch on strings.endsWith(kName, encNsName)
- - gen.go will need to have many more methods, and then double-on the 2 switch loops like:
- switch k {
- case "abc" : x.abc()
- case "def" : x.def()
- default {
- switch {
- case !nsAware: panic(...)
- case strings.endsWith(":abc"): x.abc()
- case strings.endsWith(":def"): x.def()
- default: panic(...)
- }
- }
- }
-
-The structure below accommodates this:
-
- type typeInfo struct {
- sfi []*structFieldInfo // sorted by encName
- sfins // sorted by namespace
- sfia // sorted, to have those with attributes at the top. Needed to write XML appropriately.
- sfip // unsorted
- }
- type structFieldInfo struct {
- encName
- nsEncName
- ns string
- attr bool
- cdata bool
- }
-
-indexForEncName is now an internal helper function that takes a sorted array
-(one of ti.sfins or ti.sfi). It is only used by *Encoder.getStructFieldInfo(...)
-
-There will be a separate parser from the builder.
-The parser will have a method: next() xmlToken method. It has lookahead support,
-so you can pop multiple tokens, make a determination, and push them back in the order popped.
-This will be needed to determine whether we are "nakedly" decoding a container or not.
-The stack will be implemented using a slice and push/pop happens at the [0] element.
-
-xmlToken has fields:
- - type uint8: 0 | ElementStart | ElementEnd | AttrKey | AttrVal | Text
- - value string
- - ns string
-
-SEE: http://www.xml.com/pub/a/98/10/guide0.html?page=3#ENTDECL
-
-The following are skipped when parsing:
- - External Entities (from external file)
- - Notation Declaration e.g.
- - Entity Declarations & References
- - XML Declaration (assume UTF-8)
- - XML Directive i.e.
- - Other Declarations: Notation, etc.
- - Comment
- - Processing Instruction
- - schema / DTD for validation:
- We are not a VALIDATING parser. Validation is done elsewhere.
- However, some parts of the DTD internal subset are used (SEE BELOW).
- For Attribute List Declarations e.g.
-
- We considered using the ATTLIST to get "default" value, but not to validate the contents. (VETOED)
-
-The following XML features are supported
- - Namespace
- - Element
- - Attribute
- - cdata
- - Unicode escape
-
-The following DTD (when as an internal sub-set) features are supported:
- - Internal Entities e.g.
- AND entities for the set: [<>&"']
- - Parameter entities e.g.
-
-
-At decode time, a structure containing the following is kept
- - namespace mapping
- - default attribute values
- - all internal entities (<>&"' and others written in the document)
-
-When decode starts, it parses XML namespace declarations and creates a map in the
-xmlDecDriver. While parsing, that map continuously gets updated.
-The only problem happens when a namespace declaration happens on the node that it defines.
-e.g.
-To handle this, each Element must be fully parsed at a time,
-even if it amounts to multiple tokens which are returned one at a time on request.
-
-xmlns is a special attribute name.
- - It is used to define namespaces, including the default
- - It is never returned as an AttrKey or AttrVal.
- *We may decide later to allow user to use it e.g. you want to parse the xmlns mappings into a field.*
-
-Number, bool, null, mapKey, etc can all be decoded from any xmlToken.
-This accommodates map[int]string for example.
-
-It should be possible to create a schema from the types,
-or vice versa (generate types from schema with appropriate tags).
-This is however out-of-scope from this parsing project.
-
-We should write all namespace information at the first point that it is referenced in the tree,
-and use the mapping for all child nodes and attributes. This means that state is maintained
-at a point in the tree. This also means that calls to Decode or MustDecode will reset some state.
-
-When decoding, it is important to keep track of entity references and default attribute values.
-It seems these can only be stored in the DTD components. We should honor them when decoding.
-
-Configuration for XMLHandle will look like this:
-
- XMLHandle
- DefaultNS string
- // Encoding:
- NS map[string]string // ns URI to key, used for encoding
- // Decoding: in case ENTITY declared in external schema or dtd, store info needed here
- Entities map[string]string // map of entity rep to character
-
-
-During encode, if a namespace mapping is not defined for a namespace found on a struct,
-then we create a mapping for it using nsN (where N is 1..1000000, and doesn't conflict
-with any other namespace mapping).
-
-Note that different fields in a struct can have different namespaces.
-However, all fields will default to the namespace on the _struct field (if defined).
-
-An XML document is a name, a map of attributes and a list of children.
-Consequently, we cannot "DecodeNaked" into a map[string]interface{} (for example).
-We have to "DecodeNaked" into something that resembles XML data.
-
-To support DecodeNaked (decode into nil interface{}), we have to define some "supporting" types:
- type Name struct { // Preferred. Less allocations due to conversions.
- Local string
- Space string
- }
- type Element struct {
- Name Name
- Attrs map[Name]string
- Children []interface{} // each child is either *Element or string
- }
-Only two "supporting" types are exposed for XML: Name and Element.
-
-// ------------------
-
-We considered 'type Name string' where Name is like "Space Local" (space-separated).
-We decided against it, because each creation of a name would lead to
-double allocation (first convert []byte to string, then concatenate them into a string).
-The benefit is that it is faster to read Attrs from a map. But given that Element is a value
-object, we want to eschew methods and have public exposed variables.
-
-We also considered the following, where xml types were not value objects, and we used
-intelligent accessor methods to extract information and for performance.
-*** WE DECIDED AGAINST THIS. ***
- type Attr struct {
- Name Name
- Value string
- }
- // Element is a ValueObject: There are no accessor methods.
- // Make element self-contained.
- type Element struct {
- Name Name
- attrsMap map[string]string // where key is "Space Local"
- attrs []Attr
- childrenT []string
- childrenE []Element
- childrenI []int // each child is a index into T or E.
- }
- func (x *Element) child(i) interface{} // returns string or *Element
-
-// ------------------
-
-Per XML spec and our default handling, white space is always treated as
-insignificant between elements, except in a text node. The xml:space='preserve'
-attribute is ignored.
-
-**Note: there is no xml: namespace. The xml: attributes were defined before namespaces.**
-**So treat them as just "directives" that should be interpreted to mean something**.
-
-On encoding, we support indenting aka prettifying markup in the same way we support it for json.
-
-A document or element can only be encoded/decoded from/to a struct. In this mode:
- - struct name maps to element name (or tag-info from _struct field)
- - fields are mapped to child elements or attributes
-
-A map is either encoded as attributes on current element, or as a set of child elements.
-Maps are encoded as attributes iff their keys and values are primitives (number, bool, string).
-
-A list is encoded as a set of child elements.
-
-Primitives (number, bool, string) are encoded as an element, attribute or text
-depending on the context.
-
-Extensions must encode themselves as a text string.
-
-Encoding is tough, specifically when encoding mappings, because we need to encode
-as either attribute or element. To do this, we need to default to encoding as attributes,
-and then let Encoder inform the Handle when to start encoding as nodes.
-i.e. Encoder does something like:
-
- h.EncodeMapStart()
- h.Encode(), h.Encode(), ...
- h.EncodeMapNotAttrSignal() // this is not a bool, because it's a signal
- h.Encode(), h.Encode(), ...
- h.EncodeEnd()
-
-Only XMLHandle understands this, and will set itself to start encoding as elements.
-
-This support extends to maps. For example, if a struct field is a map, and it has
-the struct tag signifying it should be attr, then all its fields are encoded as attributes.
-e.g.
-
- type X struct {
- M map[string]int `codec:"m,attr"` // encode keys as attributes named
- }
-
-Question:
- - if encoding a map, what if map keys have spaces in them???
- Then they cannot be attributes or child elements. Error.
-
-Options to consider adding later:
- - For attribute values, normalize by trimming beginning and ending white space,
- and converting every white space sequence to a single space.
- - ATTLIST restrictions are enforced.
- e.g. default value of xml:space, skipping xml:XYZ style attributes, etc.
- - Consider supporting NON-STRICT mode (e.g. to handle HTML parsing).
- Some elements e.g. br, hr, etc need not close and should be auto-closed
- ... (see http://www.w3.org/TR/html4/loose.dtd)
- An expansive set of entities are pre-defined.
- - Have easy way to create a HTML parser:
- add a HTML() method to XMLHandle, that will set Strict=false, specify AutoClose,
- and add HTML Entities to the list.
- - Support validating element/attribute XMLName before writing it.
- Keep this behind a flag, which is set to false by default (for performance).
- type XMLHandle struct {
- CheckName bool
- }
-
-Misc:
-
-ROADMAP (1 weeks):
- - build encoder (1 day)
- - build decoder (based off xmlParser) (1 day)
- - implement xmlParser (2 days).
- Look at encoding/xml for inspiration.
- - integrate and TEST (1 days)
- - write article and post it (1 day)
-
-// ---------- MORE NOTES FROM 2017-11-30 ------------
-
-when parsing
-- parse the attributes first
-- then parse the nodes
-
-basically:
-- if encoding a field: we use the field name for the wrapper
-- if encoding a non-field, then just use the element type name
-
- map[string]string ==> ... or
- ... OR
- val1val2... <- PREFERED
- []string ==> v1v2...
- string v1 ==> v1
- bool true ==> true
- float 1.0 ==> 1.0
- ...
-
- F1 map[string]string ==> abcval... OR
- val... OR
- val... <- PREFERED
- F2 []string ==> v1v2...
- F3 bool ==> true
- ...
-
-- a scalar is encoded as:
- (value) of type T ==>
- (value) of field F ==>
-- A kv-pair is encoded as:
- (key,value) ==> OR