MCPcopy Create free account
hub / github.com/beefytech/Beef / Modify

Method Modify

IDEHelper/Backend/BeMCContext.cpp:504–618  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

502}
503
504BeVTrackingList* BeVTrackingContext::Modify(BeVTrackingList* list, const SizedArrayImpl<int>& inAdds, const SizedArrayImpl<int>& inRemoves, SizedArrayImpl<int>& filteredAdds, SizedArrayImpl<int>& filteredRemoves, bool preserveChanges)
505{
506 for (int idx : inAdds)
507 {
508 if (!IsSet(list, idx))
509 {
510 filteredAdds.push_back(idx);
511 }
512 }
513
514 for (int idx : inRemoves)
515 {
516 if (IsSet(list, idx))
517 {
518 filteredRemoves.push_back(idx);
519 }
520 }
521
522 if ((filteredAdds.empty()) && (filteredRemoves.empty()))
523 return list;
524
525 int newSize = list->mSize - filteredRemoves.size() + filteredAdds.size();
526 int changeSize;
527 if (preserveChanges)
528 changeSize = list->mNumChanges;
529 else
530 changeSize = filteredRemoves.size() + filteredAdds.size();
531
532 int allocBytes = sizeof(int) * (2 + newSize + changeSize);
533 auto newList = (BeVTrackingList*)mAlloc.AllocBytes(allocBytes);
534 mStats.mListBytes += allocBytes;
535
536 if (filteredAdds.size() > 1)
537 std::sort(filteredAdds.begin(), filteredAdds.end());
538 if (filteredRemoves.size() > 1)
539 std::sort(filteredRemoves.begin(), filteredRemoves.end());
540
541 int addIdx = 0;
542 int nextAdd;
543 if (addIdx < (int)filteredAdds.size())
544 nextAdd = filteredAdds[addIdx++];
545 else
546 nextAdd = 0x7FFFFFFF;
547
548 int removeIdx = 0;
549 int nextRemove;
550 if (removeIdx < (int)filteredRemoves.size())
551 nextRemove = filteredRemoves[removeIdx++];
552 else
553 nextRemove = 0x7FFFFFFF;
554
555 int* outPtr = &newList->mEntries[0];
556 for (auto idx : *list)
557 {
558 if (idx == nextRemove)
559 {
560 if (removeIdx < (int)filteredRemoves.size())
561 nextRemove = filteredRemoves[removeIdx++];

Callers 3

GenerateLivenessMethod · 0.80
InitializedPassHelperMethod · 0.80
DoInstCombinePassMethod · 0.80

Calls 6

push_backMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45
AllocBytesMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected