ObjFW  Check-in [f2a39c4f61]

Overview
Comment:Make -[removeLastObject] on an empty array a nop.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: f2a39c4f6120050abd78787280b3350b7e71f18bd7a93e6db86818cb97bac6f4
User & Date: js on 2012-11-02 22:07:47
Other Links: manifest | tags
Context
2012-11-03
22:18
Blocks: Only use the lower 2 bytes as retain count check-in: 616b4e0dd2 user: js tags: trunk
2012-11-02
22:07
Make -[removeLastObject] on an empty array a nop. check-in: f2a39c4f61 user: js tags: trunk
21:39
Small fix in OFDictionaryEnumerator_hashtable. check-in: 62497de4c2 user: js tags: trunk
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
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]];
	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
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]];
	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
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)
		[self removeObjectAtIndex: count - 1];
	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
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;

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

	mutations++;
}

- (void)exchangeObjectAtIndex: (size_t)index1