Index: src/OFDictionary.m ================================================================== --- src/OFDictionary.m +++ src/OFDictionary.m @@ -147,12 +147,31 @@ } - initWithObject: (OFObject*)obj forKey: (OFObject *)key { + uint32_t i; + self = [self init]; + @try { + data = [self allocMemoryForNItems: 2 + withSize: BUCKET_SIZE]; + } @catch (OFException *e) { + /* + * We can't use [super dealloc] on OS X here. Compiler bug? + * Anyway, we didn't do anything yet anyway, so [self dealloc] + * works. + */ + [self dealloc]; + @throw e; + } + memset(data, 0, 2 * BUCKET_SIZE); + size = 2; + + i = [key hash] & 1; + @try { key = [key copy]; } @catch (OFException *e) { [self dealloc]; @throw e; @@ -164,13 +183,14 @@ [key release]; [self dealloc]; @throw e; } - data[0].key = key; - data[0].object = obj; - data[0].hash = [key hash]; + data[i].key = key; + data[i].object = obj; + data[i].hash = [key hash]; + count = 1; return self; } - initWithObjects: (OFArray*)objs