ObjFW  View Ticket

Ticket UUID: c34a429b8cd54bc99eaad51fa400932cf48db300
Title: Optimize initWithContentsOfURI: with file: URIs
Status: Open Type: Enhancement
Severity: Minor Priority: Medium
Subsystem: Resolution:
Last Modified: 2022-10-20 16:41:25
Version Found In: Milestone: none
User Comments:
js added on 2022-10-20 16:41:25:

Currently this goes through the OFURIHandler for file:. This means the generic code is used that grows a buffer, while -[initWithContentsOfFile:] is more optimized and only needs to allocate the buffer once. It would make sense to either add a specialization to fall back to -[initWithContentsOfFile:] on file: or to generalize it and always check if the returned stream is a OFSeekableStream, allowing to just seek to the end of the stream to get its size. However, for networked protocols, that might have negative performance implications, so it might be safer to just add a specialization for file:.