Changeset View
Changeset View
Standalone View
Standalone View
kdevplatform/util/embeddedfreetree.h
Show First 20 Lines • Show All 678 Lines • ▼ Show 20 Line(s) | 678 | if(bound == -1) | |||
---|---|---|---|---|---|
679 | bound = end; | 679 | bound = end; | ||
680 | 680 | | |||
681 | //Now our item should end up right before bound | 681 | //Now our item should end up right before bound | ||
682 | 682 | | |||
683 | int target; | 683 | int target; | ||
684 | //bound cannot be pos, because pos is invalid | 684 | //bound cannot be pos, because pos is invalid | ||
685 | Q_ASSERT(bound != pos); | 685 | Q_ASSERT(bound != pos); | ||
686 | 686 | | |||
687 | #if defined(__GNUC__) && !defined(__INTEL_COMPILER) && (((__GNUC__ * 100) + __GNUC_MINOR__) >= 800) | ||||
688 | #pragma GCC diagnostic push | ||||
689 | #pragma GCC diagnostic ignored "-Wclass-memaccess" | ||||
687 | //Shuffle around the item at the free pos, so reference counting in constructors/destructors is not screwed up | 690 | //Shuffle around the item at the free pos, so reference counting in constructors/destructors is not screwed up | ||
688 | char backup[sizeof(Data)]; | 691 | char backup[sizeof(Data)]; | ||
689 | memcpy(backup, m_items+pos, sizeof(Data)); | 692 | memcpy(backup, m_items+pos, sizeof(Data)); | ||
690 | 693 | | |||
691 | if(bound < pos) { | 694 | if(bound < pos) { | ||
692 | if(!force && pos-bound > maxMoveAround()) { | 695 | if(!force && pos-bound > maxMoveAround()) { | ||
693 | // qCDebug(UTIL) << "increasing because" << pos-bound << ">" << maxMoveAround() << "left free items:" << countFreeItems(*m_centralFreeItem) << "target free items:" << (m_itemCount-countFreeItems(*m_centralFreeItem))/increaseFraction; | 696 | // qCDebug(UTIL) << "increasing because" << pos-bound << ">" << maxMoveAround() << "left free items:" << countFreeItems(*m_centralFreeItem) << "target free items:" << (m_itemCount-countFreeItems(*m_centralFreeItem))/increaseFraction; | ||
694 | return false; | 697 | return false; | ||
695 | } | 698 | } | ||
696 | //Move [bound, pos) one to right, and insert at bound | 699 | //Move [bound, pos) one to right, and insert at bound | ||
697 | memmove(m_items+bound+1, m_items+bound, sizeof(Data)*(pos-bound)); | 700 | memmove(m_items+bound+1, m_items+bound, sizeof(Data)*(pos-bound)); | ||
698 | target = bound; | 701 | target = bound; | ||
699 | }else { | 702 | }else { | ||
700 | Q_ASSERT(bound > pos); | 703 | Q_ASSERT(bound > pos); | ||
701 | if(!force && bound-pos-1 > maxMoveAround()) { | 704 | if(!force && bound-pos-1 > maxMoveAround()) { | ||
702 | // qCDebug(UTIL) << "increasing because" << bound-pos-1 << ">" << maxMoveAround() << "left free items:" << countFreeItems(*m_centralFreeItem)<< "target free items:" << (m_itemCount-countFreeItems(*m_centralFreeItem))/increaseFraction; | 705 | // qCDebug(UTIL) << "increasing because" << bound-pos-1 << ">" << maxMoveAround() << "left free items:" << countFreeItems(*m_centralFreeItem)<< "target free items:" << (m_itemCount-countFreeItems(*m_centralFreeItem))/increaseFraction; | ||
703 | return false; | 706 | return false; | ||
704 | } | 707 | } | ||
705 | //Move (pos, bound) one to left, and insert at bound-1 | 708 | //Move (pos, bound) one to left, and insert at bound-1 | ||
706 | memmove(m_items+pos, m_items+pos+1, sizeof(Data)*(bound-pos-1)); | 709 | memmove(m_items+pos, m_items+pos+1, sizeof(Data)*(bound-pos-1)); | ||
707 | target = bound-1; | 710 | target = bound-1; | ||
708 | } | 711 | } | ||
709 | memcpy(m_items+target, backup, sizeof(Data)); | 712 | memcpy(m_items+target, backup, sizeof(Data)); | ||
713 | #pragma GCC diagnostic pop | ||||
714 | #endif | ||||
710 | 715 | | |||
711 | ItemHandler::copyTo(data, m_items[target]); | 716 | ItemHandler::copyTo(data, m_items[target]); | ||
712 | return true; | 717 | return true; | ||
713 | } | 718 | } | ||
714 | 719 | | |||
715 | const Data& m_add; | 720 | const Data& m_add; | ||
716 | Data* m_items; | 721 | Data* m_items; | ||
717 | uint m_itemCount; | 722 | uint m_itemCount; | ||
▲ Show 20 Lines • Show All 172 Lines • Show Last 20 Lines |