MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / fxDeleteEntry

Function fxDeleteEntry

xs/sources/xsMapSet.c:1093–1126  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1091}
1092
1093txBoolean fxDeleteEntry(txMachine* the, txSlot* table, txSlot* list, txSlot* key, txBoolean paired, txBoolean fit)
1094{
1095 txSlot* info = list->next;
1096 txU4 sum = fxSumEntry(the, key);
1097 txU4 index = sum & (table->value.table.length - 1);
1098 txSlot** address = &(table->value.table.address[index]);
1099 txSlot* entry;
1100 txSlot* first;
1101 txSlot* last;
1102 while ((entry = *address)) {
1103 if (entry->value.entry.sum == sum) {
1104 first = entry->value.entry.slot;
1105 if (fxTestEntry(the, first, key)) {
1106 *address = entry->next;
1107 entry->next = C_NULL;
1108 first->flag = XS_DONT_ENUM_FLAG;
1109 first->kind = XS_UNDEFINED_KIND;
1110 if (paired) {
1111 last = first->next;
1112 last->flag = XS_DONT_ENUM_FLAG;
1113 last->kind = XS_UNDEFINED_KIND;
1114 }
1115 info->value.integer--;
1116 if (fit) {
1117 fxResizeEntries(the, table, list);
1118 fxPurgeEntries(the, list);
1119 }
1120 return 1;
1121 }
1122 }
1123 address = &entry->next;
1124 }
1125 return 0;
1126}
1127
1128txSlot* fxGetEntry(txMachine* the, txSlot* table, txSlot* slot)
1129{

Callers 4

fx_Map_prototype_deleteFunction · 0.85
fx_Set_prototype_deleteFunction · 0.85

Calls 4

fxSumEntryFunction · 0.85
fxTestEntryFunction · 0.85
fxResizeEntriesFunction · 0.85
fxPurgeEntriesFunction · 0.85

Tested by

no test coverage detected