staticvoidprepareMethodLists(Class cls, method_list_t **addedLists, int addedCount,
bool baseMethods, bool methodsFromBundle, constchar *why)// Add method lists to array.// Reallocate un-fixed method lists.// The new methods are PREPENDED to the method list array.for (int i = 0; i < addedCount; i++) {
method_list_t *mlist = addedLists[i];
ASSERT(mlist);
// Fixup selectors if necessaryif (!mlist->isFixedUp()) {
fixupMethodList(mlist, methodsFromBundle, true/*sort*/);
fixupMethodList
点击进入fixupMethodList:
static void
fixupMethodList(method_list_t *mlist, bool bundleCopy, bool sort)
// Sort by selector address.// Don't try to sort small lists, as they're immutable.// Don't try to sort big lists of nonstandard size, as stable_sort// won't copy the entries properly.if (sort && !mlist->isSmallList() && mlist->entsize() == method_t::bigSize) {
method_t::SortBySELAddress sorter;
std::stable_sort(&mlist->begin()->big(), &mlist->end()->big(), sorter);