ObjFW  Check-in [d68dc5201f]

Overview
Comment:Improve -[isEqual:] of OFList.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: d68dc5201fcde74883ee3d5be69b6f0e7a7d51c34e3439699ec6e2f43a6b25f8
User & Date: js on 2009-08-28 00:18:54
Other Links: manifest | tags
Context
2009-08-28
00:33
Add OF_BSWAP{16,32,64}_IF_{BE,LE} for conditional byte swap. check-in: 30f6c422ad user: js tags: trunk
00:18
Improve -[isEqual:] of OFList. check-in: d68dc5201f user: js tags: trunk
00:18
Prevent updating a hash after it has been calculated. check-in: 5bf0f17e80 user: js tags: trunk
Changes

Modified src/OFList.m from [3dcb760b24] to [6526cc451e].

1
2
3
4
5
6
7
8
9
10
11
12
13


14
15
16
17
18
19
20
/*
 * Copyright (c) 2008 - 2009
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of libobjfw. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */

#include "config.h"



#import "OFList.h"
#import "OFExceptions.h"

@implementation OFList
+ list
{
	return [[[self alloc] init] autorelease];













>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/*
 * Copyright (c) 2008 - 2009
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of libobjfw. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */

#include "config.h"

#include "assert.h"

#import "OFList.h"
#import "OFExceptions.h"

@implementation OFList
+ list
{
	return [[[self alloc] init] autorelease];
210
211
212
213
214
215
216



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

- (BOOL)isEqual: (id)obj
{
	of_list_object_t *iter, *iter2;

	if (![obj isKindOfClass: [OFList class]])
		return NO;




	for (iter = first, iter2 = [obj first]; iter != NULL && iter2 != NULL;
	    iter = iter->next, iter2 = iter2->next)
		if (![iter->object isEqual: iter2->object])
			return NO;

	/* One has still items */
	if (iter != NULL || iter2 != NULL)
		return NO;

	return YES;
}

- (id)copy
{
	OFList *new;







>
>
>






|
|
<







212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229

230
231
232
233
234
235
236

- (BOOL)isEqual: (id)obj
{
	of_list_object_t *iter, *iter2;

	if (![obj isKindOfClass: [OFList class]])
		return NO;

	if ([obj count] != count)
		return NO;

	for (iter = first, iter2 = [obj first]; iter != NULL && iter2 != NULL;
	    iter = iter->next, iter2 = iter2->next)
		if (![iter->object isEqual: iter2->object])
			return NO;

	/* One is bigger than the other although we checked the count */
	assert(iter == NULL && iter2 == NULL);


	return YES;
}

- (id)copy
{
	OFList *new;