ObjFW  Check-in [8c4adb2599]

Overview
Comment:Improve performance of OFArray's +[arrayWithCArray:].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 8c4adb259935edab07737e87a5efa5b4d4628e1302ef841169cd8b8aa18e70a1
User & Date: js on 2010-04-17 13:44:35
Other Links: manifest | tags
Context
2010-04-17
15:46
Don't return self where not necessary, return void or something useful. check-in: 062a052b50 user: js tags: trunk
13:44
Improve performance of OFArray's +[arrayWithCArray:]. check-in: 8c4adb2599 user: js tags: trunk
13:29
Reduce memory usage of OFDictionary and fix hashing. check-in: d46212a8cd user: js tags: trunk
Changes

Modified src/OFArray.m from [89b8c0adc9] to [f9679701a3].

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

153
154

155
156
157





158



159
160
161
162
163
164
165
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
153
154
155
156
157

158
159


160
161

162



163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178







+


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

+
+
+










-
+

-
-
+

-
+
-
-
-
+
+
+
+
+

+
+
+








	return self;
}

- initWithCArray: (OFObject**)objs
{
	id *obj;
	size_t count;

	self = [self init];

	@try {
		for (obj = objs; *obj != nil; obj++) {
	
	count = 0;

	for (obj = objs; *obj != nil; obj++) {
			[array addItem: obj];
			[*obj retain];
		}
		[*obj retain];
		count++;
	}

	@try {
		[array addNItems: count
		      fromCArray: objs];
	} @catch (OFException *e) {
		for (obj = objs; *obj != nil; obj++)
			[*obj release];

		[self dealloc];
		@throw e;
	}

	return self;
}

- initWithCArray: (OFObject**)objs
	  length: (size_t)len
{
	self = [self init];
	size_t i;

	@try {
		size_t i;
	self = [self init];

		for (i = 0; i < len; i++) {
	for (i = 0; i < len; i++)
			[array addItem: objs + i];
			[objs[i] retain];
		}
		[objs[i] retain];

	@try {
		[array addNItems: len
		      fromCArray: objs];
	} @catch (OFException *e) {
		for (i = 0; i < len; i++)
			[objs[i] release];

		[self dealloc];
		@throw e;
	}

	return self;
}