ObjFW  Check-in [3b0699b790]

Overview
Comment:Don't create and release a pool in -[enumerateObjectsUsingBlock:].

This fixes the mutable versions reimplementing it and still behaving the
old way.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 3b0699b790bf71e0d94ce6bd1bdbd7e69b811ff15c70085224da60971b36dd2e
User & Date: js on 2011-07-28 22:21:03
Other Links: manifest | tags
Context
2011-07-29
20:35
Make typeEncoding a const char* in OFIntrospection. check-in: 430222609a user: js tags: trunk
2011-07-28
22:21
Don't create and release a pool in -[enumerateObjectsUsingBlock:]. check-in: 3b0699b790 user: js tags: trunk
21:31
Add +[elementWithFile:] to OFXMLElement. check-in: 7d5e2ebb80 user: js tags: trunk
Changes

Modified src/OFMutableArray.m from [4897ca4a74] to [637e903291].

220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
		   dataArray: array
	    mutationsPointer: &mutations] autorelease];
}

#ifdef OF_HAVE_BLOCKS
- (void)enumerateObjectsUsingBlock: (of_array_enumeration_block_t)block
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	id *cArray = [array cArray];
	size_t i, count = [array count];
	BOOL stop = NO;
	unsigned long mutations2 = mutations;

	for (i = 0; i < count && !stop; i++) {
		if (mutations != mutations2)
			@throw [OFEnumerationMutationException
			    newWithClass: isa
				  object: self];

		block(cArray[i], i, &stop);
		[pool releaseObjects];
	}

	[pool release];
}

- (void)replaceObjectsUsingBlock: (of_array_replace_block_t)block
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	id *cArray = [array cArray];
	size_t i, count = [array count];
	BOOL stop = NO;
	unsigned long mutations2 = mutations;

	for (i = 0; i < count && !stop; i++) {
		id newObject;







<












<

<
<




<







220
221
222
223
224
225
226

227
228
229
230
231
232
233
234
235
236
237
238

239


240
241
242
243

244
245
246
247
248
249
250
		   dataArray: array
	    mutationsPointer: &mutations] autorelease];
}

#ifdef OF_HAVE_BLOCKS
- (void)enumerateObjectsUsingBlock: (of_array_enumeration_block_t)block
{

	id *cArray = [array cArray];
	size_t i, count = [array count];
	BOOL stop = NO;
	unsigned long mutations2 = mutations;

	for (i = 0; i < count && !stop; i++) {
		if (mutations != mutations2)
			@throw [OFEnumerationMutationException
			    newWithClass: isa
				  object: self];

		block(cArray[i], i, &stop);

	}


}

- (void)replaceObjectsUsingBlock: (of_array_replace_block_t)block
{

	id *cArray = [array cArray];
	size_t i, count = [array count];
	BOOL stop = NO;
	unsigned long mutations2 = mutations;

	for (i = 0; i < count && !stop; i++) {
		id newObject;
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
		if (newObject == nil)
			@throw [OFInvalidArgumentException newWithClass: isa
							       selector: _cmd];

		[newObject retain];
		[cArray[i] release];
		cArray[i] = newObject;

		[pool releaseObjects];
	}

	[pool release];
}
#endif
@end







|
<
<
<
<



259
260
261
262
263
264
265
266




267
268
269
		if (newObject == nil)
			@throw [OFInvalidArgumentException newWithClass: isa
							       selector: _cmd];

		[newObject retain];
		[cArray[i] release];
		cArray[i] = newObject;
	}




}
#endif
@end

Modified src/OFMutableDictionary.m from [7bf06a0039] to [e5d16fd400].

275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
	     mutationsPointer: &mutations] autorelease];
}

#ifdef OF_HAVE_BLOCKS
- (void)enumerateKeysAndObjectsUsingBlock:
    (of_dictionary_enumeration_block_t)block
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	size_t i;
	BOOL stop = NO;
	unsigned long mutations2 = mutations;

	for (i = 0; i < size && !stop; i++) {
		if (mutations != mutations2)
			@throw [OFEnumerationMutationException
			    newWithClass: isa
				  object: self];

		if (data[i] != NULL && data[i] != DELETED) {
			block(data[i]->key, data[i]->object, &stop);
			[pool releaseObjects];
		}
	}

	[pool release];
}

- (void)replaceObjectsUsingBlock: (of_dictionary_replace_block_t)block
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	size_t i;
	BOOL stop = NO;
	unsigned long mutations2 = mutations;

	for (i = 0; i < size && !stop; i++) {
		if (mutations != mutations2)
			@throw [OFEnumerationMutationException







<










|

<
|
<
<
<




<







275
276
277
278
279
280
281

282
283
284
285
286
287
288
289
290
291
292
293

294



295
296
297
298

299
300
301
302
303
304
305
	     mutationsPointer: &mutations] autorelease];
}

#ifdef OF_HAVE_BLOCKS
- (void)enumerateKeysAndObjectsUsingBlock:
    (of_dictionary_enumeration_block_t)block
{

	size_t i;
	BOOL stop = NO;
	unsigned long mutations2 = mutations;

	for (i = 0; i < size && !stop; i++) {
		if (mutations != mutations2)
			@throw [OFEnumerationMutationException
			    newWithClass: isa
				  object: self];

		if (data[i] != NULL && data[i] != DELETED)
			block(data[i]->key, data[i]->object, &stop);

	}



}

- (void)replaceObjectsUsingBlock: (of_dictionary_replace_block_t)block
{

	size_t i;
	BOOL stop = NO;
	unsigned long mutations2 = mutations;

	for (i = 0; i < size && !stop; i++) {
		if (mutations != mutations2)
			@throw [OFEnumerationMutationException
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
				@throw [OFInvalidArgumentException
				    newWithClass: isa
					selector: _cmd];

			[new retain];
			[data[i]->object release];
			data[i]->object = new;

			[pool releaseObjects];
		}
	}

	[pool release];
}
#endif
@end







|
<
|
<
<
<



313
314
315
316
317
318
319
320

321



322
323
324
				@throw [OFInvalidArgumentException
				    newWithClass: isa
					selector: _cmd];

			[new retain];
			[data[i]->object release];
			data[i]->object = new;
		}

	}



}
#endif
@end