ObjFW  Diff

Differences From Artifact [f394a43240]:

To Artifact [d31a7805ef]:


18
19
20
21
22
23
24






25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#import "runtime.h"
#import "runtime-private.h"







static struct objc_sparsearray *selectors = NULL;

void
objc_register_selector(struct objc_abi_selector *sel)
{
	uint32_t hash, last;
	struct objc_selector *rsel = (struct objc_selector*)sel;
	const char *name;

	if (selectors == NULL)
		selectors = objc_sparsearray_new();

	hash = objc_hash_string(sel->name) & 0xFFFFFF;

	while (hash <= 0xFFFFFF &&
	    (name = objc_sparsearray_get(selectors, hash)) != NULL) {
		if (!strcmp(name, sel->name)) {
			rsel->uid = hash;
			return;
		}

		hash++;
	}

	if (hash > 0xFFFFFF) {
		last = hash;
		hash = 0;

		while (hash < last &&
		    (name = objc_sparsearray_get(selectors, hash)) != NULL) {
			if (!strcmp(name, sel->name)) {
				rsel->uid = hash;







>
>
>
>
>
>













|

|









|







18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#import "runtime.h"
#import "runtime-private.h"

#ifndef OF_SELUID16
# define SEL_MAX 0xFFFFFF
#else
# define SEL_MAX 0xFFFF
#endif

static struct objc_sparsearray *selectors = NULL;

void
objc_register_selector(struct objc_abi_selector *sel)
{
	uint32_t hash, last;
	struct objc_selector *rsel = (struct objc_selector*)sel;
	const char *name;

	if (selectors == NULL)
		selectors = objc_sparsearray_new();

	hash = objc_hash_string(sel->name) & SEL_MAX;

	while (hash <= SEL_MAX &&
	    (name = objc_sparsearray_get(selectors, hash)) != NULL) {
		if (!strcmp(name, sel->name)) {
			rsel->uid = hash;
			return;
		}

		hash++;
	}

	if (hash > SEL_MAX) {
		last = hash;
		hash = 0;

		while (hash < last &&
		    (name = objc_sparsearray_get(selectors, hash)) != NULL) {
			if (!strcmp(name, sel->name)) {
				rsel->uid = hash;