ObjFW  Diff

Differences From Artifact [58afce4465]:

  • File src/runtime/category.m — part of check-in [84a724dd4b] at 2013-12-06 00:52:26 on branch trunk — Add a fast path for objc_classname_to_class().

    This should improve the performance for the GCC ABI, as
    objc_classname_to_class() is used for all sorts of class lookups, e.g.
    objc_lookup_class().

    As this performance improvement needs RAM, it is only used after 128
    calls into objc_classname_to_class(), so that if the ObjFW ABI is used
    and the user does not call into objc_getClass() or similar in a loop, no
    memory is wasted.

    Runtime internal usage of objc_classname_to_class() does not use the
    fast path and does not count as a call into objc_classname_to_class().
    The reason for this is that if the runtime calls
    objc_classname_to_class(), it already has the lock and thus the
    performance gain would be small, but it would waste memory. (user: js, size: 3209) [annotate] [blame] [check-ins using]

To Artifact [1f2f7da047]:


112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
		return NULL;

	return (struct objc_category**)objc_hashtable_get(categories,
	    cls->name);
}

void
objc_free_all_categories(void)
{
	uint32_t i;

	if (categories == NULL)
		return;

	for (i = 0; i <= categories->last_idx; i++)
		if (categories->data[i] != NULL)
			free((void*)categories->data[i]->obj);

	objc_hashtable_free(categories);
	categories = NULL;
}







|













112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
		return NULL;

	return (struct objc_category**)objc_hashtable_get(categories,
	    cls->name);
}

void
objc_unregister_all_categories(void)
{
	uint32_t i;

	if (categories == NULL)
		return;

	for (i = 0; i <= categories->last_idx; i++)
		if (categories->data[i] != NULL)
			free((void*)categories->data[i]->obj);

	objc_hashtable_free(categories);
	categories = NULL;
}