ObjFW  Check-in [ddbf831e72]

Overview
Comment:Make -[removeLastObject] on an empty array a nop.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | 0.7
Files: files | file ages | folders
SHA3-256: ddbf831e722dfac5a8d53bf3a9cfc7ec9040436b3e935a403c8077e498064cce
User & Date: js on 2012-11-02 22:08:20
Other Links: branch diff | manifest | tags
Context
2012-11-03
22:19
Blocks: Only use the lower 2 bytes as retain count check-in: 793bd8883b user: js tags: 0.7
2012-11-02
22:08
Make -[removeLastObject] on an empty array a nop. check-in: ddbf831e72 user: js tags: 0.7
2012-10-29
13:37
Documentation improvements (add references). check-in: 1bcd4b3d46 user: js tags: 0.7
Changes

Modified src/OFDataArray.m from [238d0749d1] to [dfe3b68b31].

393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
	} @catch (OFOutOfMemoryException *e) {
		/* We don't really care, as we only made it smaller */
	}
}

- (void)removeLastItem
{
	if (count < 1)
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];

	count--;
	@try {
		data = [self resizeMemory: data
				     size: itemSize
				    count: count];
	} @catch (OFOutOfMemoryException *e) {







|
|







393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
	} @catch (OFOutOfMemoryException *e) {
		/* We don't really care, as we only made it smaller */
	}
}

- (void)removeLastItem
{
	if (count == 0)
		return;

	count--;
	@try {
		data = [self resizeMemory: data
				     size: itemSize
				    count: count];
	} @catch (OFOutOfMemoryException *e) {
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
	size = newSize;
}

- (void)removeLastItem
{
	size_t newSize, lastPageByte;

	if (count < 1)
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];

	count--;
	lastPageByte = of_pagesize - 1;
	newSize = (count * itemSize + lastPageByte) & ~lastPageByte;

	if (size != newSize) {
		@try {







|
|







659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
	size = newSize;
}

- (void)removeLastItem
{
	size_t newSize, lastPageByte;

	if (count == 0)
		return;

	count--;
	lastPageByte = of_pagesize - 1;
	newSize = (count * itemSize + lastPageByte) & ~lastPageByte;

	if (size != newSize) {
		@try {

Modified src/OFMutableArray.m from [93a257326c] to [880c8c3997].

298
299
300
301
302
303
304
305


306
307
308
309
310
311
312
313
		[self removeObjectAtIndex: range.location];
}

- (void)removeLastObject
{
	size_t count = [self count];

	if (count > 0)


		[self removeObjectAtIndex: count - 1];
}

- (void)removeAllObjects
{
	[self removeObjectsInRange: of_range(0, [self count])];
}








|
>
>
|







298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
		[self removeObjectAtIndex: range.location];
}

- (void)removeLastObject
{
	size_t count = [self count];

	if (count == 0)
		return;

	[self removeObjectAtIndex: count - 1];
}

- (void)removeAllObjects
{
	[self removeObjectsInRange: of_range(0, [self count])];
}

Modified src/OFMutableArray_adjacent.m from [83612a9b9c] to [d741de4264].

193
194
195
196
197
198
199






200
201
202
203
204
205
206
207
	} @finally {
		[self freeMemory: copy];
	}
}

- (void)removeLastObject
{






	id object = [self objectAtIndex: [array count] - 1];
	[array removeLastItem];
	[object release];

	mutations++;
}

- (void)exchangeObjectAtIndex: (size_t)index1







>
>
>
>
>
>
|







193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
	} @finally {
		[self freeMemory: copy];
	}
}

- (void)removeLastObject
{
	size_t count = [array count];
	id object;

	if (count == 0)
		return;

	object = [self objectAtIndex: count - 1];
	[array removeLastItem];
	[object release];

	mutations++;
}

- (void)exchangeObjectAtIndex: (size_t)index1