ObjFW  Check-in [927dbf6e7d]

Overview
Comment:Add -[makeImmutable] to all mutable classes and use it.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 927dbf6e7dd4a1b437c9ee2af7e0d81f171620f7ee6a2d44a639d7336855943e
User & Date: js on 2011-08-07 16:57:49
Other Links: manifest | tags
Context
2011-08-12
16:18
Add OFSOCKS5Socket. check-in: 48e58dfed1 user: js tags: trunk
2011-08-07
16:57
Add -[makeImmutable] to all mutable classes and use it. check-in: 927dbf6e7d user: js tags: trunk
2011-08-04
18:37
Fix a name conflict in OFHashAlreadyCalculatedException. check-in: 507057d9a6 user: js tags: trunk
Changes

Modified src/OFApplication.m from [849335f8ed] to [00b46f84d9].

163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
		if ((env = getenv("USER")) != NULL)
			[environment
			    setObject: [OFString stringWithCString: env]
			       forKey: @"USER"];
#endif
		[pool release];

		/*
		 * Class swizzle the environment to be immutable, as we don't
		 * need to change it anymore and expose it only as
		 * OFDictionary*. But not swizzling it would create a real copy
		 * each time -[copy] is called.
		 */
		environment->isa = [OFDictionary class];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}







<
<
<
<
<
<
|







163
164
165
166
167
168
169






170
171
172
173
174
175
176
177
		if ((env = getenv("USER")) != NULL)
			[environment
			    setObject: [OFString stringWithCString: env]
			       forKey: @"USER"];
#endif
		[pool release];







		[environment makeImmutable];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

Modified src/OFArray.m from [409e6b7e60] to [da553bca16].

367
368
369
370
371
372
373


374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
		append(ret, @selector(appendString:), [cArray[i] description]);
		append(ret, @selector(appendString:), separator);

		[pool2 releaseObjects];
	}
	append(ret, @selector(appendString:), [cArray[i] description]);



	[pool release];

	/*
	 * Class swizzle the array to be immutable. We declared the return type
	 * to be OFArray*, so it can't be modified anyway. But not swizzling it
	 * would create a real copy each time -[copy] is called.
	 */
	ret->isa = [OFString class];
	return ret;
}

- (BOOL)isEqual: (id)object
{
	/* FIXME: Optimize (for example, buffer of 16 for each) */
	OFArray *otherArray;







>
>


<
<
<
<
<
<







367
368
369
370
371
372
373
374
375
376
377






378
379
380
381
382
383
384
		append(ret, @selector(appendString:), [cArray[i] description]);
		append(ret, @selector(appendString:), separator);

		[pool2 releaseObjects];
	}
	append(ret, @selector(appendString:), [cArray[i] description]);

	[ret makeImmutable];

	[pool release];







	return ret;
}

- (BOOL)isEqual: (id)object
{
	/* FIXME: Optimize (for example, buffer of 16 for each) */
	OFArray *otherArray;
447
448
449
450
451
452
453

454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
	} @catch (id e) {
		[ret release];
		@throw e;
	}

	[pool release];


	[ret autorelease];

	/*
	 * Class swizzle the array to be immutable. We declared the return type
	 * to be OFArray*, so it can't be modified anyway. But not swizzling it
	 * would create a real copy each time -[copy] is called.
	 */
	ret->isa = [OFString class];
	return ret;
}

- (OFXMLElement*)XMLElementBySerializing
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFAutoreleasePool *pool2;







>


<
<
<
<
<
<







443
444
445
446
447
448
449
450
451
452






453
454
455
456
457
458
459
	} @catch (id e) {
		[ret release];
		@throw e;
	}

	[pool release];

	[ret makeImmutable];
	[ret autorelease];







	return ret;
}

- (OFXMLElement*)XMLElementBySerializing
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFAutoreleasePool *pool2;

Modified src/OFCountedSet.m from [c9d1c58489] to [01afd72625].

112
113
114
115
116
117
118


119
120
121
122
123
124
125
126
127
128
129
130
131
132
133

		[pool2 releaseObjects];
	}
	[ret replaceOccurrencesOfString: @"\n"
			     withString: @"\n\t"];
	[ret appendString: @"\n)}"];



	[pool release];

        /*
	 * Class swizzle the string to be immutable. We declared the return type
	 * to be OFString*, so it can't be modified anyway. But not swizzling it
	 * would create a real copy each time -[copy] is called.
	 */
	ret->isa = [OFString class];
	return ret;
}

- copy
{
	return [[OFCountedSet alloc] initWithSet: self];
}







>
>


<
<
<
<
<
<







112
113
114
115
116
117
118
119
120
121
122






123
124
125
126
127
128
129

		[pool2 releaseObjects];
	}
	[ret replaceOccurrencesOfString: @"\n"
			     withString: @"\n\t"];
	[ret appendString: @"\n)}"];

	[ret makeImmutable];

	[pool release];







	return ret;
}

- copy
{
	return [[OFCountedSet alloc] initWithSet: self];
}
244
245
246
247
248
249
250




251

		for (i = 0; i < count; i++)
			[self addObject: object];
	}

	[pool release];
}




@end







