зеркало из https://github.com/akkadotnet/Hyperion.git
faster
This commit is contained in:
Родитель
7eebd577f3
Коммит
cded71c231
|
@ -66,10 +66,10 @@ But even with it's rich featureset, Wire performs extremely well.
|
|||
|
||||
```text
|
||||
Wire - preregister types
|
||||
Serialize 373 ms
|
||||
Deserialize 330 ms
|
||||
Serialize 312 ms
|
||||
Deserialize 261 ms
|
||||
Size 38 bytes
|
||||
Total 703 ms
|
||||
Total 573 ms
|
||||
Wire - no version data
|
||||
Serialize 381 ms
|
||||
Deserialize 403 ms
|
||||
|
|
|
@ -5,8 +5,9 @@ namespace Wire
|
|||
{
|
||||
public class FastTypeUShortDictionary
|
||||
{
|
||||
private int _length = 0;
|
||||
private Tuple<Type, ushort> _first;
|
||||
private int _length;
|
||||
private Type _firstType;
|
||||
private ushort _firstValue;
|
||||
private Dictionary<Type, ushort> _all;
|
||||
|
||||
public bool TryGetValue(Type key, out ushort value)
|
||||
|
@ -17,9 +18,9 @@ namespace Wire
|
|||
value = 0;
|
||||
return false;
|
||||
case 1:
|
||||
if (key == _first.Item1)
|
||||
if (key == _firstType)
|
||||
{
|
||||
value = _first.Item2;
|
||||
value = _firstValue;
|
||||
return true;
|
||||
}
|
||||
value = 0;
|
||||
|
@ -34,11 +35,12 @@ namespace Wire
|
|||
switch (_length)
|
||||
{
|
||||
case 0:
|
||||
_first = Tuple.Create(type, value);
|
||||
_firstType = type;
|
||||
_firstValue = value;
|
||||
_length = 1;
|
||||
break;
|
||||
case 1:
|
||||
_all = new Dictionary<Type, ushort> {{_first.Item1, _first.Item2}, {type, value}};
|
||||
_all = new Dictionary<Type, ushort> {{_firstType, _firstValue}, {type, value}};
|
||||
_length = 2;
|
||||
break;
|
||||
default:
|
||||
|
|
Загрузка…
Ссылка в новой задаче