MCPcopy Create free account
hub / github.com/apache/fory / AssignTypeMetaIndexIfAbsent

Method AssignTypeMetaIndexIfAbsent

csharp/src/Fory/WriteContext.cs:68–133  ·  view source on GitHub ↗
(Type type)

Source from the content-addressed store, hash-verified

66 }
67
68 internal (uint Index, bool IsNew) AssignTypeMetaIndexIfAbsent(Type type)
69 {
70 ulong typeKey = TypeMapKey.Get(type);
71 switch (_inlineTypeMetaCount)
72 {
73 case 0:
74 _firstInlineTypeMetaKey = typeKey;
75 _inlineTypeMetaCount = 1;
76 _nextTypeMetaIndex = 1;
77 return (0, true);
78 case 1:
79 if (_firstInlineTypeMetaKey == typeKey)
80 {
81 return (0, false);
82 }
83
84 _secondInlineTypeMetaKey = typeKey;
85 _inlineTypeMetaCount = 2;
86 _nextTypeMetaIndex = 2;
87 return (1, true);
88 case 2:
89 if (_firstInlineTypeMetaKey == typeKey)
90 {
91 return (0, false);
92 }
93
94 if (_secondInlineTypeMetaKey == typeKey)
95 {
96 return (1, false);
97 }
98
99 _thirdInlineTypeMetaKey = typeKey;
100 _inlineTypeMetaCount = InlineTypeMetaSlots;
101 _nextTypeMetaIndex = InlineTypeMetaSlots;
102 return (2, true);
103 }
104
105 if (_firstInlineTypeMetaKey == typeKey)
106 {
107 return (0, false);
108 }
109
110 if (_secondInlineTypeMetaKey == typeKey)
111 {
112 return (1, false);
113 }
114
115 if (_thirdInlineTypeMetaKey == typeKey)
116 {
117 return (2, false);
118 }
119
120 if (_typeMetaIndexByType is null)
121 {
122 _typeMetaIndexByType = new UInt64Map<uint>();
123 }
124 else if (_typeMetaIndexByType.TryGetValue(typeKey, out uint existing))
125 {

Callers

nothing calls this directly

Calls 3

GetMethod · 0.45
TryGetValueMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected