ObjFW  Check-in [50a6d34eff]

Overview
Comment:Small string optimization.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 50a6d34eff04c19a1f8cc7aebf9a090502aaa9625f42c2ac16944c3c5dbde9e1
User & Date: js on 2011-04-27 16:14:39
Other Links: manifest | tags
Context
2011-04-27
21:29
Fix a typo in -[description] of OFConnectionFailedException. check-in: ffb574eb74 user: js tags: trunk
16:14
Small string optimization. check-in: 50a6d34eff user: js tags: trunk
2011-04-25
22:54
Actually, it's called charset in the header, not encoding. check-in: 7d29241068 user: js tags: trunk
Changes

Modified src/OFString.m from [ac1b639bcb] to [e3d5101e79].

766
767
768
769
770
771
772



773
774
775
776
777
778
779
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782







+
+
+







{
	return string;
}

- (size_t)length
{
	/* FIXME: Maybe cache this in an ivar? */

	if (![self isUTF8])
		return length;

	return of_string_position_to_index(string, length);
}

- (size_t)cStringLength
{
	return length;

Modified src/OFXMLParser.m from [852bd85a55] to [b060def371].

46
47
48
49
50
51
52
53
54
55
56
57
58
59

60
61
62
63
64



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79


80
81
82


83
84
85
86
87
88
89
90
46
47
48
49
50
51
52







53
54




55
56
57



58











59
60



61
62

63
64
65
66
67
68
69







-
-
-
-
-
-
-
+

-
-
-
-
+
+
+
-
-
-

-
-
-
-
-
-
-
-
-
-
-
+
+
-
-
-
+
+
-







{
	[cache replaceOccurrencesOfString: @"\r\n"
			       withString: @"\n"];
	[cache replaceOccurrencesOfString: @"\r"
			       withString: @"\n"];

	if (cut > 0) {
		/*
		 * We need to create a mutable copy in order to detect possible
		 * UTF-8, as we never checked for UTF-8 when appending to the
		 * cache for performance reasons.
		 */
		OFMutableString *ret = [[cache mutableCopy] autorelease];
		size_t length;
		size_t length = [cache length];

		length = [ret length];
		[ret deleteCharactersFromIndex: length - cut
				       toIndex: length];

		[cache deleteCharactersFromIndex: length - cut
					 toIndex: length];
	}
		if (unescape)
			return [ret stringByXMLUnescapingWithDelegate:
			    delegate];

		/*
		 * Class swizzle the string to be immutable. We pass it as
		 * 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;
	} else {
		if (unescape)
			return [cache stringByXMLUnescapingWithDelegate:
	if (unescape)
		return [cache stringByXMLUnescapingWithDelegate: delegate];
			    delegate];
		else
			return [[cache copy] autorelease];
	else
		return [[cache copy] autorelease];
	}
}

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