MCPcopy Create free account
hub / github.com/Tencent/UnLua / pb_name

Function pb_name

Plugins/UnLuaExtensions/LuaProtobuf/Source/src/pb.h:1092–1112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1090}
1091
1092PB_API const pb_Name *pb_name(const pb_State *S, pb_Slice s, pb_Cache *cache) {
1093 pb_NameEntry *entry = NULL;
1094 pb_CacheSlot *slot;
1095 if (s.p == NULL) return NULL;
1096 if (cache == NULL)
1097 entry = pbN_getname(S, s, pbN_calchash(s));
1098 else {
1099 slot = cache->slots[((uintptr_t)s.p*2654435761U)%PB_CACHE_SIZE];
1100 if (slot[0].name == s.p)
1101 entry = pbN_getname(S, s, cache->hash = slot[0].hash);
1102 else if (slot[1].name == s.p)
1103 entry = pbN_getname(S, s, cache->hash = (++slot)[0].hash);
1104 else
1105 slot[1] = slot[0], slot[0].name = s.p;
1106 if (entry == NULL) {
1107 cache->hash = slot[0].hash = pbN_calchash(s);
1108 entry = pbN_getname(S, s, slot[0].hash);
1109 }
1110 }
1111 return entry ? (pb_Name*)(entry + 1) : NULL;
1112}
1113
1114
1115/* state */

Callers 2

pbL_loadFileFunction · 0.85
lpb_typeFunction · 0.85

Calls 2

pbN_getnameFunction · 0.85
pbN_calchashFunction · 0.85

Tested by

no test coverage detected