ObjFW  Check-in [e1b790cdfe]

Overview
Comment:Improve readability of -[initWithDictionary:].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: e1b790cdfe70707a0250abc2e57cba989e5f75f51b2913fbfd6eba116c164dd6
User & Date: js on 2009-12-05 16:54:33
Other Links: manifest | tags
Context
2009-12-05
17:15
Improve -[initWithObjects:forKeys:]. check-in: f6e79c23b4 user: js tags: trunk
16:54
Improve readability of -[initWithDictionary:]. check-in: e1b790cdfe user: js tags: trunk
16:52
Improve error handling in OFDictionary and OFMutableDictionary. check-in: 0fcd9ed4d3 user: js tags: trunk
Changes

Modified src/OFDictionary.m from [0f7a7ffebd] to [6ffe55f0db].

114
115
116
117
118
119
120


121
122

123

124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
		@throw e;
	}

	size = dict->size;
	count = dict->count;

	for (i = 0; i < size; i++) {


		if (dict->data[i].key != nil) {
			OFObject <OFCopying> *key;



			@try {
				key = [dict->data[i].key copy];
			} @catch (OFException *e) {
				[self dealloc];
				@throw e;
			}

			@try {
				[dict->data[i].object retain];
			} @catch (OFException *e) {
				[key release];
				[self dealloc];
				@throw e;
			}

			data[i].key = key;
			data[i].object = dict->data[i].object;
			data[i].hash = dict->data[i].hash;
		} else
			data[i].key = nil;
	}

	return self;
}

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







>
>
|
|
>
|
>
|
|
|
|
|
|

|
|
|
|
|
|
|

|
|
|
<
<







114
115
116
117
118
119
120
121
122
123
124
125
126
127
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
		@throw e;
	}

	size = dict->size;
	count = dict->count;

	for (i = 0; i < size; i++) {
		OFObject <OFCopying> *key;

		if (dict->data[i].key == nil) {
			data[i].key = nil;
			continue;
		}

		@try {
			key = [dict->data[i].key copy];
		} @catch (OFException *e) {
			[self dealloc];
			@throw e;
		}

		@try {
			[dict->data[i].object retain];
		} @catch (OFException *e) {
			[key release];
			[self dealloc];
			@throw e;
		}

		data[i].key = key;
		data[i].object = dict->data[i].object;
		data[i].hash = dict->data[i].hash;


	}

	return self;
}

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