>
>
>
>

240
241
242
243
244
245
246
247
248
249
250
251

		for (i = 0; i < count; i++)
			[self addObject: object];
	}

	[pool release];
}

- (void)makeImmutable
{
}
@end

Modified src/OFDictionary.m from [39169fee1e] to [45afb75ecd].

748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788

	[self enumerateKeysAndObjectsUsingBlock: ^ (id key, id object,
	    BOOL *stop) {
		[new setObject: block(key, object)
			forKey: key];
	}];

	/*
	 * Class swizzle the dictionary to be immutable. We declared the return
	 * type to be OFDictionary*, so it can't be modified anyway. But not
	 * swizzling it would create a real copy each time -[copy] is called.
	 */
	new->isa = [OFDictionary class];
	return new;
}

- (OFDictionary*)filteredDictionaryUsingBlock:
    (of_dictionary_filter_block_t)block
{
	OFMutableDictionary *new = [OFMutableDictionary dictionary];

	[self enumerateKeysAndObjectsUsingBlock: ^ (id key, id object,
	    BOOL *stop) {
		if (block(key, object))
			[new setObject: object
				forKey: key];
	}];

	/*
	 * Class swizzle the dictionary to be immutable. We declared the return
	 * type to be OFDictionary*, so it can't be modified anyway. But not
	 * swizzling it would create a real copy each time -[copy] is called.
	 */
	new->isa = [OFDictionary class];
	return new;
}
#endif

- (void)dealloc
{
	uint32_t i;







<
|
|
<
<
<















<
|
|
<
<
<







748
749
750
751
752
753
754

755
756



757
758
759
760
761
762
763
764
765
766
767
768
769
770
771

772
773



774
775
776
777
778
779
780

	[self enumerateKeysAndObjectsUsingBlock: ^ (id key, id object,
	    BOOL *stop) {
		[new setObject: block(key, object)
			forKey: key];
	}];


	[new makeImmutable];




	return new;
}

- (OFDictionary*)filteredDictionaryUsingBlock:
    (of_dictionary_filter_block_t)block
{
	OFMutableDictionary *new = [OFMutableDictionary dictionary];

	[self enumerateKeysAndObjectsUsingBlock: ^ (id key, id object,
	    BOOL *stop) {
		if (block(key, object))
			[new setObject: object
				forKey: key];
	}];


	[new makeImmutable];




	return new;
}
#endif

- (void)dealloc
{
	uint32_t i;
855
856
857
858
859
860
861


862
863
864
865
866
867
868
869
870
871
872
873
874
875
876

		[pool2 releaseObjects];
	}
	[ret replaceOccurrencesOfString: @"\n"
			     withString: @"\n\t"];
	[ret appendString: @";\n}"];



	[pool release];

	/*
	 * Class swizzle the string to be immutable. We declared the return type
	 * to be OFString*, so it can't be modified anyway. But not swizzling it
	 * would create a real copy each time -[copy] is called.
	 */
	ret->isa = [OFString class];
	return ret;
}

- (OFXMLElement*)XMLElementBySerializing
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFAutoreleasePool *pool2;







>
>


<
<
<
<
<
<







847
848
849
850
851
852
853
854
855
856
857






858
859
860
861
862
863
864

		[pool2 releaseObjects];
	}
	[ret replaceOccurrencesOfString: @"\n"
			     withString: @"\n\t"];
	[ret appendString: @";\n}"];

	[ret makeImmutable];

	[pool release];







	return ret;
}

- (OFXMLElement*)XMLElementBySerializing
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFAutoreleasePool *pool2;

Modified src/OFDoubleMatrix.m from [0e9aecd40d] to [a2ea99d71f].

272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
				    appendFormat: @"%10f\n",
						  data[j * rows + i]];
		}
	}

	[description appendString: @")>"];

	/*
	 * Class swizzle the string to be immutable. We declared the return type
	 * to be OFString*, so it can't be modified anyway. But not swizzling it
	 * would create a real copy each time -[copy] is called.
	 */
	description->isa = [OFString class];
	return description;
}

- (double*)cArray
{
	return data;
}







<
|
|
<
<
<







272
273
274
275
276
277
278

279
280



281
282
283
284
285
286
287
				    appendFormat: @"%10f\n",
						  data[j * rows + i]];
		}
	}

	[description appendString: @")>"];


	[description makeImmutable];




	return description;
}

- (double*)cArray
{
	return data;
}

Modified src/OFDoubleVector.m from [a8ab061699] to [8de83ff694].

245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
	for (i = 0; i < dimension; i++) {
		if (i != dimension - 1)
			[description appendFormat: @"%g, ", data[i]];
		else
			[description appendFormat: @"%g)>", data[i]];
	}

	/*
	 * Class swizzle the string to be immutable. We declared the return type
	 * to be OFString*, so it can't be modified anyway. But not swizzling it
	 * would create a real copy each time -[copy] is called.
	 */
	description->isa = [OFString class];
	return description;
}

- (double*)cArray
{
	return data;
}







<
|
|
<
<
<







245
246
247
248
249
250
251

252
253



