ObjFW  Check-in [deea33a4d9]

Overview
Comment:Implement -[hash] for OFArray.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: deea33a4d959aa7b2712061c76447b17c15a7131b5b32608347aef54ededafe8
User & Date: js on 2009-10-16 10:46:27
Other Links: manifest | tags
Context
2009-10-17
20:09
Update TODO. check-in: 60e4985929 user: js tags: trunk
2009-10-16
10:46
Implement -[hash] for OFArray. check-in: deea33a4d9 user: js tags: trunk
08:44
OFMutableString's -[upper] and -[lower]: Get rid of code duplication. check-in: 8389241a05 user: js tags: trunk
Changes

Modified src/OFArray.m from [04cd287505] to [cf7588aa90].

11
12
13
14
15
16
17

18
19
20
21
22
23
24
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25







+








#include "config.h"

#include <stdarg.h>

#import "OFArray.h"
#import "OFExceptions.h"
#import "OFMacros.h"

@implementation OFArray
+ array
{
	return [[[self alloc] init] autorelease];
}

228
229
230
231
232
233
234
235
236
237



238
239
















240
229
230
231
232
233
234
235

236
237
238
239
240


241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257







-


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


- removeNObjects: (size_t)nobjects
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
}

/* FIXME: Implement!
- (uint32_t)hash
{
	OFObject **carray = [array cArray];
	size_t i, count = [array count];
	uint32_t hash;
}
*/

	OF_HASH_INIT(hash);

	for (i = 0; i < count; i++) {
		uint32_t h = [carray[i] hash];

		OF_HASH_ADD(hash, h >> 24);
		OF_HASH_ADD(hash, (h >> 16) & 0xFF);
		OF_HASH_ADD(hash, (h >> 8) & 0xFF);
		OF_HASH_ADD(hash, h & 0xFF);
	}

	OF_HASH_FINALIZE(hash);

	return hash;
}
@end

Modified src/OFMutableString.m from [feeaa349e9] to [b1198e7c3f].

43
44
45
46
47
48
49
50
51


52
53
54
55
56
57
58
59
60
61
43
44
45
46
47
48
49


50
51

52

53
54
55
56
57
58
59







-
-
+
+
-

-







	size_t i, j, d;
	char *nstr;

	if (!is_utf8) {
		uint8_t *p = (uint8_t*)*string + *length;
		uint8_t t;

		while (--p >= (uint8_t*)*string) {
			t = table[0][*p];
		while (--p >= (uint8_t*)*string)
			if ((t = table[0][*p]) != 0)
			if (t != 0)
				*p = t;
		}

		return;
	}

	ulen = [self length];
	ustr = [self allocMemoryForNItems: [self length]
				 withSize: ulen];