ObjFW  Check-in [776cc1c033]

Overview
Comment:Improve -[initWithObject:forKey:].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 776cc1c033c2bcbd840e21328cb4febd8244fc851a44d410fbab1f4c4b2d71f6
User & Date: js on 2009-12-05 16:43:07
Other Links: manifest | tags
Context
2009-12-05
16:52
Improve error handling in OFDictionary and OFMutableDictionary. check-in: 0fcd9ed4d3 user: js tags: trunk
16:43
Improve -[initWithObject:forKey:]. check-in: 776cc1c033 user: js tags: trunk
16:33
Improve OFDictionary. check-in: 725b23f325 user: js tags: trunk
Changes

Modified src/OFDictionary.m from [be94e8c683] to [f6cebc6bb3].

128
129
130
131
132
133
134
135
136
137
138
139
140





141


142

143
144
145
146




147
148
149
150
151
152
153

	return self;
}

- initWithObject: (OFObject*)obj
	  forKey: (OFObject <OFCopying>*)key
{
	const SEL sel = @selector(setObject:forKey:);
	IMP set = [OFMutableDictionary instanceMethodForSelector: sel];

	self = [self init];

	@try {





		set(self, sel, obj, key);


	} @catch (OFException *e) {

		[self dealloc];
		@throw e;
	}





	return self;
}

/* FIXME: Do it without resizing! */
- initWithObjects: (OFArray*)objs
	  forKeys: (OFArray*)keys
{







<
<
<



>
>
>
>
>
|
>
>

>




>
>
>
>







128
129
130
131
132
133
134



135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162

	return self;
}

- initWithObject: (OFObject*)obj
	  forKey: (OFObject <OFCopying>*)key
{



	self = [self init];

	@try {
		key = [key copy];
	} @catch (OFException *e) {
		[self dealloc];
		@throw e;
	}

	@try {
		[obj retain];
	} @catch (OFException *e) {
		[key release];
		[self dealloc];
		@throw e;
	}

	data[0].key = key;
	data[0].object = obj;
	data[0].hash = [key hash];

	return self;
}

/* FIXME: Do it without resizing! */
- initWithObjects: (OFArray*)objs
	  forKeys: (OFArray*)keys
{