254
255
256
257
258
259
260
	for (i = 0; i < dimension; i++) {
		if (i != dimension - 1)
			[description appendFormat: @"%g, ", data[i]];
		else
			[description appendFormat: @"%g)>", data[i]];
	}


	[description makeImmutable];




	return description;
}

- (double*)cArray
{
	return data;
}

Modified src/OFFile.m from [24d4055b98] to [072b46a026].

299
300
301
302
303
304
305
306


307
308
309
310
311
312
313
	} @finally {
		FindClose(handle);
	}

	[pool release];
#endif

	return [files makeImmutable];


}

+ (void)changeToDirectory: (OFString*)path
{
	if (chdir([path cString]))
		@throw [OFChangeDirectoryFailedException newWithClass: self
								 path: path];







|
>
>







299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
	} @finally {
		FindClose(handle);
	}

	[pool release];
#endif

	[files makeImmutable];

	return files;
}

+ (void)changeToDirectory: (OFString*)path
{
	if (chdir([path cString]))
		@throw [OFChangeDirectoryFailedException newWithClass: self
								 path: path];

Modified src/OFFloatMatrix.m from [47a5b85ad1] to [d289104dc5].

272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
				    appendFormat: @"%10f\n",
						  data[j * rows + i]];
		}
	}

	[description appendString: @")>"];

	/*
	 * Class swizzle the string to be immutable. We declared the return type
	 * to be OFString*, so it can't be modified anyway. But not swizzling it
	 * would create a real copy each time -[copy] is called.
	 */
	description->isa = [OFString class];
	return description;
}

- (float*)cArray
{
	return data;
}







<
|
|
<
<
<







272
273
274
275
276
277
278

279
280



281
282
283
284
285
286
287
				    appendFormat: @"%10f\n",
						  data[j * rows + i]];
		}
	}

	[description appendString: @")>"];


	[description makeImmutable];




	return description;
}

- (float*)cArray
{
	return data;
}

Modified src/OFFloatVector.m from [a1eb70bd06] to [ac31706dc3].

245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
	for (i = 0; i < dimension; i++) {
		if (i != dimension - 1)
			[description appendFormat: @"%g, ", data[i]];
		else
			[description appendFormat: @"%g)>", data[i]];
	}

	/*
	 * Class swizzle the string to be immutable. We declared the return type
	 * to be OFString*, so it can't be modified anyway. But not swizzling it
	 * would create a real copy each time -[copy] is called.
	 */
	description->isa = [OFString class];
	return description;
}

- (float*)cArray
{
	return data;
}







<
|
|
<
<
<







245
246
247
248
249
250
251

252
253



254
255
256
257
258
259
260
	for (i = 0; i < dimension; i++) {
		if (i != dimension - 1)
			[description appendFormat: @"%g, ", data[i]];
		else
			[description appendFormat: @"%g)>", data[i]];
	}


	[description makeImmutable];




	return description;
}

- (float*)cArray
{
	return data;
}

Modified src/OFHTTPRequest.m from [205f214213] to [3269a913de].

394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
			 */
			if (cl != bytesReceived && (status == 200 ||
			    status == 301 || status == 302 || status == 303))
				@throw [OFTruncatedDataException
				    newWithClass: isa];
		}

		/*
		 * Class swizzle the dictionary to be immutable. We pass it as
		 * OFDictionary*, so it can't be modified anyway. But not
		 * swizzling it would create a real copy each time -[copy] is
		 * called.
		 */
		serverHeaders->isa = [OFDictionary class];

		result = [[OFHTTPRequestResult alloc]
		    initWithStatusCode: status
			       headers: serverHeaders
				  data: data];

		if (status != 200 && status != 301 && status != 302 &&







<
<
<
<
<
<
|







394
395
396
397
398
399
400






401
402
403
404
405
406
407
408
			 */
			if (cl != bytesReceived && (status == 200 ||
			    status == 301 || status == 302 || status == 303))
				@throw [OFTruncatedDataException
				    newWithClass: isa];
		}







		[serverHeaders makeImmutable];

		result = [[OFHTTPRequestResult alloc]
		    initWithStatusCode: status
			       headers: serverHeaders
				  data: data];

		if (status != 200 && status != 301 && status != 302 &&

Modified src/OFList.m from [58ae77a2af] to [5cba33a83a].

347
348
349
350
351
352
353


354
355
356
357
358
359
360
361
362
363
364
365
366
367
368

		[pool releaseObjects];
	}
	[ret replaceOccurrencesOfString: @"\n"
			     withString: @"\n\t"];
	[ret appendString: @"\n]"];



	[pool release];

	/*
	 * Class swizzle the string to be immutable. We declared the return type
	 * to be OFString*, so it can't be modified anyway. But not swizzling it
	 * would create a real copy each time -[copy] is called.
	 */
	ret->isa = [OFString class];
	return ret;
}

- (OFXMLElement*)XMLElementBySerializing
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFAutoreleasePool *pool2;







>
>


<
<
<
<
<
<







347
348
349
350
351
352
353
354
355
356
357






358
359
360
361
362
363
364

		[pool releaseObjects];
	}
	[ret replaceOccurrencesOfString: @"\n"
			     withString: @"\n\t"];
	[ret appendString: @"\n]"];

	[ret makeImmutable];

	[pool release];







	return ret;
}

