ObjFW  Check-in [13eb2bf77b]

Overview
Comment:OFRunLoop: Remove the key for the stream.

As the stream is used as a key, this references the stream. This
resulted in the stream never being deallocated, even though it was not
used anymore. The advantage of not removing it was that the next async
read on the stream would have been slightly faster by saving one malloc.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 13eb2bf77b53debb37f5d59c466c172650e24c3f4f99cb85d3655fd90d9c768c
User & Date: js on 2012-09-14 05:36:54
Other Links: manifest | tags
Context
2012-09-14
06:09
Add -[OFObject performSelector:afterDelay:]. check-in: 5e067285c8 user: js tags: trunk
05:36
OFRunLoop: Remove the key for the stream. check-in: 13eb2bf77b user: js tags: trunk
05:24
Create a pool for -[applicationDidFinishLaunching] check-in: bba061e4b7 user: js tags: trunk
Changes

Modified src/OFRunLoop.m from [0049670d02] to [317802665c].

214
215
216
217
218
219
220
221
222


223
224
225
226
227
228
229
230
231
232
233
234
235
236
237


238
239
240
241
242
243
244
		void *buffer = [queueItem buffer];
		size_t length = [stream readIntoBuffer: buffer
						length: [queueItem length]];

		if (![queueItem block](stream, buffer, length)) {
			[queue removeListObject: listObject];

			if ([queue count] == 0)
				[streamObserver removeStreamForReading: stream];


		}
	} else if ([listObject->object isKindOfClass:
	    [OFRunLoop_ReadLineQueueItem class]]) {
		OFRunLoop_ReadLineQueueItem *queueItem = listObject->object;
		OFString *line;

		line = [stream tryReadLineWithEncoding: [queueItem encoding]];

		if (line != nil || [stream isAtEndOfStream]) {
			if (![queueItem block](stream, line)) {
				[queue removeListObject: listObject];

				if ([queue count] == 0)
					[streamObserver
					    removeStreamForReading: stream];


			}
		}
	} else
		OF_ENSURE(0);
}
#endif








|

>
>












|


>
>







214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
		void *buffer = [queueItem buffer];
		size_t length = [stream readIntoBuffer: buffer
						length: [queueItem length]];

		if (![queueItem block](stream, buffer, length)) {
			[queue removeListObject: listObject];

			if ([queue count] == 0) {
				[streamObserver removeStreamForReading: stream];
				[readQueues removeObjectForKey: stream];
			}
		}
	} else if ([listObject->object isKindOfClass:
	    [OFRunLoop_ReadLineQueueItem class]]) {
		OFRunLoop_ReadLineQueueItem *queueItem = listObject->object;
		OFString *line;

		line = [stream tryReadLineWithEncoding: [queueItem encoding]];

		if (line != nil || [stream isAtEndOfStream]) {
			if (![queueItem block](stream, line)) {
				[queue removeListObject: listObject];

				if ([queue count] == 0) {
					[streamObserver
					    removeStreamForReading: stream];
					[readQueues removeObjectForKey: stream];
				}
			}
		}
	} else
		OF_ENSURE(0);
}
#endif