ObjFW  Diff

Differences From Artifact [5cf73c1314]:

To Artifact [271b9597ba]:


56
57
58
59
60
61
62
63

64
65
66
67
68
69
70

71
72
73
74
75
76
77
78
79
80

81
82
83
84
85
86
87

88
89
90
91
92
93
94
56
57
58
59
60
61
62

63
64
65
66
67
68
69

70
71
72
73
74
75
76
77
78
79

80
81
82
83
84
85
86

87
88
89
90
91
92
93
94







-
+






-
+









-
+






-
+







	[_array addItem: &object];
	[object retain];

	_mutations++;
}

- (void)insertObject: (id)object
	     atIndex: (size_t)index
	     atIndex: (size_t)idx
{
	if (object == nil)
		@throw [OFInvalidArgumentException exception];

	@try {
		[_array insertItem: &object
			   atIndex: index];
			   atIndex: idx];
	} @catch (OFOutOfRangeException *e) {
		@throw [OFOutOfRangeException exception];
	}
	[object retain];

	_mutations++;
}

- (void)insertObjectsFromArray: (OFArray *)array
		       atIndex: (size_t)index
		       atIndex: (size_t)idx
{
	id const *objects = [array objects];
	size_t count = [array count];

	@try {
		[_array insertItems: objects
			    atIndex: index
			    atIndex: idx
			      count: count];
	} @catch (OFOutOfRangeException *e) {
		@throw [OFOutOfRangeException exception];
	}

	for (size_t i = 0; i < count; i++)
		[objects[i] retain];
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
141
142
143
144
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
141
142
143
144







-
+










-
+


-
-
+
+







			objects[i] = newObject;

			return;
		}
	}
}

- (void)replaceObjectAtIndex: (size_t)index
- (void)replaceObjectAtIndex: (size_t)idx
		  withObject: (id)object
{
	id *objects;
	id oldObject;

	if (object == nil)
		@throw [OFInvalidArgumentException exception];

	objects = [_array items];

	if (index >= [_array count])
	if (idx >= [_array count])
		@throw [OFOutOfRangeException exception];

	oldObject = objects[index];
	objects[index] = [object retain];
	oldObject = objects[idx];
	objects[idx] = [object retain];
	[oldObject release];
}

- (void)replaceObjectIdenticalTo: (id)oldObject
		      withObject: (id)newObject
{
	id *objects;
205
206
207
208
209
210
211
212

213
214
215
216


217
218
219
220
221
222
223
205
206
207
208
209
210
211

212
213
214


215
216
217
218
219
220
221
222
223







-
+


-
-
+
+







			[object release];

			return;
		}
	}
}

- (void)removeObjectAtIndex: (size_t)index
- (void)removeObjectAtIndex: (size_t)idx
{
#ifndef __clang_analyzer__
	id object = [self objectAtIndex: index];
	[_array removeItemAtIndex: index];
	id object = [self objectAtIndex: idx];
	[_array removeItemAtIndex: idx];
	[object release];

	_mutations++;
#endif
}

- (void)removeAllObjects
268
269
270
271
272
273
274
275
276


277
278
279
280
281
282

283
284
285
286
287



288
289
290
291
292
293
294
268
269
270
271
272
273
274


275
276
277
278
279
280
281

282
283
284



285
286
287
288
289
290
291
292
293
294







-
-
+
+





-
+


-
-
-
+
+
+







	[_array removeLastItem];
	[object release];

	_mutations++;
#endif
}

- (void)exchangeObjectAtIndex: (size_t)index1
	    withObjectAtIndex: (size_t)index2
- (void)exchangeObjectAtIndex: (size_t)idx1
	    withObjectAtIndex: (size_t)idx2
{
	id *objects = [_array items];
	size_t count = [_array count];
	id tmp;

	if (index1 >= count || index2 >= count)
	if (idx1 >= count || idx2 >= count)
		@throw [OFOutOfRangeException exception];

	tmp = objects[index1];
	objects[index1] = objects[index2];
	objects[index2] = tmp;
	tmp = objects[idx1];
	objects[idx1] = objects[idx2];
	objects[idx2] = tmp;
}

- (void)reverse
{
	id *objects = [_array items];
	size_t i, j, count = [_array count];