- (OFXMLElement*)XMLElementBySerializing
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFAutoreleasePool *pool2;

Modified src/OFMutableArray.h from [1389a09656] to [0e34f7fe92].

118
119
120
121
122
123
124
125
126
127
128
129
 */
- (void)replaceObjectsUsingBlock: (of_array_replace_block_t)block;
#endif

/**
 * \brief Converts the mutable array to an immutable array.
 */
- (OFArray*)makeImmutable;
@end

@interface OFMutableArrayPlaceholder: OFMutableArray
@end







|




118
119
120
121
122
123
124
125
126
127
128
129
 */
- (void)replaceObjectsUsingBlock: (of_array_replace_block_t)block;
#endif

/**
 * \brief Converts the mutable array to an immutable array.
 */
- (void)makeImmutable;
@end

@interface OFMutableArrayPlaceholder: OFMutableArray
@end

Modified src/OFMutableArray.m from [7ce334d92a] to [8df097f31b].

236
237
238
239
240
241
242
243
244
245
246
247
	    BOOL *stop) {
		[self replaceObjectAtIndex: index
				withObject: block(object, index, stop)];
	}];
}
#endif

- (OFArray*)makeImmutable
{
	return self;
}
@end







|

<


236
237
238
239
240
241
242
243
244

245
246
	    BOOL *stop) {
		[self replaceObjectAtIndex: index
				withObject: block(object, index, stop)];
	}];
}
#endif

- (void)makeImmutable
{

}
@end

Modified src/OFMutableCArray.m from [a724222ebd] to [5511bcf0c5].

268
269
270
271
272
273
274
275
276
277
278
279
280
		[newObject retain];
		[cArray[i] release];
		cArray[i] = newObject;
	}
}
#endif

- (OFArray*)makeImmutable
{
	isa = [OFCArray class];
	return self;
}
@end







|


<


268
269
270
271
272
273
274
275
276
277

278
279
		[newObject retain];
		[cArray[i] release];
		cArray[i] = newObject;
	}
}
#endif

- (void)makeImmutable
{
	isa = [OFCArray class];

}
@end

Modified src/OFMutableDictionary.h from [ca4efa5ceb] to [29972e06f6].

56
57
58
59
60
61
62





63
#endif

#if defined(OF_SET_M) || defined(OF_MUTABLE_SET_M) || defined(OF_COUNTED_SET_M)
- (void)_setObject: (id)object
	    forKey: (id)key
	   copyKey: (BOOL)copyKey;
#endif





@end







>
>
>
>
>

56
57
58
59
60
61
62
63
64
65
66
67
68
#endif

#if defined(OF_SET_M) || defined(OF_MUTABLE_SET_M) || defined(OF_COUNTED_SET_M)
- (void)_setObject: (id)object
	    forKey: (id)key
	   copyKey: (BOOL)copyKey;
#endif

/**
 * \brief Converts the mutable dictionary to an immutable dictionary.
 */
- (void)makeImmutable;
@end

Modified src/OFMutableDictionary.m from [e5d16fd400] to [6cae7254e5].

317
318
319
320
321
322
323





324
			[new retain];
			[data[i]->object release];
			data[i]->object = new;
		}
	}
}
#endif





@end







>
>
>
>
>

317
318
319
320
321
322
323
324
325
326
327
328
329
			[new retain];
			[data[i]->object release];
			data[i]->object = new;
		}
	}
}
#endif

- (void)makeImmutable
{
	isa = [OFDictionary class];
}
@end

Modified src/OFMutableSet.h from [0cfa8bd2d7] to [aa22f58832].

55
56
57
58
59
60
61





62

/**
 * \brief Creates a union of the receiver and the specified set.
 *
 * \param set The set to create the union with
 */
- (void)unionSet: (OFSet*)set;





@end







>
>
>
>
>

55
56
57
58
59
60
61
62
63
64
65
66
67

/**
 * \brief Creates a union of the receiver and the specified set.
 *
 * \param set The set to create the union with
 */
- (void)unionSet: (OFSet*)set;

/**
 * \brief Converts the mutable set to an immutable set.
 */
- (void)makeImmutable;
@end

Modified src/OFMutableSet.m from [917221d23f] to [54d40938db].

75
76
77
78
79
80
81





82
	id object;

	while ((object = [enumerator nextObject]) != nil)
		[self addObject: object];

	[pool release];
}





@end







>
>
>
>
>

75
76
77
78
79
80
81
82
83
84
85
86
87
	id object;

	while ((object = [enumerator nextObject]) != nil)
		[self addObject: object];

	[pool release];
}

- (void)makeImmutable
{
	isa = [OFSet class];
}
@end

Modified src/OFMutableString.h from [7e1d229b63] to [a723d0168a].

154
155
156
157
158
159
160





161
 */
- (void)deleteTrailingWhitespaces;

/**
 * \brief Deletes all whitespaces at the beginning and the end of the string.
 */
- (void)deleteEnclosingWhitespaces;





@end







>
>
>
>
>

154
155
156
157
158
159
160
161
162
163
164
165
166
 */
