ObjFW  Check-in [af56ce47e0]

Overview
Comment:Compare pointers of strings before comparing the string content.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: af56ce47e0ec219e1a19b260195287ac701882dba18f275deba8cf67c308f321
User & Date: js on 2012-01-24 11:57:45
Other Links: manifest | tags
Context
2012-01-24
12:01
Cache hashes of strings. check-in: a0d967e8dd user: js tags: trunk
11:57
Compare pointers of strings before comparing the string content. check-in: af56ce47e0 user: js tags: trunk
2012-01-08
02:03
More methods for OFArray and OFMutableArray. check-in: 72efa4f4f3 user: js tags: trunk
Changes

Modified src/OFString.m from [e0f353ec6a] to [3219cfa2ad].

1032
1033
1034
1035
1036
1037
1038



1039
1040
1041
1042
1043
1044
1045

- (BOOL)isEqual: (id)object
{
	OFAutoreleasePool *pool;
	OFString *otherString;
	const of_unichar_t *unicodeString, *otherUnicodeString;
	size_t length;




	if (![object isKindOfClass: [OFString class]])
		return NO;

	otherString = object;
	length = [self length];








>
>
>







1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048

- (BOOL)isEqual: (id)object
{
	OFAutoreleasePool *pool;
	OFString *otherString;
	const of_unichar_t *unicodeString, *otherUnicodeString;
	size_t length;

	if (object == self)
		return YES;

	if (![object isKindOfClass: [OFString class]])
		return NO;

	otherString = object;
	length = [self length];

1075
1076
1077
1078
1079
1080
1081



1082
1083
1084
1085
1086
1087
1088
- (of_comparison_result_t)compare: (id)object
{
	OFAutoreleasePool *pool;
	OFString *otherString;
	const of_unichar_t *unicodeString, *otherUnicodeString;
	size_t i, minimumLength;




	if (![object isKindOfClass: [OFString class]])
		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];

	otherString = object;
	minimumLength = ([self length] > [otherString length]
	    ? [otherString length] : [self length]);







>
>
>







1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
- (of_comparison_result_t)compare: (id)object
{
	OFAutoreleasePool *pool;
	OFString *otherString;
	const of_unichar_t *unicodeString, *otherUnicodeString;
	size_t i, minimumLength;

	if (object == self)
		return OF_ORDERED_SAME;

	if (![object isKindOfClass: [OFString class]])
		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];

	otherString = object;
	minimumLength = ([self length] > [otherString length]
	    ? [otherString length] : [self length]);
1115
1116
1117
1118
1119
1120
1121



1122
1123
1124
1125
1126
1127
1128
}

- (of_comparison_result_t)caseInsensitiveCompare: (OFString*)otherString
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	const of_unichar_t *string, *otherUnicodeString;
	size_t i, length, otherLength, minimumLength;




	string = [self unicodeString];
	otherUnicodeString = [otherString unicodeString];
	length = [self length];
	otherLength = [otherString length];

	minimumLength = (length > otherLength ? otherLength : length);







>
>
>







1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
}

- (of_comparison_result_t)caseInsensitiveCompare: (OFString*)otherString
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	const of_unichar_t *string, *otherUnicodeString;
	size_t i, length, otherLength, minimumLength;

	if (otherString == self)
		return OF_ORDERED_SAME;

	string = [self unicodeString];
	otherUnicodeString = [otherString unicodeString];
	length = [self length];
	otherLength = [otherString length];

	minimumLength = (length > otherLength ? otherLength : length);

Modified src/OFString_UTF8.m from [38887f119f] to [53d2bab608].

585
586
587
588
589
590
591



592
593
594
595
596
597
598
							    selector: _cmd];
	}
}

- (BOOL)isEqual: (id)object
{
	OFString_UTF8 *otherString;




	if (![object isKindOfClass: [OFString class]])
		return NO;

	otherString = object;

	if ([otherString UTF8StringLength] != s->cStringLength ||







>
>
>







585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
							    selector: _cmd];
	}
}

- (BOOL)isEqual: (id)object
{
	OFString_UTF8 *otherString;

	if (object == self)
		return YES;

	if (![object isKindOfClass: [OFString class]])
		return NO;

	otherString = object;

	if ([otherString UTF8StringLength] != s->cStringLength ||
607
608
609
610
611
612
613



614
615
616
617
618
619
620

- (of_comparison_result_t)compare: (id)object
{
	OFString *otherString;
	size_t otherCStringLength, minimumCStringLength;
	int compare;




	if (![object isKindOfClass: [OFString class]])
		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];

	otherString = object;
	otherCStringLength = [otherString UTF8StringLength];
	minimumCStringLength = (s->cStringLength > otherCStringLength







>
>
>







610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626

- (of_comparison_result_t)compare: (id)object
{
	OFString *otherString;
	size_t otherCStringLength, minimumCStringLength;
	int compare;

	if (object == self)
		return OF_ORDERED_SAME;

	if (![object isKindOfClass: [OFString class]])
		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];

	otherString = object;
	otherCStringLength = [otherString UTF8StringLength];
	minimumCStringLength = (s->cStringLength > otherCStringLength
636
637
638
639
640
641
642



643
644
645
646
647
648
649
}

- (of_comparison_result_t)caseInsensitiveCompare: (OFString*)otherString
{
	const char *otherCString;
	size_t i, j, otherCStringLength, minimumCStringLength;
	int compare;




	if (![otherString isKindOfClass: [OFString class]])
		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];

	otherCString = [otherString UTF8String];
	otherCStringLength = [otherString UTF8StringLength];







>
>
>







642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
}

- (of_comparison_result_t)caseInsensitiveCompare: (OFString*)otherString
{
	const char *otherCString;
	size_t i, j, otherCStringLength, minimumCStringLength;
	int compare;

	if (otherString == self)
		return OF_ORDERED_SAME;

	if (![otherString isKindOfClass: [OFString class]])
		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];

	otherCString = [otherString UTF8String];
	otherCStringLength = [otherString UTF8StringLength];