ObjFW  Check-in [0ccbebce04]

Overview
Comment:Small optimization for -[componentsJoinedByString:].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 0ccbebce04b3041d56493cbccbbd470dc71b34757378a4e83bc9e1c2a8b2b4a5
User & Date: js on 2010-02-05 14:00:17
Other Links: manifest | tags
Context
2010-02-05
14:03
Rename of_atomic_*32 to of_atomic_*_32 and add of_atomic_cmpswap_ptr. check-in: 4e1ab53403 user: js tags: trunk
14:00
Small optimization for -[componentsJoinedByString:]. check-in: 0ccbebce04 user: js tags: trunk
2010-02-02
18:58
Rename OFMacros.h to macros.h, as it's not a class. check-in: 832188d759 user: js tags: trunk
Changes

Modified src/OFArray.m from [8b2d803278] to [cfc59d89e5].

223
224
225
226
227
228
229


230
231
232
233
234
235
236
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238







+
+







	OFString *str;
	OFString **objs = [array cArray];
	size_t i, count = [array count];
	IMP append;

	if (count == 0)
		return @"";
	if (count == 1)
		return [objs[0] retain];

	str = [OFMutableString string];
	append = [str methodForSelector: @selector(appendString:)];

	for (i = 0; i < count - 1; i++) {
		append(str, @selector(appendString:), objs[i]);
		append(str, @selector(appendString:), separator);

Modified tests/OFArray.m from [a4eb61b01c] to [e8b5e9e9d5].

114
115
116
117
118
119
120

121
122
123




124
125
126
127
128
129
130
114
115
116
117
118
119
120
121



122
123
124
125
126
127
128
129
130
131
132







+
-
-
-
+
+
+
+








	EXPECT_EXCEPTION(@"Detect out of range in -[objectAtIndex:]",
	    OFOutOfRangeException, [a[0] objectAtIndex: [a[0] count]])

	EXPECT_EXCEPTION(@"Detect out of range in -[removeNItems:]",
	    OFOutOfRangeException, [m[0] removeNObjects: [m[0] count] + 1])

	TEST(@"-[componentsJoinedByString:]",
	a[1] = [OFArray arrayWithObjects: @"foo", @"bar", @"baz", nil];
	TEST(@"-[componentsJoinedByString:]",
	    [[a[1] componentsJoinedByString: @" "] isEqual: @"foo bar baz"])
	    (a[1] = [OFArray arrayWithObjects: @"foo", @"bar", @"baz", nil]) &&
	    [[a[1] componentsJoinedByString: @" "] isEqual: @"foo bar baz"] &&
	    (a[1] = [OFArray arrayWithObject: @"foo"]) &&
	    [[a[1] componentsJoinedByString: @" "] isEqual: @"foo"])

	m[0] = [[a[0] mutableCopy] autorelease];
	ok = YES;
	i = 0;

	TEST(@"-[enumerator]", (enumerator = [m[0] enumerator]))