- (void)deleteTrailingWhitespaces;

/**
 * \brief Deletes all whitespaces at the beginning and the end of the string.
 */
- (void)deleteEnclosingWhitespaces;

/**
 * \brief Converts the mutable string to an immutable string.
 */
- (void)makeImmutable;
@end

Modified src/OFMutableString.m from [f5b0d569c9] to [2936968cd3].

655
656
657
658
659
660
661





662
	}
}

- copy
{
	return [[OFString alloc] initWithString: self];
}





@end







>
>
>
>
>

655
656
657
658
659
660
661
662
663
664
665
666
667
	}
}

- copy
{
	return [[OFString alloc] initWithString: self];
}

- (void)makeImmutable
{
	isa = [OFString class];
}
@end

Modified src/OFSet.m from [b1d260547d] to [ac40594a2c].

211
212
213
214
215
216
217


218
219
220
221
222
223
224
225
226
227
228
229
230
231
232

		[pool2 releaseObjects];
	}
	[ret replaceOccurrencesOfString: @"\n"
			     withString: @"\n\t"];
	[ret appendString: @"\n)}"];



	[pool release];

	/*
	 * Class swizzle the string to be immutable. We declared the return type
	 * to be OFString*, so it can't be modified anyway. But not swizzling it
	 * would create a real copy each time -[copy] is called.
	 */
	ret->isa = [OFString class];
	return ret;
}

- copy
{
	return [[OFSet alloc] initWithSet: self];
}







>
>


<
<
<
<
<
<







211
212
213
214
215
216
217
218
219
220
221






222
223
224
225
226
227
228

		[pool2 releaseObjects];
	}
	[ret replaceOccurrencesOfString: @"\n"
			     withString: @"\n\t"];
	[ret appendString: @"\n)}"];

	[ret makeImmutable];

	[pool release];







	return ret;
}

- copy
{
	return [[OFSet alloc] initWithSet: self];
}
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327

	[dictionary enumerateKeysAndObjectsUsingBlock: ^ (id key, id object,
	    BOOL *stop) {
		if (block(key))
			[ret addObject: key];
	}];

	/*
	 * Class swizzle the set to be immutable. We declared the return type
	 * to be OFSet*, so it can't be modified anyway. But not swizzling it
	 * would create a real copy each time -[copy] is called.
	 */
	ret->isa = [OFSet class];
	return ret;
}
#endif
@end







<
|
|
<
<
<




307
308
309
310
311
312
313

314
315



316
317
318
319

	[dictionary enumerateKeysAndObjectsUsingBlock: ^ (id key, id object,
	    BOOL *stop) {
		if (block(key))
			[ret addObject: key];
	}];


	[ret makeImmutable];




	return ret;
}
#endif
@end

Modified src/OFString+XMLUnescaping.m from [f26dc131a5] to [f6529b2cf8].

167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186

	if (inEntity)
		@throw [OFInvalidEncodingException newWithClass: isa];

	[ret appendCString: string + last
		withLength: i - last];

	/*
	 * Class swizzle the string to be immutable. We declared the return type
	 * to be OFString*, so it can't be modified anyway. But not swizzling it
	 * would create a real copy each time -[copy] is called.
	 */
	ret->isa = [OFString class];
	return ret;
}

#ifdef OF_HAVE_BLOCKS
- (OFString*)stringByXMLUnescapingWithBlock:
    (of_string_xml_unescaping_block_t)block
{







<
|
|
<
<
<







167
168
169
170
171
172
173

174
175



176
177
178
179
180
181
182

	if (inEntity)
		@throw [OFInvalidEncodingException newWithClass: isa];

	[ret appendCString: string + last
		withLength: i - last];


	[ret makeImmutable];




	return ret;
}

#ifdef OF_HAVE_BLOCKS
- (OFString*)stringByXMLUnescapingWithBlock:
    (of_string_xml_unescaping_block_t)block
{
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281

	if (inEntity)
		@throw [OFInvalidEncodingException newWithClass: isa];

	[ret appendCString: string + last
		withLength: i - last];

	/*
	 * Class swizzle the string to be immutable. We declared the return type
	 * to be OFString*, so it can't be modified anyway. But not swizzling it
	 * would create a real copy each time -[copy] is called.
	 */
	ret->isa = [OFString class];
	return ret;
}
#endif
@end







<
|
|
<
<
<




261
262
263
264
265
266
267

268
269



270
271
272
273

	if (inEntity)
		@throw [OFInvalidEncodingException newWithClass: isa];

	[ret appendCString: string + last
		withLength: i - last];


	[ret makeImmutable];




	return ret;
}
#endif
@end

Modified src/OFString.m from [e16259c02d] to [6c62052489].

1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
- (OFString*)stringByAppendingString: (OFString*)string
{
	OFMutableString *new;

	new = [OFMutableString stringWithString: self];
	[new appendString: string];

	/*
	 * Class swizzle the string to be immutable. We declared the return type
	 * to be OFString*, so it can't be modified anyway. But not swizzling it
	 * would create a real copy each time -[copy] is called.
	 */
	new->isa = [OFString class];
	return new;
}

