ObjFW  Check-in [45869ac8ac]

Overview
Comment:Implement fast enumeration for OFArray.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 45869ac8acc34b5447263bd4b834f95301bfc7bde6bb9132c023e974a418ea8b
User & Date: js on 2010-01-03 18:28:03
Other Links: manifest | tags
Context
2010-01-03
18:39
Check for fast enumeration support in compiler and run tests. check-in: a2effa2a7f user: js tags: trunk
18:28
Implement fast enumeration for OFArray. check-in: 45869ac8ac user: js tags: trunk
18:14
OFMutableArray: Add mutation counter, required for fast enumeration. check-in: fe56ea4a9c user: js tags: trunk
Changes

Modified src/OFArray.h from [29ba7d9e73] to [b142bf7140].

9
10
11
12
13
14
15

16
17
18
19
20
21
22
23
24
25
26
27
28
29
 * the packaging of this file.
 */

#include <stdarg.h>

#import "OFObject.h"
#import "OFDataArray.h"


@class OFString;

/**
 * The OFArray class is a class for storing objects in an array.
 */
@interface OFArray: OFObject <OFCopying, OFMutableCopying>
{
	OFDataArray *array;
}

/**
 * \return A new autoreleased OFArray
 */







>






|







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 * the packaging of this file.
 */

#include <stdarg.h>

#import "OFObject.h"
#import "OFDataArray.h"
#import "OFFastEnumeration.h"

@class OFString;

/**
 * The OFArray class is a class for storing objects in an array.
 */
@interface OFArray: OFObject <OFCopying, OFMutableCopying, OFFastEnumeration>
{
	OFDataArray *array;
}

/**
 * \return A new autoreleased OFArray
 */

Modified src/OFArray.m from [7844cdc05f] to [368e6650a6].

279
280
281
282
283
284
285
















286
287
288
289
290
291
292
		OF_HASH_ADD(hash, h & 0xFF);
	}

	OF_HASH_FINALIZE(hash);

	return hash;
}

















- (void)dealloc
{
	OFObject **objs = [array cArray];
	size_t i, count = [array count];

	for (i = 0; i < count; i++)







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







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
		OF_HASH_ADD(hash, h & 0xFF);
	}

	OF_HASH_FINALIZE(hash);

	return hash;
}

- (int)countByEnumeratingWithState: (of_fast_enumeration_state_t*)state
			   objects: (id*)objects
			     count: (int)count_
{
	size_t count = [array count];

	if (state->state >= count)
		return 0;

	state->state = count;
	state->itemsPtr = [array cArray];
	state->mutationsPtr = (unsigned long*)self;

	return count;
}

- (void)dealloc
{
	OFObject **objs = [array cArray];
	size_t i, count = [array count];

	for (i = 0; i < count; i++)

Modified src/OFMutableArray.m from [ca890914b8] to [6b6d81b49f].

195
196
197
198
199
200
201
















202
			[copy[i] release];
	} @finally {
		[self freeMemory: copy];
	}

	return self;
}
















@end







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
			[copy[i] release];
	} @finally {
		[self freeMemory: copy];
	}

	return self;
}

- (int)countByEnumeratingWithState: (of_fast_enumeration_state_t*)state
			   objects: (id*)objects
			     count: (int)count_
{
	size_t count = [array count];

	if (state->state >= count)
		return 0;

	state->state = count;
	state->itemsPtr = [array cArray];
	state->mutationsPtr = &mutations;

	return count;
}
@end