ObjFW  Check-in [365e946d10]

Overview
Comment:OFArray: Optimize fast enumeration.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 365e946d107ea08216aaa1d9037733a9bf644a3bd12e4a9e36664be6e1e48649
User & Date: js on 2012-10-30 22:16:35
Other Links: manifest | tags
Context
2012-11-02
21:19
Remove a useless ivar. check-in: a40ccfa7cf user: js tags: trunk
2012-10-30
22:16
OFArray: Optimize fast enumeration. check-in: 365e946d10 user: js tags: trunk
18:50
Async I/O: Pass a context. check-in: 13ea2fc8b1 user: js tags: trunk
Changes

Modified src/OFArray.m from [03e4be362e] to [626ce7ee3d].

563
564
565
566
567
568
569
570

571
572
573

574
575

576
577

578
579




580
581
582


583
584
585

586
587
588
589
590
591
592
563
564
565
566
567
568
569

570
571


572
573

574
575
576
577


578
579
580
581
582


583
584
585
586

587
588
589
590
591
592
593
594







-
+

-
-
+

-
+


+
-
-
+
+
+
+

-
-
+
+


-
+







	[new makeImmutable];

	return new;
}

- (int)countByEnumeratingWithState: (of_fast_enumeration_state_t*)state
			   objects: (id*)objects
			     count: (int)count_
			     count: (int)count
{
	/* FIXME: Use -[getObjects:inRange:] on the passed objects */
	size_t count = [self count];
	of_range_t range = of_range(state->state, count);

	if (count > INT_MAX)
	if (range.length > SIZE_MAX - range.location)
		@throw [OFOutOfRangeException exceptionWithClass: [self class]];

	if (range.location + range.length > [self count])
	if (state->state >= count)
		return 0;
		range.length = [self count] - range.location;

	[self getObjects: objects
		 inRange: range];

	state->state = count;
	state->itemsPtr = [self objects];
	state->state = range.location + range.length;
	state->itemsPtr = objects;
	state->mutationsPtr = (unsigned long*)self;

	return (int)count;
	return (int)range.length;
}

- (OFEnumerator*)objectEnumerator
{
	return [[[OFArrayEnumerator alloc] initWithArray: self
					    mutationsPtr: NULL] autorelease];
}