- (OFString*)stringByPrependingString: (OFString*)string
{
	OFMutableString *new = [[string mutableCopy] autorelease];

	[new appendString: self];

	/*
	 * Class swizzle the string to be immutable. We declared the return type
	 * to be OFString*, so it can't be modified anyway. But not swizzling it
	 * would create a real copy each time -[copy] is called.
	 */
	new->isa = [OFString class];
	return new;
}

- (OFString*)uppercaseString
{
	OFMutableString *new = [[self mutableCopy] autorelease];

	[new upper];

	/*
	 * Class swizzle the string to be immutable. We declared the return type
	 * to be OFString*, so it can't be modified anyway. But not swizzling it
	 * would create a real copy each time -[copy] is called.
	 */
	new->isa = [OFString class];
	return new;
}

- (OFString*)lowercaseString
{
	OFMutableString *new = [[self mutableCopy] autorelease];

	[new lower];

	/*
	 * Class swizzle the string to be immutable. We declared the return type
	 * to be OFString*, so it can't be modified anyway. But not swizzling it
	 * would create a real copy each time -[copy] is called.
	 */
	new->isa = [OFString class];
	return new;
}

- (OFString*)stringByDeletingLeadingWhitespaces
{
	OFMutableString *new = [[self mutableCopy] autorelease];

	[new deleteLeadingWhitespaces];

	/*
	 * Class swizzle the string to be immutable. We declared the return type
	 * to be OFString*, so it can't be modified anyway. But not swizzling it
	 * would create a real copy each time -[copy] is called.
	 */
	new->isa = [OFString class];
	return new;
}

- (OFString*)stringByDeletingTrailingWhitespaces
{
	OFMutableString *new = [[self mutableCopy] autorelease];

	[new deleteTrailingWhitespaces];

	/*
	 * Class swizzle the string to be immutable. We declared the return type
	 * to be OFString*, so it can't be modified anyway. But not swizzling it
	 * would create a real copy each time -[copy] is called.
	 */
	new->isa = [OFString class];
	return new;
}

- (OFString*)stringByDeletingEnclosingWhitespaces
{
	OFMutableString *new = [[self mutableCopy] autorelease];

	[new deleteEnclosingWhitespaces];

	/*
	 * Class swizzle the string to be immutable. We declared the return type
	 * to be OFString*, so it can't be modified anyway. But not swizzling it
	 * would create a real copy each time -[copy] is called.
	 */
	new->isa = [OFString class];
	return new;
}

- (BOOL)hasPrefix: (OFString*)prefix
{
	size_t cStringLength = [prefix cStringLength];








<
|
|
<
<
<









<
|
|
<
<
<









<
|
|
<
<
<









<
|
|
<
<
<









<
|
|
<
<
<









<
|
|
<
<
<









<
|
|
<
<
<







1420
1421
1422
1423
1424
1425
1426

1427
1428



1429
1430
1431
1432
1433
1434
1435
1436
1437

1438
1439



1440
1441
1442
1443
1444
1445
1446
1447
1448

1449
1450



1451
1452
1453
1454
1455
1456
1457
1458
1459

1460
1461



1462
1463
1464
1465
1466
1467
1468
1469
1470

1471
1472



1473
1474
1475
1476
1477
1478
1479
1480
1481

1482
1483



1484
1485
1486
1487
1488
1489
1490
1491
1492

1493
1494



1495
1496
1497
1498
1499
1500
1501
- (OFString*)stringByAppendingString: (OFString*)string
{
	OFMutableString *new;

	new = [OFMutableString stringWithString: self];
	[new appendString: string];


	[new makeImmutable];




	return new;
}

- (OFString*)stringByPrependingString: (OFString*)string
{
	OFMutableString *new = [[string mutableCopy] autorelease];

	[new appendString: self];


	[new makeImmutable];




	return new;
}

- (OFString*)uppercaseString
{
	OFMutableString *new = [[self mutableCopy] autorelease];

	[new upper];


	[new makeImmutable];




	return new;
}

- (OFString*)lowercaseString
{
	OFMutableString *new = [[self mutableCopy] autorelease];

	[new lower];


	[new makeImmutable];




	return new;
}

- (OFString*)stringByDeletingLeadingWhitespaces
{
	OFMutableString *new = [[self mutableCopy] autorelease];

	[new deleteLeadingWhitespaces];


	[new makeImmutable];




	return new;
}

- (OFString*)stringByDeletingTrailingWhitespaces
{
	OFMutableString *new = [[self mutableCopy] autorelease];

	[new deleteTrailingWhitespaces];


	[new makeImmutable];




	return new;
}

- (OFString*)stringByDeletingEnclosingWhitespaces
{
	OFMutableString *new = [[self mutableCopy] autorelease];

	[new deleteEnclosingWhitespaces];


	[new makeImmutable];




	return new;
}

- (BOOL)hasPrefix: (OFString*)prefix
{
	size_t cStringLength = [prefix cStringLength];

1569
1570
1571
1572
1573
1574
1575


1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
		[array addObject: [OFString stringWithCString: s->cString + last
						       length: i - last]];
		i += cStringLength - 1;
		last = i + 1;
	}
	[array addObject: [OFString stringWithCString: s->cString + last]];



	[pool release];

	return [array makeImmutable];
}

