ArrayData* MixedArray::EscalateForSort(ArrayData* ad, SortFunction sf) { auto a = asMixed(ad); // We can uncomment later if we want this feature. // if (a->m_size <= 1 && !isSortFamily(sf)) { // return a; // } if (UNLIKELY(hasUserDefinedCmp(sf) || a->hasMultipleRefs())) { auto ret = a->copyMixed(); assert(ret->hasExactlyOneRef()); return ret; } else { return a; } }
bool MixedArray::Uasort(ArrayData* ad, const Variant& cmp_function) { auto a = asMixed(ad); USER_SORT_BODY(ValAccessor, false); }
void MixedArray::Asort(ArrayData* ad, int sort_flags, bool ascending) { auto a = asMixed(ad); SORT_BODY(ValAccessor, false); }
ArrayData* MixedArray::EscalateForSort(ArrayData* ad) { // task #1910931 only do this for refCount() > 1 return asMixed(ad)->copyMixed(); }
bool HphpArray::Usort(ArrayData* ad, const Variant& cmp_function) { auto a = asMixed(ad); USER_SORT_BODY(ValAccessor, true); }
bool HphpArray::Uksort(ArrayData* ad, const Variant& cmp_function) { auto a = asMixed(ad); USER_SORT_BODY(KeyAccessor, false); }
void HphpArray::Sort(ArrayData* ad, int sort_flags, bool ascending) { auto a = asMixed(ad); SORT_BODY(ValAccessor, true); }
void HphpArray::Ksort(ArrayData* ad, int sort_flags, bool ascending) { auto a = asMixed(ad); SORT_BODY(KeyAccessor, false); }
bool MixedArray::Usort(ArrayData* ad, const Variant& cmp_function) { auto a = asMixed(ad); USER_SORT_BODY(AssocValAccessor<MixedArray::Elm>, true); }
void MixedArray::Asort(ArrayData* ad, int sort_flags, bool ascending) { auto a = asMixed(ad); auto data_begin = a->data(); auto data_end = data_begin + a->m_size; SORT_BODY(AssocValAccessor<MixedArray::Elm>, false); }
bool MixedArray::WarnAndUsort(ArrayData* ad, const Variant& cmp_function) { assert(ad->kind() != kMixedKind); MixedArray::downgradeAndWarn(ad, Reason::kUsort); auto a = asMixed(ad); USER_SORT_BODY(ValAccessor, true); }
void MixedArray::WarnAndSort(ArrayData* ad, int sort_flags, bool ascending) { assert(ad->kind() != kMixedKind); MixedArray::downgradeAndWarn(ad, Reason::kSort); auto a = asMixed(ad); SORT_BODY(ValAccessor, true); }