ObjFW  Diff

Differences From Artifact [f94483610d]:

To Artifact [a181bd3b11]:


62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
{
	self = [super init];

	@try {
		uint32_t i;
		OFDictionary_hashtable *hashtable;

		if (dictionary == nil)
			@throw [OFInvalidArgumentException
			    exceptionWithClass: [self class]
				      selector: _cmd];

		if (![dictionary isKindOfClass:
		    [OFDictionary_hashtable class]] &&
		    ![dictionary isKindOfClass:
		    [OFMutableDictionary_hashtable class]])
			@throw [OFInvalidArgumentException
			    exceptionWithClass: [self class]
				      selector: _cmd];







<
<
<
<
<







62
63
64
65
66
67
68





69
70
71
72
73
74
75
{
	self = [super init];

	@try {
		uint32_t i;
		OFDictionary_hashtable *hashtable;






		if (![dictionary isKindOfClass:
		    [OFDictionary_hashtable class]] &&
		    ![dictionary isKindOfClass:
		    [OFMutableDictionary_hashtable class]])
			@throw [OFInvalidArgumentException
			    exceptionWithClass: [self class]
				      selector: _cmd];
112
113
114
115
116
117
118



119
120
121
122
123
124
125
126
127
128
129
130
131




132
133
134
135
136
137
138
	}

	return self;
}

- initWithDictionary: (OFDictionary*)dictionary
{



	if ([dictionary class] == [OFDictionary_hashtable class] ||
	    [dictionary class] == [OFMutableDictionary_hashtable class])
		return [self OF_initWithDictionary: dictionary
					  copyKeys: YES];

	self = [super init];

	@try {
		void *pool;
		OFEnumerator *enumerator;
		id key;
		uint32_t i, newSize;





		count = [dictionary count];

		if (count > UINT32_MAX)
			@throw [OFOutOfRangeException
			    exceptionWithClass: [self class]];

		for (newSize = 1; newSize < count; newSize <<= 1);







>
>
>













>
>
>
>







107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
	}

	return self;
}

- initWithDictionary: (OFDictionary*)dictionary
{
	if (dictionary == nil)
		return [self init];

	if ([dictionary class] == [OFDictionary_hashtable class] ||
	    [dictionary class] == [OFMutableDictionary_hashtable class])
		return [self OF_initWithDictionary: dictionary
					  copyKeys: YES];

	self = [super init];

	@try {
		void *pool;
		OFEnumerator *enumerator;
		id key;
		uint32_t i, newSize;

		if (dictionary == nil)
			@throw [OFInvalidArgumentException
			    exceptionWithClass: [self class]];

		count = [dictionary count];

		if (count > UINT32_MAX)
			@throw [OFOutOfRangeException
			    exceptionWithClass: [self class]];

		for (newSize = 1; newSize < count; newSize <<= 1);
284
285
286
287
288
289
290




291
292
293
294
295
296
297
		for (j = 0; j < newSize; j++)
			data[j] = NULL;

		size = newSize;

		for (i = 0; i < count; i++) {
			uint32_t hash, last;





			hash = [keys[i] hash];
			last = size;

			for (j = hash & (size - 1); j < last && data[j] != NULL;
			    j++)
				if ([data[j]->key isEqual: keys[i]])







>
>
>
>







286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
		for (j = 0; j < newSize; j++)
			data[j] = NULL;

		size = newSize;

		for (i = 0; i < count; i++) {
			uint32_t hash, last;

			if (keys[i] == nil || objects[i] == nil)
				@throw [OFInvalidArgumentException
				    exceptionWithClass: [self class]];

			hash = [keys[i] hash];
			last = size;

			for (j = hash & (size - 1); j < last && data[j] != NULL;
			    j++)
				if ([data[j]->key isEqual: keys[i]])
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
	return YES;
}

- (BOOL)containsObject: (id)object
{
	uint32_t i;

	if (count == 0)
		return NO;

	for (i = 0; i < size; i++)
		if (data[i] != NULL && data[i] != DELETED &&
		    [data[i]->object isEqual: object])
			return YES;

	return NO;
}

- (BOOL)containsObjectIdenticalTo: (id)object
{
	uint32_t i;

	if (count == 0)
		return NO;

	for (i = 0; i < size; i++)
		if (data[i] != NULL && data[i] != DELETED &&
		    data[i]->object == object)
			return YES;








|














|







626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
	return YES;
}

- (BOOL)containsObject: (id)object
{
	uint32_t i;

	if (object == nil || count == 0)
		return NO;

	for (i = 0; i < size; i++)
		if (data[i] != NULL && data[i] != DELETED &&
		    [data[i]->object isEqual: object])
			return YES;

	return NO;
}

- (BOOL)containsObjectIdenticalTo: (id)object
{
	uint32_t i;

	if (object == nil || count == 0)
		return NO;

	for (i = 0; i < size; i++)
		if (data[i] != NULL && data[i] != DELETED &&
		    data[i]->object == object)
			return YES;