- (OFArray*)pathComponents
{
	OFMutableArray *ret;
	OFAutoreleasePool *pool;
	size_t i, last = 0, pathCStringLength = s->cStringLength;







>
>


|







1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
		[array addObject: [OFString stringWithCString: s->cString + last
						       length: i - last]];
		i += cStringLength - 1;
		last = i + 1;
	}
	[array addObject: [OFString stringWithCString: s->cString + last]];

	[array makeImmutable];

	[pool release];

	return array;
}

- (OFArray*)pathComponents
{
	OFMutableArray *ret;
	OFAutoreleasePool *pool;
	size_t i, last = 0, pathCStringLength = s->cStringLength;
1611
1612
1613
1614
1615
1616
1617


1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
			last = i + 1;
		}
	}

	[ret addObject: [OFString stringWithCString: s->cString + last
					     length: i - last]];



	[pool release];

	return [ret makeImmutable];
}

- (OFString*)lastPathComponent
{
	size_t pathCStringLength = s->cStringLength;
	ssize_t i;








>
>


|







1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
			last = i + 1;
		}
	}

	[ret addObject: [OFString stringWithCString: s->cString + last
					     length: i - last]];

	[ret makeImmutable];

	[pool release];

	return ret;
}

- (OFString*)lastPathComponent
{
	size_t pathCStringLength = s->cStringLength;
	ssize_t i;

Modified src/OFURL.m from [d4ad83d094] to [1998367c8d].

528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547

	if (query != nil)
		[ret appendFormat: @"?%@", query];

	if (fragment != nil)
		[ret appendFormat: @"#%@", fragment];

	/*
	 * Class swizzle the string to be immutable. We declared the return type
	 * to be OFString*, so it can't be modified anyway. But not swizzling it
	 * would create a real copy each time -[copy] is called.
	 */
	ret->isa = [OFString class];
	return ret;
}

- (OFString*)description
{
	return [self string];
}







<
|
|
<
<
<







528
529
530
531
532
533
534

535
536



537
538
539
540
541
542
543

	if (query != nil)
		[ret appendFormat: @"?%@", query];

	if (fragment != nil)
		[ret appendFormat: @"#%@", fragment];


	[ret makeImmutable];




	return ret;
}

- (OFString*)description
{
	return [self string];
}

Modified src/OFXMLElement.m from [c5f82626bf] to [99bfc17297].

456
457
458
459
460
461
462


463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
			[ret appendString: cArray[i]->CDATA];
		else if (cArray[i]->comment == nil) {
			[ret appendString: [cArray[i] stringValue]];
			[pool releaseObjects];
		}
	}



	[pool release];

	/*
	 * Class swizzle the string to be immutable. We declared the return type
	 * to be OFString*, so it can't be modified anyway. But not swizzling it
	 * would create a real copy each time -[copy] is called.
	 */
	ret->isa = [OFString class];
	return ret;
}

- (intmax_t)decimalValue
{
	return [[self stringValue] decimalValue];
}







>
>


<
<
<
<
<
<







456
457
458
459
460
461
462
463
464
465
466






467
468
469
470
471
472
473
			[ret appendString: cArray[i]->CDATA];
		else if (cArray[i]->comment == nil) {
			[ret appendString: [cArray[i] stringValue]];
			[pool releaseObjects];
		}
	}

	[ret makeImmutable];

	[pool release];







	return ret;
}

- (intmax_t)decimalValue
{
	return [[self stringValue] decimalValue];
}
1032
1033
1034
1035
1036
1037
1038
1039


1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053


1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067


1068
1069
1070
1071
1072
1073
1074
	OFXMLElement **cArray = [children cArray];
	size_t i, count = [children count];

	for (i = 0; i < count; i++)
		if (cArray[i]->name != nil)
			[ret addObject: cArray[i]];

	return [ret makeImmutable];


}

- (OFArray*)elementsForName: (OFString*)elementName
{
	OFMutableArray *ret = [OFMutableArray array];
	OFXMLElement **cArray = [children cArray];
	size_t i, count = [children count];

	for (i = 0; i < count; i++)
		if (cArray[i]->ns == nil &&
		    [cArray[i]->name isEqual: elementName])
			[ret addObject: cArray[i]];

	return [ret makeImmutable];


}

- (OFArray*)elementsForNamespace: (OFString*)elementNS
{
	OFMutableArray *ret = [OFMutableArray array];
	OFXMLElement **cArray = [children cArray];
	size_t i, count = [children count];

	for (i = 0; i < count; i++)
		if (cArray[i]->name != nil &&
		    [cArray[i]->ns isEqual: elementNS])
			[ret addObject: cArray[i]];

	return [ret makeImmutable];


}

- (OFArray*)elementsForName: (OFString*)elementName
		  namespace: (OFString*)elementNS
{
	OFMutableArray *ret;
	OFXMLElement **cArray;







|
>
>













|
>
>













|
>
>







1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
	OFXMLElement **cArray = [children cArray];
	size_t i, count = [children count];

	for (i = 0; i < count; i++)
		if (cArray[i]->name != nil)
			[ret addObject: cArray[i]];

