Skip to content
This repository has been archived by the owner on Dec 14, 2020. It is now read-only.

Commit

Permalink
Use lookup table in readAny
Browse files Browse the repository at this point in the history
This doesn't make any noticible performance difference.

name                                  old time/op    new time/op    delta
Marshal/*amqp.performOpen-8             1.84µs ± 1%    1.83µs ± 1%    ~     (p=0.055 n=10+10)
Marshal/*amqp.performBegin-8            1.45µs ± 1%    1.47µs ± 2%  +1.12%  (p=0.004 n=10+10)
Marshal/*amqp.performAttach-8           5.20µs ± 2%    5.17µs ± 1%    ~     (p=0.089 n=10+10)
Marshal/amqp.role-8                     30.6ns ± 5%    30.7ns ± 4%    ~     (p=0.970 n=10+10)
Marshal/*amqp.unsettled-8                368ns ± 4%     372ns ± 2%    ~     (p=0.138 n=10+9)
Marshal/*amqp.source-8                  1.96µs ± 2%    1.93µs ± 2%  -1.31%  (p=0.007 n=10+10)
Marshal/*amqp.target-8                  1.15µs ± 2%    1.14µs ± 2%    ~     (p=0.468 n=10+10)
Marshal/*amqp.performFlow-8             1.18µs ± 1%    1.17µs ± 1%    ~     (p=0.591 n=10+10)
Marshal/*amqp.performTransfer-8          833ns ± 1%     832ns ± 1%    ~     (p=0.983 n=10+10)
Marshal/*amqp.performDisposition-8       412ns ± 2%     414ns ± 1%    ~     (p=0.464 n=10+10)
Marshal/*amqp.performDetach-8           1.31µs ± 1%    1.32µs ± 2%    ~     (p=0.764 n=9+10)
Marshal/amqp.ErrorCondition-8            115ns ± 1%     115ns ± 2%    ~     (p=0.698 n=10+10)
Marshal/*amqp.Error-8                   1.05µs ± 3%    1.06µs ± 4%    ~     (p=0.810 n=10+10)
Marshal/*amqp.performEnd-8              1.23µs ± 2%    1.23µs ± 2%    ~     (p=0.528 n=10+10)
Marshal/*amqp.performClose-8            1.23µs ± 2%    1.24µs ± 2%    ~     (p=0.109 n=10+10)
Marshal/*amqp.Message-8                 3.72µs ± 1%    3.70µs ± 4%    ~     (p=0.258 n=9+9)
Marshal/*amqp.MessageHeader-8            396ns ± 1%     394ns ± 1%    ~     (p=0.135 n=10+10)
Marshal/*amqp.MessageProperties-8       1.57µs ± 1%    1.57µs ± 1%    ~     (p=0.541 n=10+10)
Marshal/*amqp.stateReceived-8            294ns ± 2%     291ns ± 1%  -0.97%  (p=0.004 n=10+8)
Marshal/*amqp.stateAccepted-8           37.5ns ± 1%    37.4ns ± 2%    ~     (p=0.403 n=10+10)
Marshal/*amqp.stateRejected-8           1.25µs ± 2%    1.24µs ± 2%    ~     (p=0.447 n=10+10)
Marshal/*amqp.stateReleased-8           37.7ns ± 2%    38.1ns ± 2%    ~     (p=0.084 n=10+10)
Marshal/*amqp.stateModified-8            594ns ± 2%     593ns ± 2%    ~     (p=0.766 n=9+10)
Marshal/amqp.UUID-8                     50.8ns ± 5%    49.6ns ± 5%    ~     (p=0.138 n=10+10)
Marshal/amqp.lifetimePolicy-8           35.9ns ± 2%    35.5ns ± 1%  -1.23%  (p=0.007 n=10+10)
Marshal/amqp.SenderSettleMode-8         45.6ns ± 2%    44.1ns ± 2%  -3.18%  (p=0.000 n=9+10)
Marshal/amqp.ReceiverSettleMode-8       45.8ns ± 3%    44.7ns ± 2%  -2.38%  (p=0.002 n=10+10)
Marshal/bool-8                          16.0ns ± 6%    16.1ns ± 8%    ~     (p=0.856 n=10+9)
Marshal/int8-8                          49.7ns ± 1%    49.0ns ± 1%  -1.33%  (p=0.001 n=10+10)
Marshal/int8#01-8                       49.6ns ± 1%    48.7ns ± 1%  -1.81%  (p=0.000 n=10+10)
Marshal/int16-8                         66.9ns ± 2%    67.0ns ± 1%    ~     (p=0.537 n=10+10)
Marshal/int16#01-8                      67.3ns ± 1%    67.0ns ± 1%    ~     (p=0.087 n=10+10)
Marshal/int32-8                         67.0ns ± 2%    67.2ns ± 1%    ~     (p=0.230 n=9+10)
Marshal/int32#01-8                      67.3ns ± 1%    67.4ns ± 1%    ~     (p=0.457 n=10+9)
Marshal/int64-8                         68.6ns ± 1%    68.6ns ± 1%    ~     (p=0.753 n=10+10)
Marshal/int64#01-8                      68.7ns ± 2%    68.6ns ± 1%    ~     (p=0.868 n=10+10)
Marshal/uint8-8                         30.4ns ± 4%    30.4ns ± 2%    ~     (p=0.669 n=10+10)
Marshal/uint16-8                        67.1ns ± 2%    68.0ns ± 2%  +1.43%  (p=0.015 n=10+10)
Marshal/uint32-8                        68.3ns ± 1%    67.1ns ± 1%  -1.79%  (p=0.000 n=10+10)
Marshal/uint64-8                        68.8ns ± 2%    68.4ns ± 1%    ~     (p=0.085 n=10+10)
Marshal/amqp.describedType-8             293ns ±11%     301ns ± 9%    ~     (p=0.305 n=10+10)
Marshal/*amqp.saslInit-8                 467ns ± 1%     459ns ± 1%  -1.72%  (p=0.000 n=10+9)
Marshal/*amqp.saslMechanisms-8           500ns ± 1%     499ns ± 2%    ~     (p=0.565 n=10+10)
Marshal/*amqp.saslOutcome-8              318ns ± 2%     314ns ± 1%  -1.07%  (p=0.004 n=10+10)
Marshal/amqp.symbol-8                   72.0ns ± 2%    72.4ns ± 2%    ~     (p=0.224 n=10+10)
Marshal/amqp.milliseconds-8             93.0ns ± 1%    91.2ns ± 1%  -1.97%  (p=0.000 n=10+10)
Marshal/*amqp.mapAnyAny-8                398ns ± 5%     393ns ± 6%    ~     (p=0.535 n=10+9)
Marshal/*amqp.mapStringAny-8             412ns ± 4%     414ns ± 8%    ~     (p=0.983 n=8+10)
Marshal/*amqp.mapSymbolAny-8             411ns ±12%     405ns ±10%    ~     (p=0.515 n=10+10)
Unmarshal/*amqp.performOpen-8           1.91µs ± 8%    1.90µs ± 3%    ~     (p=0.950 n=10+9)
Unmarshal/*amqp.performBegin-8          1.79µs ±11%    1.71µs ±11%    ~     (p=0.165 n=10+10)
Unmarshal/*amqp.performAttach-8         7.46µs ±10%    7.51µs ± 8%    ~     (p=0.699 n=10+10)
Unmarshal/amqp.role-8                    243ns ±16%     241ns ±14%    ~     (p=0.809 n=10+10)
Unmarshal/*amqp.unsettled-8             1.36µs ±15%    1.32µs ±16%    ~     (p=0.425 n=10+10)
Unmarshal/*amqp.source-8                2.69µs ±10%    2.70µs ± 9%    ~     (p=0.971 n=10+10)
Unmarshal/*amqp.target-8                1.58µs ± 7%    1.58µs ±10%    ~     (p=0.702 n=10+9)
Unmarshal/*amqp.performFlow-8           2.00µs ± 1%    1.98µs ± 1%  -0.80%  (p=0.050 n=10+10)
Unmarshal/*amqp.performTransfer-8       1.92µs ± 1%    1.92µs ± 1%    ~     (p=0.270 n=10+10)
Unmarshal/*amqp.performDisposition-8    1.06µs ± 1%    1.06µs ± 2%    ~     (p=0.986 n=9+10)
Unmarshal/*amqp.performDetach-8         2.19µs ± 3%    2.23µs ± 3%    ~     (p=0.247 n=10+10)
Unmarshal/amqp.ErrorCondition-8          281ns ±12%     292ns ±17%    ~     (p=0.250 n=9+10)
Unmarshal/*amqp.Error-8                 1.86µs ± 3%    1.93µs ± 9%  +3.69%  (p=0.046 n=10+10)
Unmarshal/*amqp.performEnd-8            2.04µs ± 4%    2.04µs ± 3%    ~     (p=0.869 n=10+10)
Unmarshal/*amqp.performClose-8          2.05µs ± 5%    2.05µs ± 3%    ~     (p=0.671 n=10+10)
Unmarshal/*amqp.Message-8               6.93µs ± 9%    6.95µs ± 6%    ~     (p=1.000 n=10+10)
Unmarshal/*amqp.MessageHeader-8          662ns ± 1%     662ns ± 2%    ~     (p=0.900 n=10+10)
Unmarshal/*amqp.MessageProperties-8     1.50µs ± 0%    1.52µs ± 1%  +1.68%  (p=0.000 n=7+10)
Unmarshal/*amqp.stateReceived-8          515ns ± 7%     512ns ± 4%    ~     (p=0.897 n=10+10)
Unmarshal/*amqp.stateAccepted-8          286ns ±10%     285ns ±12%    ~     (p=0.896 n=10+10)
Unmarshal/*amqp.stateRejected-8         2.05µs ± 4%    2.04µs ± 3%    ~     (p=0.650 n=9+9)
Unmarshal/*amqp.stateReleased-8          279ns ± 9%     278ns ±12%    ~     (p=0.845 n=8+10)
Unmarshal/*amqp.stateModified-8         1.15µs ±10%    1.10µs ±10%    ~     (p=0.190 n=10+10)
Unmarshal/amqp.UUID-8                    239ns ±14%     255ns ±12%    ~     (p=0.108 n=10+10)
Unmarshal/amqp.lifetimePolicy-8          218ns ±21%     213ns ±14%    ~     (p=0.447 n=10+10)
Unmarshal/amqp.SenderSettleMode-8        249ns ±13%     252ns ±19%    ~     (p=0.684 n=10+10)
Unmarshal/amqp.ReceiverSettleMode-8      251ns ±13%     249ns ±11%    ~     (p=0.869 n=10+10)
Unmarshal/bool-8                         213ns ±12%     222ns ± 9%    ~     (p=0.098 n=9+10)
Unmarshal/int8-8                         227ns ±10%     217ns ±12%    ~     (p=0.305 n=10+9)
Unmarshal/int8#01-8                      224ns ±14%     221ns ±14%    ~     (p=0.644 n=10+10)
Unmarshal/int16-8                        218ns ±18%     225ns ±15%    ~     (p=0.579 n=10+10)
Unmarshal/int16#01-8                     223ns ± 9%     222ns ±20%    ~     (p=0.473 n=8+10)
Unmarshal/int32-8                        223ns ±14%     230ns ±21%    ~     (p=0.403 n=10+10)
Unmarshal/int32#01-8                     219ns ±17%     226ns ±12%    ~     (p=0.470 n=10+10)
Unmarshal/int64-8                        227ns ±19%     228ns ± 9%    ~     (p=0.725 n=10+10)
Unmarshal/int64#01-8                     218ns ±15%     220ns ±14%    ~     (p=0.675 n=10+9)
Unmarshal/uint8-8                        208ns ±22%     199ns ±30%    ~     (p=0.363 n=10+10)
Unmarshal/uint16-8                       209ns ±18%     215ns ±16%    ~     (p=0.343 n=10+10)
Unmarshal/uint32-8                       211ns ±13%     218ns ±21%    ~     (p=0.752 n=10+10)
Unmarshal/uint64-8                       222ns ±12%     217ns ±11%    ~     (p=0.644 n=10+10)
Unmarshal/amqp.describedType-8           463ns ±10%     485ns ±11%    ~     (p=0.148 n=10+10)
Unmarshal/*amqp.saslInit-8               613ns ± 2%     614ns ± 3%    ~     (p=0.810 n=10+10)
Unmarshal/*amqp.saslMechanisms-8         570ns ± 3%     579ns ± 4%    ~     (p=0.148 n=10+10)
Unmarshal/*amqp.saslOutcome-8            590ns ± 4%     581ns ± 3%    ~     (p=0.324 n=10+10)
Unmarshal/amqp.symbol-8                  248ns ±21%     248ns ± 8%    ~     (p=0.725 n=10+10)
Unmarshal/amqp.milliseconds-8            216ns ±12%     207ns ±18%    ~     (p=0.469 n=10+10)
Unmarshal/*amqp.mapAnyAny-8             1.36µs ±11%    1.30µs ±15%    ~     (p=0.182 n=9+10)
Unmarshal/*amqp.mapStringAny-8          1.28µs ±21%    1.32µs ±15%    ~     (p=0.481 n=10+10)
Unmarshal/*amqp.mapSymbolAny-8          1.08µs ±11%    1.05µs ± 8%    ~     (p=0.481 n=10+10)

name                                  old alloc/op   new alloc/op   delta
Marshal/*amqp.performOpen-8               448B ± 0%      448B ± 0%    ~     (all equal)
Marshal/*amqp.performBegin-8              344B ± 0%      344B ± 0%    ~     (all equal)
Marshal/*amqp.performAttach-8           1.44kB ± 0%    1.44kB ± 0%    ~     (all equal)
Marshal/amqp.role-8                      0.00B          0.00B         ~     (all equal)
Marshal/*amqp.unsettled-8                 152B ± 0%      152B ± 0%    ~     (all equal)
Marshal/*amqp.source-8                    584B ± 0%      584B ± 0%    ~     (all equal)
Marshal/*amqp.target-8                    320B ± 0%      320B ± 0%    ~     (all equal)
Marshal/*amqp.performFlow-8               296B ± 0%      296B ± 0%    ~     (all equal)
Marshal/*amqp.performTransfer-8           104B ± 0%      104B ± 0%    ~     (all equal)
Marshal/*amqp.performDisposition-8       48.0B ± 0%     48.0B ± 0%    ~     (all equal)
Marshal/*amqp.performDetach-8             352B ± 0%      352B ± 0%    ~     (all equal)
Marshal/amqp.ErrorCondition-8            34.0B ± 0%     34.0B ± 0%    ~     (all equal)
Marshal/*amqp.Error-8                     328B ± 0%      328B ± 0%    ~     (all equal)
Marshal/*amqp.performEnd-8                336B ± 0%      336B ± 0%    ~     (all equal)
Marshal/*amqp.performClose-8              336B ± 0%      336B ± 0%    ~     (all equal)
Marshal/*amqp.Message-8                 1.13kB ± 0%    1.13kB ± 0%    ~     (all equal)
Marshal/*amqp.MessageHeader-8            40.0B ± 0%     40.0B ± 0%    ~     (all equal)
Marshal/*amqp.MessageProperties-8         424B ± 0%      424B ± 0%    ~     (all equal)
Marshal/*amqp.stateReceived-8            48.0B ± 0%     48.0B ± 0%    ~     (all equal)
Marshal/*amqp.stateAccepted-8            4.00B ± 0%     4.00B ± 0%    ~     (all equal)
Marshal/*amqp.stateRejected-8             336B ± 0%      336B ± 0%    ~     (all equal)
Marshal/*amqp.stateReleased-8            4.00B ± 0%     4.00B ± 0%    ~     (all equal)
Marshal/*amqp.stateModified-8             168B ± 0%      168B ± 0%    ~     (all equal)
Marshal/amqp.UUID-8                      16.0B ± 0%     16.0B ± 0%    ~     (all equal)
Marshal/amqp.lifetimePolicy-8            4.00B ± 0%     4.00B ± 0%    ~     (all equal)
Marshal/amqp.SenderSettleMode-8          2.00B ± 0%     2.00B ± 0%    ~     (all equal)
Marshal/amqp.ReceiverSettleMode-8        2.00B ± 0%     2.00B ± 0%    ~     (all equal)
Marshal/bool-8                           0.00B          0.00B         ~     (all equal)
Marshal/int8-8                           8.00B ± 0%     8.00B ± 0%    ~     (all equal)
Marshal/int8#01-8                        8.00B ± 0%     8.00B ± 0%    ~     (all equal)
Marshal/int16-8                          16.0B ± 0%     16.0B ± 0%    ~     (all equal)
Marshal/int16#01-8                       16.0B ± 0%     16.0B ± 0%    ~     (all equal)
Marshal/int32-8                          16.0B ± 0%     16.0B ± 0%    ~     (all equal)
Marshal/int32#01-8                       16.0B ± 0%     16.0B ± 0%    ~     (all equal)
Marshal/int64-8                          16.0B ± 0%     16.0B ± 0%    ~     (all equal)
Marshal/int64#01-8                       16.0B ± 0%     16.0B ± 0%    ~     (all equal)
Marshal/uint8-8                          2.00B ± 0%     2.00B ± 0%    ~     (all equal)
Marshal/uint16-8                         16.0B ± 0%     16.0B ± 0%    ~     (all equal)
Marshal/uint32-8                         16.0B ± 0%     16.0B ± 0%    ~     (all equal)
Marshal/uint64-8                         16.0B ± 0%     16.0B ± 0%    ~     (all equal)
Marshal/amqp.describedType-8              120B ± 0%      120B ± 0%    ~     (all equal)
Marshal/*amqp.saslInit-8                  112B ± 0%      112B ± 0%    ~     (all equal)
Marshal/*amqp.saslMechanisms-8           72.0B ± 0%     72.0B ± 0%    ~     (all equal)
Marshal/*amqp.saslOutcome-8              74.0B ± 0%     74.0B ± 0%    ~     (all equal)
Marshal/amqp.symbol-8                    18.0B ± 0%     18.0B ± 0%    ~     (all equal)
Marshal/amqp.milliseconds-8              16.0B ± 0%     16.0B ± 0%    ~     (all equal)
Marshal/*amqp.mapAnyAny-8                 152B ± 0%      152B ± 0%    ~     (all equal)
Marshal/*amqp.mapStringAny-8              160B ± 0%      160B ± 0%    ~     (all equal)
Marshal/*amqp.mapSymbolAny-8              160B ± 0%      160B ± 0%    ~     (all equal)
Unmarshal/*amqp.performOpen-8             624B ± 0%      624B ± 0%    ~     (all equal)
Unmarshal/*amqp.performBegin-8            640B ± 0%      640B ± 0%    ~     (all equal)
Unmarshal/*amqp.performAttach-8         2.48kB ± 0%    2.48kB ± 0%    ~     (all equal)
Unmarshal/amqp.role-8                     112B ± 0%      112B ± 0%    ~     (all equal)
Unmarshal/*amqp.unsettled-8               592B ± 0%      592B ± 0%    ~     (all equal)
Unmarshal/*amqp.source-8                1.02kB ± 0%    1.02kB ± 0%    ~     (all equal)
Unmarshal/*amqp.target-8                  576B ± 0%      576B ± 0%    ~     (all equal)
Unmarshal/*amqp.performFlow-8             560B ± 0%      560B ± 0%    ~     (all equal)
Unmarshal/*amqp.performTransfer-8         296B ± 0%      296B ± 0%    ~     (all equal)
Unmarshal/*amqp.performDisposition-8      208B ± 0%      208B ± 0%    ~     (all equal)
Unmarshal/*amqp.performDetach-8           712B ± 0%      712B ± 0%    ~     (all equal)
Unmarshal/amqp.ErrorCondition-8           128B ± 0%      128B ± 0%    ~     (all equal)
Unmarshal/*amqp.Error-8                   680B ± 0%      680B ± 0%    ~     (all equal)
Unmarshal/*amqp.performEnd-8              680B ± 0%      680B ± 0%    ~     (all equal)
Unmarshal/*amqp.performClose-8            680B ± 0%      680B ± 0%    ~     (all equal)
Unmarshal/*amqp.Message-8               2.42kB ± 0%    2.42kB ± 0%    ~     (all equal)
Unmarshal/*amqp.MessageHeader-8           144B ± 0%      144B ± 0%    ~     (all equal)
Unmarshal/*amqp.MessageProperties-8       208B ± 0%      208B ± 0%    ~     (all equal)
Unmarshal/*amqp.stateReceived-8           176B ± 0%      176B ± 0%    ~     (all equal)
Unmarshal/*amqp.stateAccepted-8           112B ± 0%      112B ± 0%    ~     (all equal)
Unmarshal/*amqp.stateRejected-8           680B ± 0%      680B ± 0%    ~     (all equal)
Unmarshal/*amqp.stateReleased-8           112B ± 0%      112B ± 0%    ~     (all equal)
Unmarshal/*amqp.stateModified-8           480B ± 0%      480B ± 0%    ~     (all equal)
Unmarshal/amqp.UUID-8                     128B ± 0%      128B ± 0%    ~     (all equal)
Unmarshal/amqp.lifetimePolicy-8           112B ± 0%      112B ± 0%    ~     (all equal)
Unmarshal/amqp.SenderSettleMode-8         112B ± 0%      112B ± 0%    ~     (all equal)
Unmarshal/amqp.ReceiverSettleMode-8       112B ± 0%      112B ± 0%    ~     (all equal)
Unmarshal/bool-8                          112B ± 0%      112B ± 0%    ~     (all equal)
Unmarshal/int8-8                          112B ± 0%      112B ± 0%    ~     (all equal)
Unmarshal/int8#01-8                       112B ± 0%      112B ± 0%    ~     (all equal)
Unmarshal/int16-8                         112B ± 0%      112B ± 0%    ~     (all equal)
Unmarshal/int16#01-8                      112B ± 0%      112B ± 0%    ~     (all equal)
Unmarshal/int32-8                         112B ± 0%      112B ± 0%    ~     (all equal)
Unmarshal/int32#01-8                      112B ± 0%      112B ± 0%    ~     (all equal)
Unmarshal/int64-8                         112B ± 0%      112B ± 0%    ~     (all equal)
Unmarshal/int64#01-8                      112B ± 0%      112B ± 0%    ~     (all equal)
Unmarshal/uint8-8                         112B ± 0%      112B ± 0%    ~     (all equal)
Unmarshal/uint16-8                        112B ± 0%      112B ± 0%    ~     (all equal)
Unmarshal/uint32-8                        112B ± 0%      112B ± 0%    ~     (all equal)
Unmarshal/uint64-8                        112B ± 0%      112B ± 0%    ~     (all equal)
Unmarshal/amqp.describedType-8            184B ± 0%      184B ± 0%    ~     (all equal)
Unmarshal/*amqp.saslInit-8                166B ± 0%      166B ± 0%    ~     (all equal)
Unmarshal/*amqp.saslMechanisms-8          201B ± 0%      201B ± 0%    ~     (all equal)
Unmarshal/*amqp.saslOutcome-8             176B ± 0%      176B ± 0%    ~     (all equal)
Unmarshal/amqp.symbol-8                   120B ± 0%      120B ± 0%    ~     (all equal)
Unmarshal/amqp.milliseconds-8             112B ± 0%      112B ± 0%    ~     (all equal)
Unmarshal/*amqp.mapAnyAny-8               600B ± 0%      600B ± 0%    ~     (all equal)
Unmarshal/*amqp.mapStringAny-8            596B ± 0%      596B ± 0%    ~     (all equal)
Unmarshal/*amqp.mapSymbolAny-8            500B ± 0%      500B ± 0%    ~     (all equal)

name                                  old allocs/op  new allocs/op  delta
Marshal/*amqp.performOpen-8               32.0 ± 0%      32.0 ± 0%    ~     (all equal)
Marshal/*amqp.performBegin-8              29.0 ± 0%      29.0 ± 0%    ~     (all equal)
Marshal/*amqp.performAttach-8             94.0 ± 0%      94.0 ± 0%    ~     (all equal)
Marshal/amqp.role-8                       0.00           0.00         ~     (all equal)
Marshal/*amqp.unsettled-8                 6.00 ± 0%      6.00 ± 0%    ~     (all equal)
Marshal/*amqp.source-8                    35.0 ± 0%      35.0 ± 0%    ~     (all equal)
Marshal/*amqp.target-8                    22.0 ± 0%      22.0 ± 0%    ~     (all equal)
Marshal/*amqp.performFlow-8               27.0 ± 0%      27.0 ± 0%    ~     (all equal)
Marshal/*amqp.performTransfer-8           14.0 ± 0%      14.0 ± 0%    ~     (all equal)
Marshal/*amqp.performDisposition-8        8.00 ± 0%      8.00 ± 0%    ~     (all equal)
Marshal/*amqp.performDetach-8             26.0 ± 0%      26.0 ± 0%    ~     (all equal)
Marshal/amqp.ErrorCondition-8             3.00 ± 0%      3.00 ± 0%    ~     (all equal)
Marshal/*amqp.Error-8                     21.0 ± 0%      21.0 ± 0%    ~     (all equal)
Marshal/*amqp.performEnd-8                23.0 ± 0%      23.0 ± 0%    ~     (all equal)
Marshal/*amqp.performClose-8              23.0 ± 0%      23.0 ± 0%    ~     (all equal)
Marshal/*amqp.Message-8                   81.0 ± 0%      81.0 ± 0%    ~     (all equal)
Marshal/*amqp.MessageHeader-8             9.00 ± 0%      9.00 ± 0%    ~     (all equal)
Marshal/*amqp.MessageProperties-8         39.0 ± 0%      39.0 ± 0%    ~     (all equal)
Marshal/*amqp.stateReceived-8             7.00 ± 0%      7.00 ± 0%    ~     (all equal)
Marshal/*amqp.stateAccepted-8             1.00 ± 0%      1.00 ± 0%    ~     (all equal)
Marshal/*amqp.stateRejected-8             23.0 ± 0%      23.0 ± 0%    ~     (all equal)
Marshal/*amqp.stateReleased-8             1.00 ± 0%      1.00 ± 0%    ~     (all equal)
Marshal/*amqp.stateModified-8             9.00 ± 0%      9.00 ± 0%    ~     (all equal)
Marshal/amqp.UUID-8                       1.00 ± 0%      1.00 ± 0%    ~     (all equal)
Marshal/amqp.lifetimePolicy-8             1.00 ± 0%      1.00 ± 0%    ~     (all equal)
Marshal/amqp.SenderSettleMode-8           1.00 ± 0%      1.00 ± 0%    ~     (all equal)
Marshal/amqp.ReceiverSettleMode-8         1.00 ± 0%      1.00 ± 0%    ~     (all equal)
Marshal/bool-8                            0.00           0.00         ~     (all equal)
Marshal/int8-8                            1.00 ± 0%      1.00 ± 0%    ~     (all equal)
Marshal/int8#01-8                         1.00 ± 0%      1.00 ± 0%    ~     (all equal)
Marshal/int16-8                           2.00 ± 0%      2.00 ± 0%    ~     (all equal)
Marshal/int16#01-8                        2.00 ± 0%      2.00 ± 0%    ~     (all equal)
Marshal/int32-8                           2.00 ± 0%      2.00 ± 0%    ~     (all equal)
Marshal/int32#01-8                        2.00 ± 0%      2.00 ± 0%    ~     (all equal)
Marshal/int64-8                           2.00 ± 0%      2.00 ± 0%    ~     (all equal)
Marshal/int64#01-8                        2.00 ± 0%      2.00 ± 0%    ~     (all equal)
Marshal/uint8-8                           1.00 ± 0%      1.00 ± 0%    ~     (all equal)
Marshal/uint16-8                          2.00 ± 0%      2.00 ± 0%    ~     (all equal)
Marshal/uint32-8                          2.00 ± 0%      2.00 ± 0%    ~     (all equal)
Marshal/uint64-8                          2.00 ± 0%      2.00 ± 0%    ~     (all equal)
Marshal/amqp.describedType-8              5.00 ± 0%      5.00 ± 0%    ~     (all equal)
Marshal/*amqp.saslInit-8                  11.0 ± 0%      11.0 ± 0%    ~     (all equal)
Marshal/*amqp.saslMechanisms-8            7.00 ± 0%      7.00 ± 0%    ~     (all equal)
Marshal/*amqp.saslOutcome-8               6.00 ± 0%      6.00 ± 0%    ~     (all equal)
Marshal/amqp.symbol-8                     2.00 ± 0%      2.00 ± 0%    ~     (all equal)
Marshal/amqp.milliseconds-8               3.00 ± 0%      3.00 ± 0%    ~     (all equal)
Marshal/*amqp.mapAnyAny-8                 6.00 ± 0%      6.00 ± 0%    ~     (all equal)
Marshal/*amqp.mapStringAny-8              7.00 ± 0%      7.00 ± 0%    ~     (all equal)
Marshal/*amqp.mapSymbolAny-8              7.00 ± 0%      7.00 ± 0%    ~     (all equal)
Unmarshal/*amqp.performOpen-8             17.0 ± 0%      17.0 ± 0%    ~     (all equal)
Unmarshal/*amqp.performBegin-8            13.0 ± 0%      13.0 ± 0%    ~     (all equal)
Unmarshal/*amqp.performAttach-8           49.0 ± 0%      49.0 ± 0%    ~     (all equal)
Unmarshal/amqp.role-8                     1.00 ± 0%      1.00 ± 0%    ~     (all equal)
Unmarshal/*amqp.unsettled-8               9.00 ± 0%      9.00 ± 0%    ~     (all equal)
Unmarshal/*amqp.source-8                  19.0 ± 0%      19.0 ± 0%    ~     (all equal)
Unmarshal/*amqp.target-8                  11.0 ± 0%      11.0 ± 0%    ~     (all equal)
Unmarshal/*amqp.performFlow-8             8.00 ± 0%      8.00 ± 0%    ~     (all equal)
Unmarshal/*amqp.performTransfer-8         8.00 ± 0%      8.00 ± 0%    ~     (all equal)
Unmarshal/*amqp.performDisposition-8      4.00 ± 0%      4.00 ± 0%    ~     (all equal)
Unmarshal/*amqp.performDetach-8           18.0 ± 0%      18.0 ± 0%    ~     (all equal)
Unmarshal/amqp.ErrorCondition-8           2.00 ± 0%      2.00 ± 0%    ~     (all equal)
Unmarshal/*amqp.Error-8                   17.0 ± 0%      17.0 ± 0%    ~     (all equal)
Unmarshal/*amqp.performEnd-8              17.0 ± 0%      17.0 ± 0%    ~     (all equal)
Unmarshal/*amqp.performClose-8            17.0 ± 0%      17.0 ± 0%    ~     (all equal)
Unmarshal/*amqp.Message-8                 60.0 ± 0%      60.0 ± 0%    ~     (all equal)
Unmarshal/*amqp.MessageHeader-8           2.00 ± 0%      2.00 ± 0%    ~     (all equal)
Unmarshal/*amqp.MessageProperties-8       12.0 ± 0%      12.0 ± 0%    ~     (all equal)
Unmarshal/*amqp.stateReceived-8           3.00 ± 0%      3.00 ± 0%    ~     (all equal)
Unmarshal/*amqp.stateAccepted-8           1.00 ± 0%      1.00 ± 0%    ~     (all equal)
Unmarshal/*amqp.stateRejected-8           17.0 ± 0%      17.0 ± 0%    ~     (all equal)
Unmarshal/*amqp.stateReleased-8           1.00 ± 0%      1.00 ± 0%    ~     (all equal)
Unmarshal/*amqp.stateModified-8           6.00 ± 0%      6.00 ± 0%    ~     (all equal)
Unmarshal/amqp.UUID-8                     2.00 ± 0%      2.00 ± 0%    ~     (all equal)
Unmarshal/amqp.lifetimePolicy-8           1.00 ± 0%      1.00 ± 0%    ~     (all equal)
Unmarshal/amqp.SenderSettleMode-8         1.00 ± 0%      1.00 ± 0%    ~     (all equal)
Unmarshal/amqp.ReceiverSettleMode-8       1.00 ± 0%      1.00 ± 0%    ~     (all equal)
Unmarshal/bool-8                          1.00 ± 0%      1.00 ± 0%    ~     (all equal)
Unmarshal/int8-8                          1.00 ± 0%      1.00 ± 0%    ~     (all equal)
Unmarshal/int8#01-8                       1.00 ± 0%      1.00 ± 0%    ~     (all equal)
Unmarshal/int16-8                         1.00 ± 0%      1.00 ± 0%    ~     (all equal)
Unmarshal/int16#01-8                      1.00 ± 0%      1.00 ± 0%    ~     (all equal)
Unmarshal/int32-8                         1.00 ± 0%      1.00 ± 0%    ~     (all equal)
Unmarshal/int32#01-8                      1.00 ± 0%      1.00 ± 0%    ~     (all equal)
Unmarshal/int64-8                         1.00 ± 0%      1.00 ± 0%    ~     (all equal)
Unmarshal/int64#01-8                      1.00 ± 0%      1.00 ± 0%    ~     (all equal)
Unmarshal/uint8-8                         1.00 ± 0%      1.00 ± 0%    ~     (all equal)
Unmarshal/uint16-8                        1.00 ± 0%      1.00 ± 0%    ~     (all equal)
Unmarshal/uint32-8                        1.00 ± 0%      1.00 ± 0%    ~     (all equal)
Unmarshal/uint64-8                        1.00 ± 0%      1.00 ± 0%    ~     (all equal)
Unmarshal/amqp.describedType-8            4.00 ± 0%      4.00 ± 0%    ~     (all equal)
Unmarshal/*amqp.saslInit-8                5.00 ± 0%      5.00 ± 0%    ~     (all equal)
Unmarshal/*amqp.saslMechanisms-8          6.00 ± 0%      6.00 ± 0%    ~     (all equal)
Unmarshal/*amqp.saslOutcome-8             3.00 ± 0%      3.00 ± 0%    ~     (all equal)
Unmarshal/amqp.symbol-8                   2.00 ± 0%      2.00 ± 0%    ~     (all equal)
Unmarshal/amqp.milliseconds-8             1.00 ± 0%      1.00 ± 0%    ~     (all equal)
Unmarshal/*amqp.mapAnyAny-8               10.0 ± 0%      10.0 ± 0%    ~     (all equal)
Unmarshal/*amqp.mapStringAny-8            10.0 ± 0%      10.0 ± 0%    ~     (all equal)
Unmarshal/*amqp.mapSymbolAny-8            6.00 ± 0%      6.00 ± 0%    ~     (all equal)
  • Loading branch information
vcabbage committed Jan 23, 2018
1 parent c1e6bfe commit 0ca7be4
Showing 1 changed file with 59 additions and 73 deletions.
132 changes: 59 additions & 73 deletions decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,62 @@ func readHeaderSlice(r reader) (elements int, _ error) {
return elements, nil
}

func init() {
// break initialization cycle by assigning in init
// typeReaders -> readComposite -> unmarshal -> readAny -> typeReaders
typeReaders[0x0] = readComposite
}

var typeReaders = [256]func(r reader) (interface{}, error){
// bool
typeCodeBool: func(r reader) (interface{}, error) { return readBool(r) },
typeCodeBoolTrue: func(r reader) (interface{}, error) { return readBool(r) },
typeCodeBoolFalse: func(r reader) (interface{}, error) { return readBool(r) },
// uint
typeCodeUbyte: func(r reader) (interface{}, error) { return readUint(r) },
typeCodeUshort: func(r reader) (interface{}, error) { return readUint(r) },
typeCodeUint: func(r reader) (interface{}, error) { return readUint(r) },
typeCodeSmallUint: func(r reader) (interface{}, error) { return readUint(r) },
typeCodeUint0: func(r reader) (interface{}, error) { return readUint(r) },
typeCodeUlong: func(r reader) (interface{}, error) { return readUint(r) },
typeCodeSmallUlong: func(r reader) (interface{}, error) { return readUint(r) },
typeCodeUlong0: func(r reader) (interface{}, error) { return readUint(r) },
// int
typeCodeByte: func(r reader) (interface{}, error) { return readInt(r) },
typeCodeShort: func(r reader) (interface{}, error) { return readInt(r) },
typeCodeInt: func(r reader) (interface{}, error) { return readInt(r) },
typeCodeSmallint: func(r reader) (interface{}, error) { return readInt(r) },
typeCodeLong: func(r reader) (interface{}, error) { return readInt(r) },
typeCodeSmalllong: func(r reader) (interface{}, error) { return readInt(r) },
// binary
typeCodeVbin8: func(r reader) (interface{}, error) { return readBinary(r) },
typeCodeVbin32: func(r reader) (interface{}, error) { return readBinary(r) },
// strings
typeCodeStr8: func(r reader) (interface{}, error) { return readString(r) },
typeCodeStr32: func(r reader) (interface{}, error) { return readString(r) },
typeCodeSym8: func(r reader) (interface{}, error) { return readString(r) },
typeCodeSym32: func(r reader) (interface{}, error) { return readString(r) },
// timestamp
typeCodeTimestamp: func(r reader) (interface{}, error) { return readTimestamp(r) },
// UUID
typeCodeUUID: func(r reader) (interface{}, error) { return readUUID(r) },

// TODO: implement
typeCodeFloat: func(r reader) (interface{}, error) { return nil, errorNew("float not implemented") },
typeCodeDouble: func(r reader) (interface{}, error) { return nil, errorNew("double not implemented") },
typeCodeDecimal32: func(r reader) (interface{}, error) { return nil, errorNew("decimal32 not implemented") },
typeCodeDecimal64: func(r reader) (interface{}, error) { return nil, errorNew("decimal64 not implemented") },
typeCodeDecimal128: func(r reader) (interface{}, error) { return nil, errorNew("decimal128 not implemented") },
typeCodeChar: func(r reader) (interface{}, error) { return nil, errorNew("char not implemented") },
typeCodeList0: func(r reader) (interface{}, error) { return nil, errorNew("list0 not implemented") },
typeCodeList8: func(r reader) (interface{}, error) { return nil, errorNew("list8 not implemented") },
typeCodeList32: func(r reader) (interface{}, error) { return nil, errorNew("list32 not implemented") },
typeCodeMap8: func(r reader) (interface{}, error) { return nil, errorNew("map8 not implemented") },
typeCodeMap32: func(r reader) (interface{}, error) { return nil, errorNew("map32 not implemented") },
typeCodeArray8: func(r reader) (interface{}, error) { return nil, errorNew("array8 not implemented") },
typeCodeArray32: func(r reader) (interface{}, error) { return nil, errorNew("array32 not implemented") },
}

func readAny(r reader) (interface{}, error) {
b, err := r.ReadByte()
if err != nil {
Expand All @@ -595,81 +651,11 @@ func readAny(r reader) (interface{}, error) {
return nil, err
}

switch amqpType(b) {
// bool
case
typeCodeBool,
typeCodeBoolTrue,
typeCodeBoolFalse:
return readBool(r)

// unsigned integers
case
typeCodeUbyte,
typeCodeUshort,
typeCodeUint,
typeCodeSmallUint,
typeCodeUint0,
typeCodeUlong,
typeCodeSmallUlong,
typeCodeUlong0:
return readUint(r)

// signed integers
case
typeCodeByte,
typeCodeShort,
typeCodeInt,
typeCodeSmallint,
typeCodeLong,
typeCodeSmalllong:
return readInt(r)

// binary
case
typeCodeVbin8,
typeCodeVbin32:
return readBinary(r)

// strings
case
typeCodeStr8,
typeCodeStr32,
typeCodeSym8,
typeCodeSym32:
return readString(r)

// timestamp
case typeCodeTimestamp:
return readTimestamp(r)

// composite
case 0x0:
return readComposite(r)

case typeCodeUUID:
return readUUID(r)

// not-implemented
case
typeCodeFloat,
typeCodeDouble,
typeCodeDecimal32,
typeCodeDecimal64,
typeCodeDecimal128,
typeCodeChar,
typeCodeList0,
typeCodeList8,
typeCodeList32,
typeCodeMap8,
typeCodeMap32,
typeCodeArray8,
typeCodeArray32:
return nil, errorErrorf("%0x not implemented", b)

default:
tr := typeReaders[amqpType(b)]
if tr == nil {
return nil, errorErrorf("unknown type %0x", b)
}
return tr(r)
}

// roReader is similar to bytes.Reader but does not support rune
Expand Down

0 comments on commit 0ca7be4

Please sign in to comment.