	[ret makeImmutable];

	return ret;
}

- (OFArray*)elementsForName: (OFString*)elementName
{
	OFMutableArray *ret = [OFMutableArray array];
	OFXMLElement **cArray = [children cArray];
	size_t i, count = [children count];

	for (i = 0; i < count; i++)
		if (cArray[i]->ns == nil &&
		    [cArray[i]->name isEqual: elementName])
			[ret addObject: cArray[i]];

	[ret makeImmutable];

	return ret;
}

- (OFArray*)elementsForNamespace: (OFString*)elementNS
{
	OFMutableArray *ret = [OFMutableArray array];
	OFXMLElement **cArray = [children cArray];
	size_t i, count = [children count];

	for (i = 0; i < count; i++)
		if (cArray[i]->name != nil &&
		    [cArray[i]->ns isEqual: elementNS])
			[ret addObject: cArray[i]];

	[ret makeImmutable];

	return ret;
}

- (OFArray*)elementsForName: (OFString*)elementName
		  namespace: (OFString*)elementNS
{
	OFMutableArray *ret;
	OFXMLElement **cArray;
1082
1083
1084
1085
1086
1087
1088
1089


1090
1091
1092
1093
1094
1095
1096
	count = [children count];

	for (i = 0; i < count; i++)
		if ([cArray[i]->ns isEqual: elementNS] &&
		    [cArray[i]->name isEqual: elementName])
			[ret addObject: cArray[i]];

	return [ret makeImmutable];


}

- (BOOL)isEqual: (id)object
{
	OFXMLElement *otherElement;

	if (![object isKindOfClass: [OFXMLElement class]])







|
>
>







1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
	count = [children count];

	for (i = 0; i < count; i++)
		if ([cArray[i]->ns isEqual: elementNS] &&
		    [cArray[i]->name isEqual: elementName])
			[ret addObject: cArray[i]];

	[ret makeImmutable];

	return ret;
}

- (BOOL)isEqual: (id)object
{
	OFXMLElement *otherElement;

	if (![object isKindOfClass: [OFXMLElement class]])

Modified src/OFXMLParser.m from [a92b6c9809] to [e1a9a7f1bc].

78
79
80
81
82
83
84

85
86
87
88
89
90
91
92

		[ret deleteCharactersInRange: of_range(length - cut, cut)];
	}

	if (unescape)
		return [ret stringByXMLUnescapingWithDelegate: delegate];


	ret->isa = [OFString class];
	return ret;
}

static OFString*
namespace_for_prefix(OFString *prefix, OFArray *namespaces)
{
	OFDictionary **cArray = [namespaces cArray];







>
|







78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93

		[ret deleteCharactersInRange: of_range(length - cut, cut)];
	}

	if (unescape)
		return [ret stringByXMLUnescapingWithDelegate: delegate];

	[ret makeImmutable];

	return ret;
}

static OFString*
namespace_for_prefix(OFString *prefix, OFArray *namespaces)
{
	OFDictionary **cArray = [namespaces cArray];
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804

	pool = [[OFAutoreleasePool alloc] init];

	cacheString = [OFMutableString stringWithCString: [cache cArray]
						  length: [cache count]];
	[cacheString deleteEnclosingWhitespaces];
	/* Prevent a useless copy later */
	cacheString->isa = [OFString class];

	cacheCString = [cacheString cString];
	cacheLength = [cacheString cStringLength];

	if ((tmp = memchr(cacheCString, ':', cacheLength)) != NULL) {
		attributeName = [[OFString alloc]
		    initWithCString: tmp + 1







|







791
792
793
794
795
796
797
798
799
800
801
802
803
804
805

	pool = [[OFAutoreleasePool alloc] init];

	cacheString = [OFMutableString stringWithCString: [cache cArray]
						  length: [cache count]];
	[cacheString deleteEnclosingWhitespaces];
	/* Prevent a useless copy later */
	[cacheString makeImmutable];

	cacheCString = [cacheString cString];
	cacheLength = [cacheString cStringLength];

	if ((tmp = memchr(cacheCString, ':', cacheLength)) != NULL) {
		attributeName = [[OFString alloc]
		    initWithCString: tmp + 1

Modified src/base64.m from [469ffb49bd] to [ed05504ebf].

83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102

		[ret appendCString: tb
			withLength: 4];

		break;
	}

	/*
	 * Class swizzle the string to be immutable. We declared the return type
	 * to be OFString*, so it can't be modified anyway. But not swizzling it
	 * would create a real copy each time -[copy] is called.
	 */
	ret->isa = [OFString class];
	return ret;
}

BOOL
of_base64_decode(OFDataArray *data, const char *string, size_t length)
{
	const uint8_t *buffer = (const uint8_t*)string;







<
|
|
<
<
<







83
84
85
86
87
88
89

90
91



92
93
94
95
96
97
98

		[ret appendCString: tb
			withLength: 4];

		break;
	}


	[ret makeImmutable];




	return ret;
}

BOOL
of_base64_decode(OFDataArray *data, const char *string, size_t length)
{
	const uint8_t *buffer = (const uint8_t*)string;